/* FAB Solar — design tokens, layout and components.
   Light/dark follow the system unless the user picks one in Settings (data-theme on <html>). */

:root {
  color-scheme: light;
  --bg: #f2f2f7; --surface: #ffffff; --surface-2: #f6f6f9; --surface-3: #ececf1;
  --text: #1d1d1f; --text-2: #6e6e73; --text-3: #8e8e93; --line: rgba(0,0,0,.08); --line-2: rgba(0,0,0,.14);
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.05);
  --accent: #0a84ff;
  /* entity colours (validated categorical slots; colour follows the entity) */
  --solar: #f47230; --grid: #257de0; --battery: #00b894; --home: #6a4ce2;
  --s1: #257de0; --s2: #f47230; --s3: #00b894; --s4: #f2a600; --s5: #ee7fac; --s6: #008a17; --s7: #6a4ce2; --s8: #ec4647;
  /* status (always paired with an icon and a label) */
  --good: #0aac23; --warn: #fbb315; --serious: #f18a59; --crit: #dc3c3d;
  --good-bg: rgba(10,172,35,.10); --warn-bg: rgba(251,179,21,.14); --crit-bg: rgba(220,60,61,.10);
  --radius: 18px; --radius-s: 12px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #000000; --surface: #1c1c1e; --surface-2: #232326; --surface-3: #2c2c2e;
    --text: #f5f5f7; --text-2: #a1a1a6; --text-3: #7c7c80; --line: rgba(255,255,255,.08); --line-2: rgba(255,255,255,.16);
    --shadow: none;
    --solar: #e76624; --grid: #338ced; --battery: #00a888; --home: #9887ef;
    --s1: #338ced; --s2: #e76624; --s3: #00a888; --s4: #d28e05; --s5: #e24d8b; --s6: #0aac23; --s7: #9887ef; --s8: #eb6263;
    --good-bg: rgba(10,172,35,.16); --warn-bg: rgba(251,179,21,.16); --crit-bg: rgba(220,60,61,.18);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #000000; --surface: #1c1c1e; --surface-2: #232326; --surface-3: #2c2c2e;
  --text: #f5f5f7; --text-2: #a1a1a6; --text-3: #7c7c80; --line: rgba(255,255,255,.08); --line-2: rgba(255,255,255,.16);
  --shadow: none;
  --solar: #e76624; --grid: #338ced; --battery: #00a888; --home: #9887ef;
  --s1: #338ced; --s2: #e76624; --s3: #00a888; --s4: #d28e05; --s5: #e24d8b; --s6: #0aac23; --s7: #9887ef; --s8: #eb6263;
  --good-bg: rgba(10,172,35,.16); --warn-bg: rgba(251,179,21,.16); --crit-bg: rgba(220,60,61,.18);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 15px/1.45 var(--font); background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
.num, .value, td.num { font-variant-numeric: tabular-nums; }
svg.icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- shell ---------- */
.app { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 18px; padding: 22px 14px;
  background: var(--surface); border-right: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; font-weight: 700; font-size: 17px; letter-spacing: -.01em; }
.brand-mark { width: 30px; height: 30px; border-radius: 9px; background: var(--solar); color: #fff; display: grid; place-items: center; }
.brand-mark svg.icon { width: 18px; height: 18px; stroke-width: 2; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 10px; color: var(--text-2); text-decoration: none; font-weight: 500; }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.on { background: var(--surface-3); color: var(--text); }
.nav a.on svg.icon { color: var(--accent); }
.nav .sep { height: 1px; background: var(--line); margin: 8px 6px; }
.sidebar-foot { margin-top: auto; padding: 0 8px; font-size: 12px; color: var(--text-3); display: flex; flex-direction: column; gap: 6px; }

.selector { display: flex; flex-direction: column; gap: 6px; padding: 0 4px; }
.selector label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); padding: 0 6px; }
.select { appearance: none; width: 100%; padding: 9px 34px 9px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2)
  url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238e8e93' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center; font-weight: 600; cursor: pointer; }

