/* PréstoYa – estilos (móvil primero · claro / oscuro / automático) */

/* ------------------------------------------------------------------ tokens: claro */
:root {
  --bg: #F4F5F7;
  --sup: #FFFFFF;
  --sup-2: #F0F1F4;          /* relleno sutil (controles segmentados, cajas internas) */
  --texto: #16181D;
  --muted: #6B7280;
  --borde: #E5E7EB;
  --oro: #EF9F27;            /* SOLO logo, botón + y pestaña activa */
  --oro-sombra: rgba(239, 159, 39, .35);
  --primario: #16181D;       /* botón principal: neutro, tipo banca */
  --primario-texto: #FFFFFF;

  /* colores con significado: tono fuerte + fondo suave */
  --azul: #1D4ED8;    --azul-bg: #E8EFFE;      /* capital */
  --ambar: #B45309;   --ambar-bg: #FEF3C7;     /* intereses pendientes */
  --verde: #15803D;   --verde-bg: #DCFCE7;     /* cobrado / al día */
  --morado: #6D28D9;  --morado-bg: #EDE9FE;    /* préstamos activos */
  --rojo: #DC2626;    --rojo-bg: #FEE2E2;      /* vencido / peligro */
  --gris-bg: #F0F1F4;

  --sombra: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
  --radio: 16px;
  color-scheme: light;
}

/* ------------------------------------------------------------------ tokens: oscuro */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121418; --sup: #1C1F25; --sup-2: #242830;
    --texto: #F3F4F6; --muted: #9CA3AF; --borde: #2A2E36;
    --primario: #F3F4F6; --primario-texto: #121418;
    --azul: #93B4FD;   --azul-bg: #1A2744;
    --ambar: #FBBF24;  --ambar-bg: #3A2A0C;
    --verde: #4ADE80;  --verde-bg: #12301E;
    --morado: #C4B5FD; --morado-bg: #2A2048;
    --rojo: #F87171;   --rojo-bg: #3C1818;
    --gris-bg: #242830;
    --sombra: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121418; --sup: #1C1F25; --sup-2: #242830;
  --texto: #F3F4F6; --muted: #9CA3AF; --borde: #2A2E36;
  --primario: #F3F4F6; --primario-texto: #121418;
  --azul: #93B4FD;   --azul-bg: #1A2744;
  --ambar: #FBBF24;  --ambar-bg: #3A2A0C;
  --verde: #4ADE80;  --verde-bg: #12301E;
  --morado: #C4B5FD; --morado-bg: #2A2048;
  --rojo: #F87171;   --rojo-bg: #3C1818;
  --gris-bg: #242830;
  --sombra: none;
  color-scheme: dark;
}

