:root {
  color-scheme: dark;
  --page: #0b0b0b;
  --surface-1: #191919;
  --surface-2: #222222;
  --ink: #efefef;
  --ink-2: #9c9c9c;
  --grid: #303030;
  --axis: #474747;
  --ring: rgba(255,255,255,0.10);
  /* entity colors: fixed categorical slots 1..5 (validated, dark surface) */
  --c-load: #338ced;   /* slot 1 blue   */
  --c-grid: #e76624;   /* slot 2 orange */
  --c-batt: #00a888;   /* slot 3 aqua   */
  --c-pv:   #d28e05;   /* slot 4 yellow */
  --c-gen:  #e24d8b;   /* slot 5 magenta*/
  /* status (reserved, always with icon + label) */
  --good: #0aac23;
  --warn: #fbb315;
  --serious: #f18a59;
  --crit: #dc3c3d;
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
  --warn-ink: #fbb315;                 /* warning used as TEXT */
  --header-bg: rgba(11,11,11,.94);
  --tip-bg: #0b0b0b;
  --shadow: rgba(0,0,0,.5);
  --diff-bg: rgba(251,179,21,.07);
}
/* light theme: OS preference unless the toggle forced dark, or the toggle forced light */
@media (prefers-color-scheme: light) {
  :root:where(:not([data-theme="dark"])) {
    color-scheme: light;
    --page: #f9f9f9; --surface-1: #ffffff; --surface-2: #f2f2f2; --ink: #191919; --ink-2: #666666;
    --grid: #e7e7e7; --axis: #c2c2c2; --ring: rgba(11,11,11,0.10);
    --c-load: #257de0; --c-grid: #f47230; --c-batt: #00b894; --c-pv: #f2a600; --c-gen: #ee7fac;
    --warn-ink: #8a5a00; --header-bg: rgba(249,249,249,.94); --tip-bg: #ffffff; --shadow: rgba(0,0,0,.12);
    --diff-bg: rgba(251,179,21,.14);
  }
}
:root[data-theme="light"] {
  color-scheme: light;
  --page: #f9f9f9; --surface-1: #ffffff; --surface-2: #f2f2f2; --ink: #191919; --ink-2: #666666;
  --grid: #e7e7e7; --axis: #c2c2c2; --ring: rgba(11,11,11,0.10);
  --c-load: #257de0; --c-grid: #f47230; --c-batt: #00b894; --c-pv: #f2a600; --c-gen: #ee7fac;
  --warn-ink: #8a5a00; --header-bg: rgba(249,249,249,.94); --tip-bg: #ffffff; --shadow: rgba(0,0,0,.12);
  --diff-bg: rgba(251,179,21,.14);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--page); color: var(--ink); font-family: var(--font);
  font-size: clamp(13px, 12px + 0.15vw, 16px); -webkit-text-size-adjust: 100%; }
.top { display: flex; align-items: center; gap: 16px; padding: 12px 20px; border-bottom: 1px solid var(--ring);
  position: sticky; top: 0; background: var(--header-bg); backdrop-filter: blur(6px); z-index: 5; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; }
.logo { font-size: 26px; color: var(--c-pv); }
h1 { font-size: 18px; margin: 0; font-weight: 600; }
h2 { font-size: 14px; margin: 0; font-weight: 600; }
.sub, .hint { color: var(--ink-2); font-size: 12px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; flex: 1; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px;
  background: var(--surface-1); border: 1px solid var(--ring); font-size: 12px; white-space: nowrap; }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; }
.clock { color: var(--ink-2); font-size: 12px; font-variant-numeric: tabular-nums; }
.banner { margin: 12px 20px 0; padding: 8px 12px; border-radius: 8px; background: var(--surface-1);
  border: 1px solid var(--ring); border-left: 3px solid var(--warn); color: var(--ink); font-size: 13px; }
main { padding: clamp(10px, 1.2vw, 24px) clamp(10px, 1.6vw, 32px); display: grid; gap: clamp(10px, 1vw, 20px);
  width: 100%; box-sizing: border-box; margin: 0 auto; }
