:root {
  /* Each color defined once, per theme, as a "-dark"/"-light" suffixed
     variable — the actual --bg/--panel/etc. variables below just point
     at one or the other, so there's exactly one place to edit a given
     color, and the auto media query + manual :root[data-theme] override
     below both reference the same values instead of duplicating hex. */
  --bg-dark: #0D1316;
  --panel-dark: #141C20;
  --panel-border-dark: #223038;
  --text-dark: #E7ECEE;
  --text-muted-dark: #7C8B93;
  --solar-dark: #F2A93B;
  --battery-charge-dark: #34D399;
  --battery-discharge-dark: #FB8A3C;
  --grid-dark: #6C93AC;
  --loads-dark: #C9CFD3;
  --gen-dark: #9C8AD1;
  --danger-dark: #E2574C;
  /* Only used as the "yellow" stop in the Frequency tile's green→yellow→
     orange→red gradient (see freqAccentColor() in app.js) — orange/red
     reuse --solar/--danger, but there's no existing yellow to borrow. */
  --freq-yellow-dark: #E4C13D;
  /* Per-phase colors for the phase-distribution Sankey (L1/L2/L3) —
     orange/green/blue, the common panel-meter convention; kept separate
     from the battery and grid tokens, since a phase isn't an energy-flow
     type. */
  /* EV charging station node (flow diagram). Teal, distinct from every
     other node color in both themes. */
  --ev-dark: #2DD4BF;
  /* Separate PV inverter node — a lighter yellow than --solar (the
     inverter's own MPPT input), same sun-energy family. */
  --pvinv-dark: #FDE047;
  /* Smart load node — rose, distinct from every other node color. */
  --smart-dark: #F472B6;
  --phase-l1-dark: #F0883E;
  --phase-l2-dark: #3FB950;
  --phase-l3-dark: #4C9AFF;
  --online-glow-dark: rgba(52, 211, 153, 0.18);
  --offline-glow-dark: rgba(226, 87, 76, 0.18);

  /* Same hue family as dark mode (amber=solar, green=charging, etc.) but
     darkened for contrast against a light background — the dark-mode
     values would wash out against white. */
  --bg-light: #F4F6F7;
  --panel-light: #FFFFFF;
  --panel-border-light: #DCE2E5;
  --text-light: #1B2429;
  --text-muted-light: #66727C;
  --solar-light: #B8791A;
  --battery-charge-light: #128A67;
  --battery-discharge-light: #C96A1A;
  --grid-light: #3F6E90;
  --loads-light: #5C6771;
  --gen-light: #6D4FB0;
  --danger-light: #B83629;
  --freq-yellow-light: #96790A;
  --ev-light: #0F8F80;
  --pvinv-light: #A16207;
  --smart-light: #BE185D;
  --phase-l1-light: #C25E12;
  --phase-l2-light: #1F8A3B;
  --phase-l3-light: #1F6FD1;
  --online-glow-light: rgba(18, 138, 103, 0.18);
  --offline-glow-light: rgba(184, 54, 41, 0.18);

  /* Active theme — defaults to dark; overridden below by either the
     prefers-color-scheme media query (automatic) or a data-theme
     attribute on <html> (manual, via the toggle button in app.js). */
  --bg: var(--bg-dark);
  --panel: var(--panel-dark);
  --panel-border: var(--panel-border-dark);
  --text: var(--text-dark);
  --text-muted: var(--text-muted-dark);
  --solar: var(--solar-dark);
  --battery-charge: var(--battery-charge-dark);
  --battery-discharge: var(--battery-discharge-dark);
  --grid: var(--grid-dark);
  --loads: var(--loads-dark);
  --gen: var(--gen-dark);
  --danger: var(--danger-dark);
  --freq-yellow: var(--freq-yellow-dark);
  --ev: var(--ev-dark);
  --pvinv: var(--pvinv-dark);
  --smart: var(--smart-dark);
  --phase-l1: var(--phase-l1-dark);
  --phase-l2: var(--phase-l2-dark);
  --phase-l3: var(--phase-l3-dark);
  --online-glow: var(--online-glow-dark);
  --offline-glow: var(--offline-glow-dark);

  --font-display: "Space Grotesk", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", "SF Mono", Consolas, monospace;

  --radius: 10px;
}

/* Automatic: follows the OS/browser preference when there's no manual
   override (see :root[data-theme] below, which — being an attribute
   selector — always wins over this on specificity, regardless of
   source order or whether this media query currently matches). */
@media (prefers-color-scheme: light) {
  :root {
    --bg: var(--bg-light);
    --panel: var(--panel-light);
    --panel-border: var(--panel-border-light);
    --text: var(--text-light);
    --text-muted: var(--text-muted-light);
    --solar: var(--solar-light);
    --battery-charge: var(--battery-charge-light);
    --battery-discharge: var(--battery-discharge-light);
    --grid: var(--grid-light);
    --loads: var(--loads-light);
    --gen: var(--gen-light);
    --danger: var(--danger-light);
    --freq-yellow: var(--freq-yellow-light);
    --ev: var(--ev-light);
    --pvinv: var(--pvinv-light);
    --smart: var(--smart-light);
    --phase-l1: var(--phase-l1-light);
    --phase-l2: var(--phase-l2-light);
    --phase-l3: var(--phase-l3-light);
    --online-glow: var(--online-glow-light);
    --offline-glow: var(--offline-glow-light);
  }
}

/* Manual override, set by the theme-toggle button in app.js
   (localStorage-backed). Higher specificity than the bare :root above
   (attribute selector vs. none), so it wins unconditionally once set —
   including overriding the media query in the opposite direction. */
:root[data-theme="light"] {
  --bg: var(--bg-light);
  --panel: var(--panel-light);
  --panel-border: var(--panel-border-light);
  --text: var(--text-light);
  --text-muted: var(--text-muted-light);
  --solar: var(--solar-light);
  --battery-charge: var(--battery-charge-light);
  --battery-discharge: var(--battery-discharge-light);
  --grid: var(--grid-light);
  --loads: var(--loads-light);
  --gen: var(--gen-light);
  --danger: var(--danger-light);
  --freq-yellow: var(--freq-yellow-light);
  --ev: var(--ev-light);
  --pvinv: var(--pvinv-light);
  --smart: var(--smart-light);
  --phase-l1: var(--phase-l1-light);
  --phase-l2: var(--phase-l2-light);
  --phase-l3: var(--phase-l3-light);
  --online-glow: var(--online-glow-light);
  --offline-glow: var(--offline-glow-light);
}

:root[data-theme="dark"] {
  --bg: var(--bg-dark);
  --panel: var(--panel-dark);
  --panel-border: var(--panel-border-dark);
  --text: var(--text-dark);
  --text-muted: var(--text-muted-dark);
  --solar: var(--solar-dark);
  --battery-charge: var(--battery-charge-dark);
  --battery-discharge: var(--battery-discharge-dark);
  --grid: var(--grid-dark);
  --loads: var(--loads-dark);
  --gen: var(--gen-dark);
  --danger: var(--danger-dark);
  --freq-yellow: var(--freq-yellow-dark);
  --ev: var(--ev-dark);
  --pvinv: var(--pvinv-dark);
  --smart: var(--smart-dark);
  --phase-l1: var(--phase-l1-dark);
  --phase-l2: var(--phase-l2-dark);
  --phase-l3: var(--phase-l3-dark);
  --online-glow: var(--online-glow-dark);
  --offline-glow: var(--offline-glow-dark);
}

.theme-toggle-btn {
  position: fixed;
  top: 1rem;
  right: 1rem;
  height: 32px;
  padding: 0 0.85rem;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 100;
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.theme-toggle-btn:hover {
  color: var(--text);
  border-color: var(--text-muted);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-display);
}

body {
  min-height: 100vh;
  padding-bottom: 3rem;
}

/* ---- brand logo (decorative, inside the first device's card) ---- */

.brand-logo-slot {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 1220px;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
  border-radius: 14px 14px 0 0;
}

.brand-logo-bg {
  width: 100%;
  height: 100%;
}

.brand-logo-bg svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* The entrance itself is driven entirely from JS now (see the
   requestAnimationFrame loop in static/app.js, near brandLogoWrap) — a
   CSS @keyframes animation here turned out to restart on every
   reparenting, since #app's whole subtree gets rebuilt each tick. No
   animation-related CSS is needed for .brand-logo-slide at all now. */

/* ---- layout ---- */

#app {
  max-width: 1100px;
  margin: 0 auto;
  margin-top: 5px;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.chart-slot {
  margin-top: 1.5rem;
}

.trend-panel canvas {
  margin-top: 0.75rem;
}

.empty-state {
  color: var(--text-muted);
  text-align: center;
  padding: 4rem 1rem;
  font-size: 0.95rem;
}

/* ---- plant state card ("Plant invalid", "Caut plantul…", 2.9.73) ---- */

.plant-state {
  /* explicit width: #app is a flex column, so with only max-width the card
     would shrink to its text ("Plant invalid" alone → a narrow sliver) */
  width: min(420px, calc(100% - 2rem));
  box-sizing: border-box;
  margin: 3rem auto;
  padding: 2.5rem 1.5rem 2.25rem;
  text-align: center;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  /* soft sun-colored glow behind the illustration */
  background-image: radial-gradient(circle at 50% 26%, color-mix(in srgb, var(--solar) 16%, transparent) 0, transparent 46%);
}

.plant-state-art { margin-bottom: 1rem; line-height: 0; }

.plant-sun circle { fill: color-mix(in srgb, var(--solar) 28%, transparent); stroke: var(--solar); stroke-width: 2; }
.plant-rays path { fill: none; stroke: var(--solar); stroke-width: 2; stroke-linecap: round; }
.plant-panel path { fill: none; stroke: var(--text-muted); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.plant-panel path:first-child { fill: color-mix(in srgb, var(--grid) 22%, var(--panel)); stroke: var(--text); }
.plant-badge circle { fill: var(--danger); stroke: var(--panel); stroke-width: 3; }
.plant-badge path { fill: none; stroke: #fff; stroke-width: 2.6; stroke-linecap: round; }

/* "error": dim the sun a little — the plant isn't producing anything here */
.plant-state--error .plant-sun { opacity: 0.55; }

/* "searching": slowly turning sun, no badge */
.plant-state--searching .plant-sun {
  transform-origin: 62px 26px;
  animation: plant-sun-spin 6s linear infinite;
}
@keyframes plant-sun-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .plant-state--searching .plant-sun { animation: none; }
}

.plant-state-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.25rem;
  letter-spacing: 0.01em;
}
.plant-state--error .plant-state-title { color: var(--text); }

.plant-state-sub {
  margin-top: 0.6rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  line-height: 1.7;
}

.plant-chip {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text);
  background: color-mix(in srgb, var(--text-muted) 14%, transparent);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  padding: 0.05rem 0.45rem;
  word-break: break-all;
}

@media (max-width: 480px) {
  .plant-state { margin: 2rem auto; padding: 2rem 1.1rem 1.8rem; }
}

.conn-error {
  max-width: 420px;
  margin: 3rem auto;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 3rem 1.5rem;
  text-align: center;
}

.conn-error-icon {
  color: var(--danger);
  margin-bottom: 0.75rem;
  animation: conn-error-pulse 1.4s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
  .conn-error-icon { animation: none; }
}

@keyframes conn-error-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.conn-error-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.05rem;
  margin-bottom: 0.35rem;
}

.conn-error-sub {
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* ---- device section ---- */

.device {
  position: relative;
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: .4rem;
  background: linear-gradient(180deg, rgba(255,255,255,0.015), transparent);
  transition: opacity 0.2s ease;
}

/* .brand-logo-slot (position: absolute, z-index: 0) is always the first
   child of .device when present. Every OTHER direct child needs its own
   stacking context above it — a positioned element paints above static
   (position: static) content by default regardless of DOM order, so
   without this the slot would cover whatever of the card's real content
   it happens to overlap, however tall the slot ends up being. One rule
   covering every child, rather than tagging device-header/hero-row/etc
   individually, so nothing added later is silently missed. */
.device > *:not(.brand-logo-slot) {
  position: relative;
  z-index: 1;
}

/* 2.17.0: no more fading the whole card when offline — see .offline-banner */

.device-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.device-model {
  font-weight: 600;
  font-size: 1.05rem;
  margin-right: 0.6rem;
}

.device-meta {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-muted);
}

.device-status {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--battery-charge);
  box-shadow: 0 0 0 3px var(--online-glow);
}

.device.is-offline .status-dot {
  background: var(--danger);
  box-shadow: 0 0 0 3px var(--offline-glow);
}

.status-age { font-family: var(--font-mono); }

/* Live-values (hero row) toggle — 2.9.82. Tiles hidden by default; the
   button in the device header shows/hides them (choice remembered). */
.hero-hidden .hero-row { display: none; }
.settings-hidden .plant-specs { display: none; }  /* 2.17.0: own ⚙ button */
.settings-toggle[aria-pressed="true"] { color: var(--solar); border-color: color-mix(in srgb, var(--solar) 55%, transparent); background: color-mix(in srgb, var(--solar) 14%, var(--panel)); }

.hero-toggle,
.hdr-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  margin-left: 0.35rem;
  padding: 0;
  border-radius: 999px;
  border: 1px solid var(--panel-border);
  background: var(--panel);
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}
.hero-toggle:hover, .hdr-btn:hover { color: var(--text); border-color: var(--text-muted); }
.hdr-btn:focus-visible { outline: 2px solid var(--solar); outline-offset: 2px; }
/* 30-day history button (2.12.1): calendar in the solar colour */
.dh-open-icon { color: var(--solar); }
.dh-open-icon:hover { border-color: color-mix(in srgb, var(--solar) 55%, transparent); background: color-mix(in srgb, var(--solar) 12%, var(--panel)); color: var(--solar); }
.hero-toggle[aria-pressed="true"] {
  color: var(--solar);
  border-color: color-mix(in srgb, var(--solar) 55%, transparent);
  background: color-mix(in srgb, var(--solar) 14%, var(--panel));
}
.hero-toggle:focus-visible { outline: 2px solid var(--solar); outline-offset: 2px; }

.device-weather {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding-right: 0.6rem;
  border-right: 1px solid var(--panel-border);
}

/* ---- hero row ---- */

.hero-row {
  display: grid;
  grid-template-columns: repeat(6, 1fr); /* 6 tiles since 2.9.81 (Invertor PV) */
  gap: 1px;
  background: var(--panel-border);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 1.5rem;
}

.hero-tile {
  background: var(--panel);
  padding: 1.1rem 1rem;
  border-top: 2px solid transparent;
}

.hero-tile.accent-solar { border-top-color: var(--solar); }
.hero-tile.accent-pvinv { border-top-color: var(--pvinv); }
.hero-tile.accent-battery { border-top-color: var(--battery-charge); }
.hero-tile.accent-battery.flow-discharge { border-top-color: var(--battery-discharge); }
.hero-tile.accent-loads { border-top-color: var(--loads); }
.hero-tile.accent-grid { border-top-color: var(--grid); }
/* Frequency has no dedicated color token of its own — it's an AC/grid-side
   electrical reading (not a separate energy flow the way Solar/Battery/
   Loads/Grid each are), so it reuses --grid's accent rather than adding a
   6th color to tune across both theme variants for one tile. */
.hero-tile.accent-frequency { border-top-color: var(--grid); }

.hero-tile.is-zero {
  opacity: 0.35;
  filter: grayscale(1);
}

/* Grid stays clearly visible at 0 kW (2.9.79, per explicit direction): on
   an off-grid day it reads ~0 all the time, and the generic 35% + greyscale
   fade made the tile look missing. A light dim + its own border color keeps
   "nothing flowing" readable without hiding the tile. */
.hero-tile.accent-grid.is-zero,
.hero-tile.accent-loads.is-zero, /* Loads too, since 2.9.80 */
.hero-tile.accent-pvinv.is-zero { /* Invertor PV too, since 2.9.81 */
  opacity: 0.8;
  filter: none;
}

.hero-value {
  font-family: var(--font-mono);
  display: flex;
  align-items: baseline;
  gap: 0.3rem;
}

.hero-number { font-size: 1.7rem; font-weight: 500; }
.hero-unit { font-size: 0.85rem; color: var(--text-muted); }

.hero-label {
  margin-top: 0.35rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.hero-sublabel {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

/* ---- panels ---- */

.panel-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
}

.panel-title {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.kv-list {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.kv-list > div {
  display: flex;
  justify-content: space-between;
  font-size: 0.88rem;
}

.kv-list dt { color: var(--text-muted); margin: 0; font-weight: 400; }
.kv-list dd { margin: 0; font-family: var(--font-mono); }

.phase-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

.phase-table th {
  text-align: right;
  color: var(--text-muted);
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 0.78rem;
  padding-bottom: 0.4rem;
}

.phase-table th:first-child, .phase-table td.phase-name { text-align: left; }

.phase-table td { text-align: right; padding: 0.28rem 0; }

.phase-table tbody tr + tr { border-top: 1px solid var(--panel-border); }

/* 2.18.0: up to 20 MPPTs / 2 batteries */
.panel-sub { font-size: 0.72rem; margin-left: 0.35rem; padding: 0.05rem 0.4rem; border-radius: 999px; border: 1px solid var(--panel-border); }
.phase-table tfoot td { border-top: 1px solid var(--text-muted); padding-top: 0.35rem; font-weight: 600; }
.bat-table td + td, .bat-table th + th { padding-left: 0.6rem; }
.bat-table td:last-child, .bat-table th:last-child { font-weight: 600; }
.bat-table + .kv-list { margin-top: 0.7rem; }
.bat-table + .kv-list:empty { display: none; }

/* ---- power flow diagram ---- */

.flow-section {
  margin-bottom: 1.5rem;
}

.flow-wrap {
  position: relative;
  width: 100%;
  max-width: 680px;
  aspect-ratio: 680 / 580;
  margin: 0 auto;
}

/* FIX 1: doar SVG-ul diagramei (copil direct), nu si iconitele din noduri */
.flow-wrap > svg { position: absolute; inset: 0; }

.flow-line {
  stroke: var(--panel-border);
  stroke-width: 1.5;
  transition: opacity 0.3s ease;
}

.flow-line.idle {
  stroke-dasharray: 3 4;
  opacity: 0.4;
}

.flow-hub { fill: var(--text-muted); }

/* FIX 2: eliminat regula .idle { animation: none } — :not(.idle) acopera deja cazul */
.dot-group .dot { opacity: 0; }
.dot-group:not(.idle) .dot { animation: flowY 1s linear infinite; }
.dot-group.reverse .dot { animation-direction: reverse; } /* trebuie sa ramana DUPA shorthand */

.dot-group.solar .dot { fill: var(--solar); --dy: 133px; }
.dot-group.battery .dot { fill: var(--battery-discharge); animation-name: flowX; --dx: 124px; }
.dot-group.battery.reverse .dot { fill: var(--battery-charge); }
.dot-group.loads .dot { fill: var(--loads); animation-name: flowX; --dx: 124px; }
.dot-group.grid .dot { fill: var(--grid); --dy: 133px; }
/* Generator's line to the hub is a diagonal (see flowSection() in app.js —
   it sits off in a top-right corner, not on the same horizontal/vertical
   cross as the other four), so it needs both axes animated at once —
   flowX/flowY above only move one axis — hence the separate flowXY
   keyframe below. */
.dot-group.generator .dot { fill: var(--gen); animation-name: flowXY; --dx: -162px; --dy: 164px; }
/* EV charging station: vertical mirror of Generator (bottom-right
   corner), and power flows OUT of the hub toward it, so the dots start
   at the hub end of its diagonal and move down-right. */
.dot-group.ev .dot { fill: var(--ev); animation-name: flowXY; --dx: 162px; --dy: 164px; }
/* PV inverter: horizontal mirror of Generator (top-left corner), power
   flows INTO the hub, so dots move down-right from the inverter. */
/* Smart load: bottom-left corner, power flows OUT of the hub toward it,
   so dots move down-left. */
.dot-group.smart .dot { fill: var(--smart); animation-name: flowXY; --dx: -162px; --dy: 164px; }
.dot-group.pvinv .dot { fill: var(--pvinv); animation-name: flowXY; --dx: 162px; --dy: 164px; }

@keyframes flowY {
  0% { transform: translate(0, 0); opacity: 0; }
  10% { opacity: 1; }
  90% { opacity: 1; }
  100% { transform: translate(0, var(--dy)); opacity: 0; }
}

@keyframes flowX {
  0% { transform: translate(0, 0); opacity: 0; }
  10% { opacity: 1; }
  90% { opacity: 1; }
  100% { transform: translate(var(--dx), 0); opacity: 0; }
}

@keyframes flowXY {
  0% { transform: translate(0, 0); opacity: 0; }
  10% { opacity: 1; }
  90% { opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)); opacity: 0; }
}

.flow-node {
  position: absolute;
  width: 115px;
  min-height: 115px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 10px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;

  transform: translateX(-50%);
  /* FIX 3: adaugat filter la tranzitie */
  transition: opacity 0.3s ease, box-shadow 0.3s ease, filter 0.3s ease;
}

 .flow-node svg { width: 55%; height: auto; }
.flow-node.solar { color: var(--solar); }
.flow-node.battery { color: var(--battery-charge); }
.flow-node.loads { color: var(--loads); }
.flow-node.grid { color: var(--grid); }
.flow-node.generator { color: var(--gen); }
.flow-node.ev { color: var(--ev); }
.flow-node.pvinv { color: var(--pvinv); }
.flow-node.smart { color: var(--smart); }

/* FIX 4: selector simplificat + fallback pentru browsere fara color-mix() */
.flow-node:not(.is-zero) {
  box-shadow: 0 0 18px 2px rgba(128, 128, 128, 0.35);
  box-shadow: 0 0 18px 2px color-mix(in srgb, currentColor 45%, transparent);
}

/* Node color treatment (2.9.74, "variant B", approved via preview): an
   active node gets a light veil of its own color over the panel, a border
   in that color, and its icon + label in that color; the value stays in
   the regular text color for legibility. Same color tokens as the energy
   Sankey, so each device reads as the same color in both panels. */
.flow-node:not(.is-zero) {
  background: color-mix(in srgb, currentColor 18%, var(--panel));
  border-color: color-mix(in srgb, currentColor 45%, transparent);
}
.flow-node:not(.is-zero) .flow-label {
  color: color-mix(in srgb, currentColor 80%, var(--text));
  font-weight: 600;
}
.flow-node:not(.is-zero) .flow-value { color: var(--text); font-weight: 600; }

/* Battery: orange while discharging, green while charging — matching the
   Sankey's two battery nodes (flowSection() adds .discharging). */
.flow-node.battery.discharging { color: var(--battery-discharge); }

/* Idle node (≤ 15 W, or no data): the Sankey's grey "empty" look instead
   of a faded/greyscaled copy of its color (was opacity .35 + grayscale). */
.flow-node.is-zero {
  /* more faded since 2.9.75 (was solid --panel-border at opacity .75) */
  background: color-mix(in srgb, var(--panel-border) 60%, transparent);
  border-color: transparent;
  opacity: 0.45;
}
.flow-node.is-zero > svg,
.flow-node.is-zero .flow-label,
.flow-node.is-zero .flow-value { color: var(--text-muted); }

.flow-label {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.flow-value {
  font-family: var(--font-mono);
  font-size: 0.95rem;
}

/* FIX 5: pe ecrane inguste nodurile scaleaza odata cu diagrama */
@media (max-width: 600px) {
  .flow-node {
    width: calc(118 / 480 * 100%);
    min-height: 0;
    aspect-ratio: 1;
    padding: 10px;
    gap: 4px;
  }
  .flow-node svg { width: 55%; height: auto; }
  .flow-label { font-size: 0.6rem; }
  .flow-value { font-size: 0.75rem; }
}

/* Narrow screens: the bottom-row nodes (Grid, and the 2-line
   "Stație încărcare" charging station) are taller relative to the
   scaled-down diagram and extend up to ~36px past .flow-wrap's bottom
   edge (measured at 600px wide), which made the charger node overlap the
   next panel. Reserve that room below the diagram. Desktop unaffected. */
@media (max-width: 720px) {
  .flow-wrap { margin-bottom: 3.25rem; }
}

/* FIX 6: respecta setarea de reducere a animatiilor */
@media (prefers-reduced-motion: reduce) {
  .dot-group .dot { animation: none !important; opacity: 0; }
  .flow-node { transition: none; }
}

/* ---- battery level panel ---- */

.battery-level-panel {
  max-width: 640px;
  margin: 0 auto 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.battery-level-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
}

.battery-level-label {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.battery-level-value {
  font-family: var(--font-mono);
  font-size: 1.2rem;
  color: var(--text);
}

.battery-level-value .unit {
  font-family: var(--font-display);
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-left: 0.2rem;
}

.segmented-bar {
  display: flex;
  gap: 0.25rem;
}

.segment {
  flex: 1;
  height: 0.25rem;
  border-radius: 2px;
}

.segment.filled { background: var(--solar); }
.segment.empty { background: var(--panel-border); }

.segmented-bar.level-high .segment.filled { background: var(--battery-charge); }
.segmented-bar.level-mid .segment.filled { background: var(--battery-discharge); }
.segmented-bar.level-low .segment.filled { background: var(--danger); }

/* Distinct low-battery warning — the segmented bar alone (red fill,
   .segmented-bar.level-low above) already signals this via color, but
   color alone is easy to miss in a quick glance; this adds a
   deliberately more attention-grabbing treatment for the same
   condition (battery below 20%, the same threshold that turns the bar
   red — see batteryLevelClass() in app.js), not a separate one. */
.battery-low-warning {
  border-color: var(--danger);
  animation: battery-low-pulse 2s ease-in-out infinite;
}

@keyframes battery-low-pulse {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--danger) 35%, transparent); }
  50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--danger) 0%, transparent); }
}

@media (prefers-reduced-motion: reduce) {
  .battery-low-warning { animation: none; }
}

.battery-low-badge {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 15%, transparent);
  border: 1px solid var(--danger);
  border-radius: 999px;
  padding: 0.1rem 0.55rem;
}


/* ---- self-consumption ratio (Sankey flow diagram) ---- */

.sc-panel {
  /* 820px (was 640) since 2.9.64: the direct-flow Sankey can carry up to
     5 sources × 5 destinations, and the extra width keeps the ribbons
     between the two columns from crowding together. */
  max-width: 820px;
  margin: 0 auto 1.5rem;
}

