/* =========================================================================
   style.css — Basis-Layout, Navigation, Wisch-Mechanik, gemeinsame
   Komponenten (Karten, Tabellen, Badges, Buttons).
   Zielgerät: 16" Touchscreen, 1920x1080 (landscape), Chromium Kiosk.
   Responsive/skalierend über clamp() und vw/vh, damit auch andere
   Auflösungen (z.B. Portrait, kleinere Displays) nutzbar bleiben.
   ========================================================================= */

:root {
  /* Runde 37: Anzahl der Pager-Seiten — wird von app.js#setPageCount() zur
     Laufzeit passend zur tatsächlich aktiven Seitenliste gesetzt (siehe
     'deployment.pages' in config.inc.php); 6 hier nur als Fallback, falls
     JS aus irgendeinem Grund noch nicht gelaufen ist. .pager-track/.page
     unten rechnen NUR noch mit dieser Variable, keine feste Prozentzahl
     mehr. */
  --page-count: 6;

  --bg: #e8f1fb;
  --bg-gradient: linear-gradient(180deg, #eaf3fd 0%, #e3edfa 100%);
  --surface: #ffffff;
  --surface-alt: #f4f8fc;
  --border: #dfe9f5;
  --text: #1e293b;
  --text-muted: #64748b;
  --text-faint: #94a3b8;

  --accent: #2f7dd1;
  --accent-dark: #1c5aa3;
  --accent-soft: #e5f0fb;

  --red: #e0463f;
  --red-soft: #fdecec;
  --green: #22a35e;
  --green-soft: #e8f8ee;
  --orange: #e8912a;
  --orange-soft: #fdf2e3;
  --blue: #2f7dd1;
  --blue-soft: #e5f0fb;
  --purple: #7c5ce0;
  --purple-soft: #efeafd;

  --chart-grid: #e7ecf2;

  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;

  --shadow-card: 0 1px 3px rgba(30, 41, 59, 0.06), 0 1px 2px rgba(30, 41, 59, 0.04);
  --nav-height: clamp(64px, 8vh, 88px);

  --fs-base: clamp(14px, 1.15vw, 17px);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-gradient), var(--bg);
  color: var(--text);
  transition: background 0.4s ease, color 0.4s ease;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: var(--fs-base);
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* Nacht-Design: bewusst sehr dunkel/kontrastarm gehalten für abgedunkelte
   Räume (kein grelles Weiß, gedämpfte Akzentfarben). */
body[data-theme="dark"] {
  --bg: #0a0e16;
  --bg-gradient: linear-gradient(180deg, #0b0f18 0%, #080b12 100%);
  --surface: #121826;
  --surface-alt: #171f2f;
  --border: #232e42;
  --text: #cdd7e5;
  --text-muted: #7c8ba1;
  --text-faint: #4d5c74;
  --accent: #4f8ecf;
  --accent-dark: #3a72ab;
  --accent-soft: #172a3f;
  --chart-grid: #1c2536;
  --red: #c85a53;
  --red-soft: #2c1417;
  --green: #3fa06a;
  --green-soft: #102a1c;
  --orange: #c98a3e;
  --orange-soft: #2c2213;
  --blue-soft: #172a3f;
  --purple: #8874d6;
  --purple-soft: #1e1a35;
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.35);
}

#app {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* Runde 47: Wartungsmodus (siehe app.js#renderMaintenanceScreen()) — ersetzt
   den kompletten body-Inhalt, braucht deshalb eigenes Höhen-/Zentrierungs-
   Layout statt sich auf "#app" zu verlassen. */
.maintenance-screen {
  width: 100%;
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 10px;
  padding: 24px;
  background: var(--bg-gradient);
  color: var(--text);
}
.maintenance-icon { font-size: 48px; }
.maintenance-screen h1 { margin: 0; font-size: 22px; }
.maintenance-screen p { margin: 0; max-width: 480px; color: var(--text-muted); font-size: 15px; white-space: pre-wrap; }

/* ---------------------------------------------------------------------
   Top-Navigation
   --------------------------------------------------------------------- */
.topnav {
  height: var(--nav-height);
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 clamp(8px, 1.2vw, 20px);
  gap: clamp(4px, 1vw, 16px);
  z-index: 20;
}

.nav-arrow {
  flex: 0 0 auto;
  width: clamp(44px, 6vh, 60px);
  height: clamp(44px, 6vh, 60px);
  border-radius: 50%;
  border: none;
  background: var(--surface-alt);
  color: var(--text-muted);
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, transform 0.1s;
}
.nav-arrow:active { transform: scale(0.92); background: var(--accent-soft); color: var(--accent); }
.nav-arrow svg { width: 42%; height: 42%; display: block; }

.nav-tabs {
  flex: 1 1 auto;
  display: flex;
  height: 100%;
  align-items: stretch;
  justify-content: space-evenly;
  gap: clamp(2px, 0.6vw, 10px);
}

.nav-tab {
  flex: 1 1 0;
  max-width: 260px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: clamp(13px, 1.35vw, 17px);
  font-weight: 600;
  letter-spacing: 0.01em;
  position: relative;
  border-radius: var(--radius-sm);
  transition: color 0.15s, background 0.15s;
}
.nav-tab .tab-icon { display: flex; align-items: center; justify-content: center; }
/* Runde 44: einheitliche, stilisierte Nav-Icons (frontend/assets/nav/*.svg)
   per CSS-Maske eingefärbt — ersetzt die vorherigen rohen Emoji-Zeichen, die
   je nach Gerät/Schriftart unterschiedlich (teils bunt, teils als leeres
   Kästchen bei fehlendem Emoji-Glyph) dargestellt wurden. Grau im Ruhezustand,
   Akzentfarbe nur beim aktiven Tab (siehe .nav-tab.active unten) — dasselbe
   Maskierungs-Prinzip wie .device-icon-glyph in misc.css. */
.tab-icon-glyph {
  display: block;
  width: clamp(18px, 2.2vh, 23px);
  height: clamp(18px, 2.2vh, 23px);
  background: var(--text-muted);
  -webkit-mask-size: contain; mask-size: contain;
  -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
  -webkit-mask-position: center; mask-position: center;
  transition: background 0.15s;
}
.nav-tab:active { background: var(--surface-alt); }
.nav-tab.active { color: var(--accent); }
.nav-tab.active .tab-icon-glyph { background: var(--accent); }
.nav-tab .tab-underline {
  position: absolute;
  bottom: 6px;
  left: 20%;
  right: 20%;
  height: 3px;
  border-radius: 3px;
  background: var(--accent);
  opacity: 0;
  transform: scaleX(0.4);
  transition: opacity 0.2s, transform 0.2s;
}
.nav-tab.active .tab-underline { opacity: 1; transform: scaleX(1); }

/* Runde 44: auf schmalen Touch-Geräten (Handy, z.B. iPhone) — Beschriftung
   unter den Nav-Icons weg (Icons allein reichen, spart Platz) UND die
   Vor-/Zurück-Pfeile weg (auf einem Touchscreen übernimmt ohnehin die
   Wisch-Geste den Seitenwechsel, siehe app.js#setupSwipe() — die Pfeile sind
   dort nur zusätzlicher, beengender Ballast). Auf breiteren Geräten
   (Tablet-Kiosk, Desktop) bleibt beides wie bisher sichtbar. */
@media (max-width: 600px) {
  .nav-tab .tab-label { display: none; }
  .nav-arrow { display: none; }
}

.nav-status {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  font-size: clamp(11px, 1vw, 13px);
  color: var(--text-faint);
}
.status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-faint);
  transition: background 0.3s;
}
.status-dot.live { background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.status-dot.offline { background: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }
/* Runde 18: verbunden, aber seit LIVE_STALE_MS (app.js) kein echtes
   Live-Update mehr angekommen — optisch wie "offline" (rot), aber als
   eigene Klasse, falls später ein eigener Farbton gewünscht wird. */
.status-dot.stale { background: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }
.nav-clock { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--text-muted); }

