:root {
  color-scheme: light;
  --fondo: #f3f2ee;
  --tarjeta: #fcfcfb;
  --borde: #dedcd5;
  --texto: #0b0b0b;
  --texto-2: #52514e;
  --texto-3: #66655f;
  --acento: #1f6bc4;
  --acento-texto: #ffffff;
  --acento-suave: #e4eefa;
  --enlace: #1f6bc4;
  --serie: #2a78d6;
  --eje: #d6d4cc;
  --pista: #e8e6e0;
  --bien: #0b7a0b;  --bien-fondo: #e5f3e5;
  --ojo: #8a5a00;   --ojo-fondo: #fcf0d6;
  --mal: #b42f2f;   --mal-fondo: #fbe8e8;
  --sombra: 0 1px 2px rgb(0 0 0 / .05), 0 2px 8px rgb(0 0 0 / .04);
  --radio: 16px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --fondo: #111110;
    --tarjeta: #1a1a19;
    --borde: #33332f;
    --texto: #f0efec;
    --texto-2: #c3c2b7;
    --texto-3: #a7a69d;
    --acento-suave: #1c2b3f;
    --enlace: #79b0f0;
    --serie: #3987e5;
    --eje: #3a3a36;
    --pista: #2c2c29;
    --bien: #5cc45c;  --bien-fondo: #16301a;
    --ojo: #f0b43c;   --ojo-fondo: #352a10;
    --mal: #ef7070;   --mal-fondo: #3b1b1b;
    --sombra: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --fondo: #111110; --tarjeta: #1a1a19; --borde: #33332f; --texto: #f0efec; --texto-2: #c3c2b7;
  --texto-3: #a7a69d; --acento-suave: #1c2b3f; --enlace: #79b0f0; --serie: #3987e5; --eje: #3a3a36;
  --pista: #2c2c29; --bien: #5cc45c; --bien-fondo: #16301a; --ojo: #f0b43c; --ojo-fondo: #352a10;
  --mal: #ef7070; --mal-fondo: #3b1b1b; --sombra: none;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--fondo);
  color: var(--texto);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-variant-numeric: tabular-nums;
}
body.con-menu { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
a { color: var(--enlace); }
h1 { font-size: 1.35rem; margin: .2rem 0 .8rem; line-height: 1.2; }
h2 { font-size: 1.05rem; margin: 0 0 .7rem; }
h2 a { color: inherit; text-decoration: none; }
h2 a::after { content: " ›"; color: var(--texto-3); }
small { font-size: .82em; color: var(--texto-3); }
main { max-width: 560px; margin: 0 auto; padding: 12px 16px 24px; }

/* arriba */
.arriba {
  max-width: 560px; margin: 0 auto; padding: 12px 16px 0;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.marca { font-weight: 700; color: var(--texto); text-decoration: none; font-size: 1.05rem; }
.yo {
  text-decoration: none; color: var(--texto-2); font-weight: 600; font-size: .95rem;
  border: 1px solid var(--borde); border-radius: 999px; padding: .3rem .85rem; background: var(--tarjeta);
}
.yo.activo { border-color: var(--acento); color: var(--texto); }

/* menú de abajo */
.menu {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--tarjeta); border-top: 1px solid var(--borde);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
.menu a {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0;
  color: var(--texto-3); text-decoration: none; font-size: .72rem; font-weight: 600; border-radius: 12px;
}
.menu a[aria-current="page"] { color: var(--acento); background: var(--acento-suave); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .menu a[aria-current="page"] { color: var(--enlace); } }
:root[data-theme="dark"] .menu a[aria-current="page"] { color: var(--enlace); }
.ico { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

/* tarjetas */
.tarjeta {
  background: var(--tarjeta); border: 1px solid var(--borde); border-radius: var(--radio);
  padding: 16px; margin: 0 0 14px; box-shadow: var(--sombra);
}
.nota { color: var(--texto-2); font-size: .92rem; margin: .2rem 0 .8rem; }
.vacio { color: var(--texto-3); text-align: center; padding: 1rem; }
.volver { margin: 0 0 .4rem; font-size: .92rem; }
.volver a { text-decoration: none; }

/* saldo */
.saldo { text-align: center; padding: 20px 16px; }
.saldo-quien { font-size: 1rem; font-weight: 600; color: var(--texto-2); margin: 0; }
.saldo-monto { font-size: 2.9rem; font-weight: 750; margin: .1rem 0 .7rem; letter-spacing: -.02em; font-variant-numeric: proportional-nums; }
.cifra { font-size: 2.2rem; font-weight: 750; margin: 0 0 .2rem; font-variant-numeric: proportional-nums; }

/* avisos */
.aviso { border-radius: 12px; padding: .7rem .9rem; margin: 0 0 14px; font-size: .95rem; }
.aviso p { margin: 0; }
.aviso.bien { background: var(--bien-fondo); color: var(--texto); border: 1px solid color-mix(in srgb, var(--bien) 35%, transparent); }
.aviso.mal { background: var(--mal-fondo); color: var(--texto); border: 1px solid color-mix(in srgb, var(--mal) 40%, transparent); }
.recien { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.recien form { margin: 0; flex: none; }

/* formularios */
.campo { display: block; margin: 0 0 14px; border: 0; padding: 0; min-width: 0; }
.rotulo { display: block; font-weight: 650; font-size: .92rem; margin: 0 0 6px; color: var(--texto); padding: 0; }
input, button, select { font: inherit; color: inherit; }
input[type="text"], input:not([type]), input[type="search"], input[type="password"], input[type="date"],
input[type="number"], input[type="month"] {
  width: 100%; min-height: 48px; padding: .6rem .8rem; font-size: 16px;
  border: 1.5px solid var(--borde); border-radius: 12px; background: var(--fondo); color: var(--texto);
}
input:focus-visible, .boton:focus-visible, summary:focus-visible, .chip:focus-visible {
  outline: 2.5px solid var(--acento); outline-offset: 2px;
}
input[aria-invalid="true"] { border-color: var(--mal); }
.monto { display: flex; align-items: center; gap: 8px; border: 1.5px solid var(--borde); border-radius: 12px; background: var(--fondo); padding: 0 .8rem; }
.monto:focus-within { outline: 2.5px solid var(--acento); outline-offset: 2px; }
.monto > span { font-size: 1.5rem; color: var(--texto-3); font-weight: 600; }
.monto input { border: 0 !important; background: transparent !important; padding-left: 0; font-size: 1.6rem; font-weight: 700; min-height: 56px; outline: none; }
.error { display: block; color: var(--mal); font-style: normal; font-size: .9rem; margin-top: 4px; font-weight: 600; }
.check { display: flex; gap: 10px; align-items: center; margin: 0 0 14px; font-size: .95rem; }
.check input { width: 22px; height: 22px; accent-color: var(--acento); }
.dos-campos { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.opciones { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.opcion { position: relative; display: block; cursor: pointer; }
.opcion input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.opcion > span {
  display: block; height: 100%; padding: .65rem .75rem; border: 1.5px solid var(--borde); border-radius: 12px;
  background: var(--fondo); font-weight: 600; font-size: .95rem; line-height: 1.25;
}
.opcion small { display: block; font-weight: 400; margin-top: 2px; }
.opcion input:checked + span { border-color: var(--acento); background: var(--acento-suave); box-shadow: inset 0 0 0 1px var(--acento); }
.opcion input:focus-visible + span { outline: 2.5px solid var(--acento); outline-offset: 2px; }
.opciones.dos .opcion > span { text-align: center; padding: .8rem; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: -6px 0 14px; }
.chip {
  border: 1px solid var(--borde); background: var(--fondo); border-radius: 999px; padding: .35rem .8rem;
  font-size: .88rem; cursor: pointer; color: var(--texto-2); min-height: 36px;
}
.chip:hover { border-color: var(--acento); }

.previa { min-height: 1.4em; margin: -4px 0 12px; color: var(--texto-2); font-size: .93rem; }
.previa b { color: var(--texto); }

/* botones */
.boton {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 48px;
  padding: .6rem 1.1rem; border-radius: 12px; border: 1.5px solid transparent; font-weight: 650;
  text-decoration: none; cursor: pointer; font-size: 1rem; text-align: center;
}
.boton.principal { background: var(--acento); color: var(--acento-texto); width: 100%; }
.boton.principal:active { filter: brightness(.92); }
.boton.secundario { background: var(--tarjeta); color: var(--texto); border-color: var(--borde); }
.boton.peligro { background: transparent; color: var(--mal); border-color: color-mix(in srgb, var(--mal) 45%, transparent); }
.boton.chico { min-height: 40px; padding: .35rem .85rem; font-size: .92rem; }
.boton.fantasma { visibility: hidden; }
.boton[disabled] { opacity: .6; cursor: wait; }
.saldo .boton { min-width: 60%; }
.flotante { position: sticky; bottom: calc(84px + env(safe-area-inset-bottom)); box-shadow: 0 4px 14px rgb(0 0 0 / .18); margin-top: 8px; }
form.borrar { margin-top: 10px; }
form.borrar .boton, .salir .boton { width: 100%; }
.salir { margin: 8px 0 0; }

/* desplegables */
.desplegable { margin-top: 10px; }
.desplegable > summary { list-style: none; cursor: pointer; }
.desplegable > summary::-webkit-details-marker { display: none; }
.desplegable > summary.boton { width: 100%; }
.desplegable.chico > summary { color: var(--enlace); font-weight: 600; font-size: .95rem; padding: .4rem 0; }
.desplegable.chico > summary::before { content: "▸ "; }
.desplegable.chico[open] > summary::before { content: "▾ "; }
.form-corto { margin-top: 14px; }

/* listas */
.movs { list-style: none; margin: 0; padding: 0; }
.movs.tarjeta { padding: 4px 16px; }
.mov + .mov { border-top: 1px solid var(--borde); }
.mov a {
  display: grid; grid-template-columns: 1fr auto; column-gap: 10px; row-gap: 2px; padding: 10px 0;
  color: inherit; text-decoration: none;
}
.mov-que { font-weight: 600; overflow-wrap: anywhere; }
.mov-plata { font-weight: 700; text-align: right; }
.mov-detalle { grid-column: 1 / -1; font-size: .85rem; color: var(--texto-2); }
.mov-pago .mov-plata, .mov-saldo .mov-plata { color: var(--texto-2); }
.etiqueta { white-space: nowrap; }
.ver-mas { display: block; text-align: center; padding: 10px 0 2px; font-weight: 600; }
.dia-fecha { font-size: .88rem; color: var(--texto-2); font-weight: 650; margin: 16px 4px 6px; }

.lista-estado { list-style: none; margin: 0; padding: 0; }
.lista-estado li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 0; }
.lista-estado li + li { border-top: 1px solid var(--borde); }
.lista-estado .nombre { font-weight: 600; }
.estado { font-size: .88rem; font-weight: 650; border-radius: 999px; padding: .2rem .65rem; white-space: nowrap; }
.estado.bien { color: var(--bien); background: var(--bien-fondo); }
.estado.ojo { color: var(--ojo); background: var(--ojo-fondo); }
.estado.mal { color: var(--mal); background: var(--mal-fondo); }
.estado.neutro { color: var(--texto-2); background: var(--fondo); border: 1px solid var(--borde); }

.servicio-cabeza { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 4px; }
.servicio-cabeza h2 { margin: 0; }
.terminada { opacity: .75; }

.meses { display: grid; grid-template-columns: 48px 1fr 48px; align-items: center; gap: 8px; margin: 4px 0 6px; }
.meses h1 { text-align: center; margin: 0; text-transform: capitalize; }
.meses .boton { padding: 0; font-size: 1.4rem; }
.buscar { display: flex; gap: 8px; margin: 0 0 14px; }
.buscar input { flex: 1; }

.historia { list-style: none; margin: 0; padding: 0; font-size: .9rem; }
.historia li { padding: 6px 0; border-top: 1px solid var(--borde); overflow-wrap: anywhere; }
.historia li:first-child { border-top: 0; }
.historia span { color: var(--texto-3); margin-right: 4px; }

/* gráficos */
.figura { margin: 10px 0 0; }
.figura figcaption { font-size: .88rem; color: var(--texto-2); margin-bottom: 6px; }
.grafico { display: block; width: 100%; height: auto; overflow: visible; }
.g-col { fill: var(--serie); }
.g-base { stroke: var(--eje); stroke-width: 1; }
.g-eje { fill: var(--texto-3); font-size: 11px; }
.g-valor { fill: var(--texto); font-size: 12px; font-weight: 650; }
.g-hit { fill: transparent; cursor: pointer; }
.g-item:hover .g-col, .g-item.activo .g-col { opacity: .78; }
.grafico-info { font-size: .88rem; color: var(--texto-2); margin: 4px 0 0; min-height: 1.3em; }
.tabla-datos { margin-top: 6px; font-size: .9rem; }
.tabla-datos summary { color: var(--enlace); cursor: pointer; font-weight: 600; padding: 4px 0; }
table { width: 100%; border-collapse: collapse; margin-top: 6px; }
th, td { text-align: left; padding: 6px 4px; border-bottom: 1px solid var(--borde); }
td:last-child, th:last-child { text-align: right; }
.tabla-personas td { text-align: right; font-weight: 600; }
.tabla-personas thead th { font-size: .85rem; color: var(--texto-2); font-weight: 600; text-align: right; }
.progreso { display: block; margin: 8px 0 10px; }
.progreso .pista { fill: var(--pista); }
.progreso .lleno { fill: var(--serie); }
.barras { list-style: none; margin: 0; padding: 0; }
.barras li { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 7px 0; }
.barra-nombre { font-weight: 600; overflow-wrap: anywhere; }
.barra-monto { font-weight: 650; text-align: right; }
.barra { grid-column: 1 / -1; display: block; }
.barra rect { fill: var(--serie); }

/* ingreso */
.entrar { margin-top: 8vh; text-align: center; }
.entrar form, .entrar .aviso { text-align: left; }
.logo { border-radius: 16px; }

@media (min-width: 600px) {
  .opciones { grid-template-columns: 1fr 1fr; }
}
@media (forced-colors: active) {
  .g-col, .barra rect, .progreso .lleno { fill: CanvasText; }
  .opcion input:checked + span { outline: 3px solid Highlight; }
}
