:root {
  color-scheme: light dark;
  --bg: #f6f7f5;
  --panel: #ffffff;
  --text: #17201d;
  --muted: #5e6b66;
  --line: #e0e4e0;
  --accent: #1f6f5c;
  --accent-text: #ffffff;
  --good: #1f7a55;
  --watch: #a06a00;
  --tight: #b5560f;
  --bad: #b3261e;
  --track: #e6eae6;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101614;
    --panel: #18211e;
    --text: #e9eeeb;
    --muted: #9aa8a2;
    --line: #2a3531;
    --accent: #5cc4a6;
    --accent-text: #0c1a16;
    --good: #5cc4a6;
    --watch: #e0b050;
    --tight: #eb9a5a;
    --bad: #f2867e;
    --track: #2a3531;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); line-height: 1.4; }
main { max-width: 720px; margin: 0 auto; padding: 16px 16px 120px; }
h1 { font-size: 1.4rem; margin: 8px 0 16px; }
h2 { font-size: 1.05rem; margin: 0 0 12px; }
h3 { font-size: .95rem; margin: 16px 0 8px; }
p { margin: 0 0 12px; }
a { color: var(--accent); }
.muted { color: var(--muted); font-size: .875rem; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin-bottom: 16px; }
.hero { text-align: center; padding: 24px 16px; }
.hero .big { font-size: 3rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.hero .label { color: var(--muted); }
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .8rem; font-weight: 600; color: #fff; }
.status-on_track { background: var(--good); }
.status-watch { background: var(--watch); }
.status-tight { background: var(--tight); }
.status-over { background: var(--bad); }
@media (prefers-color-scheme: dark) { .badge { color: #101614; } }
.stats { display: flex; justify-content: space-around; gap: 12px; margin-top: 16px; }
.stats div { text-align: center; }
.stats b { display: block; font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.bar-row { margin-bottom: 12px; }
.bar-head { display: flex; justify-content: space-between; gap: 8px; font-size: .9rem; }
.bar { height: 8px; border-radius: 4px; background: var(--track); overflow: hidden; margin-top: 4px; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.bar i.over { background: var(--bad); }
.row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.row .grow { flex: 1; min-width: 0; }
.row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row button.link { all: unset; flex: 1; min-width: 0; cursor: pointer; }
.amount { font-variant-numeric: tabular-nums; white-space: nowrap; }
.amount.in { color: var(--good); }
label { display: block; margin-bottom: 12px; font-size: .875rem; color: var(--muted); }
label.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 1rem; }
input, select, textarea { display: block; width: 100%; margin-top: 4px; padding: 10px; font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; min-height: 44px; }
input[type=checkbox] { width: 22px; height: 22px; min-height: 0; margin: 0; flex: none; accent-color: var(--accent); }
button { font: inherit; min-height: 44px; padding: 10px 16px; border-radius: 8px; border: 1px solid var(--accent); background: var(--accent); color: var(--accent-text); font-weight: 600; cursor: pointer; }
button.ghost { background: transparent; color: var(--accent); }
button.danger { background: transparent; border-color: var(--bad); color: var(--bad); }
button.small { min-height: 36px; padding: 6px 12px; font-size: .875rem; }
button:disabled { opacity: .5; cursor: default; }
.buttons { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.tabs { display: flex; gap: 8px; overflow-x: auto; margin-bottom: 16px; padding-bottom: 4px; }
.tabs button { white-space: nowrap; background: transparent; color: var(--text); border-color: var(--line); font-weight: 500; }
.tabs button.on { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.error { color: var(--bad); }
.secret { font-family: ui-monospace, Menlo, monospace; word-break: break-all; background: var(--bg); padding: 10px; border-radius: 8px; font-size: .875rem; }
.qr { display: block; width: min(240px, 100%); margin: 0 auto 12px; background: #fff; border-radius: 8px; }
.steps { color: var(--muted); font-size: .875rem; margin-bottom: 8px; }
.tag { font-size: .75rem; color: var(--muted); border: 1px solid var(--line); border-radius: 6px; padding: 0 6px; margin-left: 6px; }
#nav { position: fixed; bottom: calc(22px + env(safe-area-inset-bottom)); left: 0; right: 0; display: flex; justify-content: space-around; background: var(--panel); border-top: 1px solid var(--line); }
#version { position: fixed; bottom: 0; left: 0; right: 0; height: calc(22px + env(safe-area-inset-bottom)); padding-top: 3px; text-align: center; font-size: .72rem; color: var(--muted); background: var(--panel); }
#nav[hidden] { display: none; }
#nav a { flex: 1; text-align: center; padding: 14px 2px; color: var(--muted); text-decoration: none; font-size: .78rem; font-weight: 600; }
#nav a.on { color: var(--accent); }
#toast { position: fixed; left: 16px; right: 16px; bottom: 98px; max-width: 480px; margin: 0 auto; background: var(--text); color: var(--bg); padding: 12px 16px; border-radius: 10px; }
#toast[hidden] { display: none; }
dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 12px; width: min(480px, calc(100vw - 32px)); padding: 16px; }
dialog::backdrop { background: rgba(0, 0, 0, .5); }
