:root {
  --bg: #f6f7fb; --card: #ffffff; --text: #151823; --muted: #6b7280; --line: #e5e7ee;
  --accent: #4f46e5; --accent-soft: #eceafd; --ok: #16a34a; --warn: #d97706; --bad: #dc2626;
  --shadow: 0 1px 2px rgba(20, 24, 40, .06), 0 4px 16px rgba(20, 24, 40, .05);
  --tab-h: 58px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1115; --card: #181b22; --text: #eceef4; --muted: #9aa1b2; --line: #2a2f3a;
    --accent: #8b87ff; --accent-soft: #25254a; --shadow: none;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  padding-top: env(safe-area-inset-top);
}
main { max-width: 920px; margin: 0 auto; padding: 14px 16px calc(var(--tab-h) + 28px + env(safe-area-inset-bottom)); min-height: 100vh; }
h1 { font-size: 26px; margin: 8px 0 4px; letter-spacing: -.02em; }
h2 { font-size: 17px; margin: 0 0 10px; }
h3 { font-size: 15px; margin: 14px 0 6px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
a { color: var(--accent); }
.head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.head h1 { margin: 0; }
.grid { display: grid; gap: 12px; }
@media (min-width: 720px) { .grid.two { grid-template-columns: 1fr 1fr; } .grid.three { grid-template-columns: repeat(3, 1fr); } }
.card { background: var(--card); border-radius: 18px; padding: 16px; box-shadow: var(--shadow); border: 1px solid var(--line); margin-bottom: 12px; overflow: hidden; }
.card > h2:first-child { margin-top: 0; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(104px, 1fr)); gap: 10px; margin-bottom: 12px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 12px; box-shadow: var(--shadow); }
.kpi b { display: block; font-size: 22px; letter-spacing: -.02em; }
.kpi span { font-size: 13px; color: var(--muted); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 10px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { border: 1px solid var(--line); background: var(--card); color: var(--text); border-radius: 999px; padding: 7px 14px; font: inherit; font-size: 14px; white-space: nowrap; cursor: pointer; }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn { border: 1px solid var(--line); background: var(--card); color: var(--text); border-radius: 12px; padding: 11px 16px; font: inherit; font-weight: 600; cursor: pointer; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--bad); }
.btn:disabled { opacity: .5; }
.btn.small { padding: 6px 12px; font-size: 14px; }
input[type=text], input[type=password], textarea, select {
  width: 100%; font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px;
}
textarea { resize: vertical; min-height: 64px; }
.chart { width: 100%; height: 260px; }
.chart.tall { height: 340px; }
.chart.short { height: 200px; }
.empty { text-align: center; color: var(--muted); padding: 28px 12px; }
.empty b { display: block; color: var(--text); margin-bottom: 4px; }
.rate { display: flex; gap: 8px; }
.rate button { flex: 1; aspect-ratio: 1; max-height: 58px; border-radius: 16px; border: 2px solid transparent; font: inherit; font-size: 22px; font-weight: 700; color: #fff; cursor: pointer; opacity: .85; }
.rate button.on { border-color: var(--text); opacity: 1; transform: scale(1.06); }
.rate-lbl { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin: 6px 2px 10px; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu a { text-decoration: none; color: var(--text); display: flex; justify-content: space-between; padding: 14px 4px; border-bottom: 1px solid var(--line); }
.menu a:last-child { border-bottom: 0; }
.menu a::after { content: "›"; color: var(--muted); }
.bars .row { display: grid; grid-template-columns: minmax(80px, 38%) 1fr auto; gap: 8px; align-items: center; padding: 4px 0; font-size: 14px; }
.bars .row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bars .bar { height: 10px; border-radius: 6px; background: var(--accent-soft); overflow: hidden; }
.bars .bar i { display: block; height: 100%; background: var(--accent); border-radius: 6px; }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th, table.t td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.t th { color: var(--muted); font-weight: 600; font-size: 12px; }
.scroll-x { overflow-x: auto; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.pill.fresh { background: #dcfce7; color: #166534; } .pill.lag { background: #fef3c7; color: #92400e; } .pill.stale { background: #fee2e2; color: #991b1b; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .pill.fresh { background: #14532d; color: #bbf7d0; } :root:not([data-theme="light"]) .pill.lag { background: #78350f; color: #fde68a; } :root:not([data-theme="light"]) .pill.stale { background: #7f1d1d; color: #fecaca; } }
.md h1, .md h2, .md h3 { margin: 14px 0 6px; }
.md p { margin: 8px 0; } .md ul, .md ol { padding-left: 22px; } .md code { background: var(--bg); padding: 1px 5px; border-radius: 5px; }
.md pre { background: var(--bg); padding: 10px; border-radius: 10px; overflow-x: auto; } .md blockquote { margin: 8px 0; padding-left: 12px; border-left: 3px solid var(--line); color: var(--muted); }
.map { height: 380px; border-radius: 14px; overflow: hidden; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tab-h) + 20px + env(safe-area-inset-bottom)); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px; z-index: 50; }
.banner { background: var(--accent-soft); border-radius: 14px; padding: 12px 14px; margin-bottom: 12px; font-size: 14px; }
.spin { text-align: center; padding: 40px; color: var(--muted); }
#tabs {
  position: fixed; left: 0; right: 0; bottom: 0; display: flex; background: color-mix(in srgb, var(--card) 92%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom); z-index: 20;
}
#tabs a { flex: 1; height: var(--tab-h); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 11px; color: var(--muted); text-decoration: none; }
#tabs svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
#tabs a.on { color: var(--accent); }
@media (min-width: 900px) { #tabs { left: 50%; right: auto; transform: translateX(-50%); width: 560px; bottom: 12px; border: 1px solid var(--line); border-radius: 20px; } }
body.login { display: grid; place-items: center; min-height: 100vh; }
.login-card { width: min(92vw, 360px); text-align: center; display: grid; gap: 12px; }
.login-card img { margin: 0 auto; border-radius: 20px; }
.login-card h1 { margin: 0; }
.err { color: var(--bad); min-height: 1.2em; margin: 0; }
