:root {
  color-scheme: light;
  --plane: #f9f9f7;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --accent: #2a78d6;
  --on-accent: #ffffff;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --plane: #0d0d0d;
  --surface: #1a1a19;
  --ink: #ffffff;
  --ink-2: #c3c2b7;
  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --series-1: #3987e5;
  --series-2: #d95926;
  --accent: #3987e5;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  background: var(--plane);
  color: var(--ink);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif;
  padding: 12px 16px calc(24px + env(safe-area-inset-bottom));
  max-width: 640px;
  margin: 0 auto;
  overflow-x: hidden;
}
button { font: inherit; color: inherit; cursor: pointer; }
h1 { font-size: 22px; margin: 4px 0 2px; }
h2 { font-size: 13px; font-weight: 600; color: var(--ink-2); margin: 0 0 10px; text-transform: uppercase; letter-spacing: .04em; }
.sub { color: var(--muted); font-size: 13px; }
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 14px; margin-top: 12px; }

/* hero */
.hero { display: flex; gap: 16px; align-items: center; }
.hero-num { font-size: 34px; font-weight: 700; line-height: 1; }
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.tile { background: var(--plane); border-radius: 12px; padding: 10px; }
.tile b { display: block; font-size: 20px; }
.tile span { display: block; font-size: 12px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; }

/* section grid */
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 12px; }
.sec { min-width: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 12px; text-align: left; min-height: 116px; display: flex; flex-direction: column; gap: 6px; }
.sec:active { transform: scale(.98); }
.sec .icon { font-size: 26px; line-height: 1; }
.sec .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sec .money { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.sec.add { align-items: center; justify-content: center; border-style: dashed; color: var(--muted); }
.bar { height: 6px; border-radius: 3px; background: var(--grid); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 3px; background: var(--series-1); }
.badge { font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 999px; border: 1px solid var(--border); white-space: nowrap; }

/* lists */
.item { padding: 10px 0; border-top: 1px solid var(--grid); }
.item:first-of-type { border-top: 0; }
.item .t { font-weight: 600; overflow-wrap: anywhere; }
.item .m { font-size: 12px; color: var(--ink-2); margin-top: 2px; }
.item .c { font-size: 13px; margin-top: 4px; color: var(--ink-2); }
.amount { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.void { opacity: .45; text-decoration: line-through; }
.empty { color: var(--muted); text-align: center; padding: 18px 0; font-size: 14px; }
.link { background: none; border: 0; color: var(--accent); padding: 4px 0; font-size: 13px; }

/* tabs & chips */
.tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); background: var(--grid); border-radius: 12px; padding: 3px; margin-top: 12px; }
.tabs button { border: 0; background: none; padding: 8px 4px; border-radius: 10px; font-weight: 600; color: var(--ink-2); }
.tabs button[aria-selected="true"] { background: var(--surface); color: var(--ink); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 7px 12px; font-size: 14px; }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

/* buttons */
.btn { border: 0; border-radius: 12px; padding: 12px 14px; font-weight: 600; background: var(--accent); color: var(--on-accent); width: 100%; }
.btn.ghost { background: var(--plane); color: var(--ink); border: 1px solid var(--border); }
.btn:disabled { opacity: .5; }
.actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }

/* charts */
svg.chart { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { fill: var(--muted); font-size: 10px; font-variant-numeric: tabular-nums; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--ink-2); margin-bottom: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.tip { font-size: 12px; color: var(--ink-2); min-height: 18px; margin-top: 6px; font-variant-numeric: tabular-nums; }
.hbar { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; font-size: 13px; margin-top: 8px; }
.hbar .bar { grid-column: 1 / -1; height: 8px; border-radius: 4px; }
.hbar .bar > i { border-radius: 4px; }

/* bottom sheet */
.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); display: flex; align-items: flex-end; z-index: 10; }
.sheet { background: var(--surface); width: 100%; max-width: 640px; margin: 0 auto; border-radius: 20px 20px 0 0; padding: 16px 16px calc(20px + env(safe-area-inset-bottom)); max-height: 92vh; overflow-y: auto; }
.sheet h3 { margin: 0 0 12px; font-size: 18px; }
.field { margin-bottom: 14px; }
.field > label { display: block; font-size: 12px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .04em; }
input, textarea { width: 100%; font: inherit; color: var(--ink); background: var(--plane); border: 1px solid var(--border); border-radius: 12px; padding: 11px 12px; }
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
input.big { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.err { color: var(--critical); font-size: 13px; min-height: 18px; margin-bottom: 8px; }

#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: var(--plane); padding: 10px 16px; border-radius: 12px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 20; max-width: 90vw; }
#toast.show { opacity: 1; }
.skeleton { height: 120px; border-radius: 16px; background: var(--grid); margin-top: 12px; opacity: .6; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
