:root {
  color-scheme: light;
  --bg: #f6f7f9; --surface: #ffffff; --text: #191919; --muted: #666666;
  --grid: #e7e7e7; --axis: #c2c2c2; --border: rgba(11,11,11,0.10);
  --accent: #257de0; --accent-text: #ffffff;
  --good: #0aac23; --warning: #fbb315; --critical: #dc3c3d;
  --danger: #c62828;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #111418; --surface: #191919; --text: #efefef; --muted: #9c9c9c;
    --grid: #303030; --axis: #474747; --border: rgba(255,255,255,0.10);
    --accent: #338ced; --danger: #ef6b6b;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111418; --surface: #191919; --text: #efefef; --muted: #9c9c9c;
  --grid: #303030; --axis: #474747; --border: rgba(255,255,255,0.10);
  --accent: #338ced; --danger: #ef6b6b;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; position: sticky; top: 0; z-index: 5;
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 18px; }
nav { display: flex; gap: 4px; }
nav button[aria-current="page"] { background: var(--surface); }
main { max-width: 860px; margin: 0 auto; padding: 16px; }
.narrow { max-width: 520px; margin: 0 auto; }
h1 { font-size: 26px; margin: 8px 0 4px; }
h2 { font-size: 18px; margin: 0 0 6px; }
h3 { font-size: 15px; margin: 0 0 8px; font-weight: 600; }
.muted { color: var(--muted); font-weight: 400; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 16px; margin: 0 0 12px;
}
label { display: block; font-size: 14px; color: var(--muted); margin: 12px 0 6px; }
input {
  width: 100%; font: inherit; padding: 12px; border-radius: 10px; color: var(--text);
  border: 1px solid var(--axis); background: var(--surface);
}
input#code { font-size: 24px; letter-spacing: 6px; text-align: center; }
button, .button {
  font: inherit; font-size: 15px; padding: 10px 16px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  text-decoration: none; display: inline-flex; align-items: center; gap: 6px; min-height: 44px;
}
button.primary, .button.primary { background: var(--accent); color: var(--accent-text); border-color: transparent; font-weight: 600; }
form button.primary { margin-top: 12px; }
button.ghost { background: transparent; border-color: transparent; }
button.small, .button.small { font-size: 14px; padding: 6px 12px; min-height: 36px; }
button.danger { background: var(--danger); color: #fff; border-color: transparent; }
button.danger-ghost { color: var(--danger); }
button:disabled { opacity: .5; cursor: default; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; }
.msg { min-height: 1.4em; color: var(--muted); }
.msg.error, .warn { color: var(--danger); }
.banner { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: 10px; padding: 10px 14px; margin-bottom: 12px; }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.chips { display: flex; gap: 6px; }
.chip { padding: 6px 12px; min-height: 36px; border-radius: 999px; font-size: 14px; }
.chip[aria-pressed="true"] { background: var(--text); color: var(--bg); }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 12px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 12px 14px; }
.tile .label { font-size: 13px; color: var(--muted); }
.tile .value { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; }
.tile .sub { font-size: 13px; color: var(--muted); }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.chart { position: relative; height: 180px; }
.chart svg { display: block; width: 100%; height: 100%; overflow: visible; }
.chart .empty { color: var(--muted); font-size: 14px; padding-top: 60px; text-align: center; }
.axis-label { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.gridline { stroke: var(--grid); stroke-width: 1; }
.baseline { stroke: var(--axis); stroke-width: 1; }
.series-line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.series-dot { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.series-bar { fill: var(--accent); }
.avg-line { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 4 4; }
.crosshair { stroke: var(--axis); stroke-width: 1; }
.tooltip {
  position: fixed; z-index: 20; pointer-events: none; background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; font-size: 13px;
  box-shadow: 0 4px 16px rgba(0,0,0,.18); white-space: nowrap;
}
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--border); }
.list li:first-child { border-top: 0; }
.list .meta { color: var(--muted); font-size: 14px; }
.list .right { text-align: right; font-variant-numeric: tabular-nums; }
.copy { display: flex; gap: 8px; align-items: center; background: var(--bg); border-radius: 10px; padding: 8px 8px 8px 12px; margin: 6px 0; }
.copy code { flex: 1; overflow-wrap: anywhere; font-size: 14px; }
.steps { margin: 6px 0; padding-left: 20px; }
@media (max-width: 480px) { .tile .value { font-size: 24px; } h1 { font-size: 22px; } }
