:root {
  --bg: #e9ede7; --paper: #f8f8f4; --card: #ffffff; --ink: #1b2e26; --muted: #6d7b73; --line: #e4e8e1;
  --inc: #1f9a6a; --exp: #d0643f;
  --c1: #1f9a6a; --c2: #d0643f; --c3: #3f7fbf; --c4: #c9a227; --c5: #8e63b5; --c-other: #a9b3ad;
  --green: #245a43; --lime: #c5e063; --terra: #c8745a; --amber: #e0a84a; --track: #edf0ea; --r: 18px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101a15; --paper: #14211b; --card: #1b2b23; --ink: #e8efe9; --muted: #93a49a; --line: #2a3d33;
    --inc: #2ba372; --exp: #dc6641;
    --c1: #2ba372; --c2: #dc6641; --c3: #4a90d9; --c4: #b8891a; --c5: #a07bc9; --c-other: #5d6e65;
    --green: #5fb48c; --lime: #c5e063; --terra: #e08f75; --amber: #e8b75e; --track: #26382f;
  }
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  background: var(--paper); color: var(--ink); min-height: 100vh;
  font: 15px/1.35 -apple-system, "SF Pro Text", Inter, system-ui, sans-serif;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
main { padding: 16px 14px 0; max-width: 560px; margin: 0 auto; }
h1 { font-size: 24px; letter-spacing: -.02em; }
.sub { font-size: 12px; color: var(--muted); margin: 2px 0 12px; }
.hero { background: #1b2e26; color: #fff; border-radius: var(--r); padding: 16px; }
.hero small, .eyebrow { font: 10px ui-monospace, Menlo, monospace; letter-spacing: .12em; text-transform: uppercase; }
.hero small { color: #9fb5a9; }
.hero .big { font-size: 32px; font-weight: 700; letter-spacing: -.02em; margin: 6px 0 10px; }
.hero .row { display: flex; justify-content: space-between; font-size: 12px; color: #c9d8cf; border-top: 1px solid #35493f; padding-top: 10px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; margin-top: 10px; }
.card h3 { font-size: 14px; margin-bottom: 8px; display: flex; justify-content: space-between; align-items: baseline; }
.card h3 span { font-size: 11px; font-weight: 400; color: var(--muted); }
.bar { height: 8px; background: var(--track); border-radius: 99px; overflow: hidden; }
.bar > div { height: 100%; border-radius: 99px; }
.ok { background: var(--green); } .warn { background: var(--amber); } .over { background: var(--terra); }
.li { display: flex; align-items: flex-start; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.li:last-child { border-bottom: 0; }
.ic { width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; font-size: 16px; flex: none; background: var(--track); }
.li .t { flex: 1; min-width: 0; }
.li .t b { display: block; font-weight: 600; overflow-wrap: anywhere; }
.li .t span, .muted { font-size: 11px; color: var(--muted); }
.li .a { font-weight: 600; text-align: right; white-space: nowrap; }
.pos { color: var(--green); } .neg { color: var(--terra); }
.brow { padding: 9px 0; border-bottom: 1px solid var(--line); }
.brow:last-child { border: 0; }
.bhead { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 6px; }
.bhead span { color: var(--muted); font-size: 12px; }
.chips { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 10px; scrollbar-width: none; }
.chip { flex: none; padding: 6px 12px; border-radius: 99px; background: var(--card); border: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.chip.on { background: var(--ink); color: var(--paper); border-color: var(--ink); }
input[type=search] { width: 100%; padding: 10px 12px; margin-bottom: 10px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font-size: 14px; }
.day { font: 10px ui-monospace, Menlo, monospace; letter-spacing: .1em; color: var(--muted); padding: 12px 0 2px; text-transform: uppercase; }
.more { display: block; width: 100%; margin-top: 10px; padding: 12px; border-radius: 12px; background: var(--card); border: 1px solid var(--line); color: var(--ink); font-size: 14px; }
.empty { text-align: center; color: var(--muted); padding: 40px 0; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
.tabs { position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-around; background: var(--card); border-top: 1px solid var(--line); padding: 8px 0 calc(8px + env(safe-area-inset-bottom)); }
.tabs button { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 10px; color: var(--muted); min-width: 72px; }
.tabs i { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--muted); opacity: .5; }
.tabs .on { color: var(--ink); font-weight: 600; }
.tabs .on i { background: var(--green); border-color: var(--green); opacity: 1; }

.tabs button { min-width: 0; flex: 1; }
.brow.tap { cursor: pointer; }
.bhead.sm { margin: 6px 0 0; font-size: 12px; }
.del { display: block; margin-top: 4px; margin-left: auto; font-size: 11px; color: var(--terra); }
.fab { position: fixed; right: 16px; bottom: calc(84px + env(safe-area-inset-bottom)); background: var(--lime); color: #1b2e26; font-weight: 700; border-radius: 99px; padding: 12px 18px; font-size: 14px; box-shadow: 0 8px 20px rgba(36,90,67,.25); }
.backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: flex-end; z-index: 10; }
.sheet { background: var(--paper); width: 100%; max-height: 92vh; overflow-y: auto; border-radius: 22px 22px 0 0; padding: 10px 16px calc(16px + env(safe-area-inset-bottom)); }
.sheet h2 { font-size: 20px; margin-bottom: 8px; }
.grab { width: 40px; height: 4px; background: var(--line); border-radius: 4px; margin: 0 auto 12px; }
.field { display: block; margin-top: 10px; }
.field[hidden] { display: none; }
.field small { display: block; font: 10px ui-monospace, Menlo, monospace; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.field input, .field select, input[type=date] { width: 100%; padding: 11px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font-size: 15px; }
.check { display: flex; gap: 10px; align-items: center; margin-top: 14px; font-size: 13px; }
.check input { width: 20px; height: 20px; flex: none; }
.form-error { color: var(--terra); font-size: 13px; margin-top: 10px; min-height: 1em; }
.primary { display: block; width: 100%; margin-top: 12px; padding: 14px; border-radius: 14px; background: var(--green); color: #fff; font-weight: 600; font-size: 15px; }
.primary:disabled { opacity: .5; }
.ghost { display: block; width: 100%; padding: 12px; color: var(--muted); }

.primary.small { padding: 10px; font-size: 14px; margin-top: 12px; background: var(--card); color: var(--ink); border: 1px solid var(--line); }
.card .bhead { margin-top: 2px; }
.card .bhead.sm { flex-wrap: wrap; gap: 4px; }
.li.tap { cursor: pointer; }
.danger { display: block; width: 100%; margin-top: 4px; padding: 12px; color: var(--terra); font-weight: 600; }
.li .a { flex: none; }
.li .t span { display: block; margin-top: 2px; }

.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.key { display: inline-block; width: 14px; height: 2px; margin-right: 6px; vertical-align: middle; border-radius: 2px; }
.key.inc { background: var(--inc); } .key.exp { background: var(--exp); }
.chart-wrap { position: relative; }
.chart { width: 100%; height: auto; display: block; touch-action: pan-y; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { stroke: var(--muted); stroke-opacity: .5; stroke-width: 1; }
.chart .tick { fill: var(--muted); font-size: 9px; }
.chart .line { fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.chart .line.inc, .chart .dot.inc { stroke: var(--inc); } .chart .line.exp, .chart .dot.exp { stroke: var(--exp); }
.chart .dot { stroke-width: 2; paint-order: stroke; }
.chart .dot.inc { fill: var(--inc); stroke: var(--card); } .chart .dot.exp { fill: var(--exp); stroke: var(--card); }
.chart .cross { stroke: var(--muted); stroke-opacity: .6; stroke-width: 1; }
.tip { position: absolute; top: 0; transform: translateX(-50%); background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; font-size: 12px; pointer-events: none; box-shadow: 0 6px 18px rgba(0,0,0,.12); white-space: nowrap; }
.tip[hidden] { display: none; }
.tip-head { color: var(--muted); margin-bottom: 2px; }
.tip-row { display: flex; align-items: center; gap: 6px; }
.tip-row span { color: var(--muted); }
.table-view { margin-top: 8px; font-size: 12px; color: var(--muted); }
.table-view summary { cursor: pointer; padding: 4px 0; }
.table-view table { width: 100%; border-collapse: collapse; margin-top: 6px; font-variant-numeric: tabular-nums; }
.table-view th, .table-view td { text-align: right; padding: 4px 0; border-bottom: 1px solid var(--line); color: var(--ink); }
.table-view th:first-child, .table-view td:first-child { text-align: left; color: var(--muted); }
.hero .row + .row { margin-top: 8px; }

.donut-block { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.donut { width: 168px; height: 168px; touch-action: pan-y; }
.donut .ring-track { fill: none; stroke: var(--track); stroke-width: 18; }
.donut .ring { fill: none; stroke-width: 18; transition: opacity .12s; }
.donut .ring.dim { opacity: .3; }
.donut-value { fill: var(--ink); font-size: 17px; font-weight: 700; }
.donut-label { fill: var(--muted); font-size: 8.5px; }
.legend-list { width: 100%; }
.legend-row { display: flex; align-items: center; gap: 8px; padding: 8px 6px; border-radius: 10px; font-size: 13px; }
.legend-row.on { background: var(--track); }
.legend-row .swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.legend-name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.legend-share { width: 38px; text-align: right; color: var(--muted); }
