:root {
  --bg: #f1f3f6;
  --surface: #ffffff;
  --sunk: #f5f7fa;
  --ink: #13213a;
  --ink2: #48556b;
  --muted: #758197;
  --line: #e2e6ec;
  --accent: #1c5cab;
  --accent-soft: #e6eef9;
  --pos: #0f7a55;
  --neg: #bf3b2b;
  --warn: #a8660c;
  --s1: #2a78d6;
  --s2: #eb6834;
  --r-block: 20px;
  --r-ctl: 12px;
  --font: 'Geist', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 15px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
body.locked { overflow: hidden; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
.num { font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.pos { color: var(--pos); } .neg { color: var(--neg); } .muted { color: var(--ink2); }
h1, h2, h3, p { margin: 0; }

#app { max-width: 520px; margin: 0 auto; min-height: 100vh; }
.view { padding: calc(env(safe-area-inset-top, 0px) + 12px) 16px calc(110px + var(--safe-b)); }
.demo-bar { background: #fff4e5; color: #8a4b00; text-align: center; font-size: 12.5px; padding: 6px; }

/* Encabezados */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; margin: 4px 0 14px; }
.top h1 { font-size: 24px; font-weight: 650; letter-spacing: -0.02em; flex: 1; }
.top .icon-btn + h1 { text-align: center; }
.eyebrow-date { color: var(--muted); font-size: 13px; }
.hello { font-size: 22px; font-weight: 650; letter-spacing: -0.02em; }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; color: var(--ink2); flex: none; }
.icon-btn:active { background: var(--line); }
.icon-btn:disabled { opacity: .3; cursor: default; }

/* Patrimonio */
.hero { padding: 10px 2px 22px; }
.hero-label { color: var(--ink2); font-size: 14px; }
.hero-num { font-size: clamp(40px, 12vw, 52px); font-weight: 600; letter-spacing: -0.035em; line-height: 1.05; margin: 4px 0 16px; }
.hero-num .cur { font-size: .5em; font-weight: 500; color: var(--muted); margin-right: 4px; vertical-align: .55em; letter-spacing: 0; }
.split { display: flex; gap: 2px; height: 10px; border-radius: 6px; overflow: hidden; background: var(--line); }
.split span { min-width: 3px; }
.split span:first-child { border-radius: 6px 0 0 6px; } .split span:last-child { border-radius: 0 6px 6px 0; } .split span:only-child { border-radius: 6px; }
.hero-legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 10px; font-size: 13.5px; color: var(--ink2); }
.hero-legend i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; vertical-align: 1px; }
.hero-legend b { color: var(--ink); font-weight: 600; margin-left: 4px; }
.hero-foot { margin-top: 10px; font-size: 13.5px; color: var(--muted); }
.hero-foot b { color: var(--ink2); font-weight: 600; }

/* Dólar blue */
.blue { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 4px 12px; background: var(--surface); border-radius: var(--r-block); padding: 14px 16px; margin-bottom: 12px; cursor: pointer; }
.blue-name { font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.blue-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--s2); box-shadow: 0 0 0 4px #fdebe3; }
.blue-vals { display: flex; justify-content: flex-end; gap: 20px; }
.blue-vals span { display: flex; flex-direction: column; align-items: flex-end; }
.blue-vals small { color: var(--muted); font-size: 12px; }
.blue-vals b { font-size: 17px; font-weight: 600; }
.blue-time { grid-column: 1 / -1; color: var(--muted); font-size: 12.5px; }

/* Bloques */
.block { background: var(--surface); border-radius: var(--r-block); padding: 16px; margin-bottom: 12px; }
.block-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; gap: 12px; }
.block-head h2 { font-size: 16px; font-weight: 650; letter-spacing: -0.01em; }
.link { color: var(--accent); font-weight: 550; font-size: 14px; }
.empty { color: var(--muted); font-size: 14px; padding: 6px 0 2px; }
.empty.ok::before { content: '✓ '; color: var(--pos); font-weight: 700; }
.note { color: var(--muted); font-size: 13px; margin: -4px 4px 12px; }
.hint { color: var(--ink2); font-size: 13.5px; margin: 6px 0 10px; }
.mini-h { color: var(--muted); font-size: 13px; margin: 6px 0 8px; }
.big-line { margin: 0 0 12px; font-size: 15px; color: var(--ink2); }
.big-line b { font-size: 20px; color: var(--ink); font-weight: 650; }
.big-line span { color: var(--muted); font-size: 13.5px; }

