/* ═══════════════════════════════════════════════════════════
   Dashboard cards — shared structure (loaded after style.css on
   the dashboard and in the layout editor's previews).

   Every card fills its block, uses one surface, one title style and
   one way of showing numbers. Numbers scale with the block's width
   through container queries (cqi), so small blocks don't clip and
   large blocks don't look empty.
   ═══════════════════════════════════════════════════════════ */

.dashboard-block { container-type: inline-size; }
.dashboard-block > * { height: 100%; }

:root {
  --card-pad: clamp(10px, 3.2cqi, 18px);
  --card-gap: clamp(6px, 2cqi, 12px);
}

/* ── Surface ──────────────────────────────────────────────── */
.ep-card,
.stats-grid.ep-tiles,
.multi-value-card,
.chart-container,
.daily-breakdown-container,
.bar-single-card,
.bar-stacked-card,
.bar-threshold-card,
.switch-block,
.state-select-block,
.flow-card,
.flow-card-2,
.flow-card-square,
.flow-card-square2 {
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  min-width: 0;
  border-radius: var(--radius);
}
.ep-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: var(--card-pad);
  display: flex;
  flex-direction: column;
  gap: var(--card-gap);
  overflow: hidden;
}
.ep-card-flush { padding: 0; }
.ep-card-empty {
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--text-secondary);
  font-size: calc(0.85rem * var(--card-font-scale, 1));
  line-height: 1.45;
}

.ep-card-title, .chart-header h3, .fc-title, .daily-breakdown-header h3 {
  margin: 0;
  font-size: calc(clamp(0.8rem, 2.6cqi, 0.95rem) * var(--card-font-scale, 1)) !important;
  font-weight: 700 !important;
  letter-spacing: 0.01em;
  color: var(--text);
  line-height: 1.3;
}

/* Labels and values */
.ep-label {
  font-size: calc(clamp(0.7rem, 2.4cqi, 0.85rem) * var(--card-font-scale, 1));
  font-weight: 600;
  color: var(--text-secondary);
  opacity: 1;
  margin: 0;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}
.ep-value {
  display: inline-flex;
  align-items: baseline;
  gap: 0.18em;
  margin: 0;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  line-height: 1.05;
  letter-spacing: -0.01em;
  white-space: nowrap;
  max-width: 100%;
}
.ep-num { overflow: hidden; text-overflow: ellipsis; }
.ep-unit { font-size: 0.55em; font-weight: 600; color: var(--text-secondary); letter-spacing: 0; }
.ep-value.is-empty { color: var(--text-secondary); font-weight: 500; }
/* Text values (modes, states) wrap instead of being cut off. */
.ep-value.is-text { white-space: normal; overflow-wrap: anywhere; line-height: 1.15; }
.ep-tiles > .ep-tile .ep-value.is-text { font-size: calc(clamp(1rem, 4.6cqi, 1.5rem) * var(--card-font-scale, 1)); }

/* ── Tiles: metric cards, multi-value, savings, grid hours ── */
.ep-tiles {
  display: grid !important;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 120px), 1fr));
  gap: var(--card-gap);
  align-content: stretch;
  background: none;
}
.ep-tiles > .ep-tile {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 0.35em;
  padding: var(--card-pad);
  text-align: left;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.ep-tiles > .ep-tile .ep-value { font-size: calc(clamp(1.15rem, 6cqi, 2.1rem) * var(--card-font-scale, 1)); }
/* Inside a card (savings, grid) tiles are flat sub-areas, not cards. */
.ep-card .ep-tiles > .ep-tile { background: var(--bg); border-color: transparent; box-shadow: none; padding: 0.6em 0.75em; }
.ep-card .ep-tiles > .ep-tile .ep-value { font-size: calc(clamp(1rem, 4.6cqi, 1.6rem) * var(--card-font-scale, 1)); }
.ep-card .ep-tiles { flex: 1 1 auto; }
@container (max-width: 260px) {
  .ep-tiles { grid-template-columns: minmax(0, 1fr); }
}

/* ── Tile icons: an optional icon or image beside a tile's text (Metric cards, Multi-value rows, Text metric) ── */
.stat-card.has-icon {
  display: grid !important; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: auto auto;
  grid-template-areas: "icon label" "icon value"; align-content: center; align-items: center; justify-items: start;
  column-gap: clamp(0.5rem, 2.2cqi, 1rem); row-gap: 0.15em;
}
.stat-card.has-icon > .tile-icon { grid-area: icon; align-self: center; }
.stat-card.has-icon > .stat-label { grid-area: label; align-self: end; }
.stat-card.has-icon > .stat-value { grid-area: value; align-self: start; }
.stat-card.has-icon > :not(.tile-icon, .stat-label, .stat-value) { grid-column: 1 / -1; }   /* breakdown lists and the like span the tile */
/* The icon's square follows the card (the block's width), with limits so it neither vanishes nor takes over. */
.tile-icon {
  --tile-icon-size: clamp(1.9rem, 5.2cqi, 3.4rem);
  display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; box-sizing: border-box;
  width: var(--tile-icon-size); height: var(--tile-icon-size); border-radius: 0.7em; overflow: hidden;
  background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent);
}
.tile-icon > svg { width: 56%; height: 56%; }
.tile-icon.is-image { background: transparent; }
.tile-icon.is-image > img { width: 100%; height: 100%; object-fit: contain; display: block; }
.tile-icon.is-emoji { font-size: calc(var(--tile-icon-size) * 0.52); line-height: 1; }
/* A single card (Text metric) lays its icon out the same way. */
.text-metric-card.has-icon { padding: var(--card-pad) !important; align-items: center !important; justify-content: start !important; }

/* ── Text metric ──────────────────────────────────────────── */
.text-metric-card {
  align-items: flex-start !important;
  justify-content: center !important;
  text-align: left !important;
  padding: var(--card-pad) !important;
  gap: 0.35em;
}
.text-metric-card .text-metric-value { font-size: calc(clamp(1.1rem, 5.5cqi, 2rem) * var(--card-font-scale, 1)) !important; font-weight: 700; line-height: 1.15; }
.text-metric-card .text-metric-label { font-size: calc(clamp(0.7rem, 2.4cqi, 0.85rem) * var(--card-font-scale, 1)); font-weight: 600; margin: 0; }

/* ── Gauges ───────────────────────────────────────────────── */
.ep-gauge { align-items: center; justify-content: center; text-align: center; padding: var(--card-pad) !important; }
.ep-gauge-wrap { position: relative; width: 100%; flex: 1 1 auto; min-height: 0; display: flex; align-items: center; justify-content: center; }
.ep-gauge-svg { width: 100%; height: 100%; max-height: 100%; display: block; overflow: visible; }
.ep-gauge-track { stroke: var(--border); }
.ep-gauge-fill { transition: stroke-dasharray 0.6s ease, stroke-dashoffset 0.6s ease, stroke 0.3s; }
.ep-gauge-readout {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.15em;
  pointer-events: none;
}
.ep-gauge-ring .ep-value { font-size: calc(clamp(1.05rem, 12cqi, 2.4rem) * var(--card-font-scale, 1)); }
.ep-gauge-half { aspect-ratio: 200 / 112; flex: 0 1 auto; max-height: 100%; }
.ep-gauge-half .ep-gauge-readout { justify-content: flex-end; padding-bottom: 2%; }
.ep-gauge-half .ep-value { font-size: calc(clamp(0.95rem, 8cqi, 1.9rem) * var(--card-font-scale, 1)); }
.ep-gauge > .ep-label { flex-shrink: 0; }
.ep-gauge-zero {
  position: absolute; left: 50%; top: 3%; width: 2px; height: 14%;
  transform: translateX(-50%); background: var(--text-secondary); opacity: 0.5; border-radius: 1px;
}

/* ── Bar gauges ───────────────────────────────────────────── */
/* The card is a size container, so its bars are sized from its width AND its height: rows share the height and each
   bar is a share of its row; columns (Orientation: Vertical) share the width and each bar is a share of its column.
   --bars is the number of metrics (set by the card), --bar-font the text size that fits a row or a column. A bigger
   card gets bigger bars and text, a smaller one smaller, and the card is always filled. */
.bar-gauge-card, .bar-gauge-retro-card {
  container-type: size; justify-content: stretch !important; gap: 0 !important; padding: var(--card-pad) !important;
  --bar-font: calc(clamp(0.7rem, min(100cqh / var(--bars, 4) * 0.36, 4.4cqw), 1.6rem) * var(--card-font-scale, 1));
}
.bar-gauge-row, .bg-retro-row {
  display: grid !important; flex: 1 1 0; min-height: 0; font-size: var(--bar-font);
  grid-template-columns: minmax(3.5em, min(28%, 9em)) minmax(0, 1fr) auto; grid-template-rows: minmax(0, 1fr) auto;
  align-items: center; column-gap: 0.6em;
}
.bar-gauge-label, .bg-retro-label {
  font-size: inherit !important; font-weight: 600; color: var(--text-secondary);
  min-width: 0 !important; max-width: none !important; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.bar-gauge-value, .bg-retro-value { font-size: calc(var(--bar-font) * 1.15) !important; min-width: 0 !important; }
.bar-gauge-track { align-self: center; height: clamp(6px, 46%, 40px) !important; background: var(--bg) !important; border: 1px solid var(--border); border-radius: 99px !important; }
.bar-gauge-fill { border-radius: 99px !important; }
.bg-retro-segments { align-self: center; height: clamp(8px, 52%, 44px); gap: clamp(1px, 0.5cqw, 4px) !important; }
.bg-retro-seg { height: 100% !important; border-radius: 3px !important; background: var(--border); }

/* Bar ends (the card's "Bar ends" setting): rounded or square, on the bars and on each segment. */
.bar-gauge-card.bar-ends-rounded :is(.bar-gauge-track, .bar-gauge-fill),
.bar-gauge-retro-card.bar-ends-rounded .bg-retro-seg { border-radius: 99px !important; }
.bar-gauge-card.bar-ends-square :is(.bar-gauge-track, .bar-gauge-fill),
.bar-gauge-retro-card.bar-ends-square .bg-retro-seg { border-radius: 0 !important; }

/* Vertical bars (the card's "Orientation" setting): one column per metric, the value on top, the bar in the
   middle and the label below. The bars fill from the bottom; the segments are stacked from the bottom up. */
:is(.bar-gauge-card, .bar-gauge-retro-card).is-vertical {
  flex-direction: row !important; align-items: stretch; gap: clamp(4px, 1.4cqw, 16px) !important;
  --bar-font: calc(clamp(0.55rem, min(100cqw / var(--bars, 4) * 0.2, 100cqh * 0.09), 1.6rem) * var(--card-font-scale, 1));
}
:is(.bar-gauge-card, .bar-gauge-retro-card).is-vertical :is(.bar-gauge-row, .bg-retro-row) {
  display: flex !important; flex-direction: column; align-items: center; flex: 1 1 0; min-width: 0; min-height: 0; gap: 0.5em;
}
:is(.bar-gauge-card, .bar-gauge-retro-card).is-vertical :is(.bar-gauge-value, .bg-retro-value) { order: 0; text-align: center; max-width: 100%; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
:is(.bar-gauge-card, .bar-gauge-retro-card).is-vertical :is(.bar-gauge-label, .bg-retro-label) { order: 2; text-align: center; max-width: 100% !important; }
:is(.bar-gauge-card, .bar-gauge-retro-card).is-vertical :is(.bar-gauge-row, .bg-retro-row) > .bd-list { order: 3; grid-column: auto; padding-left: 0; max-width: 100%; }
.bar-gauge-card.is-vertical .bar-gauge-track {
  order: 1; flex: 1 1 0; min-height: 0; height: auto !important; width: clamp(12px, 46%, 140px);
  display: flex; flex-direction: column; justify-content: flex-end;
}
/* The track is what is rounded; the fill is cut to it. A rounded fill is a blob when it is short and the column wide. */
.bar-gauge-card.is-vertical .bar-gauge-fill { transition: height 0.5s ease; border-radius: 0 !important; }
.bar-gauge-retro-card.is-vertical .bg-retro-segments { order: 1; flex: 1 1 0; min-height: 0; height: auto; width: clamp(12px, 46%, 140px); flex-direction: column-reverse; gap: clamp(1px, 0.9cqh, 5px) !important; }
.bar-gauge-retro-card.is-vertical .bg-retro-seg { height: auto !important; width: 100%; flex: 1 1 0; min-height: 0; }
/* A very short card keeps the bars and values and drops the labels, with less space around them, rather than
   squeezing the bars away. */
@container (max-height: 120px) {
  :is(.bar-gauge-card, .bar-gauge-retro-card).is-vertical :is(.bar-gauge-label, .bg-retro-label) { display: none; }
  :is(.bar-gauge-card, .bar-gauge-retro-card).is-vertical :is(.bar-gauge-row, .bg-retro-row) { gap: 2px; }
  .bar-gauge-retro-card.is-vertical .bg-retro-segments { gap: 0 !important; }   /* there is no room for gaps between segments */
}
/* Where a card has no height of its own (phones stack the blocks), each bar keeps a height to be drawn in. */
@media (max-width: 768px) {
  .bar-gauge-card, .bar-gauge-retro-card { min-height: calc(var(--bars, 4) * 3.2rem); }
  .bar-gauge-card.is-vertical, .bar-gauge-retro-card.is-vertical { min-height: 14rem; }
}

/* ── Power flow ───────────────────────────────────────────── */
/* Sources on the left, destinations on the right, lines through a junction between. The body is a size container: the
   nodes in a column share its height equally (--pf-rows is the taller column's node count, set by the card), and the text
   and icons follow the height of a row, limited by the width, so the card fills at any size. The lines are drawn from the
   slot centres in a 0-100 box (powerFlow.js flowPaths), so they stay attached to the nodes. */
.power-flow-card { display: flex !important; flex-direction: column; gap: 0.5em; padding: var(--card-pad) !important; min-width: 0; height: 100%; width: 100%; box-sizing: border-box; container-type: size; }
.pf-title { flex: 0 0 auto; font-size: calc(clamp(0.8rem, 2.6cqi, 1.05rem) * var(--card-font-scale, 1)); font-weight: 700; color: var(--text); }
.pf-body {
  flex: 1 1 0; min-height: 0; container-type: size;
  display: grid; grid-template-columns: max-content minmax(1.5rem, 1fr) max-content; align-items: stretch;
  --pf-font: calc(clamp(0.4rem, min(100cqh / var(--pf-rows, 3) * 0.24, 100cqw * 0.042), 1.6rem) * var(--card-font-scale, 1));
}
.pf-col { display: flex; flex-direction: column; min-height: 0; }
.pf-sources { align-items: flex-end; }
.pf-dests { align-items: flex-start; }
.pf-node { flex: 1 1 0; min-height: 0; display: flex; align-items: center; gap: 0.6em; font-size: var(--pf-font); }
.pf-node[hidden] { display: none; }
.pf-icon {
  flex: 0 0 auto; width: 2.6em; height: 2.6em; border-radius: 0.7em; display: inline-flex; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--pf-color) 18%, transparent); color: var(--pf-color);
}
.pf-icon > svg { width: 58%; height: 58%; }
.pf-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.15; }
.pf-label { font-size: 0.8em; font-weight: 600; color: var(--text-secondary); white-space: nowrap; }
.pf-value { font-size: 1.35em; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; white-space: nowrap; }
.pf-sub { font-size: 0.8em; color: var(--text-secondary); white-space: nowrap; }
.pf-sub:empty { display: none; }
.pf-node:not(.is-flowing) .pf-value { color: var(--text-secondary); font-weight: 600; }
.pf-mid { position: relative; min-width: 0; }
.pf-lines { position: absolute; top: 0; bottom: 0; left: 0.5em; right: 0.5em; width: calc(100% - 1em); height: 100%; overflow: visible; }
.pf-line {
  fill: none; stroke: var(--pf-color); vector-effect: non-scaling-stroke; stroke-linecap: round;
  stroke-width: calc(var(--pf-font, 14px) * 0.14); opacity: 0.22;
}
.pf-line.is-flowing { opacity: 0.9; stroke-dasharray: 0.5em 0.6em; animation: pf-flow 1.1s linear infinite; }
@keyframes pf-flow { to { stroke-dashoffset: -1.1em; } }
.pf-dot {
  position: absolute; left: 50%; top: 50%; width: calc(var(--pf-font, 14px) * 0.7); height: calc(var(--pf-font, 14px) * 0.7);
  transform: translate(-50%, -50%); border-radius: 50%; background: var(--text-secondary); opacity: 0.35;
}
.pf-dot.is-flowing { opacity: 0.9; background: var(--text); }
@media (prefers-reduced-motion: reduce) { .pf-line.is-flowing { animation: none; stroke-dasharray: none; } }
/* A narrow card drops the labels (the icons say which node is which); a short one drops the title. */
@container (max-width: 300px) { .pf-label { display: none; } }
@container (max-height: 150px) { .pf-title { display: none; } }
/* Where a card has no height of its own (phones stack the blocks), each row keeps a height to be drawn in. */
@media (max-width: 768px) { .power-flow-card { min-height: calc(var(--pf-rows, 3) * 4.2rem + 3rem); } }