.sc-sankey {
  width: 100%;
  display: block;
  /* No fixed aspect-ratio here (unlike an earlier version): the SVG's
     viewBox height is now computed per-render in renderSelfConsumption()
     — it grows when MIN_NODE_H padding (for zero/near-zero nodes) pushes
     a column taller than the base canvas — so a hardcoded ratio would
     fight that and letterbox/shrink the diagram. With no explicit
     height attribute on the <svg> itself, width: 100% here is enough:
     the browser sizes it from its own viewBox aspect ratio automatically,
     whatever that ratio is on a given render. */
}

/* Energy-flow Sankey text (2.9.68 design). Sizes are set per element in
   renderSelfConsumption() (scaled up on phones together with the badges
   and node heights), so only weight/family/color live here. */
.sd-pill { font-weight: 600; font-family: var(--font-display); letter-spacing: 0.04em; }
.sd-val { font-weight: 700; font-family: var(--font-display); }
.sd-unit, .sd-pct { font-weight: 500; font-family: var(--font-display); opacity: 0.8; }
.sd-zero { font-weight: 500; font-family: var(--font-display); fill: var(--text-muted); }

.sc-node-label { font-size: 11px; }
.sc-node-value { font-size: 13px; }

/* Fixed viewBox (900 units wide) means the diagram scales down uniformly
   with its container — on a narrow phone (~340px rendered width), an
   11px label would render at under 5 actual screen pixels, unreadable.
   Since these are CSS-styled (not SVG font-size attributes), a media
   query can bump them relative to the still-fixed-width node boxes,
   genuinely increasing legibility rather than just scaling everything
   uniformly. Short Romanian labels (Solar/Baterie/Consum/Rețea) and the
   "kWh" suffix already dropped from the value text (just the number) are
   what makes this fit without also needing to widen the boxes. */
@media (max-width: 600px) {
  .sc-node-label { font-size: 15px; }
  .sc-node-value { font-size: 17px; }
}

/* ---- per-phase power distribution (Sankey) ---- */

.phase-sankey-panel {
  margin: 0 0 1.5rem;
}

.phase-sankey-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.25rem;
}

.phase-sankey-title {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.phase-sankey-total {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.phase-sankey-total .num {
  font-family: var(--font-mono);
  color: var(--text);
}

.phase-sankey { width: 100%; display: block; }

/* Same approach as .sc-node-label above: fixed viewBox (1000 wide) scales
   the whole diagram down on a phone, so the text is CSS-sized and bumped
   at the breakpoint to stay legible relative to the still-fixed geometry. */
.ph-name { font-size: 24px; font-weight: 600; font-family: var(--font-display); }
.ph-value { font-size: 21px; font-family: var(--font-mono); fill: var(--text-muted); }

@media (max-width: 600px) {
  .ph-name { font-size: 32px; }
  .ph-value { font-size: 27px; }
}

@media (max-width: 720px) {
  .hero-row { grid-template-columns: repeat(2, 1fr); }
  /* 6 tiles (since 2.9.81) fill a 2-column grid evenly — 3 full rows — so
     Frequency no longer needs to span both columns (it did with 5). */
  .panel-grid { grid-template-columns: 1fr; }
}

.app-footer {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.78rem;
  padding: 1rem 1rem 1.5rem;
}

/* Inverter operating status badge + fault/alarm banner — 2.9.84 */
.inv-status {
  --st: var(--text-muted);
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .18rem .6rem .18rem .5rem; margin-right: .6rem;
  border-radius: 999px; font-size: .75rem; font-weight: 600; letter-spacing: .02em;
  color: var(--st);
  background: color-mix(in srgb, var(--st) 14%, var(--panel));
  border: 1px solid color-mix(in srgb, var(--st) 40%, transparent);
  vertical-align: 2px; white-space: nowrap;
}
.inv-status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--st); }
.inv-status.st-ok    { --st: var(--battery-charge); }
.inv-status.st-idle  { --st: var(--grid); }
.inv-status.st-busy  { --st: var(--freq-yellow); }
.inv-status.st-alarm { --st: var(--battery-discharge); }
.inv-status.st-fault { --st: var(--danger); }
.inv-status.st-off,
.inv-status.st-unknown { --st: var(--text-muted); }
.inv-status.st-busy .inv-status-dot,
.inv-status.st-fault .inv-status-dot,
.inv-status.st-alarm .inv-status-dot { animation: inv-pulse 1.4s ease-in-out infinite; }
.inv-status.is-stale { filter: grayscale(.6); opacity: .8; }
.inv-status.is-stale .inv-status-dot { animation: none; }
@keyframes inv-pulse {
  0%,100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--st) 60%, transparent); }
  50%     { box-shadow: 0 0 0 4px color-mix(in srgb, var(--st) 0%, transparent); }
}
@media (prefers-reduced-motion: reduce) { .inv-status-dot { animation: none !important; } }

.inv-banner {
  --st: var(--danger);
  display: flex; align-items: center; gap: .7rem;
  margin: -0.5rem 0 1.25rem; padding: .65rem .9rem;
  border-radius: var(--radius); font-size: .88rem;
  color: var(--text);
  background: color-mix(in srgb, var(--st) 14%, var(--panel));
  border: 1px solid color-mix(in srgb, var(--st) 45%, transparent);
  border-left: 4px solid var(--st);
}
.inv-banner.st-alarm { --st: var(--battery-discharge); }
.inv-banner-icon {
  flex: none; width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 700; font-size: .8rem;
  background: var(--st); color: #fff;
}

/* SOC % on the "Nivel încărcare" row — 2.9.90 */
.battery-level-value .battery-low-badge { margin-right: .5rem; vertical-align: middle; font-family: var(--font-display); }

/* Per-plant installation data — 2.9.94 */
.plant-specs { margin: -10px 0 1.5rem; padding: .85rem 1rem 1rem; }
.ps-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .6rem; }
.ps-title { font-size: .8rem; color: var(--text-muted); letter-spacing: .02em; }
.ps-edit {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  border: 1px solid var(--panel-border); background: transparent; color: var(--text-muted); cursor: pointer;
}
.ps-edit:hover { color: var(--text); border-color: var(--text-muted); }
.ps-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; }
.ps-cell {
  padding: .6rem .75rem; border-radius: 8px;
  background: color-mix(in srgb, var(--ps) 9%, var(--panel));
  border: 1px solid color-mix(in srgb, var(--ps) 28%, transparent);
  min-width: 0;
}
.ps-label { display: flex; align-items: center; gap: .4rem; font-size: .74rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ps-icon { color: var(--ps); display: inline-flex; }
.ps-value { margin-top: .3rem; font-family: var(--font-mono); font-size: 1.15rem; color: var(--text); }
.ps-value .unit { font-family: var(--font-display); font-size: .72rem; color: var(--text-muted); margin-left: .15rem; }
.ps-value.is-empty { color: var(--text-muted); }
.ps-input { margin-top: .3rem; display: flex; align-items: center; gap: .35rem; }
.ps-input input, .ps-key {
  width: 100%; min-width: 0; padding: .3rem .45rem; border-radius: 6px;
  font: 500 1rem var(--font-mono); color: var(--text);
  background: var(--panel); border: 1px solid var(--panel-border);
}
.ps-input input:focus, .ps-key:focus { outline: 2px solid color-mix(in srgb, var(--ps, var(--solar)) 60%, transparent); outline-offset: 1px; }
.ps-input span { font-size: .72rem; color: var(--text-muted); }
.ps-actions { display: flex; align-items: center; justify-content: flex-end; gap: .5rem; margin-top: .75rem; flex-wrap: wrap; }
.ps-key { width: 140px; font-size: .85rem; }
.ps-msg { font-size: .78rem; color: var(--danger); margin-right: auto; }
.ps-btn { padding: .4rem .9rem; border-radius: 999px; font: 600 .8rem var(--font-display); cursor: pointer; border: 1px solid var(--panel-border); background: transparent; color: var(--text); }
.ps-save { background: var(--solar); border-color: var(--solar); color: #1B2429; }
@media (max-width: 720px) { .ps-grid { grid-template-columns: repeat(2, 1fr); } .ps-label { white-space: normal; align-items: flex-start; } }

/* Capacity utilisation bars — compact, collapsible (2.9.98) */
.capacity-bars { margin-bottom: 1.5rem; padding: .7rem 1rem; }
.cb-toggle { all: unset; box-sizing: border-box; width: 100%; display: flex; align-items: center; gap: .75rem; cursor: pointer; }
.cb-toggle:focus-visible { outline: 2px solid var(--solar); outline-offset: 4px; border-radius: 6px; }
.cb-title { font-size: .72rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--text-muted); white-space: nowrap; }
.cb-summary { flex: 1; display: none; justify-content: flex-end; gap: .7rem; }
.is-collapsed .cb-summary { display: flex; }
.cb-title { flex: 1; }
.is-collapsed .cb-title { flex: none; }
.cb-chip { display: inline-flex; align-items: center; gap: .3rem; font: 600 .78rem var(--font-mono); color: var(--text); }
.cb-chip i { width: 8px; height: 8px; border-radius: 50%; background: var(--cb); }
.cb-chevron { width: 8px; height: 8px; border-right: 2px solid var(--text-muted); border-bottom: 2px solid var(--text-muted); transform: rotate(45deg); margin: 0 .2rem .2rem; transition: transform .2s; flex: none; }
.is-collapsed .cb-chevron { transform: rotate(-45deg); margin-bottom: 0; }
.cb-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.25rem; margin-top: .7rem; }
.is-collapsed .cb-grid { display: none; }
.cb-top { display: flex; align-items: center; gap: .35rem; margin-bottom: .35rem; }
.cb-icon { color: var(--cb); display: inline-flex; }
.cb-name { font-size: .8rem; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cb-pct { margin-left: auto; font: 600 .9rem var(--font-mono); color: var(--text); }
.cb-track { height: 6px; border-radius: 999px; background: color-mix(in srgb, var(--cb) 14%, var(--panel-border)); overflow: hidden; }
.cb-fill { height: 100%; border-radius: inherit; background: var(--cb); transition: width .6s ease; }
.cb-detail { margin-top: .3rem; font: .7rem var(--font-mono); color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cb-cell.is-empty { opacity: .45; }
@media (max-width: 720px) { .cb-grid { grid-template-columns: repeat(2, 1fr); gap: .9rem 1rem; } .cb-summary { gap: .45rem; } .cb-chip { font-size: .7rem; } }
@media (max-width: 420px) { .is-collapsed .cb-title { display: none; } .cb-summary { justify-content: flex-start; } }

/* Collapsible power-flow section — 2.9.98 */
.flow-panel { margin-bottom: 1.5rem; }
.fl-head { display: flex; align-items: center; gap: .75rem; padding: .55rem 1rem; }  /* 2.15.7: plain heading, no collapsing */
.fl-title { flex: 1; font-size: .72rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--text-muted); white-space: nowrap; }
.fl-chip { display: inline-flex; align-items: center; gap: .3rem; font-size: .78rem; color: var(--text-muted); white-space: nowrap; }
.fl-chip i { width: 8px; height: 8px; border-radius: 50%; background: var(--fc); }
.fl-chip b { font: 600 .8rem var(--font-mono); color: var(--text); }
.fl-chip.is-idle { opacity: .5; }
.flow-panel .cb-chevron { flex: none; }

/* Simplified view — 2.9.99: only header, alert banner, power flow and
   capacity bars. */
.simple-view section.device > :not(.device-header):not(.inv-banner):not(.offline-banner):not(.flow-panel):not(.capacity-bars):not(.brand-logo-slot) { display: none !important; }
.simple-view .device-status .hero-toggle:not(.simple-toggle) { display: none; }

/* Trend chart range selector — 2.9.102 */
.trend-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; margin-bottom: .5rem; }
.trend-head .panel-title { margin-bottom: 0; }
.range-group { display: inline-flex; border: 1px solid var(--panel-border); border-radius: 999px; padding: 2px; }
.range-btn { border: 0; background: transparent; color: var(--text-muted); font: 600 .75rem var(--font-display); padding: .25rem .7rem; border-radius: 999px; cursor: pointer; }
.range-btn:hover { color: var(--text); }
.range-btn[aria-pressed="true"] { background: color-mix(in srgb, var(--solar) 18%, var(--panel)); color: var(--text); }
.range-btn:focus-visible { outline: 2px solid var(--solar); outline-offset: 1px; }

/* Capacity rings — 2.9.103 */
.cb-grid.cb-rings, .capacity-bars .cb-grid { grid-template-columns: repeat(7, 1fr); gap: .75rem; }
.cb-ring { display: flex; flex-direction: column; align-items: center; text-align: center; min-width: 0; }
.cb-ring-svg { width: 88px; height: 88px; }
.cb-ring-track { fill: none; stroke: color-mix(in srgb, var(--cb) 16%, var(--panel-border)); stroke-width: 7; }
.cb-ring-fill { fill: none; stroke: var(--cb); stroke-width: 7; stroke-linecap: round; transition: stroke-dasharray .6s ease; }
.cb-ring.is-over .cb-ring-fill { stroke: var(--danger); }
.cb-ring-pct { font: 600 13px var(--font-mono); fill: var(--text); text-anchor: middle; dominant-baseline: middle; }
.cb-ring-name { display: flex; align-items: center; gap: .3rem; margin-top: .35rem; font-size: .8rem; color: var(--text); white-space: nowrap; }
.cb-ring .cb-detail { max-width: 100%; text-align: center; white-space: normal; line-height: 1.3; }
@media (max-width: 720px) { .capacity-bars .cb-grid { grid-template-columns: repeat(4, 1fr); gap: .9rem .35rem; } .cb-ring-svg { width: 64px; height: 64px; } .cb-ring .cb-detail { font-size: .62rem; white-space: normal; line-height: 1.3; } }

