/* Nona Seattle. Dark first; the light theme is derived from it. The sidebar is the logo's navy in both. */
:root {
  color-scheme: dark;
  --navy: #0c1528; --navy-2: #142238; --navy-ink: #e6ebf3; --navy-muted: #8294ad;
  --bg: #121d31; --surface: #192844; --surface-2: #203352; --solid: #192844; --hero: #152339;
  --ink: #eef2f8; --ink-2: #bcc6d6; --muted: #8191a8;
  --grid: rgba(255, 255, 255, 0.07); --axis: rgba(255, 255, 255, 0.18); --border: rgba(255, 255, 255, 0.09);
  --series: #6ea8fe; --series-fill: rgba(110, 168, 254, 0.14);
  --good: #3ccf8e; --warning: #e8b53a; --critical: #ef5f5f;
  --btn: rgba(255, 255, 255, 0.06); --btn-hover: rgba(255, 255, 255, 0.11);
  --accent: #6ea8fe; --accent-ink: #0a0e16;
  --c1: #6ea8fe; --c2: #f28b6b; --c3: #52c49a; --c4: #e3b341; --c5: #b49cf5; --c6: #ec86b8; --c7: #4fc3d8; --c8: #a9b85c;
  --shadow: none;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --bg: #f5f3ee; --surface: #fffefb; --surface-2: #f6f4ef; --solid: #fffefb; --hero: #fbfaf7;
    --ink: #15192a; --ink-2: #4b5160; --muted: #7d828f;
    --grid: #ebe8e1; --axis: #cfcac0; --border: #e6e2d9;
    --series: #2563eb; --series-fill: rgba(37, 99, 235, 0.12);
    --good: #12925c; --warning: #d9930d; --critical: #d13b3b;
    --btn: #ece9e2; --btn-hover: #e1ddd4;
    --accent: #2563eb; --accent-ink: #ffffff;
    --c1: #2563eb; --c2: #e4572e; --c3: #16a075; --c4: #d9930d; --c5: #7c5cd6; --c6: #cf4a8c; --c7: #0f9db3; --c8: #7a8a3a;
  }
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f5f3ee; --surface: #fffefb; --surface-2: #f6f4ef; --solid: #fffefb; --hero: #fbfaf7;
  --ink: #15192a; --ink-2: #4b5160; --muted: #7d828f;
  --grid: #ebe8e1; --axis: #cfcac0; --border: #e6e2d9;
  --series: #2563eb; --series-fill: rgba(37, 99, 235, 0.12);
  --good: #12925c; --warning: #d9930d; --critical: #d13b3b;
  --btn: #ece9e2; --btn-hover: #e1ddd4;
  --accent: #2563eb; --accent-ink: #ffffff;
  --c1: #2563eb; --c2: #e4572e; --c3: #16a075; --c4: #d9930d; --c5: #7c5cd6; --c6: #cf4a8c; --c7: #0f9db3; --c8: #7a8a3a;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0; min-height: 100vh; color: var(--ink); background: var(--bg);
  font: 14px/1.5 "Inter Tight", "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
  display: grid; grid-template-columns: 216px minmax(0, 1fr);
  font-variant-numeric: tabular-nums; -webkit-font-smoothing: antialiased;
}
main { padding: 24px 32px 48px; min-width: 0; }
/* big readings: light weight, tight tracking; labels: small, spaced capitals */
.kpi .v, .card .value, .strip .big, .strip .kv b, .chart .title .now b, .stat .v, .mrow .v { font-weight: 400; letter-spacing: -0.02em; }

/* sidebar: navy in both themes, the brand's own colour */
.side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 24px; padding: 24px 16px 20px;
  background: var(--navy); color: var(--navy-ink); overflow: hidden; border-right: 1px solid var(--border); }