.row.two { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 16px; }
.row.invs { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(460px, 100%), 1fr)); gap: clamp(10px, 1vw, 20px); }
@media (max-width: 1000px) { .row.two { grid-template-columns: 1fr; } .row.invs { grid-template-columns: 1fr; } }
.card { background: var(--surface-1); border: 1px solid var(--ring); border-radius: 12px; padding: 14px 16px; min-width: 0; }
.card-h { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.card-h .hint { margin-left: auto; }
#flow { width: 100%; height: auto; display: block; }

/* tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(170px, 100%), 1fr)); gap: clamp(8px, 0.8vw, 16px); align-content: start; }
.tile { background: var(--surface-1); border: 1px solid var(--ring); border-radius: 12px; padding: 12px 14px;
  border-top: 3px solid var(--accent, var(--axis)); min-width: 0; }
.tile .lbl { color: var(--ink-2); font-size: 12px; display: flex; justify-content: space-between; gap: 6px; }
.tile .val { font-size: 28px; font-weight: 600; margin: 4px 0 2px; line-height: 1.1; }
.tile .val small { font-size: 14px; color: var(--ink-2); font-weight: 400; margin-left: 3px; }
.tile .note { color: var(--ink-2); font-size: 12px; min-height: 16px; }
.soc-bar { height: 6px; background: var(--surface-2); border-radius: 3px; margin-top: 6px; overflow: hidden; }
.soc-bar > i { display: block; height: 100%; background: var(--c-batt); border-radius: 3px; }

/* today */
.today { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.today .t { background: var(--surface-2); border-radius: 8px; padding: 10px 12px; }
.today .t .k { color: var(--ink-2); font-size: 12px; display: flex; align-items: center; gap: 6px; }
.today .t .v { font-size: 20px; font-weight: 600; margin-top: 4px; }
.today .t .v small { font-size: 12px; color: var(--ink-2); font-weight: 400; }
.sw { width: 10px; height: 10px; border-radius: 2px; display: inline-block; flex: none; }

/* history */
.seg { display: inline-flex; background: var(--surface-2); border-radius: 8px; padding: 2px; margin-left: auto; }
.seg button, .ghost { background: transparent; color: var(--ink-2); border: 0; padding: 5px 10px; border-radius: 6px;
  font: inherit; font-size: 12px; cursor: pointer; }
.seg button.on { background: var(--surface-1); color: var(--ink); box-shadow: 0 0 0 1px var(--ring); }
.ghost { border: 1px solid var(--ring); }
.ghost:hover, .seg button:hover { color: var(--ink); }
.chart-title { font-size: 13px; font-weight: 600; margin: 8px 0 4px; }
.chart-title .hint { font-weight: 400; margin-left: 6px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--ink-2); margin-bottom: 4px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 14px; height: 2px; display: inline-block; border-radius: 1px; }
.chart { position: relative; height: clamp(200px, 30vh, 460px); }
.chart.small { height: clamp(120px, 17vh, 260px); }
.chart svg { width: 100%; height: 100%; display: block; overflow: visible; }
.chart .empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--ink-2); font-size: 13px; }
.tip { position: absolute; pointer-events: none; background: var(--tip-bg); border: 1px solid var(--ring); border-radius: 8px;
  padding: 8px 10px; font-size: 12px; min-width: 150px; z-index: 3; box-shadow: 0 6px 20px var(--shadow); }
.tip .h { color: var(--ink-2); margin-bottom: 4px; font-variant-numeric: tabular-nums; }
.tip .r { display: flex; align-items: center; gap: 6px; justify-content: space-between; }
.tip .r b { font-weight: 600; font-variant-numeric: tabular-nums; }
.table-wrap { max-height: 320px; overflow: auto; margin-top: 10px; border: 1px solid var(--ring); border-radius: 8px; }

/* tables */
table { width: 100%; border-collapse: collapse; font-size: 12.5px; font-variant-numeric: tabular-nums; }
th, td { padding: 5px 8px; text-align: right; border-bottom: 1px solid var(--grid); white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
th { color: var(--ink-2); font-weight: 500; position: sticky; top: 0; background: var(--surface-1); }

/* inverter cards */
.inv .card-h h2 { font-size: 15px; }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2);
  border: 1px solid var(--ring); text-transform: uppercase; letter-spacing: .04em; }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; margin-left: auto; }
