/* =============================================================================
   Sistema visual
   =============================================================================
   Sobrio y claro. Un fondo claro, una sola familia tipográfica, mucho espacio
   en blanco y filas altas. Nada decorativo: los números que importan son pocos
   y tienen que leerse de un vistazo.

   Tres reglas que no son estéticas sino de uso, porque la usa alguien que no
   está cómodo con lo digital:

     - Cuerpo de 17px para arriba y 44px de alto mínimo en cualquier cosa que
       se toque. Se usa desde el celular.
     - Los estados llevan color Y palabra. El color acompaña al texto, nunca
       lo reemplaza: alguien que no distingue rojo de verde tiene que poder
       usar esto igual.
     - Un solo color de acento, y usado poco. Si todo resalta, nada resalta.
   ========================================================================== */

:root {
  color-scheme: light;

  --fondo:        #faf9f7;
  --superficie:   #ffffff;
  --borde:        #e6e1d9;
  --borde-fuerte: #d3ccc0;

  --texto:        #1b1916;
  --texto-suave:  #6b6459;
  --texto-tenue:  #928a7d;

  /* El único acento. Botón principal, links y foco. */
  --acento:       #0f5c52;
  --acento-vivo:  #14776a;
  --acento-suave: #e8f2f0;

  /* Estados. Siempre acompañados de la palabra. */
  --debe:         #a3271b;
  --debe-fondo:   #fdf0ee;
  --alerta:       #855a10;
  --alerta-fondo: #fdf5e6;
  --bien:         #1a6b45;
  --bien-fondo:   #ecf6f0;

  --radio:        12px;
  --sombra:       0 1px 2px rgba(27, 25, 22, .05), 0 1px 8px rgba(27, 25, 22, .04);
  --ancho:        min(920px, 100% - 2rem);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--fondo);
  color: var(--texto);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 17px;
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
}

/* Los montos se leen en columna: sin cifras tabulares no se alinean. */
.monto, .tabular { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }

h1 { font-size: 1.6rem; font-weight: 650; letter-spacing: -.015em; margin: 0 0 .25rem; }
h2 { font-size: 1.15rem; font-weight: 620; margin: 0 0 .75rem; }
p  { margin: 0 0 .75rem; }
a  { color: var(--acento); text-underline-offset: 3px; }

/* --- estructura ---------------------------------------------------------- */

.barra {
  background: var(--superficie);
  border-bottom: 1px solid var(--borde);
  position: sticky; top: 0; z-index: 20;
}
.barra-interior {
  width: var(--ancho); margin: 0 auto;
  min-height: 60px; display: flex; align-items: center; gap: 1rem;
}
.marca {
  font-weight: 640; letter-spacing: -.01em; font-size: 1.05rem;
  color: var(--texto); text-decoration: none; margin-right: auto;
  display: inline-flex; align-items: center; gap: .55rem;
}
.marca::before {
  content: ""; width: 10px; height: 10px; border-radius: 3px;
  background: var(--acento); flex: none;
}
.quien { color: var(--texto-suave); font-size: .95rem; }

main { width: var(--ancho); margin: 0 auto; padding: 1.75rem 0 5rem; }
.encabezado { margin-bottom: 1.5rem; }
.encabezado .bajada { color: var(--texto-suave); margin: 0; }

.seccion { margin-top: 2.5rem; }
.seccion > h2 { color: var(--texto-suave); font-size: .95rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .05em; }

/* --- tarjetas de contrato ------------------------------------------------ */

.lista { display: flex; flex-direction: column; gap: .75rem; }

.fila {
  background: var(--superficie);
  border: 1px solid var(--borde);
  border-radius: var(--radio);
  box-shadow: var(--sombra);
  padding: 1.15rem 1.25rem;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: .35rem 1.25rem;
  align-items: start;
}
/* Quien debe se distingue por un borde izquierdo, no sólo por color de texto. */
.fila.debe { border-left: 4px solid var(--debe); }
.fila.al-dia { border-left: 4px solid var(--bien); }

