.side-panel {
  padding: 16px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Sub-section divider inside the merged Sistema view (above the network stats) */
.sys-subsection {
  flex: 0 0 auto;
  margin-top: 0;
  padding: 4px 2px 0;
  border-top: 1px solid rgba(255,255,255,0.07);
  color: var(--dim-text);
  font-size: 10.5px;
  font-weight: 850;
  letter-spacing: 0.6px;
  text-transform: uppercase;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2px;
  color: var(--muted-text);
  font-size: 13.5px;
  font-weight: 850;
}

.system-block {
  flex: 1 1 auto;     /* fill the tile so the cards can distribute vertically */
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* System tabs (Sistema / Rete & Gaming) */
.system-tabs {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  /* One row: tab pills on the left, Optimize + uptime pinned to the far right.
     The tab group keeps its own internal wrap for extreme narrowness, so nothing
     spills onto a wasted second row. */
  flex-wrap: nowrap;
  gap: 10px;
  padding: 0 2px 4px;
  min-width: 0;
}
/* Unified tab style — matches the Agenda tabs (.cal-task-toggle / .cal-task-btn) */
.system-tabs-left {
  min-width: 0;
  max-width: 100%;
  display: inline-flex;
  flex: 0 1 auto;
  flex-wrap: wrap;
  gap: 2px;
  background: var(--surface-alt);
  border: 1px solid rgba(255,255,255,0.055);
  border-radius: 22px;
  padding: 3px;
}
.system-tabs-right {
  flex: 0 0 auto;
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: nowrap;
  gap: 6px;
}
.system-tabs-right .sys-uptime { margin-left: 0; }
.sys-tab {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  font-family: inherit;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  border: none;
  border-radius: 18px;
  padding: 6px 12px;
  cursor: pointer;
  background: transparent;
  color: var(--dim-text);
  white-space: nowrap;
  transition: background 0.22s ease, color 0.22s ease, box-shadow 0.22s ease;
}
/* The `display: inline-flex` above outranks the UA `[hidden]{display:none}` rule,
   so without this the Volume/Microfono tabs stay clickable after their content is
   extracted into a standalone tile, opening an empty pane. Same for History while
   sensor history is off. */
.sys-tab[hidden] { display: none; }
.sys-tab svg {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.sys-tab:hover:not(.active) { color: var(--text); }
.sys-tab.active {
  background: rgba(var(--accent-rgb), 0.14);
  color: var(--accent);
  box-shadow: 0 1px 6px rgba(0,0,0,0.25), inset 0 1px 0 rgba(255,255,255,0.04);
}
.sys-uptime {
  margin-left: auto;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.07);
  background: var(--surface-alt);
  color: var(--text);
  font-size: 11.5px;
  font-weight: 800;
  white-space: nowrap;
}
.weather-pill {
  min-width: 0;
  max-width: 150px;
  height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  border: 1px solid rgba(var(--accent-rgb),0.22);
  background: rgba(var(--accent-rgb),0.10);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  overflow: hidden;
}
.weather-pill.offline {
  border-color: var(--divider);
  background: var(--surface-alt);
  color: var(--muted-text);
}
.weather-pill svg {
  width: 14px;
  height: 14px;
  fill: var(--green);
  flex-shrink: 0;
}
.weather-temp {
  font-size: 13.5px;
  font-weight: 950;
  font-variant-numeric: tabular-nums;
}
.weather-place {
  min-width: 0;
  color: var(--muted-text);
  font-size: 11px;
  font-weight: 850;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Network grid cards */
.sys-net-grid .stat-row { align-items: baseline; gap: 4px; }
.stat-unit {
  color: var(--muted-text);
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: 0.3px;
}
.stat-na {
  background: var(--surface-alt);
  color: var(--muted-text);
  border: 1px solid rgba(255,255,255,0.08);
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.3px;
}
.stat-fill.net-ping     { background: linear-gradient(90deg,var(--green),var(--green)); }
.stat-fill.net-fps      { background: linear-gradient(90deg,#7c5cff,#4c8cff); }
.stat-fill.net-latency  { background: linear-gradient(90deg, var(--color-warn), color-mix(in srgb, var(--color-warn), var(--color-danger) 42%)); }
.stat-row-bw {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  width: 100%;
}
.bw-line {
  display: flex;
  align-items: center;
  gap: 8px;
}
.bw-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  fill: none;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.bw-icon.down { stroke: var(--green); }
.bw-icon.up   { stroke: #4c8cff; }
.bw-value {
  font-size: 18px;
  font-weight: 900;
  color: var(--text);
  line-height: 1;
  min-width: 0;
}
.bw-unit {
  color: var(--muted-text);
  font-size: 12.5px;
  font-weight: 700;
}
.system-grid {
  /* Fill remaining height and let the card rows stretch/compress to fit, so the
     merged Sistema view (CPU/GPU/RAM/DISCO + Rete&Gaming) never needs scrolling
     on the short Xeneon Edge screen while still filling tall desktop windows. */
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-rows: minmax(0, 1fr);
  align-content: stretch;
  gap: 8px;
}
/* Both the main and the net grids hold 2 rows of cards, so they share the
   height equally (default flex-grow: 1) → uniform card height across the view. */
.audio-block {
  flex: 0 0 auto;
}
.system-grid[hidden] { display: none !important; }

.stat-box {
  min-width: 0;
  min-height: 0;          /* allow vertical compression on short screens */
  padding: 9px 13px 9px;
  border-radius: var(--radius);
  background: var(--panel-soft);
  border: 1px solid #222929;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow: hidden;
}

.stat-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted-text);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.stat-head-right {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
}

/* Model name shown inline after the CPU/GPU label (e.g. "Ryzen 7 7800X3D",
   "NVIDIA RTX 5080"). Takes the middle space and ellipsises — never wraps. */
.stat-head-name {
  flex: 1 1 auto;
  min-width: 0;
  text-transform: none;
  letter-spacing: 0.1px;
  font-size: 10.5px;
  font-weight: 750;
  color: var(--muted-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: left;
}
.stat-head-name:empty { display: none; }

.stat-head-value {
  color: var(--muted-text);
  font-size: 10.5px;
  font-weight: 850;
  letter-spacing: 0.2px;
  white-space: nowrap;
}

.stat-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
}

.stat-value {
  font-size: 19px;
  font-weight: 850;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.stat-temp {
  color: var(--amber);
  font-size: 11px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.stat-sub {
  color: var(--muted-text);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-detail {
  min-height: 12px;
  color: var(--muted-text);
  font-size: 11px;
  line-height: 1.15;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-muted-detail {
  color: var(--dim-text);
  font-size: 10.5px;
}

.stat-track {
  margin-top: 2px;
  height: 4px;
  border-radius: 999px;
  background: var(--control-bg);
  overflow: hidden;
}

.stat-fill {
  width: 0%;
  height: 100%;
  border-radius: 999px;
  background: var(--cyan);
  transition: width 0.35s ease;
}

.stat-fill.cpu { background: var(--green); }
.stat-fill.gpu { background: var(--blue); }
.stat-fill.ram { background: var(--amber); }
.stat-fill.disk { background: #c084fc; }

/* ── Live sparkline (replaces the flat bar) ──────────────────── */
.stat-track.has-spark {
  /* Grows to fill leftover card height on tall tiles, shrinks on short ones
     (so the card compresses by trimming the chart, not by clipping text). The
     low min-height lets the bottom row trim its chart instead of overflowing
     and being clipped by the tile on short displays. */
  flex: 1 1 0;
  min-height: 6px;
  height: 44px;          /* preferred height when there's room */
  margin-top: 4px;
  overflow: hidden;
  border-radius: 6px;
  /* faint "see-through" horizontal grid behind the line */
  background: repeating-linear-gradient(to bottom, rgba(255,255,255,0.055) 0 1px, transparent 1px 11px);
}
.stat-track.has-spark .stat-fill { display: none; }
.stat-spark { width: 100%; height: 100%; display: block; overflow: visible; color: var(--accent); }
/* The sparkline is TWO stacked strokes, and deliberately carries no filter.
   `transition: d` interpolates the path GEOMETRY, which is not compositable: the
   path is re-rasterised on every frame of the transition. A
   `filter: drop-shadow()` on top of that re-ran a gaussian blur on every one of
   those frames, and with a sample arriving each second the 0.6s transition means
   each chart animates ~60% of the time — eight charts on a page kept the GPU
   process busy at ~7% with the renderer idle. The halo is now a wider translucent
   copy of the same path underneath (`.stat-spark-glow`, painted by
   renderStatSpark in js/utils.js), which is one ordinary stroke raster instead of
   an offscreen surface plus a blur pass. Do not put a filter back on either path.
   `stroke-opacity`, not `opacity`: opacity would force its own compositing group. */
.stat-spark-glow,
.stat-spark-line {
  fill: none;
  stroke: currentColor;
  stroke-linejoin: round;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
  transition: d 0.6s ease;
}
.stat-spark-glow {
  stroke-width: 6;
  stroke-opacity: 0.16;
}
.stat-spark-line {
  stroke-width: 2;
}
@media (prefers-reduced-motion: reduce) {
  .stat-spark-glow,
  .stat-spark-line { transition: none; }
}
/* The glide is invisible to every freeze mechanism: it is a TRANSITION retriggered
   by each SSE sample (one per second, forever), not an infinite animation, so the
   ambient-idle WAAPI sweep never sees it and it kept re-rasterising both strokes
   at display rate even with the dashboard untouched, under overlays, and in game
   mode. Snap to the new value in those states; the data still updates. */
body.overlay-frozen .stat-spark-glow, body.overlay-frozen .stat-spark-line,
body.ambient-idle .stat-spark-glow, body.ambient-idle .stat-spark-line,
body.game-mode .stat-spark-glow, body.game-mode .stat-spark-line,
body.low-power-gpu .stat-spark-glow, body.low-power-gpu .stat-spark-line { transition: none; }

.stat-head-temp {
  padding: 1px 6px 2px;
  border-radius: 999px;
  background: rgba(var(--accent-rgb), 0.12);
  border: 1px solid rgba(var(--accent-rgb), 0.20);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.3px;
  color: var(--green);
  font-variant-numeric: tabular-nums;
}
.stat-head-temp:empty { display: none; }
.stat-head-temp.amber {
  color: var(--amber);
  background: var(--warning-bg);
  border-color: rgba(var(--warning-rgb), 0.22);
}

.disk-cycle-btn {
  width: 14px;
  height: 14px;
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
  color: var(--dim-text);
  display: grid;
  place-items: center;
  opacity: 0.7;
  transition: opacity 0.15s ease, color 0.15s ease;
  flex-shrink: 0;
}
.disk-cycle-btn:hover { opacity: 1; color: var(--text); }
.disk-cycle-btn svg { width: 12px; height: 12px; fill: currentColor; }

.device-caption {
  margin-top: 2px;
  color: var(--dim-text);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: none;
}
