:root {
  --bg: #f4f6f9; --card: #fff; --ink: #0f172a; --muted: #64748b; --line: #dbe1ea;
  --accent: #1d4ed8; --accent-ink: #fff; --good: #15803d; --warn: #b45309; --bad: #b91c1c;
  --chart: #1d4ed8; --chart-pr: #d97706;
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1220; --card: #131c2e; --ink: #e6ebf5; --muted: #8b9ab3; --line: #25324b;
    --accent: #6ea0ff; --accent-ink: #08142e; --good: #4ade80; --warn: #fbbf24; --bad: #f87171;
    --chart: #6ea0ff; --chart-pr: #fbbf24;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.4 system-ui, -apple-system, Segoe UI, Roboto, sans-serif; }
body { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
.top { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center;
  padding: 10px 16px; background: #0f172a; color: #fff; }
.brand { font-weight: 700; letter-spacing: .02em; }
.sync { font-size: 13px; padding: 3px 10px; border-radius: 99px; background: #1e293b; }
.sync.ok { color: #86efac; } .sync.pending { color: #fcd34d; } .sync.off { color: #fca5a5; }
.view { max-width: 760px; margin: 0 auto; padding: 12px 16px 24px; }
.tabs { position: fixed; bottom: 0; left: 0; right: 0; display: flex; background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom); z-index: 5; }
.tabs a { flex: 1; text-align: center; padding: 14px 4px; color: var(--muted); text-decoration: none; font-size: 14px; font-weight: 600; }
.tabs a.on { color: var(--accent); box-shadow: inset 0 3px 0 var(--accent); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin: 0 0 12px; }
h2 { margin: 4px 0 12px; font-size: 20px; } h3 { margin: 0 0 8px; font-size: 16px; }
label { display: block; font-size: 13px; color: var(--muted); margin: 8px 0 4px; font-weight: 600; }
input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea { width: 100%; padding: 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); min-height: 46px; }
input.big { font-size: 34px; font-weight: 700; text-align: center; padding: 14px; }
textarea { min-height: 120px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; }
button { padding: 12px 16px; min-height: 46px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); cursor: pointer; font-weight: 600; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); width: 100%; margin-top: 10px; }
button.primary.big { font-size: 20px; min-height: 58px; }
button.ghost { background: transparent; }
button.danger { color: var(--bad); }
button:disabled { opacity: .5; }
.row { display: flex; gap: 10px; align-items: flex-end; } .row > .f { flex: 1; min-width: 0; }
.between { justify-content: space-between; align-items: center; }
.muted { color: var(--muted); font-size: 14px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink); margin: 8px 0; }
.check input { width: 22px; height: 22px; min-height: 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; max-height: 240px; overflow-y: auto; margin-top: 8px; }
.chip { padding: 12px 8px; text-align: center; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); font-weight: 600; cursor: pointer; font-size: 15px; }
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.list .val { font-weight: 700; font-variant-numeric: tabular-nums; }
.pill { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--bg); border: 1px solid var(--line); color: var(--muted); }
.pill.pr { color: var(--chart-pr); border-color: var(--chart-pr); }
table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
th, td { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: left; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
td.n, th.n { text-align: right; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 8px; }
.stat { background: var(--bg); border-radius: 10px; padding: 10px; text-align: center; }
.stat b { display: block; font-size: 20px; } .stat span { font-size: 12px; color: var(--muted); }
.log { background: #020617; color: #86efac; font: 12px/1.5 ui-monospace, Menlo, Consolas, monospace; padding: 10px; border-radius: 10px; height: 220px; overflow: auto; white-space: pre-wrap; word-break: break-all; }
svg.chart { width: 100%; height: auto; display: block; }
svg.chart text { fill: var(--muted); font-size: 11px; }
.toast { position: fixed; left: 50%; bottom: calc(78px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); background: #0f172a; color: #fff;
  padding: 10px 16px; border-radius: 10px; opacity: 0; pointer-events: none; transition: .2s; z-index: 10; max-width: 90vw; font-size: 14px; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.notice { border-left: 4px solid var(--warn); }