.side > * { position: relative; }
.side > .side-art { position: absolute; left: 0; right: 0; bottom: 0; height: 52%; pointer-events: none; opacity: 0.55; }  /* behind the foot */
.side-art path { fill: none; stroke: #fff; stroke-opacity: 0.09; stroke-width: 1.2; }
.side-toggle { position: absolute; top: 18px; right: 12px; min-height: 0; width: 36px; height: 36px; padding: 0; border-radius: 10px;
  background: transparent; color: var(--navy-muted); display: flex; align-items: center; justify-content: center; }
.side-toggle .ico { width: 20px; height: 20px; }
.side-toggle:hover { background: rgba(255, 255, 255, 0.14); color: #fff; }
.side-foot .ico { width: 16px; height: 16px; display: block; }
/* collapsed: a 60 px rail with initials; the charts get the width */
body.collapsed { grid-template-columns: 60px minmax(0, 1fr); }
body.collapsed .side { padding: 18px 10px; gap: 18px; align-items: stretch; }
body.collapsed .side-brand, body.collapsed .side-links a span, body.collapsed .side-status, body.collapsed .side-foot, body.collapsed .side-art { display: none; }
body.collapsed .side-toggle { position: static; width: 40px; height: 38px; margin: 0 auto; background: rgba(255, 255, 255, 0.08); color: var(--navy-ink); }
body.collapsed .side-toggle:hover { background: rgba(255, 255, 255, 0.18); }
body.collapsed .side-links a { justify-content: center; padding: 11px 0; }
body.collapsed .side-links .ico { width: 22px; height: 22px; }
.side-brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; padding: 2px 40px 2px 4px; }
.side-brand img { width: 56px; height: 25px; object-fit: cover; border-radius: 6px; }
.side-brand span { font-weight: 600; letter-spacing: 0.01em; white-space: nowrap; }
.side-links { display: flex; flex-direction: column; gap: 2px; }
.side-links a { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 10px; color: var(--navy-ink); text-decoration: none; line-height: 1.25; }
.side-links a span { display: flex; flex-direction: column; }
.side-links .ico { width: 20px; height: 20px; flex: none; color: var(--navy-muted); }
.side-links a.on .ico, .side-links a:hover .ico { color: #fff; }
.side-links a b { font-weight: 600; font-size: 14.5px; }
.side-links a small { color: var(--navy-muted); font-size: 11px; }
.side-links a:hover { background: rgba(255, 255, 255, 0.07); }
.side-links a.on { background: rgba(255, 255, 255, 0.12); }
.side-links a.on b { color: #fff; }
.side-status { margin-top: auto; font-size: 12px; color: var(--navy-muted); display: flex; flex-direction: column; gap: 6px; padding: 0 6px; }
.side-status b { color: var(--navy-ink); font-weight: 600; }
.side-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 6px; }
.side-foot .why { color: var(--navy-muted); }
.side .seg { background: rgba(255, 255, 255, 0.08); flex-wrap: nowrap; }
.side .seg button { color: var(--navy-ink); min-height: 26px; padding: 2px 9px; font-size: 12px; display: flex; align-items: center; }
.side .seg button.on, .side .seg button.on:hover { background: #fff; color: var(--navy); }

/* page head: title left, this page's actions right */
header { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; margin-bottom: 16px; min-height: 44px; }
.brand { display: flex; align-items: center; gap: 14px; margin-right: auto; }
.brand img { display: none; }
.brand h1 { font-size: 28px; font-weight: 500; margin: 0; letter-spacing: -0.035em; line-height: 1.1; }
.brand .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.brand .sub .pill { padding: 0; border: 0; background: none; font-size: 12px; color: var(--muted); gap: 5px; }
header .spacer { flex: 1; }
header .actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
a.button.quiet, button.quiet { background: transparent; border-color: transparent; color: var(--ink-2); }
a.button.quiet:hover, button.quiet:hover:not(:disabled) { background: var(--btn); color: var(--ink); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { display: inline-flex; align-items: center; gap: 7px; padding: 4px 11px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); font-size: 12.5px; color: var(--ink-2); }
.pill.link { cursor: pointer; }
.pill.link:hover { background: var(--btn-hover); color: var(--ink); }
.pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.pill.good::before { background: var(--good); box-shadow: 0 0 0 3px rgba(12, 163, 12, 0.18); }
.pill.warn::before { background: var(--warning); box-shadow: 0 0 0 3px rgba(250, 178, 25, 0.18); }
.pill.bad::before { background: var(--critical); box-shadow: 0 0 0 3px rgba(208, 59, 59, 0.2); }

/* panels */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 20px 24px 24px; margin-bottom: 16px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.panel-head > .why { max-width: 60%; text-align: right; }
h2 { font-size: 15px; font-weight: 500; margin: 0; color: var(--ink); letter-spacing: -0.01em; text-transform: none; }
h3 { font-size: 12px; font-weight: 600; margin: 14px 0 8px; color: var(--muted); }
h3:first-child { margin-top: 0; }

#tripbar { position: sticky; top: 0; z-index: 5; }  /* the trip bar and its Reset stay in view while scrolling */
.overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.55); backdrop-filter: blur(3px); z-index: 20; display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow: auto; }
.modal { background: var(--solid); color: var(--ink); border: 1px solid var(--border); border-radius: 12px; padding: 18px 20px; width: min(1180px, 100%); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35); }
.fgrid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px 22px; }
.frow { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 3px 0; font-size: 13px; }
.frow span { color: var(--ink-2); }
.frow small { color: var(--muted); }
.frow input, .frow select { width: 130px; }
.frow output.calc { width: 130px; text-align: right; color: var(--ink-2); font-variant-numeric: tabular-nums; padding-right: 10px; }
.frow .checks { display: flex; flex-direction: column; gap: 2px; font-size: 12px; }
.frow .checks input { width: auto; margin-right: 6px; }
.frow:has(.checks) { align-items: flex-start; }
.frow.wide { flex-direction: column; align-items: stretch; gap: 6px; margin: 8px 0; }  /* the Notify section: full width, readable */
.frow.wide input[type=text] { width: 100%; font-size: 14px; }
.frow .folder { display: flex; flex-wrap: wrap; gap: 6px; }
.frow .folder select { flex: 1 1 100%; width: 100%; min-width: 0; font-size: 14px; text-overflow: ellipsis; }  /* long folder names stay in the column */
.frow .folder .path { flex-basis: 100%; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.frow.wide .checks { font-size: 14px; gap: 8px; padding-left: 2px; }
.frow.wide .checks input { width: 17px; height: 17px; margin-right: 8px; vertical-align: -3px; }
.frow select { padding: 6px 4px; }
.details { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px 22px; }
.drow { display: flex; justify-content: space-between; gap: 8px; padding: 3px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.drow span { color: var(--ink-2); }
.drow small { color: var(--muted); }
.drow b { font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.drow input, .drow select { width: 130px; }
.drow .checks { display: flex; flex-direction: column; gap: 2px; font-size: 12px; }
.drow .checks input { width: auto; margin-right: 6px; }
.steady { font-size: 14px; color: var(--ink-2); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.steady b { color: var(--ink); font-variant-numeric: tabular-nums; }
table.readings tr.on td { background: color-mix(in srgb, var(--good) 12%, transparent); }
.strip { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; padding: 10px 16px; margin-bottom: 12px;
  background: var(--surface); border: 0; border-left: 4px solid var(--accent); border-radius: 12px; }
.strip .big { font-size: 20px; display: flex; align-items: baseline; gap: 10px; }
.strip .kv { display: flex; flex-direction: column; font-size: 12px; color: var(--muted); }
.strip .kv b { font-size: 18px; color: var(--ink); font-variant-numeric: tabular-nums; }
.schem .temps { box-sizing: border-box; margin: 0; padding: 14px; border: 1px solid var(--border); border-radius: 10px;
  display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto 1fr; gap: 12px 14px; font-size: 11px; color: var(--muted); }
.schem .temps .th { grid-column: 1 / -1; display: flex; justify-content: space-between; gap: 8px; letter-spacing: 0.06em; text-transform: uppercase; }
.schem .temps #tempsmsg { text-transform: none; letter-spacing: 0; color: var(--ink-2); }
.schem .temps .tg { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
.schem .temps label { display: flex; flex-direction: column; gap: 4px; }
.schem .temps input { width: 100%; box-sizing: border-box; padding: 4px 8px; font-size: 12px; min-height: 0; }
.schem .temps button { align-self: end; padding: 4px 12px; font-size: 12px; }
.card.supply.module { grid-column: span 2; display: flex; gap: 18px; }  /* module supply: controls left, programme right */
.card.supply.module .supply-main { flex: 1; min-width: 0; }
.card.supply:not(.module), .card.supply .supply-main { display: flex; flex-direction: column; }
.card.supply .supply-main { flex: 1; }
.card.supply .why[id^="w_"] { margin-top: auto; padding-top: 10px; }  /* refusals and notes sit at the foot of the card */
.program { flex: 1.3; min-width: 0; padding-left: 18px; border-left: 1px solid var(--border); }
.program .lab { margin-bottom: 8px; }
.program .pgrid { display: grid; grid-template-columns: max-content 1fr; gap: 8px 12px; align-items: center; font-size: 13px; color: var(--ink-2); }
.program .runset { margin: 0 0 12px; padding-bottom: 12px; border-bottom: 1px dashed var(--border); }
.program .runset .row { flex-wrap: nowrap; }
.program .runset select, .program .runset input { min-width: 0; flex: 1; max-width: 220px; }
.program .runset button[id^=rpdel] { min-width: 84px; }  /* fits Confirm, so the button does not move between the two clicks */
.program .pgrid + .pgrid { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--border); }
.program .pgrid .row { margin-top: 0; }
.program input[type=number] { width: 64px; }
.program input[type=checkbox] { width: 16px; height: 16px; }
.program label { color: var(--ink-2); }
.band { fill: var(--good); opacity: 0.1; }
.marker { stroke: var(--muted); stroke-dasharray: 3 3; opacity: 0.8; }  /* grey: no series uses it */
.marker.near { stroke: var(--ink); stroke-width: 2; stroke-dasharray: none; opacity: 1; }
.tip .ev { flex-basis: 100%; color: var(--ink); }
.tip .ev time { color: var(--muted); margin-right: 8px; font-variant-numeric: tabular-nums; }  /* time apart from the text */
.marker.many { stroke-dasharray: none; }
text.count { font-size: 10px; font-weight: 600; fill: var(--ink); paint-order: stroke; stroke: var(--surface); stroke-width: 3px; }
.banner { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 16px; margin-bottom: 12px;
  border-radius: 10px; background: var(--solid); border: 1px solid var(--border); border-left: 4px solid var(--critical); }
.banner.warn { border-left-color: var(--warning); }
.banner b { letter-spacing: 0.04em; }

/* tiles */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(200px, 100%), 1fr)); gap: 10px; }
.card { background: var(--surface-2); border: 1px solid transparent; border-radius: 10px; padding: 16px; position: relative; }
.card .tag { font-weight: 600; font-size: 13px; display: flex; align-items: center; gap: 8px; }
.card .kind { font-weight: 500; font-size: 11px; color: var(--muted); padding: 1px 7px; border-radius: 999px; border: 1px solid var(--border); }
.card .kind.unknown { border-style: dashed; }
.card .desc { color: var(--muted); font-size: 12px; margin-top: 1px; }
.card .value { font-size: 28px; margin-top: 6px; }
.card .value small { font-size: 13px; font-weight: 400; color: var(--ink-2); margin-left: 3px; }
.card .fault { color: var(--critical); font-size: 12px; }
.card.faulted { border-color: rgba(208, 59, 59, 0.5); }
.mrow { display: flex; justify-content: space-between; align-items: baseline; margin-top: 4px; }
.mrow .k { color: var(--muted); font-size: 12px; }
.mrow .v { font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
.mrow .v small { font-size: 12px; font-weight: 400; color: var(--ink-2); }
.nw { color: var(--muted); font-size: 12px; font-weight: 400; }
.bad { color: var(--critical); font-size: 13px; }
.panel-head .seg + .seg { margin-left: 8px; }
.spark { display: block; width: 100%; height: 34px; margin-top: 6px; }

/* controls */
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 4px; }
.seg { display: inline-flex; background: var(--btn); border-radius: 999px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; min-height: 30px; padding: 3px 13px; border-radius: 999px; }

button { font: inherit; padding: 6px 14px; border-radius: 999px; border: 1px solid transparent;
  background: var(--btn); color: var(--ink); cursor: pointer; min-height: 34px; font-weight: 500; }
a.button { display: inline-flex; align-items: center; font: inherit; padding: 6px 14px; border-radius: 999px; min-height: 34px;
  border: 1px solid var(--border); background: var(--btn); color: var(--ink); text-decoration: none; }
button:hover:not(:disabled), a.button:hover { background: var(--btn-hover); }
button:disabled { opacity: 0.35; cursor: not-allowed; }
.seg button.on, .seg button.on:hover:not(:disabled) { background: var(--accent); color: var(--accent-ink); cursor: default; }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button.primary, button.primary:hover:not(:disabled) { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
button.primary:hover:not(:disabled) { filter: brightness(1.1); }
button.stop { background: var(--critical); color: #fff; border-color: transparent; font-weight: 600; }
button.stop:hover:not(:disabled) { background: #b83232; }
button.stop.armed { outline: 3px solid var(--warning); outline-offset: 2px; }
input, select { font: inherit; padding: 6px 11px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg); color: var(--ink); }
input[type=search] { border-radius: 999px; padding-left: 14px; min-width: 240px; }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
select option { background: var(--solid); color: var(--ink); }  /* the list must not inherit a translucent surface */
input[type=number] { width: 84px; }
.toggle { display: flex; align-items: center; gap: 10px; justify-self: end; }
.toggle span { font-size: 13px; color: var(--muted); min-width: 64px; text-align: right; }
.toggle span.lit { color: var(--ink); font-weight: 600; }
.switch { position: relative; width: 46px; min-height: 0; height: 26px; padding: 0; border-radius: 999px; border: 0;
  background: var(--btn-hover); }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3); transition: transform 0.15s; }
.switch.on, .switch.on:hover:not(:disabled) { background: var(--accent); }
.switch.on::after { transform: translateX(20px); }
.switch:disabled { opacity: 0.6; }
.unit { color: var(--muted); font-size: 12px; }
.why { color: var(--muted); font-size: 12px; }
.power .why, .tvrow .why, .swtile .why { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
#msg { min-height: 20px; color: var(--ink-2); font-size: 13px; margin: -6px 0 10px; }

/* layout: power row, one panel per circuit, trends */
.power { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(270px, 100%), 1fr)); gap: 10px; }
.circuits { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(560px, 100%), 1fr)); gap: 16px; align-items: start; }
.circuits > * { min-width: 0; }
.meters { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(150px, 100%), 1fr)); gap: 8px; margin-bottom: 4px; }
.meters .card { padding: 10px 12px; }
.name { font-weight: 600; }
.desc { color: var(--muted); font-size: 12px; }
.state { font-variant-numeric: tabular-nums; color: var(--ink-2); font-size: 13px; }
.supply .supply-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.supply .state { margin-top: 6px; }
.steps { display: inline-flex; gap: 6px; }
.tvrow .steps { margin-left: 8px; }
.steps button { min-height: 30px; padding: 3px 10px; font-variant-numeric: tabular-nums; }
.tvrow { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(90px, auto); gap: 4px 12px; align-items: center;
  padding: 8px 0; border-top: 1px solid var(--border); }
