:root {
  --bg: #f4f5f7; --card: #ffffff; --text: #111827; --muted: #6b7280; --line: #e5e7eb;
  --accent: #f59e0b; --ok: #16a34a; --warn: #f59e0b; --bad: #dc2626; --heat: #ea580c; --info: #2563eb;
  --chip: #eef0f3; --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0b1020; --card: #131a2b; --text: #e5e7eb; --muted: #94a3b8; --line: #23304a; --chip: #1d2740; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
.hidden { display: none !important; }
main { max-width: 1100px; margin: 0 auto; padding: 12px 14px calc(24px + env(safe-area-inset-bottom)); display: grid; gap: 12px; }
h2 { font-size: 15px; margin: 0; font-weight: 600; }
.section-title { margin: 6px 2px 8px; display: flex; gap: 8px; align-items: baseline; }
.muted { color: var(--muted); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.chip { background: var(--chip); color: var(--muted); border-radius: 999px; padding: 2px 10px; font-size: 12px; white-space: nowrap; }
.chip.ok { color: var(--ok); } .chip.warn { color: var(--warn); } .chip.bad { color: var(--bad); } .chip.heat { color: var(--heat); }
.top { display: flex; justify-content: space-between; align-items: center; padding: 4px 2px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 18px; }
.brand img { width: 28px; height: 28px; border-radius: 8px; }
.status { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); display: inline-block; }
.dot.ok { background: var(--ok); } .dot.bad { background: var(--bad); }

.hero .hero-head { display: flex; justify-content: space-between; align-items: center; }
.label { color: var(--muted); font-size: 13px; }
.power { font-size: 52px; font-weight: 700; letter-spacing: -1px; line-height: 1.1; margin: 4px 0 10px; }
.unit { font-size: 0.4em; color: var(--muted); margin-left: 4px; font-weight: 600; }
.bar { position: relative; height: 14px; background: var(--chip); border-radius: 999px; overflow: visible; }
.bar.small { height: 8px; margin: 6px 0 8px; }
.bar-fill { height: 100%; width: 0; border-radius: 999px; background: var(--ok); transition: width .6s ease, background .3s; }
.bar-fill.warn { background: var(--warn); } .bar-fill.bad { background: var(--bad); }
.bar-mark { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--text); opacity: .5; }
.bar-mark.limit { right: 0; background: var(--bad); opacity: .9; }
.bar-mark.target { border-left: 2px dashed var(--warn); background: transparent; }
.bar-legend { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; margin-top: 6px; }

.grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(155px, 1fr)); }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; }
.zone { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; display: grid; gap: 4px; }
.zone.heating { border-color: var(--heat); box-shadow: inset 0 0 0 1px var(--heat); }
.zone.off { opacity: .6; }
.zone.offline { opacity: .45; }
.zone .name { font-weight: 600; display: flex; justify-content: space-between; gap: 6px; }
.zone .t { font-size: 28px; font-weight: 700; }
.zone .sp { color: var(--muted); font-size: 13px; }
.zone .meta { display: flex; gap: 6px; flex-wrap: wrap; }
.zone .order { font-size: 11px; color: var(--muted); }
.big { font-size: 40px; font-weight: 700; }
.facts { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; margin: 0; }
.facts dt { color: var(--muted); } .facts dd { margin: 0; text-align: right; font-weight: 600; }
.events { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 13px; }
.events li { display: grid; grid-template-columns: 52px 1fr; gap: 8px; }
.events .when { color: var(--muted); font-variant-numeric: tabular-nums; }
.events.compact li { grid-template-columns: 52px 1fr; }
.tabs { display: flex; gap: 4px; background: var(--chip); padding: 3px; border-radius: 999px; }
.tabs button { border: 0; background: transparent; color: var(--muted); padding: 4px 10px; border-radius: 999px; font: inherit; font-size: 12px; cursor: pointer; }
.tabs button.on { background: var(--card); color: var(--text); }
.chart { width: 100%; min-height: 240px; }
.lights { display: flex; flex-wrap: wrap; gap: 8px; }
.light { display: flex; align-items: center; gap: 6px; background: var(--chip); border-radius: 999px; padding: 6px 12px; font-size: 13px; }
.light .bulb { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.light.on .bulb { background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.light.offline { opacity: .45; }
.foot { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 12px; padding: 4px 2px; }
button.link { background: none; border: 0; color: var(--info); font: inherit; cursor: pointer; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; width: min(360px, 100%); display: grid; gap: 10px; }
.login-card input { padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font: inherit; }
.login-card button { padding: 10px; border: 0; border-radius: 10px; background: var(--accent); color: #111; font-weight: 700; font: inherit; cursor: pointer; }
.error { color: var(--bad); min-height: 1em; margin: 0; }
.hint { color: var(--muted); font-size: 12px; margin: 0; }
.uplot, .u-legend { color: var(--text); }

.collapsible .collapse-head { all: unset; cursor: pointer; display: flex; justify-content: space-between; align-items: center; width: 100%; }
.collapsible .collapse-head .ttl { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.collapsible .chev { color: var(--muted); transition: transform .2s; font-size: 18px; }
.collapsible.open .chev { transform: rotate(180deg); }
.collapsible .temps { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.collapsible .temps > div { display: grid; }
.collapsible .tval { font-size: 30px; font-weight: 700; }
.collapsible .zones-grid { display: none; margin-top: 12px; }
.collapsible.open .zones-grid { display: grid; }
.collapsible .collapse-head:focus-visible { outline: 2px solid var(--info); outline-offset: 4px; border-radius: 6px; }
