:root {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --accent: #2563eb;
  --ok: #16a34a;
  --warn: #d97706;
  --bad: #dc2626;
  --idle: #94a3b8;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1120;
    --surface: #111a2e;
    --text: #e2e8f0;
    --muted: #94a3b8;
    --line: #1e293b;
    --accent: #60a5fa;
    --ok: #22c55e;
    --warn: #f59e0b;
    --bad: #f87171;
    --idle: #64748b;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding-bottom: calc(64px + env(safe-area-inset-bottom));
}
header {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: center; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
header .brand { font-weight: 700; color: var(--text); text-decoration: none; }
header .who { margin-left: auto; color: var(--muted); font-size: 13px; }
header form { margin: 0; }
main { max-width: 860px; margin: 0 auto; padding: 16px; }
a { color: var(--accent); }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 14px 16px; margin-bottom: 14px;
}
.card h2 { margin: 0 0 10px; font-size: 16px; }
.card h2 a { color: var(--text); text-decoration: none; }
.row {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px;
  padding: 9px 0; border-top: 1px solid var(--line); color: var(--text); text-decoration: none;
}
.row:first-of-type { border-top: 0; }
.row .kv { margin-left: auto; color: var(--muted); font-size: 13px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.error { color: var(--bad); }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--idle); flex: none; }
.dot.ok { background: var(--ok); } .dot.warn { background: var(--warn); } .dot.bad { background: var(--bad); }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--line); }
.badge.ok { color: var(--ok); } .badge.warn { color: var(--warn); } .badge.bad { color: var(--bad); }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px; }
@media (min-width: 640px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stats div { background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 12px; color: var(--muted); font-size: 13px; }
.stats b { display: block; font-size: 24px; color: var(--text); }
.stats .bad b { color: var(--bad); } .stats .warn b { color: var(--warn); }
.metric { display: grid; grid-template-columns: 90px 1fr; align-items: center; gap: 10px; margin: 8px 0; }
.bar { height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--ok); }
.bar.warn i { background: var(--warn); } .bar.bad i { background: var(--bad); }
.ranges a { display: inline-block; padding: 4px 10px; border-radius: 999px; text-decoration: none;
  color: var(--muted); border: 1px solid var(--line); margin: 0 4px 6px 0; font-size: 13px; }
.ranges a.on { color: var(--text); border-color: var(--accent); }
.chart { margin: 8px 0 14px; }
.chart figcaption { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.chart svg { width: 100%; height: 120px; background: var(--bg); border-radius: 8px; }
.chart .grid line { stroke: var(--line); stroke-width: 1; }
.chart .line polyline { fill: none; stroke: var(--accent); stroke-width: 2; vector-effect: non-scaling-stroke; }
nav.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 2;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
nav.tabs a { padding: 14px 4px; text-align: center; color: var(--muted); text-decoration: none; font-size: 13px; }
nav.tabs a.on { color: var(--accent); font-weight: 600; }
.login { max-width: 420px; margin: 8vh auto; text-align: center; background: var(--surface);
  border: 1px solid var(--line); border-radius: 16px; padding: 24px 20px; }
.login .code { font: 700 32px/1.2 ui-monospace, Menlo, monospace; letter-spacing: 4px; margin: 18px 0 6px; }
.button { display: inline-block; margin: 14px 0; padding: 12px 22px; border-radius: 12px;
  background: var(--accent); color: #fff; text-decoration: none; font-weight: 600; }
button.link { background: none; border: 0; color: var(--accent); font: inherit; cursor: pointer; padding: 6px; }
details { margin: 10px 0; text-align: left; }
details summary { cursor: pointer; color: var(--accent); }
code.copy { display: block; padding: 8px; border-radius: 8px; background: var(--bg);
  word-break: break-all; user-select: all; -webkit-user-select: all; font-size: 13px; }
