/* Blix Finance — "libro de cuentas privado": papel calido, tinta verde, numeros con voz propia. */

@font-face { font-family: 'Fraunces'; src: url('/static/fonts/fraunces.woff2') format('woff2'); font-weight: 100 900; font-display: swap; }
@font-face { font-family: 'Instrument Sans'; src: url('/static/fonts/instrument-sans.woff2') format('woff2'); font-weight: 400 700; font-display: swap; }

:root {
  color-scheme: light;
  --bg: #F4EFE6; --surface: #FFFDF8; --surface-2: #EFE9DC; --surface-3: #E6DFD0;
  --ink: #16211C; --ink-2: #47544C; --ink-3: #66726A; --line: #E0D8C8; --line-strong: #CBC2AF;
  --brand: #0E5C4A; --brand-ink: #F6F3E8; --brand-soft: #DCE9DF;
  --hero: #0E4A3C; --hero-ink: #F6F3E8; --hero-ink-2: #BFD6C8; --hero-line: rgba(246, 243, 232, .14); --hero-spark: #F2B8A0;
  --spend: #C8462B; --earn: #0F7A57;
  --good: #0F7A57; --good-soft: #DCEBDF; --warn: #8F5B00; --warn-soft: #F5E7C8; --bad: #B8371E; --bad-soft: #F8DFD6;
  --c0: #0F8560; --c1: #8F4CC0; --c2: #0097A7; --c3: #E0563A; --c4: #2C6CC0; --c5: #C08000; --c6: #C93D82; --c7: #6B8A14; --c8: #94998F;
  --shadow: 0 1px 2px rgba(40, 32, 16, .05), 0 8px 24px rgba(40, 32, 16, .06);
  --shadow-up: 0 -10px 40px rgba(20, 20, 10, .18);
  --radius: 18px; --radius-s: 12px;
  --sans: 'Instrument Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --serif: 'Fraunces', Georgia, 'Times New Roman', serif;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
}

:root:not([data-theme="light"]) { --dark-probe: 0; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0C1210; --surface: #161E1B; --surface-2: #1F2925; --surface-3: #2A3530;
    --ink: #EEF1EA; --ink-2: #B7C1B9; --ink-3: #8F9A92; --line: #29332E; --line-strong: #3A4640;
    --brand: #7FE0B8; --brand-ink: #0A1F18; --brand-soft: #1B3A2F;
    --hero: #123A2E; --hero-ink: #F1F5EC; --hero-ink-2: #A9CBB9; --hero-line: rgba(241, 245, 236, .1); --hero-spark: #FFB39C;
    --spend: #FF8A6B; --earn: #5FD3A6;
    --good: #5FD3A6; --good-soft: #17352A; --warn: #E8B64A; --warn-soft: #362B12; --bad: #FF8A6B; --bad-soft: #3B1F18;
    --c0: #2FA87C; --c1: #A56FDC; --c2: #1AA5B0; --c3: #E5654A; --c4: #4F8DE0; --c5: #BC8A10; --c6: #D86598; --c7: #84A12C; --c8: #6E7A73;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3); --shadow-up: 0 -10px 40px rgba(0, 0, 0, .55);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0C1210; --surface: #161E1B; --surface-2: #1F2925; --surface-3: #2A3530;
  --ink: #EEF1EA; --ink-2: #B7C1B9; --ink-3: #8F9A92; --line: #29332E; --line-strong: #3A4640;
  --brand: #7FE0B8; --brand-ink: #0A1F18; --brand-soft: #1B3A2F;
  --hero: #123A2E; --hero-ink: #F1F5EC; --hero-ink-2: #A9CBB9; --hero-line: rgba(241, 245, 236, .1); --hero-spark: #FFB39C;
  --spend: #FF8A6B; --earn: #5FD3A6;
  --good: #5FD3A6; --good-soft: #17352A; --warn: #E8B64A; --warn-soft: #362B12; --bad: #FF8A6B; --bad-soft: #3B1F18;
  --c0: #2FA87C; --c1: #A56FDC; --c2: #1AA5B0; --c3: #E5654A; --c4: #4F8DE0; --c5: #BC8A10; --c6: #D86598; --c7: #84A12C; --c8: #6E7A73;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3); --shadow-up: 0 -10px 40px rgba(0, 0, 0, .55);
}

* { 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: 400 15px/1.45 var(--sans); min-height: 100dvh; overflow-x: hidden; }
h1, h2, h3, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: inherit; }
svg { display: block; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 6px; }
.ic { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.num { font-variant-numeric: tabular-nums lining-nums; }
.serif { font-family: var(--serif); font-optical-sizing: auto; font-variant-numeric: lining-nums; }
.muted { color: var(--ink-3); } .small { font-size: 13px; } .tiny { font-size: 12px; }
.grow { flex: 1; min-width: 0; } .row { display: flex; align-items: center; gap: 10px; } .between { justify-content: space-between; } .wrap { flex-wrap: wrap; }
.stack { display: grid; gap: 10px; } .hidden { display: none !important; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pos { color: var(--earn); } .neg { color: var(--spend); }
body.privacy .amt { filter: blur(7px); user-select: none; }

/* ── Estructura ─────────────────────────────────────────── */
.shell { display: grid; min-height: 100dvh; }
.side { display: none; }
.main { padding: calc(16px + var(--safe-t)) 16px calc(104px + var(--safe-b)); max-width: 1180px; width: 100%; margin: 0 auto; min-width: 0; }
.topbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 12px; margin-bottom: 18px; }
.topbar > .row:last-child { margin-left: auto; gap: 2px; }
.page-title { font: 500 30px/1.1 var(--serif); letter-spacing: -.01em; }
.eyebrow { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); font-weight: 600; }
.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; color: var(--ink-2); position: relative; }
.icon-btn:hover { background: var(--surface-2); }

.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: grid; grid-template-columns: repeat(5, 1fr); align-items: end;
  background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line); padding: 6px 6px calc(6px + var(--safe-b)); }
.tab { display: grid; justify-items: center; gap: 2px; padding: 6px 0; font-size: 11px; color: var(--ink-3); font-weight: 500; min-height: 48px; position: relative; }
.tab.on { color: var(--brand); font-weight: 600; }
.tab-add { width: 56px; height: 56px; margin: -22px auto 2px; border-radius: 20px; background: var(--brand); color: var(--brand-ink); display: grid; place-items: center; box-shadow: 0 8px 20px color-mix(in srgb, var(--brand) 40%, transparent); }
.tab-add .ic { width: 26px; height: 26px; stroke-width: 2.2; }
.badge { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--spend); color: #fff; font-size: 11px; font-weight: 700; display: inline-grid; place-items: center; }
.tab .badge { position: absolute; top: 0; left: 50%; margin-left: 6px; }

@media (min-width: 960px) {
  .shell { grid-template-columns: 236px minmax(0, 1fr); }
  .tabbar { display: none; }
  .main { padding: 28px 36px 60px; }
  .side { display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100dvh; padding: 24px 14px; border-right: 1px solid var(--line); }
  .brand { display: flex; align-items: center; gap: 10px; padding: 2px 10px 20px; font: 600 21px var(--serif); letter-spacing: -.01em; }
  .brand img { width: 30px; height: 30px; border-radius: 9px; }
  .nav { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; color: var(--ink-2); font-weight: 500; width: 100%; text-align: left; }
  .nav:hover { background: var(--surface-2); }
  .nav.on { background: var(--brand-soft); color: var(--ink); font-weight: 600; }
  .nav.on .ic { color: var(--brand); }
  .nav .badge { margin-left: auto; }
  .side-add { margin-bottom: 14px; }
  .side-foot { margin-top: auto; padding: 10px 12px; font-size: 13px; color: var(--ink-3); }
}