.theme-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  border: none;
  background: var(--surface-alt);
  color: var(--text-muted);
  font-size: clamp(11px, 1vw, 13px);
  font-weight: 700;
  padding: 7px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  white-space: nowrap;
}
.theme-toggle:active { transform: scale(0.96); background: var(--accent-soft); }
.theme-toggle #themeIcon { font-size: 1.1em; }
/* Feste Breite für das Label, damit der Button beim Umschalten zwischen
   "Hell"/"Dunkel"/"Automatisch (Tag)" nicht seine Breite ändert und dadurch
   den Rest der Navigation verschiebt. Breit genug für den längsten Text
   ("Automatisch (Nacht)"). */
.theme-toggle #themeLabel {
  display: inline-block;
  min-width: 21ch;
  text-align: left;
}
/* Runde 23: gleiches Prinzip wie #themeLabel oben — feste Breite, damit der
   Schriftgrößen-Knopf beim Durchschalten (100%/115%/130%/145%) nicht
   wackelt. */
.theme-toggle #fontSizeLabel {
  display: inline-block;
  min-width: 5ch;
  text-align: left;
}
/* Runde 31: gleiches Prinzip wie #themeLabel/#fontSizeLabel oben — feste
   Breite, damit der Zeitraum-Knopf beim Durchschalten (1 Tag .. 7 Tage)
   nicht wackelt ("7 Tage" ist der längste Text). */