.fila .unidad { font-size: 1.18rem; font-weight: 640; letter-spacing: -.01em; }
.fila .inquilino { color: var(--texto-suave); grid-column: 1; }
.fila .dato { grid-column: 1; margin-top: .5rem; }

.plata { font-size: 1.5rem; font-weight: 650; letter-spacing: -.02em; }
.plata.debe { color: var(--debe); }
.cuando { color: var(--texto-suave); font-size: .95rem; }

.acciones { grid-column: 2; grid-row: 1 / span 4; display: flex; flex-direction: column;
  gap: .5rem; align-items: stretch; }

/* --- etiquetas de estado: color Y palabra -------------------------------- */

.etiqueta {
  display: inline-flex; align-items: center; gap: .4rem;
  font-size: .85rem; font-weight: 600; line-height: 1;
  padding: .4rem .6rem; border-radius: 7px; white-space: nowrap;
}
.etiqueta::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.etiqueta.debe    { color: var(--debe);   background: var(--debe-fondo); }
.etiqueta.alerta  { color: var(--alerta); background: var(--alerta-fondo); }
.etiqueta.bien    { color: var(--bien);   background: var(--bien-fondo); }
.etiqueta.neutra  { color: var(--texto-suave); background: #f2efe9; }

/* --- botones ------------------------------------------------------------- */

.boton {
  font: inherit; font-weight: 600;
  min-height: 44px; padding: .6rem 1.15rem;
  border-radius: 10px; border: 1px solid transparent;
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  gap: .5rem; white-space: nowrap; text-decoration: none;
  transition: background-color .12s ease, border-color .12s ease;
}
.boton.principal { background: var(--acento); color: #fff; }
.boton.principal:hover { background: var(--acento-vivo); }
.boton.secundario { background: var(--superficie); color: var(--texto); border-color: var(--borde-fuerte); }
.boton.secundario:hover { background: #f6f3ee; }
.boton.discreto { background: transparent; color: var(--texto-suave); padding: .5rem .7rem; }
.boton.discreto:hover { background: #f2efe9; color: var(--texto); }
.boton.peligro { background: var(--superficie); color: var(--debe); border-color: #e8c4bf; }
.boton.peligro:hover { background: var(--debe-fondo); }
.boton:disabled { opacity: .5; cursor: not-allowed; }

:where(a, button, input, select, textarea, summary):focus-visible {
  outline: 3px solid var(--acento); outline-offset: 2px; border-radius: 8px;
}

/* --- formularios --------------------------------------------------------- */

.campo { display: block; margin-bottom: 1.1rem; }
.campo > span { display: block; font-weight: 600; margin-bottom: .35rem; font-size: .95rem; }
.campo .ayuda { font-weight: 400; color: var(--texto-suave); font-size: .9rem; }

input, select, textarea {
  font: inherit; width: 100%; min-height: 48px;
  padding: .6rem .8rem;
  background: var(--superficie);
  border: 1px solid var(--borde-fuerte); border-radius: 10px;
  color: var(--texto);
}
input.monto-grande { font-size: 1.35rem; font-weight: 640; }

/* --- avisos -------------------------------------------------------------- */

.aviso { padding: .9rem 1.05rem; border-radius: 10px; margin-bottom: 1.15rem; border: 1px solid; }
.aviso.error { color: var(--debe); background: var(--debe-fondo); border-color: #f0cdc7; }
.aviso.atencion { color: var(--alerta); background: var(--alerta-fondo); border-color: #ecd9ac; }
.aviso.ok { color: var(--bien); background: var(--bien-fondo); border-color: #c3e2d1; }
.aviso p:last-child { margin-bottom: 0; }

/* --- vacío --------------------------------------------------------------- */

.vacio {
  text-align: center; padding: 3.5rem 1.5rem;
  background: var(--superficie); border: 1px solid var(--borde);
  border-radius: var(--radio);
}
.vacio .grande { font-size: 1.45rem; font-weight: 640; margin-bottom: .35rem; }
.vacio p { color: var(--texto-suave); margin: 0; }

/* --- meses del estado de cuenta ------------------------------------------ */

.mes {
  background: var(--superficie); border: 1px solid var(--borde);
  border-radius: var(--radio); overflow: hidden;
}
.mes + .mes { margin-top: .6rem; }
.mes-cabecera {
  display: flex; align-items: center; gap: .9rem;
  padding: 1rem 1.15rem; width: 100%; text-align: left;
  font: inherit; background: none; border: 0; cursor: pointer; min-height: 60px;
}
.mes-cabecera:hover { background: #f8f6f2; }
.mes-cabecera .nombre { font-weight: 600; }
.mes-cabecera .importe { margin-left: auto; font-weight: 640; font-size: 1.1rem; }
.mes-cuerpo { padding: 0 1.15rem 1.15rem; border-top: 1px solid var(--borde); }

.renglon { display: flex; gap: 1rem; padding: .7rem 0; border-bottom: 1px solid var(--borde); }
.renglon:last-child { border-bottom: 0; }
.renglon .que { flex: 1; }
.renglon .cuanto { font-weight: 600; }
.renglon.anulado { color: var(--texto-tenue); text-decoration: line-through; }

/* Listas de dato y valor, a dos columnas. Se usan en la ficha del contrato y
   en la cuenta del ajuste. */
.datos { display: grid; grid-template-columns: auto 1fr; gap: .45rem 1.5rem; margin: 0; }
.datos dt { color: var(--texto-suave); }
.datos dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.datos .resultado { border-top: 1px solid #c8ded9; margin-top: .45rem; padding-top: .55rem; font-weight: 650; }

/* La cuenta del ajuste: es lo que se le muestra al inquilino si discute. */
.cuenta {
  margin-top: .8rem; padding: .9rem 1rem;
  background: var(--acento-suave); border-radius: 10px;
  font-size: .95rem;
}
.cuenta summary { cursor: pointer; font-weight: 600; min-height: 32px; display: flex; align-items: center; }
.cuenta[open] summary { margin-bottom: .6rem; }

/* La ficha de datos del contrato, en tarjeta propia. */
.ficha {
  background: var(--superficie); border: 1px solid var(--borde);
  border-radius: var(--radio); box-shadow: var(--sombra);
  padding: 1.15rem 1.25rem;
}
.ficha + .ficha { margin-top: .75rem; }

/* --- panel deslizante (el cobro) ----------------------------------------- */

dialog.panel {
  border: 0; padding: 0; background: transparent;
  width: min(560px, 100%); max-height: 92vh; margin: auto auto 0;
}
dialog.panel::backdrop { background: rgba(27, 25, 22, .45); }
.panel-caja {
  background: var(--superficie);
  border-radius: 16px 16px 0 0;
  padding: 1.5rem 1.5rem 1.75rem;
  max-height: 92vh; overflow-y: auto;
}
.panel-cabecera { display: flex; align-items: start; gap: 1rem; margin-bottom: 1.25rem; }
.panel-cabecera h2 { margin: 0; }
.panel-cabecera .sub { color: var(--texto-suave); font-size: .95rem; }
.panel-pie { display: flex; gap: .75rem; margin-top: 1.5rem; }
.panel-pie .boton { flex: 1; }

@media (min-width: 640px) {
  dialog.panel { margin: auto; }
  .panel-caja { border-radius: 16px; }
}

/* --- utilidades ---------------------------------------------------------- */

.oculto { display: none !important; }
.cargando { color: var(--texto-suave); padding: 2rem 0; text-align: center; }
.pie-nota { color: var(--texto-tenue); font-size: .9rem; margin-top: 2.5rem; }

@media (max-width: 560px) {
  .fila { grid-template-columns: 1fr; }
  .acciones { grid-column: 1; grid-row: auto; margin-top: .9rem; }
  .plata { font-size: 1.35rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
