.uplot,.uplot *,.uplot *:before,.uplot *:after{box-sizing:border-box}.uplot{font-family:system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji";line-height:1.5;width:min-content}.u-title{text-align:center;font-size:18px;font-weight:700}.u-wrap{position:relative;-webkit-user-select:none;user-select:none}.u-over,.u-under{position:absolute}.u-under{overflow:hidden}.uplot canvas{display:block;position:relative;width:100%;height:100%}.u-axis{position:absolute}.u-legend{font-size:14px;margin:auto;text-align:center}.u-inline{display:block}.u-inline *{display:inline-block}.u-inline tr{margin-right:16px}.u-legend th{font-weight:600}.u-legend th>*{vertical-align:middle;display:inline-block}.u-legend .u-marker{width:1em;height:1em;margin-right:4px;background-clip:padding-box!important}.u-inline.u-live th:after{content:":";vertical-align:middle}.u-inline:not(.u-live) .u-value{display:none}.u-series>*{padding:4px}.u-series th{cursor:pointer}.u-legend .u-off>*{opacity:.3}.u-select{background:#00000012;position:absolute;pointer-events:none}.u-cursor-x,.u-cursor-y{position:absolute;left:0;top:0;pointer-events:none;will-change:transform}.u-hz .u-cursor-x,.u-vt .u-cursor-y{height:100%;border-right:1px dashed #607D8B}.u-hz .u-cursor-y,.u-vt .u-cursor-x{width:100%;border-bottom:1px dashed #607D8B}.u-cursor-pt{position:absolute;top:0;left:0;border-radius:50%;border:0 solid;pointer-events:none;will-change:transform;background-clip:padding-box!important}.u-axis.u-off,.u-select.u-off,.u-cursor-x.u-off,.u-cursor-y.u-off,.u-cursor-pt.u-off{display:none}

:root {
  color-scheme: light;
  --bg: #f3f4f6;
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --border: #e4e6ea;
  --text: #0f1216;
  --text-2: #4b5260;
  --muted: #7c8392;
  --track: #e2e5ea;
  --accent: #1baf7a;
  --accent-ink: #ffffff;
  --grid: #2a78d6;
  --solar: #eb6834;
  --acout: #1baf7a;
  --dcout: #eda100;
  --batt: #6250d6;
  --good: #158a5e;
  --warn: #c27a00;
  --crit: #d33b3b;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 4px 16px rgba(16, 24, 40, .05);
  --radius: 18px;
  --nav-h: 64px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0d1014; --surface: #161a20; --surface-2: #1c2128; --border: #262c35;
    --text: #eef0f3; --text-2: #b4bac5; --muted: #828a98; --track: #2a313b;
    --grid: #3987e5; --solar: #d95926; --acout: #199e70; --dcout: #c98500; --batt: #9085e9;
    --good: #2fbf86; --warn: #e0a030; --crit: #ef5d5d;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 20px rgba(0,0,0,.25);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d1014; --surface: #161a20; --surface-2: #1c2128; --border: #262c35;
  --text: #eef0f3; --text-2: #b4bac5; --muted: #828a98; --track: #2a313b;
  --grid: #3987e5; --solar: #d95926; --acout: #199e70; --dcout: #c98500; --batt: #9085e9;
  --good: #2fbf86; --warn: #e0a030; --crit: #ef5d5d;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 20px rgba(0,0,0,.25);
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
  min-height: 100vh; overflow-x: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--grid); }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hidden { display: none !important; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh; padding: 22px 14px; border-right: 1px solid var(--border);
  background: var(--surface); display: flex; flex-direction: column; gap: 4px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; padding: 4px 10px 18px; }
.brand-mark { width: 30px; height: 30px; border-radius: 9px; background: var(--accent); display: grid; place-items: center; color: #fff; }
.nav-btn {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; border: 0;
  background: none; cursor: pointer; color: var(--text-2); font-weight: 550; text-align: left; position: relative;
}
.nav-btn svg { width: 20px; height: 20px; flex: none; }
.nav-btn:hover { background: var(--surface-2); }
.nav-btn.on { background: var(--surface-2); color: var(--text); }
.nav-btn .dot { position: absolute; left: 26px; top: 7px; width: 8px; height: 8px; border-radius: 50%; background: var(--crit); }
.main { min-width: 0; padding: 22px 28px 40px; max-width: 1240px; width: 100%; }
.topbar { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.topbar h1 { font-size: 22px; margin: 0; letter-spacing: -.01em; }
.topbar .spacer { flex: 1; }
.pill {
  display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border); font-size: 13px; color: var(--text-2); white-space: nowrap;
}
.pill i { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.pill.ok i { background: var(--good); box-shadow: 0 0 0 3px color-mix(in srgb, var(--good) 22%, transparent); }
.pill.bad i { background: var(--crit); }
.pill.warn i { background: var(--warn); }
.icon-btn {
  width: 38px; height: 38px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface);
  display: grid; place-items: center; cursor: pointer; color: var(--text-2);
}
.icon-btn svg { width: 18px; height: 18px; }

.tabbar { display: none; }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { display: none; }
  .main { padding: calc(14px + env(safe-area-inset-top)) 16px calc(var(--nav-h) + 24px + env(safe-area-inset-bottom)); }
  .topbar h1 { font-size: 20px; }
  .tabbar {
    display: grid; grid-template-columns: repeat(6, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(14px);
    border-top: 1px solid var(--border);
  }
  .tabbar .nav-btn { flex-direction: column; gap: 3px; justify-content: center; align-items: center; font-size: 11px; padding: 6px 0; border-radius: 0; background: none; }
  .tabbar .nav-btn.on { color: var(--accent); }
  .tabbar .nav-btn .dot { left: calc(50% + 6px); top: 9px; }
}

/* ---------- cards & layout ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; min-width: 0; }
.card h2 { font-size: 15px; margin: 0 0 12px; font-weight: 650; display: flex; align-items: center; gap: 8px; }
.card h2 .sub { margin-left: auto; font-weight: 450; font-size: 13px; color: var(--muted); }
.grid { display: grid; gap: 16px; }
.live-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(280px, 1fr); gap: 16px; align-items: start; }
@media (max-width: 1060px) { .live-grid { grid-template-columns: 1fr; } }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 760px) { .two { grid-template-columns: 1fr; } }
.stack { display: flex; flex-direction: column; gap: 16px; }

.banner {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: 14px; margin-bottom: 16px;
  background: color-mix(in srgb, var(--grid) 10%, var(--surface)); border: 1px solid color-mix(in srgb, var(--grid) 30%, var(--border));
  flex-wrap: wrap;
}
.banner.warn { background: color-mix(in srgb, var(--warn) 12%, var(--surface)); border-color: color-mix(in srgb, var(--warn) 35%, var(--border)); }
.banner .grow { flex: 1; min-width: 200px; }

/* ---------- power flow ---------- */
.flow-card { padding: 10px 10px 14px; }
.flow { width: 100%; height: auto; display: block; max-height: 520px; }
.flow .track { fill: none; stroke: var(--track); stroke-width: 3; stroke-linecap: round; }
.flow .wire { fill: none; stroke-width: 3; stroke-linecap: round; opacity: 0; transition: opacity .5s; }
.flow .wire.on { opacity: .55; }
.flow .node-bg { fill: var(--surface-2); stroke: var(--border); stroke-width: 1.5; transition: all .4s; }
.flow .node.on .node-bg { stroke-width: 2; }
.flow .node .ico { transition: opacity .4s; }
.flow .node:not(.on) .ico { opacity: .45; }
.flow .lbl { font-size: 13px; fill: var(--muted); text-anchor: middle; }
.flow .val { font-size: 17px; font-weight: 700; fill: var(--text); text-anchor: middle; font-variant-numeric: tabular-nums; }
.flow .node:not(.on) .val { fill: var(--muted); font-weight: 600; }
.flow .soc-track { fill: none; stroke: var(--track); stroke-width: 9; }
.flow .soc-ring { fill: none; stroke: var(--batt); stroke-width: 9; stroke-linecap: round; transition: stroke-dasharray 1s ease; transform: rotate(-90deg); transform-origin: center; transform-box: fill-box; }
.flow .soc-txt { font-size: 40px; font-weight: 750; fill: var(--text); text-anchor: middle; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.flow .soc-pct { font-size: 18px; font-weight: 600; fill: var(--muted); }
.flow .soc-sub { font-size: 13px; fill: var(--text-2); text-anchor: middle; font-variant-numeric: tabular-nums; }
.flow .dotp { filter: drop-shadow(0 0 4px currentColor); }
.flow .tag { font-size: 11px; fill: var(--muted); text-anchor: middle; }
.flow-meta { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; padding: 2px 8px 0; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 999px; font-size: 13px;
  background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); white-space: nowrap;
}
.chip svg { width: 14px; height: 14px; }
.chip.good { color: var(--good); }
.chip.crit { color: var(--crit); border-color: color-mix(in srgb, var(--crit) 40%, var(--border)); }

/* ---------- output tiles ---------- */
.out-tile { display: flex; align-items: center; gap: 14px; padding: 14px 16px; }
.out-tile .ic { width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center; flex: none; }
.out-tile .ic svg { width: 22px; height: 22px; }
.out-tile .t { flex: 1; min-width: 0; }
.out-tile .t b { display: block; font-size: 15px; }
.out-tile .t span { color: var(--muted); font-size: 13px; }

/* ---------- switches, inputs ---------- */
.switch { position: relative; width: 52px; height: 30px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--track); transition: background .25s; }
.switch span::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .25s cubic-bezier(.3,.7,.4,1.3);
}
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(22px); }
.switch input:disabled { cursor: not-allowed; }
.switch input:disabled + span { opacity: .45; }
.switch.busy span::after { animation: pulse .8s ease-in-out infinite alternate; }
@keyframes pulse { to { opacity: .4; } }