.theme-toggle #periodDaysLabel {
  display: inline-block;
  min-width: 6ch;
  text-align: left;
}

/* ---------------------------------------------------------------------
   Footer (Runde 44: Layout-Größe/Hell-Dunkel-Umschalter, vorher Teil der
   Kopfzeile — dort auf schmalen Geräten zu eng neben Nav-Tabs/Uhr/Status)
   --------------------------------------------------------------------- */
.app-footer {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(6px, 1vw, 12px);
  padding: clamp(3px, 0.5vh, 5px) clamp(8px, 1.2vw, 20px);
  background: var(--surface);
  border-top: 1px solid var(--border);
}
/* Runde 45: kompakter als der bisherige (an der Kopfzeile orientierte)
   Button-Stil — der Footer ist ein reiner Einstellungs-Streifen, braucht
   nicht dieselbe Größe wie prominente Nav-Elemente. */
.app-footer .theme-toggle {
  padding: 4px 10px;
  font-size: clamp(10px, 0.9vw, 12px);
  gap: 4px;
}
.app-footer .theme-toggle #themeIcon,
.app-footer .theme-toggle #fontSizeIcon { font-size: 1em; }

/* Runde 46: kleines Admin-Symbol am Footer-Rand (siehe admin.php) — gleiche
   Masken-Technik wie die Nav-Icons oben, bewusst kleiner/unauffälliger. */
.footer-admin-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--surface-alt);
  margin-left: 4px;
  transition: background 0.15s;
}
.footer-admin-link:active { background: var(--accent-soft); }
.footer-admin-icon {
  width: 13px;
  height: 13px;
  background: var(--text-faint);
  -webkit-mask-size: contain; mask-size: contain;
  -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
  -webkit-mask-position: center; mask-position: center;
  -webkit-mask-image: url('../assets/nav/admin.svg');
  mask-image: url('../assets/nav/admin.svg');
}
.footer-admin-link:active .footer-admin-icon { background: var(--accent); }

/* ---------------------------------------------------------------------
   Wisch-/Seiten-Mechanik
   --------------------------------------------------------------------- */
.pager-viewport {
  flex: 1 1 auto;
  overflow: hidden;
  position: relative;
  /* Runde 28 Bugfix (Nico: Wischen zum Seitenwechsel "zieht nur etwas rüber,
     bleibt aber auf der vorherigen Seite", extrem laggy — auf dem Touch-Pi4):
     ohne "touch-action" versucht der Browser bei einer Touch-Bewegung
     PARALLEL zu unserer eigenen Pointer-Event-Logik (siehe app.js#setupSwipe())
     selbst zu erkennen, ob das eine native Scroll-Geste ist — entscheidet er
     sich (oft schon nach den ersten Pixeln, BEVOR unser eigener
     "axisLocked"-Check greift) dafür, bricht er die Pointer-Events mit einem
     "pointercancel" ab. app.js#endDrag() beendet den Wisch dann so, als wäre
     der Finger schon losgelassen worden — meist NOCH VOR Erreichen der
     18%-Schwelle, die Seite springt zurück zur alten Position. "pan-y"
     erlaubt dem Browser weiterhin natives VERTIKALES Scrollen (die einzelnen
     Seiten sind ja selbst hochscrollbar, siehe ".page" unten), verbietet ihm
     aber, horizontale Wischgesten selbst zu übernehmen — die bleiben
     vollständig unserer eigenen Wisch-Logik überlassen, wie ursprünglich
     gedacht. */
  touch-action: pan-y;
}
.pager-track {
  display: flex;
  /* Runde 37: statt fester "600%" jetzt über --page-count (siehe :root
     oben, gesetzt von app.js#setPageCount()) — passt sich automatisch an,
     wenn eine Seite (z.B. "mower") über config.inc.php ausgeblendet ist,
     statt bei jeder Seiten-Änderung von Hand nachgepflegt werden zu
     müssen. app.js#goTo() berechnet die Verschiebung ebenfalls aus
     PAGES.length — beides MUSS zur selben Zahl passen, siehe dortiger
     Kommentar. */
  width: calc(var(--page-count) * 100%);
  height: 100%;
  will-change: transform;
  transition: transform 320ms cubic-bezier(0.22, 0.61, 0.36, 1);
}
.pager-track.dragging { transition: none; }