/* ── Componentes ────────────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.card-title { font: 500 18px/1.2 var(--serif); }
.grid { display: grid; gap: 14px; }
@media (min-width: 720px) { .g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .span2 { grid-column: span 2; } }
@media (min-width: 1100px) { .g-home { grid-template-columns: repeat(12, minmax(0, 1fr)); } .c4 { grid-column: span 4; } .c5 { grid-column: span 5; } .c6 { grid-column: span 6; } .c7 { grid-column: span 7; } .c8 { grid-column: span 8; } .c12 { grid-column: span 12; } }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 16px; border-radius: 12px; font-weight: 600; border: 1px solid var(--line-strong); background: var(--surface); transition: transform .08s ease; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: transparent; }
.btn.primary:hover { background: color-mix(in srgb, var(--brand) 88%, var(--ink)); }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, transparent); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .55; pointer-events: none; }

.chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
.chip .ic { width: 13px; height: 13px; stroke-width: 2.2; }
.chip.good { background: var(--good-soft); color: var(--good); } .chip.warn { background: var(--warn-soft); color: var(--warn); } .chip.bad { background: var(--bad-soft); color: var(--bad); }

.seg { display: flex; padding: 3px; gap: 2px; background: var(--surface-2); border-radius: 12px; }
.seg button { flex: 1; min-height: 38px; padding: 0 12px; border-radius: 9px; font-weight: 600; font-size: 14px; color: var(--ink-3); white-space: nowrap; }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .1); }

.field { display: grid; gap: 5px; min-width: 0; grid-template-columns: minmax(0, 1fr); }
.field > label, .label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.input { width: 100%; min-width: 0; min-height: 46px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line-strong); background: var(--surface); font-size: 16px; appearance: none; -webkit-appearance: none; }
select.input { background-image: linear-gradient(45deg, transparent 50%, var(--ink-3) 50%), linear-gradient(135deg, var(--ink-3) 50%, transparent 50%); background-position: calc(100% - 18px) 20px, calc(100% - 13px) 20px; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 30px; }
.input:focus { outline: 2px solid var(--brand); outline-offset: -1px; border-color: transparent; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; min-height: 28px; }
.check input { width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--brand); flex: none; }
.hint { font-size: 12.5px; color: var(--ink-3); }
.form { display: grid; gap: 14px; }
.form-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.err { color: var(--bad); font-size: 14px; font-weight: 500; }

.list { display: grid; grid-template-columns: minmax(0, 1fr); }
.item { display: flex; align-items: center; gap: 12px; padding: 11px 2px; border-top: 1px solid var(--line); text-align: left; width: 100%; min-height: 58px; }
.list > .item:first-child { border-top: 0; }
button.item:hover { background: linear-gradient(90deg, transparent, var(--surface-2) 12%, var(--surface-2) 88%, transparent); }
.item-title { font-weight: 600; }
.glyph { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; flex: none; background: color-mix(in srgb, var(--tone, var(--c8)) 16%, var(--surface)); color: var(--tone, var(--ink-2)); }
.amount { font-weight: 600; font-variant-numeric: tabular-nums lining-nums; white-space: nowrap; text-align: right; }
.day-head { font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-3); padding: 16px 2px 6px; display: flex; justify-content: space-between; }
.empty { text-align: center; padding: 28px 12px; color: var(--ink-3); }
.empty .ic { width: 28px; height: 28px; margin: 0 auto 10px; }
.empty p { max-width: 34ch; margin: 0 auto 12px; }

.bar { height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 3px; background: var(--brand); }

/* ── Vaticinio ──────────────────────────────────────────── */
.hero { position: relative; overflow: hidden; background: var(--hero); color: var(--hero-ink); border-radius: 24px; padding: 22px; box-shadow: var(--shadow);
  background-image: repeating-linear-gradient(0deg, transparent 0 31px, var(--hero-line) 31px 32px); }