/* ------------------------------------------------------------------ base */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--texto);
  font: 16px/1.45 system-ui, -apple-system, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  min-height: 100dvh;
}
/* transición suave de 200 ms al cambiar de tema */
body, .cabecera, .nav, .tarjeta, .kpi, .caja, .modal, input, select, textarea, .btn, .seg, .badge, .chip, .fila {
  transition: background-color .2s ease, color .2s ease, border-color .2s ease;
}
h1, h2, h3 { color: var(--texto); line-height: 1.2; margin: 0 0 .5rem; letter-spacing: -.01em; }
h1 { font-size: 1.5rem; font-weight: 750; }
h2 { font-size: .8rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin: 1.6rem 0 .6rem; }
h3 { font-size: 1.02rem; font-weight: 650; }
p { margin: .25rem 0; }
a { color: inherit; }
.muted { color: var(--muted); }
small { font-size: .82rem; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
[hidden] { display: none !important; }
.volver { display: inline-flex; align-items: center; min-height: 44px; color: var(--muted); text-decoration: none; font-weight: 600; }

/* ------------------------------------------------------------------ cabecera */
.cabecera {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: .7rem;
  padding: calc(.6rem + env(safe-area-inset-top)) 16px .6rem;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px);
}
.cab-logo { border-radius: 10px; flex: none; }
.cab-titulo { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
.cab-titulo strong { font-size: 1.05rem; font-weight: 750; letter-spacing: -.01em; }
.cab-titulo small { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.campana {
  position: relative; width: 44px; height: 44px; border-radius: 50%; flex: none;
  display: grid; place-items: center; border: 1px solid var(--borde); cursor: pointer;
  background: var(--sup); color: var(--texto); box-shadow: var(--sombra);
}
.campana svg { width: 22px; height: 22px; }
.campana .punto {
  position: absolute; top: -3px; right: -3px; min-width: 20px; height: 20px; padding: 0 5px;
  border-radius: 99px; background: var(--rojo); color: #fff; font-size: .7rem; font-weight: 700;
  display: grid; place-items: center; border: 2px solid var(--bg);
}

/* ------------------------------------------------------------------ contenido */
.contenido { padding: 12px 16px calc(104px + env(safe-area-inset-bottom)); max-width: 760px; margin: 0 auto; }
.contenido.ancho { max-width: 980px; padding-bottom: 48px; }
.cargando { text-align: center; padding: 3rem 0; color: var(--muted); }

/* ------------------------------------------------------------------ tarjetas */
.tarjeta { background: var(--sup); border: 1px solid var(--borde); border-radius: var(--radio); padding: 16px; box-shadow: var(--sombra); }
.lista { display: grid; gap: 10px; }
.caja { background: var(--sup); border: 1px solid var(--borde); border-radius: var(--radio); box-shadow: var(--sombra); overflow: hidden; }

/* KPIs 2×2 */
.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 720px) { .kpis.cuatro { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.kpi { background: var(--sup); border: 1px solid var(--borde); border-radius: var(--radio); padding: 14px; box-shadow: var(--sombra); min-width: 0; }
.kpi .ico { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; margin-bottom: 10px; }
.kpi .ico svg { width: 20px; height: 20px; }
.kpi span, .kpi .etq { display: block; color: var(--muted); font-size: .78rem; font-weight: 500; }
.kpi strong { display: block; font-size: 1.32rem; font-weight: 750; letter-spacing: -.02em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; margin-top: 2px; }
.kpi small { color: var(--muted); font-size: .75rem; }
.c-azul .ico { background: var(--azul-bg); color: var(--azul); }
.c-ambar .ico { background: var(--ambar-bg); color: var(--ambar); }
.c-verde .ico { background: var(--verde-bg); color: var(--verde); }
.c-morado .ico { background: var(--morado-bg); color: var(--morado); }
.c-rojo .ico { background: var(--rojo-bg); color: var(--rojo); }
.t-azul { color: var(--azul); } .t-ambar { color: var(--ambar); } .t-verde { color: var(--verde); } .t-morado { color: var(--morado); } .t-rojo { color: var(--rojo); }

/* ------------------------------------------------------------------ botones */
.btn {
  appearance: none; border: 1px solid var(--borde); background: var(--sup); color: var(--texto);
  font: inherit; font-weight: 650; padding: .65rem 1rem; border-radius: 12px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; text-decoration: none;
  min-height: 44px; min-width: 44px;
}
.btn:active { transform: scale(.98); }
.btn.primario { background: var(--primario); border-color: var(--primario); color: var(--primario-texto); }
.btn.peligro { color: var(--rojo); border-color: color-mix(in srgb, var(--rojo) 35%, var(--borde)); }
.btn.ghost { background: transparent; }
.btn.peq { padding: .45rem .8rem; font-size: .9rem; border-radius: 10px; }
.btn.grande { width: 100%; padding: .9rem 1rem; font-size: 1.02rem; border-radius: 14px; min-height: 52px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.acciones { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.acciones form { margin: 0; }

/* ------------------------------------------------------------------ formularios */
.form { display: grid; gap: 14px; }
.form label { display: grid; gap: 6px; font-size: .85rem; font-weight: 600; color: var(--muted); }
input, select, textarea {
  font: inherit; color: var(--texto); background: var(--sup); width: 100%;
  border: 1px solid var(--borde); border-radius: 12px; padding: .7rem .85rem; min-height: 48px;
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .7; }
textarea { min-height: 76px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--azul); outline-offset: 0; border-color: transparent; }
.btn:focus-visible, .seg button:focus-visible, .chip:focus-visible, .nav a:focus-visible, .nav button:focus-visible { outline: 2px solid var(--azul); outline-offset: 2px; }
.rejilla { grid-template-columns: 1fr; }
@media (min-width: 640px) { .rejilla { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: end; } }
.buscador { position: sticky; top: calc(64px + env(safe-area-inset-top)); z-index: 5; display: flex; gap: 8px; padding: 4px 0 10px; background: var(--bg); }
.buscador input, .buscador select { flex: 1; min-width: 0; }
.buscador.estatico { position: static; padding: 0; background: none; }
.campo-fijo { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: .55rem .85rem; background: var(--sup-2); border-radius: 12px; color: var(--texto); font-weight: 600; }
.campo-fijo small { color: var(--muted); font-weight: 500; margin-left: auto; }
#form-socio { display: flex; margin-top: 10px; }

/* control segmentado */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; background: var(--sup-2); padding: 4px; border-radius: 13px; }
.seg button {
  appearance: none; border: 0; background: transparent; color: var(--muted); font: inherit; font-weight: 600; font-size: .88rem;
  min-height: 44px; padding: .45rem .3rem; border-radius: 10px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.seg button svg { width: 18px; height: 18px; flex: none; }
.seg button.on { background: var(--sup); color: var(--texto); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1px solid var(--borde); background: var(--sup); color: var(--texto); border-radius: 99px; min-height: 44px; padding: .35rem 1rem; font: inherit; font-size: .9rem; font-weight: 600; cursor: pointer; }
.chip.on { background: var(--primario); border-color: var(--primario); color: var(--primario-texto); }

/* ------------------------------------------------------------------ alertas e insignias */
.alerta { padding: .8rem 1rem; border-radius: 12px; margin: 0 0 12px; font-weight: 500; font-size: .93rem; }
.alerta.error { background: var(--rojo-bg); color: var(--rojo); }
.alerta.ok { background: var(--verde-bg); color: var(--verde); }
.alerta.aviso { background: var(--ambar-bg); color: var(--ambar); }
.alerta a { font-weight: 700; }
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: .74rem; font-weight: 700; padding: .25rem .6rem; border-radius: 99px; white-space: nowrap; line-height: 1.3; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.ok, .badge.verde { background: var(--verde-bg); color: var(--verde); }
.badge.aviso, .badge.ambar { background: var(--ambar-bg); color: var(--ambar); }
.badge.error, .badge.rojo { background: var(--rojo-bg); color: var(--rojo); }
.badge.morado { background: var(--morado-bg); color: var(--morado); }
.badge.azul { background: var(--azul-bg); color: var(--azul); }
.badge.neutro { background: var(--gris-bg); color: var(--muted); }

/* ------------------------------------------------------------------ filas */
.fila { display: flex; align-items: center; gap: 12px; padding: 12px 14px; text-decoration: none; min-height: 64px; color: inherit; }
.fila + .fila { border-top: 1px solid var(--borde); }
a.fila:active { background: var(--sup-2); }
.fila .cuerpo { flex: 1; min-width: 0; }
.fila .cuerpo strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 650; }
.fila .cuerpo small { color: var(--muted); display: block; }
.fila .der { text-align: right; flex: none; display: grid; justify-items: end; gap: 4px; }
.fila .der small { color: var(--muted); }
.fila-sup { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.empresa h3 { margin: 0; }
.sub { border-top: 1px dashed var(--borde); margin-top: 12px; padding-top: 12px; display: grid; gap: 12px; }

/* avatares pastel */
.av { width: 42px; height: 42px; border-radius: 50%; flex: none; display: grid; place-items: center; font-weight: 700; font-size: .95rem; }
.av.grande { width: 52px; height: 52px; font-size: 1.15rem; }
.av-0 { background: #DBEAFE; color: #1E40AF; } .av-1 { background: #DCFCE7; color: #166534; }
.av-2 { background: #EDE9FE; color: #5B21B6; } .av-3 { background: #FCE7F3; color: #9D174D; }
.av-4 { background: #CCFBF1; color: #115E59; } .av-5 { background: #FFEDD5; color: #9A3412; }
:root[data-theme="dark"] .av-0 { background: #1E3A8A; color: #DBEAFE; }
:root[data-theme="dark"] .av-1 { background: #14532D; color: #DCFCE7; }
:root[data-theme="dark"] .av-2 { background: #4C1D95; color: #EDE9FE; }
:root[data-theme="dark"] .av-3 { background: #831843; color: #FCE7F3; }
:root[data-theme="dark"] .av-4 { background: #134E4A; color: #CCFBF1; }
:root[data-theme="dark"] .av-5 { background: #7C2D12; color: #FFEDD5; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .av-0 { background: #1E3A8A; color: #DBEAFE; }
  :root:not([data-theme="light"]) .av-1 { background: #14532D; color: #DCFCE7; }
  :root:not([data-theme="light"]) .av-2 { background: #4C1D95; color: #EDE9FE; }
  :root:not([data-theme="light"]) .av-3 { background: #831843; color: #FCE7F3; }
  :root:not([data-theme="light"]) .av-4 { background: #134E4A; color: #CCFBF1; }
  :root:not([data-theme="light"]) .av-5 { background: #7C2D12; color: #FFEDD5; }
}

/* tarjeta de socio (pulsable) */
.socio { display: grid; gap: 12px; width: 100%; text-align: left; font: inherit; color: inherit; cursor: pointer; }
.socio:active { transform: scale(.99); }
.socio .cab { display: flex; align-items: center; gap: 12px; }
.socio .cab .cuerpo { flex: 1; min-width: 0; }
.socio .cab strong { display: block; font-weight: 650; }
.socio .cab small { color: var(--muted); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.barra { height: 8px; background: var(--sup-2); border-radius: 99px; overflow: hidden; }
.barra i { display: block; height: 100%; border-radius: 99px; background: var(--verde); transition: width .4s ease; }
.barra-pie { display: flex; justify-content: space-between; font-size: .78rem; color: var(--muted); margin-top: -4px; }

/* ------------------------------------------------------------------ préstamo */
.prestamo { display: grid; gap: 12px; }
.datos { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.datos div span { display: block; font-size: .76rem; color: var(--muted); }
.datos div strong { font-variant-numeric: tabular-nums; font-weight: 650; }
.prestamo.liquidado { opacity: .7; }
details { border-top: 1px solid var(--borde); padding-top: 4px; }
details summary { cursor: pointer; font-weight: 600; color: var(--muted); list-style: none; min-height: 44px; display: flex; align-items: center; }
details summary::-webkit-details-marker { display: none; }
details summary::before { content: "›"; display: inline-block; width: 1em; font-size: 1.2em; transition: transform .2s; }
details[open] summary::before { transform: rotate(90deg); }
.hist { width: 100%; border-collapse: collapse; font-size: .88rem; }
.hist td { padding: 8px 4px; border-bottom: 1px solid var(--borde); vertical-align: top; }
.hist tr:last-child td { border-bottom: 0; }
.hist td:first-child { color: var(--muted); white-space: nowrap; }
.hist td:last-child { text-align: right; }
.reparto { display: grid; gap: 7px; background: var(--sup-2); border-radius: 12px; padding: 14px; }
.reparto .linea { display: flex; justify-content: space-between; gap: 10px; }
.reparto .total { border-top: 1px solid var(--borde); padding-top: 8px; margin-top: 2px; font-weight: 700; }

/* ------------------------------------------------------------------ movimientos */
.mov .icono { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex: none; font-weight: 800; font-size: 1rem; }
.mov .icono.prestamo { background: var(--azul-bg); color: var(--azul); }
.mov .icono.abono { background: var(--verde-bg); color: var(--verde); }
.mov .icono.interes { background: var(--ambar-bg); color: var(--ambar); }
.positivo { color: var(--verde); }
.filtros { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 10px; }
.filtros .seg, .filtros .chips { grid-column: 1 / -1; }
.filtros input, .filtros select { min-height: 44px; padding: .55rem .6rem; font-size: .95rem; }

/* ------------------------------------------------------------------ estados vacíos */
.vacio { text-align: center; color: var(--muted); padding: 2rem 1rem; }
.vacio-tarjeta { text-align: center; padding: 28px 20px; display: grid; justify-items: center; gap: 8px; }
.vacio-tarjeta .ico { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; background: var(--sup-2); color: var(--muted); }
.vacio-tarjeta .ico svg { width: 28px; height: 28px; }
.vacio-tarjeta strong { font-size: 1.05rem; }
.vacio-tarjeta p { color: var(--muted); max-width: 32ch; margin-bottom: 6px; }

/* ------------------------------------------------------------------ barra inferior */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: end;
  background: var(--sup);
  border-top: 1px solid var(--borde);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
.nav a, .nav button {
  display: grid; justify-items: center; gap: 3px; text-decoration: none; color: var(--muted);
  font: inherit; font-size: .68rem; font-weight: 600; min-height: 48px; padding: 4px 0;
  background: none; border: 0; cursor: pointer; transition: color .2s;
}
.nav svg { width: 24px; height: 24px; }
.nav a.on { color: var(--oro); }
.nav .mas .circ {
  width: 56px; height: 56px; margin-top: -28px; border-radius: 50%;
  display: grid; place-items: center; background: var(--oro); color: #fff;
  box-shadow: 0 6px 16px var(--oro-sombra); border: 4px solid var(--sup);
  transition: transform .2s ease, border-color .2s ease;
}
.nav .mas .circ svg { width: 26px; height: 26px; }
.nav .mas[aria-expanded="true"] .circ { transform: rotate(45deg); }

/* ------------------------------------------------------------------ hojas (modal inferior) */
.modal-fondo { position: fixed; inset: 0; z-index: 50; background: rgba(10, 12, 16, .5); display: flex; align-items: flex-end; justify-content: center; animation: aparecer .2s ease; }
.modal { background: var(--bg); width: 100%; max-width: 560px; max-height: 92dvh; overflow: auto; border-radius: 22px 22px 0 0; padding: 10px 16px calc(18px + env(safe-area-inset-bottom)); animation: subir .25s cubic-bezier(.2, .8, .2, 1); }
.modal::before { content: ""; display: block; width: 40px; height: 5px; border-radius: 99px; background: var(--borde); margin: 0 auto 14px; }
@media (min-width: 640px) { .modal-fondo { align-items: center; } .modal { border-radius: 22px; } .modal::before { display: none; } }
.modal h2 { margin-top: 0; font-size: 1.15rem; text-transform: none; letter-spacing: -.01em; color: var(--texto); }
@keyframes aparecer { from { opacity: 0; } }
@keyframes subir { from { transform: translateY(40px); opacity: .6; } }
@media (prefers-reduced-motion: reduce) { .modal-fondo, .modal { animation: none; } * { transition: none !important; } }

/* menú rápido del + */
.menu-rapido { display: grid; gap: 8px; }
.menu-rapido a, .menu-rapido button {
  display: flex; align-items: center; gap: 14px; min-height: 64px; padding: 10px 14px; width: 100%;
  background: var(--sup); border: 1px solid var(--borde); border-radius: 14px;
  font: inherit; color: var(--texto); text-decoration: none; text-align: left; cursor: pointer;
}
.menu-rapido .ico { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; flex: none; }
.menu-rapido .ico svg { width: 22px; height: 22px; }
.menu-rapido strong { display: block; font-weight: 650; }
.menu-rapido small { color: var(--muted); }

/* avisos */
.aviso-item .ico { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex: none; }
.aviso-item .ico svg { width: 20px; height: 20px; }

/* ------------------------------------------------------------------ login */
.login { max-width: 400px; margin: 0 auto; padding: calc(56px + env(safe-area-inset-top)) 16px 32px; text-align: center; }
.login .form { text-align: left; margin-top: 24px; }
.login-logo { border-radius: 24px; box-shadow: 0 10px 30px rgba(239, 159, 39, .28); }
.login h1 { margin-top: 16px; font-size: 1.9rem; }

.toast { position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 60; background: var(--primario); color: var(--primario-texto); padding: .75rem 1.15rem; border-radius: 12px; font-weight: 600; box-shadow: 0 8px 24px rgba(0,0,0,.2); max-width: calc(100% - 32px); animation: aparecer .2s ease; }

/* ------------------------------------------------------------------ utilidades de maquetación */
.form-campo { display: grid; gap: 6px; }
.etq-campo { font-size: .85rem; font-weight: 600; color: var(--muted); }
.socio-cab { display: flex; align-items: center; gap: 12px; min-width: 0; }
.socio-cab h1, .socio-cab h2 { margin: 0; }
.modal .socio-cab { margin-bottom: 14px; }
.modal .socio-cab h2 { flex: 1; }
.kpis.espacio { margin-top: 14px; }
.nota { margin-top: 8px; }
.acciones.sin-margen { margin-top: 0; flex-wrap: nowrap; }
.menu-rapido { margin-bottom: 4px; }
.fila .acciones { margin-top: 0; }

/* ------------------------------------------------------------------ correcciones de ancho y colores de iconos */
.lista, .menu-rapido, .form { grid-template-columns: minmax(0, 1fr); }
.rejilla, .filtros { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 639px) { .rejilla:not(.filtros) { grid-template-columns: minmax(0, 1fr); } }
.lista > *, .menu-rapido > *, .form > * { min-width: 0; }
.socio { max-width: 100%; }
html, body { overflow-x: hidden; }
.ico.c-azul { background: var(--azul-bg); color: var(--azul); }
.ico.c-ambar { background: var(--ambar-bg); color: var(--ambar); }
.ico.c-verde { background: var(--verde-bg); color: var(--verde); }
.ico.c-morado { background: var(--morado-bg); color: var(--morado); }
.ico.c-rojo { background: var(--rojo-bg); color: var(--rojo); }
.socio { grid-template-columns: minmax(0, 1fr); box-sizing: border-box; }
.socio .cab .badge { flex: none; }
.socio .barra, .socio .barra-pie { width: 100%; }
.socio-cab > div { min-width: 0; }
.btn svg { width: 18px; height: 18px; flex: none; }
.socio .cab small { white-space: normal; }

/* ------------------------------------------------------------------ panel de superadministrador */
.c-oro .ico { background: linear-gradient(135deg, #F8DC9D, #EF9F27); color: #3D2606; }
.t-oro { color: #B7740B; }
:root[data-theme="dark"] .t-oro { color: #F5B544; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .t-oro { color: #F5B544; } }
.herramientas { display: grid; gap: 10px; margin: 18px 0 12px; }
.herramientas .chips { gap: 6px; }
.chip.on .cont { opacity: .8; }
.empresa .contacto { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; }
.btn.wa { color: #15803D; border-color: color-mix(in srgb, #15803D 35%, var(--borde)); }
:root[data-theme="dark"] .btn.wa { color: #4ADE80; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn.wa { color: #4ADE80; } }
.pagos { margin-top: 10px; }
.pagos .hist td:nth-child(2) { white-space: nowrap; }
.formulario-pago { background: var(--sup-2); border-radius: 14px; padding: 14px; display: grid; gap: 12px; margin-top: 12px; }
.formulario-pago h4 { margin: 0; font-size: .98rem; }
.cab-admin { display: flex; align-items: center; gap: .7rem; }
.cab-admin .salir { margin: 0; }
.fila-sup .cuerpo-emp { min-width: 0; }
.fila-sup .cuerpo-emp h3 { overflow-wrap: anywhere; }
.kpis.cuatro .kpi strong { font-size: 1.25rem; }
.oculto-etiqueta { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* =====================================================================
   RESPONSIVE · móvil (<600) · tablet (600–1024) · ordenador (>1024)
   ===================================================================== */
*, *::before, *::after { box-sizing: border-box; }
img, svg, video, canvas, table, input, select, textarea { max-width: 100%; }
html, body { max-width: 100%; overflow-x: hidden; }

/* zona segura (iPhone con notch / horizontal) */
.contenido { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); max-width: 1100px; }
.contenido.ancho { max-width: 1100px; }
.cabecera { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
.nav { padding-left: max(4px, env(safe-area-inset-left)); padding-right: max(4px, env(safe-area-inset-right)); }

/* ---- nombre de la empresa visible bajo el logo ---- */
.cab-titulo strong { font-size: 1.05rem; line-height: 1.15; }
.cab-empresa { color: var(--texto); font-size: .95rem; font-weight: 600; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-marca { display: none; }
.mas-txt { display: none; }
.nombre-emp { font-size: 1.2rem; font-weight: 750; line-height: 1.2; margin: 0; overflow-wrap: anywhere; }
.meta { color: var(--muted); font-size: .82rem; margin: 3px 0 0; line-height: 1.4; }
.form-empresa { margin-top: 14px; }

/* ---- KPIs: 2×2, números que siempre caben ---- */
.kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.kpi strong { font-size: clamp(20px, 6vw, 28px); line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .etq, .kpi small { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }

/* ---- insignias compactas ---- */
.badge { font-size: 12px; padding: 3px 8px; flex-shrink: 0; white-space: nowrap; }
.badge::before { width: 5px; height: 5px; }

/* ---- tarjeta de socio ---- */
.av { width: 44px; height: 44px; }
.socio .cab { align-items: flex-start; }
.socio .cab .cuerpo { flex: 1; min-width: 0; }
.socio .cab .badge { align-self: flex-start; }
.socio .cab small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; line-height: 1.35; }
.socio .barra { background: var(--borde); height: 8px; }
.socio .barra-pie { margin-top: -4px; font-size: 13px; color: var(--muted); display: block; }
.lista-socios { grid-template-columns: minmax(0, 1fr); }

/* ---- TABLET (600–1024): KPIs en fila de 4, socios en 2 columnas ---- */
@media (min-width: 600px) {
  .kpis.cuatro { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .lista-socios { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #lista-empresas { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
  .filtros { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  #form-prestamo, #form-abono { max-width: 640px; }
}

/* ---- ORDENADOR (>1024): menú lateral, contenido centrado, socios en 3 columnas ---- */
@media (min-width: 1025px) {
  .lista-socios { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .app-shell { padding-left: 248px; }
  .nav {
    top: 0; bottom: auto; left: 0; right: auto; width: 248px; height: 100dvh;
    display: flex; flex-direction: column; align-items: stretch; gap: 4px;
    padding: 20px 14px; border-top: 0; border-right: 1px solid var(--borde);
  }
  .nav-marca { display: flex; align-items: center; gap: 12px; padding: 4px 8px 18px; order: -2; }
  .nav-marca img { border-radius: 11px; flex: none; }
  .nav-marca div { display: grid; min-width: 0; }
  .nav-marca strong { font-size: 1.1rem; font-weight: 750; }
  .nav-marca span { color: var(--texto); font-weight: 600; font-size: .95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .nav a, .nav button {
    display: flex; flex-direction: row; justify-content: flex-start; align-items: center; gap: 12px;
    font-size: .95rem; min-height: 46px; padding: 8px 12px; border-radius: 12px;
  }
  .nav a:hover, .nav button:hover { background: var(--sup-2); }
  .nav a.on { background: color-mix(in srgb, var(--oro) 14%, transparent); color: var(--oro); }
  .nav .mas { order: -1; background: var(--oro); color: #fff; justify-content: center; margin-bottom: 12px; }
  .nav .mas:hover { background: var(--oro); filter: brightness(1.05); }
  .nav .mas .circ { width: auto; height: auto; margin: 0; border: 0; box-shadow: none; background: none; }
  .nav .mas .circ svg { width: 22px; height: 22px; }
  .mas-txt { display: inline; font-weight: 700; }
  .app-shell .cabecera { justify-content: flex-end; background: transparent; backdrop-filter: none; -webkit-backdrop-filter: none; padding-top: 14px; padding-bottom: 0; }
  .app-shell .cabecera .cab-logo, .app-shell .cabecera .cab-titulo { display: none; }
  .contenido { padding-bottom: 48px; }
  .buscador { top: 0; }
  .toast { bottom: 32px; }
  .modal-fondo { padding-left: 248px; }
}

/* ---- panel de administrador: tarjeta de empresa ---- */
.empresa .socio-cab { align-items: center; }
.empresa .cuerpo-emp { min-width: 0; }
.empresa .fila-sup { align-items: flex-start; }

/* etiquetas de KPI: pueden pasar a 2 líneas antes que cortarse */
.kpi .etq { white-space: normal; overflow: visible; text-overflow: clip; line-height: 1.25; }
.pagos .hist { table-layout: auto; width: 100%; }
.pagos .hist td { padding: 8px 4px; }
.pagos .hist td:nth-child(2) { white-space: normal; }
.pagos .hist td:last-child { text-align: right; width: 1%; }
.pagos .hist .btn { min-width: 36px; min-height: 36px; padding: 0 8px; }

/* ---- superadmin: fechas automáticas, teléfono con prefijo, resumen para el cliente ---- */
.fecha-fila { display: flex; gap: 8px; align-items: center; }
.fecha-fila input { flex: 1; min-width: 0; }
.fecha-nota, .ayuda-usuario { font-size: .8rem; line-height: 1.35; min-height: 1.1em; }
.fecha-nota.err, .ayuda-usuario.err { color: var(--rojo); }
.tel-fila { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 8px; }
.resumen-envio { border-color: var(--verde); display: grid; gap: 10px; margin-bottom: 16px; }
.resumen-envio h3 { margin: 0; }
.resumen-envio textarea { font: .9rem/1.45 ui-monospace, SFMono-Regular, Menlo, monospace; min-height: 250px; resize: none; background: var(--sup-2); }
.nota-clave { grid-column: 1 / -1; }

/* ---- cliente: seguridad ---- */
.fuerza { display: grid; gap: 4px; }
.fuerza .pista { height: 6px; background: var(--borde); border-radius: 99px; overflow: hidden; }
.fuerza .pista i { display: block; height: 100%; width: 0; border-radius: 99px; background: var(--rojo); transition: width .25s ease, background-color .25s ease; }
.fuerza .txt { font-size: .8rem; color: var(--muted); }
.accesos .fila { min-height: 56px; }
.accesos .actual { color: var(--verde); font-weight: 600; }

/* ---- v6: nombre de empresa como título, activación por enlace ---- */
.empresa .nombre-emp { font-size: 1.35rem; font-weight: 800; letter-spacing: -.015em; line-height: 1.15; }
.activar-emp { font-size: 1.3rem; font-weight: 800; margin: 6px 0 4px; overflow-wrap: anywhere; }
.login .form input[readonly] { background: var(--sup-2); color: var(--muted); }
.resumen-envio input[readonly] { font: .85rem/1.3 ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--sup-2); text-overflow: ellipsis; }
.meta .badge { margin-top: 2px; }
.empresa .nombre-emp { overflow-wrap: break-word; word-break: normal; }
@media (max-width: 599px) {
  .empresa .fila-sup { flex-direction: column; align-items: flex-start; gap: 8px; }
  .empresa .fila-sup > .badge { margin-left: 64px; }
}