.tvrow .row { margin-top: 0; }
.tvrow .state { text-align: right; }
.tvrow .why { grid-column: 1 / -1; }
.tvrow .why:empty { display: none; }
.switches { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(220px, 100%), 1fr)); gap: 8px; }
.swtile { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; align-items: center;
  padding: 8px 10px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); }
.swtile .why { grid-column: 1 / -1; }
.swtile .why:empty, .supply .why:empty { display: none; }
.toggle span { min-width: 0; }

/* monitor: toolbar, headline numbers, range totals */
.toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 28px; padding: 12px 18px; }
.toolbar .spacer { flex: 1; }
.lab { font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 0; margin: 4px 0 18px; background: var(--surface); border-radius: 14px; padding: 6px 4px; }
.kpi { padding: 12px 20px; border-left: 1px solid var(--border); }
.kpi:first-child { border-left: 0; }
.kpi .n, .stat .n { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }
.kpi .v { font-size: 32px; margin-top: 2px; line-height: 1.1; }
.kpi .now { font-size: 12px; color: var(--muted); margin-top: 2px; font-variant-numeric: tabular-nums; }
#passnote { margin: 0 0 6px; }
.timebar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 10px 14px; }
.timebar .spacer { flex: 1; }
.timebar .live { display: inline-flex; align-items: center; gap: 7px; min-width: 96px; justify-content: center; background: var(--accent); color: var(--accent-ink); }
.timebar .live:hover:not(:disabled) { background: var(--accent); color: var(--accent-ink); filter: brightness(1.1); }  /* Latest stays blue */
.timebar .live.good, .timebar .live.warn { background: var(--btn); color: var(--ink); }
.timebar .live.good:hover:not(:disabled), .timebar .live.warn:hover:not(:disabled) { background: var(--btn-hover); color: var(--ink); filter: none; }
.timebar .live.good::before, .timebar .live.warn::before { content: ""; width: 8px; height: 8px; border-radius: 50%; }
.timebar .live.good::before { background: var(--good); box-shadow: 0 0 0 3px rgba(12, 163, 12, 0.18); }
.timebar .live.warn::before { background: var(--warning); box-shadow: 0 0 0 3px rgba(250, 178, 25, 0.18); }
.timebar .arrow { min-width: 38px; padding: 6px 10px; }
.timebar .when { font-size: 15px; font-weight: 600; background: transparent; }
.timebar .picker { flex-basis: 100%; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.kpi .u, .stat .u { font-size: 13px; font-weight: 400; color: var(--ink-2); margin-left: 4px; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(160px, 100%), 1fr)); gap: 10px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 0; border-radius: 12px; padding: 12px 16px; }
.stat .v { font-size: 22px; margin-top: 2px; font-variant-numeric: tabular-nums; }
.chartgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(440px, 100%), 1fr)); gap: 12px; }
.chartgrid > * { min-width: 0; }

