:root {
  --bg: #EEF2F1; --surface: #FFFFFF; --surface-2: #F5F8F7; --ink: #13211F; --muted: #5C6B68;
  --line: #DCE4E2; --accent: #0B8A64; --accent-ink: #FFFFFF; --accent-soft: #DDF3EA;
  --neg: #C93B3B; --neg-soft: #FBE6E6; --warn: #A86A12; --warn-soft: #FBF0DC;
  --frame: #1D2B29; --shadow: 0 18px 50px rgba(19, 33, 31, .14);
  --display: 'Bricolage Grotesque', 'Segoe UI', system-ui, sans-serif;
  --body: 'Figtree', 'Segoe UI', system-ui, -apple-system, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0B1211; --surface: #121B1A; --surface-2: #182322; --ink: #E8F0EE; --muted: #8FA19D;
    --line: #24312F; --accent: #3DD9A0; --accent-ink: #052016; --accent-soft: #12352A;
    --neg: #FF8080; --neg-soft: #3A1A1A; --warn: #F2B84B; --warn-soft: #3A2E14;
    --frame: #000000; --shadow: 0 18px 50px rgba(0, 0, 0, .5); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0B1211; --surface: #121B1A; --surface-2: #182322; --ink: #E8F0EE; --muted: #8FA19D;
  --line: #24312F; --accent: #3DD9A0; --accent-ink: #052016; --accent-soft: #12352A;
  --neg: #FF8080; --neg-soft: #3A1A1A; --warn: #F2B84B; --warn-soft: #3A2E14;
  --frame: #000000; --shadow: 0 18px 50px rgba(0, 0, 0, .5); color-scheme: dark;
}
html { box-sizing: border-box; height: 100%; }
*, *::before, *::after { box-sizing: inherit; }
body { height: 100%; margin: 0; background: var(--bg); color: var(--ink); font-family: var(--body);
  font-size: 15px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.num { font-variant-numeric: tabular-nums; }

/* ── Escenario: en el teléfono, pantalla completa; en pantallas anchas, una columna centrada ── */
.stage { height: 100%; }
.device { position: relative; width: 100%; height: 100%; margin: 0 auto; }
@media (min-width: 640px) {
  .device { max-width: 480px; border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
}

/* ── App ── */
.app { position: relative; height: 100%; display: flex; flex-direction: column; background: var(--bg); overflow: hidden; }
.scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.pad { padding: 18px 16px 24px; display: flex; flex-direction: column; gap: 16px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px 4px; }
.hola { color: var(--muted); font-size: 13px; font-weight: 600; }
.h1 { font-family: var(--display); font-size: 26px; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; margin: 0; text-wrap: balance; }
.h2 { font-family: var(--display); font-size: 18px; font-weight: 700; letter-spacing: -.01em; margin: 0; }
.lead { color: var(--muted); margin: 0; }
.eyebrow { font-size: 11.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 16px; }
.iconbtn { width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface);
  display: grid; place-items: center; font-weight: 700; color: var(--muted); }

.btn { min-height: 50px; border-radius: 14px; border: none; padding: 0 20px; font-weight: 700; font-size: 16px; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn-text { background: none; border: none; color: var(--accent); font-weight: 700; padding: 8px 4px; }
.btn-block { width: 100%; }

/* Bienvenida */
.hero { display: flex; flex-direction: column; gap: 18px; padding: 36px 20px 24px; }
.logo { width: 52px; height: 52px; border-radius: 16px; background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; font-family: var(--display); font-size: 26px; font-weight: 700; }
.brand { font-family: var(--display); font-size: 40px; font-weight: 700; letter-spacing: -.03em; line-height: 1; margin: 0; }
.preview { display: flex; flex-direction: column; gap: 12px; }
.preview .fila { display: flex; justify-content: space-between; font-size: 14px; color: var(--muted); }
.preview .fila b { color: var(--ink); }
.mini-bars { display: flex; align-items: flex-end; gap: 6px; height: 54px; }
.mini-bars span { flex: 1; border-radius: 4px 4px 0 0; background: var(--accent-soft); }
.mini-bars span.hoy { background: var(--accent); }
.tag-ej { align-self: flex-start; font-size: 11px; font-weight: 700; color: var(--muted); background: var(--surface-2);
  border: 1px solid var(--line); border-radius: 999px; padding: 2px 9px; }

/* Asistente */
.progress { display: flex; gap: 4px; padding: 14px 16px 0; }
.progress span { flex: 1; height: 5px; border-radius: 3px; background: var(--line); }
.progress span.ok { background: var(--accent); }
.paso-n { font-size: 12.5px; font-weight: 700; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 44px; padding: 0 16px; border-radius: 999px; border: 1.5px solid var(--line); background: var(--surface);
  font-weight: 600; display: inline-flex; align-items: center; gap: 8px; }
.chip[aria-pressed="true"], .chip[aria-checked="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--ink); }
.chip[aria-pressed="true"]::before, .chip[aria-checked="true"]::before { content: "✓"; color: var(--accent); font-weight: 800; }
.subt { font-size: 13px; font-weight: 700; color: var(--muted); margin: 4px 0 -4px; }
.otro { display: flex; gap: 8px; }
.input { min-height: 48px; width: 100%; border-radius: 12px; border: 1.5px solid var(--line); background: var(--surface);
  padding: 0 14px; font-size: 16px; }
.input:focus { border-color: var(--accent); outline: none; }
.monto-fila { display: grid; grid-template-columns: minmax(0, 1fr) 150px; align-items: center; gap: 12px;
  padding: 10px 0; border-bottom: 1px solid var(--line); }
.monto-fila:last-child { border-bottom: none; }
.monto-fila label { font-weight: 600; }
.monto-fila small { display: block; color: var(--muted); font-size: 12px; font-weight: 500; }
.monto-in { position: relative; }
.monto-in .unidad { position: absolute; left: 6px; top: 50%; transform: translateY(-50%); z-index: 1; min-height: 34px; min-width: 36px;
  padding: 0 9px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface-2); color: var(--muted);
  font-size: 13px; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; }
.monto-in .unidad.uf { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.monto-in .input { padding-left: 52px; text-align: right; }
.uf-hint { display: block; color: var(--accent); font-size: 12px; font-weight: 600; }
.input-dia { width: 64px !important; min-height: 40px !important; text-align: center; padding: 0 6px !important; }
.dia-cobro { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); margin-top: -4px; }
.dia-cobro label { font-weight: 600; color: var(--ink); }
.dia-linea { display: flex; align-items: center; gap: 10px; min-height: 44px; font-weight: 600; }
.dia-linea small { color: var(--muted); font-weight: 500; font-size: 12.5px; }
.input[aria-invalid="true"] { border-color: var(--neg); }
.dia-cobro input[aria-invalid="true"] + span { color: var(--neg); }
.aviso-repetir { font-size: 13px; }
.aviso-repetir:not(:empty) { margin-top: 6px; }
.sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.uf-hint:empty { display: none; }
.uf-linea { display: flex; justify-content: center; margin-top: -6px; }
.uf-pill { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--muted); font-size: 13px; font-weight: 600; }
.uf-pill b { color: var(--ink); }
.uf-pill.vieja b { color: var(--warn); }
.uf-tag { display: inline-block; margin-left: 6px; padding: 1px 6px; border-radius: 6px; background: var(--accent-soft); color: var(--accent);
  font-size: 10.5px; font-weight: 800; letter-spacing: .04em; vertical-align: middle; }
.pie { padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px)); display: flex; gap: 10px;
  background: var(--bg); border-top: 1px solid var(--line); }