/* ── Ring gauge ───────────────────────────────────────────── */
/* The card and its dial are size containers: the dial (a square SVG in a 0-100 box) fills the room the card has, and the
   centre text follows the dial (cqmin), so the card scales to any size. Three rings leave less room in the middle, so the
   text steps down. */
.ring-gauge-card { display: flex !important; flex-direction: column; gap: 0.4em; padding: var(--card-pad) !important; min-width: 0; height: 100%; width: 100%; box-sizing: border-box; container-type: size; }
.rg-title { flex: 0 0 auto; font-size: calc(clamp(0.8rem, 2.6cqi, 1.05rem) * var(--card-font-scale, 1)); font-weight: 700; color: var(--text); text-align: center; }
.rg-dial { flex: 1 1 0; min-height: 0; position: relative; container-type: size; display: flex; align-items: center; justify-content: center; --rg-fs: 11.3cqmin; }
/* The text block must fit inside the innermost ring (a circle), corners included: it measured 10 to 20% too big at 14 and 11, so it is kept about 10% inside. */
.rg-n1 .rg-dial { --rg-fs: 15cqmin; }
.rg-n3 .rg-dial { --rg-fs: 7.9cqmin; }
.rg-svg { width: 100%; height: 100%; display: block; }
.rg-track { stroke: var(--text-secondary); opacity: 0.16; }
.rg-arc { transition: stroke-dasharray 0.6s ease; }
.rg-center {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  gap: 0.15em; font-size: calc(var(--rg-fs) * var(--card-font-scale, 1)); line-height: 1.1; pointer-events: none;
}
.rg-read { display: flex; flex-direction: column; align-items: center; min-width: 0; }
.rg-label { font-size: 0.42em; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-secondary); white-space: nowrap; }
.rg-value { font-size: 1em; font-weight: 800; color: var(--text); font-variant-numeric: tabular-nums; white-space: nowrap; }
.rg-read-1 .rg-value { font-size: 0.82em; }
.rg-divider { width: 3.2em; height: 1px; background: var(--text-secondary); opacity: 0.3; margin: 0.12em 0; }
.rg-center > .tile-icon.rg-icon { --tile-icon-size: 0.7em; width: 0.7em; height: 0.7em; background: transparent; color: var(--rg-icon-color, var(--solar, #f59e0b)); border-radius: 0; margin-bottom: 0.1em; }
.rg-center > .tile-icon.rg-icon > svg { width: 100%; height: 100%; }
.rg-center > .tile-icon.rg-icon.is-emoji { font-size: 0.8em; }
.rg-legend { flex: 0 0 auto; display: flex; flex-wrap: wrap; justify-content: center; gap: 0.3em 1em; font-size: calc(clamp(0.7rem, 2cqi, 0.9rem) * var(--card-font-scale, 1)); color: var(--text-secondary); }
.rg-leg-item { display: inline-flex; align-items: center; gap: 0.4em; white-space: nowrap; }
.rg-leg-dot { width: 0.7em; height: 0.7em; border-radius: 50%; display: inline-block; }
.rg-leg-value { color: var(--text); font-variant-numeric: tabular-nums; }
@container (max-height: 160px) { .rg-title { display: none; } }
@media (max-width: 768px) { .ring-gauge-card { min-height: 18rem; } }

/* ── Battery ──────────────────────────────────────────────── */
/* The body is a size container: the battery and the current marker are sized from its height, and the charge scale and
   marker labels from the card. Below it the charge in big type, and a row of small readings. */
.battery-card { display: flex !important; flex-direction: column; gap: 0.5em; padding: var(--card-pad) !important; min-width: 0; height: 100%; width: 100%; box-sizing: border-box; container-type: size; container-name: bc-card; align-items: center; }
.bc-title { flex: 0 0 auto; font-size: calc(clamp(0.8rem, 2.6cqi, 1.1rem) * var(--card-font-scale, 1)); font-weight: 800; color: var(--text); text-align: center; text-transform: uppercase; letter-spacing: 0.04em; }
.bc-body { flex: 1 1 0; min-height: 0; width: 100%; container-type: size; display: flex; align-items: stretch; justify-content: center; gap: 0.6em; }
.bc-scale { display: flex; flex-direction: column; justify-content: space-between; align-items: flex-end; padding: 6% 0 0; font-size: calc(clamp(0.5rem, 6cqh * 0.6, 0.75rem) * var(--card-font-scale, 1)); color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.bc-battery { height: 100%; width: min(calc(100cqh * 0.58), 56cqw); display: flex; flex-direction: column; align-items: center; }
.bc-cap { flex: 0 0 auto; width: 34%; height: 5%; border-radius: 3px 3px 0 0; background: var(--text-secondary); opacity: 0.55; }
.bc-shell { flex: 1 1 0; min-height: 0; width: 100%; position: relative; box-sizing: border-box; border: max(2px, 1.6cqh) solid color-mix(in srgb, var(--text-secondary) 55%, transparent); border-radius: 8px; overflow: hidden; background: color-mix(in srgb, var(--text-secondary) 10%, transparent); }
.bc-fill { position: absolute; left: 0; right: 0; bottom: 0; height: 0; background: var(--bc-band, #22c55e); transition: height 0.6s ease; }
.battery-card[data-band="low"] { --bc-band: var(--bc-low, #ef4444); }
.battery-card[data-band="mid"] { --bc-band: var(--bc-mid, #f59e0b); }
.battery-card[data-band="high"] { --bc-band: var(--bc-high, #22c55e); }
.bc-tick { position: absolute; left: 0; right: 0; height: 1px; background: var(--text-secondary); opacity: 0.3; }
.bc-current { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: space-between; font-size: calc(clamp(0.45rem, 5cqh * 0.6, 0.7rem) * var(--card-font-scale, 1)); color: var(--text-secondary); }
.bc-cur-label { white-space: nowrap; font-variant-numeric: tabular-nums; }
.bc-cur-zero { display: none; }
.bc-track { flex: 1 1 0; min-height: 0; width: 0.9em; margin: 0.4em 0; border-radius: 999px; position: relative; background: linear-gradient(to bottom, color-mix(in srgb, var(--bc-charge, #22c55e) 45%, transparent), color-mix(in srgb, var(--text-secondary) 20%, transparent) 50%, color-mix(in srgb, var(--bc-discharge, #ef4444) 45%, transparent)); }
.bc-marker { position: absolute; left: 50%; top: 50%; width: 1.3em; height: 1.3em; margin: -0.65em 0 0 -0.65em; border-radius: 50%; background: var(--text); border: 2px solid var(--bg, #fff); box-sizing: border-box; transition: top 0.6s ease; }
.bc-marker[hidden] { display: none; }
.bc-readout { flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; line-height: 1.05; }
.bc-soc { font-size: calc(clamp(1.1rem, min(9cqh, 16cqw), 2.6rem) * var(--card-font-scale, 1)); font-weight: 800; color: var(--bc-band, var(--text)); font-variant-numeric: tabular-nums; }
.bc-amps { font-size: calc(clamp(0.7rem, min(4.5cqh, 7cqw), 1.1rem) * var(--card-font-scale, 1)); font-weight: 700; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.bc-amps[data-dir="charge"] { color: var(--bc-charge, #22c55e); }
.bc-amps[data-dir="discharge"] { color: var(--bc-discharge, #ef4444); }
.bc-amps:empty { display: none; }
.bc-chips { flex: 0 0 auto; width: 100%; display: flex; flex-wrap: wrap; justify-content: space-around; gap: 0.3em 0.8em; padding-top: 0.4em; border-top: 1px solid color-mix(in srgb, var(--text-secondary) 25%, transparent); font-size: calc(clamp(0.65rem, 2.2cqi, 0.9rem) * var(--card-font-scale, 1)); color: var(--text-secondary); }
.bc-chip { display: inline-flex; align-items: center; gap: 0.4em; white-space: nowrap; }
.bc-chip-dot { width: 0.65em; height: 0.65em; border-radius: 50%; background: var(--text-secondary); display: inline-block; }
.bc-chip-value { color: var(--text); font-variant-numeric: tabular-nums; }
@container bc-card (max-height: 170px) { .bc-title { display: none; } }
@container bc-card (max-height: 230px) { .bc-scale, .bc-cur-label { display: none; } }
@media (max-width: 768px) { .battery-card { min-height: 22rem; } }

/* ── System hero ──────────────────────────────────────────── */
/* Words on the left, a picture on the right. The card is a size container; the text follows its height and width, and the
   picture is dropped when the card is too narrow for both. */
.system-hero-card { display: block !important; padding: var(--card-pad) !important; min-width: 0; height: 100%; width: 100%; box-sizing: border-box; container-type: size; overflow: hidden; }
.sh-body { height: 100%; min-width: 0; display: flex; flex-direction: column; gap: 0.5em; }
.sh-text { flex: 0 0 auto; min-width: 0; display: flex; flex-direction: column; gap: 0.3em; }
.sh-title { font-size: calc(clamp(0.6rem, min(8cqh, 3.2cqw), 0.95rem) * var(--card-font-scale, 1)); font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-secondary); }
.sh-headline { font-size: calc(clamp(0.95rem, min(11cqh, 4.6cqw), 2rem) * var(--card-font-scale, 1)); font-weight: 500; line-height: 1.15; color: var(--text); overflow-wrap: anywhere; }
.sh-headline:empty { display: none; }
/* The pill is dark with a dot in the state's colour, whatever the theme (the text colour is its background). */
.sh-pill { --sh-pill: var(--solar, #f59e0b); flex: 0 0 auto; align-self: flex-start; max-width: 100%; box-sizing: border-box; display: inline-flex; align-items: center; gap: 0.55em; padding: 0.4em 0.9em; border-radius: 999px;
  font-size: calc(clamp(0.65rem, min(7.5cqh, 3cqw), 0.95rem) * var(--card-font-scale, 1)); font-weight: 600; color: var(--bg, #fff); background: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sh-pill::before { content: ''; flex: 0 0 auto; width: 0.6em; height: 0.6em; border-radius: 50%; background: var(--sh-pill); }
.sh-pill:empty { display: none; }
.sh-art { flex: 1 1 0; min-height: 0; width: 100%; display: flex; align-items: center; justify-content: center; }
.sh-img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
/* Side by side: the words on the left (pill under them), the picture on the right. */
.system-hero-card[data-layout="side"] .sh-body { display: grid; grid-template-columns: minmax(0, 1fr) 42%; grid-template-rows: 1fr auto; grid-template-areas: "text art" "pill art"; column-gap: 0.8em; row-gap: 0.4em; }
.system-hero-card[data-layout="side"] .sh-text { grid-area: text; align-self: end; }
.system-hero-card[data-layout="side"] .sh-art { grid-area: art; height: 100%; }
.system-hero-card[data-layout="side"] .sh-pill { grid-area: pill; align-self: start; justify-self: start; }
.system-hero-card[data-layout="side"]:not(.sh-has-image) .sh-body { grid-template-columns: minmax(0, 1fr); grid-template-areas: "text" "pill"; }
/* A stacked card too short to hold the picture under the words is drawn side by side (when it is wide enough). */
@container (max-height: 210px) and (min-width: 261px) {
  .system-hero-card[data-layout="stacked"] .sh-body { display: grid; grid-template-columns: minmax(0, 1fr) 42%; grid-template-rows: 1fr auto; grid-template-areas: "text art" "pill art"; column-gap: 0.8em; row-gap: 0.4em; }
  .system-hero-card[data-layout="stacked"] .sh-text { grid-area: text; align-self: end; }
  .system-hero-card[data-layout="stacked"] .sh-art { grid-area: art; height: 100%; }
  .system-hero-card[data-layout="stacked"] .sh-pill { grid-area: pill; align-self: start; justify-self: start; }
  .system-hero-card[data-layout="stacked"]:not(.sh-has-image) .sh-body { grid-template-columns: minmax(0, 1fr); grid-template-areas: "text" "pill"; }
}
@container (max-width: 260px) { .system-hero-card[data-layout="side"] .sh-art { display: none; } }
@container (max-height: 80px) { .system-hero-card .sh-art { display: none; } }
@media (max-width: 768px) { .system-hero-card { min-height: 14rem; } .system-hero-card[data-layout="side"] { min-height: 8.5rem; } }

/* ── Speedometer ──────────────────────────────────────────── */
/* The face is a box with the dial's proportions (100 × 86); the reading is laid over its lower half, sized in the face's
   own units, so it scales with the dial. */
.speedometer-card { display: flex !important; flex-direction: column; align-items: center; gap: 0.35em; padding: var(--card-pad) !important; min-width: 0; height: 100%; width: 100%; box-sizing: border-box; container-type: size; }
.sp-head { flex: 0 0 auto; width: 100%; display: flex; align-items: baseline; justify-content: space-between; gap: 0.8em; }
.sp-title { font-size: calc(clamp(0.7rem, min(8cqh, 3cqw), 1rem) * var(--card-font-scale, 1)); font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-secondary); }
.sp-status { font-size: calc(clamp(0.65rem, min(8cqh, 3cqw), 0.95rem) * var(--card-font-scale, 1)); font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; white-space: nowrap; margin-left: auto; color: var(--text-secondary); }
.sp-status[data-rule="near-peak"] { color: var(--battery, #22c55e); }
.sp-status:empty { display: none; }
.sp-dial { flex: 1 1 0; min-height: 0; width: 100%; container-type: size; display: flex; align-items: center; justify-content: center; }
.sp-face { position: relative; width: min(100cqw, calc(100cqh * 100 / 86)); aspect-ratio: 100 / 86; container-type: size; }
.sp-svg { width: 100%; height: 100%; display: block; }
.sp-track { stroke: var(--text-secondary); opacity: 0.18; }
.sp-arc { stroke: var(--solar, #f59e0b); transition: stroke-dasharray 0.6s ease; }
.sp-tick { stroke: var(--text-secondary); opacity: 0.5; }
.sp-needle { transform-origin: 50px 52px; transform: rotate(150deg); transition: transform 0.6s ease; }
.sp-needle-line { stroke: var(--text); }
.sp-hub { fill: var(--text); }
.sp-read { position: absolute; left: 0; right: 0; top: 63%; display: flex; flex-direction: column; align-items: center; line-height: 1.05; pointer-events: none; }
.sp-main { display: flex; align-items: baseline; gap: 0.25em; white-space: nowrap; }
.sp-value { font-size: calc(13cqw * var(--card-font-scale, 1)); font-weight: 800; color: var(--text); font-variant-numeric: tabular-nums; }
.sp-unit { font-size: calc(6cqw * var(--card-font-scale, 1)); font-weight: 700; color: var(--text-secondary); }
.sp-of { font-size: calc(5.4cqw * var(--card-font-scale, 1)); color: var(--text-secondary); white-space: nowrap; font-variant-numeric: tabular-nums; }
.sp-end { position: absolute; top: 84%; transform: translateX(-50%); font-size: calc(5cqw * var(--card-font-scale, 1)); color: var(--text-secondary); font-variant-numeric: tabular-nums; pointer-events: none; }
.sp-end-min { left: 18.8%; }
.sp-end-max { left: 81.2%; }
.sp-hl { color: var(--solar, #f59e0b); font-weight: 800; }
.sp-caption { flex: 0 0 auto; font-size: calc(clamp(0.65rem, min(7cqh, 2.8cqw), 0.9rem) * var(--card-font-scale, 1)); color: var(--text-secondary); text-align: center; }
.sp-caption:empty { display: none; }
@container (max-height: 150px) { .sp-title { display: none; } }
@container (max-height: 110px) { .sp-end { display: none; } }
@media (max-width: 768px) { .speedometer-card { min-height: 16rem; } }

/* ── Flow rows ────────────────────────────────────────────── */
/* The rows share the card's height (--fr-rows is how many); a row is its label and value over a bar, sized from the row. */
.flow-rows-card { display: flex !important; flex-direction: column; gap: 0.4em; padding: var(--card-pad) !important; min-width: 0; height: 100%; width: 100%; box-sizing: border-box; container-type: size; }
.fr-title { flex: 0 0 auto; font-size: calc(clamp(0.7rem, 2.6cqi, 1rem) * var(--card-font-scale, 1)); font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-secondary); }
.fr-rows { flex: 1 1 0; min-height: 0; display: grid; grid-template-columns: max-content minmax(0, 1fr) max-content; grid-auto-rows: minmax(0, 1fr); align-items: center; column-gap: 1em; container-type: size; --fr-font: calc(clamp(0.45rem, min(100cqh / var(--fr-rows, 3) * 0.34, 100cqw * 0.07), 1.3rem) * var(--card-font-scale, 1)); font-size: var(--fr-font); }
/* A row is its label, its bar and its value on one line; the rows' cells sit in shared columns so the bars line up. */
.fr-row { display: contents; }
.fr-label { min-width: 0; max-width: 40cqw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); font-weight: 600; }
.fr-value { justify-self: end; color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.fr-row[data-state="idle"] .fr-value, .fr-row[data-state="unknown"] .fr-value { color: var(--text-secondary); }
.fr-bar { height: 0.8em; border-radius: 999px; background: color-mix(in srgb, var(--text-secondary) 16%, transparent); overflow: hidden; }
.fr-fill { display: block; height: 100%; width: 0; border-radius: inherit; transition: width 0.6s ease; }
.fr-row[data-state="idle"] .fr-fill, .fr-row[data-state="unknown"] .fr-fill { background: var(--text-secondary) !important; opacity: 0.55; }
.fr-no-bars .fr-bar { visibility: hidden; }
.fr-empty { color: var(--text-secondary); font-size: 0.85rem; padding: 0.5em; }
@container (max-height: 120px) { .fr-title { display: none; } }
@media (max-width: 768px) { .flow-rows-card { min-height: calc(var(--fr-rows, 3) * 3.2rem + 2.5rem); } }

/* ── Meter card ───────────────────────────────────────────── */
/* A label, the big value, a bar of segments, and up to two lines of words, sized from the card's height and width. */
.meter-card { --mt-color: var(--solar, #f59e0b); display: flex !important; flex-direction: column; justify-content: center; gap: 0.35em; padding: var(--card-pad) !important; min-width: 0; height: 100%; width: 100%; box-sizing: border-box; container-type: size; }
.mt-label { font-size: calc(clamp(0.6rem, min(10cqh, 3.2cqw), 0.95rem) * var(--card-font-scale, 1)); font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-secondary); }
.mt-main { display: flex; align-items: baseline; gap: 0.25em; white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--text); }
.mt-value { font-size: calc(clamp(1.2rem, min(30cqh, 16cqw), 3.4rem) * var(--card-font-scale, 1)); font-weight: 800; line-height: 1; }
.mt-prefix { font-size: calc(clamp(0.8rem, min(16cqh, 8cqw), 1.8rem) * var(--card-font-scale, 1)); font-weight: 700; color: var(--text-secondary); }
.mt-unit { font-size: calc(clamp(0.7rem, min(13cqh, 6.5cqw), 1.4rem) * var(--card-font-scale, 1)); font-weight: 700; color: var(--text-secondary); }
.mt-bar { --mt-fill: var(--mt-color); height: clamp(0.4rem, 8cqh, 1rem); border-radius: 999px; background: color-mix(in srgb, var(--text-secondary) 18%, transparent); overflow: hidden; }
.meter-card[data-band="low"] .mt-bar { --mt-fill: var(--bc-low, #ef4444); }
.meter-card[data-band="mid"] .mt-bar { --mt-fill: var(--bc-mid, #f59e0b); }
.meter-card[data-band="high"] .mt-bar { --mt-fill: var(--bc-high, #22c55e); }
.mt-fill { display: block; height: 100%; width: 0; background: var(--mt-fill); border-radius: inherit; transition: width 0.6s ease; }
.mt-bar.mt-segmented { display: grid; grid-template-columns: repeat(var(--mt-n, 10), minmax(0, 1fr)); gap: 0.18em; background: none; border-radius: 0; overflow: visible; }
.mt-seg { display: block; border-radius: 999px; background: color-mix(in srgb, var(--text-secondary) 18%, transparent); transition: background 0.4s ease; }
.mt-seg[data-on="1"] { background: var(--mt-fill); }
.mt-note { font-size: calc(clamp(0.6rem, min(9cqh, 3.2cqw), 0.9rem) * var(--card-font-scale, 1)); color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.mt-note:empty { display: none; }
@container (max-height: 90px) { .mt-note, .mt-label { display: none; } }
@media (max-width: 768px) { .meter-card { min-height: 7.5rem; } }

/* Device card: header (title, subtitle, picture), big value with a pill and a line, a bar, a trio of small readings, label/value rows. */
.device-card { --dv-color: var(--solar, #f59e0b); display: flex !important; flex-direction: column; gap: 0.5em; padding: var(--card-pad) !important; min-width: 0; height: 100%; width: 100%; box-sizing: border-box; container-type: inline-size; overflow: hidden; }
.dv-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.75em; }
.dv-words { min-width: 0; }
.dv-title { font-size: calc(clamp(0.85rem, 5.2cqw, 1.2rem) * var(--card-font-scale, 1)); font-weight: 700; color: var(--text); overflow-wrap: anywhere; }
.dv-subtitle { font-size: calc(clamp(0.7rem, 3.6cqw, 0.95rem) * var(--card-font-scale, 1)); color: var(--text-secondary); }
.dv-head .tile-icon.dv-art { flex: 0 0 auto; width: clamp(2.2rem, 16cqw, 4rem); height: clamp(2.2rem, 16cqw, 4rem); margin: 0; background: none; border-radius: 0; }
.dv-head .tile-icon.dv-art svg, .dv-head .tile-icon.dv-art img { width: 100%; height: 100%; object-fit: contain; }
.dv-main { display: flex; align-items: baseline; gap: 0.25em; white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--text); margin-top: 0.25em; }
.dv-value { font-size: calc(clamp(1.6rem, 14cqw, 3.4rem) * var(--card-font-scale, 1)); font-weight: 800; line-height: 1; }
.dv-prefix, .dv-unit { font-size: calc(clamp(0.8rem, 5.5cqw, 1.4rem) * var(--card-font-scale, 1)); font-weight: 700; color: var(--text-secondary); }
.dv-pill { align-self: flex-start; --dv-pill: var(--text-secondary); font-size: calc(clamp(0.7rem, 3.4cqw, 0.9rem) * var(--card-font-scale, 1)); font-weight: 600; padding: 0.25em 0.8em; border-radius: 999px; background: color-mix(in srgb, var(--text) 10%, transparent); color: var(--text); border: 1px solid color-mix(in srgb, var(--dv-pill) 40%, transparent); }
.dv-pill:empty { display: none; }
.dv-note, .dv-caption { font-size: calc(clamp(0.7rem, 3.4cqw, 0.9rem) * var(--card-font-scale, 1)); color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.dv-note:empty, .dv-caption:empty { display: none; }
.dv-bar { --dv-fill: var(--dv-color); height: 0.5rem; border-radius: 999px; background: color-mix(in srgb, var(--text-secondary) 18%, transparent); overflow: hidden; }
.device-card[data-band="low"] .dv-bar { --dv-fill: var(--bc-low, #ef4444); }
.device-card[data-band="mid"] .dv-bar { --dv-fill: var(--bc-mid, #f59e0b); }
.device-card[data-band="high"] .dv-bar { --dv-fill: var(--bc-high, #22c55e); }
.dv-fill { display: block; height: 100%; width: 0; background: var(--dv-fill); border-radius: inherit; transition: width 0.6s ease; }
.dv-stats { display: grid; grid-template-columns: repeat(var(--dv-n, 3), minmax(0, 1fr)); gap: 0.5em; padding-top: 0.6em; border-top: 1px solid var(--border); }
.dv-stat-label { font-size: calc(clamp(0.62rem, 3cqw, 0.8rem) * var(--card-font-scale, 1)); color: var(--text-secondary); }
.dv-stat-value { font-size: calc(clamp(0.8rem, 4.2cqw, 1.05rem) * var(--card-font-scale, 1)); font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text); }
.dv-rows { display: flex; flex-direction: column; gap: 0.3em; padding-top: 0.6em; border-top: 1px solid var(--border); }
.dv-row { display: flex; justify-content: space-between; gap: 0.75em; font-size: calc(clamp(0.72rem, 3.6cqw, 0.95rem) * var(--card-font-scale, 1)); }
.dv-row-label { color: var(--text-secondary); min-width: 0; overflow-wrap: anywhere; }
.dv-row-value { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text); white-space: nowrap; }

/* ── Status list ──────────────────────────────────────────── */
/* The rows share the card's height (--sl-rows is how many) and the text follows a row's height, limited by the width. */
.status-list-card { display: flex !important; flex-direction: column; gap: 0.4em; padding: var(--card-pad) !important; min-width: 0; height: 100%; width: 100%; box-sizing: border-box; container-type: size; }
.sl-head { flex: 0 0 auto; display: flex; align-items: baseline; justify-content: space-between; gap: 0.6em; }
.sl-title { font-size: calc(clamp(0.8rem, 2.6cqi, 1.05rem) * var(--card-font-scale, 1)); font-weight: 700; color: var(--text); text-transform: uppercase; letter-spacing: 0.04em; }
.sl-count { font-size: calc(clamp(0.65rem, 2cqi, 0.85rem) * var(--card-font-scale, 1)); color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.sl-rows { flex: 1 1 0; min-height: 0; display: flex; flex-direction: column; container-type: size; --sl-font: calc(clamp(0.45rem, min(100cqh / var(--sl-rows, 4) * 0.36, 100cqw * 0.075), 1.3rem) * var(--card-font-scale, 1)); }
.sl-row { flex: 1 1 0; min-height: 0; display: flex; align-items: center; gap: 0.7em; font-size: var(--sl-font); padding: 0 0.6em; border-radius: 0.5em; }
.sl-dot { flex: 0 0 auto; width: 0.8em; height: 0.8em; border-radius: 50%; background: color-mix(in srgb, var(--text-secondary) 45%, transparent); transition: background 0.3s ease, box-shadow 0.3s ease; }
.sl-row[data-state="on"] .sl-dot { background: var(--sl-on, #22c55e); box-shadow: 0 0 0.6em var(--sl-on, #22c55e); }
.sl-row[data-state="unknown"] .sl-dot { background: transparent; border: 1px solid color-mix(in srgb, var(--text-secondary) 55%, transparent); box-sizing: border-box; }
.sl-label { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-secondary); font-weight: 600; }
.sl-row[data-state="on"] .sl-label { color: var(--text); }
.sl-value { flex: 0 0 auto; color: var(--text); font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; }
.sl-value:empty { display: none; }
.sl-empty { color: var(--text-secondary); font-size: 0.85rem; padding: 0.5em; }
@container (max-height: 120px) { .sl-head .sl-title { display: none; } }
@media (max-width: 768px) { .status-list-card { min-height: calc(var(--sl-rows, 4) * 2.6rem + 3rem); } }

/* ── History and threshold bars ───────────────────────────── */
.bar-single-card, .bar-stacked-card, .bar-threshold-card {
  display: flex !important; flex-direction: column !important;
  align-items: stretch !important; justify-content: flex-start !important; text-align: left !important;
  gap: var(--card-gap); padding: var(--card-pad) !important;
}
.bar-single-title, .bar-stacked-title, .bar-threshold-title {
  margin: 0 !important; font-size: calc(clamp(0.8rem, 2.6cqi, 0.95rem) * var(--card-font-scale, 1)) !important; font-weight: 700 !important; color: var(--text) !important; text-align: left;
}
.bar-single-body, .bar-stacked-body { flex: 1 1 auto; min-height: 60px !important; align-self: stretch; gap: clamp(1px, 0.6cqi, 4px) !important; }
.bar-single-bar, .bar-stacked-body > * { border-radius: 3px 3px 0 0; }
.bar-single-status, .bar-stacked-status { font-style: normal !important; font-size: calc(0.82rem * var(--card-font-scale, 1)); }

/* ── Savings ──────────────────────────────────────────────── */
/* Same columns and sizing as the grid card's tiles (below), so a long total
   such as ₦1,894,880 isn't cut off. */
.savings-block-container .ep-tiles { grid-template-columns: repeat(var(--grid-cols, 4), minmax(0, 1fr)) !important; --tile-chars: 7; }

/* ── Grid status ──────────────────────────────────────────── */
.grid-card.ep-card { gap: var(--card-gap); padding: var(--card-pad); }
/* Only the bars give up height when the card is short; the rest keeps its own. */
.grid-card.ep-card > * { flex-shrink: 0; }
.grid-card.ep-card > .ep-grid-days { flex-shrink: 1; }
.ep-grid-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.grid-card .grid-date { margin: 0 !important; font-size: calc(0.72rem * var(--card-font-scale, 1)) !important; font-weight: 500 !important; color: var(--text-secondary) !important; }
.ep-grid-now { display: flex; align-items: baseline; gap: 0.6em; flex-wrap: wrap; }
.ep-grid-state { font-size: calc(clamp(1.15rem, 6cqi, 1.8rem) * var(--card-font-scale, 1)); font-weight: 800; color: var(--text-secondary); }
.ep-grid-state[data-state="on"] { color: var(--color-battery); }
.ep-grid-state[data-state="off"] { color: var(--color-grid); }
.ep-grid-since { font-size: calc(0.78rem * var(--card-font-scale, 1)) !important; color: var(--text-secondary); opacity: 1 !important; }
.ep-grid-hours-title { margin-top: 2px; }
.grid-card :is([id^="grid-timeline"], [id^="generator-timeline"]) { overflow: hidden; }
.grid-card .grid-stats { display: grid !important; grid-template-columns: repeat(auto-fit, minmax(min(100%, 72px), 1fr)); flex: 0 0 auto; }
/* One row of tiles where they fit; on narrower cards 2 × 2 (four) or 3 + 2
   (five). The numbers shrink with the column, never below 0.8rem, so a long
   total such as 3210:00 isn't clipped; wide cards keep the usual size. */
.grid-card .grid-stats { grid-template-columns: repeat(var(--grid-cols, 4), minmax(0, 1fr)) !important; }
:is(.grid-card .grid-stats, .savings-block-container .ep-tiles)[data-count="1"] { --grid-cols: 1; }
:is(.grid-card .grid-stats, .savings-block-container .ep-tiles)[data-count="2"] { --grid-cols: 2; }
:is(.grid-card .grid-stats, .savings-block-container .ep-tiles)[data-count="3"] { --grid-cols: 3; }
:is(.grid-card .grid-stats, .savings-block-container .ep-tiles)[data-count="5"] { --grid-cols: 5; }
@container (max-width: 699px) { :is(.grid-card .grid-stats, .savings-block-container .ep-tiles)[data-count="5"] { --grid-cols: 3; } }
@container (max-width: 559px) { .grid-card .grid-stats[data-count="4"] { --grid-cols: 2; } }
/* Savings tiles carry no second line, so four stay in a row longer. */
@container (max-width: 399px) { .savings-block-container .ep-tiles[data-count="4"] { --grid-cols: 2; } }
@container (max-width: 299px) { :is(.grid-card .grid-stats, .savings-block-container .ep-tiles):is([data-count="3"], [data-count="5"]) { --grid-cols: 2; } }
:is(.grid-card .grid-stats, .savings-block-container .ep-tiles) > .ep-tile .ep-value { font-size: calc(clamp(0.8rem, min(4.6cqi, (100cqi - 3rem) / var(--grid-cols, 4) / var(--tile-chars, 5.4)), 1.6rem) * var(--card-font-scale, 1)); }
:is(.grid-card .grid-stats, .savings-block-container .ep-tiles) > .ep-tile { min-width: 0; }
:is(.grid-card .grid-stats, .savings-block-container .ep-tiles) > .ep-tile .ep-value { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ep-grid-cost { display: block; margin-top: 2px; font-size: calc(0.74rem * var(--card-font-scale, 1)); font-weight: 600; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Grid hours per day: one bar per day, out of 24 h; today is still running. */
.ep-grid-days-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-top: 2px; }
/* The day range uses the charts' .chart-controls look. */
.ep-grid-range { display: inline-flex; }
.ep-grid-range button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
/* The bars take the card's spare height (64px at least, 240px at most). */
.ep-grid-days { position: relative; display: flex; align-items: flex-end; gap: clamp(1px, 0.8cqi, 4px); flex: 1 1 64px; min-height: 64px; max-height: 240px; margin-right: 30px; border-bottom: 1px solid var(--border); }
.ep-grid-days::before, .ep-grid-days::after { content: ""; position: absolute; left: 0; right: 0; border-top: 1px dashed var(--border); pointer-events: none; }
.ep-grid-days::before { top: 0; }
.ep-grid-days::after { top: 50%; }
.ep-grid-days-y { position: absolute; left: calc(100% + 4px); transform: translateY(-50%); font-size: calc(0.62rem * var(--card-font-scale, 1)); color: var(--text-secondary); white-space: nowrap; }
.ep-grid-day { flex: 1 1 0; position: relative; z-index: 1; min-width: 2px; border-radius: 3px 3px 0 0; background: var(--success); cursor: pointer; }
.ep-grid-day.today { background: repeating-linear-gradient(45deg, var(--success) 0 4px, color-mix(in srgb, var(--success) 45%, transparent) 4px 8px); }
.ep-grid-day.none, .ep-grid-day.unknown { height: 2px !important; background: var(--border); }
.ep-grid-day:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.ep-grid-days-axis { display: flex; justify-content: space-between; margin-right: 30px; font-size: calc(0.68rem * var(--card-font-scale, 1)); color: var(--text-secondary); }
.ep-grid-days-sum { font-size: calc(0.74rem * var(--card-font-scale, 1)); color: var(--text-secondary); min-height: 1.3em; }
.ep-grid-days-sum b { color: var(--text); }

/* ── Text and embeds ──────────────────────────────────────── */
.text-card.ep-card { white-space: pre-wrap; word-break: break-word; font-size: calc(clamp(0.85rem, 2.8cqi, 1rem) * var(--card-font-scale, 1)); line-height: 1.55; color: var(--text); overflow: auto; }
.text-card.ep-card.ep-card-empty { white-space: normal; color: var(--text-secondary); }
.iframe-card iframe { width: 100%; height: 100%; border: 0; display: block; border-radius: inherit; }

/* ── Charts ───────────────────────────────────────────────── */
.chart-container { padding: var(--card-pad) !important; gap: 4px; }
.chart-header { margin-bottom: 4px !important; gap: 8px; flex-wrap: wrap; }
.chart-controls { gap: 2px !important; padding: 2px; border-radius: 10px; background: var(--bg); border: 1px solid var(--border); }
.chart-controls button {
  min-height: 28px !important; min-width: 0 !important; padding: 0 10px !important;
  border: none !important; border-radius: 8px !important; background: none !important;
  color: var(--text-secondary) !important; font-size: calc(0.75rem * var(--card-font-scale, 1)) !important; font-weight: 700;
}
.chart-controls button:hover { color: var(--text) !important; }
.chart-controls button.active { background: var(--card-bg) !important; color: var(--text) !important; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12); }
.chart-empty { text-align: center; font-size: calc(0.82rem * var(--card-font-scale, 1)); color: var(--text-secondary); padding: 8px; }

/* ── Tables ───────────────────────────────────────────────── */
.daily-breakdown-container { padding: var(--card-pad) !important; }
.energy-table th { font-size: calc(0.72rem * var(--card-font-scale, 1)); font-weight: 700; color: var(--text-secondary); }
.energy-table td { font-variant-numeric: tabular-nums; }

/* ── Flow squares: fit the block instead of fixed paddings ── */
.flow-card-square, .flow-card-square2 { padding: var(--card-pad) !important; overflow: hidden; }
.fcs-grid, .fcs2-grid { height: 100%; gap: var(--card-gap) !important; }
.fcs-cell, .fcs2-cell { padding: clamp(4px, 2.5cqi, 16px) !important; min-width: 0; min-height: 0; }
.fcs-icon, .fcs2-icon { font-size: calc(clamp(1.6rem, 9cqi, 3rem) * var(--card-font-scale, 1)) !important; width: auto !important; }
.fcs-inverter-icon, .fcs2-inv { width: clamp(1.8rem, 9cqi, 3rem) !important; height: clamp(2.6rem, 14cqi, 5rem) !important; color: var(--color-text-on-accent, #111) !important; }
.fcs-label, .fcs2-label { font-size: calc(clamp(0.62rem, 2.2cqi, 0.75rem) * var(--card-font-scale, 1)) !important; }
.fcs-value, .fcs2-value { font-size: calc(clamp(0.85rem, 4.2cqi, 1.3rem) * var(--card-font-scale, 1)) !important; font-variant-numeric: tabular-nums; }
.fcs-sub, .fcs2-sub { font-size: calc(clamp(0.62rem, 2.4cqi, 0.8rem) * var(--card-font-scale, 1)) !important; }

/* Flow card (four nodes) */
.flow-value { font-size: calc(clamp(1rem, 5cqi, 1.7rem) * var(--card-font-scale, 1)) !important; font-variant-numeric: tabular-nums; white-space: nowrap; }
.flow-label { font-size: calc(clamp(0.72rem, 2.4cqi, 0.85rem) * var(--card-font-scale, 1)) !important; }
.flow-icon { font-size: calc(clamp(1.4rem, 7cqi, 2.4rem) * var(--card-font-scale, 1)); }

/* ── Controls ─────────────────────────────────────────────── */
.toggle-switch.action-toggle .slider { background: var(--switch-off-color, #a8a59e) !important; }
[data-theme="dark"] .toggle-switch.action-toggle .slider { background: var(--switch-off-color, #4a4a4a) !important; }
.toggle-switch.action-toggle input:checked + .slider { background: var(--switch-on-color, #3a8c4f) !important; }
[data-theme="dark"] .toggle-switch.action-toggle input:checked + .slider { background: var(--switch-on-color, #4da863) !important; }
.toggle-switch.action-toggle .slider::before { background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .15); }
[data-theme="dark"] .toggle-switch.action-toggle .slider::before { background: #111111; }
.toggle-switch.action-toggle input:focus-visible + .slider { outline: 2px solid var(--st-amber-text, #b45309); outline-offset: 2px; }
.switch-block { padding: var(--card-pad) !important; }
.state-select-block { padding: var(--card-pad) !important; overflow: auto; }

/* ── Forecast and weather: quieter error notices ──────────── */
.fc-error, .wx-error {
  font-size: calc(0.8rem * var(--card-font-scale, 1)) !important; color: var(--text-secondary) !important;
  padding: 8px 10px; border-radius: 8px; background: var(--bg); border: 1px dashed var(--border);
}

/* Phones: blocks stack and lose their fixed height, so cards that draw
   to their height get a sensible minimum. */
@media (max-width: 768px) {
  .dashboard-block > .ep-gauge { min-height: 180px; }
  .dashboard-block > .bar-single-card, .dashboard-block > .bar-stacked-card { min-height: 180px; }
  .dashboard-block > .chart-container { min-height: 260px; }
  .dashboard-block > .flow-card-square, .dashboard-block > .flow-card-square2 { min-height: 280px; }
  .dashboard-block > .iframe-card { min-height: 300px; }
}
/* Built-in icons for the .fi icon classes (replaces the external icon font). */
.fi { display: inline-block; width: 1em; height: 1em; vertical-align: -0.125em; background-color: currentColor; -webkit-mask: var(--fi) center / contain no-repeat; mask: var(--fi) center / contain no-repeat; font-style: normal; }
.fi::before { content: none !important; }
.fi-sr-solar-panel { --fi: url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 24 24%22%3E%3Cpath d=%22M3 15l2.5-10h13L21 15z%22 stroke=%22black%22 stroke-width=%221.8%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22 fill=%22none%22/%3E%3Cpath d=%22M4.3 10h15.4M9.5 5l-1 10M14.5 5l1 10M12 15v4M8 19h8%22 stroke=%22black%22 stroke-width=%221.8%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22 fill=%22none%22/%3E%3C/svg%3E"); }
.fi-sr-battery-full { --fi: url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 24 24%22%3E%3Crect x=%226%22 y=%225%22 width=%2212%22 height=%2214%22 rx=%222%22 stroke=%22black%22 stroke-width=%221.8%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22 fill=%22none%22/%3E%3Cpath d=%22M10 3h4%22 stroke=%22black%22 stroke-width=%221.8%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22 fill=%22none%22/%3E%3Crect x=%227.5%22 y=%227.5%22 width=%229%22 height=%2210.0%22 rx=%221%22 fill=%22black%22/%3E%3C/svg%3E"); }
.fi-sr-battery-three-quarters { --fi: url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 24 24%22%3E%3Crect x=%226%22 y=%225%22 width=%2212%22 height=%2214%22 rx=%222%22 stroke=%22black%22 stroke-width=%221.8%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22 fill=%22none%22/%3E%3Cpath d=%22M10 3h4%22 stroke=%22black%22 stroke-width=%221.8%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22 fill=%22none%22/%3E%3Crect x=%227.5%22 y=%2210.0%22 width=%229%22 height=%227.5%22 rx=%221%22 fill=%22black%22/%3E%3C/svg%3E"); }
.fi-sr-battery-half { --fi: url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 24 24%22%3E%3Crect x=%226%22 y=%225%22 width=%2212%22 height=%2214%22 rx=%222%22 stroke=%22black%22 stroke-width=%221.8%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22 fill=%22none%22/%3E%3Cpath d=%22M10 3h4%22 stroke=%22black%22 stroke-width=%221.8%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22 fill=%22none%22/%3E%3Crect x=%227.5%22 y=%2212.5%22 width=%229%22 height=%225.0%22 rx=%221%22 fill=%22black%22/%3E%3C/svg%3E"); }
.fi-sr-battery-quarter { --fi: url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 24 24%22%3E%3Crect x=%226%22 y=%225%22 width=%2212%22 height=%2214%22 rx=%222%22 stroke=%22black%22 stroke-width=%221.8%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22 fill=%22none%22/%3E%3Cpath d=%22M10 3h4%22 stroke=%22black%22 stroke-width=%221.8%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22 fill=%22none%22/%3E%3Crect x=%227.5%22 y=%2215.0%22 width=%229%22 height=%222.5%22 rx=%221%22 fill=%22black%22/%3E%3C/svg%3E"); }
.fi-sr-battery-empty { --fi: url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 24 24%22%3E%3Crect x=%226%22 y=%225%22 width=%2212%22 height=%2214%22 rx=%222%22 stroke=%22black%22 stroke-width=%221.8%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22 fill=%22none%22/%3E%3Cpath d=%22M10 3h4%22 stroke=%22black%22 stroke-width=%221.8%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22 fill=%22none%22/%3E%3C/svg%3E"); }
.fi-sr-home { --fi: url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 24 24%22%3E%3Cpath d=%22M3 11l9-7 9 7%22 stroke=%22black%22 stroke-width=%221.8%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22 fill=%22none%22/%3E%3Cpath d=%22M5 9.5V20h14V9.5%22 stroke=%22black%22 stroke-width=%221.8%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22 fill=%22none%22/%3E%3Cpath d=%22M10 20v-5h4v5%22 stroke=%22black%22 stroke-width=%221.8%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22 fill=%22none%22/%3E%3C/svg%3E"); }
.fi-sr-bolt { --fi: url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 24 24%22%3E%3Cpath d=%22M13 2L4 14h7l-1 8 9-12h-7z%22 fill=%22black%22/%3E%3C/svg%3E"); }
.fi-sr-cloud { --fi: url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 24 24%22%3E%3Cpath d=%22M7 18h10a4 4 0 00.5-8 6 6 0 00-11.4 1.5A3.3 3.3 0 007 18z%22 stroke=%22black%22 stroke-width=%221.8%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22 fill=%22none%22/%3E%3C/svg%3E"); }
.fi-sr-clouds { --fi: url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 24 24%22%3E%3Cpath d=%22M6 19h10a3.5 3.5 0 00.4-7 5 5 0 00-9.6 1.2A2.9 2.9 0 006 19z%22 stroke=%22black%22 stroke-width=%221.8%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22 fill=%22none%22/%3E%3Cpath d=%22M9 7.5A5 5 0 0118.5 9a3.5 3.5 0 012.5 3.4%22 stroke=%22black%22 stroke-width=%221.8%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22 fill=%22none%22/%3E%3C/svg%3E"); }
.fi-sr-cloud-sun { --fi: url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 24 24%22%3E%3Cpath d=%22M8 19h9a3.5 3.5 0 00.4-7 5 5 0 00-9.6 1.2A2.9 2.9 0 008 19z%22 stroke=%22black%22 stroke-width=%221.8%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22 fill=%22none%22/%3E%3Cpath d=%22M7 10.5a3.5 3.5 0 015-4.6M7 3v1.5M2.5 7.5H4M3.8 3.8l1 1%22 stroke=%22black%22 stroke-width=%221.8%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22 fill=%22none%22/%3E%3C/svg%3E"); }
.fi-sr-cloud-moon { --fi: url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 24 24%22%3E%3Cpath d=%22M8 19h9a3.5 3.5 0 00.4-7 5 5 0 00-9.6 1.2A2.9 2.9 0 008 19z%22 stroke=%22black%22 stroke-width=%221.8%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22 fill=%22none%22/%3E%3Cpath d=%22M9.5 6.5A4 4 0 014 10.5a4 4 0 015.5-4z%22 stroke=%22black%22 stroke-width=%221.8%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22 fill=%22none%22/%3E%3C/svg%3E"); }
.fi-sr-cloud-rain { --fi: url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 24 24%22%3E%3Cpath d=%22M7 15h10a4 4 0 00.5-8 6 6 0 00-11.4 1.5A3.3 3.3 0 007 15z%22 stroke=%22black%22 stroke-width=%221.8%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22 fill=%22none%22/%3E%3Cpath d=%22M8 18l-1 3M12 18l-1 3M16 18l-1 3%22 stroke=%22black%22 stroke-width=%221.8%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22 fill=%22none%22/%3E%3C/svg%3E"); }
.fi-sr-cloud-snow { --fi: url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 24 24%22%3E%3Cpath d=%22M7 15h10a4 4 0 00.5-8 6 6 0 00-11.4 1.5A3.3 3.3 0 007 15z%22 stroke=%22black%22 stroke-width=%221.8%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22 fill=%22none%22/%3E%3Cpath d=%22M8 19h.01M12 19h.01M16 19h.01M10 21.5h.01M14 21.5h.01%22 stroke=%22black%22 stroke-width=%221.8%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22 fill=%22none%22 stroke-width=%222.6%22/%3E%3C/svg%3E"); }
.fi-sr-thunderstorm { --fi: url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 24 24%22%3E%3Cpath d=%22M7 14h10a4 4 0 00.5-8 6 6 0 00-11.4 1.5A3.3 3.3 0 007 14z%22 stroke=%22black%22 stroke-width=%221.8%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22 fill=%22none%22/%3E%3Cpath d=%22M12.5 15l-2.5 4h3l-2 4%22 stroke=%22black%22 stroke-width=%221.8%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22 fill=%22none%22/%3E%3C/svg%3E"); }
/* Weather icons for every code weatherFormat.js and the server can return. */
.fi-sr-cloud-drizzle { --fi: url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 24 24%22%3E%3Cpath d=%22M7 15h10a4 4 0 00.5-8 6 6 0 00-11.4 1.5A3.3 3.3 0 007 15z%22 stroke=%22black%22 stroke-width=%221.8%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22 fill=%22none%22/%3E%3Cpath d=%22M8 18.5v.01M12 18.5v.01M16 18.5v.01M10 21.5v.01M14 21.5v.01%22 stroke=%22black%22 stroke-width=%222.4%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22 fill=%22none%22/%3E%3C/svg%3E"); }
.fi-sr-cloud-hail { --fi: url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 24 24%22%3E%3Cpath d=%22M7 15h10a4 4 0 00.5-8 6 6 0 00-11.4 1.5A3.3 3.3 0 007 15z%22 stroke=%22black%22 stroke-width=%221.8%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22 fill=%22none%22/%3E%3Cpath d=%22M8 19v.01M12 19v.01M16 19v.01M10 22v.01M14 22v.01%22 stroke=%22black%22 stroke-width=%223%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22 fill=%22none%22/%3E%3C/svg%3E"); }
.fi-sr-cloud-showers { --fi: url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 24 24%22%3E%3Cpath d=%22M7 15h10a4 4 0 00.5-8 6 6 0 00-11.4 1.5A3.3 3.3 0 007 15z%22 stroke=%22black%22 stroke-width=%221.8%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22 fill=%22none%22/%3E%3Cpath d=%22M8 17.5l-1.5 4M12 17.5l-1.5 4M16 17.5l-1.5 4%22 stroke=%22black%22 stroke-width=%221.8%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22 fill=%22none%22/%3E%3C/svg%3E"); }
.fi-sr-cloud-showers-heavy { --fi: url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 24 24%22%3E%3Cpath d=%22M7 15h10a4 4 0 00.5-8 6 6 0 00-11.4 1.5A3.3 3.3 0 007 15z%22 stroke=%22black%22 stroke-width=%221.8%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22 fill=%22none%22/%3E%3Cpath d=%22M7 17.5l-1.5 4.5M10.5 17.5L9 22M14 17.5L12.5 22M17.5 17.5L16 22%22 stroke=%22black%22 stroke-width=%221.8%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22 fill=%22none%22/%3E%3C/svg%3E"); }
.fi-sr-cloud-sleet { --fi: url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 24 24%22%3E%3Cpath d=%22M7 15h10a4 4 0 00.5-8 6 6 0 00-11.4 1.5A3.3 3.3 0 007 15z%22 stroke=%22black%22 stroke-width=%221.8%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22 fill=%22none%22/%3E%3Cpath d=%22M8 18l-1 3M16 18l-1 3%22 stroke=%22black%22 stroke-width=%221.8%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22 fill=%22none%22/%3E%3Cpath d=%22M12 18.5v.01M12 21.5v.01%22 stroke=%22black%22 stroke-width=%222.4%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22 fill=%22none%22/%3E%3C/svg%3E"); }
.fi-sr-cloud-sun-rain { --fi: url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 24 24%22%3E%3Cpath d=%22M9 15h8.5a3.5 3.5 0 00.4-7 5 5 0 00-9.6 1.2A2.9 2.9 0 009 15z%22 stroke=%22black%22 stroke-width=%221.8%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22 fill=%22none%22/%3E%3Cpath d=%22M6.5 9a3 3 0 014.3-4M6.5 2v1.3M2 6.5h1.3M3.3 3.3l.9.9%22 stroke=%22black%22 stroke-width=%221.8%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22 fill=%22none%22/%3E%3Cpath d=%22M10 18l-1 3M14 18l-1 3M18 18l-1 3%22 stroke=%22black%22 stroke-width=%221.8%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22 fill=%22none%22/%3E%3C/svg%3E"); }
.fi-sr-cloud-moon-rain { --fi: url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 24 24%22%3E%3Cpath d=%22M9 15h8.5a3.5 3.5 0 00.4-7 5 5 0 00-9.6 1.2A2.9 2.9 0 009 15z%22 stroke=%22black%22 stroke-width=%221.8%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22 fill=%22none%22/%3E%3Cpath d=%22M9.5 4.5A3.5 3.5 0 015 9a3.5 3.5 0 014.5-4.5z%22 stroke=%22black%22 stroke-width=%221.8%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22 fill=%22none%22/%3E%3Cpath d=%22M10 18l-1 3M14 18l-1 3M18 18l-1 3%22 stroke=%22black%22 stroke-width=%221.8%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22 fill=%22none%22/%3E%3C/svg%3E"); }
.fi-sr-cloud-question { --fi: url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 24 24%22%3E%3Cpath d=%22M7 18h10a4 4 0 00.5-8 6 6 0 00-11.4 1.5A3.3 3.3 0 007 18z%22 stroke=%22black%22 stroke-width=%221.8%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22 fill=%22none%22/%3E%3Cpath d=%22M10.6 11.6a1.5 1.5 0 112.6 1c-.6.4-1.2.7-1.2 1.4M12 16.3v.01%22 stroke=%22black%22 stroke-width=%221.8%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22 fill=%22none%22/%3E%3C/svg%3E"); }
.fi-sr-moon-stars { --fi: url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 24 24%22%3E%3Cpath d=%22M20 14.5A8 8 0 019.5 4 8 8 0 1020 14.5z%22 stroke=%22black%22 stroke-width=%221.8%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22 fill=%22none%22/%3E%3Cpath d=%22M17 2.5v3M15.5 4h3M20.5 8v2M19.5 9h2%22 stroke=%22black%22 stroke-width=%221.8%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22 fill=%22none%22/%3E%3C/svg%3E"); }
.fi-sr-snowflake { --fi: url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 24 24%22%3E%3Cpath d=%22M12 3v18M4.2 7.5l15.6 9M4.2 16.5l15.6-9M10 4.5l2 1.5 2-1.5M10 19.5l2-1.5 2 1.5%22 stroke=%22black%22 stroke-width=%221.8%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22 fill=%22none%22/%3E%3C/svg%3E"); }
.fi-sr-snowflakes { --fi: url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 24 24%22%3E%3Cpath d=%22M10 3v14M4 6.5l12 7M4 13.5l12-7%22 stroke=%22black%22 stroke-width=%221.8%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22 fill=%22none%22/%3E%3Cpath d=%22M18.5 15v6M16 16.5l5 3M16 19.5l5-3%22 stroke=%22black%22 stroke-width=%221.8%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22 fill=%22none%22/%3E%3C/svg%3E"); }
.fi-sr-thunderstorm-sun { --fi: url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 24 24%22%3E%3Cpath d=%22M9 15h8.5a3.5 3.5 0 00.4-7 5 5 0 00-9.6 1.2A2.9 2.9 0 009 15z%22 stroke=%22black%22 stroke-width=%221.8%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22 fill=%22none%22/%3E%3Cpath d=%22M6.5 9a3 3 0 014.3-4M6.5 2v1.3M2 6.5h1.3M3.3 3.3l.9.9%22 stroke=%22black%22 stroke-width=%221.8%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22 fill=%22none%22/%3E%3Cpath d=%22M14.5 15l-2.5 4h3l-2 4%22 stroke=%22black%22 stroke-width=%221.8%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22 fill=%22none%22/%3E%3C/svg%3E"); }
.fi-sr-thunderstorm-moon { --fi: url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 24 24%22%3E%3Cpath d=%22M9 15h8.5a3.5 3.5 0 00.4-7 5 5 0 00-9.6 1.2A2.9 2.9 0 009 15z%22 stroke=%22black%22 stroke-width=%221.8%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22 fill=%22none%22/%3E%3Cpath d=%22M9.5 4.5A3.5 3.5 0 015 9a3.5 3.5 0 014.5-4.5z%22 stroke=%22black%22 stroke-width=%221.8%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22 fill=%22none%22/%3E%3Cpath d=%22M14.5 15l-2.5 4h3l-2 4%22 stroke=%22black%22 stroke-width=%221.8%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22 fill=%22none%22/%3E%3C/svg%3E"); }
.fi-sr-fog { --fi: url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 24 24%22%3E%3Cpath d=%22M7 12h10a3.5 3.5 0 00.4-7 5 5 0 00-9.6 1.2A2.9 2.9 0 007 12z%22 stroke=%22black%22 stroke-width=%221.8%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22 fill=%22none%22/%3E%3Cpath d=%22M4 16h16M6 20h12%22 stroke=%22black%22 stroke-width=%221.8%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22 fill=%22none%22/%3E%3C/svg%3E"); }
.fi-sr-moon { --fi: url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 24 24%22%3E%3Cpath d=%22M20 14.5A8 8 0 019.5 4 8 8 0 1020 14.5z%22 stroke=%22black%22 stroke-width=%221.8%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22 fill=%22none%22/%3E%3C/svg%3E"); }
.fi-sr-sun { --fi: url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 24 24%22%3E%3Ccircle cx=%2212%22 cy=%2212%22 r=%224%22 stroke=%22black%22 stroke-width=%221.8%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22 fill=%22none%22/%3E%3Cpath d=%22M12 2v2M12 20v2M2 12h2M20 12h2M5 5l1.4 1.4M17.6 17.6L19 19M5 19l1.4-1.4M17.6 6.4L19 5%22 stroke=%22black%22 stroke-width=%221.8%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22 fill=%22none%22/%3E%3C/svg%3E"); }
.fi-sr-sun-dust { --fi: url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 24 24%22%3E%3Ccircle cx=%2210%22 cy=%2210%22 r=%223.5%22 stroke=%22black%22 stroke-width=%221.8%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22 fill=%22none%22/%3E%3Cpath d=%22M10 2.5V4M2.5 10H4M4.7 4.7l1 1M15.3 4.7l-1 1M14 16h7M11 19.5h9M4 16h4%22 stroke=%22black%22 stroke-width=%221.8%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22 fill=%22none%22/%3E%3C/svg%3E"); }
.fi-sr-sunrise { --fi: url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 24 24%22%3E%3Cpath d=%22M5 16a7 7 0 0114 0M2 20h20M12 3v5M9 6l3-3 3 3%22 stroke=%22black%22 stroke-width=%221.8%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22 fill=%22none%22/%3E%3C/svg%3E"); }
.fi-sr-sunset { --fi: url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 24 24%22%3E%3Cpath d=%22M5 16a7 7 0 0114 0M2 20h20M12 8V3M9 5l3 3 3-3%22 stroke=%22black%22 stroke-width=%221.8%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22 fill=%22none%22/%3E%3C/svg%3E"); }
.fi-sr-temperature-high { --fi: url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 24 24%22%3E%3Cpath d=%22M10 14.5V4.5a2 2 0 014 0v10a4 4 0 11-4 0z%22 stroke=%22black%22 stroke-width=%221.8%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22 fill=%22none%22/%3E%3Cpath d=%22M12 9v7%22 stroke=%22black%22 stroke-width=%221.8%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22 fill=%22none%22/%3E%3C/svg%3E"); }
.fi-sr-humidity { --fi: url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 24 24%22%3E%3Cpath d=%22M12 3s6 6.5 6 11a6 6 0 01-12 0c0-4.5 6-11 6-11z%22 stroke=%22black%22 stroke-width=%221.8%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22 fill=%22none%22/%3E%3C/svg%3E"); }
.fi-sr-wind { --fi: url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 24 24%22%3E%3Cpath d=%22M3 8h11a3 3 0 10-3-3M3 12h15a3 3 0 11-3 3M3 16h7%22 stroke=%22black%22 stroke-width=%221.8%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22 fill=%22none%22/%3E%3C/svg%3E"); }
.fi-sr-umbrella { --fi: url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 24 24%22%3E%3Cpath d=%22M3 12a9 9 0 0118 0z%22 stroke=%22black%22 stroke-width=%221.8%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22 fill=%22none%22/%3E%3Cpath d=%22M12 12v7a2 2 0 01-4 0%22 stroke=%22black%22 stroke-width=%221.8%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22 fill=%22none%22/%3E%3C/svg%3E"); }
.fi-sr-tachometer-average { --fi: url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 24 24%22%3E%3Cpath d=%22M4 17a8 8 0 1116 0%22 stroke=%22black%22 stroke-width=%221.8%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22 fill=%22none%22/%3E%3Cpath d=%22M12 17l3-5%22 stroke=%22black%22 stroke-width=%221.8%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22 fill=%22none%22/%3E%3C/svg%3E"); }

/* PV Today weather row: one icon and one cloud bar per hour, aligned. */
.pvt-timeline-icons { display: flex !important; justify-content: stretch !important; gap: 2px; padding: 0 !important; margin-bottom: 4px !important; }
.pvt-timeline-icons > .pvt-timeline-icon { flex: 1 1 0; min-width: 0; display: flex; justify-content: center; font-size: calc(clamp(0.8rem, 3.4cqi, 1.3rem) * var(--card-font-scale, 1)) !important; overflow: hidden; }
.pvt-timeline-icons > .pvt-timeline-icon .wx-ic { font-size: inherit !important; }
.pvt-timeline-bar { display: flex; gap: 2px; margin-bottom: 6px; }
.pvt-timeline-seg { flex: 1 1 0; height: 4px; border-radius: 2px; }

/* ── Configurable gauge ──────────────────────────────────────
   Shared card surface; the dial fits the block's width AND height
   (it used to be sized by width only and got cut off in short blocks);
   the readout scales with the dial unless a size is set. */
.configurable-gauge-card {
  display: flex; flex-direction: column; align-items: center;
  container-type: size;
  background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius, 12px);
  padding: var(--card-pad) !important; gap: 4px !important;
}
.configurable-gauge-title { align-self: stretch; text-align: left; }
.configurable-gauge-viz {
  position: relative; flex: 0 0 auto; margin: auto;
  width: min(100cqw - 2 * var(--card-pad), var(--cg-size, 400px), 100cqh - 2 * var(--card-pad) - 1.6em);
  aspect-ratio: 1; container-type: inline-size;
}
.configurable-gauge-readout {
  /* Position and default size come from innerLayout() (inside the ring's hole). */
  position: absolute; display: flex; align-items: center; justify-content: center; gap: 0.15em;
  text-align: center; color: var(--text); white-space: nowrap; line-height: 1;
}
.configurable-gauge-history { position: absolute; max-height: none !important; overflow: hidden; }

/* ── Metric Trend / Dual metric: text follows the card size and the
   Text size setting unless the person set an explicit size. ── */
.metric-trend-card .metric-trend-value { font-size: calc(var(--mt-value-size, clamp(1.4rem, 15cqi, 3.2rem)) * var(--card-font-scale, 1)); }
.metric-trend-card .metric-trend-unit { font-size: calc(var(--mt-unit-size, clamp(0.8rem, 6cqi, 1.4rem)) * var(--card-font-scale, 1)); color: var(--text-secondary); }
.metric-trend-card { container-type: inline-size; }
.metric-trend-header .metric-trend-title { flex: 1 1 auto; }
.metric-trend-graph-unit { display: none; }
.metric-trend-context { font-size: calc(0.75rem * var(--card-font-scale, 1)); }

.dual-metric-title { font-size: calc(clamp(0.9rem, 1rem + 0.5cqi, 1.15rem) * var(--card-font-scale, 1)) !important; }
.dual-metric-card { container-type: inline-size; }
.dual-metric-header[hidden] { display: none !important; }
.dual-metric-header { padding: 10px var(--dual-padding, 14px) !important; }
.dual-metric-header .dual-metric-title { flex: 1 1 auto; }
.dual-metric-help { flex: 0 0 28px !important; width: 28px !important; height: 28px !important; min-height: 28px !important; margin: -4px -6px -4px 0; border: 1px solid var(--border) !important; font-weight: 700; color: var(--text-secondary) !important; }
.dual-metric-help-text { flex-basis: 100%; font-size: calc(0.8rem * var(--card-font-scale, 1)); color: var(--text-secondary); }
.dual-metric-header { flex-wrap: wrap; }
.dual-metric-pane { padding: 8px var(--dual-padding, 14px) !important; }
.dual-metric-label { font-size: calc(var(--dual-label-size, clamp(0.72rem, 7cqi, 0.95rem)) * var(--card-font-scale, 1)) !important; color: var(--text-secondary); font-weight: 600; }
.dual-metric-value { font-size: calc(var(--dual-value-size, clamp(1.1rem, 17cqi, 2.6rem)) * var(--card-font-scale, 1)) !important; }
.dual-metric-unit { font-size: calc(var(--dual-unit-size, clamp(0.75rem, 7cqi, 1.1rem)) * var(--card-font-scale, 1)) !important; color: var(--text-secondary); }

/* ── Power chart with statistics ─────────────────────────────
   Inside a dashboard block (fixed height) the chart takes the free
   space and the table scrolls, instead of the table being cut off at
   the block's edge. A chart height set in the editor still wins. */
.dashboard-block > .chart-container:has(.power-stats) { display: flex; flex-direction: column; height: 100% !important; overflow: hidden; }
.dashboard-block > .chart-container:has(.power-stats) > .power-chart-canvas-wrap:not([style*="height"]) { flex: 1 1 auto; height: auto; min-height: 140px; }
.dashboard-block > .chart-container:has(.power-stats) > .power-stats { flex: 0 1 auto; min-height: 0; max-height: 45%; overflow: auto; }
.power-stats h4 { font-size: calc(0.75rem * var(--card-font-scale, 1)) !important; font-weight: 700 !important; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-secondary) !important; }
.power-stats-table thead th { font-size: 0.72rem; font-weight: 700; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.03em; }
.power-stats-table tbody tr { cursor: pointer; }
.power-stats-table tbody tr:hover th, .power-stats-table tbody tr:hover td { background: var(--hover, rgba(127,127,127,0.06)); }
.power-stats-table tbody tr:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.power-stats-table tbody tr[aria-pressed="false"] { opacity: 0.45; }
.power-stats-warning, .power-stats-unavailable { margin: 6px 0 0; font-size: 0.75rem; color: var(--text-secondary); }

/* Phones: blocks stack and take their content's height, so cards that size
   themselves to the block need a height of their own. */
@media (max-width: 768px) {
  .dashboard-block > .configurable-gauge-card { height: 260px !important; }
  .dashboard-block > .metric-trend-card { height: 220px !important; }
  .dashboard-block > .dual-metric-card { min-height: 130px; }
}

/* ── Energy day card ───────────────────────────────────────────────────── */
.energy-day-card {
  background: var(--card-bg); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--border);
  padding: var(--card-pad, 12px); height: 100%; width: 100%; box-sizing: border-box;
  display: flex; flex-direction: column; gap: 6px; overflow: hidden; min-height: 0;
}
.ed-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; flex-shrink: 0; }
.ed-title { margin: 0; font-size: calc(var(--fs-large) * var(--card-font-scale, 1)); font-weight: 500; color: var(--text); }
.ed-controls { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ed-daynav { display: inline-flex; align-items: center; gap: 4px; }
.ed-day { min-width: 6.5em; text-align: center; font-size: calc(0.8rem * var(--card-font-scale, 1)); font-weight: 600; color: var(--text); padding: 0 4px; }
.ed-btn {
  background: var(--bg); border: 1px solid var(--border); color: var(--text); border-radius: var(--radius);
  min-height: 30px; min-width: 30px; padding: 0 10px; font: inherit; font-size: calc(0.78rem * var(--card-font-scale, 1)); cursor: pointer;
}
.ed-btn:hover:not(:disabled) { border-color: var(--accent); }
.ed-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.ed-btn:disabled { opacity: .35; cursor: default; }
.ed-prev, .ed-next { padding: 0; font-size: 1rem; line-height: 1; }
.ed-btn[hidden] { display: none; }
.ed-panels { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; gap: 2px; }
.ed-panel { position: relative; min-height: 0; }
.ed-energy { flex: 3 1 0; min-height: 120px; }
.ed-battery { flex: 1 1 0; min-height: 72px; max-height: 140px; }
.ed-panel[hidden] { display: none; }
.ed-panel canvas { position: absolute; inset: 0; width: 100% !important; height: 100% !important; }
.ed-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; flex-shrink: 0; font-size: calc(0.72rem * var(--card-font-scale, 1)); color: var(--text-secondary); }
.ed-key { display: inline-flex; align-items: center; gap: 6px; }
.ed-swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; flex-shrink: 0; }
.ed-swatch-solid { background: var(--c); }
.ed-swatch-hatch { border: 1px solid var(--c); background: repeating-linear-gradient(135deg, var(--c) 0 1.5px, transparent 1.5px 4px); }
.ed-swatch-dash, .ed-swatch-line, .ed-swatch-dots { height: 0; width: 16px; border-radius: 0; border-top: 2px dashed var(--c); }
.ed-swatch-line { border-top-style: solid; }
.ed-swatch-dots { border-top-style: dotted; }
.ed-status { margin: 0; flex-shrink: 0; font-size: calc(0.72rem * var(--card-font-scale, 1)); color: var(--text-secondary); }
.ed-status:empty { display: none; }
/* Daily peak and Histogram cards: the Daily Energy chart's frame (.chart-container) with its segmented range buttons. */
.pk-controls { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.pk-panel { position: relative; flex: 1 1 0; min-height: 140px; min-width: 0; }
.pk-panel canvas { position: absolute; inset: 0; width: 100% !important; height: 100% !important; }
.pk-status { margin: 0; flex-shrink: 0; font-size: calc(0.72rem * var(--card-font-scale, 1)); color: var(--text-secondary); }
.pk-status:empty { display: none; }

/* ── Day totals card ───────────────────────────────────────────────────── */
.energy-totals-card { height: 100%; width: 100%; box-sizing: border-box; display: flex; flex-direction: column; gap: 6px; min-height: 0; container-type: inline-size; }
.et-title { margin: 0; font-size: calc(var(--fs-large) * var(--card-font-scale, 1)); font-weight: 500; color: var(--text); }
.et-tiles { flex: 1 1 auto; min-height: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 2px; }
.et-tile {
  background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: var(--card-pad, 12px); min-width: 0; display: flex; flex-direction: column; gap: 6px; overflow: hidden;
}
.et-label { margin: 0; display: flex; align-items: center; gap: 6px; font-size: calc(0.8rem * var(--card-font-scale, 1)); font-weight: 600; color: var(--text-secondary); }
.et-icon { display: inline-flex; color: var(--et-c); }
.et-icon svg { width: 16px; height: 16px; }
.et-value { margin: 0; color: var(--text); line-height: 1.1; }
.et-num { font-size: calc(clamp(1.4rem, 1rem + 2cqi, 2rem) * var(--card-font-scale, 1)); font-weight: 600; font-variant-numeric: tabular-nums; }
.et-unit { font-size: calc(0.9rem * var(--card-font-scale, 1)); color: var(--text-secondary); }
.et-compare { display: flex; flex-direction: column; gap: 3px; margin-top: auto; }
.et-compare[hidden] { display: none; }
.et-row { display: flex; justify-content: space-between; gap: 8px; font-size: calc(0.72rem * var(--card-font-scale, 1)); color: var(--text-secondary); }
.et-row span:last-child { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.et-track { position: relative; height: 6px; border-radius: 3px; background: var(--border); overflow: hidden; }
.et-fill { position: absolute; inset: 0 auto 0 0; width: 0; border-radius: 3px; background: var(--et-c); }
.et-band {
  position: absolute; top: 0; bottom: 0; border-radius: 3px;
  background: repeating-linear-gradient(135deg, var(--et-c) 0 2px, transparent 2px 5px); box-shadow: inset 0 0 0 1px var(--et-c);
}
.et-status { margin: 0; font-size: calc(0.72rem * var(--card-font-scale, 1)); color: var(--text-secondary); }
.et-status:empty { display: none; }

/* ── Costs and earnings card ───────────────────────────────────────────── */
.ec-totals { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 6px; flex-shrink: 0; }
.ec-total { border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 10px; min-width: 0; background: var(--bg); }
.ec-total h4 { margin: 0 0 2px; font-size: calc(0.72rem * var(--card-font-scale, 1)); font-weight: 600; color: var(--text-secondary); }
.ec-amount { margin: 0; font-size: calc(clamp(1.05rem, 0.9rem + 0.8cqi, 1.4rem) * var(--card-font-scale, 1)); font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ec-sub { margin: 0; font-size: calc(0.7rem * var(--card-font-scale, 1)); color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.ec-prices { margin: 0; flex-shrink: 0; font-size: calc(0.7rem * var(--card-font-scale, 1)); color: var(--text-secondary); }
.energy-costs-card { container-type: inline-size; }

/* ── System overview card ──────────────────────────────────────────────── */
.system-overview-card { height: 100%; width: 100%; box-sizing: border-box; display: flex; flex-direction: column; gap: 8px; min-height: 0; container-type: inline-size; }
.so-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; flex-shrink: 0; }
.so-title { margin: 0; font-size: calc(var(--fs-large) * var(--card-font-scale, 1)); font-weight: 500; color: var(--text); }
.so-strip { display: flex; gap: 18px; margin: 0; flex-wrap: wrap; }
.so-strip div { display: flex; flex-direction: column; }
.so-strip dt { font-size: calc(0.7rem * var(--card-font-scale, 1)); color: var(--text-secondary); }
.so-strip dd { margin: 0; font-size: calc(0.8rem * var(--card-font-scale, 1)); font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.so-status[data-state="warn"] { color: var(--color-grid); }
.so-body { flex: 1 1 auto; min-height: 0; display: grid; grid-template-columns: 1fr; gap: 8px; }
.so-body.has-extras { grid-template-columns: minmax(0, 1fr) minmax(150px, 22%); }
.so-diagram { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) minmax(90px, 18%) minmax(0, 1fr); gap: 0 14%; min-height: 0; }
.so-diagram .so-col { display: grid; grid-template-rows: 1fr 1fr; gap: 8px; min-height: 0; position: relative; z-index: 1; }
.so-lines { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.so-line { fill: none; stroke: var(--border); stroke-width: 2; }
.so-line[data-flow="in"], .so-line[data-flow="out"] { stroke: var(--so-c); stroke-dasharray: 2 10; stroke-linecap: round; stroke-width: 3; animation: so-flow 1.2s linear infinite; }
.so-line[data-flow="out"] { animation-direction: reverse; }
@keyframes so-flow { to { stroke-dashoffset: -12; } }
@media (prefers-reduced-motion: reduce) { .so-line[data-flow] { animation: none; } }
.so-hub { display: flex; align-items: center; justify-content: center; position: relative; z-index: 1; }
.so-hub-box {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px; width: 100%; max-width: 120px; box-sizing: border-box;
  background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); color: var(--text);
}
.so-hub-icon { display: inline-flex; color: var(--accent); }
.so-hub-icon svg { width: 30px; height: 30px; }
.so-hub-img { max-width: 100%; max-height: 70px; object-fit: contain; }
.so-hub-state { font-size: calc(0.72rem * var(--card-font-scale, 1)); font-weight: 700; color: var(--text-secondary); text-align: center; }
.so-tile {
  position: relative; overflow: hidden; min-width: 0; min-height: 0; padding: 10px 12px; box-sizing: border-box;
  background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  display: flex; flex-direction: column; justify-content: flex-start; gap: 4px;
}
.so-tile header { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; position: relative; }
.so-tile h4 { margin: 0; display: flex; align-items: center; gap: 6px; font-size: calc(0.8rem * var(--card-font-scale, 1)); font-weight: 600; color: var(--text-secondary); min-width: 0; }
.so-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.so-icon { display: inline-flex; color: var(--so-c); }
.so-icon svg { width: 16px; height: 16px; }
.so-corner { font-size: calc(0.72rem * var(--card-font-scale, 1)); color: var(--text-secondary); font-variant-numeric: tabular-nums; white-space: nowrap; }
.so-value { margin: 0; position: relative; z-index: 1; color: var(--text); line-height: 1.05; }
.so-tile header { z-index: 1; }
.so-num { font-size: calc(clamp(1.2rem, 0.8rem + 2cqi, 2rem) * var(--card-font-scale, 1)); font-weight: 600; font-variant-numeric: tabular-nums; }
.so-unit { font-size: calc(0.9rem * var(--card-font-scale, 1)); color: var(--text-secondary); }
.so-spark { position: absolute; left: 0; right: 0; bottom: 0; width: 100%; height: 40%; pointer-events: none; }
.so-spark-line { fill: none; stroke: var(--so-c); stroke-width: 1.5; vector-effect: non-scaling-stroke; opacity: .8; }
.so-spark-area { fill: var(--so-c); opacity: .12; stroke: none; }
.so-extras { display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.so-extras .so-tile { flex: 1 1 0; }
/* Narrow: a 2x2 grid of tiles; the hub's state moves into the strip. */
.so-strip-inverter { display: none !important; }
@container (max-width: 620px) {
  .so-body.has-extras { grid-template-columns: 1fr; }
  .so-extras { display: grid; grid-template-columns: 1fr 1fr; }
  .so-diagram { grid-template-columns: 1fr 1fr; grid-auto-rows: 1fr; gap: 8px; }
  .so-diagram .so-col { display: contents; }
  .so-hub, .so-lines { display: none; }
  .so-strip-inverter { display: flex !important; }
  .so-strip { gap: 12px; }
  .so-tile { padding: 8px 10px; }
  .so-tile header { flex-wrap: wrap; }
  .so-spark { height: 28%; opacity: .7; }
}

/* ── Energy, tabbed ─────────────────────────────────────────────────────── */
.energy-tabs-card {
  background: var(--card-bg); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--border);
  padding: var(--card-pad, 12px); height: 100%; width: 100%; box-sizing: border-box;
  display: flex; flex-direction: column; gap: 6px; min-height: 0; overflow: hidden;
}
.etabs-title { margin: 0; font-size: calc(var(--fs-large) * var(--card-font-scale, 1)); font-weight: 500; color: var(--text); }
.etabs-list { display: flex; gap: 2px; border-bottom: 1px solid var(--border); flex-shrink: 0; overflow-x: auto; scrollbar-width: none; }
.etabs-tab {
  appearance: none; background: none; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px;
  padding: 8px 12px; min-height: 36px; font: inherit; font-size: calc(0.82rem * var(--card-font-scale, 1)); font-weight: 600;
  color: var(--text-secondary); cursor: pointer; white-space: nowrap;
}
.etabs-tab:hover { color: var(--text); }
.etabs-tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.etabs-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 6px 6px 0 0; }
.etabs-panel { flex: 1 1 auto; min-height: 0; display: flex; }
.etabs-panel[hidden] { display: none; }
/* The card inside a tab drops its own frame: the tabbed card is the frame. */
.etabs-panel > .energy-day-card, .etabs-panel > .energy-totals-card { border: 0; box-shadow: none; background: none; padding: 0; border-radius: 0; }
.etabs-panel > .energy-day-card .ed-header { justify-content: flex-end; }
.etabs-panel > .energy-totals-card .et-tiles { flex: 0 0 auto; align-content: start; }
/* Wide cards: the tab's controls sit at the right end of the tab bar. */
.energy-tabs-card { position: relative; container-type: inline-size; }
@container (min-width: 760px) {
  .etabs-list { padding-right: 330px; }
  .etabs-panel > .energy-day-card .ed-header { position: absolute; right: var(--card-pad, 12px); top: calc(var(--etabs-row-top, 0px) + 2px); }
}
/* PV split: three tiles on the right (PV inverter, Home, PV charger). */
.so-body.is-split .so-right { grid-template-rows: repeat(3, 1fr); }
.so-weather .so-value { display: flex; align-items: baseline; gap: 4px; }
.so-wx-icon { margin-left: auto; font-size: calc(1.8rem * var(--card-font-scale, 1)); color: var(--accent); line-height: 1; }
.so-wx-desc { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 60%; }
/* Weather details: one line each (label, value), in two columns when the
   tile is wide; fitWeather() hides the lines a short tile has no room for. */
.so-wx-facts { flex: 1 1 0; min-height: 0; overflow: hidden; margin: 6px 0 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 10.5em), 1fr)); gap: 3px 14px; align-content: start; }
.so-wx-facts > div { min-width: 0; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding-top: 3px; border-top: 1px solid var(--border); }
.so-wx-facts dt { font-size: calc(0.72rem * var(--card-font-scale, 1)); color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.so-wx-facts dd { margin: 0; font-size: calc(0.78rem * var(--card-font-scale, 1)); font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Switch / selector placeholder (the working controls are on the Controls page) */
.control-placeholder { display: flex; flex-direction: column; justify-content: center; gap: .35rem; height: 100%; box-sizing: border-box; padding: 1rem; background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); }
.control-placeholder-name { font-weight: 600; color: var(--text); }
.control-placeholder-text { margin: 0; font-size: var(--fs-small, .85rem); color: var(--text-secondary); }
.control-placeholder-text a { color: var(--text); }

/* ── Slider and rotary controls (Controls page) ─────────────── */
.numctl { --nc-accent: var(--accent, #f59e0b); --nc-pct: 0%; justify-content: center; color: var(--text); user-select: none; -webkit-tap-highlight-color: transparent; }
.numctl-head { display: flex; align-items: baseline; justify-content: space-between; gap: .75rem; min-width: 0; }
.numctl-label { font-weight: 600; color: var(--text); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.numctl-value { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--nc-accent); white-space: nowrap; }
.numctl-scale { display: flex; justify-content: space-between; font-size: var(--fs-small, .8rem); color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.numctl-status { min-height: 1.1em; font-size: var(--fs-small, .8rem); color: var(--color-danger, #dc2626); }
.numctl-empty { font-size: var(--fs-small, .85rem); color: var(--text-secondary); }
.numctl.is-unknown .numctl-value { color: var(--text-secondary); }
.numctl.is-unavailable { opacity: .55; }
.numctl.is-busy { opacity: .75; }
.numctl.is-error { border-color: var(--color-danger, #dc2626); animation: switch-shake .4s ease; }

.numctl-range { -webkit-appearance: none; appearance: none; width: 100%; height: 28px; margin: 0; background: transparent; cursor: pointer; touch-action: pan-y; }
.numctl-range:disabled { cursor: progress; }
.numctl-range::-webkit-slider-runnable-track { height: 8px; border-radius: 4px; background: linear-gradient(to right, var(--nc-accent) var(--nc-pct), var(--border) var(--nc-pct)); }
.numctl-range::-moz-range-track { height: 8px; border-radius: 4px; background: var(--border); }
.numctl-range::-moz-range-progress { height: 8px; border-radius: 4px; background: var(--nc-accent); }
.numctl-range::-webkit-slider-thumb { -webkit-appearance: none; width: 24px; height: 24px; margin-top: -8px; border-radius: 50%; background: var(--card-bg); border: 3px solid var(--nc-accent); box-shadow: var(--shadow); }
.numctl-range::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: var(--card-bg); border: 3px solid var(--nc-accent); box-shadow: var(--shadow); }
.numctl-range:focus-visible { outline: 2px solid var(--nc-accent); outline-offset: 4px; border-radius: 4px; }
.numctl.is-unknown .numctl-range::-webkit-slider-thumb { border-color: var(--text-secondary); }
.numctl.is-unknown .numctl-range::-moz-range-thumb { border-color: var(--text-secondary); }

.numctl-rotary { align-items: center; text-align: center; }
.numctl-rotary .numctl-scale { width: min(70%, 12rem); }
.numctl-knob { position: relative; width: min(100%, 10rem); aspect-ratio: 1; touch-action: none; cursor: grab; border-radius: 50%; outline: none; }
.numctl-knob:active { cursor: grabbing; }
.numctl-knob svg { width: 100%; height: 100%; display: block; overflow: visible; }
.numctl-knob .knob-track, .numctl-knob .knob-fill { fill: none; stroke-width: 8; stroke-linecap: round; }
.numctl-knob .knob-track { stroke: var(--border); }
.numctl-knob .knob-fill { stroke: var(--nc-accent); }
.numctl-knob .knob-cap { fill: var(--card-bg); stroke: var(--border); stroke-width: 2; }
.numctl-knob .knob-mark { stroke: var(--nc-accent); stroke-width: 4; stroke-linecap: round; }
.numctl.is-unknown .knob-mark { stroke: var(--text-secondary); }
.numctl-knob:focus-visible .knob-cap { stroke: var(--nc-accent); stroke-width: 3; }
.numctl-knob .numctl-value { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: calc(1.05rem * var(--card-font-scale, 1)); pointer-events: none; }

/* ── Button card (Home Assistant style) ─────────────────────── */
.button-card {
  box-sizing: border-box; width: 100%; height: 100%; min-width: 0;
  container-type: size;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  padding: var(--card-pad); margin: 0; font: inherit; text-align: center; color: var(--text);
  background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius);
  -webkit-tap-highlight-color: transparent; user-select: none;
}
button.button-card { cursor: pointer; transition: transform .08s ease, border-color .15s ease; }
button.button-card:hover { border-color: var(--text-secondary, #888); }
button.button-card:active { transform: scale(.98); }
button.button-card:focus-visible { outline: 2px solid var(--bc-on, #ffc107); outline-offset: 2px; }
.button-card .bc-icon {
  display: flex; align-items: center; justify-content: center;
  width: 100%; flex: 1 1 0; min-height: 20px; max-height: min(62cqh, 80cqw);
  color: var(--bc-off); transition: color .2s ease;
}
.button-card.is-on .bc-icon, .button-card.is-press .bc-icon { color: var(--bc-on); }
.button-card.bc-pressed .bc-icon { animation: bc-press .6s ease; }
@keyframes bc-press { 0% { transform: scale(1); } 30% { transform: scale(.86); opacity: .7; } 100% { transform: scale(1); } }
.button-card.is-unknown .bc-icon { opacity: .45; }
.button-card .bc-icon svg { height: 100%; width: auto; max-width: 100%; }
.button-card .bc-icon img { height: 100%; width: auto; max-width: 100%; object-fit: contain; }
.button-card.is-off .bc-icon img { opacity: .55; filter: grayscale(.4); }
.button-card .bc-emoji { font-size: min(44cqh, 60cqw); line-height: 1; }
.button-card .bc-name {
  max-width: 100%; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-height: 1.2;
  font-size: calc(clamp(.8rem, 9cqh, 1rem) * var(--card-font-scale, 1)); font-weight: 500; color: var(--text);
}
.button-card .bc-state {
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: calc(clamp(.68rem, 7cqh, .82rem) * var(--card-font-scale, 1)); color: var(--text-secondary);
}
.button-card.bc-busy { opacity: .7; }
.button-card.bc-error { border-color: var(--color-danger, #dc2626); animation: switch-shake .4s ease; }
.button-card.bc-error .bc-state { color: var(--color-danger, #dc2626); white-space: normal; }
/* Short blocks: the icon gives way to the text */
@container (max-height: 90px) { .button-card .bc-state { display: none; } }

/* A Tuya device that is not answering (readingAge.js): its last reading is not shown as live. */
.switch-block.is-unavailable,
.state-select-block.is-unavailable { opacity: 0.55; }

/* ── Control card styles (components/controlStyle.js) ─────────────────────
   Layout, sub-label, on/off pill and fill-when-on for the Button and Toggle cards, set in the layout
   editor. A card with none of them has none of these classes and looks as it always did. */
.button-card .bc-sub, .switch-block .cs-sub { display: none; }
.button-card .bc-pill { display: none; }
.button-card .bc-sub, .switch-block .cs-sub {
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: calc(clamp(.66rem, 6.5cqh, .8rem) * var(--card-font-scale, 1)); color: var(--text-secondary); line-height: 1.2;
}
.switch-block .cs-sub { font-size: calc(var(--fs-small, .8rem) * var(--card-font-scale, 1)); }
/* The on/off pill on a Button card: the same track and knob as the Toggle's switch. */
.button-card .bc-pill { position: relative; flex: none; width: 40px; height: 22px; border-radius: 999px; background: var(--switch-off-color, #a8a59e); transition: background .2s ease; }
[data-theme="dark"] .button-card .bc-pill { background: var(--switch-off-color, #4a4a4a); }
.button-card .bc-pill::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 ease; }
[data-theme="dark"] .button-card .bc-pill::after { background: #111; }
.button-card.is-on .bc-pill { background: var(--bc-on); }
.button-card.is-on .bc-pill::after { transform: translateX(18px); }
.button-card.is-unknown .bc-pill { opacity: .45; }
.button-card.is-press .bc-pill { display: none; }

/* Fill while on: the card takes a tint of its "on" colour. */
.button-card.cs-fill.is-on, .button-card.cs-fill.is-press { background: color-mix(in srgb, var(--bc-on) 16%, var(--card-bg)); border-color: color-mix(in srgb, var(--bc-on) 55%, var(--border)); }
.switch-block.cs-fill.is-on { background: color-mix(in srgb, var(--cs-on, var(--accent, #f59e0b)) 16%, var(--card-bg)); border-color: color-mix(in srgb, var(--cs-on, var(--accent, #f59e0b)) 55%, var(--border)); }

/* Button: tile. Name, room and state on the left, the icon large on the right, the pill bottom right. */
.button-card.cs-tile {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(44px, 36%); grid-template-rows: auto auto minmax(0, 1fr) auto;
  grid-template-areas: "name icon" "sub icon" "state icon" "pill pill";
  align-items: start; justify-items: start; text-align: left; gap: 2px 8px;
}
.button-card.cs-tile .bc-name { grid-area: name; font-weight: 600; }
.button-card.cs-tile .bc-sub { grid-area: sub; display: block; }
.button-card.cs-tile .bc-state { grid-area: state; align-self: end; }
.button-card.cs-tile .bc-icon { grid-area: icon; width: 100%; height: auto; max-height: 100%; aspect-ratio: 1; align-self: center; justify-self: end; flex: none; min-height: 0; }
.button-card.cs-tile .bc-icon svg, .button-card.cs-tile .bc-icon img { height: 100%; width: 100%; object-fit: contain; }
.button-card.cs-tile .bc-pill { grid-area: pill; display: block; justify-self: end; align-self: end; }
.button-card.cs-tile.is-press .bc-pill { display: none; }

/* Button: row. Icon, then name and room, then the pill. */
.button-card.cs-row {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-rows: auto auto auto;
  grid-template-areas: "icon name pill" "icon sub pill" "icon state pill";
  align-items: center; justify-items: start; text-align: left; gap: 0 12px; padding-block: 8px;
}
.button-card.cs-row .bc-icon { grid-area: icon; width: auto; height: min(70cqh, 52px); aspect-ratio: 1; flex: none; max-height: none; }
.button-card.cs-row .bc-icon svg, .button-card.cs-row .bc-icon img { height: 100%; width: 100%; object-fit: contain; }
.button-card.cs-row .bc-name { grid-area: name; }
.button-card.cs-row .bc-sub { grid-area: sub; display: block; }
.button-card.cs-row .bc-state { grid-area: state; }
.button-card.cs-row .bc-pill { grid-area: pill; display: block; justify-self: end; }
.button-card.cs-row.is-press .bc-pill { display: none; }

/* Button: compact, for rows of quick actions. */
.button-card.cs-compact { gap: 6px; padding: 10px 6px; border-radius: 16px; }
.button-card.cs-compact .bc-icon { flex: none; width: auto; height: clamp(22px, 36cqh, 40px); max-height: none; }
.button-card.cs-compact .bc-icon svg, .button-card.cs-compact .bc-icon img { height: 100%; width: auto; }
.button-card.cs-compact .bc-name { font-size: calc(clamp(.68rem, 14cqh, .86rem) * var(--card-font-scale, 1)); text-align: center; }
.button-card.cs-compact .bc-state, .button-card.cs-compact .bc-sub, .button-card.cs-compact .bc-pill { display: none; }

/* Toggle: icon and room. The classic card is a label on the left and the switch on the right; these add to it. */
.switch-block { container-type: size; gap: 10px; }
.switch-block .cs-icon { display: flex; align-items: center; justify-content: center; flex: none; width: 1.8em; height: 1.8em; color: var(--cs-off, var(--text-secondary)); transition: color .2s ease; }
.switch-block.is-on .cs-icon { color: var(--cs-on, var(--accent, #f59e0b)); }
.switch-block .cs-icon svg, .switch-block .cs-icon img { width: 100%; height: 100%; object-fit: contain; }
.switch-block .cs-icon .bc-emoji { font-size: 1.5em; }
.switch-block > .switch-label { flex: 1 1 auto; min-width: 0; }
.switch-block.cs-row, .switch-block.cs-tile, .switch-block.cs-compact { align-items: center; }
.switch-block.cs-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "icon label control" "icon sub control"; column-gap: 12px; }
.switch-block.cs-row .cs-icon { grid-area: icon; width: 2.2em; height: 2.2em; }
.switch-block.cs-row .switch-label { grid-area: label; align-self: end; }
.switch-block.cs-row .cs-sub { grid-area: sub; display: block; align-self: start; }
.switch-block.cs-row .switch-control { grid-area: control; }
.switch-block.cs-tile {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(44px, 36%); grid-template-rows: auto auto minmax(0, 1fr) auto;
  grid-template-areas: "label icon" "sub icon" ". icon" "control control"; align-items: start; gap: 2px 8px; cursor: pointer;
}
.switch-block.cs-tile .switch-label { grid-area: label; font-weight: 600; }
.switch-block.cs-tile .cs-sub { grid-area: sub; display: block; }
.switch-block.cs-tile .cs-icon { grid-area: icon; width: 100%; height: auto; max-height: 100%; aspect-ratio: 1; align-self: center; justify-self: end; }
.switch-block.cs-tile .switch-control { grid-area: control; justify-self: end; align-self: end; }
.switch-block.cs-compact { flex-direction: column; justify-content: center; gap: 6px; text-align: center; cursor: pointer; padding: 10px 6px !important; border-radius: 16px; }
.switch-block.cs-compact .cs-icon { width: clamp(22px, 36cqh, 40px); height: clamp(22px, 36cqh, 40px); }
.switch-block.cs-compact .switch-label { flex: none; font-size: calc(clamp(.68rem, 14cqh, .86rem) * var(--card-font-scale, 1)); }
.switch-block.cs-compact .cs-sub { display: none; }
/* The whole compact card is the switch; the real checkbox stays for keyboards and screen readers. */
.switch-block.cs-compact .switch-control { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.switch-block.cs-compact { position: relative; }
.switch-block.cs-compact:focus-within { outline: 2px solid var(--cs-on, var(--accent, #f59e0b)); outline-offset: 2px; }

/* ── Quick actions: one card, a row of compact buttons (components/quickActions.js) ── */
.quick-actions {
  box-sizing: border-box; width: 100%; height: 100%; min-width: 0;
  display: flex; flex-direction: column; gap: 8px;
}
.quick-actions .qa-title { flex: none; font-size: calc(.8rem * var(--card-font-scale, 1)); font-weight: 600; color: var(--text-secondary); padding: 0 2px; }
.quick-actions .qa-row {
  flex: 1 1 0; min-height: 0;
  display: grid; gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(68px, 1fr)); grid-auto-rows: minmax(0, 1fr);
}
.quick-actions .button-card { min-height: 0; }

/* ── Slider, knob and State select: sub-label, tile layout, tint (components/controlStyle.js) ── */
.numctl-sub, .state-select-sub { font-size: calc(.76rem * var(--card-font-scale, 1)); color: var(--text-secondary); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.state-select-sub { margin: -.35rem 0 .5rem; }
.numctl.cs-fill { background: color-mix(in srgb, var(--nc-accent) 14%, var(--card-bg)); border-color: color-mix(in srgb, var(--nc-accent) 45%, var(--border)); }

/* Slider and knob tile: name and room at the top left, the value large, a thick track. */
.numctl.cs-tile { border-radius: 24px; padding: 16px 18px !important; gap: 4px; justify-content: space-between; align-items: stretch; text-align: left; }
.numctl.cs-tile .numctl-head { display: contents; }
.numctl.cs-tile .numctl-label { order: 1; font-size: calc(.95rem * var(--card-font-scale, 1)); font-weight: 700; }
.numctl.cs-tile .numctl-sub { order: 2; }
.numctl.cs-tile .numctl-value { order: 3; font-size: calc(2rem * var(--card-font-scale, 1)); font-weight: 700; line-height: 1.1; margin-top: auto; }
.numctl-slider.cs-tile .numctl-range { order: 4; height: 32px; }
.numctl-slider.cs-tile .numctl-scale { order: 5; }
.numctl-slider.cs-tile .numctl-status { order: 6; }
.numctl-slider.cs-tile .numctl-range::-webkit-slider-runnable-track { height: 14px; border-radius: 10px; }
.numctl-slider.cs-tile .numctl-range::-webkit-slider-thumb { width: 28px; height: 28px; margin-top: -7px; }
.numctl-slider.cs-tile .numctl-range::-moz-range-track, .numctl-slider.cs-tile .numctl-range::-moz-range-progress { height: 14px; border-radius: 10px; }
.numctl-slider.cs-tile .numctl-range::-moz-range-thumb { width: 22px; height: 22px; }
.numctl-rotary.cs-tile .numctl-knob { order: 3; align-self: center; margin-top: auto; }
.numctl-rotary.cs-tile .numctl-knob .numctl-value { margin-top: 0; font-size: calc(1.25rem * var(--card-font-scale, 1)); }
.numctl-rotary.cs-tile .numctl-scale { order: 5; align-self: center; }
.numctl-rotary.cs-tile .numctl-status { order: 6; }

/* State select tile: name and room above, the options as round chips. */
.state-select-block.cs-tile { border-radius: 24px; padding: 16px 18px !important; }
.state-select-block.cs-tile .state-select-label { font-weight: 700; }
.state-select-block.cs-tile .state-select-label:has(+ .state-select-sub) { margin-bottom: .1rem; }
.state-select-block.cs-tile .state-select-sub { margin: 0 0 .6rem; }
.state-select-block.cs-tile .state-select-buttons { gap: .5rem; }
.state-select-block.cs-tile .state-btn { border-radius: 999px; padding-inline: 1rem; }
.state-select-block.cs-tile .state-select-dropdown { border-radius: 999px; }

/* Generator card: the grid card's layout. Running is the state to notice, so it is amber, and stopped is plain. */
.grid-card.generator-card .ep-grid-state[data-state="on"] { color: var(--color-warning); }
.grid-card.generator-card .ep-grid-state[data-state="off"] { color: var(--text-secondary); }
.grid-card.generator-card .tl-segment.on { background: var(--color-warning); color: #fff; }
.grid-card.generator-card .tl-segment.off,
[data-theme="dark"] .grid-card.generator-card .tl-segment.off { background: color-mix(in srgb, var(--text-secondary) 14%, transparent); color: var(--text-secondary); }
.grid-card.generator-card .ep-grid-day { background: var(--color-warning); }
.grid-card.generator-card .ep-grid-day.today { background: repeating-linear-gradient(45deg, var(--color-warning) 0 4px, color-mix(in srgb, var(--color-warning) 45%, transparent) 4px 8px); }
.grid-card.generator-card .ep-grid-day.none, .grid-card.generator-card .ep-grid-day.unknown { height: 2px !important; background: var(--border); }

/* ── Prepaid meter ────────────────────────────────────────── */
/* A big balance, a segmented bar against the last recharge, the days left, facts, the latest entries and the buttons. Sized from
   the card (a size container); the colour follows the level (green, amber at a warning level, red when out). */
.prepaid-card { --pm-c: var(--battery, #22c55e); display: flex !important; flex-direction: column; gap: 0.6em; padding: var(--card-pad) !important; min-width: 0; height: 100%; width: 100%; box-sizing: border-box; container-type: size; overflow: hidden; }
.prepaid-card[data-level="low"], .prepaid-card[data-level="out"] { --pm-c: #ef4444; }   /* red from the warning level, as on the Grid card */
.prepaid-card[data-level="unknown"] { --pm-c: var(--text-secondary); }
.pm-title { flex: 0 0 auto; font-size: calc(clamp(0.65rem, min(5cqh, 3cqw), 0.95rem) * var(--card-font-scale, 1)); font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-secondary); }
.pm-msg { color: var(--text-secondary); font-size: calc(clamp(0.75rem, 3.2cqw, 1rem) * var(--card-font-scale, 1)); }
.pm-msg[hidden], .pm-body[hidden], .pm-actions[hidden], .pm-facts[hidden], .pm-ledger[hidden], .pm-btn[hidden] { display: none; }
.pm-body { display: flex; flex-direction: column; gap: 0.45em; }
.pm-big { display: flex; align-items: baseline; gap: 0.35em; flex-wrap: wrap; font-variant-numeric: tabular-nums; }
.pm-num { font-size: calc(clamp(1.8rem, min(15cqh, 17cqw), 4rem) * var(--card-font-scale, 1)); font-weight: 800; line-height: 1; color: var(--pm-c); }
.pm-unit { font-size: calc(clamp(0.8rem, min(6cqh, 4.5cqw), 1.2rem) * var(--card-font-scale, 1)); color: var(--text-secondary); font-weight: 600; }
.pm-bar { height: clamp(0.6rem, 4cqh, 1rem); border-radius: 999px; background: color-mix(in srgb, var(--text-secondary) 18%, transparent); overflow: hidden; }
.pm-fill { display: block; height: 100%; width: 0; background: var(--pm-c); border-radius: inherit; transition: width 0.6s ease; }
.pm-bar.pm-segmented { display: grid; grid-template-columns: repeat(var(--pm-n, 12), minmax(0, 1fr)); gap: 0.18em; background: none; border-radius: 0; overflow: visible; }
.pm-seg { display: block; border-radius: 3px; background: color-mix(in srgb, var(--text-secondary) 18%, transparent); transition: background 0.4s ease; }
.pm-seg[data-on="1"] { background: var(--pm-c); }
.pm-days { font-size: calc(clamp(0.7rem, min(4.5cqh, 3.2cqw), 0.95rem) * var(--card-font-scale, 1)); color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.pm-days:empty { display: none; }
.pm-facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.5em 1em; font-size: calc(clamp(0.65rem, min(4cqh, 2.8cqw), 0.85rem) * var(--card-font-scale, 1)); color: var(--text-secondary); }
.pm-fact b { display: block; color: var(--text); font-size: 1.2em; font-variant-numeric: tabular-nums; }
.pm-ledger { display: flex; flex-direction: column; font-size: calc(clamp(0.65rem, min(4cqh, 2.8cqw), 0.85rem) * var(--card-font-scale, 1)); font-variant-numeric: tabular-nums; }
.pm-ledger-row { display: grid; grid-template-columns: 4.5em minmax(0, 1fr) auto; gap: 0.6em; padding: 0.35em 0; border-top: 1px solid color-mix(in srgb, var(--text-secondary) 22%, transparent); }
.pm-ledger-date { color: var(--text-secondary); } .pm-ledger-note { color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pm-plus { color: var(--battery, #22c55e); } .pm-fix { color: var(--home, #38bdf8); }
.pm-actions { display: flex; flex-wrap: wrap; gap: 0.5em; margin-top: auto; }
.pm-btn { font: inherit; font-size: calc(clamp(0.7rem, min(4.5cqh, 3cqw), 0.9rem) * var(--card-font-scale, 1)); font-weight: 600; padding: 0.45em 0.9em; border-radius: 8px; border: 1px solid var(--border, #d6d3d1); background: transparent; color: var(--text); cursor: pointer; }
.pm-btn.pm-primary { background: var(--text); color: var(--bg, #fff); border-color: var(--text); }
.pm-btn.pm-quiet { border-color: transparent; color: var(--text-secondary); }
.pm-btn:disabled { opacity: 0.5; cursor: default; }
.pm-btn:focus-visible { outline: 2px solid var(--solar, #f59e0b); outline-offset: 2px; }
/* A short card gives up the entries first, then the facts, so the balance and the buttons always fit. */
@container (max-height: 380px) { .pm-ledger { display: none; } }
@container (max-height: 230px) { .pm-facts { display: none; } }
@media (max-width: 768px) { .prepaid-card { min-height: 20rem; } }

/* The prepaid text at the top right of the Grid card: plain text, no bar. Quiet while all is well, red from the warning level. */
.pm-strip { margin-left: auto; text-align: right; min-width: 0; font-variant-numeric: tabular-nums; line-height: 1.25; }
.pm-strip[hidden] { display: none; }
.pm-strip-main { font-size: 0.95em; font-weight: 700; color: var(--text); }
.pm-strip-sub { font-size: 0.8em; font-weight: 500; color: var(--text-secondary); }
.pm-strip-sub:empty { display: none; }
.pm-strip[data-level="low"] :is(.pm-strip-main, .pm-strip-sub), .pm-strip[data-level="out"] :is(.pm-strip-main, .pm-strip-sub) { color: #ef4444; }
