/* Panel de D'León — pensado primero para el teléfono. */
@font-face {
  font-family: 'Montserrat';
  src: url('../assets/fonts/montserrat-latin-wght.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --verde: #047967;
  --verde-600: #036353;
  --verde-800: #034a3f;
  --verde-900: #022f28;
  --oro: #d9b04a;
  --oro-600: #b8902c;
  --tinta: #12302b;
  --suave: #4b625d;
  --fondo: #eef3f1;
  --tarjeta: #fff;
  --linea: #d6e2de;
  --peligro: #b3261e;
  --peligro-fondo: #fdecea;
  --aviso: #8a6100;
  --aviso-fondo: #fff6df;
  --ok-fondo: #e3f4ec;
  --radio: 14px;
  --nav-alto: 66px;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: 'Montserrat', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--tinta);
  background: var(--fondo);
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, p { margin: 0; }
a { color: var(--verde-600); }
button { font: inherit; color: inherit; }
img { max-width: 100%; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.sin-js { padding: 24px; }
code { background: #e6efec; padding: 1px 6px; border-radius: 6px; font-size: .9em; }
:focus-visible { outline: 3px solid var(--oro); outline-offset: 2px; }
.ic { flex: none; vertical-align: middle; }

/* ───────── estructura ───────── */
.app { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.barra {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--verde); color: #fff;
}
.marca { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 800; font-size: 1.1rem; }
.marca small { font-weight: 600; opacity: .8; font-size: .75rem; letter-spacing: .08em; text-transform: uppercase; margin-left: 2px; }
.barra-der { display: flex; align-items: center; gap: 12px; font-size: .8rem; min-width: 0; }
.usuario { max-width: 30vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.red { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; white-space: nowrap; }
.red::before { content: ''; width: 9px; height: 9px; border-radius: 50%; background: currentColor; }
.red-ok { color: #9ff0cf; }
.red-mal { color: #ffb4ab; }

#vista {
  width: 100%; max-width: 960px; margin: 0 auto;
  padding: 16px 16px calc(var(--nav-alto) + 28px + env(safe-area-inset-bottom));
  outline: none; flex: 1;
}

.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: #fff; border-top: 1px solid var(--linea);
  padding-bottom: env(safe-area-inset-bottom);
  transition: transform .2s;
}
.nav a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: var(--nav-alto); color: var(--suave); text-decoration: none; font-size: .72rem; font-weight: 600;
}
.nav a[aria-current='page'] { color: var(--verde); }
.nav a[aria-current='page'] .ic { stroke-width: 2.6; }
body.escribiendo .nav { transform: translateY(110%); }

.banner { padding: 10px 16px; font-size: .85rem; font-weight: 600; text-align: center; }
.banner-peligro { background: var(--peligro); color: #fff; }

.avisos { position: fixed; left: 12px; right: 12px; bottom: calc(var(--nav-alto) + 16px + env(safe-area-inset-bottom)); z-index: 60; display: grid; gap: 8px; pointer-events: none; }
.aviso { cursor: pointer; pointer-events: auto; justify-self: center; max-width: 520px; padding: 12px 16px; border-radius: 12px; background: var(--verde-900); color: #fff; font-weight: 600; font-size: .9rem; box-shadow: 0 6px 20px rgba(0,0,0,.25); }
.aviso-ok { background: var(--verde-600); }
.aviso-peligro { background: var(--peligro); }

@media (min-width: 900px) {
  .app { display: grid; grid-template-columns: 220px 1fr; grid-template-rows: auto auto 1fr; }
  #banners, .barra { grid-column: 1 / -1; }
  .nav { position: sticky; top: 64px; align-self: start; grid-column: 1; grid-row: 3; display: flex; flex-direction: column; gap: 4px; padding: 16px 12px; border: 0; background: transparent; height: calc(100vh - 64px); transform: none !important; }
  .nav a { flex-direction: row; justify-content: flex-start; gap: 12px; min-height: 48px; padding: 0 14px; border-radius: 12px; font-size: .95rem; }
  .nav a[aria-current='page'] { background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
  #vista { grid-column: 2; grid-row: 3; padding: 24px 24px 48px; }
  .avisos { bottom: 24px; }
  .usuario { max-width: 260px; }
}

@media (max-width: 430px) { .marca small { display: none; } .barra { padding-left: 12px; padding-right: 12px; } }

/* ───────── textos y títulos ───────── */
.titulo-vista { font-size: 1.5rem; font-weight: 800; line-height: 1.2; }
.titulo-vista small { display: block; font-size: .8rem; font-weight: 600; color: var(--suave); margin-top: 2px; }
.titulo-vista a { color: inherit; text-decoration: none; }
.sub-vista { color: var(--suave); font-size: .9rem; margin-top: 4px; }
h2 { font-size: 1.05rem; font-weight: 800; margin: 24px 0 10px; display: flex; align-items: center; gap: 8px; }
h3 { font-size: .85rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--suave); margin: 12px 0 6px; }
.contador { background: var(--verde); color: #fff; font-size: .75rem; font-weight: 700; padding: 1px 9px; border-radius: 999px; }
.atras { display: inline-block; margin-bottom: 8px; text-decoration: none; font-weight: 600; font-size: .9rem; padding: 6px 0; }
.cab-lista { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.vacio { color: var(--suave); text-align: center; padding: 22px 12px; background: var(--tarjeta); border: 1px dashed var(--linea); border-radius: var(--radio); }
.sub { color: var(--suave); font-size: .82rem; }
.ayuda { color: var(--suave); font-size: .82rem; margin: 6px 0; }
.nota-peq { color: var(--suave); font-size: .8rem; margin-top: 10px; }
.puntos { text-align: center; color: var(--suave); }

/* ───────── tarjetas, listas ───────── */
.tarjeta { background: var(--tarjeta); border: 1px solid var(--linea); border-radius: var(--radio); padding: 14px 16px; }
.tarjeta .acciones { margin-top: 12px; }
.fila { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 7px 0; border-bottom: 1px solid #edf3f1; font-size: .92rem; }
.fila:last-child { border-bottom: 0; }
.fila span { color: var(--suave); }
.fila b { text-align: right; font-weight: 700; overflow-wrap: anywhere; min-width: 0; }
.fila.total { border-top: 2px solid var(--linea); border-bottom: 0; margin-top: 4px; padding-top: 10px; font-size: 1.05rem; }
.fila.total span { color: var(--tinta); font-weight: 700; }

.lista { display: grid; gap: 10px; }
.item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  width: 100%; text-align: left; text-decoration: none; color: inherit;
  background: var(--tarjeta); border: 1px solid var(--linea); border-radius: var(--radio);
  padding: 12px 14px; min-height: 64px; cursor: pointer;
}
a.item:active, button.item:active { background: #f4f9f7; }
.item-izq { display: grid; gap: 1px; min-width: 0; overflow-wrap: anywhere; }
.item-izq strong { overflow-wrap: anywhere; }
.item-der { display: grid; gap: 4px; justify-items: end; text-align: right; flex: none; }
.item-atraso { display: block; padding: 0; cursor: default; border-left: 5px solid var(--peligro); }
.item-atraso .item-cuerpo { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px 6px; color: inherit; text-decoration: none; }
.item-acciones { display: flex; gap: 8px; padding: 6px 14px 12px; flex-wrap: wrap; }
.item-boton { font: inherit; }

.insignia { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .74rem; font-weight: 700; white-space: nowrap; }
.insignia-ok { background: var(--ok-fondo); color: #0b5a45; }
.insignia-peligro { background: var(--peligro-fondo); color: var(--peligro); }
.insignia-neutro { background: #e8eeec; color: var(--suave); }

/* ───────── indicadores ───────── */
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 14px 0 6px; }
.kpis-chico { grid-template-columns: repeat(2, 1fr); }
.kpis-chico .kpi:first-child { grid-column: 1 / -1; }
.kpi { background: var(--tarjeta); border: 1px solid var(--linea); border-radius: var(--radio); padding: 12px 14px; display: grid; gap: 1px; }
.kpi-t { font-size: .74rem; font-weight: 700; color: var(--suave); text-transform: uppercase; letter-spacing: .04em; }
.kpi-v { font-size: clamp(1rem, 4.6vw, 1.3rem); font-weight: 800; overflow-wrap: break-word; }
.kpi-s { font-size: .78rem; color: var(--suave); }
.kpi-peligro { border-color: #f0b8b3; background: var(--peligro-fondo); }
.kpi-peligro .kpi-v { color: var(--peligro); }
.kpi-aviso { border-color: #ecd18a; background: var(--aviso-fondo); }
.kpi-ok .kpi-v { color: var(--verde-600); }
@media (min-width: 640px) { .kpis { grid-template-columns: repeat(3, 1fr); } .kpis-chico { grid-template-columns: repeat(3, 1fr); } .kpis-chico .kpi:first-child { grid-column: auto; } }

/* ───────── alertas ───────── */
.alerta { display: grid; gap: 3px; padding: 12px 14px; border-radius: var(--radio); border: 1px solid; margin: 12px 0; font-size: .92rem; }
.alerta strong { font-weight: 800; }
.alerta .peq { font-size: .78rem; opacity: .85; }
.alerta-peligro { background: var(--peligro-fondo); border-color: #f0b8b3; color: #7a1710; }
.alerta-aviso { background: var(--aviso-fondo); border-color: #ecd18a; color: #5c4300; }
.alerta-ok { background: var(--ok-fondo); border-color: #a5d8c1; color: #0b4a3a; }
.mora-total { font-size: 1.15em; }

/* ───────── botones ───────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 18px; border: 0; border-radius: 12px;
  font-weight: 700; font-size: .95rem; text-decoration: none; cursor: pointer; text-align: center;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-verde { background: var(--verde); color: #fff; }
.btn-verde:active:not(:disabled) { background: var(--verde-800); }
.btn-claro { background: #e4eeeb; color: var(--verde-900); }
.btn-peligro { background: var(--peligro); color: #fff; }
.btn-peligro-claro { background: #fff; color: var(--peligro); border: 1.5px solid #e5b1ad; }
.btn-grande { min-height: 54px; font-size: 1.05rem; }
.btn-chico { min-height: 38px; padding: 0 14px; font-size: .85rem; border-radius: 10px; }
.btn-icono { display: inline-grid; place-items: center; width: 44px; height: 44px; border: 0; border-radius: 12px; background: transparent; cursor: pointer; }
.btn-enlace { background: none; border: 0; color: var(--verde-600); font-weight: 600; text-decoration: underline; cursor: pointer; padding: 10px; }
.acciones { display: flex; flex-wrap: wrap; gap: 10px; margin: 14px 0; }
.acciones-col { flex-direction: column; }
.acciones-col .btn { width: 100%; }

/* ───────── formularios ───────── */
.campo { display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; margin: 10px 0; min-width: 0; }
.campo > span, .campo-grupo legend { font-size: .8rem; font-weight: 700; color: var(--suave); }
.campo input, .campo select, .campo textarea {
  width: 100%; min-width: 0; max-width: 100%; min-height: 48px; text-overflow: ellipsis; padding: 10px 12px; font: inherit; font-size: 16px; /* 16px: iOS no hace zoom */
  color: var(--tinta); background: #fff; border: 1.5px solid #bfd0cb; border-radius: 12px;
}
.campo textarea { min-height: 76px; resize: vertical; }
.campo input:focus, .campo select:focus, .campo textarea:focus { outline: 3px solid var(--oro); outline-offset: 0; border-color: var(--oro-600); }
.campo-monto { font-size: 1.5rem !important; font-weight: 800; }
.campo-grupo { border: 0; padding: 0; margin: 10px 0; }
.fila-campos { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0 12px; }
@media (min-width: 560px) { .fila-campos { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.error-campo { color: var(--peligro); font-weight: 600; font-size: .85rem; margin: 6px 0; }
.ok-campo { color: var(--verde-600); font-weight: 600; font-size: .85rem; margin: 6px 0; }
.eco-monto { min-height: 1.3em; color: var(--verde-600); font-weight: 800; margin: -4px 0 4px; }
.chips-tipo { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-radio input { position: absolute; opacity: 0; pointer-events: none; }
.chip-radio span { display: inline-flex; align-items: center; min-height: 44px; padding: 0 16px; border: 1.5px solid #bfd0cb; border-radius: 12px; font-weight: 700; font-size: .9rem; cursor: pointer; background: #fff; }
.chip-radio input:checked + span { background: var(--verde); border-color: var(--verde); color: #fff; }
.chip-radio input:focus-visible + span { outline: 3px solid var(--oro); outline-offset: 2px; }
.chip-check { display: flex; align-items: center; gap: 10px; min-height: 44px; font-weight: 600; font-size: .92rem; }
.chip-check input { width: 22px; height: 22px; accent-color: var(--verde); }
.buscador { position: relative; display: block; margin: 0 0 14px; }
.buscador .ic { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--suave); }
.buscador input { width: 100%; min-height: 50px; padding: 0 14px 0 44px; font: inherit; font-size: 16px; border: 1.5px solid #bfd0cb; border-radius: 14px; background: #fff; }
.buscador input:focus { outline: 3px solid var(--oro); border-color: var(--oro-600); }

.filtros { display: flex; gap: 8px; overflow-x: auto; margin: 0 -16px 14px; padding: 2px 16px; scrollbar-width: none; }
.filtros::-webkit-scrollbar { display: none; }
.filtro { flex: none; min-height: 40px; display: inline-flex; align-items: center; padding: 0 16px; border-radius: 999px; background: #fff; border: 1.5px solid var(--linea); text-decoration: none; color: var(--suave); font-weight: 700; font-size: .85rem; }
.filtro.activo { background: var(--verde); border-color: var(--verde); color: #fff; }

/* ───────── cuotas y pagos ───────── */
.lista-cuotas, .lista-pagos, .lista-cubre, .lista-auditoria { list-style: none; margin: 0; padding: 0; }
.lista-cuotas { display: grid; gap: 8px; }
.cuota { display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: 10px; background: #fff; border: 1px solid var(--linea); border-radius: 12px; padding: 10px 12px; border-left: 5px solid var(--linea); }
.cuota-n { font-weight: 800; color: var(--suave); }
.cuota-info { display: grid; line-height: 1.25; font-size: .9rem; }
.cuota-info span { font-size: .78rem; color: var(--suave); }
.cuota-monto { display: grid; justify-items: end; text-align: right; line-height: 1.25; }
.cuota-monto span { font-size: .75rem; color: var(--suave); }
.cuota-monto .mora, .mora-celda { color: var(--peligro); font-weight: 800; }
.cuota-monto .mora { font-size: .78rem; }
.cuota-pagada { border-left-color: #6dbd9b; opacity: .72; }
.cuota-vencida { border-left-color: var(--peligro); background: #fffafa; }
.cuota-hoy { border-left-color: var(--oro); background: #fffcf1; }
.lista-pagos { display: grid; gap: 8px; }
.pago { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; background: #fff; border: 1px solid var(--linea); border-radius: 12px; padding: 10px 12px; }
.pago-info { display: grid; line-height: 1.3; font-size: .85rem; }
.pago-info b { font-size: 1.05rem; }
.pago-info span { color: var(--suave); }
.pago-info .desglose-peq { font-size: .78rem; }
.pago-anulado { opacity: .6; }
.pago-anulado b { text-decoration: line-through; }
.pago-info .anulado { color: var(--peligro); font-weight: 700; }
.lista-cubre { margin: 6px 0 4px; font-size: .84rem; color: var(--suave); padding-left: 2px; }
.lista-cubre li::before { content: '✓ '; color: var(--verde); font-weight: 800; }
.lista-auditoria li { display: grid; gap: 1px; padding: 10px 0; border-bottom: 1px solid #edf3f1; font-size: .88rem; }
.lista-auditoria span, .lista-auditoria small { color: var(--suave); font-size: .78rem; }

.tabla-mini-caja { overflow-x: auto; margin-top: 8px; }
.tabla-mini { width: 100%; border-collapse: collapse; font-size: .8rem; }
.tabla-mini th { text-align: left; font-size: .7rem; text-transform: uppercase; letter-spacing: .04em; color: var(--suave); padding: 4px 8px 4px 0; }
.tabla-mini td { padding: 5px 8px 5px 0; border-top: 1px solid rgba(0,0,0,.07); white-space: nowrap; }
.tabla-mini small { color: var(--suave); }

.explicacion ul { margin: 6px 0 0; padding-left: 20px; display: grid; gap: 4px; font-size: .9rem; }

/* ───────── ventanas ───────── */
.modal { border: 0; padding: 0; background: transparent; color: var(--tinta); max-width: 100%; width: 100%; max-height: 100dvh; margin: auto 0 0; overflow: visible; }
.modal::backdrop { background: rgba(2, 47, 40, .6); }
.modal-caja { min-width: 0; background: #fff; border-radius: 22px 22px 0 0; max-height: 94dvh; display: flex; flex-direction: column; padding-bottom: env(safe-area-inset-bottom); animation: subir .22s ease-out; }
@keyframes subir { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-cab { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 8px 10px 18px; border-bottom: 1px solid var(--linea); }
.modal-titulo { font-size: 1.1rem; font-weight: 800; margin: 0; }
.modal-cuerpo { min-width: 0; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; padding: 14px 18px 20px; }
@media (min-width: 700px) {
  .modal { margin: auto; max-width: 560px; }
  .modal-caja { border-radius: 22px; max-height: 90dvh; }
  .modal-grande { max-width: 680px; }
  .modal-chico { max-width: 460px; }
}
.acciones-modal { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.acciones-modal .btn { flex: 1 1 140px; }
.texto-modal { margin-bottom: 10px; font-size: .95rem; }

.pago-cliente { margin-bottom: 4px; }
.pago-cliente span { color: var(--suave); font-size: .9rem; }
.chips-monto { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.chip-monto { display: grid; text-align: left; gap: 0; padding: 8px 14px; background: #fff; border: 1.5px solid var(--verde); border-radius: 12px; cursor: pointer; min-height: 52px; }
.chip-monto span { font-size: .72rem; font-weight: 700; color: var(--suave); text-transform: uppercase; letter-spacing: .03em; }
.chip-monto b { font-size: 1rem; color: var(--verde-800); }
.chip-monto:active { background: var(--ok-fondo); }
.totales-pago { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 8px 0; }
.totales-pago div { background: #f4f8f7; border-radius: 12px; padding: 8px 12px; display: grid; }
.totales-pago span { font-size: .72rem; color: var(--suave); font-weight: 700; }
.totales-pago b { font-size: 1.05rem; }
.previa { margin: 10px 0; background: #f9fbfa; }
.confirmacion { text-align: center; padding: 6px 0 4px; }
.monto-grande { font-size: 2.2rem; font-weight: 800; color: var(--verde); line-height: 1.15; overflow-wrap: anywhere; }
.exito .monto-grande { margin-bottom: 4px; }
.exito-icono { width: 64px; height: 64px; margin: 0 auto 8px; border-radius: 50%; background: var(--ok-fondo); color: var(--verde); display: grid; place-items: center; }

/* ───────── entrada, carga ───────── */
.centrado { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 20px; background: linear-gradient(160deg, var(--verde) 0%, var(--verde-900) 100%); }
.tarjeta-centro { width: 100%; max-width: 420px; padding: 24px 22px; display: grid; gap: 6px; text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.tarjeta-centro h1 { font-size: 1.3rem; font-weight: 800; margin-bottom: 4px; }
.tarjeta-centro p { color: var(--suave); font-size: .92rem; }
.tarjeta-centro .campo { text-align: left; }
.logo-login { width: 100%; max-width: 280px; margin: 0 auto 10px; display: block; }
.spinner { width: 38px; height: 38px; margin: 12px auto; border: 4px solid #cfe3dc; border-top-color: var(--verde); border-radius: 50%; animation: gira .8s linear infinite; }
@keyframes gira { to { transform: rotate(360deg); } }
.cargando { text-align: center; padding: 48px 12px; color: var(--suave); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