.status .dot { width: 8px; height: 8px; border-radius: 50%; }
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; margin-bottom: 12px; }
.kv div { background: var(--surface-2); border-radius: 8px; padding: 7px 10px; }
.kv .k { color: var(--ink-2); font-size: 11px; }
.kv .v { font-size: 15px; font-weight: 600; margin-top: 2px; }
.sec { color: var(--ink-2); font-size: 12px; margin: 12px 0 4px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.alerts { display: flex; flex-direction: column; gap: 4px; }
.alert { display: flex; gap: 8px; align-items: center; font-size: 12.5px; padding: 6px 10px; border-radius: 6px; background: var(--surface-2); }
.alert.ok { color: var(--ink-2); }
.muted { color: var(--ink-2); }
.offline-msg { color: var(--ink-2); padding: 18px 4px; line-height: 1.6; }
footer { color: var(--ink-2); font-size: 12px; text-align: center; padding: 10px 0 24px; }

/* flow diagram */
.node rect { fill: var(--surface-2); stroke: var(--ring); }
.node .t { fill: var(--ink-2); font-size: 12px; }
.node .v { fill: var(--ink); font-size: 18px; font-weight: 600; }
.node .n { fill: var(--ink-2); font-size: 11px; }
.wire { fill: none; stroke: var(--grid); stroke-width: 2; }
.wire.live { stroke-width: 3; stroke-dasharray: 6 8; animation: dash 1s linear infinite; }
.wire.rev { animation-direction: reverse; }
@keyframes dash { to { stroke-dashoffset: -14; } }
@media (prefers-reduced-motion: reduce) { .wire.live { animation: none; stroke-dasharray: none; } }

/* events */
.events { display: flex; flex-direction: column; max-height: 360px; overflow: auto; }
.ev { display: grid; grid-template-columns: 18px 150px minmax(0, 1fr); gap: 10px; padding: 8px 4px; border-bottom: 1px solid var(--grid); align-items: start; }
.ev:last-child { border-bottom: 0; }
.ev .t { color: var(--ink-2); font-size: 12px; font-variant-numeric: tabular-nums; padding-top: 1px; }
.ev .ti { font-weight: 600; font-size: 13px; }
.ev .m { color: var(--ink-2); font-size: 12.5px; white-space: pre-line; margin-top: 2px; }
#notify-status { margin-left: auto; }
#notify-status + .ghost { margin-left: 0; }

/* control */
.ctl { display: grid; gap: 12px; }
.ctl-state { display: flex; gap: 10px; flex-wrap: wrap; }
.ctl-btns { display: flex; gap: 10px; flex-wrap: wrap; }
.btn { font: inherit; font-size: 13px; font-weight: 600; padding: 9px 16px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--ring); background: var(--surface-2); color: var(--ink); }
.btn.on { border-color: var(--c-gen); }
.btn.off { border-color: var(--axis); }
.btn:disabled { opacity: .5; cursor: wait; }