/* Tariffs row in "Date instalație" — 2.9.104 */
.ps-subtitle { margin: .85rem 0 .5rem; font-size: .74rem; color: var(--text-muted); letter-spacing: .02em; }
.ps-grid.ps-tariffs { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 720px) { .ps-grid.ps-tariffs { grid-template-columns: repeat(2, 1fr); } }

/* Today: import cost / export earnings — 2.9.105 */
.money-list { margin-top: .6rem; padding-top: .6rem; border-top: 1px dashed var(--panel-border); }
.money-cost { color: var(--danger); }
.money-gain { color: var(--battery-charge); }
.money-net dt { font-weight: 600; color: var(--text); }
.money-net dd { font-weight: 600; }

/* Location row + forecast notes — 2.9.106 */
.ps-hint { color: var(--text-muted); opacity: .75; font-size: .7rem; }
.ps-grid.ps-location { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 720px) { .ps-grid.ps-location { grid-template-columns: repeat(2, 1fr); } }
.fc-split { display: block; font-size: .68rem; color: var(--text-muted); opacity: .85; margin-top: .1rem; }
.fc-basis { margin: .6rem 0 0; font-size: .72rem; color: var(--text-muted); }
.fc-warn { margin: .3rem 0 0; font-size: .72rem; color: var(--solar); }

/* Server/page version mismatch warning — 2.9.108 */
.version-warn { margin: 0 auto 1rem; max-width: 1100px; padding: .7rem 1rem; border-radius: var(--radius); font-size: .85rem; color: var(--text);
  background: color-mix(in srgb, var(--danger) 14%, var(--panel)); border: 1px solid color-mix(in srgb, var(--danger) 45%, transparent); border-left: 4px solid var(--danger); }
.version-warn code { font-family: var(--font-mono); font-size: .8rem; }

/* "Versiune nouă disponibilă" — 2.9.110 (replaces the red mismatch text) */
.version-warn { display: flex; align-items: center; justify-content: space-between; gap: .75rem; width: 100%; box-sizing: border-box;
  background: color-mix(in srgb, var(--solar) 14%, var(--panel)); border-color: color-mix(in srgb, var(--solar) 45%, transparent); border-left-color: var(--solar); font-weight: 600; }
.version-reload { border: 0; border-radius: 999px; padding: .35rem .9rem; font: 600 .8rem var(--font-display); background: var(--solar); color: #1B2429; cursor: pointer; }

/* Battery autonomy estimate — 2.9.111 */
.autonomy { display: flex; align-items: center; gap: .7rem; max-width: 560px; margin: .25rem auto 0; padding: .6rem .9rem; border-radius: var(--radius);
  --au: var(--battery-discharge); background: color-mix(in srgb, var(--au) 12%, var(--panel)); border: 1px solid color-mix(in srgb, var(--au) 40%, transparent); }
.autonomy.au-charge, .autonomy.au-full { --au: var(--battery-charge); }
.au-icon { color: var(--au); display: inline-flex; }
.au-main { font-size: .92rem; color: var(--text); }
.au-main b { font-family: var(--font-mono); }
.au-until { color: var(--text-muted); font-size: .82rem; }
.au-detail { font-size: .72rem; color: var(--text-muted); margin-top: .15rem; }
.au-chip { color: var(--battery-discharge); }
.au-chip.au-charge { color: var(--battery-charge); }
@media (max-width: 720px) { .autonomy { margin-top: 0; } }

/* Autonomy: estimate not possible — 2.9.112 */
.autonomy.au-none { --au: var(--text-muted); }

/* Model + MAC at the bottom of "Date instalație" — 2.9.115 */
.ps-device { display: flex; flex-wrap: wrap; gap: .4rem 1.4rem; margin-top: .9rem; padding-top: .7rem; border-top: 1px dashed var(--panel-border);
  font-family: var(--font-mono); font-size: .78rem; color: var(--text); }
.ps-device-k { font-family: var(--font-display); color: var(--text-muted); margin-right: .35rem; }

/* Theme switch inside "Date instalație" — 2.9.118 */
.ps-theme { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-top: .9rem; }
.ps-theme .ps-subtitle { margin: 0; }

/* "Realtime" connection label — 2.9.121 */
.status-text.is-realtime { color: var(--battery-charge); font-weight: 600; }
.status-age:empty { display: none; }

/* Owner icon — 2.9.127 */
.device-owner { display: inline-flex; align-items: center; gap: .35rem; }
.owner-icon { display: inline-flex; color: var(--text-muted); }

/* Implausible values dropped by the server — 2.10.0 */
.data-warn { display: inline-flex; align-items: center; gap: .25rem; margin-right: .6rem; padding: .12rem .5rem; border-radius: 999px;
  font-size: .72rem; font-weight: 600; color: var(--solar); background: color-mix(in srgb, var(--solar) 14%, var(--panel));
  border: 1px solid color-mix(in srgb, var(--solar) 40%, transparent); vertical-align: 2px; cursor: pointer; }

/* Daily history panel — 2.10.0 */
.daily-panel { margin-bottom: 1.5rem; }
.dh-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: .6rem; margin: .5rem 0 .3rem; }
.dh-kpis > div { padding: .5rem .7rem; border-radius: 8px; background: color-mix(in srgb, var(--panel-border) 35%, transparent); }
.dh-kpis span { display: block; font-size: .72rem; color: var(--text-muted); }
.dh-kpis b { font-family: var(--font-mono); font-size: 1rem; color: var(--text); }
.dh-kpis b.money-cost { color: var(--danger); } .dh-kpis b.money-gain { color: var(--battery-charge); }
.dh-note { margin: .2rem 0 .6rem; font-size: .72rem; color: var(--text-muted); }
.dh-chart { position: relative; height: 260px; margin: .4rem 0 .6rem; }
@media (max-width: 600px) { .dh-chart { height: 230px; } .dh-kpis { grid-template-columns: repeat(2, 1fr); } }
.dh-table-wrap summary { cursor: pointer; font-size: .8rem; color: var(--text-muted); margin: .3rem 0; }
.dh-table { max-height: 320px; overflow: auto; }
.dh-tbl td, .dh-tbl th { text-align: right; } .dh-tbl td:first-child, .dh-tbl th:first-child { text-align: left; }

/* Guided first setup — 2.10.0 */
.setup-guide { margin: 0 0 1.25rem; padding: .9rem 1rem; border-radius: var(--radius);
  background: color-mix(in srgb, var(--solar) 9%, var(--panel)); border: 1px solid color-mix(in srgb, var(--solar) 38%, transparent); }
.sg-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.sg-title { font-weight: 600; font-size: .98rem; color: var(--text); }
.sg-sub { font-size: .8rem; color: var(--text-muted); margin-top: .15rem; }
.sg-progress { flex: none; width: 120px; height: 8px; margin-top: .4rem; border-radius: 999px; background: color-mix(in srgb, var(--solar) 18%, var(--panel-border)); overflow: hidden; }
.sg-progress span { display: block; height: 100%; background: var(--solar); border-radius: inherit; }
.sg-steps { list-style: none; margin: .75rem 0 .2rem; padding: 0; display: flex; flex-wrap: wrap; gap: .45rem 1.6rem; }
.sg-steps li { white-space: nowrap; }
@media (max-width: 600px) { .sg-steps { flex-direction: column; } }
.sg-steps li { display: flex; align-items: center; gap: .45rem; font-size: .84rem; color: var(--text); }
.sg-steps li b { font-weight: 600; }
.sg-why { color: var(--text-muted); font-size: .76rem; }
.sg-check { flex: none; width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; font-size: .7rem; font-weight: 700;
  border: 1.5px solid var(--text-muted); color: #fff; }
.sg-steps li.is-done .sg-check { background: var(--battery-charge); border-color: var(--battery-charge); }
.sg-steps li.is-done b { color: var(--text-muted); text-decoration: line-through; }
.sg-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: .6rem; }
@media (max-width: 600px) { .sg-head { flex-direction: column; gap: .5rem; } .sg-progress { width: 100%; } }
.sg-go { background: var(--solar); border-color: var(--solar); color: #1B2429; }

/* ---- 30-day history window (2.10.1) ---- */
.dh-open { display: flex; align-items: center; gap: .45rem; width: 100%; margin-top: .8rem; padding: .55rem .75rem; border-radius: 8px; border: 1px solid var(--panel-border); background: color-mix(in srgb, var(--panel-border) 30%, transparent); color: var(--text); font: inherit; font-size: .82rem; cursor: pointer; transition: background .15s, border-color .15s; }
.dh-open:hover, .dh-open:focus-visible { border-color: var(--solar); background: color-mix(in srgb, var(--solar) 12%, transparent); outline: none; }
.dh-open svg { color: var(--solar); }
.dh-open-sub { margin-left: auto; font-size: .72rem; color: var(--text-muted); }
.dh-lock, .dh-lock body { overflow: hidden; }
.dh-modal { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 1.5rem; background: rgba(5, 10, 18, .62); backdrop-filter: blur(3px); }
.dh-modal[hidden] { display: none; }
.dh-dialog { width: min(980px, 100%); max-height: calc(100vh - 3rem); overflow: auto; background: linear-gradient(var(--panel), var(--panel)), var(--bg); border: 1px solid var(--panel-border); border-radius: 14px; box-shadow: 0 20px 60px rgba(0,0,0,.45); padding: 1.1rem 1.3rem 1.3rem; animation: dh-in .16s ease-out; }
@keyframes dh-in { from { opacity: 0; transform: translateY(8px) scale(.99); } to { opacity: 1; transform: none; } }
.dh-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: .4rem; position: sticky; top: -1.1rem; margin: -1.1rem -1.3rem .5rem; padding: 1.1rem 1.3rem .6rem; background: linear-gradient(var(--panel), var(--panel)), var(--bg); border-bottom: 1px solid var(--panel-border); z-index: 2; }
.dh-title { display: flex; align-items: center; gap: .45rem; font-size: 1rem; font-weight: 600; color: var(--text); }
.dh-title svg { color: var(--solar); }
.dh-sub { font-size: .78rem; color: var(--text-muted); margin-top: .15rem; }
.dh-close { flex: none; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--panel-border); background: transparent; color: var(--text-muted); cursor: pointer; }
.dh-close:hover, .dh-close:focus-visible { color: var(--text); border-color: var(--text-muted); outline: none; }
.dh-dialog .daily-panel { margin: 0; }
@media (min-width: 760px) { .dh-dialog .dh-totals .dh-kpis { grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); } .dh-dialog .dh-kpis b { font-size: .92rem; } }
.dh-dialog .dh-kpis b { white-space: nowrap; }
.dh-dialog .dh-chart { height: 320px; }
.dh-dialog .dh-table { max-height: none; }
@media (max-width: 600px) {
  .dh-modal { padding: 0; align-items: stretch; }
  .dh-dialog { max-height: none; height: 100%; border-radius: 0; border: 0; padding: 1rem; }
  .dh-head { top: -1rem; margin: -1rem -1rem .5rem; padding: 1rem 1rem .6rem; }
  .dh-dialog .dh-chart { height: 240px; }
}

/* ---- access control (2.11.0) ---- */
.ps-viewer { align-items: center; }
.ps-viewer svg { color: var(--text-muted); }
.ps-role { font-size: .7rem; padding: .1rem .5rem; border-radius: 999px; border: 1px solid var(--panel-border); color: var(--text-muted); }
.ps-role-edit { color: var(--battery-charge); border-color: color-mix(in srgb, var(--battery-charge) 45%, transparent); }

/* ---- settings change log (2.12.0) ---- */
.ps-log-wrap { flex-direction: column; align-items: flex-start; gap: .35rem; }
.ps-log-wrap svg { color: var(--text-muted); }
.ps-log summary { cursor: pointer; font-size: .78rem; color: var(--text-muted); }
.pl-list { font-family: var(--font-display); list-style: none; margin: .45rem 0 0; padding: 0; display: grid; gap: .55rem; max-height: 260px; overflow: auto; }
.pl-entry { padding: .45rem .65rem; border-radius: 8px; background: color-mix(in srgb, var(--panel-border) 28%, transparent); }
.pl-when { font-size: .74rem; color: var(--text-muted); margin-bottom: .2rem; }
.pl-changes { list-style: none; margin: 0; padding: 0; font-size: .8rem; }
.pl-field { color: var(--text-muted); }
.pl-old { text-decoration: line-through; opacity: .65; }
.pl-new { font-family: var(--font-mono); color: var(--text); }
.pl-arrow { color: var(--text-muted); }

