:root {
  --bg: #f6f7f9; --surface: #ffffff; --surface-2: #f0f2f5; --text: #15181d; --muted: #667085; --border: #e3e6eb;
  --accent: #0f766e; --accent-ink: #ffffff; --accent-soft: #e6f4f2; --pos: #15803d; --neg: #c2410c; --warn: #b45309; --warn-soft: #fef3c7;
  --c1: #0f766e; --c2: #2563eb; --c3: #d97706; --c4: #7c3aed; --c5: #db2777; --c6: #65a30d; --c7: #0891b2; --c8: #64748b;
  --radius: 14px; --shadow: 0 1px 2px rgba(16, 24, 40, .06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1116; --surface: #161a21; --surface-2: #1d222b; --text: #e7eaee; --muted: #8b95a5; --border: #262c36;
    --accent: #2dd4bf; --accent-ink: #062a26; --accent-soft: #12302d; --pos: #4ade80; --neg: #fb923c; --warn: #fbbf24; --warn-soft: #3a2e10;
    --c1: #2dd4bf; --c2: #60a5fa; --c3: #fbbf24; --c4: #a78bfa; --c5: #f472b6; --c6: #a3e635; --c7: #22d3ee; --c8: #94a3b8;
    --shadow: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.35rem; } h2 { font-size: 1.05rem; } h3 { font-size: .95rem; }
.num, td.num, .amount { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .tiny { font-size: .75rem; }
.pos { color: var(--pos); } .neg { color: var(--neg); } .warn { color: var(--warn); }

/* Layout */
.top { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); }
.top-inner { max-width: 1040px; margin: 0 auto; padding: .6rem 16px; display: flex; align-items: center; gap: 1rem; }
.brand { font-weight: 700; color: var(--text); display: flex; align-items: center; gap: .45rem; }
.brand img { width: 22px; height: 22px; }
.nav-desktop { display: flex; gap: .2rem; flex-wrap: wrap; margin-left: auto; }
.nav-desktop a { color: var(--muted); padding: .35rem .6rem; border-radius: 8px; font-size: .9rem; }
.nav-desktop a.on, .nav-desktop a:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
main { max-width: 1040px; margin: 0 auto; padding: 16px 16px 96px; }
.grid { display: grid; gap: 14px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); min-width: 0; }
.card > h2 { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.card > h2 a, .card > h2 .muted { font-size: .85rem; font-weight: 500; }
.section-title { margin: 22px 0 8px; display: flex; justify-content: space-between; align-items: baseline; }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: baseline; gap: .75rem; }
.stack > * + * { margin-top: .5rem; }

/* Hero */
.hero { padding: 18px 16px; }
.hero .label { color: var(--muted); font-size: .85rem; }
.hero .big { font-size: 2.1rem; font-weight: 750; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.chips { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: .4rem; }
.chip { background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: .15rem .6rem; font-size: .8rem; color: var(--muted); white-space: nowrap; }
.chip b { color: var(--text); font-weight: 600; }
.chip.pos b { color: var(--pos); } .chip.neg b { color: var(--neg); }
button.chip { cursor: pointer; font: inherit; font-size: .8rem; }
.badge { display: inline-block; font-size: .7rem; padding: .05rem .45rem; border-radius: 6px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); vertical-align: middle; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.ok { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

/* Lists and tables */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; justify-content: space-between; gap: .75rem; padding: .55rem 0; border-top: 1px solid var(--border); align-items: center; }
.list li:first-child { border-top: 0; }
.list .name { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.table-wrap { overflow-x: auto; margin: 0 -16px; padding: 0 16px; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th { text-align: left; color: var(--muted); font-weight: 500; font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; padding: .4rem .5rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: .5rem; border-bottom: 1px solid var(--border); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
th.num { text-align: right; }

/* Bars */
.bar { height: 8px; border-radius: 6px; background: var(--surface-2); overflow: hidden; margin-top: .25rem; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 6px; }
.bar.over > i { background: var(--neg); }
.bar-row { padding: .45rem 0; border-top: 1px solid var(--border); }
.bar-row:first-child { border-top: 0; }

/* Charts */
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart .zero { stroke: var(--border); stroke-dasharray: 3 3; }
.chart-labels { display: flex; justify-content: space-between; font-size: .72rem; color: var(--muted); margin-top: .2rem; gap: .5rem; }
.legend { display: flex; flex-wrap: wrap; gap: .3rem .8rem; font-size: .78rem; color: var(--muted); margin-top: .4rem; }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: .3rem; }
.spark { vertical-align: middle; }

/* Forms */
form.inline { display: inline; }
label { display: block; font-size: .82rem; color: var(--muted); margin: .55rem 0 .2rem; }
input, select, textarea { width: 100%; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: .55rem .65rem; min-height: 42px; }
textarea { min-height: 90px; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); border-color: var(--accent); }
input[type="checkbox"] { width: auto; min-height: 0; margin-right: .4rem; }
.check { display: flex; align-items: center; color: var(--text); font-size: .92rem; margin: .5rem 0; }
.fields { display: grid; gap: 0 12px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.btn, button { font: inherit; font-weight: 600; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); border-radius: 10px; padding: .55rem .9rem; cursor: pointer; min-height: 40px; display: inline-flex; align-items: center; justify-content: center; gap: .35rem; }
.btn.primary, button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger, button.danger { color: var(--neg); }
.btn.small, button.small { min-height: 30px; padding: .2rem .6rem; font-size: .82rem; }
.btn:hover { text-decoration: none; filter: brightness(1.05); }
.amount-input { font-size: 1.6rem; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.seg { display: flex; gap: .3rem; overflow-x: auto; padding-bottom: .2rem; }
.seg a, .seg button { white-space: nowrap; border: 1px solid var(--border); border-radius: 999px; padding: .3rem .8rem; color: var(--muted); background: var(--surface); font-size: .85rem; font-weight: 500; min-height: 0; }
.seg a.on, .seg button.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
details > summary { cursor: pointer; color: var(--accent); font-size: .9rem; margin: .4rem 0; }

/* Messages */
.flash { border-radius: 10px; padding: .6rem .8rem; margin-bottom: 12px; font-size: .92rem; }
.flash.ok { background: var(--accent-soft); color: var(--accent); }
.flash.err { background: color-mix(in srgb, var(--neg) 14%, transparent); color: var(--neg); }
.notice { background: var(--warn-soft); color: var(--warn); border-radius: 10px; padding: .55rem .75rem; font-size: .88rem; }

/* Mobile nav */
.tabbar { display: none; }
@media (max-width: 760px) {
  .nav-desktop { display: none; }
  .tabbar { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; bottom: 0; left: 0; right: 0; z-index: 15; background: var(--surface); border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom); }
  .tabbar a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: .45rem 0 .5rem; color: var(--muted); font-size: .7rem; }
  .tabbar a.on { color: var(--accent); }
  .tabbar svg { width: 22px; height: 22px; }
  .tabbar a:hover { text-decoration: none; }
  .hero .big { font-size: 1.8rem; }
  main { padding-bottom: 120px; }
  .hide-sm { display: none; }
}
.more-menu { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.more-menu a { display: block; padding: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); font-weight: 600; }
.codes { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 1.05rem; display: grid; grid-template-columns: repeat(2, 1fr); gap: .4rem 1rem; }
.center-page { max-width: 420px; margin: 8vh auto; }