/* settings page */
a.ghost.link, a.ghost { text-decoration: none; display: inline-flex; align-items: center; }
.toggle { color: var(--ink-2); font-size: 12px; display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
#s-groups { display: grid; gap: 16px; }
.s-wrap { max-height: none; margin-top: 0; }
.s-table { table-layout: fixed; }
.s-table th, .s-table td { text-align: left; white-space: normal; vertical-align: top; padding: 7px 10px; }
.s-table th { position: static; }
.s-table td:first-child { color: var(--ink-2); width: 30%; }
.s-table td.flag { width: 120px; white-space: nowrap; }
.s-table tr.diff td { background: var(--diff-bg); }
.s-table tr.diff td:first-child { box-shadow: inset 3px 0 0 var(--warn); color: var(--ink); }
.s-table .raw { color: var(--ink-2); font-size: 11px; margin-top: 2px; font-family: ui-monospace, monospace; }
.warn-t { color: var(--warn-ink); }
.kv .v.sm { font-size: 13px; font-weight: 500; }
.top .ghost { padding: 6px 12px; }

/* login */
.login-body { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login { width: 100%; max-width: 360px; display: grid; gap: 14px; padding: 22px; }
.login label { display: grid; gap: 6px; color: var(--ink-2); font-size: 12px; }
.login input { font: inherit; font-size: 14px; color: var(--ink); background: var(--surface-2); border: 1px solid var(--ring);
  border-radius: 8px; padding: 9px 10px; }
.login input:focus { outline: 2px solid var(--c-load); outline-offset: 1px; }
.login .banner { margin: 0; }
.login .btn { width: 100%; }

/* theme toggle */
.theme-btn { white-space: nowrap; }
.login-body .theme-btn { position: fixed; top: 14px; right: 14px; }

.ctl-sep { border-top: 1px solid var(--grid); }
.ctl-row { display: grid; gap: 8px; }
.ctl-row input[type=number] { font: inherit; font-size: 14px; width: 90px; color: var(--ink); background: var(--surface-2);
  border: 1px solid var(--ring); border-radius: 8px; padding: 8px 10px; }
.ctl-btns { align-items: center; }

/* in-page confirmation */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: grid; place-items: center; z-index: 50; padding: 20px; }
.modal[hidden] { display: none; }
.modal-box { max-width: 460px; width: 100%; display: grid; gap: 16px; box-shadow: 0 12px 40px var(--shadow); }
#cm-text { white-space: pre-line; line-height: 1.5; }

/* settings editor */
.ghost.sm { padding: 3px 8px; font-size: 11.5px; margin-left: 6px; }
.s-table td.flag { width: auto; min-width: 120px; white-space: normal; text-align: right; }
.s-table tr.editor td { background: var(--surface-2); }
.ed { display: grid; gap: 8px; padding: 4px 0; }
.ed-ctl { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.ed input[type=number], .ed select { font: inherit; font-size: 14px; color: var(--ink); background: var(--surface-1);
  border: 1px solid var(--ring); border-radius: 8px; padding: 7px 10px; width: 120px; }
.ed select { width: auto; }
.seen { color: var(--warn-ink); font-size: 11.5px; }
.lock { font-size: 11.5px; cursor: help; }

.modal-box.wide { max-width: 640px; }
.ul-list { display: grid; gap: 2px; max-height: 50vh; overflow: auto; border: 1px solid var(--ring); border-radius: 8px; padding: 4px; }
.ul-item { display: grid; grid-template-columns: 22px 110px 1fr auto; gap: 8px; align-items: center; padding: 7px 8px;
  border-radius: 6px; cursor: pointer; }
.ul-item:hover { background: var(--surface-2); }
.ul-item input:disabled + span { opacity: .5; }

/* ---------- responsive ---------- */
.tscroll { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
.tscroll table { min-width: 100%; }
img, svg { max-width: 100%; }
.row.two > .tiles { grid-auto-rows: 1fr; align-content: stretch; }   /* tiles fill the height beside the diagram */
.row.two > .tiles .tile { display: flex; flex-direction: column; justify-content: center; }
#flow { max-height: min(56vh, 560px); margin: 0 auto; }
@media (min-width: 1800px) {            /* big monitors: use the width */
  .row.two { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .tile .val { font-size: 38px; }
  .tile .lbl, .tile .note { font-size: 14px; }
}
@media (max-width: 1000px) {
  .row.two { grid-template-columns: 1fr; }
  .pactions .chips { flex-basis: auto; }
  .clock { margin-left: auto; }
}
@media (min-width: 561px) and (max-width: 1000px) {
  .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 700px) {             /* phones */
  .top { position: static; padding: 10px 12px; gap: 8px; }
  .top .sub { display: none; }
  .chips { order: 3; flex-basis: 100%; }
  .clock { margin-left: auto; }
  .top .ghost, .top .toggle { padding: 5px 9px; font-size: 12px; }
  .banner { margin: 8px 10px 0; }
  .card { padding: 12px; border-radius: 10px; }
  .card-h { gap: 8px; }
  .card-h .hint { margin-left: 0; flex-basis: 100%; }
  .tile { padding: 10px 12px; }
  .tile .val { font-size: 24px; }
  .today { grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); }
  .today .t .v { font-size: 17px; }
  .kv { grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); }
  .ev { grid-template-columns: 18px minmax(0, 1fr); }
  .ev .t { grid-column: 2; padding-top: 0; }
  .ev > div:last-child { grid-column: 2; }
  .seg { margin-left: 0; }
  .ctl-btns .btn { flex: 1 1 140px; }
  footer { padding: 10px 12px 20px; }
  /* settings tables become stacked rows: label, then master / slave */
  .s-table { table-layout: auto; }
  .s-table thead, .s-table th { display: none; }
  .s-table tr:has(> th) { display: none; }
  .s-table, .s-table tbody { display: block; }
  .s-table tr { display: grid; grid-template-columns: 1fr 1fr; border-bottom: 1px solid var(--grid); padding: 6px 0; }
  .s-table td { border: 0; padding: 3px 8px; width: auto !important; }
  .s-table td:first-child { grid-column: 1 / -1; font-weight: 600; color: var(--ink); }
  .s-table td[data-label]::before { content: attr(data-label); display: block; font-size: 11px; color: var(--ink-2); }
  .s-table td.flag { grid-column: 1 / -1; text-align: left; min-width: 0; }
  .s-table td.flag:empty { display: none; }
  .s-table tr.editor { display: block; }
  .s-table tr.editor td { display: block; }
  .s-table tr.diff td:first-child { box-shadow: none; }
  .s-table tr.diff { box-shadow: inset 3px 0 0 var(--warn); }
  .ed input[type=number] { width: 100px; }
  .ul-item { grid-template-columns: 22px minmax(0, 1fr) auto; }
  .ul-item > span.muted { display: none; }
  .modal-box { padding: 16px; }
}
@media (max-width: 560px) {             /* small phones: the tiles carry the same numbers, larger */
  .flow-card { display: none; }
}

/* ---------- alert settings page ---------- */
/* masonry: alerts.js puts every card in the currently shortest column -> no empty holes */
.agrid { display: flex; align-items: flex-start; gap: clamp(10px, 1vw, 20px); }
.acol { flex: 1 1 0; min-width: 0; display: grid; gap: clamp(10px, 1vw, 20px); }
.frow { display: grid; grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr); gap: 12px; padding: 10px 0; border-top: 1px solid var(--grid); }
.frow.changed { background: var(--diff-bg); box-shadow: inset 3px 0 0 var(--c-load); padding-left: 8px; margin-left: -8px; }
.flabel { font-size: 13px; }
.fsrc { margin-top: 3px; font-size: 11px; color: var(--ink-2); }
.src.panel { color: var(--c-load); font-weight: 600; }
.reset { color: var(--ink-2); }
.finput { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-width: 0; }
.finput > .hint, .finput > .ferr { flex-basis: 100%; }
.finput input[type=number] { width: 90px; }
.finput input[type=text], .finput input[type=time], .finput input[type=number], .finput textarea, .prow input {
  font: inherit; font-size: 14px; color: var(--ink); background: var(--surface-2); border: 1px solid var(--ring);
  border-radius: 8px; padding: 7px 9px; min-width: 0; box-sizing: border-box; }
.finput input[type=text] { flex: 1 1 180px; }
.finput textarea { width: 100%; resize: vertical; }
.finput input:disabled, .finput textarea:disabled { opacity: .7; }
.ferr { color: var(--crit); font-size: 12px; }
.ferr:empty { display: none; }
.plist { display: grid; gap: 6px; flex-basis: 100%; }
.prow { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr) auto; gap: 6px; align-items: center; }
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.switch input { width: 18px; height: 18px; }
.mppt { display: inline-flex; align-items: center; gap: 6px; }
.mppt input[type=text] { flex: 0 0 90px !important; width: 90px; }
.difflist { margin: 0 0 12px; padding-left: 18px; display: grid; gap: 8px; max-height: 50vh; overflow: auto; }
table.ro td, table.ro th { text-align: left; }
.top .btn { padding: 7px 14px; }
@media (max-width: 700px) {
  .frow { grid-template-columns: 1fr; gap: 6px; }
  .agrid { grid-template-columns: 1fr; }
}
.warnline { color: var(--warn); font-weight: 600; }