/* ---- forecast vs actual (2.12.0) ---- */
.dh-fc { margin: .4rem 0 .8rem; padding-top: .8rem; border-top: 1px dashed var(--panel-border); }
.dh-sec { font-size: .9rem; font-weight: 600; color: var(--text); margin-bottom: .3rem; }
.dh-dialog .dh-fc-chart { height: 240px; }
@media (min-width: 760px) { .dh-dialog .dh-fc-kpis { grid-template-columns: repeat(4, 1fr); } }
.fc-good { color: var(--battery-charge) !important; }
.fc-fair { color: var(--solar) !important; }
.fc-poor { color: var(--danger) !important; }

/* ---- battery health (2.13.0) ---- */
@media (min-width: 760px) { .dh-dialog .dh-bat-kpis { grid-template-columns: repeat(var(--n, 6), 1fr); } }
.dh-dialog .dh-bat-chart { height: 240px; }
.dh-help { opacity: .8; font-style: italic; }

/* ---- days rebuilt from history (2.14.0) ---- */
.dh-est td { color: var(--text-muted); font-style: italic; }
.dh-chart[hidden] { display: none; }

.dh-fc[hidden] { display: none; }

/* ---- session expiry (2.14.0) ---- */
.ps-session { display: inline-flex; align-items: center; gap: .3rem; font-size: .78rem; color: var(--text-muted); }
.ps-session-at { opacity: .75; }
.ps-session.is-day { color: var(--solar); }
.ps-session.is-soon, .ps-session.is-expired { color: var(--danger); }

/* ---- help link (2.15.0) ---- */
a.hdr-btn { text-decoration: none; box-sizing: border-box; }

/* ---- device header (2.15.4) ----
   Row 1: owner · inverter status · Realtime/Online.
   Row 2: info (weather · warnings · house capacity) + round buttons.
   Desktop: both rows side by side on one line, row 2 on the right.
   Phones: stacked; row 2 centred, buttons 40 px — if info and buttons don't
   fit on one line, the buttons wrap onto their own centred line. */
.device-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .5rem 1rem; }
.hdr-row1 { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem; min-width: 0; }
.hdr-row1 .device-model { margin-right: .2rem; }
.status-live { display: inline-flex; align-items: center; gap: 0.45rem; margin-left: .35rem; font-size: .82rem; color: var(--text-muted); }
.hdr-row2 { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: .5rem .9rem; }
.hdr-info { display: flex; align-items: center; flex-wrap: wrap; gap: .7rem; font-size: .8rem; color: var(--text-muted); }
.hdr-info:not(:has(*)) { display: none; }
.hdr-info .device-weather { border-right: 0; padding-right: 0; }
.hdr-info .data-warn { margin-right: 0; }
/* House capacity like the weather next to it (2.15.6): same font, size and
   icon size instead of the small monospace style. */
.hdr-info { font-size: .88rem; }
.hdr-info .device-meta { display: inline-flex; align-items: center; gap: .3rem; font-family: inherit; font-size: inherit; color: inherit; }
.hdr-info .device-weather svg, .hdr-info .device-meta svg { width: 16px; height: 16px; }
.hdr-tools { gap: .35rem; }
.hdr-tools .hero-toggle, .hdr-tools .hdr-btn { margin-left: 0; }
@media (max-width: 600px) {
  .device-header { flex-direction: column; align-items: stretch; gap: .75rem; }
  .hdr-row1 { flex-wrap: nowrap; }
  .hdr-row1 .device-owner { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .hdr-row1 .status-live { margin-left: auto; flex: none; }
  .hdr-row1 .inv-status { flex: none; }
  .hdr-row2 { justify-content: center; gap: .65rem 1rem; }
  .hdr-info { font-size: .95rem; gap: .9rem; justify-content: center; }
  .hdr-info svg { width: 18px; height: 18px; }
  .hdr-info .data-warn { padding: .3rem .6rem; }
  .hdr-info .data-warn .dw-t { display: none; }
  .hdr-tools { gap: .6rem; justify-content: center; }
  .hdr-tools .hero-toggle, .hdr-tools .hdr-btn { width: 40px; height: 40px; }
  .hdr-tools svg { width: 20px; height: 20px; }
}


/* ---- ignored values: clickable chip + popover (2.15.13) ---- */
button.data-warn { font-family: inherit; cursor: pointer; line-height: 1.4; }
button.data-warn:hover { background: color-mix(in srgb, var(--solar) 24%, var(--panel)); }
button.data-warn:focus-visible { outline: 2px solid var(--solar); outline-offset: 2px; }
.dw-pop { position: fixed; z-index: 1100; background: linear-gradient(var(--panel), var(--panel)), var(--bg); color: var(--text);
  border: 1px solid color-mix(in srgb, var(--solar) 45%, var(--panel-border)); border-radius: 12px; padding: .8rem .95rem;
  box-shadow: 0 14px 40px rgba(0,0,0,.35); font-size: .85rem; animation: dh-in .14s ease-out; }
.dw-pop[hidden] { display: none; }
.dw-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; color: var(--solar); }
.dw-close { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 7px; border: 1px solid var(--panel-border); background: transparent; color: var(--text-muted); cursor: pointer; }
.dw-close:hover { color: var(--text); }
.dw-intro, .dw-foot { margin: .45rem 0; color: var(--text-muted); font-size: .8rem; line-height: 1.45; }
.dw-list { list-style: none; margin: .4rem 0; padding: 0; display: grid; gap: .45rem; }
.dw-list li { padding: .45rem .6rem; border-radius: 8px; background: color-mix(in srgb, var(--panel-border) 30%, transparent); }
.dw-name { font-weight: 600; }
.dw-name code { font-size: .72rem; color: var(--text-muted); font-weight: 400; margin-left: .25rem; }
.dw-val { color: var(--text-muted); font-size: .8rem; }
.dw-val b { color: var(--danger); font-family: var(--font-mono); }

/* ---- brand in the device header (2.16.0) ----
   Logo · "Solar Monitor" (bold) · "By Electric Team" (small), before the
   owner. Desktop: first item of the one-row header, with a divider.
   Phones: its own row on top. */
.device-header { justify-content: flex-start; }
.hdr-row2 { margin-left: auto; }
.hdr-brand { display: flex; align-items: center; gap: .55rem; padding-right: .9rem; margin-right: .2rem; border-right: 1px solid var(--panel-border); }
.hb-logo { width: 34px; height: 34px; flex: none; }
.hb-text { display: flex; flex-direction: column; line-height: 1.1; white-space: nowrap; }
.hb-text b { font-family: var(--font-display); font-size: 1.02rem; font-weight: 700; color: var(--text); letter-spacing: .01em; }
.hb-text small { font-size: .68rem; color: var(--text-muted); letter-spacing: .02em; }
@media (max-width: 600px) {
  .hdr-brand { border-right: 0; padding-right: 0; margin-right: 0; padding-bottom: .65rem; border-bottom: 1px solid var(--panel-border); }
  .hdr-row2 { margin-left: 0; }
  .hb-logo { width: 36px; height: 36px; }
  .hb-text b { font-size: 1.1rem; }
  .hb-text small { font-size: .74rem; }
}
.simple-view .settings-toggle { display: none; }

/* ---- offline banner (2.17.0) ---- */
.offline-banner { display: flex; align-items: center; gap: .6rem; margin: -.4rem 0 1.1rem; padding: .65rem .9rem; border-radius: 10px;
  background: color-mix(in srgb, var(--danger) 12%, var(--panel)); border: 1px solid color-mix(in srgb, var(--danger) 45%, transparent);
  color: var(--text); font-size: .9rem; }
.offline-banner svg { color: var(--danger); flex: none; }
.offline-banner b { font-weight: 600; }
.offline-banner .ob-at { font-family: var(--font-mono); }

/* ==== 2.17.0 — alerts, today vs forecast, connection, skeleton, a11y ==== */
/* Contrast: muted text a touch darker (light) / lighter (dark) — ≥ 4.5:1 */
:root { --text-muted-light: #56616B; --text-muted-dark: #8A99A1; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* alerts bell */
.alerts-btn { position: relative; }
.alerts-btn.has-alerts { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 50%, transparent); }
.al-badge { position: absolute; top: -5px; right: -5px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 999px; background: var(--danger);
  color: #fff; font: 700 .66rem/17px var(--font-display); text-align: center; box-shadow: 0 0 0 2px var(--panel); }
.al-list { list-style: none; margin: .5rem 0; padding: 0; display: grid; gap: .45rem; }
.al-item { display: flex; gap: .6rem; align-items: flex-start; padding: .5rem .6rem; border-radius: 8px; background: color-mix(in srgb, var(--panel-border) 30%, transparent); }
.al-item b { display: block; font-weight: 600; }
.al-item small { color: var(--text-muted); font-size: .76rem; }
.al-ico { color: var(--danger); flex: none; margin-top: .1rem; }
.al-item.al-offline .al-ico, .al-item.al-over_capacity .al-ico { color: var(--solar); }
.al-none { color: var(--battery-charge); margin: .6rem 0; }

/* Today vs forecast */
.tf { margin: .1rem 0 .8rem; }
.tf-top { display: flex; align-items: baseline; gap: .5rem; font-size: .85rem; color: var(--text-muted); }
.tf-top b { color: var(--text); font-family: var(--font-mono); font-weight: 600; }
.tf-pct { margin-left: auto; font-weight: 700; color: var(--solar); }
.tf-bar { height: 10px; border-radius: 999px; background: color-mix(in srgb, var(--panel-border) 60%, transparent); overflow: hidden; margin: .35rem 0 .3rem; }
.tf-bar i { display: block; height: 100%; border-radius: inherit; background: var(--solar); transition: width .6s ease; }
.tf.is-over .tf-bar i { background: var(--battery-charge); }
.tf.is-over .tf-pct { color: var(--battery-charge); }
.tf-note { font-size: .74rem; color: var(--text-muted); }

/* rings: over capacity in words too */
.cb-over { font-size: .7rem; font-weight: 600; color: var(--danger); margin-top: .1rem; }

/* connection bar */
.conn-banner { position: fixed; top: 0; left: 0; right: 0; z-index: 1200; display: flex; align-items: center; justify-content: center; gap: .55rem;
  padding: .5rem 1rem; background: color-mix(in srgb, var(--solar) 18%, var(--panel)); border-bottom: 1px solid color-mix(in srgb, var(--solar) 50%, transparent);
  color: var(--text); font-size: .86rem; box-shadow: 0 6px 20px rgba(0,0,0,.18); }
.conn-banner[hidden] { display: none; }
.conn-spin { width: 14px; height: 14px; border-radius: 50%; border: 2px solid color-mix(in srgb, var(--solar) 35%, transparent); border-top-color: var(--solar); animation: conn-spin .8s linear infinite; }
@keyframes conn-spin { to { transform: rotate(360deg); } }

/* loading skeleton */
.skel { max-width: 1100px; margin: 0 auto; }
.skel i, .skel-block { display: block; background: linear-gradient(90deg, color-mix(in srgb, var(--panel-border) 55%, transparent) 25%, color-mix(in srgb, var(--panel-border) 90%, transparent) 50%, color-mix(in srgb, var(--panel-border) 55%, transparent) 75%);
  background-size: 200% 100%; animation: skel-shine 1.3s ease-in-out infinite; border-radius: 8px; }
.skel-hdr { display: flex; align-items: center; gap: .6rem; margin-bottom: 1.25rem; }
.skel-logo { width: 34px; height: 34px; border-radius: 50% !important; }
.skel-line { height: 14px; }
.skel-line.w30 { width: 140px; } .skel-line.w15 { width: 80px; }
.skel-sp { flex: 1; }
.skel-dot { width: 30px; height: 30px; border-radius: 50% !important; }
.skel-block { border-radius: 14px; }
.skel-flow { height: 340px; margin-bottom: 1rem; }
.skel-mid { height: 120px; margin-bottom: 1rem; }
.skel-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.skel-grid .skel-block { height: 150px; }
.skel-msg { text-align: center; color: var(--text-muted); font-size: .9rem; margin-top: 1rem; }
@keyframes skel-shine { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }
@media (max-width: 600px) { .skel-grid { grid-template-columns: 1fr; } .skel-flow { height: 280px; } }
@media (prefers-reduced-motion: reduce) { .skel i, .skel-block, .conn-spin { animation: none; } }

/* ---- no data for today yet (2.17.1) ---- */
.day-stale { display: flex; align-items: flex-start; gap: .5rem; margin: .3rem 0 .6rem; padding: .6rem .75rem; border-radius: 9px;
  background: color-mix(in srgb, var(--panel-border) 35%, transparent); color: var(--text-muted); font-size: .86rem; line-height: 1.45; }
.day-stale svg { flex: none; margin-top: .15rem; color: var(--solar); }
.day-stale b { color: var(--text); font-family: var(--font-mono); font-weight: 500; }
.fl-offline { display: inline-flex; align-items: center; gap: .3rem; font-size: .75rem; color: var(--danger); }   /* 2.17.2 */

.cb-ring .cb-extra { margin-top: .1rem; }

/* 2.19.4: bold card titles (Battery, Solar, AC loads, AC grid, Today, Lifetime, Prognoză, Istoric) */
.panel-title.is-strong { font-weight: 700; color: var(--text); }

/* ==== 2.20.0 ============================================================ */
/* Empty battery: red and clearly visible instead of faded like an idle node. */
.flow-node.battery.is-depleted {
  color: var(--danger); opacity: 1;
  background: color-mix(in srgb, var(--danger) 14%, var(--panel));
  border: 2px solid var(--danger);
  box-shadow: 0 0 18px 2px color-mix(in srgb, var(--danger) 40%, transparent);
}
.flow-node.battery.is-depleted .flow-label { color: var(--danger); font-weight: 700; }
.flow-node.battery.is-depleted .flow-value { color: var(--text); }
.hero-tile.is-depleted { border-top-color: var(--danger) !important; opacity: 1; filter: none; }
.hero-tile.is-depleted .hero-sublabel { color: var(--danger); font-weight: 600; }
.cb-ring.is-depleted .cb-ring-track { stroke: color-mix(in srgb, var(--danger) 55%, var(--panel-border)); }
.cb-ring.is-depleted .cb-ring-pct { fill: var(--danger); }
.cb-ring.is-depleted .cb-extra { color: var(--danger); font-weight: 600; }
.autonomy.au-empty { --au: var(--danger); border-color: color-mix(in srgb, var(--danger) 55%, transparent) !important;
  background: color-mix(in srgb, var(--danger) 10%, var(--panel)) !important; }
.autonomy.au-empty .au-main { font-weight: 600; }

/* Capacity rings: only the ones that are set, centred; link for the rest. */
.capacity-bars .cb-grid { display: flex; flex-wrap: wrap; justify-content: center; gap: .9rem 1.4rem; }
.capacity-bars .cb-ring { width: 130px; }
.cb-unset { display: block; margin: .75rem auto 0; padding: .3rem .8rem; border: 1px dashed var(--panel-border); border-radius: 999px;
  background: transparent; color: var(--text-muted); font: 500 .76rem var(--font-display); cursor: pointer; }
.cb-unset:hover { color: var(--text); border-color: var(--text-muted); }
.capacity-bars.is-collapsed .cb-unset { display: none; }
@media (max-width: 720px) {
  .capacity-bars .cb-grid { gap: .9rem .3rem; }
  .capacity-bars .cb-ring { width: calc(25% - .3rem); }
}

/* Cards take the height of their own content — no empty space inside. */
.panel-grid { align-items: start; }

/* Forecast inside "Azi" */
.fc-in-today { margin: .2rem 0 .9rem; padding: .6rem .7rem; border-radius: 8px; background: color-mix(in srgb, var(--solar) 7%, transparent);
  border: 1px solid color-mix(in srgb, var(--solar) 22%, transparent); }
.fc-in-today .fc-sub { font-size: .72rem; color: var(--text-muted); letter-spacing: .02em; margin-bottom: .35rem; }
.fc-in-today .fc-basis { margin-top: .35rem; }

/* Header: ⋯ menu on phones only */
.hdr-more { display: none; }
@media (max-width: 600px) {
  .hdr-tools .hdr-wide { display: none; }
  .hdr-more { display: inline-grid; place-items: center; }
}
.more-pop { padding: .35rem; }
.more-list { display: grid; }
.more-item { display: flex; align-items: center; gap: .65rem; width: 100%; padding: .7rem .75rem; border: 0; border-radius: 8px;
  background: transparent; color: var(--text); font: 500 .95rem var(--font-display); text-align: left; text-decoration: none; cursor: pointer; }
.more-item:hover, .more-item:focus-visible { background: color-mix(in srgb, var(--panel-border) 45%, transparent); outline: none; }
.more-item svg { color: var(--text-muted); flex: none; }
.more-item.hero-toggle, .more-item.dh-open-icon { width: 100%; height: auto; margin: 0; border: 0; border-radius: 8px; background: transparent; justify-content: flex-start; color: var(--text); }
.more-item.hero-toggle[aria-pressed="true"] { background: transparent; color: var(--text); }

/* ==== 2.21.0: tablet view — header + a large power flow filling the screen ==== */
.tablet-view .capacity-bars, .tablet-view .fl-head, .tablet-view .app-footer { display: none !important; }
.tablet-view .flow-panel { margin-bottom: 0; }
.tablet-view .flow-section { margin-bottom: .6rem; }
.simple-toggle[data-mode="tablet"] { color: var(--solar); border-color: color-mix(in srgb, var(--solar) 55%, transparent); background: color-mix(in srgb, var(--solar) 14%, var(--panel)); }
@media (min-width: 601px) {
  /* as wide as the screen height allows (header + autonomy line stay visible) */
  .tablet-view .flow-wrap { max-width: min(100%, calc((100dvh - 230px) * 680 / 580)); min-width: 560px; container-type: inline-size; }
  .tablet-view .flow-node { width: 17%; min-height: 0; aspect-ratio: 1 / 1.08; padding: 2%; gap: 6%; border-radius: 14px; }
  .tablet-view .flow-node svg { width: 44%; flex: none; }
  .tablet-view .flow-label { font-size: .8rem; font-size: max(.75rem, 1.65cqw); line-height: 1.2; }
  .tablet-view .flow-value { font-size: 1.1rem; font-size: max(.95rem, 2.7cqw); font-weight: 700; white-space: nowrap; }
  .tablet-view .flow-line { stroke-width: 2.4; }
  .tablet-view .flow-hub { r: 8; }
  .tablet-view .autonomy { max-width: min(900px, 100%); padding: .85rem 1.2rem; gap: 1rem; }
  .tablet-view .au-icon svg { width: 28px; height: 28px; }
  .tablet-view .au-main { font-size: 1.35rem; font-weight: 600; }
  .tablet-view .au-detail { font-size: .92rem; margin-top: .25rem; }
  .tablet-view .device-header { margin-bottom: .4rem; }
}
@media (max-width: 600px) {
  .tablet-view .flow-value { font-size: .9rem; font-weight: 700; }
  .tablet-view .au-main { font-size: 1.05rem; font-weight: 600; }
}
.simple-view section.device { overflow: hidden; }  /* the brand mark stays inside the shorter card */

/* 2.22.2: owner - model (smaller) in the header */
.device-owner .owner-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.device-owner .owner-sep { color: var(--text-muted); font-weight: 400; }
.device-owner .owner-model { font-size: .72em; font-weight: 500; color: var(--text-muted); font-family: var(--font-mono); letter-spacing: .01em; }
@media (max-width: 600px) {
  .device-owner .owner-text { display: flex; flex-direction: column; line-height: 1.15; }
  .device-owner .owner-name, .device-owner .owner-model { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .device-owner .owner-sep { display: none; }
  .device-owner .owner-model { font-size: .68em; }
}

/* 2.22.3: GPS button next to "Locație și panouri" */
.ps-sub-row { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem .75rem; }
.ps-gps { display: inline-flex; align-items: center; gap: .35rem; padding: .25rem .7rem; font-size: .74rem; color: var(--grid);
  border-color: color-mix(in srgb, var(--grid) 45%, transparent); background: color-mix(in srgb, var(--grid) 10%, transparent); letter-spacing: 0; }
.ps-gps:hover { background: color-mix(in srgb, var(--grid) 18%, transparent); }
.ps-gps-msg { font-size: .74rem; color: var(--text-muted); letter-spacing: 0; }
.ps-input input.ps-filled { outline: 2px solid var(--battery-charge); transition: outline-color .3s; }

/* ---- 2.23.0: several topics summed in one page ("Topicuri" panel) ------- */
.topics-toggle { position: relative; }
.topics-toggle[aria-pressed="true"] { color: var(--grid); border-color: color-mix(in srgb, var(--grid) 55%, transparent); background: color-mix(in srgb, var(--grid) 14%, var(--panel)); }
.tp-badge { background: var(--grid); }
.topics-panel { max-width: 1100px; margin: 5px auto 0; padding: .75rem .9rem .8rem; border: 1px solid var(--panel-border); border-radius: 14px;
  background: var(--panel); display: grid; gap: .55rem; }
.topics-panel[hidden] { display: none; }
.topics-panel + #app { margin-top: 1rem; }
.tp-head { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.tp-head > b { display: inline-flex; align-items: center; gap: .35rem; font-size: .95rem; }
.tp-head .tp-close { margin-left: auto; }
.tp-mode small { font-size: .78rem; }
.tp-seg { display: inline-flex; border: 1px solid var(--panel-border); border-radius: 999px; padding: 2px; }
.tp-agg { border: 0; background: transparent; color: var(--text-muted); font: 600 .75rem var(--font-display); padding: .22rem .7rem; border-radius: 999px; cursor: pointer; }
.tp-agg.is-on { background: color-mix(in srgb, var(--grid) 22%, var(--panel)); color: var(--text); }
.tp-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .4rem; }
.tp-chip { --tp: var(--text-muted); display: inline-flex; align-items: center; gap: .4rem; max-width: 100%; padding: .28rem .3rem .28rem .6rem;
  border-radius: 999px; border: 1px solid color-mix(in srgb, var(--tp) 45%, var(--panel-border)); background: color-mix(in srgb, var(--tp) 10%, var(--panel)); }
.tp-chip.tp-ok { --tp: var(--battery-charge); }
.tp-chip.tp-searching { --tp: var(--solar); }
.tp-chip.tp-not_found, .tp-chip.tp-forbidden, .tp-chip.tp-limit, .tp-chip.tp-invalid { --tp: var(--danger); }
.tp-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--tp, var(--text-muted)); flex: none; }
.tp-name { font: 500 .8rem var(--font-mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.tp-st { color: var(--text-muted); font-size: .72rem; white-space: nowrap; }
.tp-chip:not(:has(.tp-remove)) { padding-right: .7rem; }
.tp-remove { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; border: 0; background: transparent; color: var(--text-muted); cursor: pointer; }
.tp-remove:hover { color: var(--danger); background: color-mix(in srgb, var(--danger) 14%, transparent); }
.tp-add { display: flex; gap: .45rem; }
.tp-add input { flex: 1; min-width: 0; padding: .45rem .7rem; border-radius: 999px; border: 1px solid var(--panel-border); background: var(--bg); color: var(--text);
  font: 400 .85rem var(--font-mono); }
.tp-add input:focus { outline: 2px solid color-mix(in srgb, var(--grid) 60%, transparent); outline-offset: 1px; }
.tp-add-btn { white-space: nowrap; }
.tp-msg { margin: 0; font-size: .78rem; color: var(--danger); }
.tp-msg:empty { display: none; }
.tp-mh { font-size: .78rem; color: var(--text); }
.tp-mlist { list-style: none; margin: .35rem 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: .3rem .9rem; font-size: .8rem; }
.tp-mlist li { display: inline-flex; align-items: center; gap: .35rem; }
.tp-mlist li.is-on { --tp: var(--battery-charge); }
.tp-mlist li.is-off { --tp: var(--danger); color: var(--text-muted); }
.tp-mlist small { color: var(--text-muted); font-family: var(--font-mono); font-size: .7rem; }
.al-item .al-dev { display: block; color: var(--text); font-weight: 500; }
@media (max-width: 600px) {
  .topics-panel { margin: 5px .4rem 0; padding: .6rem .65rem; }
  .tp-name { max-width: 55vw; }
}

/* ---- 2.23.2: per-inverter rows in the flow nodes (aggregate) ------------- */
.flow-node.has-split { width: 172px; gap: 5px; padding: 8px 9px 7px; justify-content: flex-start; }
.flow-node.has-split > svg { width: 28%; }
.fs-rows { width: 100%; display: grid; gap: 3px; margin-top: 2px; padding-top: 5px; border-top: 1px solid color-mix(in srgb, currentColor 22%, transparent); }
.fs-row { display: grid; grid-template-columns: minmax(0, 1fr) 30px auto; align-items: center; gap: 5px; font-size: .64rem; line-height: 1.25; text-align: left; color: var(--text); }
.fs-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-muted); }
.fs-name i { font-style: normal; font-weight: 700; color: currentColor; }
.fs-row b { font-family: var(--font-mono); font-weight: 500; white-space: nowrap; text-align: right; }
.fs-bar { height: 4px; border-radius: 2px; background: color-mix(in srgb, var(--panel-border) 70%, transparent); overflow: hidden; }
.fs-bar i { display: block; height: 100%; border-radius: 2px; background: currentColor; }
.flow-node.solar .fs-row, .flow-node.solar .fs-name i { color: var(--solar); }
.flow-node.loads .fs-row { color: var(--loads); }
.fs-row.fs-in { color: var(--battery-charge); }
.fs-row.fs-out { color: var(--battery-discharge); }
.fs-row.fs-imp { color: var(--danger); }
.fs-row.fs-exp { color: var(--battery-charge); }
.fs-row b { color: var(--text); }
.fs-row.is-idle .fs-bar i { opacity: .35; }
.fs-row.is-off { opacity: .45; }
.fs-more { justify-self: center; margin-top: 1px; padding: 1px 10px; border-radius: 999px; border: 1px solid var(--panel-border); background: var(--panel);
  color: var(--text-muted); font: 600 .62rem var(--font-display); cursor: pointer; }
.fs-more:hover { color: var(--text); }
.flow-node.is-zero .fs-rows { opacity: .9; }
/* the bottom (Grid) node grows below the diagram: reserve its room */
.flow-agg .flow-wrap { margin-bottom: calc(var(--fs-rows, 0) * 15px + 1.2rem); }
@media (max-width: 600px) {
  .flow-node.has-split { width: 31%; aspect-ratio: auto; padding: 6px 5px 5px; gap: 2px; }
  .flow-node.has-split > svg { width: 30%; }
  .fs-row { grid-template-columns: minmax(0, 1fr) auto; font-size: .55rem; gap: 3px; }
  .fs-bar { display: none; }
  .flow-agg .flow-wrap { margin-bottom: calc(var(--fs-rows, 0) * 13px + 3.5rem); }
}
.fs-row.fs-bat { grid-template-columns: minmax(0, 1fr) auto 28px; }
.fs-row.fs-bat .fs-bar { display: none; }
.fs-row.fs-bat small { font-family: var(--font-mono); font-size: .95em; color: var(--text-muted); text-align: right; }
.flow-node.has-split { z-index: 2; }
@media (max-width: 600px) { .fs-row.fs-bat { grid-template-columns: minmax(0, 1fr) auto 22px; } }

/* ---- 2.23.3: per-inverter details under the total ------------------------ */
.agg-details { margin-top: 1.4rem; display: grid; gap: .6rem; }
.agg-head { display: flex; align-items: center; justify-content: space-between; gap: .6rem; flex-wrap: wrap; padding: 0 .3rem; }
.agg-tools { display: inline-flex; gap: .35rem; }
.agg-tools .ps-btn { padding: .25rem .7rem; font-size: .72rem; }
.agg-dev { border: 1px solid var(--panel-border); border-radius: 12px; background: var(--panel); }
.agg-dev > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: .55rem .9rem; flex-wrap: wrap; padding: .65rem .85rem; }
.agg-dev > summary::-webkit-details-marker { display: none; }
.agg-dev > summary::before { content: ""; width: 7px; height: 7px; border-right: 2px solid var(--text-muted); border-bottom: 2px solid var(--text-muted);
  transform: rotate(-45deg); transition: transform .15s ease; flex: none; margin-right: .1rem; }
.agg-dev[open] > summary::before { transform: rotate(45deg); }
.agg-dev[open] > summary { border-bottom: 1px solid var(--panel-border); }
.agg-name { display: inline-flex; align-items: baseline; gap: .45rem; min-width: 0; --tp: var(--battery-charge); }
.agg-dev.is-offline .agg-name { --tp: var(--danger); }
.agg-name .tp-dot { align-self: center; }
.agg-name b { font-weight: 600; }
.agg-model { color: var(--text-muted); font-family: var(--font-mono); font-size: .72rem; }
.agg-st { font-size: .72rem; padding: .1rem .5rem; border-radius: 999px; }
.agg-st.is-on { color: var(--battery-charge); background: color-mix(in srgb, var(--battery-charge) 14%, transparent); }
.agg-st.is-off { color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, transparent); }
.agg-chips { display: inline-flex; flex-wrap: wrap; gap: .35rem .75rem; margin-left: auto; font-family: var(--font-mono); font-size: .78rem; }
.agg-k { display: inline-flex; align-items: center; gap: .25rem; color: var(--text); }
.agg-k svg { color: var(--text-muted); }
.agg-k.k-sol svg { color: var(--solar); }
.agg-k.k-in svg { color: var(--battery-charge); } .agg-k.k-out svg { color: var(--battery-discharge); }
.agg-k.k-imp svg { color: var(--danger); } .agg-k.k-exp svg { color: var(--battery-charge); }
.agg-id { color: var(--text-muted); font-family: var(--font-mono); font-size: .7rem; }
.agg-grid { padding: .7rem; }
@media (max-width: 600px) {
  .agg-chips { margin-left: 0; width: 100%; }
  .agg-grid { padding: .4rem; }
}
/* 2.23.4: per-inverter rows in the optional nodes */
.fs-row.fs-gen { color: var(--gen); }
.fs-row.fs-pvinv { color: var(--pvinv); }
.fs-row.fs-smart { color: var(--smart); }
.fs-row.fs-ev { color: var(--ev); }

/* ---- 2.23.5: wider diagrams in the aggregate view (≥ 960 px) ------------- */
.flow-wrap.is-wide { max-width: 1060px; aspect-ratio: 1060 / 580; }
.flow-wrap.is-wide .flow-node.has-split { width: 240px; }
.flow-wrap.is-wide .fs-row { grid-template-columns: minmax(0, 1fr) 54px auto; font-size: .68rem; }
.flow-wrap.is-wide .fs-row.fs-bat { grid-template-columns: minmax(0, 1fr) auto 30px; }
.sc-panel.sc-wide { max-width: 1060px; }

/* ---- 2.23.8: "Date instalație" per topic in the aggregate view ----------- */
.settings-hidden .agg-specs { display: none; }
.agg-specs { margin: 0 0 1.2rem; }
.agg-cfg-wrap { overflow-x: auto; }
.agg-cfg-table { min-width: 760px; }
.agg-cfg-table td, .agg-cfg-table th { white-space: nowrap; vertical-align: middle; }
.agg-cfg-table .unit { color: var(--text-muted); font-size: .8em; }
.agg-cfg-dev b { display: block; font-family: var(--font-display); font-weight: 600; }
.agg-cfg-dev small { color: var(--text-muted); font-size: .72rem; }
.agg-cfg-table tr.is-editing td { background: color-mix(in srgb, var(--solar) 8%, transparent); }
.agg-cfg-table .ps-btn { padding: .2rem .65rem; font-size: .72rem; display: inline-flex; align-items: center; gap: .3rem; }
.agg-cfg-formrow > td { white-space: normal; padding: .6rem .2rem 1rem; }
.agg-cfg-head { font-size: .85rem; margin-bottom: .6rem; }
.agg-cfg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .55rem .9rem; }
.agg-cfg-cell { display: grid; gap: .2rem; font-size: .74rem; color: var(--text-muted); }
.agg-cfg-cell .ps-input { display: flex; align-items: center; gap: .3rem; }
.agg-cfg-cell input { flex: 1; min-width: 0; padding: .35rem .5rem; border-radius: 7px; border: 1px solid var(--panel-border); background: var(--bg); color: var(--text); font: 400 .85rem var(--font-mono); }
.agg-cfg-cell .ps-input > span { color: var(--text-muted); font-size: .72rem; }
.agg-cfg-actions { display: flex; align-items: center; justify-content: flex-end; gap: .5rem; margin-top: .8rem; }
.agg-cfg-actions .ps-msg { margin-right: auto; }
.agg-cfg-table .agg-cfg-dev, .agg-cfg-table th:first-child, .agg-cfg-formrow, .agg-cfg-formrow td, .agg-cfg-head { text-align: left; }

/* ---- 2.23.9: every node in the aggregate view has the same size ---------- */
/* fixed row height + a rows area as tall as the longest list, so nodes with
   fewer (or no) rows are as tall as the others in their row of the diagram */
.flow-agg .fs-row { height: 15px; }
.flow-agg .fs-more { height: 15px; line-height: 13px; padding-top: 0; padding-bottom: 0; }
.flow-agg .fs-rows { min-height: calc(var(--fs-rows, 0) * 18px + 3px); align-content: start; }
.flow-agg .fs-rows.fs-empty { display: grid; place-items: center; align-content: center; color: var(--text-muted); font-size: .62rem; text-align: center; }
.flow-agg .flow-node.has-split > svg { height: 40px; width: auto; flex: none; }
.flow-agg .flow-node.has-split .flow-label { min-height: 1.2em; }
.flow-wrap.is-wide .fs-row, .flow-wrap.is-wide .fs-more { height: 16px; }
.flow-wrap.is-wide .fs-rows { min-height: calc(var(--fs-rows, 0) * 19px + 3px); }
@media (max-width: 600px) {
  .flow-agg .fs-row, .flow-agg .fs-more { height: 13px; }
  .flow-agg .fs-rows { min-height: calc(var(--fs-rows, 0) * 16px + 3px); }
  .flow-agg .flow-node.has-split > svg { height: 24px; }
}

/* ---- 2.23.11: wider page in the aggregate view; aligned capacity bars ---- */
body.agg-mode #app, body.agg-mode .topics-panel { max-width: 1480px; }
.flow-wrap.is-wide .flow-node.has-split { width: var(--fn-w, 240px); }
/* fixed columns: name | bar | value | % (capacity, or SOC for the battery) */
.flow-agg .fs-row, .flow-agg .fs-row.fs-bat { grid-template-columns: minmax(0, 1fr) 40px 52px 30px; }
.flow-wrap.is-wide .fs-row, .flow-wrap.is-wide .fs-row.fs-bat { grid-template-columns: minmax(0, 1fr) 64px 62px 34px; }
.flow-agg .fs-row.fs-bat .fs-bar { display: block; }
.flow-agg .fs-row small { font-family: var(--font-mono); font-size: .95em; color: var(--text-muted); text-align: right; }
.flow-agg .fs-row.fs-share .fs-bar i { background: repeating-linear-gradient(-45deg, currentColor 0 2px, transparent 2px 4px); opacity: .75; }
.flow-agg .fs-row.is-over .fs-bar i { background: var(--danger); }
.flow-agg .fs-row.is-over small { color: var(--danger); font-weight: 600; }
.flow-agg .fs-row.fs-bat.fs-in .fs-bar i { background: var(--battery-charge); }
.flow-agg .fs-row.fs-bat.fs-out .fs-bar i { background: var(--battery-discharge); }
@media (max-width: 600px) {
  .flow-agg .fs-row, .flow-agg .fs-row.fs-bat { grid-template-columns: minmax(0, 1fr) auto 26px; }
  .flow-agg .fs-row .fs-bar, .flow-agg .fs-row.fs-bat .fs-bar { display: none; }
}
.fs-name .fs-soc { font-style: normal; font-family: var(--font-mono); font-size: .92em; color: var(--text-muted); }
.agg-loading { padding: .6rem .4rem; font-size: .8rem; }

/* ---- 2.24.0: saved groups in the Topicuri panel -------------------------- */
.tp-groups { border-top: 1px solid var(--panel-border); padding-top: .6rem; display: grid; gap: .45rem; }
.tp-gh { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .6rem; font-size: .85rem; }
.tp-glist { display: inline-flex; flex-wrap: wrap; gap: .35rem; }
.tp-gchip { display: inline-flex; align-items: center; gap: .35rem; padding: .2rem .65rem; border-radius: 999px; border: 1px solid var(--panel-border);
  color: var(--text); text-decoration: none; font-size: .8rem; background: var(--bg); }
.tp-gchip small { color: var(--text-muted); font-family: var(--font-mono); }
.tp-gchip:hover { border-color: var(--grid); }
.tp-gchip.is-on { border-color: var(--grid); background: color-mix(in srgb, var(--grid) 16%, var(--panel)); }
.tp-gform { display: flex; flex-wrap: wrap; align-items: end; gap: .5rem .8rem; }
.tp-gform label { display: grid; gap: .2rem; font-size: .72rem; color: var(--text-muted); }
.tp-gform input { padding: .38rem .6rem; border-radius: 8px; border: 1px solid var(--panel-border); background: var(--bg); color: var(--text); font: 400 .85rem var(--font-body, inherit); }
.tp-gform input[name="name"] { min-width: 220px; }
.tp-gform input[name="soc_low"], .tp-gform input[name="import_kw"] { width: 80px; font-family: var(--font-mono); }
.tp-gform .ps-input { display: inline-flex; align-items: center; gap: .3rem; }
.tp-gbtns { display: inline-flex; gap: .4rem; margin-left: auto; }
.tp-gmsg { margin: 0; font-size: .78rem; color: var(--danger); }
.tp-gmsg:empty { display: none; }

/* ---- 2.25.2: access to The Code's set_settings from the page ------------- */
.src-form { display: flex; flex-wrap: wrap; align-items: end; gap: .55rem .8rem; margin-top: .8rem; text-align: left; }
.src-form label { display: grid; gap: .2rem; font-size: .74rem; color: var(--text-muted); }
.src-form input { padding: .42rem .65rem; border-radius: 8px; border: 1px solid var(--panel-border); background: var(--bg); color: var(--text); font: 400 .88rem var(--font-mono); min-width: 190px; }
.src-form .src-adv { flex-basis: 100%; font-size: .74rem; color: var(--text-muted); }
.src-form .src-adv summary { cursor: pointer; }
.src-form .src-adv input { min-width: min(420px, 80vw); margin-top: .3rem; }
.src-msg { flex-basis: 100%; margin: 0; font-size: .8rem; }
.src-msg:empty { display: none; }
.src-msg.is-bad { color: var(--danger); } .src-msg.is-ok { color: var(--battery-charge); }
.plant-state .src-form { justify-content: center; }
.src-block { padding: 0 0 .8rem; margin-bottom: .8rem; border-bottom: 1px solid var(--panel-border); }
.src-head { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .8rem; font-size: .84rem; }
.src-head .src-toggle { margin-left: auto; padding: .22rem .7rem; font-size: .74rem; }
.src-ok { color: var(--battery-charge); font-size: .78rem; } .src-bad { color: var(--danger); font-size: .78rem; }