.page {
  /* Runde 37: siehe .pager-track-Kommentar oben. */
  width: calc(100% / var(--page-count));
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: clamp(10px, 1.6vh, 22px) clamp(10px, 1.6vw, 28px) clamp(20px, 3vh, 36px);
}

.page-dots {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  z-index: 5;
  pointer-events: none;
}
.page-dots span {
  width: 7px; height: 7px; border-radius: 50%;
  background: rgba(100,116,139,0.28);
  transition: background 0.2s, transform 0.2s;
}
.page-dots span.active { background: var(--accent); transform: scale(1.3); }

/* ---------------------------------------------------------------------
   Gemeinsame Komponenten
   --------------------------------------------------------------------- */
.grid { display: grid; gap: clamp(10px, 1.4vw, 18px); }

.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: clamp(12px, 1.6vh, 20px) clamp(14px, 1.6vw, 22px);
}
.card-title {
  font-size: clamp(13px, 1.1vw, 15px);
  font-weight: 700;
  color: var(--text);
  margin: 0 0 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-title .muted, .modal-title .muted { font-weight: 500; color: var(--text-faint); font-size: 0.85em; }

.stat-tile {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: clamp(12px, 1.6vh, 18px) clamp(14px, 1.6vw, 20px);
  display: flex;
  flex-direction: column;
  gap: 6px;
  justify-content: center;
}
.stat-tile .label {
  font-size: clamp(11px, 0.95vw, 13px);
  font-weight: 700;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.stat-tile .value {
  font-size: clamp(22px, 2.4vw, 32px);
  font-weight: 700;
  color: var(--text);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.stat-tile .value .unit { font-size: 0.5em; font-weight: 600; color: var(--text-muted); margin-left: 4px; }
.stat-tile .sub { font-size: clamp(11px, 0.9vw, 13px); color: var(--text-muted); }
.stat-tile.accent-red .value { color: var(--red); }
.stat-tile.accent-green .value { color: var(--green); }
.stat-tile.accent-blue .value { color: var(--blue); }
.stat-tile.accent-orange .value { color: var(--orange); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.78em;
  font-weight: 700;
}
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.red { background: var(--red-soft); color: var(--red); }
.badge.blue { background: var(--blue-soft); color: var(--blue); }
.badge.orange { background: var(--orange-soft); color: var(--orange); }
.badge.gray { background: var(--surface-alt); color: var(--text-muted); }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

table.data-table {
  width: 100%;
  /* Runde 22: "table-layout: fixed" + feste Spaltenbreiten (siehe <colgroup>
     in costs.js) statt "auto" — bei "auto" berechnet der Browser die
     Spaltenbreiten bei JEDEM Neuzeichnen neu aus dem aktuellen Zellinhalt
     (z.B. "1,23 €" vs. "123,45 €" vs. "Fehlende Daten"), was bei den
     laufend aktualisierten Kosten-/Wasserwerten ein sichtbares "Springen"
     der Spalten verursachte. Mit "fixed" bleiben die Breiten konstant,
     längerer Inhalt (z.B. "Fehlende Daten") bricht stattdessen in der Zelle
     um, statt die Tabelle zu verschieben. */
  table-layout: fixed;
  border-collapse: collapse;
  font-size: clamp(12px, 1vw, 15px);
}
table.data-table th {
  text-align: right;
  color: var(--text-faint);
  font-weight: 700;
  font-size: 0.82em;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
}
table.data-table th:first-child { text-align: left; }
table.data-table td {
  padding: 9px 8px;
  text-align: right;
  border-bottom: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
table.data-table td:first-child { text-align: left; font-weight: 700; color: var(--text); }
table.data-table tr:last-child td { border-bottom: none; }
table.data-table tr.total-row td { background: var(--green-soft); font-weight: 800; }
table.data-table tr.total-row td:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
table.data-table tr.total-row td:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.val-neg { color: var(--red); }
.val-pos { color: var(--green); }
/* Runde 17: "Fehlende Daten" (siehe frontend/js/costs.js) — bewusst
   gedämpft/kursiv statt rot oder grün, damit es nicht wie ein echter
   (positiver oder negativer) Wert aussieht. */
.val-missing { color: var(--text-faint); font-style: italic; font-weight: 600; }
/* Runde 20: kWh-Zusatzspalte in der Kosten-Tabelle (siehe
   frontend/js/costs.js) — bewusst gedämpfter als der €-Betrag (der bleibt
   die primäre Zahl je Zeile), gleiches Prinzip wie .val-missing oben. */
.val-kwh { color: var(--text-faint); font-weight: 600; }

/* ---------------------------------------------------------------------
   Diagramm-Tooltip (Runde 20) — Hover für Maus-Nutzer, siehe
   frontend/js/charts.js#attachHoverTooltip(). Auf dem Touch-Kiosk ohne
   Wirkung (kein "mousemove" ohne Klick), deshalb bewusst dezent und ohne
   Einfluss auf das Touch-Layout.
   --------------------------------------------------------------------- */
.chart-tooltip {
  position: fixed;
  transform: translate(-50%, calc(-100% - 10px));
  background: var(--text);
  color: var(--surface);
  font-size: 12px;
  font-weight: 700;
  padding: 5px 9px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  z-index: 200;
  transition: opacity 0.1s;
}
.chart-tooltip.visible { opacity: 1; }

/* Runde 34: vertikaler "Fadenkreuz"-Strich am gehoverten Zeitpunkt, siehe
   frontend/js/charts.js#getSharedHoverLine() — gleiches Grund-Muster wie
   .chart-tooltip oben (ein geteiltes Element für alle Diagramme). */
.chart-hover-line {
  position: fixed;
  width: 0;
  border-left: 1px dashed var(--text-muted);
  pointer-events: none;
  opacity: 0;
  z-index: 199;
  transition: opacity 0.1s;
}
.chart-hover-line.visible { opacity: 0.6; }

/* ---------------------------------------------------------------------
   In-Page-Popup / Modal (Runde 20) — aktuell für das Geräte-Verbrauchs-
   Popup (frontend/js/misc.js#openDeviceHistory()), bewusst generisch
   gehalten (.modal-*) für spätere weitere Popups.
   --------------------------------------------------------------------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(14px, 3vw, 32px);
  z-index: 100;
  animation: modalFadeIn 0.15s ease-out;
}
@keyframes modalFadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-card {
  width: min(560px, 100%);
  max-height: 85vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.modal-title {
  font-size: clamp(15px, 1.4vw, 18px);
  font-weight: 800;
  color: var(--text);
}
.modal-close {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: var(--surface-alt);
  color: var(--text-muted);
  font-size: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.modal-close:hover { background: var(--red-soft); color: var(--red); }
.modal-body { position: relative; }
.modal-empty-hint {
  text-align: center;
  color: var(--text-faint);
  font-style: italic;
  font-weight: 600;
  padding: clamp(30px, 8vh, 60px) 0;
}

/* Runde 30: klickbare Kachel, die ein Steuer-Popup öffnet (aktuell:
   Sollraumtemperatur-Slider, siehe frontend/js/heatpump.js) — analog zur
   ".device-card:hover"-Optik auf der Sonstiges-Seite, hier aber auf
   ".stat-tile" statt einer ganzen Karte, da nur EIN Wert (nicht die ganze
   Kachel-Gruppe) tatsächlich steuerbar ist. Wird erst per JS zugeschaltet
   (siehe update()), sobald bekannt ist, dass das jeweilige Feld
   'writable' => true hat (config.inc.php) — ohne diese Klasse bleibt die
   Kachel wie bisher rein informativ.
*/
.stat-tile.controllable {
  cursor: pointer;
  transition: box-shadow 0.15s, transform 0.15s;
}
.stat-tile.controllable:hover { box-shadow: 0 3px 10px rgba(30,41,59,0.12); }
.stat-tile.controllable:active { transform: scale(0.98); }
.stat-tile.controllable .sub::after {
  content: ' ✏️';
  opacity: 0.65;
}

/* Runde 30: Steuer-Popup mit Schieberegler (aktuell einziger Anwendungsfall:
   Sollraumtemperatur, frontend/js/heatpump.js) — nutzt ansonsten dieselben
   .modal-*-Bausteine oben. */
.control-slider-value {
  text-align: center;
  font-size: clamp(30px, 4vw, 44px);
  font-weight: 800;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  margin-bottom: 6px;
}
.control-slider-value .unit { font-size: 0.5em; font-weight: 600; color: var(--text-muted); margin-left: 4px; }
.control-slider-input {
  width: 100%;
  accent-color: var(--accent);
  /* großzügige Trefferfläche für Touch (Kiosk-Tablet, siehe README "Kiosk") */
  height: 32px;
  cursor: pointer;
}
.control-slider-range {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-faint);
  font-weight: 600;
  margin-top: 2px;
}
.control-slider-error {
  margin-top: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--red-soft);
  color: var(--red);
  font-size: 12.5px;
  font-weight: 600;
}
.control-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}
.control-btn {
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  font-size: clamp(12px, 1vw, 14px);
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}
.control-btn.secondary { background: var(--surface-alt); color: var(--text-muted); }
.control-btn.secondary:hover { background: var(--border); }
.control-btn.primary { background: var(--accent); color: #fff; }
.control-btn.primary:hover { opacity: 0.9; }
/* Runde 33: dritte Variante für Aktionen, die eine laufende Ausführung
   abbrechen (Mähroboter "Abbrechen", siehe frontend/js/mower.js) — bisher
   gab es nur primary/secondary, keine davon passt farblich zu einer
   Abbrechen-Aktion. */
.control-btn.danger { background: var(--red); color: #fff; }
.control-btn.danger:hover { opacity: 0.9; }
.control-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------------------------------------------------------------------
   Zeitraum-Pfeil-Navigation (Runde 21) — gemeinsame Bausteine für die
   Datums-Navigation auf der Kosten-Seite (frontend/js/costs.js, dort als
   einzelne .period-nav-btn neben dem Datums-/Monats-/Jahres-Picker) und im
   Geräte-Verbrauchs-Popup (frontend/js/misc.js, dort als komplette
   .period-nav-Zeile mit Label mittig).
   --------------------------------------------------------------------- */
.period-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}
.period-nav-label {
  font-size: clamp(13px, 1.1vw, 15px);
  font-weight: 700;
  color: var(--text);
  min-width: 130px;
  text-align: center;
}
.period-nav-btn {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: var(--surface-alt);
  color: var(--text);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s, opacity 0.15s;
}
.period-nav-btn:hover:not(:disabled) { background: var(--accent-soft); color: var(--accent); }
.period-nav-btn:disabled { opacity: 0.35; cursor: not-allowed; }

.segmented {
  display: flex;
  background: var(--surface-alt);
  border-radius: var(--radius-md);
  padding: 4px;
  gap: 4px;
}
.segmented button {
  flex: 1;
  border: none;
  background: transparent;
  padding: clamp(8px, 1.2vh, 12px) 6px;
  border-radius: var(--radius-sm);
  font-size: clamp(12px, 1vw, 14px);
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.segmented button.active { background: var(--surface); color: var(--accent); box-shadow: 0 1px 3px rgba(30,41,59,0.12); }

canvas.chart { width: 100%; display: block; }

.section-heading {
  font-size: clamp(15px, 1.3vw, 19px);
  font-weight: 800;
  margin: clamp(14px, 2vh, 22px) 0 10px;
  color: var(--text);
}
.section-heading:first-child { margin-top: 0; }

.flow-value { font-weight: 700; font-variant-numeric: tabular-nums; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: rgba(100,116,139,0.3); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }
