:root {
  --bg: #f5f6f8; --surface: #ffffff; --surface-2: #eef0f3; --text: #16181d; --muted: #5d6470;
  --border: #dde1e6; --primary: #1f7a5a; --primary-text: #ffffff; --primary-soft: #dcefe7;
  --danger: #b3261e; --warn: #9a6700; --warn-soft: #fff4d6; --ok-soft: #dcefe7; --bad-soft: #fde2df;
  --radius: 14px; --nav-h: 64px; --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.06);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101215; --surface: #1a1d22; --surface-2: #24282e; --text: #eceef1; --muted: #9aa1ac;
    --border: #30353c; --primary: #3fbf8f; --primary-text: #0b1f17; --primary-soft: #183a2d;
    --danger: #ff8a80; --warn: #f2c14e; --warn-soft: #3a3016; --ok-soft: #183a2d; --bad-soft: #3d1f1c;
    --shadow: none;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; overscroll-behavior-y: contain; }
button, input, select { font: inherit; color: inherit; }
main { max-width: 720px; margin: 0 auto; padding: 12px 16px calc(var(--nav-h) + 96px + env(safe-area-inset-bottom)); }
h1 { font-size: 20px; margin: 4px 0 12px; }
h2 { font-size: 15px; margin: 20px 0 8px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.view { display: none; } .view.activa { display: block; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.card + .card { margin-top: 10px; }
.muted { color: var(--muted); font-size: 14px; }
.fila { display: flex; gap: 8px; align-items: center; }
.fila > .crece { flex: 1; min-width: 0; }
.oculto { display: none !important; }

/* Monto */
.monto { display: flex; align-items: center; gap: 8px; }
.monto input { flex: 1; min-width: 0; font-size: 40px; font-weight: 700; border: 0; background: transparent; outline: none; padding: 4px 0; }
.moneda-btn { min-width: 64px; height: 48px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2); font-weight: 700; }

.campo { display: block; width: 100%; height: 48px; padding: 0 12px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); }
.campo:focus, .monto input:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
label.lbl { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 6px; }

/* Chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 2px 16px; }
.chips.scroll::-webkit-scrollbar { display: none; }
.chip { flex: none; min-height: 44px; padding: 0 14px; border-radius: 22px; border: 1px solid var(--border); background: var(--surface); white-space: nowrap; }
.chip.sel { background: var(--primary); color: var(--primary-text); border-color: var(--primary); font-weight: 600; }
.chip small { opacity: .7; }

/* Botones */
.btn { min-height: 48px; padding: 0 18px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); font-weight: 600; }
.btn.primario { background: var(--primary); color: var(--primary-text); border-color: var(--primary); }
.btn.bloque { width: 100%; }
.btn:disabled { opacity: .5; }
.icon-btn { width: 44px; height: 44px; border-radius: 22px; border: 0; background: transparent; display: inline-grid; place-items: center; }

.accion-fija { position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding: 10px 16px;
  background: linear-gradient(to top, var(--bg) 70%, transparent); }
.accion-fija > div { max-width: 720px; margin: 0 auto; display: flex; gap: 8px; }
.accion-fija .btn { flex: 1; }

/* Navegación inferior */
nav.tabs { position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom); background: var(--surface); border-top: 1px solid var(--border); display: flex; z-index: 5; }
nav.tabs button { flex: 1; border: 0; background: transparent; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 12px; color: var(--muted); }
nav.tabs button.activa { color: var(--primary); font-weight: 700; }
nav.tabs svg { width: 24px; height: 24px; }

/* Lista de movimientos */
.mov { padding: 12px 14px; }
.mov .titulo { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mov .importe { font-weight: 700; white-space: nowrap; }
.mov .meta { font-size: 13px; color: var(--muted); margin-top: 2px; }
.mov .clasif { margin-top: 10px; display: flex; gap: 8px; align-items: center; }
.mov .clasif .chip { flex: 1; text-align: left; overflow: hidden; text-overflow: ellipsis; }
.mov.ignorado { opacity: .5; }
.badge { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 10px; background: var(--surface-2); color: var(--muted); }
.conf-alta { border-left: 4px solid var(--primary); }
.conf-media { border-left: 4px solid var(--warn); }
.conf-baja, .conf-ninguna { border-left: 4px solid var(--danger); }
.conf-manual { border-left: 4px solid var(--primary); }
.b-warn { background: var(--warn-soft); color: var(--warn); }
.b-ok { background: var(--ok-soft); color: var(--primary); }
.b-bad { background: var(--bad-soft); color: var(--danger); }
.check { display: flex; align-items: center; gap: 8px; min-height: 44px; font-size: 14px; }
.check input { width: 22px; height: 22px; accent-color: var(--primary); }

.archivo { display: grid; place-items: center; gap: 6px; text-align: center; padding: 28px 16px; border: 2px dashed var(--border); border-radius: var(--radius); background: var(--surface); }
.archivo input { display: none; }

/* Resumen */
.total-grande { font-size: 32px; font-weight: 800; }
.barra { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; margin-top: 6px; }
.barra > i { display: block; height: 100%; background: var(--primary); }
details summary { list-style: none; cursor: pointer; }
details summary::-webkit-details-marker { display: none; }
.subs { margin-top: 8px; font-size: 14px; }
.subs > div, .subs summary { display: flex; justify-content: space-between; gap: 8px; padding: 4px 0; border-top: 1px solid var(--border); }
.subs summary { padding: 8px 0; }
.subs details[open] summary { font-weight: 600; }
.detalle { padding: 0 0 6px 12px; font-size: 13px; }
.detalle div { display: flex; justify-content: space-between; gap: 8px; padding: 4px 0; }

/* Pagos */
.pago { cursor: pointer; }
.pago input { width: 24px; height: 24px; flex: none; accent-color: var(--primary); }
.pago.pagado .titulo, .pago.pagado .importe { color: var(--muted); }
.mes-nav { display: flex; align-items: center; justify-content: space-between; }

/* Hoja inferior (selector) */
.velo { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 10; display: flex; align-items: flex-end; justify-content: center; }
.hoja { background: var(--surface); width: 100%; max-width: 720px; max-height: 85vh; overflow: auto; border-radius: 18px 18px 0 0;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); }
.hoja .asa { width: 40px; height: 4px; border-radius: 2px; background: var(--border); margin: 0 auto 12px; }
.lista-op div { display: flex; justify-content: space-between; gap: 8px; padding: 8px 0; border-top: 1px solid var(--border); font-size: 14px; }

.toast { position: fixed; left: 16px; right: 16px; bottom: calc(var(--nav-h) + 84px + env(safe-area-inset-bottom)); max-width: 560px; margin: 0 auto;
  background: var(--text); color: var(--bg); padding: 12px 16px; border-radius: 12px; display: flex; gap: 12px; align-items: center; z-index: 20; }
.toast button { background: transparent; border: 0; color: var(--primary); font-weight: 700; min-height: 36px; }
.cargando { opacity: .6; pointer-events: none; }

@media (min-width: 768px) {
  main { padding-top: 24px; }
  .mov-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .mov-grid .card + .card { margin-top: 0; }
}

/* Login y carga inicial */
.pantalla-centro { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 24px 16px; text-align: center; }
.pantalla-centro .btn { min-width: 220px; }
