:root { color-scheme: light dark;
  --bg: #f6f7f9; --card: #fff; --text: #1c2330; --muted: #6b7686; --line: #e2e6ec;
  --accent: #2f6fde; --red: #d64545; --red-bg: #fdeaea; --yellow: #a87300; --yellow-bg: #fff6d6;
  --green: #1f8a4c;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #14171c; --card: #1c2027; --text: #e6e9ee; --muted: #8b95a5; --line: #2c323c;
    --accent: #6c9cff; --red: #ff7676; --red-bg: #3a1f22; --yellow: #f0c040; --yellow-bg: #3a3216; --green: #5fd38d; }
}
* { 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); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
main { max-width: 1280px; margin: 0 auto; padding: 16px; }
h1 { font-size: 22px; margin: 8px 0 16px; }
h1 small { font-size: 14px; color: var(--muted); font-weight: normal; }
h2 { font-size: 17px; margin: 28px 0 10px; }
.top { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; padding: 10px 16px; background: var(--card); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; color: var(--text); }
.top nav { display: flex; gap: 14px; }
.fresh { color: var(--muted); font-size: 13px; margin-left: auto; }
.logout button, button.link { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 0; font: inherit; }
.alert { background: var(--yellow-bg); border: 1px solid var(--line); padding: 8px 14px; margin: 12px 16px 0; border-radius: 6px; }
.alert ul { margin: 4px 0 0; padding-left: 18px; }
.note { background: var(--card); border-left: 3px solid var(--accent); padding: 6px 10px; }
.muted { color: var(--muted); }
.scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; background: var(--card); border: 1px solid var(--line); border-radius: 8px; }
table { border-collapse: collapse; width: 100%; background: var(--card); }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; vertical-align: top; }
th { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: none; }
th:first-child, td:first-child { text-align: left; }
td.name { position: sticky; left: 0; background: var(--card); font-weight: 600; }
td .v { display: block; font-variant-numeric: tabular-nums; }
td .d { display: block; font-size: 12px; color: var(--muted); }
td.lv-red { background: var(--red-bg); }
td.lv-red .d { color: var(--red); font-weight: 600; }
td.lv-yellow { background: var(--yellow-bg); }
td.lv-yellow .d { color: var(--yellow); font-weight: 600; }
td.prov .v { opacity: .65; }
span.lv-red { color: var(--red); font-weight: 600; }
span.lv-yellow { color: var(--yellow); font-weight: 600; }
.sp { color: var(--accent); }
.legend { color: var(--muted); font-size: 13px; }
.badge { display: inline-block; font-size: 11px; padding: 1px 6px; border-radius: 9px; background: var(--line); color: var(--muted); font-weight: normal; margin-left: 4px; }
.badge.warn { background: var(--red-bg); color: var(--red); }
.up { color: var(--green); } .down { color: var(--red); }
.ranges a { white-space: nowrap; display: inline-block; margin: 2px 2px; padding: 2px 8px; border-radius: 12px; }
.ranges a.on { background: var(--accent); color: #fff; }
.charts { display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 14px; }
.chart { margin: 0; background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; position: relative; }
.chart figcaption { font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.plot { height: 180px; position: relative; }
.plot svg { width: 100%; height: 100%; display: block; overflow: visible; }
.plot .tip { position: absolute; pointer-events: none; background: var(--text); color: var(--bg); font-size: 12px; padding: 3px 7px; border-radius: 4px; white-space: nowrap; transform: translate(-50%, -110%); }
.plot .empty { color: var(--muted); font-size: 13px; padding-top: 70px; text-align: center; }
.legend-row { font-size: 12px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 10px; margin-top: 4px; }
.legend-row i { display: inline-block; width: 10px; height: 3px; vertical-align: middle; margin-right: 4px; }
form.inline { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 8px 0; }
input, select, button { font: inherit; }
input, select { padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--card); color: var(--text); }
button { padding: 6px 14px; border: 0; border-radius: 6px; background: var(--accent); color: #fff; cursor: pointer; }
.markers { padding-left: 18px; } .markers li { margin: 4px 0; }
.pick a { margin-right: 4px; }
.login { max-width: 340px; margin: 12vh auto; background: var(--card); padding: 24px; border-radius: 10px; border: 1px solid var(--line); }
.login form { display: grid; gap: 12px; }
.login label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.error { color: var(--red); }
tfoot th, tfoot td { font-size: 14px; font-weight: 700; color: var(--text); }
tfoot tr.muted td { font-weight: normal; color: var(--muted); }
.nodata-note { color: var(--muted); font-size: 13px; margin-top: 10px; }
@media (max-width: 767px) {
  table.overview thead { display: none; }
  table.overview, table.overview tbody { display: block; }
  table.overview tr { display: grid; grid-template-columns: repeat(3, 1fr); border-bottom: 1px solid var(--line); }
  table.overview td { border: 0; text-align: left; white-space: normal; }
  table.overview td.name { grid-column: 1 / -1; position: static; padding-bottom: 0; }
  table.overview td.sp { grid-column: 1 / -1; padding-top: 0; }
  table.overview td[data-label]::before { content: attr(data-label); display: block; font-size: 11px; color: var(--muted); }
  table.overview td.sp::before { display: none; }
  table.overview td.sp svg { width: 100%; }
  .overview-wrap { overflow: visible; }
  main { padding: 10px; }
  .charts { grid-template-columns: 1fr; }
  .fresh { margin-left: 0; width: 100%; order: 3; }
  th, td { padding: 6px 8px; }
}