/* monitor: reading tables */
.subpanel { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; min-width: 0; }
.subpanel h3:first-child { margin-top: 0; }
#readings > .circuits { margin-top: 14px; }
table.readings { width: 100%; border-collapse: collapse; font-size: 13px; margin-bottom: 10px; }
table.readings th { text-align: left; font-size: 10.5px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--muted); padding: 6px 8px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); }
table.readings td { padding: 5px 8px; border-bottom: 1px solid var(--border); font-variant-numeric: tabular-nums; white-space: nowrap; }
table.readings td.desc { white-space: normal; }
table.readings tr:last-child td { border-bottom: 0; }
table.readings tr.pick { cursor: pointer; }
table.readings tr.pick:hover td { background: var(--btn); }
table.readings tr.pick.on td { background: var(--accent); color: var(--accent-ink); }
table.readings small { color: var(--ink-2); }
.on { color: var(--accent); font-weight: 600; }
input[type=datetime-local] { width: auto; }

/* the schematic is the hero: an inset dark field, thin lines, flow drawn as moving dashes, the valves lit when open */
.panel.hero { padding: 16px 20px 20px; }
.schem { background: var(--hero); border-radius: 10px; padding: 18px 20px 12px; border: 1px solid var(--border); }
.schem svg { display: block; width: 100%; height: auto; font-family: inherit; }
.schem .pipe { fill: none; stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; }
.schem .route { opacity: 0.16; transition: opacity 0.25s; }
.schem .route.open { opacity: 1; }
/* flow: the pipe dims a little and dashes in its own colour drift along it, slowly; no glow anywhere */
.schem .route .dash { fill: none; stroke-opacity: 0; stroke-width: 2.2; stroke-dasharray: 14 18; stroke-linecap: round; }
.schem .route.open.flow .pipe { opacity: 0.45; }
.schem .route.open.flow .dash { stroke-opacity: 1; animation: flow 2.6s linear infinite; }
.schem .route.open.flow.back .dash { animation-direction: reverse; }
@keyframes flow { to { stroke-dashoffset: -32; } }
.schem .arrow { opacity: 0.9; }
.schem .stem { stroke: var(--axis); stroke-width: 1; }
.schem .sym { fill: var(--hero); stroke: var(--muted); stroke-width: 1.2; }
.schem .symtxt { font-size: 9.5px; font-weight: 500; text-anchor: middle; fill: var(--ink-2); letter-spacing: 0.02em; }
.schem .symtxt.small { font-size: 8px; }
.schem .rd { font-size: 12.5px; font-weight: 500; fill: var(--ink); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.schem .rd .u { font-size: 10px; font-weight: 400; fill: var(--muted); letter-spacing: 0; }
.schem .rd.dim { fill: var(--muted); font-weight: 400; }
.schem .lbltxt { font-size: 11px; font-weight: 600; text-anchor: end; letter-spacing: 0.1em; text-transform: uppercase; }
.schem .vlabel { font-size: 9.5px; text-anchor: middle; fill: var(--muted); letter-spacing: 0.02em; }
.schem .rlabel { font-size: 11px; fill: var(--muted); letter-spacing: 0.06em; text-transform: uppercase; }
.schem .valve { cursor: pointer; }
.schem .valve .body { fill: var(--hero); stroke: var(--muted); stroke-width: 1.4; transition: fill 0.25s, stroke 0.25s, filter 0.25s; }
.schem .valve:hover .body { stroke: var(--ink); }
.schem .valve.open .body { fill: var(--good); stroke: var(--good); }
.schem .valve.open .vlabel { fill: var(--ink-2); }
.schem .valve.unknown .body { fill: none; stroke: var(--warning); stroke-dasharray: 3 3; }
.schem .valve.blocked { cursor: not-allowed; }  /* the reason is in the tooltip; open stays lit */
.schem .mod { fill: var(--surface); stroke: var(--axis); stroke-width: 1.2; transition: stroke 0.25s, filter 0.25s; }
.schem .mod.on { stroke: var(--accent); }
.schem .modtxt { font-size: 21px; font-weight: 300; text-anchor: middle; fill: var(--ink); font-variant-numeric: tabular-nums; letter-spacing: -0.03em; }
.schem .modtxt .u { font-size: 11px; font-weight: 400; fill: var(--muted); letter-spacing: 0; }
.schem .modsub { font-size: 10px; text-anchor: middle; fill: var(--muted); letter-spacing: 0.1em; }
.schem .ind { fill: none; stroke: var(--muted); stroke-width: 1.2; transition: fill 0.25s, stroke 0.25s; }
.schem .ind.on { fill: var(--good); stroke: var(--good); }
.schem .ind.bad { fill: var(--critical); stroke: var(--critical); }
.schem .pol { cursor: pointer; }
.schem .pol rect { fill: var(--hero); stroke: var(--axis); stroke-width: 1.2; }
.schem .pol:hover rect { stroke: var(--ink); }
.schem .pol.rev rect { fill: var(--accent); stroke: var(--accent); }
.schem .poltxt { font-size: 12px; font-weight: 600; text-anchor: middle; fill: var(--ink); letter-spacing: 0.06em; }
.schem .pol.rev .poltxt { fill: #fff; }
.schem .pol.blocked { cursor: not-allowed; opacity: 0.6; }

/* charts */
.charts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }  /* laptop: four per row */
.chart { position: relative; }
.chart svg { display: block; margin-top: 6px; max-width: 100%; }
.chart .empty { padding: 30px 0; text-align: center; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 4px; font-size: 12px; color: var(--ink-2); }
.legend .lv { display: inline-block; min-width: 6ch; margin-left: 6px; color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }  /* the value; a fixed width so the legend does not reflow as it changes */
.legend i, .tip i { display: inline-block; width: 10px; height: 3px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }
.axis text, text.end { font-size: 10.5px; font-variant-numeric: tabular-nums; }
.axis text.caption { fill: var(--ink-2); font-weight: 600; letter-spacing: 0.02em; }
text.end { fill: var(--ink-2); }
.chart .title { font-weight: 500; font-size: 13px; display: flex; align-items: baseline; gap: 6px; }
.chart .title .why { flex: 1; }
button.mini { margin-left: auto; min-height: 0; padding: 2px 8px; font-size: 11px; border-radius: 6px; color: var(--muted); }
.chart .title .why { font-weight: 400; margin-left: 6px; }
.chart .title .now { flex: 1; margin-left: 10px; font-weight: 400; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.chart .title .now b { font-size: 16px; color: var(--ink); margin-right: 2px; }  /* the latest reading, a touch above the title */
.tip { display: flex; gap: 12px; height: 20px; margin-top: 4px; font-size: 12px; color: var(--ink-2); overflow: hidden;
  white-space: nowrap; font-variant-numeric: tabular-nums; }  /* one line under the chart, never over it, never taller */
.tip > span { flex: 0 0 auto; }
.tip .ev { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; color: var(--ink); }
.evpop { position: absolute; z-index: 3; max-width: 260px; padding: 8px 10px; border-radius: 10px; background: var(--solid); border: 1px solid var(--border);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.14); font-size: 12px; pointer-events: none; }  /* every event under the cursor, only while a marker is hovered */
.evpop div { display: flex; gap: 8px; white-space: nowrap; }
.evpop time { color: var(--muted); font-variant-numeric: tabular-nums; }
.evlist { margin-top: 14px; font-size: 13px; }
.evlist table { border-collapse: collapse; width: 100%; }
.evlist td { padding: 4px 10px 4px 0; border-top: 1px solid var(--border); vertical-align: top; }
.evlist td:first-child { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; width: 1%; }
.evlist td.k { color: var(--muted); white-space: nowrap; width: 1%; text-transform: capitalize; }
.evlist tr.ev-trip td { color: var(--critical); }
.evlist .more { margin-top: 6px; }
.axis text { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }

/* tabs, the comparison picker, empty and loading states */
.tabs { display: inline-flex; gap: 2px; border-bottom: 1px solid var(--border); margin: 2px 0 14px; width: 100%; }
.tabs button { border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none; min-height: 38px; padding: 6px 16px; color: var(--ink-2); font-weight: 500; font-size: 14px; }
.tabs button:hover:not(:disabled) { background: none; color: var(--ink); }
.tabs button.on { color: var(--ink); border-bottom-color: var(--accent); }
.tabs button small { color: var(--muted); margin-left: 6px; font-weight: 400; }
[data-tab]:not(.show) { display: none; }
.picker { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.picker .chips { gap: 6px; }
.picker .chips .pill { gap: 6px; cursor: pointer; }
.picker .chips .pill::before { width: 10px; height: 10px; background: var(--c, var(--muted)); box-shadow: none; }
.picker .chips .pill b { font-weight: 600; color: var(--ink); }
.picker .chips .pill .x { color: var(--muted); margin-left: 2px; }
.picker .chips .pill:hover .x { color: var(--critical); }
.pickpanel { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; margin-bottom: 12px; }
.pickpanel .row { margin-top: 0; }
.pickpanel .group { margin-top: 10px; }
.pickpanel .group .lab { margin-bottom: 4px; }
.pickpanel .opts { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(230px, 100%), 1fr)); gap: 2px 14px; }
.pickpanel label { display: flex; align-items: center; gap: 8px; font-size: 13px; padding: 3px 4px; border-radius: 6px; cursor: pointer; }
.pickpanel label:hover { background: var(--btn); }
.pickpanel label small { color: var(--muted); margin-left: auto; }
.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 32px 12px; text-align: center;
  color: var(--muted); border: 1px dashed var(--border); border-radius: 12px; font-size: 13px; background: var(--surface-2); }
.empty b { color: var(--ink-2); font-weight: 600; }
.empty.loading { flex-direction: row; gap: 10px; border-style: solid; }
.spin { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--border); border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.kpi .v.skeleton { color: transparent; background: var(--btn); border-radius: 6px; }
