:root {
  color-scheme: light;
  --page: #f6f6f3;
  --surface: #fcfcfb;
  --surface-2: #f1f0ec;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --accent: #2a78d6;
  --accent-ink: #ffffff;
  --accent-soft: #e6f0fc;
  --good: #006300;
  --bad: #c22f2f;
  --warn-bg: #fff5dc;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.04);
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
  --s5: #e87ba4; --s6: #008300; --s7: #6250d6; --s8: #e34948;
  --other: #b4b2a9;
  --div-neg: #2a78d6; --div-pos: #e34948;
  --radius: 12px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--page);
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #232321;
    --ink: #f0efec;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --accent: #3987e5;
    --accent-soft: #1b2b40;
    --good: #0ca30c;
    --bad: #e66767;
    --warn-bg: #3a2e10;
    --shadow: none;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
    --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
    --other: #5f5e59;
    --div-neg: #3987e5; --div-pos: #e66767;
  }
}
* { box-sizing: border-box; }
body { margin: 0; }
a { color: var(--accent); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 22px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
.num, td.num, .tabular { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.ink2 { color: var(--ink-2); }
.small { font-size: 12px; }
.good { color: var(--good); }
.bad { color: var(--bad); }
.hidden { display: none !important; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; }
.stack > * + * { margin-top: 16px; }

/* ---------- layout ---------- */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--border); padding: 18px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; font-weight: 700; font-size: 17px; }
.brand svg { width: 28px; height: 28px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: var(--ink-2); font-weight: 500; }
.nav a:hover { background: var(--surface-2); }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.nav .ico { width: 18px; text-align: center; }
.nav .badge { margin-left: auto; background: var(--s2); color: #fff; border-radius: 10px; font-size: 11px; padding: 0 7px; font-weight: 600; }
.side-foot { margin-top: auto; padding: 10px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--border); }
.side-foot b { color: var(--ink); display: block; font-size: 13px; }
main { padding: 24px 28px 60px; max-width: 1280px; width: 100%; }
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { margin-right: auto; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 12px; }
.card-head h2 { margin-right: auto; }
.grid { display: grid; gap: 16px; }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, 1fr); } .g-main, .g3 { grid-template-columns: 1fr; } }
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; bottom: 0; top: auto; height: auto; width: 100%; z-index: 20; flex-direction: row; padding: 4px; border-right: 0; border-top: 1px solid var(--border); }
  .brand, .side-foot { display: none; }
  .nav { display: flex; width: 100%; justify-content: space-around; }
  .nav a { flex-direction: column; gap: 2px; font-size: 10px; padding: 6px; }
  .nav .badge { display: none; }
  main { padding: 16px 14px 90px; }
  .g4, .g2 { grid-template-columns: 1fr 1fr; }
  .stat .value { font-size: 19px; }
  .hide-sm { display: none; }
}

/* ---------- stat tiles ---------- */
.stat .label { color: var(--ink-2); font-size: 13px; }
.stat .value { font-size: 26px; font-weight: 650; letter-spacing: -0.02em; margin: 4px 0 2px; }
.stat .sub { font-size: 12px; color: var(--muted); }
.delta { font-weight: 600; font-size: 12px; }

/* ---------- controls ---------- */
.btn { border: 1px solid var(--border); background: var(--surface); padding: 7px 14px; border-radius: 8px; cursor: pointer; font-weight: 500; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--bad); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { padding: 4px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: default; }
input:not([type=checkbox]):not([type=radio]):not([type=file]), select, textarea {
  border: 1px solid var(--border); background: var(--surface); border-radius: 8px; padding: 7px 10px; min-width: 0;
}
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
label.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--ink-2); font-weight: 500; }
label.field > input, label.field > select, label.field > textarea { font-size: 14px; color: var(--ink); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface); }
.seg button { border: 0; background: transparent; padding: 6px 12px; cursor: pointer; color: var(--ink-2); }
.seg button.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.month-nav { display: inline-flex; align-items: center; gap: 4px; }
.month-nav .lbl { min-width: 120px; text-align: center; font-weight: 600; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 10px 14px; cursor: pointer; color: var(--ink-2); border-bottom: 2px solid transparent; font-weight: 500; white-space: nowrap; }
.tabs button.on { color: var(--accent); border-bottom-color: var(--accent); }