/* ---- 2.26.0: commands to one device ---------------------------------------- */
.cmd-panel { grid-column: 1 / -1; }
.cmd-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: .6rem; margin-top: .4rem; }
.cmd-sec { border: 1px solid var(--panel-border); border-radius: 10px; padding: .4rem .65rem .6rem; margin: 0; display: grid; gap: .4rem; }
.cmd-sec legend { padding: 0 .3rem; font-size: .78rem; font-weight: 600; color: var(--text); }
.cmd-f { display: grid; gap: .15rem; font-size: .72rem; color: var(--text-muted); }
.cmd-f input, .cmd-f select { padding: .35rem .5rem; border-radius: 7px; border: 1px solid var(--panel-border); background: var(--bg); color: var(--text); font: 400 .85rem var(--font-mono); min-width: 0; width: 100%; }
.cmd-f .ps-input { display: flex; align-items: center; gap: .3rem; }
.cmd-f .ps-input > span { font-size: .72rem; }
.cmd-actions { display: flex; flex-wrap: wrap; align-items: end; gap: .5rem .8rem; margin-top: .7rem; }
.cmd-hint { font-size: .74rem; margin-right: auto; align-self: center; }
.cmd-key input { width: 200px; }
.cmd-msg { margin: .5rem 0 0; font-size: .8rem; }
.cmd-msg:empty { display: none; }
.cmd-msg.is-bad { color: var(--danger); } .cmd-msg.is-ok { color: var(--battery-charge); }
.cmd-msg pre { margin: .35rem 0 0; padding: .5rem .6rem; border-radius: 8px; background: var(--bg); color: var(--text); font-size: .72rem; max-height: 220px; overflow: auto; }

/* 2.27.0: command cards in the colors of the power flow */
.cmd-sec { --cmd-c: var(--text-muted); border-color: color-mix(in srgb, var(--cmd-c) 45%, var(--panel-border));
  background: color-mix(in srgb, var(--cmd-c) 8%, transparent); border-left: 4px solid var(--cmd-c); }
.cmd-sec legend { color: var(--cmd-c); }
.cmdc-bat { --cmd-c: var(--battery-charge); }
.cmdc-solar { --cmd-c: var(--solar); }
.cmdc-grid { --cmd-c: var(--grid); }
.cmdc-gen { --cmd-c: var(--gen); }
.cmdc-pvinv { --cmd-c: var(--pvinv); }

/* 2.27.0: Automatizări */
.rules-panel-box > summary { cursor: pointer; list-style: none; margin-bottom: 0; }
.rules-panel-box > summary::-webkit-details-marker { display: none; }
.rules-panel-box > summary::before { content: "\25B8"; display: inline-block; margin-right: .4rem; transition: transform .15s; }
.rules-panel-box[open] > summary::before { transform: rotate(90deg); }
.rules-panel-box[open] > summary { margin-bottom: .75rem; }
.rules-count { color: var(--solar); font-weight: 600; }
.rules-total { display: flex; flex-wrap: wrap; gap: .35rem 1rem; font-size: .8rem; font-family: var(--font-mono); padding: .5rem .7rem;
  border: 1px dashed var(--panel-border); border-radius: 10px; margin-bottom: .7rem; }
.rules-total .muted { font-family: var(--font-display, inherit); }
.rules-list { list-style: none; margin: 0 0 .7rem; padding: 0; display: grid; gap: .5rem; }
.rule { border: 1px solid var(--panel-border); border-radius: 10px; padding: .55rem .75rem; display: grid; gap: .35rem; }
.rule.is-disabled { opacity: .6; }
.rule-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: .5rem; }
.rule-body { font-size: .82rem; line-height: 1.6; }
.rule-body code { font-size: .78rem; padding: .05rem .35rem; border-radius: 6px; background: color-mix(in srgb, var(--text) 8%, transparent); }
.rule-act { display: inline-block; font-size: .76rem; padding: .05rem .45rem; margin: .1rem .15rem 0 0; border-radius: 999px;
  --c: var(--cmd-c, var(--text-muted)); color: var(--c);
  border: 1px solid color-mix(in srgb, var(--c) 55%, transparent); background: color-mix(in srgb, var(--c) 12%, transparent); }
.rule-st { font-size: .74rem; padding: .05rem .5rem; border-radius: 999px; border: 1px solid var(--panel-border); color: var(--text-muted); }
.rule-st.is-hold { color: var(--solar); border-color: var(--solar); }
.rule-st.is-done { color: var(--battery-charge); border-color: var(--battery-charge); }
.rule-st.is-off { opacity: .8; }
.rule-tools, .rules-tools { display: flex; gap: .4rem; flex-wrap: wrap; }
.rule-tools .ps-btn, .rules-tools .ps-btn { padding: .25rem .7rem; font-size: .74rem; }
.rules-empty { font-size: .84rem; margin: 0 0 .6rem; }
.rule-form { margin-top: .8rem; padding-top: .8rem; border-top: 1px solid var(--panel-border); display: grid; gap: .55rem; }
.rule-row { display: flex; flex-wrap: wrap; gap: .6rem 1rem; align-items: flex-end; }
.rule-name { flex: 1 1 260px; }
.rule-name input { width: 100%; }
.rule-check { display: flex; align-items: center; gap: .35rem; font-size: .84rem; padding-bottom: .35rem; }
.rule-sub { font-size: .76rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--text-muted); margin-top: .3rem; }
.rule-conds { display: grid; gap: .4rem; }
.rule-cond { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.rule-cond input { width: 110px; }
.rule-cond .ps-btn { padding: .15rem .6rem; }
.rule-cond-add { justify-self: start; padding: .25rem .7rem; font-size: .74rem; }
.rule-cond input, .rule-cond select { font: inherit; font-size: .84rem; padding: .3rem .5rem; border-radius: 8px; border: 1px solid var(--panel-border);
  background: var(--panel); color: var(--text); }

/* 2.27.2: "Comenzi" on its own page */
.cmd-badge { background: var(--solar); color: #1B2429; }
.cmd-page { min-height: 100vh; }
.cp-top { position: sticky; top: 0; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1rem; padding: .7rem 16px;
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--panel-border); }
.cp-back { display: inline-flex; align-items: center; gap: .35rem; text-decoration: none; color: var(--text); font-size: .88rem;
  padding: .38rem .8rem .38rem .55rem; border: 1px solid var(--panel-border); border-radius: 999px; background: var(--panel); }
.cp-back:hover { border-color: var(--text-muted); }
.cp-top h1 { font: 600 1.05rem var(--font-display); margin: 0 auto 0 0; display: flex; align-items: center; gap: .45rem; }
.cp-top h1 svg { color: var(--solar); }
.cp-key { display: flex; align-items: flex-end; gap: .4rem .9rem; flex-wrap: wrap; }
.cp-key .cmd-f { min-width: 220px; }
.cp-remember { display: flex; align-items: center; gap: .35rem; font-size: .78rem; color: var(--text-muted); padding-bottom: .4rem; }
.cp-main { max-width: 1480px; margin: 0 auto; padding: 1.2rem 16px 2rem; display: grid; gap: 1.2rem; }
.cp-head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .6rem 1rem; }
.cp-head .panel-title { margin: 0 auto 0 0; font-size: 1rem; }
.cp-topic { margin: .25rem 0 .2rem; font-family: var(--font-mono); font-size: .76rem; color: var(--text-muted); }
.cmd-dev { min-width: 300px; }
.cp-rules .rules-live { margin-top: .8rem; }
.ps-btn.is-danger { color: var(--danger); border-color: var(--danger); }
@media (max-width: 720px) { .cp-key .cmd-f, .cmd-dev { min-width: 0; flex: 1 1 100%; } }

/* 2.27.3: hidden key, ready-made rules, ONE active rule in evidence */
.cp-keybox { position: relative; }
.cp-key-btn { display: inline-flex; align-items: center; gap: .4rem; padding: .4rem .85rem; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--danger); background: color-mix(in srgb, var(--danger) 10%, transparent); color: var(--danger); font: 600 .82rem var(--font-display); }
.cp-key-btn.is-set { border-color: var(--battery-charge); background: color-mix(in srgb, var(--battery-charge) 10%, transparent); color: var(--battery-charge); }
.cp-key-pop { position: absolute; right: 0; top: calc(100% + .45rem); z-index: 20; width: 290px; display: grid; gap: .5rem; padding: .8rem;
  background: var(--panel); border: 1px solid var(--panel-border); border-radius: 12px; box-shadow: 0 12px 30px rgba(0,0,0,.35); }
.cp-key-pop[hidden] { display: none; }
.cp-key-actions { display: flex; justify-content: flex-end; gap: .4rem; }
.cp-rules { border-color: color-mix(in srgb, var(--solar) 40%, var(--panel-border)); }
.cp-rules .cp-head .panel-title { font-size: 1.15rem; }
.rules-count { margin: .5rem 0 .2rem; font: 600 .95rem var(--font-display); color: var(--battery-charge); }
.rules-count.is-none { color: var(--text-muted); }
.rp-title { margin-top: .9rem; font-size: .76rem; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--text-muted); }
.rule-presets { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: .7rem; margin: .45rem 0 1rem; }
.rule-preset-card { --c: var(--solar); all: unset; box-sizing: border-box; cursor: pointer; display: grid; grid-template-columns: auto 1fr; gap: .2rem .7rem;
  padding: .8rem .9rem; border-radius: 12px; border: 1px solid color-mix(in srgb, var(--c) 55%, var(--panel-border));
  background: color-mix(in srgb, var(--c) 10%, transparent); transition: transform .12s, background .12s; }
.rule-preset-card:hover, .rule-preset-card:focus-visible { background: color-mix(in srgb, var(--c) 18%, transparent); transform: translateY(-1px); outline: none; }
.rule-preset-card.tone-solar { --c: var(--solar); }
.rule-preset-card.tone-grid { --c: var(--grid); }
.rule-preset-card.tone-bat { --c: var(--battery-charge); }
.rp-ic { grid-row: span 3; display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; font: 700 1.1rem var(--font-display);
  color: var(--c); background: color-mix(in srgb, var(--c) 18%, transparent); }
.rp-t { font: 600 .95rem var(--font-display); color: var(--text); }
.rp-h { font-size: .78rem; color: var(--text-muted); line-height: 1.4; }
.rp-go { font: 600 .78rem var(--font-display); color: var(--c); }
.rules-none { margin: .3rem 0 .6rem; padding: .55rem .8rem; border: 1px dashed var(--panel-border); border-radius: 10px; color: var(--text-muted); font-size: .86rem; }
.rule { position: relative; }
.rule.is-active { border: 2px solid var(--battery-charge); background: color-mix(in srgb, var(--battery-charge) 9%, transparent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--battery-charge) 12%, transparent); padding: .8rem 1rem; }
.rule.is-active .rule-name-t { font-size: 1.05rem; }
.rule:not(.is-active) { opacity: .78; }
.rule:not(.is-active):hover { opacity: 1; }
.rule-flag { font: 700 .7rem var(--font-display); letter-spacing: .06em; padding: .12rem .55rem; border-radius: 999px;
  border: 1px solid var(--panel-border); color: var(--text-muted); }
.rule-flag.is-on { background: var(--battery-charge); border-color: var(--battery-charge); color: #0B1118; }
.rule-last { font-size: .76rem; }

/* 2.27.4: the active automation under the battery estimate */
.autonomy.au-rule { --au: var(--solar); text-decoration: none; color: inherit; margin-top: .45rem; max-width: 760px; }
.autonomy.au-rule:hover { background: color-mix(in srgb, var(--au) 18%, var(--panel)); }
.autonomy.au-rule.is-none { --au: var(--text-muted); max-width: 560px; }
.au-rule .au-main { display: flex; flex-wrap: wrap; align-items: baseline; gap: .2rem .5rem; }
.au-flag { font: 700 .68rem var(--font-display); letter-spacing: .05em; text-transform: uppercase; color: var(--au); }
.au-rname { font-family: var(--font-display) !important; }
.au-st { font-size: .72rem; padding: .05rem .5rem; border-radius: 999px; border: 1px solid var(--panel-border); color: var(--text-muted); }
.au-st.is-hold { color: var(--solar); border-color: var(--solar); }
.au-st.is-done { color: var(--battery-charge); border-color: var(--battery-charge); }

/* 2.27.5: "Arată payload" on a rule */
.au-rule .au-body { min-width: 0; flex: 1; }
.au-rule a { color: inherit; text-decoration: none; }
.au-rule a.au-rname:hover { text-decoration: underline; }
.rule-payload { margin-top: .4rem; font-size: .78rem; }
.rule-payload > summary { cursor: pointer; color: var(--au, var(--solar)); font-weight: 600; list-style: none; display: inline-flex; gap: .35rem; align-items: baseline; flex-wrap: wrap; }
.rule-payload > summary::-webkit-details-marker { display: none; }
.rule-payload > summary::before { content: "\25B8"; transition: transform .15s; }
.rule-payload[open] > summary::before { transform: rotate(90deg); }
.rule-payload > summary .muted { font-weight: 400; font-family: var(--font-mono); font-size: .72rem; }
.rp-blk { margin-top: .45rem; }
.rp-lbl { font-size: .7rem; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--text-muted); }
.rp-topic { margin: .15rem 0; font-size: .76rem; }
.rp-topic code { font-family: var(--font-mono); }
.rp-json { margin: 0; padding: .5rem .65rem; max-height: 260px; overflow: auto; border-radius: 8px; font: .72rem/1.45 var(--font-mono);
  background: color-mix(in srgb, var(--text) 6%, transparent); border: 1px solid var(--panel-border); white-space: pre; }
.rp-none { margin: .3rem 0 0; }
.autonomy.au-rule { align-items: flex-start; }
.au-rule .au-icon { padding-top: .1rem; }
.cmd-warn { color: var(--danger); }
.cmd-ok-b { color: var(--battery-charge); }