/* ---------- v1.17 shared header: page tabs + page bar ---------- */
.top { flex-wrap: nowrap; gap: clamp(10px, 2vw, 28px); padding: 0 clamp(12px, 1.6vw, 32px); min-height: 56px; }
.brand { text-decoration: none; color: var(--ink); flex: none; }
.brand-name { font-weight: 600; font-size: 16px; }
.top .logo { font-size: 24px; }
.tabs { display: flex; align-self: stretch; gap: 4px; min-width: 0; }
.tabs a { display: inline-flex; align-items: center; padding: 0 14px; color: var(--ink-2); text-decoration: none;
  font-size: 13.5px; font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--ink); }
.tabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--c-pv); font-weight: 600; }
.tabs .sh, .pactions .sh { display: none; }
.top-end { margin-left: auto; display: flex; align-items: center; gap: 8px; flex: none; }
.pagebar { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 16px;
  padding: clamp(12px, 1.2vw, 20px) clamp(10px, 1.6vw, 32px) 0; }
.pagebar h1 { font-size: 20px; }
.ptitle { min-width: 0; }
.pactions { margin-left: auto; display: flex; align-items: center; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.pactions .chips { flex: 0 1 auto; justify-content: flex-end; }
.pactions .ghost { padding: 6px 12px; }
.pagebar.sticky { position: sticky; top: 56px; z-index: 4; background: var(--page);
  padding-bottom: 10px; border-bottom: 1px solid var(--ring); }
.jump { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px clamp(10px, 1.6vw, 32px) 0; }
.jump:empty { display: none; }
.jump a { font-size: 12px; color: var(--ink-2); text-decoration: none; padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--ring); background: var(--surface-1); white-space: nowrap; }
.jump a:hover { color: var(--ink); border-color: var(--ink-2); }
.sgroup, .acard { scroll-margin-top: 70px; }
.pagebar.sticky ~ main .acard { scroll-margin-top: 140px; }
/* compact inverter status (settings page) */
.inv-status { display: grid; gap: 0; padding-top: 6px; padding-bottom: 6px; }
.inv-row { display: flex; flex-wrap: wrap; gap: 4px 28px; align-items: center; padding: 8px 0; font-size: 13px; }
.inv-row > div { white-space: nowrap; }
.inv-name { min-width: 200px; }
.inv-row + .inv-row { border-top: 1px solid var(--grid); }
.inv-row .k { color: var(--ink-2); font-size: 11.5px; margin-right: 6px; }
.inv-name { display: flex; align-items: center; gap: 8px; }
.inv-name .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.inv-err { flex-basis: 100%; white-space: normal !important; }
/* wide screens: settings sections in two balanced columns */
@media (min-width: 1300px) {
  #s-groups { display: block; columns: 2; column-gap: clamp(10px, 1vw, 20px); }
  #s-groups > .card { break-inside: avoid; margin-bottom: clamp(10px, 1vw, 20px); display: block; }
}
@media (max-width: 900px) {
  .tabs a { padding: 0 9px; }
  .brand-name { display: none; }
}
@media (max-width: 700px) {
  .top { position: sticky; padding: 0 8px; gap: 6px; min-height: 48px; }
  .tabs { flex: 1; gap: 0; }
  .tabs a { flex: 1; justify-content: center; padding: 0 4px; font-size: 13px; }
  .tabs .lg, .theme-btn .lg { display: none; }
  .tabs .sh { display: inline; }
  .top-end { gap: 4px; }
  .top .ghost { padding: 5px 8px; font-size: 12px; }
  .pagebar { padding: 12px 10px 0; }
  .pagebar h1 { font-size: 18px; }
  .pagebar .sub { display: none; }
  .pagebar.sticky { top: 48px; }
  .pactions { margin-left: 0; justify-content: flex-start; flex-basis: 100%; }
  .pactions .chips { justify-content: flex-start; }
  .jump { padding: 8px 10px 0; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .jump::-webkit-scrollbar { display: none; }
  .inv-row { flex-direction: column; align-items: flex-start; gap: 2px; }
  .pactions .lg { display: none; }
  .pactions .sh { display: inline; }
  .pactions .chips { order: 0; flex-basis: auto; }
  .pactions .clock { margin-left: 0; }
  .pagebar.sticky { flex-wrap: nowrap; padding-bottom: 8px; }
  .pagebar.sticky .pactions { flex-basis: auto; margin-left: auto; }
  .sgroup, .acard { scroll-margin-top: 60px; }
}

/* ---------- installed app (PWA): keep content clear of the notch / home indicator ---------- */
.top { padding-top: env(safe-area-inset-top); padding-left: max(clamp(12px, 1.6vw, 32px), env(safe-area-inset-left));
  padding-right: max(clamp(12px, 1.6vw, 32px), env(safe-area-inset-right)); min-height: calc(56px + env(safe-area-inset-top)); }
.pagebar.sticky { top: calc(56px + env(safe-area-inset-top)); }
footer { padding-bottom: max(24px, env(safe-area-inset-bottom)); }
@media (max-width: 700px) {
  .top { padding-left: max(8px, env(safe-area-inset-left)); padding-right: max(8px, env(safe-area-inset-right));
    min-height: calc(48px + env(safe-area-inset-top)); }
  .pagebar.sticky { top: calc(48px + env(safe-area-inset-top)); }
}
@media (display-mode: standalone) {
  body { -webkit-tap-highlight-color: transparent; overscroll-behavior-y: contain; }
}
.save-msg { font-size: 12.5px; color: var(--ink-2); }
.save-msg.ok { color: var(--good); font-weight: 600; }
.save-msg.err { color: var(--crit); font-weight: 600; }
@media (max-width: 700px) { .save-msg { font-size: 11.5px; max-width: 55vw; } }