/* Alertas */
.alert { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--accent-soft); border-radius: 16px; padding: 12px 14px; margin-bottom: 12px; }
.alert strong { display: block; font-size: 14.5px; font-weight: 600; }
.alert span { color: var(--ink2); font-size: 13px; }
.alert.warn { background: #fdf0dc; }
.alert.soft { background: var(--surface); border: 1px dashed var(--line); }

/* Filas */
.list { display: flex; flex-direction: column; }
.row { display: grid; grid-template-columns: 38px 1fr auto; align-items: center; gap: 12px; padding: 10px 0; text-align: left; width: 100%; border-top: 1px solid var(--line); }
.list > .row:first-child { border-top: 0; }
.row-ico { width: 38px; height: 38px; border-radius: 12px; background: var(--sunk); display: grid; place-items: center; font-size: 18px; }
.row-main { min-width: 0; display: flex; flex-direction: column; }
.row-title { font-weight: 550; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-amt { font-weight: 600; font-size: 15px; text-align: right; display: flex; flex-direction: column; align-items: flex-end; white-space: nowrap; }
.row-amt small { color: var(--muted); font-size: 12px; font-weight: 500; }
.row-actions { display: flex; gap: 6px; }
.row.static { cursor: default; }
button.row:active { background: var(--sunk); }
.list.pend { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 4px; }
.day { font-size: 13px; color: var(--muted); font-weight: 550; margin: 14px 0 2px; }
.block .day:first-of-type { margin-top: 0; }
#mvlist .list, .view > #mvlist .list { background: var(--surface); border-radius: var(--r-block); padding: 2px 16px; }
.prog { display: block; height: 4px; background: var(--line); border-radius: 3px; margin-top: 6px; overflow: hidden; }
.prog span { display: block; height: 100%; background: var(--s1); border-radius: 3px; }
.badge { display: inline-block; font-size: 11.5px; font-weight: 550; color: var(--ink2); background: var(--sunk); border-radius: 6px; padding: 1px 6px; margin-left: 6px; vertical-align: 1px; }
.badge.ok { color: var(--pos); background: #e3f4ec; } .badge.warn { color: var(--warn); background: #fdf0dc; }

/* Mes */
.trio { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.trio div { display: flex; flex-direction: column; }
.trio small { color: var(--muted); font-size: 12.5px; }
.trio b { font-size: 16px; font-weight: 650; }
.meter { height: 6px; background: var(--line); border-radius: 4px; margin-top: 14px; overflow: hidden; }
.meter div { height: 100%; background: var(--ink); border-radius: 4px; }
.meter-cap { color: var(--muted); font-size: 13px; margin-top: 8px; }
.mswitch { display: flex; align-items: center; justify-content: space-between; background: var(--surface); border-radius: 999px; padding: 4px; margin-bottom: 12px; font-weight: 600; }

/* Reportes */
.summary { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.summary > div { background: var(--surface); border-radius: var(--r-block); padding: 14px 16px; display: flex; flex-direction: column; }
.summary small { color: var(--muted); font-size: 13px; }
.summary b { font-size: 19px; font-weight: 650; color: var(--ink); }
.summary .sv { grid-column: 1 / -1; }
.summary .sv b { font-size: 30px; letter-spacing: -0.03em; }
.summary .sv.pos b { color: var(--pos); } .summary .sv.neg b { color: var(--neg); }
.summary em { font-style: normal; color: var(--ink2); font-size: 13.5px; }
.insights { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.insights li { position: relative; padding-left: 18px; font-size: 14.5px; }
.insights li::before { content: ''; position: absolute; left: 2px; top: .55em; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.insights li.pos::before { background: var(--pos); } .insights li.neg::before { background: var(--neg); }
.rank { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 14px; }
.rank-top { display: flex; justify-content: space-between; gap: 10px; font-size: 14.5px; }
.rank-label { display: flex; gap: 8px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-val { font-weight: 600; }
.rank-track { height: 8px; border-radius: 0 4px 4px 0; margin-top: 6px; }
.rank-bar { height: 100%; background: var(--s1); border-radius: 0 4px 4px 0; }
.rank-sub { color: var(--muted); font-size: 12px; margin-top: 3px; }
.rank li.tip-on .rank-bar { background: #1c5cab; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 13px; color: var(--ink2); margin-bottom: 6px; }
.legend i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; }
.chart { width: 100%; height: auto; display: block; overflow: visible; touch-action: pan-y; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .base { stroke: #c9d0da; stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 10.5px; font-family: var(--font); }
.chart .axis.strong { fill: var(--ink); font-weight: 600; }
.chart .vlabel { fill: var(--ink2); font-size: 11px; font-family: var(--font); font-variant-numeric: tabular-nums; }
.chart .vlabel.strong { fill: var(--ink); font-weight: 600; }
.chart .hit { fill: transparent; }
.chart .hit.tip-on { fill: rgba(19, 33, 58, .05); }
.chart.line .hit.tip-on { fill: transparent; }
.chart .xh { stroke: var(--ink2); stroke-width: 1; stroke-dasharray: 3 3; }
.chart .xd { fill: var(--surface); stroke: var(--ink); stroke-width: 2; }
.empty-chart { color: var(--muted); font-size: 13.5px; padding: 18px 0; text-align: center; }
#tip { position: fixed; z-index: 60; display: none; pointer-events: none; background: var(--ink); color: #fff; font-size: 12.5px; line-height: 1.4; padding: 7px 10px; border-radius: 10px; white-space: pre-line; max-width: 240px; font-variant-numeric: tabular-nums; }

/* Tarjeta */
.statement { background: var(--surface); border-radius: var(--r-block); padding: 18px 16px; margin-bottom: 12px; }
.st-status { font-size: 13.5px; color: var(--ink2); font-weight: 550; }
.st-status.warn { color: var(--warn); }
.st-total { font-size: 36px; font-weight: 600; letter-spacing: -0.03em; margin-top: 2px; }
.st-usd { font-size: 18px; font-weight: 600; color: var(--ink2); }
.st-split { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0; padding: 12px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.st-split div { display: flex; flex-direction: column; }
.st-split small { color: var(--muted); font-size: 12.5px; }
.st-split b { font-weight: 600; font-size: 16px; }
.st-split em { font-style: normal; font-size: 13px; color: var(--ink2); }
.st-dates { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: baseline; font-size: 13.5px; color: var(--muted); }
.st-dates b { color: var(--ink); font-weight: 600; }
.st-dates .link { margin-left: auto; font-size: 13.5px; }
.st-paid { margin-top: 10px; font-size: 13.5px; color: var(--ink2); }
.actions3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-bottom: 14px; }
.actions2 { display: flex; flex-wrap: wrap; gap: 8px; }

/* Botones */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; background: var(--accent); color: #fff; font-weight: 600; font-size: 15px; height: 46px; padding: 0 18px; border-radius: var(--r-ctl); transition: transform .08s; white-space: nowrap; }
.btn:active { transform: scale(.98); }
.btn.sm { height: 34px; padding: 0 12px; font-size: 13.5px; border-radius: 10px; }
.btn.ghost { background: var(--accent-soft); color: var(--accent); }
.btn.ghost.danger { background: #fbe9e6; color: var(--neg); }
.btn.danger-solid { background: var(--neg); }
.btn:disabled { opacity: .55; }
.btn.loading { pointer-events: none; }
.block-btn { width: 100%; margin-top: 14px; }

/* Chips y segmentos */
.chips { display: flex; gap: 8px; margin-bottom: 12px; }
.chips.wrap { flex-wrap: wrap; }
.chips.scroll { overflow-x: auto; scrollbar-width: none; margin-left: -16px; margin-right: -16px; padding: 0 16px; }
.chips.scroll::-webkit-scrollbar { display: none; }
.chip { height: 36px; padding: 0 14px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); font-size: 14px; white-space: nowrap; flex: none; }
.chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.chip-in { width: 76px; height: 36px; border-radius: 999px; border: 1px solid var(--line); padding: 0 12px; background: var(--surface); font-size: 14px; }
.cats .chip { height: 38px; }
.seg { display: flex; background: var(--sunk); border-radius: var(--r-ctl); padding: 3px; gap: 3px; margin-bottom: 14px; overflow-x: auto; scrollbar-width: none; }
.seg button { flex: 1 0 auto; height: 38px; border-radius: 10px; font-size: 14px; font-weight: 550; color: var(--ink2); padding: 0 10px; }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(19, 33, 58, .12); }
.search input { width: 100%; height: 44px; border-radius: var(--r-ctl); border: 1px solid var(--line); background: var(--surface); padding: 0 14px; margin-bottom: 10px; font-size: 15px; }

/* Formularios */
label { display: flex; flex-direction: column; gap: 6px; font-size: 13.5px; color: var(--ink2); margin-bottom: 14px; }
label input, label select { height: 46px; border: 1px solid var(--line); border-radius: var(--r-ctl); padding: 0 12px; background: var(--surface); font-size: 16px; color: var(--ink); width: 100%; min-width: 0; }
label input[type="date"] { -webkit-appearance: none; appearance: none; }
label.check { flex-direction: row; align-items: center; gap: 10px; }
label.check input { width: 20px; height: 20px; }
.form-row.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.lbl { font-size: 13.5px; color: var(--ink2); margin-bottom: 8px; }
.amount { margin-bottom: 12px; }
.amount-l { font-size: 13.5px; }
.amount-in { display: flex; align-items: baseline; gap: 8px; border-bottom: 2px solid var(--line); padding-bottom: 4px; }
.amount-in:focus-within { border-color: var(--accent); }
.amount-cur { font-size: 22px; color: var(--muted); font-weight: 500; }
.amount-in input { border: 0; outline: 0; height: auto; padding: 0; font-size: 34px; font-weight: 600; letter-spacing: -0.02em; background: transparent; width: 100%; font-variant-numeric: tabular-nums; }
.calc { font-size: 14px; color: var(--ink2); margin: -2px 0 14px; }
.err { color: var(--neg); font-size: 14px; margin-bottom: 8px; }
.emojis { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.emojis button { height: 42px; border-radius: 10px; font-size: 20px; background: var(--sunk); }
.emojis button.on { background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent); }

/* Hoja inferior */
#sheet { position: fixed; inset: 0; z-index: 40; display: none; }
#sheet.open { display: block; }
.scrim { position: absolute; inset: 0; background: rgba(19, 33, 58, .38); }
.panel { position: absolute; left: 0; right: 0; bottom: 0; margin: 0 auto; max-width: 520px; max-height: 92vh; max-height: 92dvh; background: var(--surface); border-radius: 22px 22px 0 0; display: flex; flex-direction: column; }
.panel.enter { animation: up .24s cubic-bezier(.2, .8, .2, 1); }
@keyframes up { from { transform: translateY(40px); opacity: .4; } to { transform: none; opacity: 1; } }
.panel > .seg { margin: 0 16px 6px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 10px 8px 18px; }
.sheet-head h2 { font-size: 18px; font-weight: 650; }
.sheet-body { padding: 8px 18px 4px; overflow-y: auto; -webkit-overflow-scrolling: touch; flex: 1; }
.sheet-body.menu .row { border-top: 1px solid var(--line); }
.sheet-body.menu .row:first-child { border-top: 0; }
.sheet-foot { display: flex; gap: 10px; padding: 10px 18px calc(12px + var(--safe-b)); border-top: 1px solid var(--line); }
.sheet-foot .btn { flex: 1; }
.sheet-foot .btn.ghost.danger { flex: 0 0 auto; }

/* Navegación */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; max-width: 520px; margin: 0 auto; display: grid; grid-template-columns: 1fr 1fr 76px 1fr 1fr; align-items: center; background: rgba(255, 255, 255, .94); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-top: 1px solid var(--line); padding: 6px 6px calc(6px + var(--safe-b)); }
.tab { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: var(--muted); padding: 4px 0; }
.tab.on { color: var(--accent); font-weight: 600; }
.fab { width: 58px; height: 58px; border-radius: 20px; background: var(--accent); color: #fff; display: grid; place-items: center; justify-self: center; margin-top: -26px; box-shadow: 0 8px 20px rgba(28, 92, 171, .35); }
.fab:active { transform: scale(.96); }

/* Toast */
.toast { position: fixed; left: 50%; bottom: calc(96px + var(--safe-b)); transform: translate(-50%, 20px); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; opacity: 0; pointer-events: none; transition: .2s; z-index: 70; max-width: calc(100vw - 32px); text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: var(--neg); }

/* Login y carga */
.login { padding: calc(env(safe-area-inset-top, 0px) + 56px) 24px 40px; max-width: 420px; margin: 0 auto; }
.login-mark { margin-bottom: 18px; }
.login h1 { font-size: 30px; font-weight: 650; letter-spacing: -0.03em; }
.login-sub { color: var(--ink2); margin: 6px 0 24px; }
.login-msg { background: var(--accent-soft); border-radius: 14px; padding: 12px 14px; margin-bottom: 18px; font-size: 14px; }
.login .link { display: block; margin: 18px auto 0; }
.loading { min-height: 80vh; display: grid; place-content: center; justify-items: center; gap: 14px; color: var(--ink2); padding: 24px; text-align: center; }
.spinner { width: 30px; height: 30px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
@media (min-width: 560px) { .view { padding-top: 28px; } }
.row.rec { grid-template-columns: 38px 1fr; align-items: start; }
.row.rec .row-actions { margin-top: 10px; flex-wrap: wrap; }
.rec-amt { color: var(--ink2); font-weight: 500; margin-left: 4px; }
.chart .xh, .chart .xd { opacity: 0; }
.chart .xh[x1]:not([x1="-10"]), .chart .xd:not([cx="-10"]) { opacity: 1; }
.hint.ref { margin: -4px 0 14px; color: var(--accent); }
