:root {
  --bg: #f3f5f7; --card: #ffffff; --text: #16202a; --muted: #5b6875; --line: #dde2e7;
  --accent: #b97f00; --accent-solid: #f2a900; --on-accent: #1a1300;
  --good: #1b7f3b; --warn: #a15c00; --bad: #c62828;
  --st-offline: #6b7480; --st-alarm: #c62828; --st-stopped: #44515e; --st-starting: #b26a00;
  --st-transition: #1565c0; --st-onload: #1b7f3b; --st-running: #2e7d6b;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1418; --card: #1a2229; --text: #e8edf1; --muted: #9aa7b3; --line: #2b363f;
    --accent: #f2a900;
    --good: #5fd083; --warn: #ffb74d; --bad: #ff7b72;
    --st-offline: #55606b; --st-alarm: #d32f2f; --st-stopped: #3a4652; --st-starting: #b26a00;
    --st-transition: #1976d2; --st-onload: #2e9d4f; --st-running: #2e8f7a;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: var(--accent); }
h1, h2 { margin: 0; }
small { font-weight: 400; color: var(--muted); }

.top {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top));
  background: var(--card); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 700; }
.brand small { display: block; font-size: 12px; line-height: 1; }
.who { display: flex; align-items: center; gap: 10px; margin: 0; font-size: 14px; color: var(--muted); }
button.link { background: none; border: 0; padding: 8px 0; color: var(--accent); font: inherit; cursor: pointer; }

main { max-width: 900px; margin: 0 auto; padding: 16px; }
.page-title { font-size: 22px; margin: 4px 0 14px; }
.page-title small { font-size: 14px; margin-left: 6px; }
.back { display: inline-block; padding: 6px 0; text-decoration: none; font-size: 14px; }
.section { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 22px 0 8px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.cards { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.genset-card { display: block; color: inherit; text-decoration: none; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 10px; }
.card-head h2 { font-size: 18px; }
.sub { font-size: 12px; color: var(--muted); font-weight: 400; }
.mode { font-size: 13px; font-weight: 600; border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; white-space: nowrap; }

.banner { color: #fff; font-weight: 700; letter-spacing: .03em; border-radius: 8px; padding: 9px 12px; text-align: center; }
.banner.big { font-size: 20px; padding: 14px 12px; flex: 1; }
.st-offline { background: var(--st-offline); } .st-alarm { background: var(--st-alarm); }
.st-stopped { background: var(--st-stopped); } .st-starting { background: var(--st-starting); }
.st-transition { background: var(--st-transition); } .st-onload { background: var(--st-onload); }
.st-running { background: var(--st-running); }

.status-row { display: flex; gap: 10px; align-items: stretch; }
.mode-box { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 8px 14px; display: flex; flex-direction: column; justify-content: center; min-width: 96px; text-align: center; }
.mode-box small { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.mode-box strong { font-size: 17px; }

.badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.badge { font-size: 13px; font-weight: 700; border-radius: 6px; padding: 4px 9px; border: 1.5px solid currentColor; }
.good { color: var(--good); } .warn { color: var(--warn); } .bad { color: var(--bad); }
.notice { background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--st-offline); border-radius: 8px; padding: 10px 12px; margin: 12px 0 0; font-size: 14px; }

dl { margin: 0; }
dt { font-size: 12px; color: var(--muted); }
dd { margin: 0; font-size: 22px; font-weight: 650; font-variant-numeric: tabular-nums; }
dd small { font-size: 13px; }
.tiles { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.tiles > div { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.mini { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.mini dd { font-size: 18px; }

.table-card { margin-top: 8px; padding: 6px 12px 10px; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { padding: 8px 4px; text-align: right; border-bottom: 1px solid var(--line); }
tbody tr:last-child th, tbody tr:last-child td { border-bottom: 0; }
th { font-size: 12px; color: var(--muted); font-weight: 500; }
tbody th { text-align: left; }
td { font-weight: 600; }

.flags { list-style: none; margin: 0; padding: 4px 14px; }
.flags li { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.flags li:last-child { border-bottom: 0; }
.flags em { margin-left: auto; font-style: normal; font-size: 13px; color: var(--muted); }
.flags .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--line); }
.flags li.bad .dot, .flags li.warn .dot { background: currentColor; }
.flags li.bad, .flags li.warn { font-weight: 700; }
.flags li.bad em, .flags li.warn em { color: inherit; }

.updated, .hint { font-size: 12px; color: var(--muted); margin: 10px 2px 0; }
.stale .updated { color: var(--bad); font-weight: 600; }
.empty { text-align: center; padding: 28px 14px; }

.charts { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.chart { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px 6px; }
.chart h3 { margin: 0 0 4px; font-size: 14px; display: flex; justify-content: space-between; }
.chart h3 span { color: var(--muted); font-weight: 400; font-size: 12px; }
.chart svg { display: block; width: 100%; height: auto; }
.chart .line { fill: none; stroke: var(--accent-solid); stroke-width: 2; stroke-linejoin: round; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart text { fill: var(--muted); font-size: 11px; }

.login { max-width: 380px; margin: 8vh auto 0; display: grid; gap: 14px; padding: 22px; }
.login h1 { font-size: 22px; }
label { display: grid; gap: 6px; font-size: 14px; color: var(--muted); }
input { font: inherit; font-size: 16px; padding: 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--text); }
input:focus-visible, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent-solid); outline-offset: 2px; }
button.primary { font: inherit; font-weight: 700; padding: 13px; border: 0; border-radius: 8px; background: var(--accent-solid); color: var(--on-accent); cursor: pointer; }
.error { margin: 0; color: var(--bad); font-size: 14px; font-weight: 600; }
