:root {
  --bg: #0b1220; --panel: #121b2e; --panel-2: #182440; --line: #26334f; --text: #e6ecf7; --muted: #8b98b3;
  --accent: #4f8cff; --pos: #2fbf71; --neg: #ff5d5d; --warn: #f5b942; --radius: 12px;
}
@media (prefers-color-scheme: light) {
  :root { --bg: #f4f6fb; --panel: #ffffff; --panel-2: #eef2fa; --line: #d9e0ee; --text: #101828; --muted: #5b6577; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body { min-height: 100dvh; }
.hidden { display: none !important; }
.muted { color: var(--muted); } .small { font-size: 12px; } .err { color: var(--neg); min-height: 1.2em; margin: 8px 0 0; }
button, input { font: inherit; }
button { border: 1px solid var(--line); background: var(--panel-2); color: var(--text); border-radius: 10px; padding: 10px 14px; min-height: 44px; cursor: pointer; touch-action: manipulation; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.ghost { background: transparent; }
button.small { padding: 6px 12px; min-height: 36px; font-size: 13px; }
input { width: 100%; padding: 12px; min-height: 44px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); font-size: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.screen { min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; display: grid; gap: 10px; }
.login-card h1 { margin: 0; font-size: 22px; }
.topbar { position: sticky; top: 0; z-index: 5; background: var(--bg); border-bottom: 1px solid var(--line); padding-top: env(safe-area-inset-top); }
.top { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 16px 6px; }
.status { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand { font-weight: 700; }
.status { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.dot.open { background: var(--pos); } .dot.err { background: var(--neg); }
main { padding: 12px 16px calc(24px + env(safe-area-inset-bottom)); max-width: 1100px; margin: 0 auto; }
.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; gap: 8px; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
table { border-collapse: collapse; width: 100%; font-size: 14px; white-space: nowrap; }
th, td { padding: 11px 10px; border-bottom: 1px solid var(--line); text-align: left; }
th { position: sticky; top: 0; background: var(--panel-2); color: var(--muted); font-weight: 600; cursor: pointer; user-select: none; font-size: 12px; }
th.sorted::after { content: " ▾"; } th.sorted.asc::after { content: " ▴"; }
th:first-child, td:first-child { position: sticky; left: 0; background: var(--panel); z-index: 1; font-weight: 700; }
th:first-child { background: var(--panel-2); z-index: 2; }
tbody tr { cursor: pointer; } tbody tr:active { background: var(--panel-2); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.pos { color: var(--pos); } .neg { color: var(--neg); }
.sig { color: var(--warn); margin-left: 4px; }
.badge { display: inline-block; font-size: 10px; padding: 1px 5px; border-radius: 6px; border: 1px solid var(--line); color: var(--muted); margin-left: 4px; }
.badge.on { color: var(--pos); border-color: var(--pos); } .badge.off { color: var(--neg); border-color: var(--neg); }
.range { display: inline-block; width: 70px; height: 6px; border-radius: 3px; background: linear-gradient(90deg, var(--neg), var(--warn), var(--pos)); position: relative; vertical-align: middle; opacity: .8; }
.range i { position: absolute; top: -4px; width: 3px; height: 14px; background: var(--text); border-radius: 2px; margin-left: -1px; }
.legend { margin: 10px 2px 0; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; -webkit-overflow-scrolling: touch; }
.chips button { padding: 6px 10px; font-size: 13px; flex: 0 0 auto; }
.chips button.active, .ranges button.active, .tabs button.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.ranges { display: flex; gap: 6px; margin: 8px 0; }
.ranges button { flex: 1; padding: 7px 0; font-size: 13px; }
.chart-meta { display: flex; justify-content: space-between; align-items: baseline; margin: 4px 0 6px; }
.chart-meta .big { font-size: 22px; font-weight: 700; }
.chart-box { position: relative; height: 52vh; min-height: 260px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; }
.row { display: flex; gap: 8px; } .row input { flex: 1; }
.list { list-style: none; padding: 0; margin: 12px 0; display: grid; gap: 6px; }
.list li { display: flex; justify-content: space-between; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 8px 8px 14px; }
.list li .x { background: transparent; border: none; color: var(--neg); font-size: 18px; padding: 4px 10px; }
details.card { margin: 14px 0; } details summary { cursor: pointer; font-weight: 600; }
details form { display: grid; gap: 8px; margin-top: 10px; }
.sys { margin: 12px 0; line-height: 1.6; }
.tabs { display: flex; gap: 6px; padding: 0 12px 10px; max-width: 1100px; margin: 0 auto; }
.tabs button { flex: 1; padding: 0; min-height: 40px; font-weight: 600; font-size: 14px; border-radius: 10px; }
@media (min-width: 900px) { .tabs { max-width: 520px; } }
.burst { color: var(--warn); font-weight: 700; }
.alerts li { align-items: flex-start; padding: 10px 12px; }
.alerts li.burst { border-left: 3px solid var(--warn); }
.alerts li.day { border-left: 3px solid var(--accent); }