.pie .btn-primary { flex: 1; }

/* Mes */
.mes-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.mes-nav .h1 { text-align: center; flex: 1; }
.resumen-mes { display: flex; flex-direction: column; gap: 14px; }
.queda { font-family: var(--display); font-size: 38px; font-weight: 700; letter-spacing: -.03em; line-height: 1; }
.queda.pos { color: var(--accent); } .queda.neg { color: var(--neg); }
.trio { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.trio div { background: var(--surface-2); border-radius: 12px; padding: 8px 10px; }
.trio small { display: block; color: var(--muted); font-size: 11.5px; font-weight: 600; }
.trio b { font-size: 14.5px; }
.aviso { display: flex; align-items: center; gap: 8px; background: var(--warn-soft); color: var(--warn);
  border-radius: 12px; padding: 10px 12px; font-weight: 600; font-size: 14px; }
.aviso.ok { background: var(--accent-soft); color: var(--accent); }
.grupo { display: flex; flex-direction: column; }
.grupo-h { display: flex; justify-content: space-between; align-items: baseline; padding: 0 4px 6px; }
.grupo-h span { font-size: 12.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.lista { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.item { display: flex; align-items: center; gap: 10px; min-height: 56px; padding: 6px 14px 6px 10px; border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: none; }
.item-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0;
  background: none; border: none; text-align: left; }
.chk { width: 30px; height: 30px; flex: none; border-radius: 50%; border: 2px solid var(--line); background: var(--surface);
  color: transparent; display: grid; place-items: center; font-weight: 800; font-size: 15px; }
.chk[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chk.vacio { visibility: hidden; }
.chk:disabled { cursor: default; border-style: dashed; }
.chk:disabled[aria-pressed="true"] { border-style: solid; }
.item.hecho .val { opacity: .8; }
.avance { display: flex; flex-wrap: wrap; gap: 2px 6px; font-size: 13px; color: var(--muted); font-weight: 600; }
.avance b { color: var(--ink); }
.item .nom { flex: 1; min-width: 0; font-weight: 600; }
.item .nom small { display: block; font-size: 12px; font-weight: 500; color: var(--muted); }
.item .val { font-weight: 700; white-space: nowrap; }
.item .val.vacio { color: var(--warn); font-weight: 700; font-size: 13.5px; background: var(--warn-soft);
  padding: 4px 10px; border-radius: 999px; }
.item .val.ing { color: var(--accent); }

/* Año */
.tabla-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; }
table.anual { border-collapse: collapse; font-size: 13px; min-width: 980px; width: 100%; }
.anual th, .anual td { padding: 8px 10px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
.anual th { font-size: 11.5px; color: var(--muted); font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.anual .c1 { text-align: left; position: sticky; left: 0; background: var(--surface); min-width: 150px; max-width: 170px;
  white-space: normal; font-weight: 600; }
.anual tr.gr td { text-align: left; font-size: 11.5px; font-weight: 700; color: var(--accent); letter-spacing: .05em;
  text-transform: uppercase; padding-top: 14px; }
.anual tr.tot td { font-weight: 700; background: var(--surface-2); }
.anual tr.tot td.c1 { background: var(--surface-2); }
.anual td.fut { color: var(--muted); opacity: .55; }
.anual td.vacio { color: var(--muted); }
.neg-t { color: var(--neg); } .pos-t { color: var(--accent); }

/* Resumen */
.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.kpi small { display: block; color: var(--muted); font-size: 12.5px; font-weight: 600; }
.kpi b { font-family: var(--display); font-size: 22px; letter-spacing: -.02em; }
.kpi.ancho { grid-column: 1 / -1; }
.leyenda { display: flex; gap: 14px; font-size: 12.5px; color: var(--muted); font-weight: 600; }
.leyenda i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
svg text { fill: var(--muted); font-family: var(--body); font-size: 10px; }
.barra { display: flex; flex-direction: column; gap: 6px; }
.barra-h { display: flex; justify-content: space-between; font-size: 14px; font-weight: 600; }
.barra-h span:last-child { color: var(--muted); }
.barra-t { height: 10px; border-radius: 6px; background: var(--surface-2); overflow: hidden; }
.barra-t span { display: block; height: 100%; border-radius: 6px; background: var(--neg); opacity: .8; }

/* Mis ítems */
.item-ed { display: flex; align-items: center; gap: 8px; min-height: 56px; padding: 8px 10px 8px 14px; border-bottom: 1px solid var(--line); }
.item-ed:last-child { border-bottom: none; }
.item-ed .nom { flex: 1; min-width: 0; font-weight: 600; }
.mini { min-height: 36px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2);
  font-size: 13.5px; font-weight: 600; }
.mini.peligro { color: var(--neg); }
.form { display: flex; flex-direction: column; gap: 10px; }
.form label { font-size: 13px; font-weight: 700; color: var(--muted); display: flex; flex-direction: column; gap: 6px; }
.check { display: flex !important; flex-direction: row !important; align-items: center; gap: 10px; font-size: 15px !important;
  color: var(--ink) !important; font-weight: 600 !important; min-height: 44px; }
.check input { width: 22px; height: 22px; accent-color: var(--accent); }

/* Barra inferior */
.tabs { display: grid; grid-template-columns: repeat(4, 1fr); background: var(--surface); border-top: 1px solid var(--line);
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom, 0px)); }
.tab { display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 52px; justify-content: center;
  background: none; border: none; border-radius: 12px; color: var(--muted); font-size: 12px; font-weight: 700; }
.tab svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tab[aria-current="page"] { color: var(--accent); background: var(--accent-soft); }

/* Hoja inferior */
.velo { position: absolute; inset: 0; background: rgba(8, 14, 13, .45); display: flex; align-items: flex-end; z-index: 10; }
.hoja { width: 100%; background: var(--surface); border-radius: 22px 22px 0 0; padding: 10px 18px calc(18px + env(safe-area-inset-bottom, 0px));
  display: flex; flex-direction: column; gap: 14px; max-height: 88%; overflow-y: auto; }
.hoja::before { content: ""; align-self: center; width: 40px; height: 5px; border-radius: 3px; background: var(--line); }
.hoja:focus { outline: none; }
.monto-grande { font-size: 30px !important; font-weight: 700; min-height: 64px !important; text-align: right; }
.fila-btns { display: flex; gap: 10px; }
.fila-btns .btn { flex: 1; }

@media (prefers-reduced-motion: no-preference) {
  .hoja { animation: sube .22s ease-out; }
  @keyframes sube { from { transform: translateY(30px); opacity: .6; } to { transform: none; opacity: 1; } }
}

/* ── Cuenta: entrada, invitación, ajustes ── */
.capa { position: absolute; inset: 0; z-index: 30; background: var(--bg); display: flex; flex-direction: column; }
.capa[hidden] { display: none; }
.pequeno { font-size: 13.5px; }
.centro { text-align: center; }
.estado-msg { min-height: 1.4em; }
.estado-msg.error { color: var(--neg); }
.btn-peligro { background: var(--neg-soft); color: var(--neg); border: 1px solid var(--neg); }
.btn-chico { min-height: 40px; font-size: 14px; padding: 0 14px; }
.btn[disabled] { opacity: .55; cursor: progress; }
.seccion { display: flex; flex-direction: column; gap: 12px; }
.fila-lista { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.fila-lista:last-child { border-bottom: none; }
.fila-lista .nom { flex: 1; min-width: 0; font-weight: 600; }
.fila-lista .nom small { display: block; font-size: 12.5px; font-weight: 500; color: var(--muted); }
.etiqueta { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 700;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.etiqueta.ok { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.enlace { display: flex; flex-direction: column; gap: 10px; background: var(--surface-2); border: 1px dashed var(--line);
  border-radius: 14px; padding: 12px; }
.enlace code { font-size: 13px; word-break: break-all; color: var(--ink); }
details.privacidad { background: var(--surface-2); border-radius: 12px; padding: 10px 12px; }
details.privacidad summary { cursor: pointer; font-weight: 700; color: var(--accent); }
details.privacidad ul { margin: 10px 0 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 14px; }
.aviso-flotante { position: absolute; left: 12px; right: 12px; bottom: calc(76px + env(safe-area-inset-bottom, 0px)); z-index: 40;
  background: var(--ink); color: var(--bg); border-radius: 12px; padding: 10px 14px; font-weight: 600; font-size: 14px;
  box-shadow: var(--shadow); }
.aviso-flotante[hidden] { display: none; }