.row { display: flex; align-items: center; gap: 12px; padding: 13px 0; border-top: 1px solid var(--border); }
.row:first-of-type { border-top: 0; }
.row .t { flex: 1; min-width: 0; }
.row .t b { font-weight: 560; display: block; }
.row .t span { font-size: 13px; color: var(--muted); }
.row .na { font-size: 12px; color: var(--muted); }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: none; padding: 7px 12px; border-radius: 9px; cursor: pointer; color: var(--text-2); font-size: 13px; font-weight: 560; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.seg button:disabled { opacity: .5; cursor: not-allowed; }
input[type=text], input[type=password], input[type=number], input[type=time], input[type=url], select, textarea {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 11px; padding: 9px 12px; outline: none; min-width: 0;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }
textarea { width: 100%; resize: vertical; min-height: 70px; }
input[type=number] { width: 90px; }
.field { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; }
.field label { font-size: 13px; font-weight: 560; color: var(--text-2); }
.btn {
  border: 1px solid var(--border); background: var(--surface); padding: 9px 16px; border-radius: 11px; cursor: pointer;
  font-weight: 580; display: inline-flex; align-items: center; gap: 8px; justify-content: center; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.primary:hover { filter: brightness(1.05); }
.btn.danger { color: var(--crit); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

.range { display: flex; align-items: center; gap: 12px; width: 100%; }
.range input { flex: 1; accent-color: var(--accent); }
.range output { min-width: 44px; text-align: right; font-weight: 650; }

/* ---------- stats ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.stat { background: var(--surface-2); border: 1px solid var(--border); border-radius: 14px; padding: 12px 14px; }
.stat .k { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.stat .k i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }
.stat .v { font-size: 22px; font-weight: 700; letter-spacing: -.01em; margin-top: 2px; }
.stat .v small { font-size: 13px; font-weight: 550; color: var(--muted); margin-left: 3px; }

/* ---------- events ---------- */
.ev { display: flex; gap: 12px; padding: 11px 0; border-top: 1px solid var(--border); }
.ev:first-child { border-top: 0; }
.ev .sev { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; flex: none; }
.ev .sev svg { width: 17px; height: 17px; }
.ev .sev.critical { background: color-mix(in srgb, var(--crit) 15%, transparent); color: var(--crit); }
.ev .sev.warning { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.ev .sev.info { background: color-mix(in srgb, var(--good) 14%, transparent); color: var(--good); }
.ev .sev.control { background: var(--surface-2); color: var(--text-2); }
.ev .b { flex: 1; min-width: 0; }
.ev .b b { font-weight: 600; display: block; }
.ev .b span { font-size: 13px; color: var(--text-2); }
.ev time { font-size: 12px; color: var(--muted); white-space: nowrap; }
.day-h { font-size: 12px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin: 18px 0 2px; }
.empty { text-align: center; color: var(--muted); padding: 26px 10px; }

/* ---------- rules ---------- */
.rule { display: grid; grid-template-columns: auto 1fr auto; gap: 6px 12px; align-items: center; padding: 12px 0; border-top: 1px solid var(--border); }
.rule:first-child { border-top: 0; }
.rule .opts { grid-column: 2 / 4; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.rule .opts input[type=number] { width: 84px; padding: 6px 10px; }
.tog-chip { border: 1px solid var(--border); background: var(--surface-2); border-radius: 999px; padding: 4px 11px; font-size: 12.5px; cursor: pointer; color: var(--muted); display: inline-flex; gap: 6px; align-items: center; }
.tog-chip.on { color: var(--text); border-color: color-mix(in srgb, var(--accent) 50%, var(--border)); background: color-mix(in srgb, var(--accent) 12%, var(--surface)); }
.tog-chip svg { width: 13px; height: 13px; }
.sevdot { width: 9px; height: 9px; border-radius: 50%; }
.sevdot.critical { background: var(--crit); } .sevdot.warning { background: var(--warn); } .sevdot.info { background: var(--good); }

/* ---------- charts ---------- */
.chart-wrap { position: relative; width: 100%; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--text-2); margin: -2px 0 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }
.legend button { border: 0; background: none; padding: 0; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; color: inherit; font-size: 13px; }
.legend button.off { opacity: .4; text-decoration: line-through; }
.tip {
  position: absolute; pointer-events: none; z-index: 5; background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: var(--shadow); padding: 8px 10px; font-size: 12.5px; min-width: 140px; display: none;
}
.tip .h { color: var(--muted); margin-bottom: 4px; }
.tip .r { display: flex; align-items: center; gap: 8px; }
.tip .r i { width: 9px; height: 9px; border-radius: 2px; }
.tip .r b { margin-left: auto; padding-left: 10px; font-variant-numeric: tabular-nums; }
.uplot, .uplot * { font-family: inherit !important; }
.u-legend { display: none; }
.u-select { background: color-mix(in srgb, var(--grid) 12%, transparent); }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th, table.data td { text-align: right; padding: 7px 8px; border-top: 1px solid var(--border); font-variant-numeric: tabular-nums; }
table.data th:first-child, table.data td:first-child { text-align: left; }
table.data th { color: var(--muted); font-weight: 600; border-top: 0; }
.table-scroll { overflow-x: auto; }
details summary { cursor: pointer; color: var(--text-2); font-size: 13px; margin-top: 10px; }

/* ---------- misc ---------- */
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 14px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.drv { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-top: 1px solid var(--border); }
.drv:first-child { border-top: 0; }
.drv .sd { width: 10px; height: 10px; border-radius: 50%; margin-top: 6px; background: var(--muted); flex: none; }
.drv .sd.connected { background: var(--good); } .drv .sd.error { background: var(--crit); } .drv .sd.connecting { background: var(--warn); animation: pulse .8s infinite alternate; }
.drv .sd.active { box-shadow: 0 0 0 4px color-mix(in srgb, var(--good) 25%, transparent); }
.steps { margin: 6px 0 4px; padding-left: 20px; color: var(--text-2); font-size: 14px; }
.steps li { margin: 4px 0; }
.scan-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.scan-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); cursor: pointer; text-align: left; }
.scan-item:hover { border-color: var(--accent); }

#toasts { position: fixed; z-index: 100; top: calc(14px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; width: min(420px, calc(100vw - 32px)); pointer-events: none; }
.toast { pointer-events: auto; background: var(--surface); border: 1px solid var(--border); box-shadow: 0 10px 30px rgba(0,0,0,.18); border-radius: 14px; padding: 12px 14px; display: flex; gap: 10px; align-items: flex-start; animation: tin .3s ease; }
.toast.out { animation: tout .25s ease forwards; }
.toast .sev { width: 10px; height: 10px; border-radius: 50%; margin-top: 6px; flex: none; background: var(--good); }
.toast.critical .sev, .toast.error .sev { background: var(--crit); } .toast.warning .sev { background: var(--warn); }
.toast b { display: block; } .toast span { font-size: 13px; color: var(--text-2); }
@keyframes tin { from { opacity: 0; transform: translateY(-10px); } }
@keyframes tout { to { opacity: 0; transform: translateY(-10px); } }

.sheet-back { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 90; display: grid; place-items: center; padding: 16px; animation: fade .2s; }
.sheet { background: var(--surface); border-radius: 20px; padding: 22px; width: min(400px, 100%); box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.sheet h3 { margin: 0 0 6px; font-size: 18px; }
.sheet p { margin: 0 0 16px; color: var(--text-2); }
@keyframes fade { from { opacity: 0; } }

.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login .card { width: min(380px, 100%); padding: 28px; }
.login h1 { margin: 12px 0 4px; font-size: 22px; }
.login .brand-mark { width: 46px; height: 46px; border-radius: 14px; }
.login .brand-mark svg { width: 26px; height: 26px; }
.err { color: var(--crit); font-size: 13.5px; min-height: 20px; margin-top: 6px; }

@media (prefers-reduced-motion: reduce) { * { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
.i { width: 18px; height: 18px; flex: none; }
.card h2 .i { width: 17px; height: 17px; color: var(--text-2); }
.banner > .i { width: 20px; height: 20px; color: var(--text-2); }
.topbar h1 { font-weight: 700; }
.row.wide { flex-wrap: wrap; }
@media (max-width: 640px) {
  .row.wide .t { flex-basis: 100%; }
  .row.wide > .seg, .row.wide > select, .row.wide > .range { width: 100%; max-width: none !important; }
  .row.wide > .seg button { flex: 1; }
}
.flow.compact .soc-sub { font-size: 11.5px; }
.flow.compact .soc-time { font-size: 13px; }

/* ---------- automation, costs, health, integrations ---------- */
.banner.crit { background: color-mix(in srgb, var(--crit) 12%, var(--surface)); border-color: color-mix(in srgb, var(--crit) 40%, var(--border)); }
.banner.crit > .i { color: var(--crit); }
.chip.warn { color: var(--warn); }
.dim { opacity: .55; }
.sched { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-top: 1px solid var(--border); }
.sched:first-child { border-top: 0; }
.sched.off .sched-time, .sched.off .t b { color: var(--muted); }
.sched-time { font-size: 22px; font-weight: 700; letter-spacing: -.02em; min-width: 66px; }
.sched .t { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.sched .t b { font-weight: 600; }
.sched .t span { font-size: 13px; color: var(--text-2); }
.sched .icon-btn { width: 34px; height: 34px; }
.tpl { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--border); }
.days { display: flex; gap: 4px; flex-wrap: wrap; }
.days button { border: 1px solid var(--border); background: var(--surface-2); border-radius: 10px; padding: 7px 0; width: 44px; cursor: pointer; color: var(--muted); font-weight: 600; font-size: 13px; }
.days button.on { background: color-mix(in srgb, var(--accent) 14%, var(--surface)); border-color: color-mix(in srgb, var(--accent) 55%, var(--border)); color: var(--text); }
.sheet.wide { width: min(460px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; }
.costbars { display: flex; align-items: flex-end; gap: 3px; height: 90px; margin-top: 14px; padding-bottom: 2px; border-bottom: 1px solid var(--border); }
.costbars > div { flex: 1; height: 100%; display: flex; align-items: flex-end; }
.costbars i { display: block; width: 100%; background: var(--grid); border-radius: 3px 3px 0 0; opacity: .85; }
.costbars > div:hover i { opacity: 1; }
.spark { width: 100%; height: 70px; margin-top: 12px; display: block; }
.tf-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin: 10px 0 4px; }
.tf-grid label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 560; color: var(--text-2); }
.tf-grid input { width: 100%; }
.tariff { margin-top: 10px; }
.stat .small { margin-top: 2px; }
@media (max-width: 860px) { .tabbar .nav-btn { font-size: 10.5px; } }
.stats.quad { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.costaxis { display: flex; justify-content: space-between; margin-top: 4px; }
@media (max-width: 520px) {
  .sched { flex-wrap: wrap; gap: 4px 14px; }
  .sched .btns { width: 100%; justify-content: flex-end; }
}

/* ---------- polish (1.2.1) ---------- */
.outs { display: flex; flex-direction: column; gap: 16px; }
.out-tile .ic { transition: filter .3s, opacity .3s; }
.out-tile.off .ic { filter: grayscale(1); opacity: .55; }
.out-tile.off .t b { color: var(--text-2); }
.stats { grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); }
.flow .soc-time { font-weight: 550; }
@media (max-width: 1060px) {
  /* one column: flow, then the output switches, then the rest */
  .live-grid > .stack { display: contents; }
  .live-grid .flow-card { order: 1; }
  .live-grid .outs { order: 2; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .live-grid .today-card { order: 3; }
  .live-grid > .stack > .card:not(.flow-card):not(.today-card) { order: 4; }
}
@media (max-width: 560px) {
  .out-tile { flex-wrap: wrap; gap: 10px 12px; padding: 14px; }
  .out-tile .ic { width: 38px; height: 38px; border-radius: 11px; }
  .out-tile .t { flex-basis: 100%; order: 2; }
  .out-tile .switch { order: 1; margin-left: auto; }
  .flow-meta .chip { font-size: 12.5px; padding: 4px 10px; }
}

/* ---------- several power stations ---------- */
#devsw select { padding: 7px 30px 7px 12px; border-radius: 999px; font-weight: 600; max-width: 220px; }
.overview { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; margin-bottom: 16px; }
.overview:empty { display: none; }
.ov { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 16px; border: 1.5px solid var(--border);
  background: var(--surface); box-shadow: var(--shadow); cursor: pointer; text-align: left; min-height: 72px; }
.ov.on { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.ov.off { opacity: .7; }
.ov .t { display: flex; flex-direction: column; min-width: 0; }
.ov .t b { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ov .t > span { font-size: 13px; color: var(--text-2); }
.ov-ring { --p: 0; --c: var(--batt); width: 50px; height: 50px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: conic-gradient(var(--c) calc(var(--p) * 1%), var(--track) 0); }
.ov-ring > span { width: 40px; height: 40px; border-radius: 50%; background: var(--surface); display: flex; align-items: center;
  justify-content: center; font-weight: 700; font-size: 14px; }
.ov .t > span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ov-ring small { font-size: 9px; color: var(--muted); font-weight: 600; }
.devrow { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 4px; border: 0; border-top: 1px solid var(--border);
  background: none; cursor: pointer; text-align: left; color: inherit; }
.devrow:first-child { border-top: 0; }
.devrow:hover { background: var(--surface-2); }
.devrow .t { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.devrow .t b { font-weight: 600; }
.devrow .t span { font-size: 13px; color: var(--muted); }
.devrow .sd { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); flex: none; }
.devrow .sd.connected { background: var(--good); } .devrow .sd.error { background: var(--crit); }
.devrow .sd.connecting { background: var(--warn); animation: pulse .8s infinite alternate; }
.devrow > .i { color: var(--muted); }
.drvs { margin: 4px 0 6px; }
@media (max-width: 560px) {
  .overview { grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: minmax(200px, 78%); overflow-x: auto;
    scroll-snap-type: x mandatory; padding-bottom: 4px; margin-left: -16px; margin-right: -16px; padding-left: 16px; padding-right: 16px; }
  .ov { scroll-snap-align: start; }
}
