/* Theme tokens. Dark is the default; light follows the OS setting.
   The --c-* chart colours are a validated categorical palette (checked for
   colour-blind separation and contrast against --surface in each theme);
   each data series keeps its colour everywhere it appears. */
:root {
  color-scheme: dark;
  --plane: #0b0d11;
  --surface: #15181d;
  --surface-2: #1d2128;
  --surface-3: #262b34;
  --line: rgb(255 255 255 / 0.08);
  --line-strong: rgb(255 255 255 / 0.16);
  --text: #eef0f3;
  --text-2: #b4bac5;
  --muted: #7f8794;
  --accent: #2cc48d;
  --accent-ink: #04130d;
  --accent-wash: rgb(44 196 141 / 0.13);
  --shadow: 0 1px 0 rgb(255 255 255 / 0.03) inset, 0 12px 32px rgb(0 0 0 / 0.28);

  --good: #0ca30c;
  --warn: #fab219;
  --crit: #e5534b;

  --grid: #252a32;
  --axis: #39404b;
  --c-in: #3987e5;
  --c-out: #d95926;
  --c-soc: #199e70;
  --c-solar: #c98500;
  --c-ac_in: #d55181;
  --c-ac_out: #0ca30c;
  --c-usb: #9085e9;
  --c-dc: #e66767;

  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.45;
}

@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --plane: #f3f4f7;
    --surface: #ffffff;
    --surface-2: #f2f4f7;
    --surface-3: #e7eaef;
    --line: rgb(16 24 40 / 0.09);
    --line-strong: rgb(16 24 40 / 0.2);
    --text: #12151a;
    --text-2: #474e5c;
    --muted: #727a89;
    --accent: #0f9a69;
    --accent-ink: #ffffff;
    --accent-wash: rgb(15 154 105 / 0.1);
    --shadow: 0 1px 2px rgb(16 24 40 / 0.05), 0 8px 24px rgb(16 24 40 / 0.06);

    --good: #0a8a0a;
    --warn: #b87400;
    --crit: #d03b3b;

    --grid: #e8eaee;
    --axis: #c5cad3;
    --c-in: #2a78d6;
    --c-out: #eb6834;
    --c-soc: #1baf7a;
    --c-solar: #eda100;
    --c-ac_in: #e87ba4;
    --c-ac_out: #008300;
    --c-usb: #6250d6;
    --c-dc: #e34948;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--plane);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p, ul, dl, dd, figure { margin: 0; }
ul { padding: 0; list-style: none; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* ---------- buttons ---------- */
button { font: inherit; cursor: pointer; }
button.primary {
  border: 0;
  border-radius: 12px;
  padding: 12px 16px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 650;
}
button.primary:hover { filter: brightness(1.06); }
button.ghost {
  background: none;
  color: var(--text-2);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 7px 12px;
  font-size: 0.9rem;
}
button.ghost { white-space: nowrap; }
button.ghost:hover { color: var(--text); background: var(--surface-2); }

/* ---------- top bar ---------- */
.top {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px max(16px, calc((100vw - 1240px) / 2 + 16px));
  background: color-mix(in srgb, var(--plane) 82%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; font-size: 1.05rem; white-space: nowrap; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: linear-gradient(135deg, #3ddc97, #16a3a0);
  color: #04130d;
}
.brand-mark .icon { fill: currentColor; stroke: none; }
.brand-mark.big { width: 48px; height: 48px; border-radius: 14px; }
.brand-mark.big .icon { width: 26px; height: 26px; }
.top-right { display: flex; align-items: center; gap: 10px; }

/* ---------- pills ---------- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 0.8rem;
  white-space: nowrap;
}
.pill i { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.pill.live i { background: var(--good); animation: pulse 2.4s ease-out infinite; }
.pill.off i, .pill.bad i { background: var(--crit); }
.pill.demo i { background: var(--warn); }
.pill.bad { border-color: var(--crit); color: var(--text); }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--good) 60%, transparent); }
  70%, 100% { box-shadow: 0 0 0 7px transparent; }
}

.conn { display: flex; align-items: center; }
.conn-msg {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  padding: 9px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--crit);
  font-size: 0.9rem;
  text-align: center;
}

/* ---------- cards ---------- */
.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 22px;
  box-shadow: var(--shadow);
}
.card-title { font-size: 1.05rem; font-weight: 650; }
.model { color: var(--muted); font-size: 0.85rem; overflow-wrap: anywhere; }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr));
  gap: 20px;
  max-width: 1240px;
  margin: 0 auto;
  padding: 24px 16px 56px;
  align-items: start;
}
.card-head h2 { font-size: 1.25rem; font-weight: 650; letter-spacing: -0.01em; }
.card-head h2 a:hover { text-decoration: underline; text-underline-offset: 3px; }
.card-head { padding-right: 96px; } /* room for the status pill */