/* ---------- tables ---------- */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 500; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.tbl td { padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl .num { text-align: right; white-space: nowrap; }
.tbl th.num { text-align: right; }
.tbl.compact td { padding: 6px 8px; }
.tbl select.inline { border-color: transparent; background: transparent; padding: 3px 4px; max-width: 200px; }
.tbl select.inline:hover { border-color: var(--border); }
.tbl tr.dim td { opacity: .45; }
.tbl tfoot td { font-weight: 650; border-top: 1px solid var(--axis); }
.tx-merchant { font-weight: 550; }
.tx-desc { font-size: 12px; color: var(--muted); max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.amount.in { color: var(--good); }
.table-wrap { overflow-x: auto; }
.pill { display: inline-block; font-size: 11px; padding: 1px 8px; border-radius: 10px; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
.pill.warn { background: var(--warn-bg); }
.pill.accent { background: var(--accent-soft); color: var(--accent); }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.bulkbar { position: sticky; top: 0; z-index: 5; background: var(--accent-soft); border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; margin-bottom: 10px; }
.heat td.num { font-size: 12px; }

/* ---------- budget bars ---------- */
.bud { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 8px 0; border-bottom: 1px solid var(--border); cursor: pointer; }
.bud:last-child { border-bottom: 0; }
.bud .name { font-weight: 500; }
.bud .amt { text-align: right; font-variant-numeric: tabular-nums; }
.bud .track { grid-column: 1 / -1; height: 6px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.bud .fill { height: 100%; border-radius: 4px; background: var(--accent); }
.bud .fill.over { background: var(--bad); }
.bud .meta { grid-column: 1 / -1; font-size: 12px; color: var(--muted); }

/* ---------- lists ---------- */
.list-item { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: 0; }
.ico-circle { width: 32px; height: 32px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; flex: none; font-size: 15px; }
.empty { text-align: center; padding: 36px 16px; color: var(--muted); }
.empty h3 { color: var(--ink); margin-bottom: 6px; }
.banner { background: var(--warn-bg); border-radius: 10px; padding: 10px 14px; display: flex; gap: 10px; align-items: center; margin-bottom: 16px; }

/* ---------- auth / landing ---------- */
.landing { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(380px, 1fr); }
.hero { position: relative; overflow: hidden; color: #fff; padding: 56px 64px; display: flex; align-items: center;
  background: radial-gradient(1200px 600px at -10% -20%, #2b4c7e 0%, transparent 60%),
              radial-gradient(800px 500px at 120% 110%, rgba(242,106,46,.28) 0%, transparent 60%),
              linear-gradient(160deg, #1d3557 0%, #0f1f36 70%); }
.hero::after { content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .06;
  background-image: linear-gradient(#fff 1px, transparent 1px), linear-gradient(90deg, #fff 1px, transparent 1px); background-size: 44px 44px; }
.hero-inner { position: relative; z-index: 1; max-width: 520px; }
.hero-brand { display: flex; align-items: center; gap: 12px; font-size: 22px; font-weight: 700; letter-spacing: -0.02em; margin-bottom: 56px; }
.hero-brand img { width: 44px; height: 44px; border-radius: 12px; box-shadow: 0 0 0 1px rgba(255,255,255,.18), 0 8px 20px rgba(0,0,0,.35); }
.hero h1 { font-size: 44px; line-height: 1.08; letter-spacing: -0.035em; font-weight: 700; }
.hero-lead { font-size: 17px; line-height: 1.55; color: rgba(255,255,255,.78); margin: 18px 0 36px; max-width: 460px; }
.hero-feats { list-style: none; padding: 0; margin: 0; display: grid; gap: 18px; }
.hero-feats li { display: flex; gap: 14px; align-items: flex-start; }
.hero-feats b { display: block; font-size: 15px; font-weight: 600; }
.hero-feats span:not(.feat-ico) { display: block; color: rgba(255,255,255,.66); font-size: 13.5px; margin-top: 2px; }
.feat-ico { flex: none; width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center;
  background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.14); }
.feat-ico svg, .hero-note svg { width: 19px; height: 19px; fill: none; stroke: #ffc857; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.hero-note { display: flex; align-items: center; gap: 10px; margin-top: 44px; padding-top: 22px; border-top: 1px solid rgba(255,255,255,.12); color: rgba(255,255,255,.7); font-size: 13px; }
.auth-side { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px 24px; background: var(--page); }
.auth-card { width: 100%; max-width: 400px; }
.auth-card h2 { font-size: 28px; letter-spacing: -0.025em; font-weight: 700; margin-bottom: 6px; }
.auth-card > p { margin: 0 0 26px; }
.auth-card label.field > input, .auth-card label.field > select { padding: 11px 12px; border-radius: 10px; font-size: 15px; }
.auth-brand-sm { display: none; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; margin-bottom: 28px; }
.auth-brand-sm img { width: 34px; height: 34px; }
.btn-lg { width: 100%; padding: 12px; font-size: 15px; font-weight: 600; border-radius: 10px; }
.auth-card .btn.primary { background: #1d3557; border-color: #1d3557; }
.auth-card .btn.primary:hover { background: #0f1f36; }
.center { text-align: center; }
.auth-foot { margin-top: 48px; font-size: 12px; color: var(--muted); }
.err { color: var(--bad); font-size: 13px; min-height: 18px; }
@media (max-width: 900px) {
  .landing { grid-template-columns: 1fr; }
  .hero { padding: 36px 24px 40px; }
  .hero-brand { margin-bottom: 28px; }
  .hero h1 { font-size: 32px; }
  .hero-lead { font-size: 15px; margin-bottom: 26px; }
  .hero-note { margin-top: 28px; }
  .auth-side { padding: 36px 20px 48px; }
}
@media (max-width: 560px) {
  .hero { display: none; }
  .auth-brand-sm { display: flex; }
  .auth-side { min-height: 100vh; }
}
.brand img { width: 30px; height: 30px; }

/* ---------- modal & toast ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: var(--surface); border-radius: 14px; width: 100%; max-width: 560px; max-height: 92vh; overflow: auto; padding: 22px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal.wide { max-width: 980px; }
.modal h2 { margin-bottom: 16px; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }
#toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--surface); padding: 10px 18px; border-radius: 10px; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 60; max-width: 90vw; }
#toast.show { opacity: 1; }
.dropzone { border: 2px dashed var(--axis); border-radius: 12px; padding: 34px; text-align: center; cursor: pointer; color: var(--ink-2); }
.dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.code { font-family: ui-monospace, Menlo, Consolas, monospace; background: var(--surface-2); padding: 2px 6px; border-radius: 4px; }

/* ---------- charts ---------- */
.viz { position: relative; width: 100%; }
.viz svg { display: block; width: 100%; height: auto; overflow: visible; }
.viz text { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.viz .grid-l { stroke: var(--grid); stroke-width: 1; }
.viz .base-l { stroke: var(--axis); stroke-width: 1; }
.viz .hit { fill: transparent; cursor: pointer; }
.viz .cross { stroke: var(--axis); stroke-width: 1; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--ink-2); margin-top: 10px; }
.legend span { white-space: nowrap; }
.viz-tip { position: fixed; z-index: 70; pointer-events: none; background: var(--surface); color: var(--ink); border: 1px solid var(--border); box-shadow: 0 6px 24px rgba(0,0,0,.15); border-radius: 8px; padding: 8px 10px; font-size: 12px; min-width: 140px; }
.viz-tip .t { font-weight: 650; margin-bottom: 4px; }
.viz-tip .r { display: flex; justify-content: space-between; gap: 14px; font-variant-numeric: tabular-nums; }
.donut-wrap { display: grid; grid-template-columns: 220px 1fr; gap: 20px; align-items: center; }
@media (max-width: 760px) { .donut-wrap { grid-template-columns: 1fr; } }
@media (forced-colors: active) { .viz rect, .viz path { forced-color-adjust: none; } }