.hero .eyebrow { color: var(--hero-ink-2); }
.hero-value { font: 400 clamp(46px, 13vw, 76px)/1 var(--serif); letter-spacing: -.025em; margin: 10px 0 6px; font-variant-numeric: lining-nums; overflow-wrap: anywhere; }
.hero-sub { color: var(--hero-ink-2); font-size: 14px; }
.hero-track { display: flex; gap: 2px; height: 8px; margin: 18px 0 8px; border-radius: 4px; overflow: hidden; background: var(--hero-line); }
.hero-track i { display: block; height: 100%; }
.hero-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12.5px; color: var(--hero-ink-2); }
.hero-legend b { color: var(--hero-ink); font-weight: 600; }
.hero-legend span { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 8px; height: 8px; border-radius: 3px; display: inline-block; flex: none; }
.hero-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--hero-line); }
.hero-stats strong { display: block; font: 500 21px/1.2 var(--serif); font-variant-numeric: lining-nums; }
.hero button.link { color: inherit; text-decoration: underline; text-underline-offset: 3px; font-weight: 600; }

.quickbar { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 16px; padding: 5px 5px 5px 14px; }
.quickbar input { flex: 1; min-width: 0; border: 0; background: none; outline: 0; font-size: 16px; min-height: 42px; }
.quickbar:focus-within { outline: 2px solid var(--brand); outline-offset: -1px; }
.stat-value { font: 500 24px/1.15 var(--serif); font-variant-numeric: lining-nums; overflow-wrap: anywhere; }

.month-nav { display: flex; align-items: center; gap: 2px; }
.month-nav strong { font-weight: 600; min-width: 112px; text-align: center; text-transform: capitalize; font-size: 14px; }

/* ── Graficos ───────────────────────────────────────────── */
.chart { width: 100%; height: auto; overflow: visible; touch-action: pan-y; }
.chart text { fill: var(--ink-3); font: 500 11px var(--sans); font-variant-numeric: tabular-nums; }
.chart .grid-line { stroke: var(--line); stroke-width: 1; }
.chart .hit { fill: transparent; }
.chart .cross { stroke: var(--line-strong); stroke-width: 1; }
[data-tip] { cursor: default; }
.mark:hover { opacity: .82; }
#tip { position: fixed; z-index: 90; pointer-events: none; opacity: 0; background: var(--ink); color: var(--bg); font-size: 12.5px; line-height: 1.4; padding: 7px 10px; border-radius: 9px; max-width: 240px; transition: opacity .1s; white-space: pre-line; font-variant-numeric: tabular-nums; }
#tip.on { opacity: 1; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12.5px; color: var(--ink-2); margin-bottom: 10px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.donut-wrap { display: grid; gap: 16px; }
.donut { width: 100%; max-width: 190px; margin: 0 auto; }
.donut text { fill: var(--ink); }
@media (min-width: 720px) { .donut-wrap { grid-template-columns: 180px minmax(0, 1fr); align-items: start; } }
details.table-view summary { cursor: pointer; font-size: 12.5px; color: var(--ink-3); margin-top: 8px; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 8px; font-variant-numeric: tabular-nums; }
table.data th, table.data td { padding: 6px 4px; text-align: right; border-top: 1px solid var(--line); }
table.data th:first-child, table.data td:first-child { text-align: left; }
table.data th { color: var(--ink-3); font-weight: 600; border-top: 0; }

/* ── Sheet / modal ──────────────────────────────────────── */
.scrim { position: fixed; inset: 0; z-index: 50; background: rgba(8, 12, 10, .5); display: flex; align-items: flex-end; justify-content: center; animation: fade .16s ease; }
.sheet { width: 100%; max-width: 560px; max-height: 92dvh; overflow-y: auto; overscroll-behavior: contain; background: var(--surface); border-radius: 24px 24px 0 0; padding: 10px 18px calc(20px + var(--safe-b)); box-shadow: var(--shadow-up); animation: rise .22s cubic-bezier(.2, .8, .2, 1); }
.grabber { width: 40px; height: 4px; border-radius: 2px; background: var(--line-strong); margin: 0 auto 12px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 10px; }
.sheet-title { font: 500 22px/1.2 var(--serif); }
.sheet-actions { display: flex; gap: 10px; margin-top: 4px; }
.sheet-actions .primary { flex: 1; }
@media (min-width: 720px) { .scrim { align-items: center; } .sheet { border-radius: 24px; padding: 20px 24px 24px; } .grabber { display: none; } }
@keyframes rise { from { transform: translateY(24px); opacity: .4; } }
@keyframes fade { from { opacity: 0; } }

.amount-input { display: flex; align-items: baseline; gap: 8px; border-bottom: 2px solid var(--line-strong); padding-bottom: 4px; }
.amount-input:focus-within { border-color: var(--brand); }
.amount-input input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; font: 400 46px/1.1 var(--serif); letter-spacing: -.02em; font-variant-numeric: lining-nums; }
.pills { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.pills::-webkit-scrollbar { display: none; }
.pill { flex: none; min-height: 36px; padding: 0 12px; border-radius: 10px; font-weight: 600; font-size: 13px; background: var(--surface-2); color: var(--ink-2); }
.pill.on { background: var(--brand); color: var(--brand-ink); }
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 6px; }
.cat-opt { display: grid; justify-items: center; gap: 4px; padding: 8px 2px; border-radius: 12px; font-size: 11.5px; font-weight: 500; color: var(--ink-2); line-height: 1.15; text-align: center; border: 1.5px solid transparent; }
.cat-opt .glyph { width: 34px; height: 34px; }
.cat-opt.on { border-color: var(--brand); background: var(--brand-soft); color: var(--ink); font-weight: 600; }

.split-row { display: grid; grid-template-columns: 24px minmax(0, 1fr) 96px; gap: 10px; align-items: center; min-height: 46px; }
.split-row input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--brand); margin: 0; }
.split-row .input { min-height: 38px; padding: 6px 8px; text-align: right; }
.code-box { font: 600 13px/1.5 ui-monospace, 'Cascadia Mono', Consolas, monospace; background: var(--surface-2); border-radius: 10px; padding: 10px 12px; overflow-wrap: anywhere; user-select: all; }
.invite-code { font: 500 30px/1.1 var(--serif); letter-spacing: .1em; text-align: center; padding: 14px; background: var(--surface-2); border-radius: 14px; user-select: all; }
.steps { padding-left: 20px; margin: 0; display: grid; gap: 8px; font-size: 14px; }

#toast { position: fixed; left: 50%; bottom: calc(92px + var(--safe-b)); transform: translate(-50%, 16px); z-index: 80; background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 500; font-size: 14px; opacity: 0; pointer-events: none; transition: .18s ease; max-width: min(92vw, 440px); text-align: center; }
#toast.on { opacity: 1; transform: translate(-50%, 0); }
@media (min-width: 960px) { #toast { bottom: 32px; } }

/* ── Acceso ─────────────────────────────────────────────── */
.auth { min-height: 100dvh; display: grid; }
.auth-art { display: none; background: var(--hero); color: var(--hero-ink); padding: 48px; flex-direction: column; justify-content: space-between; background-image: repeating-linear-gradient(0deg, transparent 0 39px, var(--hero-line) 39px 40px); }
.auth-art h1 { font: 400 clamp(52px, 6vw, 84px)/.98 var(--serif); letter-spacing: -.03em; max-width: 9ch; }
.auth-art h1 em { color: var(--hero-spark); font-style: normal; }
.auth-form { display: flex; flex-direction: column; justify-content: center; padding: calc(28px + var(--safe-t)) 20px 28px; width: 100%; max-width: 440px; margin: 0 auto; gap: 18px; }
.auth-logo { display: flex; align-items: center; gap: 10px; font: 600 22px var(--serif); }
.auth-logo img { width: 34px; height: 34px; border-radius: 10px; }
.auth-form h2 { font: 400 34px/1.08 var(--serif); letter-spacing: -.02em; }
@media (min-width: 900px) { .auth { grid-template-columns: 1.1fr 1fr; } .auth-art { display: flex; } }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
@media (forced-colors: active) { .bar > i, .hero-track i { background: Highlight; } }