.card-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 18px -22px -22px;
  padding: 14px 22px;
  border-top: 1px solid var(--line);
  border-radius: 0 0 20px 20px;
  color: var(--text-2);
  font-size: 0.92rem;
  font-weight: 550;
}
.card-link:hover { background: var(--surface-2); color: var(--text); }
.card-link .icon { transition: transform 0.15s; }
.card-link:hover .icon { transform: translateX(3px); }

/* ---------- live status ---------- */
.status .state { position: absolute; top: 20px; right: 20px; }
.empty { color: var(--muted); padding: 36px 0 20px; }
.error {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--crit);
  background: color-mix(in srgb, var(--crit) 9%, transparent);
  font-size: 0.9rem;
}
.status .error { margin-top: 14px; }
.controls .error { margin-bottom: 14px; }

/* Readings from an offline device are old; show them dimmed. */
.status.stale .hero, .status.stale .flows, .status.stale .details { opacity: 0.45; }

.hero { display: flex; align-items: center; gap: 22px; margin-top: 18px; }
.ring { width: 148px; height: 148px; flex: none; }
.ring circle { fill: none; stroke-width: 9; }
.ring-track { stroke: var(--surface-3); }
.ring-fill { stroke-linecap: round; transition: stroke-dasharray 0.8s ease; }
.ring.low .ring-fill { stroke: var(--warn); }
.ring.critical .ring-fill { stroke: var(--crit); }
.ring text { text-anchor: middle; fill: var(--text); }
.ring-num { font-size: 30px; font-weight: 700; letter-spacing: -0.02em; }
.ring-pct { font-size: 15px; font-weight: 600; fill: var(--text-2); }
.ring-sub { font-size: 10px; fill: var(--muted); letter-spacing: 0.04em; text-transform: uppercase; }

.hero-side { flex: 1; min-width: 0; }
.io { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.io-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 12px;
  border-radius: 14px;
  background: var(--surface-2);
}
.io-item span { display: flex; align-items: center; gap: 6px; color: var(--text-2); font-size: 0.8rem; }
.io-item .icon { width: 15px; height: 15px; }
.io-item b { font-size: 1.6rem; font-weight: 680; letter-spacing: -0.02em; line-height: 1.15; }
.io-item small { font-size: 0.85rem; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.remain { min-height: 1.45em; margin-top: 10px; color: var(--text-2); font-size: 0.92rem; }

.flows {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: 8px;
  margin-top: 18px;
}
.flow {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  column-gap: 8px;
  padding: 9px 11px;
  border-radius: 12px;
  border: 1px solid var(--line);
  color: var(--muted);
  transition: background 0.3s, border-color 0.3s, color 0.3s;
}
.flow .icon { grid-row: span 2; }
.flow span { font-size: 0.74rem; }
.flow b { font-size: 0.95rem; font-weight: 550; font-variant-numeric: tabular-nums; }
.flow.on { color: var(--text); background: var(--accent-wash); border-color: color-mix(in srgb, var(--accent) 38%, transparent); }
.flow.on .icon { color: var(--accent); }
.flow.on b { font-weight: 650; }

.details {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px 20px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 0.88rem;
}
.details div { display: flex; justify-content: space-between; gap: 8px; }
.details dt { color: var(--muted); }
.details dd { font-variant-numeric: tabular-nums; }

/* ---------- sparkline on the overview cards ---------- */
.spark { margin-top: 16px; }
.spark figcaption { color: var(--muted); font-size: 0.74rem; margin-bottom: 4px; }
.spark-plot { height: 44px; }
.spark-plot svg { display: block; width: 100%; height: 100%; overflow: visible; }

/* ---------- controls ---------- */
.controls { margin-top: 18px; }
.device-card .controls { padding-top: 14px; border-top: 1px solid var(--line); }
.group-title {
  margin: 20px 0 6px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.controls > .group-title:first-of-type { margin-top: 0; }

.toggles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0 28px; }
.switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  cursor: pointer;
}
input[role="switch"] {
  appearance: none;
  -webkit-appearance: none;
  flex: none;
  position: relative;
  width: 46px;
  height: 28px;
  margin: 0;
  border-radius: 14px;
  background: var(--surface-3);
  cursor: pointer;
  transition: background 0.2s;
}
input[role="switch"]::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.35);
  transition: transform 0.2s;
}
input[role="switch"]:checked { background: var(--accent); }
input[role="switch"]:checked::before { transform: translateX(18px); }
input:disabled, select:disabled { opacity: 0.45; cursor: not-allowed; }

.range {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: baseline;
  column-gap: 4px;
  margin-top: 12px;
}
.range output { font-weight: 650; font-variant-numeric: tabular-nums; }
.range .unit { color: var(--muted); font-size: 0.85rem; }
.range input { grid-column: 1 / -1; width: 100%; margin: 8px 0 0; accent-color: var(--accent); }

.selects { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px 16px; margin-top: 8px; }
.select { display: flex; flex-direction: column; gap: 5px; font-size: 0.85rem; color: var(--text-2); }
select {
  font: inherit;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
}

/* The overview shows only the main switches; the rest live on the device page. */
.device-card .ranges, .device-card .timers, .device-card .more, .device-card .group-title, .device-card .details,
.device-card .switch[data-key="beep"], .device-card .switch[data-key="xboost"] { display: none; }

/* ---------- device page ---------- */
.device-page { max-width: 1240px; margin: 0 auto; padding: 20px 16px 64px; }
.device-head { margin-bottom: 20px; }
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); font-size: 0.9rem; margin-bottom: 10px; }
.back:hover { color: var(--text); }
.back .icon { width: 16px; height: 16px; }
.device-head h1 { font-size: 1.7rem; font-weight: 700; letter-spacing: -0.02em; }

.device-grid { display: grid; gap: 20px; grid-template-columns: minmax(0, 1fr); align-items: start; }
/* minmax(0, 1fr) lets wide content (the data table) scroll inside its card
   instead of stretching the page. */
.col-live, .col-history { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; min-width: 0; }
.col-live .card .controls { margin-top: 14px; }
.col-live .status .state { position: static; }
@media (min-width: 1020px) {
  .device-grid { grid-template-columns: minmax(360px, 420px) minmax(0, 1fr); }
  .col-live { position: sticky; top: 76px; }
}

/* ---------- history ---------- */
.range-row {
  display: inline-flex;
  justify-self: start;
  gap: 2px;
  padding: 3px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
}
.range-row button {
  border: 0;
  border-radius: 9px;
  padding: 7px 14px;
  background: none;
  color: var(--text-2);
  font-size: 0.9rem;
}
.range-row button:hover { background: var(--surface-2); }
.range-row button[aria-pressed="true"] { background: var(--surface-3); color: var(--text); font-weight: 650; }

.history-note { color: var(--text-2); font-size: 0.92rem; }

.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 560px) { .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.tile {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
}
.tile-label { color: var(--text-2); font-size: 0.8rem; }
.tile b { font-size: 1.35rem; font-weight: 680; letter-spacing: -0.01em; }

.chart-card { padding: 18px 18px 12px; min-width: 0; }
.chart-card figcaption h3 { font-size: 1rem; font-weight: 650; }
.chart-card figcaption p { color: var(--muted); font-size: 0.8rem; }
.chart-pair { display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); }