.topbar { display: none; }
.tabbar { display: none; }
main { padding: 26px 32px 48px; max-width: 1320px; width: 100%; min-width: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { font-size: 28px; line-height: 1.15; letter-spacing: -.02em; margin: 0; }
.page-head .sub { color: var(--text-2); font-size: 14px; margin-top: 4px; }

/* ---------- cards & grid ---------- */
.grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px; }
.span-12 { grid-column: span 12; } .span-8 { grid-column: span 8; } .span-7 { grid-column: span 7; } .span-6 { grid-column: span 6; }
.span-5 { grid-column: span 5; } .span-4 { grid-column: span 4; } .span-3 { grid-column: span 3; }
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--line); padding: 18px 20px; min-width: 0;
  animation: rise .35s ease both; }
.card h2 { font-size: 15px; font-weight: 600; margin: 0 0 12px; display: flex; align-items: center; gap: 8px; letter-spacing: -.005em; }
.card h2 .hint { margin-left: auto; font-weight: 400; font-size: 12px; color: var(--text-3); }
.card .note { font-size: 12px; color: var(--text-3); margin-top: 10px; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .card { animation: none; } .flow-line.active { animation: none !important; } }

.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.stat { background: var(--surface-2); border-radius: var(--radius-s); padding: 12px 14px; min-width: 0; }
.stat .k { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--text-2); }
.stat .k svg.icon { width: 16px; height: 16px; }
.stat .v { font-size: 21px; font-weight: 650; letter-spacing: -.015em; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat .v small { font-size: 13px; font-weight: 500; color: var(--text-2); margin-left: 3px; }
.stat .d { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.na { color: var(--text-3) !important; font-weight: 500 !important; }
.est-mark { color: var(--text-3); font-weight: 500; margin-right: 1px; }
.delta-up { color: var(--good); } .delta-down { color: var(--crit); }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 11px; border-radius: 999px; font-size: 13px; font-weight: 550; background: var(--surface); border: 1px solid var(--line); }
.chip svg.icon { width: 15px; height: 15px; }
.chip.good { background: var(--good-bg); border-color: transparent; } .chip.good svg { color: var(--good); }
.chip.warn { background: var(--warn-bg); border-color: transparent; } .chip.warn svg { color: #b67d00; }
.chip.crit { background: var(--crit-bg); border-color: transparent; } .chip.crit svg { color: var(--crit); }
:root[data-theme="dark"] .chip.warn svg { color: var(--warn); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .chip.warn svg { color: var(--warn); } }

.banner { display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px; border-radius: var(--radius-s); margin-bottom: 16px; font-size: 14px; animation: rise .3s ease both; }
.banner.warn { background: var(--warn-bg); } .banner.crit { background: var(--crit-bg); } .banner.info { background: var(--surface); border: 1px solid var(--line); }
.banner pre { white-space: pre-wrap; font: 12px/1.5 var(--mono); margin: 6px 0 0; }

/* ---------- controls ---------- */
.seg { display: inline-flex; background: var(--surface-3); border-radius: 10px; padding: 2px; gap: 2px; }
.seg button { border: 0; background: none; padding: 6px 12px; border-radius: 8px; font-size: 13px; font-weight: 550; color: var(--text-2); cursor: pointer; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line-2); background: var(--surface); color: var(--text); text-decoration: none; font-family: inherit; padding: 7px 12px; border-radius: 10px; font-size: 13px; font-weight: 550; cursor: pointer; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn:disabled { opacity: .5; cursor: default; }
.btn svg.icon { width: 16px; height: 16px; }
.icon-btn { border: 0; background: var(--surface-3); width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; cursor: pointer; color: var(--text); }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.datenav { display: inline-flex; align-items: center; gap: 6px; }
.datenav .lbl { min-width: 150px; text-align: center; font-weight: 600; font-size: 14px; }
input.field, select.field { padding: 7px 10px; border-radius: 9px; border: 1px solid var(--line-2); background: var(--surface); min-width: 0; }
input.field:focus, select.field:focus, .select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.switch { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; user-select: none; }
.switch input { appearance: none; width: 36px; height: 22px; border-radius: 11px; background: var(--surface-3); position: relative; cursor: pointer; transition: background .2s; margin: 0; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: transform .2s; }
.switch input:checked { background: var(--good); } .switch input:checked::after { transform: translateX(14px); }

/* ---------- energy flow ---------- */
.flow { width: 100%; max-width: 520px; margin: 0 auto; display: block; }
.flow .node-bg { fill: var(--surface-2); stroke: var(--line); }
.flow .node-icon { stroke-width: 1.6; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.flow .val { font-size: 15px; font-weight: 650; fill: var(--text); font-variant-numeric: tabular-nums; }
.flow .cap { font-size: 11.5px; fill: var(--text-2); }
.flow-line { fill: none; stroke: var(--line-2); stroke-width: 2.5; stroke-linecap: round; }
.flow-line.active { stroke-dasharray: 3 9; animation: dash var(--dur, 1.6s) linear infinite; }
.flow-line.static { stroke-dasharray: 3 6; }
@keyframes dash { to { stroke-dashoffset: -24; } }
.flow .outage { stroke: var(--crit); stroke-width: 2; fill: none; }

.soc { display: flex; align-items: center; gap: 20px; }
.soc-ring { width: 128px; height: 128px; flex: none; }
.soc-ring .track { stroke: var(--surface-3); } .soc-ring .bar { stroke: var(--battery); transition: stroke-dashoffset .8s ease; }
.soc-ring text { font-weight: 700; fill: var(--text); }
.soc .big { font-size: 15px; font-weight: 600; }
.soc .runtime { font-size: 26px; font-weight: 700; letter-spacing: -.02em; margin: 4px 0 2px; }
.soc .meta { font-size: 13px; color: var(--text-2); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.t th { text-align: left; font-weight: 500; color: var(--text-3); font-size: 12px; padding: 6px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.t td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.t tr:last-child td { border-bottom: 0; }
table.t td.num, table.t th.num { text-align: right; white-space: nowrap; }
[hidden] { display: none !important; }
.string.idle { opacity: .6; }
@media (max-width: 560px) {
  .flow .val { font-size: 19px; } .flow .cap { font-size: 14px; }
  table.t td, table.t th { padding-left: 6px; padding-right: 6px; }
}
table.t td.ph { font-weight: 650; }
.mono { font-family: var(--mono); font-size: 12px; }
.src { font-family: var(--mono); font-size: 11px; color: var(--text-3); }

/* ---------- charts ---------- */
.chart { position: relative; user-select: none; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .gridline { stroke: var(--line); } .chart .zero { stroke: var(--line-2); }
.chart .axis { fill: var(--text-3); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { opacity: .10; }
.chart .cross { stroke: var(--text-3); stroke-dasharray: 3 3; }
.chart .dot { stroke: var(--surface); stroke-width: 2; }
.chart .brush { fill: var(--accent); opacity: .12; }
.chart .bar-hl { fill: var(--text); opacity: .05; }
.chart .ghost { fill: var(--text-3); opacity: .35; }
.chart-tip { position: absolute; top: 4px; pointer-events: none; background: var(--surface); color: var(--text); border: 1px solid var(--line-2);
  box-shadow: 0 6px 24px rgba(0,0,0,.14); border-radius: 10px; padding: 8px 10px; font-size: 12px; min-width: 140px; z-index: 5; }
.chart-tip .t { font-weight: 650; margin-bottom: 4px; }
.chart-tip .r { display: flex; align-items: center; gap: 6px; justify-content: space-between; }
.chart-tip .r span:first-child { display: flex; align-items: center; gap: 6px; color: var(--text-2); }
.sw { width: 9px; height: 9px; border-radius: 3px; display: inline-block; flex: none; }
.legend { display: flex; gap: 6px 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-2); margin: 0 0 8px; }
.legend button { border: 0; background: none; padding: 2px 0; display: inline-flex; align-items: center; gap: 6px; color: inherit; cursor: pointer; font-size: inherit; }
.legend button.off { opacity: .4; }
.chart-foot { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--text-3); margin-top: 6px; }
.empty { display: grid; place-items: center; color: var(--text-3); font-size: 13px; min-height: 120px; text-align: center; padding: 12px; }
.skeleton { background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 10px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- alerts & timeline ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-3); white-space: nowrap; }
.badge svg.icon { width: 13px; height: 13px; }
.badge.crit { background: var(--crit-bg); } .badge.crit svg { color: var(--crit); }
.badge.warn { background: var(--warn-bg); } .badge.warn svg { color: #b67d00; }
.badge.good { background: var(--good-bg); } .badge.good svg { color: var(--good); }
.badge.serious { background: rgba(241,138,89,.15); } .badge.serious svg { color: var(--serious); }
.timeline { display: flex; flex-direction: column; gap: 6px; }
.tl-row { display: grid; grid-template-columns: 74px 1fr 64px; align-items: center; gap: 10px; font-size: 12px; color: var(--text-2); }
.tl-track { position: relative; height: 14px; background: var(--surface-2); border-radius: 7px; overflow: hidden; }
.tl-seg { position: absolute; top: 0; bottom: 0; background: var(--crit); border-radius: 3px; min-width: 2px; }
.tl-tick { position: absolute; top: 2px; bottom: 2px; width: 3px; border-radius: 2px; }
.tl-tick.voltage { background: var(--warn); } .tl-tick.frequency { background: var(--serious); }
.tl-hours { display: grid; grid-template-columns: 74px 1fr 64px; gap: 10px; font-size: 11px; color: var(--text-3); }
.tl-hours div:nth-child(2) { display: flex; justify-content: space-between; }
.event { display: grid; grid-template-columns: auto 1fr auto; gap: 4px 14px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.event:last-child { border-bottom: 0; }
.event .when { font-size: 12.5px; color: var(--text-2); white-space: nowrap; }
.event .msg { font-weight: 600; }
.event .adv { grid-column: 2 / 4; font-size: 13px; color: var(--text-2); }
.day-label { font-size: 12px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .05em; margin: 14px 0 2px; }

/* ---------- forms / settings ---------- */
.form-row { display: grid; grid-template-columns: minmax(160px, 260px) 1fr; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.form-row:last-child { border-bottom: 0; }
.form-row .lbl { font-weight: 550; } .form-row .lbl small { display: block; font-weight: 400; color: var(--text-3); font-size: 12px; }
details.raw { border-top: 1px solid var(--line); padding: 8px 0; }
details.raw summary { cursor: pointer; font-weight: 550; font-size: 13.5px; }
details.raw pre { font: 11.5px/1.5 var(--mono); background: var(--surface-2); padding: 12px; border-radius: 10px; overflow: auto; max-height: 420px; }

/* ---------- strings ---------- */
.strings { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.string { background: var(--surface-2); border-radius: var(--radius-s); padding: 12px 14px; }
.string .top { display: flex; justify-content: space-between; align-items: center; gap: 6px; font-weight: 650; }
.string .p { font-size: 22px; font-weight: 700; letter-spacing: -.02em; margin: 6px 0 2px; }
.string .row { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--text-2); }
.meter { height: 6px; background: var(--surface-3); border-radius: 3px; overflow: hidden; margin-top: 8px; }
.meter i { display: block; height: 100%; background: var(--solar); border-radius: 3px; transition: width .6s ease; }

/* ---------- mobile sheet ---------- */
.sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.3); z-index: 40; animation: fade .2s ease; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; background: var(--surface); border-radius: 18px 18px 0 0; padding: 10px 14px calc(18px + env(safe-area-inset-bottom));
  animation: up .25s ease; }
.sheet .grab { width: 36px; height: 5px; border-radius: 3px; background: var(--surface-3); margin: 0 auto 10px; }
.sheet a { display: flex; align-items: center; gap: 12px; padding: 13px 8px; color: var(--text); text-decoration: none; font-weight: 550; border-bottom: 1px solid var(--line); }
.sheet a:last-child { border-bottom: 0; }
@keyframes fade { from { opacity: 0; } } @keyframes up { from { transform: translateY(100%); } }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .span-7, .span-5, .span-8, .span-4 { grid-column: span 12; }
  .span-6 { grid-column: span 12; }
  .span-3 { grid-column: span 6; }
}
@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: none; }
  .topbar { display: flex; position: sticky; top: 0; z-index: 20; align-items: center; gap: 10px; padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
    background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: saturate(180%) blur(18px); -webkit-backdrop-filter: saturate(180%) blur(18px); border-bottom: 1px solid var(--line); }
  .topbar .select { flex: 1; max-width: 260px; padding-top: 7px; padding-bottom: 7px; }
  .topbar .dot { margin-left: auto; }
  main { padding: 16px 16px calc(96px + env(safe-area-inset-bottom)); }
  .page-head h1 { font-size: 24px; }
  .tabbar { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); background: color-mix(in srgb, var(--surface) 86%, transparent);
    backdrop-filter: saturate(180%) blur(18px); -webkit-backdrop-filter: saturate(180%) blur(18px); border-top: 1px solid var(--line); }
  .tabbar a { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 10.5px; font-weight: 550; color: var(--text-3); text-decoration: none; padding: 4px 0; }
  .tabbar a.on { color: var(--accent); }
  .tabbar svg.icon { width: 24px; height: 24px; }
  .grid { gap: 12px; }
  .card { padding: 16px; }
  .span-3 { grid-column: span 12; }
  .form-row { grid-template-columns: 1fr; gap: 6px; }
  .datenav .lbl { min-width: 0; }
}
@media (max-width: 560px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .soc { flex-direction: column; align-items: flex-start; }
  .tl-row, .tl-hours { grid-template-columns: 52px 1fr 48px; }
  .event { grid-template-columns: 1fr auto; } .event .when { grid-column: 1 / 3; } .event .adv { grid-column: 1 / 3; }
}
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--text-3); display: inline-block; flex: none; }
.dot.ok { background: var(--good); } .dot.warn { background: var(--warn); } .dot.bad { background: var(--crit); }
.muted { color: var(--text-2); } .small { font-size: 12.5px; }
.row-flex { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* ---------- data freshness ---------- */
.stats.fresh { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.stats.fresh .stat .d .badge { margin-right: 4px; }
.stats.fresh .stat .v { font-size: 22px; }
.stat.stale { box-shadow: inset 0 0 0 1.5px var(--warn); }
.fresh-row { display: flex; gap: 16px; align-items: flex-start; margin-top: 14px; flex-wrap: wrap; }
.fresh-text { flex: 1 1 380px; font-size: 13.5px; line-height: 1.5; }
.fresh-text > .badge { margin-right: 6px; vertical-align: 1px; }
.fresh-ctl { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.poll-strip { display: flex; align-items: center; gap: 3px; flex-wrap: wrap; margin-top: 12px; }
.poll-strip > .small { margin-left: 8px; }
.pd { display: inline-block; width: 9px; height: 16px; border-radius: 3px; background: var(--surface-3); vertical-align: -3px; }
.small .pd { width: 8px; height: 8px; vertical-align: 0; margin-left: 6px; }
.pd.new { background: var(--good); } .pd.rep { background: var(--line-2); } .pd.fail { background: var(--crit); } .pd.odd { background: var(--warn); }
@media (max-width: 560px) { .stats.fresh { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ---------- load breakdown ---------- */
.bl-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.bl-head .big { font-size: 26px; font-weight: 650; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.barlist { display: grid; gap: 10px; }
.bl-row { display: grid; grid-template-columns: minmax(130px, 1.1fr) 2fr auto; gap: 12px; align-items: center; }
.bl-name { font-size: 13.5px; font-weight: 550; }
.bl-name span { display: block; font-size: 11.5px; font-weight: 400; color: var(--text-3); }
.bl-bar { height: 10px; background: var(--surface-2); border-radius: 5px; overflow: hidden; }
.bl-bar i { display: block; height: 100%; border-radius: 5px; }
.bl-val { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 64px; text-align: right; }
.kv-line { display: flex; align-items: center; gap: 8px; margin-top: 10px; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); font-size: 13.5px; }
.kv-line b { margin-left: auto; font-variant-numeric: tabular-nums; }
.kv-line svg.icon { width: 16px; height: 16px; color: var(--grid); }
.flow-split { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 16px; margin-top: 8px; font-size: 13px; color: var(--text); text-decoration: none; }
.flow-split .sw { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; }
@media (max-width: 560px) { .bl-row { grid-template-columns: 1fr auto; } .bl-bar { grid-column: 1 / -1; grid-row: 2; } }

/* ---------- house energy flow ---------- */
.flow2 { width: 100%; max-width: 560px; margin: 0 auto; display: block; overflow: visible; }
.flow2 .nb { fill: var(--surface-2); stroke: var(--line); }
.flow2 .ring { fill: none; stroke-width: 2; }
.flow2 .ni { stroke-width: 1.6; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.flow2 .fv { font-size: 15px; font-weight: 650; fill: var(--text); font-variant-numeric: tabular-nums; }
.flow2 .fc { font-size: 11.5px; fill: var(--text-2); }
.flow2 .fs { font-size: 10.5px; fill: var(--text-3); }
.flow2 .fl-track { fill: none; stroke: var(--line); stroke-width: 3; stroke-linecap: round; }
.flow2 .fl-live { fill: none; stroke-width: 3; stroke-linecap: round; opacity: .28; }
.flow-story { margin: 6px 2px 12px; font-size: 14.5px; line-height: 1.5; color: var(--text); }
.flow-loads { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px; }
.fload { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); color: var(--text); text-decoration: none; }
.fload:hover { background: var(--surface-3); }
.fload b { display: block; font-size: 13.5px; font-weight: 600; }
.fload div > span { display: block; font-size: 12px; color: var(--text-3); margin-top: 2px; }
.fl-sw { width: 10px; height: 10px; border-radius: 3px; margin-top: 4px; flex: none; }
details.explain { margin-top: 12px; font-size: 13px; line-height: 1.55; }
details.explain summary { cursor: pointer; color: var(--accent); font-weight: 550; }
details.explain p { margin: 8px 0 0; color: var(--text-2); }
@media (max-width: 560px) { .flow2 .fv { font-size: 20px; } .flow2 .fc { font-size: 15px; } .flow2 .fs { display: none; } .ov-flow { order: -1; } }

/* ---------- server mode: signed out / locked ---------- */
.btn.danger { color: var(--crit); }
.btn.danger:hover { background: var(--crit-bg); }
.gate { max-width: 520px; margin: 9vh auto 0; text-align: center; padding: 0 20px; }
.gate h1 { font-size: 24px; margin: 18px 0 8px; letter-spacing: -.02em; }
.gate p { line-height: 1.5; margin: 0 auto 22px; }
.gate-icon { width: 76px; height: 76px; margin: 0 auto; border-radius: 22px; display: grid; place-items: center;
  background: linear-gradient(160deg, #ffb347, var(--solar)); color: #fff; box-shadow: 0 8px 24px rgba(244,114,48,.28); }
.gate-icon svg.icon { width: 36px; height: 36px; stroke: #fff; }
.gate-ways { display: grid; gap: 10px; text-align: left; }
.gate-way { display: flex; gap: 14px; align-items: center; background: var(--surface); border-radius: var(--radius-s); padding: 14px 16px; box-shadow: var(--shadow); }
.gate-way svg.icon { width: 26px; height: 26px; flex: none; color: var(--text-2); }
.gate-wait { display: inline-flex; gap: 10px; align-items: center; color: var(--text-2); }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line-2); border-top-color: var(--solar); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }
