:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #eef2f9;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --blue: #1d4ed8;
  --blue-2: #2563eb;
  --blue-soft: #e8efff;
  --green: #047857;
  --green-soft: #e3f6ee;
  --red: #b91c1c;
  --red-soft: #fdeaea;
  --amber: #b45309;
  --amber-soft: #fdf3e2;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 4px 16px rgba(15, 23, 42, 0.05);
  --radius: 16px;
  --tabbar-h: 64px;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1220;
    --surface: #111a2e;
    --surface-2: #17223a;
    --border: #22304d;
    --text: #e6ebf5;
    --muted: #93a1bb;
    --blue: #6b9bff;
    --blue-2: #8db2ff;
    --blue-soft: #18284a;
    --green: #34d399;
    --green-soft: #10322a;
    --red: #f87171;
    --red-soft: #3a1a1f;
    --amber: #fbbf24;
    --amber-soft: #3a2c12;
    --shadow: none;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  min-height: 100vh;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
}
code { font-size: 13px; background: var(--surface-2); padding: 1px 5px; border-radius: 6px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }
.up { color: var(--green); }
.down { color: var(--red); }

/* top bar */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(160%) blur(12px);
  -webkit-backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; gap: 10px; align-items: center; }
.brand img { border-radius: 8px; }
.brand-name { font-weight: 700; letter-spacing: -0.01em; }
.brand-sub { font-size: 12px; color: var(--muted); }
.badge {
  font-size: 11px; font-weight: 700; letter-spacing: 0.06em;
  padding: 4px 8px; border-radius: 999px;
}
.badge-paper { background: var(--blue-soft); color: var(--blue); }

/* layout */
main { padding: 14px 16px 24px; max-width: 720px; margin: 0 auto; }
.view { display: grid; gap: 12px; }
.view[hidden] { display: none; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px;
}
.card h2 { font-size: 13px; font-weight: 600; color: var(--muted); margin: 0 0 10px; letter-spacing: 0.02em; text-transform: uppercase; }
.card h3 { font-size: 15px; margin: 0; }
.row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.row + .row { margin-top: 8px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stat .label { font-size: 12px; color: var(--muted); }
.stat .value { font-size: 20px; font-weight: 650; font-variant-numeric: tabular-nums; }
.big { font-size: 34px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.sub { font-size: 14px; color: var(--muted); }

/* status */
.status { display: flex; gap: 12px; align-items: center; }
.dot { width: 12px; height: 12px; border-radius: 50%; flex: none; background: var(--muted); }
.dot.ok { background: #10b981; box-shadow: 0 0 0 4px var(--green-soft); }
.dot.warn { background: #f59e0b; box-shadow: 0 0 0 4px var(--amber-soft); }
.dot.bad { background: #ef4444; box-shadow: 0 0 0 4px var(--red-soft); }
.status-title { font-weight: 700; font-size: 17px; }
.note { font-size: 13px; color: var(--muted); margin: 10px 0 0; }
.banner { border-radius: 12px; padding: 10px 12px; font-size: 14px; }
.banner.warn { background: var(--amber-soft); color: var(--amber); }
.banner.bad { background: var(--red-soft); color: var(--red); }
.banner.info { background: var(--blue-soft); color: var(--blue); }

/* lists */
.list { display: grid; }
.item { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--border); }
.item:first-child { border-top: 0; padding-top: 0; }
.item .title { font-weight: 600; }
.item .meta { font-size: 13px; color: var(--muted); }
.item .right { text-align: right; font-variant-numeric: tabular-nums; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.chip { font-size: 11px; padding: 2px 7px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.chip.warn { background: var(--amber-soft); color: var(--amber); }
.chip.bad { background: var(--red-soft); color: var(--red); }
.chip.ok { background: var(--green-soft); color: var(--green); }
.empty { color: var(--muted); font-size: 14px; text-align: center; padding: 8px 0; }

/* bars */
.bar { position: relative; height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin-top: 6px; }
.bar > span { position: absolute; inset: 0 auto 0 0; border-radius: 999px; background: var(--blue-2); }
.bar > i { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--text); opacity: 0.55; }

/* chart */
.chart { width: 100%; height: 140px; display: block; }
.chart .line { fill: none; stroke: var(--blue-2); stroke-width: 2; vector-effect: non-scaling-stroke; }
.chart .area { fill: var(--blue-soft); opacity: 0.9; }
.chart .base { stroke: var(--border); stroke-width: 1; vector-effect: non-scaling-stroke; stroke-dasharray: 4 4; }

/* segmented */
.segmented { display: flex; background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 3px; overflow-x: auto; }
.segmented button { flex: 1; border: 0; background: transparent; color: var(--muted); font: inherit; font-size: 13px; padding: 6px 8px; border-radius: 8px; white-space: nowrap; }
.segmented button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); font-weight: 600; }

/* login */
.login { text-align: center; padding: 28px 20px; margin-top: 24px; }
.login img { border-radius: 14px; }
.login h1 { font-size: 22px; margin: 12px 0 6px; }
.login form { display: grid; gap: 10px; margin-top: 16px; }
input[type=password] {
  font: inherit; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text); width: 100%;
}
.btn {
  font: inherit; font-weight: 600; border: 0; border-radius: 12px; padding: 12px 14px;
  background: var(--blue); color: #fff;
}
.btn.ghost { background: var(--surface-2); color: var(--text); }
.error { color: var(--red); font-size: 14px; }

/* tab bar */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(160%) blur(12px);
  -webkit-backdrop-filter: saturate(160%) blur(12px);
  border-top: 1px solid var(--border);
}
.tabbar button {
  border: 0; background: transparent; color: var(--muted); font: inherit; font-size: 11px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
}
.tabbar svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabbar button.active { color: var(--blue); font-weight: 600; }
body.locked .tabbar { display: none; }