.legend { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 8px; color: var(--text-2); font-size: 0.82rem; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.key { width: 14px; height: 3px; border-radius: 2px; flex: none; }

.plot { position: relative; margin-top: 8px; outline-offset: 4px; }
.plot svg { display: block; width: 100%; overflow: visible; touch-action: pan-y; }
/* While new data loads, the old drawing stays, dimmed: no jump, no flash. */
.col-history.loading .plot, .col-history.loading .tiles { opacity: 0.55; transition: opacity 0.15s; }

.grid-line { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.axis-line { stroke: var(--axis); stroke-width: 1; shape-rendering: crispEdges; }
.tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.series-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.series-area { stroke: none; opacity: 0.1; }
.end-label { fill: var(--text-2); font-size: 11px; }
.crosshair { stroke: var(--axis); stroke-width: 1; shape-rendering: crispEdges; }
.marker { stroke: var(--surface); stroke-width: 2; }

.s-in { stroke: var(--c-in); } .f-in, .k-in { fill: var(--c-in); background: var(--c-in); }
.s-out { stroke: var(--c-out); } .f-out, .k-out { fill: var(--c-out); background: var(--c-out); }
.s-soc { stroke: var(--c-soc); } .f-soc, .k-soc { fill: var(--c-soc); background: var(--c-soc); }
.s-solar { stroke: var(--c-solar); } .f-solar, .k-solar { fill: var(--c-solar); background: var(--c-solar); }
.s-ac_in { stroke: var(--c-ac_in); } .f-ac_in, .k-ac_in { fill: var(--c-ac_in); background: var(--c-ac_in); }
.s-ac_out { stroke: var(--c-ac_out); } .f-ac_out, .k-ac_out { fill: var(--c-ac_out); background: var(--c-ac_out); }
.s-usb { stroke: var(--c-usb); } .f-usb, .k-usb { fill: var(--c-usb); background: var(--c-usb); }
.s-dc { stroke: var(--c-dc); } .f-dc, .k-dc { fill: var(--c-dc); background: var(--c-dc); }
/* The optional series reuse the palette: a measurement of something takes that
   thing's colour (AC-in voltage is the AC-in colour). The USB ports are drawn
   two to a chart, first port blue and second orange: no larger set of these
   hues stays distinguishable for every pair under colour-vision deficiency. */
.s-temp, .s-batt_v { stroke: var(--c-soc); } .f-temp, .k-temp, .f-batt_v, .k-batt_v { fill: var(--c-soc); background: var(--c-soc); }
.s-inv_temp { stroke: var(--c-out); } .f-inv_temp, .k-inv_temp { fill: var(--c-out); background: var(--c-out); }
.s-ac_in_v { stroke: var(--c-ac_in); } .f-ac_in_v, .k-ac_in_v { fill: var(--c-ac_in); background: var(--c-ac_in); }
.s-ac_out_v { stroke: var(--c-ac_out); } .f-ac_out_v, .k-ac_out_v { fill: var(--c-ac_out); background: var(--c-ac_out); }
.s-solar_v { stroke: var(--c-solar); } .f-solar_v, .k-solar_v { fill: var(--c-solar); background: var(--c-solar); }
.s-usb1 { stroke: var(--c-in); } .f-usb1, .k-usb1 { fill: var(--c-in); background: var(--c-in); }
.s-usb2 { stroke: var(--c-out); } .f-usb2, .k-usb2 { fill: var(--c-out); background: var(--c-out); }
.s-qc1, .s-tc1 { stroke: var(--c-in); } .f-qc1, .k-qc1, .f-tc1, .k-tc1 { fill: var(--c-in); background: var(--c-in); }
.s-qc2, .s-tc2 { stroke: var(--c-out); } .f-qc2, .k-qc2, .f-tc2, .k-tc2 { fill: var(--c-out); background: var(--c-out); }
/* The same holds for the rest: each set drawn together was checked as a set.
   Battery green with blue and orange (extra batteries; the battery switch),
   solar amber with blue for a second input,
   inverter orange with blue and green. */
.s-batt_a, .s-soh, .s-cycles, .s-dc_temp { stroke: var(--c-soc); }
.f-batt_a, .k-batt_a, .f-soh, .k-soh, .f-cycles, .k-cycles, .f-dc_temp, .k-dc_temp { fill: var(--c-soc); background: var(--c-soc); }
.s-xb1_soc, .s-cell_v_min, .s-mos_temp, .s-mppt_temp, .s-solar2_v, .s-solar2_a { stroke: var(--c-in); }
.f-xb1_soc, .k-xb1_soc, .f-cell_v_min, .k-cell_v_min, .f-mos_temp, .k-mos_temp, .f-mppt_temp, .k-mppt_temp,
.f-solar2_v, .k-solar2_v, .f-solar2_a, .k-solar2_a { fill: var(--c-in); background: var(--c-in); }
.s-xb2_soc, .s-cell_v_max { stroke: var(--c-out); }
.f-xb2_soc, .k-xb2_soc, .f-cell_v_max, .k-cell_v_max { fill: var(--c-out); background: var(--c-out); }
.s-ac_out_a { stroke: var(--c-ac_out); } .f-ac_out_a, .k-ac_out_a { fill: var(--c-ac_out); background: var(--c-ac_out); }
.s-solar_a { stroke: var(--c-solar); } .f-solar_a, .k-solar_a { fill: var(--c-solar); background: var(--c-solar); }

.tip {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 5;
  min-width: 132px;
  padding: 9px 11px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  box-shadow: 0 10px 28px rgb(0 0 0 / 0.3);
  font-size: 0.82rem;
  pointer-events: none;
  white-space: nowrap;
}
.tip-time { color: var(--text-2); margin-bottom: 5px; }
.tip-row { display: flex; align-items: center; gap: 7px; }
.tip-row b { font-weight: 650; font-variant-numeric: tabular-nums; }
.tip-row span:last-child { color: var(--text-2); }

.table-view { padding: 0; }
.table-view summary { padding: 14px 18px; cursor: pointer; color: var(--text-2); font-size: 0.92rem; }
.table-view summary:hover { color: var(--text); }
.table-wrap { max-height: 380px; overflow: auto; border-top: 1px solid var(--line); }
.table-wrap table { width: 100%; border-collapse: collapse; font-size: 0.82rem; font-variant-numeric: tabular-nums; }
.table-wrap th, .table-wrap td { padding: 6px 12px; text-align: right; white-space: nowrap; }
.table-wrap th:first-child, .table-wrap td:first-child { text-align: left; }
.table-wrap thead th { position: sticky; top: 0; background: var(--surface); color: var(--text-2); font-weight: 600; border-bottom: 1px solid var(--line); }
.table-wrap tbody tr:nth-child(even) { background: var(--surface-2); }

/* ---------- sign-in ---------- */
.login-page { display: grid; place-items: center; padding: 16px; }
.login {
  width: min(100%, 360px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 32px 26px 28px;
  box-shadow: var(--shadow);
}
.login h1 { font-size: 1.45rem; font-weight: 700; letter-spacing: -0.02em; margin-top: 16px; }
.login-sub { color: var(--text-2); font-size: 0.92rem; margin: 4px 0 22px; }
.login form { display: flex; flex-direction: column; gap: 8px; }
.login label { font-size: 0.85rem; color: var(--text-2); }
.login input {
  font: inherit;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  padding: 11px 13px;
}
.login button { margin-top: 10px; }

@media (max-width: 460px) {
  /* Not enough room for the connection label: keep the dot, and keep the
     words available to screen readers. */
  .conn .pill { padding: 6px; }
  .conn .pill span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
  .card { padding: 18px; border-radius: 18px; }
  .status .state { top: 16px; right: 16px; }
  .card-link { margin: 16px -18px -18px; padding: 13px 18px; border-radius: 0 0 18px 18px; }
  .hero { gap: 14px; }
  .ring { width: 118px; height: 118px; }
  .io { grid-template-columns: 1fr; gap: 8px; }
  .io-item { flex-direction: row; align-items: baseline; justify-content: space-between; padding: 8px 12px; }
  .io-item b { font-size: 1.3rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before { animation: none !important; transition: none !important; }
}

/* ---------- all readings ---------- */
.readings { margin-top: 18px; }
.readings .group-title:first-child { margin-top: 0; }
.details.plain { margin-top: 0; padding-top: 0; border-top: 0; }
.details.plain dd { white-space: nowrap; text-align: right; }
.readings + .card-link { margin-top: 18px; }
.more .selects { margin-top: 14px; }

/* ---------- the grouped charts below the main ones ---------- */
.chart-group { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; margin-top: 8px; }
.chart-group > h2 { font-size: 1.05rem; font-weight: 650; }
.plot-empty { margin: 0; padding: 48px 16px; text-align: center; color: var(--muted); font-size: 0.9rem; }

/* ---------- raw values ---------- */
.raw-intro { max-width: 68ch; margin-top: 10px; color: var(--text-2); font-size: 0.92rem; }
.raw-filter { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; color: var(--text-2); font-size: 0.9rem; }
.raw-filter input {
  flex: 1;
  max-width: 340px;
  font: inherit;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 12px;
}
.raw-count { margin: 0 0 12px; color: var(--muted); font-size: 0.85rem; }
.raw-group { margin-bottom: 16px; padding-bottom: 8px; }
.raw-group .card-title { margin-bottom: 10px; }
.raw-scroll { overflow-x: auto; }
/* Fixed columns, so every group lines up with the one above it. */
.raw-group table { width: 100%; min-width: 560px; table-layout: fixed; border-collapse: collapse; font-size: 0.86rem; }
.raw-group th:nth-child(1) { width: 36%; }
.raw-group th:nth-child(2) { width: 22%; }
.raw-group th { text-align: left; color: var(--muted); font-weight: 600; font-size: 0.74rem; letter-spacing: 0.06em; text-transform: uppercase; }
.raw-group th, .raw-group td { padding: 6px 14px 6px 0; border-bottom: 1px solid var(--line); vertical-align: top; overflow-wrap: anywhere; }
.raw-group tbody tr:last-child td { border-bottom: 0; }
.raw-group td:nth-child(1), .raw-group td:nth-child(2) { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 0.82rem; }
.raw-group td:nth-child(2) { font-variant-numeric: tabular-nums; }
.raw-group td:nth-child(3) { color: var(--text-2); }
