/**
 * lib/app.css
 *
 * Gemeinsames Gestaltungssystem für Navigation, Übersichten, Diagramme, Tageswerte und
 * Dialoge. CSS-Variablen bündeln Farben und Abstände. Spätere Regeln und Medienabfragen
 * ergänzen bewusst die Grundregeln; ihre Reihenfolge bleibt erhalten, damit Desktop,
 * Mobilansicht und Farbschema unverändert zusammenwirken.
 */

/* HEVI-ERKLÄRUNG
 * GESTALTUNGSGRUNDLAGEN: Gemeinsame Farben, Abstände und Schriftvorgaben. Nachfolgende Komponenten
 * verwenden diese Variablen; Dark Mode überschreibt gezielt die Farbwerte.
 */
:root {
    --bg: #f2f5f6;
    --surface: #fff;
    --ink: #18353c;
    --muted: #6c7f85;
    --line: #dfe8ea;
    --accent: #087e82;
    --accent-soft: #e4f3f1;
    --nav: #142f36;
    --radius: 18px;
    font-family: Inter, "Segoe UI", Arial, sans-serif;
    color: var(--ink);
    font-synthesis: none;
}
* {
    box-sizing: border-box;
}
body {
    margin: 0;
    background: var(--bg);
    font-size: 14px;
    line-height: 1.5;
}
button,
input,
select {
    font: inherit;
}
button,
a,
input {
    touch-action: manipulation;
}
a {
    color: var(--accent);
}
button,
a {
    -webkit-tap-highlight-color: transparent;
}
button {
    cursor: pointer;
}
button:disabled {
    opacity: 0.55;
    cursor: wait;
}
a:focus-visible,
button:focus-visible,
input:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible {
    outline: 3px solid #e6a841;
    outline-offset: 4px;
}
svg.icon {
    width: 21px;
    height: 21px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex: none;
}
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}
.skip-link {
    position: fixed;
    top: -80px;
    left: 16px;
    z-index: 10000;
    background: white;
    padding: 12px;
}
.skip-link:focus {
    top: 12px;
}
/* HEVI-ERKLÄRUNG
 * SEITENHIERARCHIE: Äußerer Rahmen mit Navigation und Arbeitsbereich. Min-/Maximalgrößen
 * bestimmen, wie beide Bereiche Platz teilen.
 */
#container {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    min-height: 100vh;
}
/* HEVI-ERKLÄRUNG
 * NAVIGATION: Eigenständiger Bereich für Marke, Hauptmenü und Hinweise. Mobile Medienabfragen
 * verlegen die Bedienung an den unteren Rand.
 */
.sidebar {
    background: var(--nav);
    color: #c6d8db;
    padding: 30px 18px;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}
#header {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 0 12px 36px;
}
.headerlogo {
    width: 36px;
    height: 36px;
    border-radius: 10px;
}
.headertitel {
    display: block;
    color: #fff;
    font-size: 23px;
    font-weight: 750;
    letter-spacing: -0.7px;
}
.brand-sub {
    display: block;
    font-size: 10px;
    letter-spacing: 1.8px;
    text-transform: uppercase;
    color: #8baeb4;
    margin-top: 1px;
}
.nav-caption {
    font-size: 10px;
    font-weight: 650;
    letter-spacing: 1.6px;
    color: #8ba8ae;
    padding: 10px 15px;
}
#navigation {
    display: grid;
    gap: 7px;
}
#navigation a {
    display: flex;
    gap: 12px;
    align-items: center;
    text-decoration: none;
    min-height: 48px;
    color: #bdd0d4;
    padding: 12px 15px;
    border-radius: 11px;
    font-size: 14px;
    font-weight: 550;
    transition: background 0.15s, color 0.15s;
}
#navigation a:hover {
    background: #23434b;
    color: white;
}
#navigation a.active {
    background: #2a535b;
    color: #fff;
    box-shadow: inset 3px 0 #6bcec0;
}
#navigation a.active .icon {
    color: #9de0d4;
}
.sidebar-note {
    margin-top: auto;
    padding: 24px 13px 0;
    font-size: 12px;
    color: #91b1b7;
    border-top: 1px solid #315059;
}
.sidebar-note strong {
    display: block;
    color: #dae9eb;
    font-weight: 500;
    margin-bottom: 5px;
}
/* HEVI-ERKLÄRUNG
 * ARBEITSBEREICH: Gemeinsamer Rahmen für Kopfzeile, Verbrauch, Inhalt und Fußzeile. Unteransichten
 * ergänzen diesen Rahmen, statt eigene Außenabstände zu erfinden.
 */
.workspace {
    min-width: 0;
    padding: 30px clamp(20px, 3vw, 48px) 0;
    max-width: 1700px;
    width: 100%;
    margin: auto;
}
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 28px;
}
.eyebrow {
    text-transform: uppercase;
    letter-spacing: 1.7px;
    font-size: 10px;
    font-weight: 750;
    color: var(--accent);
    margin: 0 0 6px;
}
h1 {
    font-size: clamp(25px, 2.4vw, 35px);
    line-height: 1.18;
    letter-spacing: -1px;
    margin: 0;
    font-weight: 700;
}
.page-subtitle {
    color: var(--muted);
    margin: 9px 0 0;
    font-size: 13px;
}
.top-actions {
    display: flex;
    gap: 13px;
    align-items: center;
}
.data-state {
    display: flex;
    gap: 8px;
    align-items: center;
    font-size: 12px;
    color: var(--muted);
    white-space: nowrap;
}
.state-dot {
    height: 7px;
    width: 7px;
    display: inline-block;
    background: #93a6ac;
    border-radius: 50%;
    flex: none;
}
.data-state.available .state-dot {
    background: #169782;
    box-shadow: 0 0 0 4px #e4f3ed;
}
.data-state.failed .state-dot {
    background: #c08533;
}
.icon-button {
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 12px;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--ink);
}
.icon-button:hover {
    background: var(--accent-soft);
}
/* HEVI-ERKLÄRUNG
 * VERBRAUCHSKACHELN: Die Gasübersicht ist von der Live-Sensorübersicht getrennt und kann mobil
 * eingeklappt werden.
 */
#infobox {
    margin-bottom: 24px;
}
.section-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 11px;
    font-size: 12px;
    color: var(--muted);
}
.section-label strong {
    font-weight: 600;
    color: #48646b;
}
/* HEVI-ERKLÄRUNG
 * KACHELRASTER: Mehrere Verbrauchszeiträume gleichmäßig verteilen; auf schmalen Geräten mit
 * weniger Spalten umbrechen.
 */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
}
.kpi {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 17px 20px;
}
.kpi:first-child {
    border-top: 3px solid var(--accent);
    padding-top: 15px;
}
.kpi-label {
    font-size: 12px;
    color: var(--muted);
    display: block;
    margin-bottom: 8px;
}
.kpi-value {
    font-size: 25px;
    font-weight: 650;
    line-height: 1.2;
    letter-spacing: -0.7px;
    font-variant-numeric: tabular-nums;
}
.kpi-value small {
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0;
    color: var(--muted);
    margin-left: 4px;
}
.kpi-energy {
    display: block;
    color: var(--muted);
    font-size: 11px;
    margin-top: 5px;
    min-height: 16px;
}
/* HEVI-ERKLÄRUNG
 * UNTERANSICHTEN: Gemeinsame Karte für Diagramme, Statistik und Formulare. Diagrammseiten füllen
 * den vorhandenen Höhenrahmen über Flexlayout.
 */
.card,
.page-panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: 0 3px 12px #17333a03;
}
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 23px 25px 12px;
}
.card-header h2 {
    font-size: 17px;
    margin: 0;
    font-weight: 650;
    letter-spacing: -0.3px;
}
.card-header p {
    font-size: 12px;
    color: var(--muted);
    margin: 4px 0 0;
}
.badge {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 5px 10px;
    border-radius: 7px;
    background: var(--accent-soft);
    color: #087267;
    font-size: 10px;
    font-weight: 650;
    white-space: nowrap;
}
.badge .state-dot {
    background: #15947e;
    width: 5px;
    height: 5px;
}
/* HEVI-ERKLÄRUNG
 * VISUALISIERUNG: Der eingebettete Seiteninhalt hat ein festes Seitenverhältnis. Proportional
 * skalieren; nicht einfach mit einer zu kleinen Höhe abschneiden.
 */
.system-frame {
    width: 100%;
    aspect-ratio: 100/43;
    border: 0;
    display: block;
    background: white;
}
/* HEVI-ERKLÄRUNG
 * SCHEMALEGENDE: Farben und Flussmarkierungen erklären. Die Legende gehört zum selben Kartenrahmen
 * wie die Visualisierung.
 */
.system-legend {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    border-top: 1px solid #edf1f2;
    margin: 0 25px;
    padding: 13px 0;
    font-size: 11px;
    color: var(--muted);
}
.temperature-legend {
    display: flex;
    align-items: center;
    gap: 8px;
}
.gradient-key {
    width: 55px;
    height: 5px;
    background: linear-gradient(90deg, #235bd4, #ab4599, #e65846);
    border-radius: 5px;
}
.flow-key {
    display: inline-block;
    vertical-align: middle;
    width: 27px;
    height: 7px;
    background: #31525b;
    border-radius: 3px;
    position: relative;
    margin-right: 5px;
}
.flow-key:after {
    content: "";
    position: absolute;
    top: 3px;
    left: 4px;
    right: 4px;
    border-top: 1px dashed white;
}
/* HEVI-ERKLÄRUNG
 * LIVE-MESSWERTE: Zusammengehörige Sensor- und Speicherkacheln. Überschriften und Hauptwerte
 * brauchen paarweise dieselbe vertikale Ausrichtung.
 */
.live-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 15px;
    margin-bottom: 22px;
}
.live-metric {
    position: relative;
    padding: 18px 20px;
    border: 1px solid var(--line);
    background: #f9fbfb;
    border-radius: 13px;
}
.live-metric .metric-title {
    font-size: 11px;
    color: var(--muted);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 7px;
}
.metric-title .icon {
    width: 15px;
    height: 15px;
    color: var(--accent);
}
/* HEVI-ERKLÄRUNG
 * WERTHIERARCHIE: Hauptwert und kleinere Einheit unterschiedlich gewichten, ohne voneinander
 * abweichende Grundlinien zu erzeugen.
 */
.metric-number {
    display: flex;
    gap: 5px;
    align-items: baseline;
    margin-top: 9px;
    font-size: 27px;
    font-weight: 650;
    line-height: 1.15;
    letter-spacing: -0.8px;
    font-variant-numeric: tabular-nums;
}
.metric-unit {
    font-size: 13px;
    letter-spacing: 0;
    color: var(--muted);
    font-weight: 400;
}
.metric-detail {
    font-size: 11px;
    color: var(--muted);
    margin-top: 7px;
    min-height: 17px;
}
.charge-track {
    height: 3px;
    border-radius: 5px;
    overflow: hidden;
    background: #e4ebed;
    margin-top: 9px;
}
.charge-track span {
    display: block;
    width: 0;
    height: 100%;
    background: var(--accent);
    transition: width 0.5s;
}
/* HEVI-ERKLÄRUNG
 * ANLAGENSTATUS: Pumpe, Brenner und Speicherentnahme getrennt darstellen. Die Entnahmekachel
 * enthält zusätzlich die geschützte Bedienung.
 */
.status-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1.4fr;
    gap: 15px;
    margin-top: 20px;
}
.status-card {
    padding: 19px 20px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: white;
}
.status-label {
    font-size: 11px;
    color: var(--muted);
    margin-bottom: 8px;
}
.status-value {
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}
.status-value .state-dot.on {
    background: #149581;
}
.status-caption {
    color: var(--muted);
    font-size: 11px;
    margin-top: 7px;
}
.control-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 40px;
    border-radius: 9px;
    padding: 9px 14px;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--ink);
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
}
.button:hover {
    background: #f0f6f6;
    border-color: #b8cdcf;
}
.button.primary {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}
.button.primary:hover {
    background: #086b6f;
}
.button[aria-disabled="true"] {
    opacity: 0.35;
    pointer-events: none;
}
#footer {
    padding: 22px 0;
    display: flex;
    justify-content: space-between;
    gap: 16px;
    color: #899ba0;
    font-size: 10px;
}
#footer a {
    color: inherit;
    text-decoration: none;
}
.page-panel {
    padding: 22px 24px;
}
.page-tools {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: center;
    margin-bottom: 6px;
    flex-wrap: wrap;
}
.chart-context {
    font-size: 14px;
    font-weight: 600;
}
.chart-context small {
    display: block;
    color: var(--muted);
    font-size: 11px;
    font-weight: 400;
    margin-top: 3px;
}
#tagwahl {
    display: flex;
    gap: 7px;
    align-items: center;
    flex-wrap: wrap;
}
#tagwahl input[type="date"] {
    border: 1px solid var(--line);
    border-radius: 9px;
    padding: 8px 10px;
    min-height: 40px;
    max-width: 160px;
    color: var(--ink);
    background: white;
    font-size: 12px;
}
#tagwahl .icon {
    width: 16px;
    height: 16px;
}
#chart_div,
#s_chart_div {
    position: relative;
    display: block;
    width: 100%;
    height: 480px;
    margin: 0;
    overflow: hidden;
}
.diagramm svg {
    font-family: "Segoe UI", Arial, sans-serif;
}
#mobilebgfix {
    display: none;
}
#s_nav {
    display: flex;
    gap: 6px;
    background: #f0f4f4;
    padding: 4px;
    border-radius: 10px;
    width: max-content;
    max-width: 100%;
    margin-bottom: 18px;
}
#s_nav a {
    min-height: 36px;
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 8px 16px;
    text-decoration: none;
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    border-radius: 7px;
}
#s_nav a.active {
    background: white;
    color: var(--accent);
    box-shadow: 0 1px 4px #17343b15;
}
#s_content {
    min-width: 0;
}
#s_content > p {
    font-size: 12px !important;
    color: var(--muted);
    margin: 12px 0 20px;
    max-width: 800px;
}
.table-scroll {
    overflow-x: auto;
    max-width: 100%;
    border: 1px solid var(--line);
    border-radius: 11px;
    scrollbar-width: thin;
}
.table-hint {
    font-size: 11px;
    color: var(--muted);
    margin: 0 0 12px;
}
#stattab {
    width: 100%;
    min-width: 680px;
    border-collapse: collapse;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}
#stattab th {
    font-size: 10px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    text-align: right;
    background: #edf4f4;
    color: #527078;
    font-weight: 650;
    padding: 13px 15px;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
#stattab th:first-child,
#stattab td:first-child {
    text-align: left;
}
#stattab td {
    padding: 13px 15px;
    border-bottom: 1px solid #edf1f2;
    line-height: 1.7;
    color: #536b72;
}
#stattab td:first-child {
    font-weight: 600;
    color: var(--ink);
    white-space: nowrap;
}
#stattab tr:nth-child(even) {
    background: #fafcfc;
}
#stattab tr:hover {
    background: #eaf4f2;
}
#eimg {
    height: 18px;
    width: 18px;
    object-fit: contain;
}
#stattab a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    min-height: 36px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: white;
}
.edit-form {
    max-width: 580px;
    padding: 10px 0;
}
.edit-form h2 {
    font-size: 20px;
    letter-spacing: -0.4px;
}
.edit-form p {
    font-size: 13px;
    color: var(--muted);
}
.edit-form label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin: 22px 0 8px;
}
.edit-form input[type="number"] {
    display: block;
    min-height: 46px;
    width: 100%;
    max-width: 280px;
    border: 1px solid #c2d3d7;
    border-radius: 9px;
    padding: 10px 13px;
    font-size: 18px;
    color: var(--ink);
}
.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 24px;
}
.empty-state {
    padding: 30px;
    color: var(--muted);
    font-size: 13px;
}
/* HEVI-ERKLÄRUNG
 * PUSH-DIALOG: Modaler Rahmen mit Laufzeitauswahl und Statusrückmeldung. JavaScript verwaltet
 * Zustimmung, Abozustand und Fokus, CSS nur die Darstellung.
 */
#push-panel {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    background: #102b3b78;
    backdrop-filter: blur(5px);
    padding: 20px;
}
#push-panel.open {
    display: flex;
}
#push-panel .push-card {
    position: relative;
    background: white;
    color: var(--ink);
    border: 1px solid #fff;
    border-radius: 22px;
    width: min(100%, 440px);
    max-height: calc(100dvh - 40px);
    overflow: auto;
    box-shadow: 0 30px 100px #0c232b35;
    padding: 30px;
}
#push-panel h2 {
    font-size: 23px;
    line-height: 1.2;
    letter-spacing: -0.6px;
    font-weight: 650;
    margin: 6px 25px 13px 0;
}
#push-panel p {
    font-size: 13px;
    line-height: 1.65;
    color: var(--muted);
    margin: 0;
}
#push-panel .push-symbol {
    width: 44px;
    height: 44px;
    border-radius: 13px;
    background: var(--accent-soft);
    color: var(--accent);
    display: grid;
    place-items: center;
    margin-bottom: 18px;
}
#push-panel .push-options {
    display: grid;
    gap: 9px;
    margin-top: 23px;
}
#push-panel [data-hours] {
    min-height: 46px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #f3f7f7;
    color: var(--ink);
    font-size: 13px;
    font-weight: 550;
    padding: 12px;
}
#push-panel [data-hours].primary {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
#push-panel [data-hours]:hover {
    filter: brightness(0.96);
}
#push-panel .push-status {
    font-size: 12px;
    line-height: 1.5;
    color: #a04330;
    margin-top: 14px;
    min-height: 10px;
}
#push-close {
    position: absolute;
    right: 16px;
    top: 16px;
    width: 32px;
    height: 32px;
    border: 0;
    background: transparent;
    color: var(--muted);
    border-radius: 8px;
    font-size: 22px;
}
.push-footnote {
    font-size: 11px !important;
    margin-top: 15px !important;
}
/* Anpassung für (min-width:1700px): überschreibt nur die hierfür geltenden Grundregeln. */
@media (min-width: 1700px) {
    .workspace {
        padding-top: 38px;
    }
    .system-frame {
        max-height: 610px;
    }
    .kpi {
        padding: 21px 24px;
    }
    .kpi:first-child {
        padding-top: 19px;
    }
}
/* Anpassung für (max-width:1150px): überschreibt nur die hierfür geltenden Grundregeln. */
@media (max-width: 1150px) {
    #container {
        grid-template-columns: 190px minmax(0, 1fr);
    }
    .sidebar {
        padding: 26px 12px;
    }
    .workspace {
        padding: 25px 22px 0;
    }
    .kpi {
        padding: 15px;
    }
    .kpi:first-child {
        padding-top: 13px;
    }
    .kpi-value {
        font-size: 23px;
    }
    .top-actions .data-state {
        display: none;
    }
    .status-grid {
        grid-template-columns: 1fr 1fr;
    }
    .status-card:last-child {
        grid-column: 1/-1;
    }
    .live-metric {
        padding: 15px;
    }
    .metric-number {
        font-size: 24px;
    }
}
/* Anpassung für (max-width:780px): überschreibt nur die hierfür geltenden Grundregeln. */
@media (max-width: 780px) {
    #container {
        display: block;
    }
    .sidebar {
        height: auto;
        position: relative;
        padding: 0;
        background: transparent;
    }
    .nav-caption,
    .sidebar-note,
    .brand-sub {
        display: none;
    }
    #header {
        padding: 17px 20px 12px;
        gap: 9px;
    }
    .headerlogo {
        height: 30px;
        width: 30px;
        border-radius: 8px;
    }
    .headertitel {
        color: var(--ink);
        font-size: 21px;
    }
    #navigation {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 500;
        background: #fffefc;
        border-top: 1px solid var(--line);
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 0;
        padding: 5px 6px max(6px, env(safe-area-inset-bottom));
        box-shadow: 0 -3px 18px #17343b06;
    }
    #navigation a {
        flex-direction: column;
        justify-content: center;
        gap: 4px;
        min-height: 54px;
        padding: 6px 2px;
        border-radius: 10px;
        font-size: 10px;
        font-weight: 600;
        color: #769097;
    }
    #navigation a.active {
        background: var(--accent-soft);
        color: var(--accent);
        box-shadow: none;
    }
    #navigation a.active .icon {
        color: var(--accent);
    }
    #navigation a:hover {
        background: #eef5f4;
        color: var(--ink);
    }
    #navigation .icon {
        width: 20px;
        height: 20px;
    }
    .workspace {
        padding: 9px 20px 0;
    }
    .topbar {
        gap: 12px;
        align-items: flex-start;
        margin-bottom: 22px;
    }
    .top-actions {
        position: absolute;
        right: 20px;
        top: 14px;
    }
    .icon-button {
        width: 36px;
        height: 36px;
        border-radius: 10px;
    }
    .top-actions .icon {
        width: 19px;
        height: 19px;
    }
    .eyebrow {
        font-size: 9px;
    }
    h1 {
        font-size: 27px;
    }
    .page-subtitle {
        font-size: 12px;
        max-width: 340px;
    }
    .section-label {
        font-size: 10px;
        margin-bottom: 9px;
    }
    .section-label strong {
        font-size: 11px;
    }
    .kpi-grid {
        gap: 9px;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .kpi {
        padding: 13px 15px;
        border-radius: 12px;
    }
    .kpi:first-child {
        padding-top: 11px;
    }
    .kpi-label {
        font-size: 10px;
        margin-bottom: 5px;
    }
    .kpi-value {
        font-size: 23px;
    }
    .kpi-energy {
        font-size: 10px;
        margin-top: 3px;
    }
    .kpi-value small {
        font-size: 11px;
    }
    #infobox {
        margin-bottom: 20px;
    }
    .live-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 9px;
        margin-bottom: 18px;
    }
    .live-metric {
        padding: 14px 15px;
        background: #fff;
    }
    .metric-number {
        font-size: 25px;
        margin-top: 7px;
    }
    .metric-title {
        font-size: 10px !important;
    }
    .metric-detail {
        font-size: 10px;
    }
    .card-header {
        padding: 18px 16px 9px;
    }
    .card-header h2 {
        font-size: 16px;
    }
    .card-header p {
        font-size: 10px;
    }
    .badge {
        font-size: 9px;
        padding: 5px 7px;
    }
    .system-frame {
        aspect-ratio: 100/45;
    }
    .system-legend {
        margin: 0 14px;
        padding: 11px 0;
        flex-wrap: wrap;
        gap: 7px;
        font-size: 9px;
    }
    .gradient-key {
        width: 38px;
    }
    .status-grid {
        gap: 9px;
        margin-top: 14px;
    }
    .status-card {
        padding: 15px;
        border-radius: 12px;
    }
    .status-label {
        font-size: 10px;
    }
    .status-value {
        font-size: 12px;
    }
    .status-caption {
        font-size: 10px;
    }
    .control-row {
        align-items: center;
    }
    .control-row .button {
        font-size: 11px;
        min-height: 40px;
        padding: 9px 11px;
    }
    #footer {
        padding: 22px 0 95px;
        font-size: 9px;
        flex-direction: column;
        gap: 4px;
    }
    .page-panel {
        padding: 17px 12px;
        border-radius: 15px;
    }
    .page-tools {
        gap: 12px;
        margin-bottom: 8px;
    }
    .chart-context {
        font-size: 13px;
    }
    .chart-context small {
        font-size: 10px;
    }
    #tagwahl {
        gap: 5px;
        width: 100%;
    }
    #tagwahl .button {
        font-size: 11px;
        padding: 8px 10px;
        min-height: 42px;
    }
    #tagwahl input[type="date"] {
        font-size: 11px;
        min-height: 42px;
        max-width: 145px;
    }
    #chart_div,
    #s_chart_div {
        height: 440px;
    }
    #s_nav {
        margin-bottom: 12px;
    }
    #s_nav a {
        padding: 8px 13px;
        font-size: 11px;
    }
    #s_content > p {
        font-size: 11px !important;
    }
    .table-hint {
        font-size: 10px;
    }
    #stattab {
        font-size: 11px;
        min-width: 650px;
    }
    #stattab th,
    #stattab td {
        padding: 11px;
    }
    .edit-form {
        padding: 0 5px;
    }
    .edit-form h2 {
        font-size: 19px;
    }
}
/* Anpassung für (max-width:360px): überschreibt nur die hierfür geltenden Grundregeln. */
@media (max-width: 360px) {
    .workspace {
        padding-left: 13px;
        padding-right: 13px;
    }
    #header {
        padding-left: 13px;
    }
    .top-actions {
        right: 13px;
    }
    .kpi {
        padding-left: 12px;
        padding-right: 12px;
    }
    .kpi-value {
        font-size: 21px;
    }
    .metric-number {
        font-size: 23px;
    }
    .badge {
        display: none;
    }
    .card-header {
        padding-left: 14px;
    }
    #tagwahl input[type="date"] {
        max-width: 125px;
    }
    #tagwahl .button {
        padding: 8px;
    }
    .system-legend > span:last-child {
        font-size: 8px;
    }
    .control-row {
        flex-wrap: wrap;
    }
    .control-row form {
        width: 100%;
    }
    .control-row .button {
        width: 100%;
    }
}
/* Anpassung für (prefers-reduced-motion:reduce): überschreibt nur die hierfür geltenden Grundregeln. */
@media (prefers-reduced-motion: reduce) {
    *,
    *:before,
    *:after {
        scroll-behavior: auto !important;
        transition: none !important;
    }
    .charge-track span {
        transition: none;
    }
}
.workspace {
    margin: 0 auto;
}
.consumption-toggle {
    display: none;
}
@media (max-width: 780px) {
    .desktop-consumption-title {
        display: none;
    }
    .consumption-toggle {
        display: inline-flex;
        align-items: center;
        gap: 8px;
        border: 0;
        padding: 9px 0;
        background: transparent;
        color: var(--accent);
        font-size: 11px;
        font-weight: 600;
        min-height: 38px;
    }
    .consumption-toggle[aria-expanded="true"] span {
        transform: rotate(180deg);
    }
    #infobox .kpi-grid {
        display: none;
    }
    #infobox.expanded .kpi-grid {
        display: grid;
    }
    #infobox .section-label {
        margin-bottom: 0;
        gap: 8px;
    }
    #infobox.expanded .section-label {
        margin-bottom: 8px;
    }
    #infobox {
        margin-top: -8px;
        margin-bottom: 16px;
    }
}

/* HEVI-ERKLÄRUNG
 * AUFMERKSAMKEIT: Die Warnung leicht hervorheben; die fachliche Sichtbarkeit kommt aus dem
 * Live-Zustand. Reduzierte Bewegung wird separat respektiert.
 */
.stove-warning {
    display: inline-flex;
    color: #a96816;
    margin-left: auto;
    align-items: center;
}
.stove-warning .icon {
    width: 21px;
    height: 21px;
}
.warning-label {
    font-size: 11px;
    color: #a96816;
    margin-top: 5px;
    font-weight: 600;
}
.live-metric.has-warning {
    border-color: #d7a352;
    background: #fffaf0;
}
.stove-warning[hidden],
.warning-label[hidden] {
    display: none !important;
}
.support-state {
    font-size: 10px;
    line-height: 1.4;
    margin-top: 7px;
    color: var(--muted);
    display: flex;
    align-items: flex-start;
    gap: 5px;
}
.support-state:before {
    content: "";
    width: 5px;
    height: 5px;
    flex: none;
    margin-top: 4px;
    border-radius: 50%;
    background: #93a6ac;
}
.support-state[data-state="active"] {
    color: #087768;
}
.support-state[data-state="active"]:before {
    background: #179c82;
}
.support-state[data-state="paused"] {
    color: #a96817;
}
.support-state[data-state="paused"]:before {
    background: #c28834;
}

html[data-theme="dark"] {
    --bg: #101b22;
    --surface: #192a33;
    --ink: #e2edf1;
    --muted: #a0b5bd;
    --line: #344a55;
    --accent: #78d8ca;
    --accent-soft: #243f43;
    --nav: #0d1920;
    color-scheme: dark;
}
html[data-theme="light"] {
    color-scheme: light;
}
[data-theme="dark"] .icon-button,
[data-theme="dark"] .button,
[data-theme="dark"] .live-metric,
[data-theme="dark"] .status-card,
[data-theme="dark"] .system-frame,
[data-theme="dark"] .skip-link {
    background: var(--surface);
    color: var(--ink);
}
[data-theme="dark"] .icon-button:hover,
[data-theme="dark"] .button:hover {
    background: #2a434d;
    border-color: #526d77;
}
[data-theme="dark"] .button.primary,
[data-theme="dark"] #push-panel [data-hours].primary {
    background: #68c9bb;
    color: #102e31;
    border-color: #68c9bb;
}
[data-theme="dark"] .section-label strong {
    color: #b1cbd1;
}
[data-theme="dark"] .system-legend {
    border-color: var(--line);
}
[data-theme="dark"] .badge {
    color: #98e4d5;
    background: #24443f;
}
[data-theme="dark"] .charge-track {
    background: #344952;
}
[data-theme="dark"] #tagwahl input[type="date"],
[data-theme="dark"] .edit-form input[type="number"] {
    background: #15262f;
    color: var(--ink);
    border-color: var(--line);
}
[data-theme="dark"] #s_nav {
    background: #101f27;
}
[data-theme="dark"] #s_nav a.active {
    background: #304a51;
    color: #95e2d5;
}
[data-theme="dark"] #stattab th {
    background: #223b44;
    color: #b5cdd3;
}
[data-theme="dark"] #stattab td {
    color: #b5c8cf;
    border-color: #2b424c;
}
[data-theme="dark"] #stattab td:first-child {
    color: var(--ink);
}
[data-theme="dark"] #stattab tr:nth-child(even) {
    background: #1d313a;
}
[data-theme="dark"] #stattab tr:hover {
    background: #28444a;
}
[data-theme="dark"] #stattab a {
    background: #263e48;
    border-color: var(--line);
}
[data-theme="dark"] #push-panel .push-card {
    background: var(--surface);
    border-color: var(--line);
}
[data-theme="dark"] #push-panel [data-hours] {
    background: #263e48;
    border-color: var(--line);
    color: var(--ink);
}
[data-theme="dark"] #push-panel .push-status {
    color: #f0b99a;
}
[data-theme="dark"] .data-state.available .state-dot {
    box-shadow: 0 0 0 4px #29453f;
    background: #69d1b3;
}
[data-theme="dark"] .support-state[data-state="active"] {
    color: #8edccc;
}
[data-theme="dark"] .support-state[data-state="paused"],
[data-theme="dark"] .stove-warning,
[data-theme="dark"] .warning-label {
    color: #efbf70;
}
[data-theme="dark"] .live-metric.has-warning {
    border-color: #98763d;
    background: #352f24;
}
/* Anpassung für (max-width:780px): überschreibt nur die hierfür geltenden Grundregeln. */
@media (max-width: 780px) {
    [data-theme="dark"] #navigation {
        background: #192a33;
    }
    [data-theme="dark"] #navigation a {
        color: #a5bec7;
    }
    [data-theme="dark"] #navigation a.active {
        background: #28494b;
        color: #91e4d5;
    }
    [data-theme="dark"] #navigation a:hover {
        background: #28434c;
        color: #e1edef;
    }
}

.stat-mobile {
    display: none;
}
/* Langzeitanteile stehen auf Tageswerten und Verbrauchsverlauf in derselben
   kompakten Lesereihenfolge: Zeitraum links, Gas-/Holz-Verhältnis rechts. */
.tageswerte-energieanteile {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin: 0 0 10px;
}
.tageswerte-energieanteile > div {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    min-width: 0;
    gap: 12px;
    padding: 9px 11px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
}
.tageswerte-energieanteile dt {
    overflow: hidden;
    color: var(--muted);
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.tageswerte-energieanteile dd {
    margin: 0;
    font-size: 15px;
    font-weight: 650;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
/* Anpassung für (max-width:780px): überschreibt nur die hierfür geltenden Grundregeln. */
@media (max-width: 780px) {
    #s_content .table-scroll {
        display: none;
    }
    .stat-mobile {
        display: grid;
        gap: 12px;
    }
    .tageswerte-energieanteile {
        gap: 5px;
    }
    .tageswerte-energieanteile > div {
        display: block;
        padding: 7px 8px;
    }
    .tageswerte-energieanteile dt {
        font-size: 10px;
    }
    .tageswerte-energieanteile dd {
        margin-top: 2px;
        font-size: 14px;
    }
    /* HEVI-ERKLÄRUNG
 * MOBILE TAGESWERTE: Alle Daten eines Tages gehören in eine kompakte Karte. Anders als Diagramme
 * darf die Liste dafür vertikal weiterlaufen.
 */
    .day-card {
        background: var(--surface);
        border: 1px solid var(--line);
        border-radius: 13px;
        padding: 0 14px 13px;
        min-width: 0;
    }
    .day-header {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 11px 0;
        border-bottom: 1px solid var(--line);
    }
    .day-header time {
        font-size: 13px;
        font-weight: 650;
        letter-spacing: -0.2px;
    }
    .day-outside {
        margin-left: auto;
        font-size: 11px;
        font-weight: 550;
        white-space: nowrap;
        color: var(--ink);
    }
    .day-outside span {
        display: block;
        font-size: 9px;
        font-weight: 400;
        color: var(--muted);
    }
    .day-edit {
        width: 34px;
        min-height: 38px;
        border: 1px solid var(--line);
        border-radius: 8px;
        display: grid;
        place-items: center;
        color: var(--accent);
        background: var(--accent-soft);
    }
    .day-edit .icon {
        width: 16px;
        height: 16px;
    }
    .day-grid {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px 14px;
        margin: 13px 0 0;
    }
    .day-value {
        min-width: 0;
    }
    .day-value dt {
        font-size: 10px;
        color: var(--muted);
        margin-bottom: 4px;
    }
    .day-value dd {
        margin: 0;
        font-size: 12px;
        line-height: 1.6;
        font-weight: 550;
        font-variant-numeric: tabular-nums;
        overflow-wrap: anywhere;
    }
    .day-value.saving dd {
        color: var(--accent);
    }
    .no-comparison {
        color: var(--muted);
    }
    #s_content > p {
        line-height: 1.6;
    }
}

.storage-explanation {
    margin-left: auto;
    font-size: 14px;
    color: var(--accent);
    position: static;
    line-height: 1;
}
.storage-explanation summary {
    cursor: pointer;
    list-style: none;
    padding: 2px;
}
.storage-explanation summary::-webkit-details-marker {
    display: none;
}
.storage-popover {
    position: absolute;
    top: 36px;
    right: 0;
    width: min(300px, calc(100vw - 40px));
    background: var(--surface);
    color: var(--ink);
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: 0 10px 35px #102d3a30;
    padding: 15px;
    z-index: 100;
    font-size: 12px;
    line-height: 1.5;
}
.storage-popover strong {
    font-size: 13px;
}
.storage-popover p {
    margin: 9px 0 0;
    color: var(--muted);
}

/* Compact layout: preserve values and controls, omit redundant descriptions. */
.workspace {
    padding-top: 23px;
}
.topbar {
    margin-bottom: 18px;
}
.topbar h1 {
    font-size: 30px;
}
#infobox {
    margin-bottom: 18px;
}
.kpi {
    padding: 13px 17px;
}
.kpi:first-child {
    padding-top: 11px;
}
.kpi-label {
    margin-bottom: 5px;
}
.kpi-value {
    font-size: 23px;
}
.kpi-energy {
    margin-top: 3px;
}
.live-grid {
    margin-bottom: 15px;
    gap: 12px;
}
.live-metric {
    padding: 13px 16px;
}
.metric-number {
    font-size: 25px;
    margin-top: 6px;
}
.metric-detail {
    margin-top: 4px;
    min-height: 14px;
}
.charge-track {
    margin-top: 6px;
}
.card-header {
    padding: 15px 21px 6px;
}
.system-legend {
    padding: 8px 0;
}
.status-grid {
    margin-top: 13px;
    gap: 12px;
}
.status-card {
    padding: 11px 15px;
}
.status-label {
    margin-bottom: 5px;
    font-size: 10px;
}
.status-card .button {
    min-height: 34px;
    padding: 7px 11px;
}
.status-card .status-value {
    font-size: 12px;
}
#metric-return-info[hidden] {
    display: none;
}
.storage-popover {
    top: 30px;
}
/* Anpassung für (max-width:780px): überschreibt nur die hierfür geltenden Grundregeln. */
@media (max-width: 780px) {
    #header {
        padding: 10px 14px 6px;
    }
    .headerlogo {
        width: 28px;
        height: 28px;
    }
    .headertitel {
        font-size: 20px;
    }
    .top-actions {
        top: 9px;
        right: 14px;
        gap: 8px;
    }
    .workspace {
        padding: 0 13px;
    }
    .topbar {
        margin-bottom: 7px;
        min-height: 31px;
    }
    .topbar h1 {
        font-size: 23px;
        line-height: 1.25;
        letter-spacing: -0.6px;
    }
    #infobox {
        margin: 0 0 9px;
    }
    .consumption-toggle {
        min-height: 30px;
        padding: 4px 0;
    }
    .section-label {
        font-size: 9px;
    }
    .kpi {
        padding: 10px 12px;
    }
    .kpi:first-child {
        padding-top: 8px;
    }
    .kpi-value {
        font-size: 21px;
    }
    .kpi-grid {
        gap: 7px;
    }
    .live-grid {
        gap: 7px;
        margin-bottom: 10px;
    }
    .live-metric {
        padding: 9px 11px;
        border-radius: 11px;
    }
    .metric-title {
        font-size: 10px !important;
        gap: 5px !important;
    }
    .metric-title .icon {
        width: 13px;
        height: 13px;
    }
    .metric-number {
        font-size: 22px;
        margin-top: 4px;
        line-height: 1.12;
    }
    .metric-unit {
        font-size: 11px;
    }
    .metric-detail {
        font-size: 9px;
        margin-top: 4px;
        min-height: 12px;
    }
    .charge-track {
        margin-top: 5px;
        height: 2px;
    }
    .support-state {
        margin-top: 5px;
        font-size: 9px;
        line-height: 1.25;
        gap: 4px;
    }
    .support-state:before {
        margin-top: 3px;
        width: 4px;
        height: 4px;
    }
    .card-header {
        padding: 10px 12px 5px;
    }
    .card-header h2 {
        font-size: 15px;
    }
    .badge {
        font-size: 8px;
        padding: 3px 6px;
    }
    .system-legend {
        padding: 6px 0;
        margin: 0 12px;
        gap: 5px;
        font-size: 8px;
    }
    .system-frame {
        aspect-ratio: 100/43;
    }
    .system-legend > span:last-child {
        font-size: 8px;
    }
    .status-grid {
        margin-top: 8px;
        gap: 7px;
    }
    .status-card {
        padding: 8px 11px;
        border-radius: 11px;
    }
    .status-label {
        font-size: 8px;
        margin-bottom: 4px;
    }
    .status-card .status-value {
        font-size: 11px;
    }
    .control-row {
        gap: 8px;
    }
    .status-card .button {
        min-height: 32px;
        font-size: 10px;
        padding: 6px 9px;
    }
    .control-row form {
        width: auto;
    }
    .control-row .button {
        width: auto;
    }
    #footer {
        padding: 9px 0 76px;
        font-size: 8px;
        line-height: 1.3;
    }
    #footer > span:first-child {
        display: none;
    }
    .page-panel {
        padding: 12px 10px;
    }
    .page-tools {
        gap: 7px;
        margin-bottom: 4px;
    }
    .chart-context {
        display: none;
    }
    #s_nav {
        margin-bottom: 9px;
    }
    #tagwahl {
        gap: 5px;
    }
    #tagwahl .button,
    #tagwahl input[type="date"] {
        min-height: 36px;
        padding: 7px 9px;
    }
    .storage-popover {
        top: 27px;
    }
    .storage-explanation {
        font-size: 12px;
    }
    .warning-label {
        font-size: 9px;
        margin-top: 3px;
    }
}
/* Anpassung für (max-width:360px): überschreibt nur die hierfür geltenden Grundregeln. */
@media (max-width: 360px) {
    .topbar h1 {
        font-size: 22px;
    }
    .status-card {
        padding: 8px;
    }
    .status-card .button {
        font-size: 9px;
        padding: 6px 8px;
    }
    .control-row {
        flex-wrap: nowrap;
    }
    .control-row form {
        width: auto;
    }
    .control-row .button {
        width: auto;
    }
    .metric-title {
        font-size: 9px !important;
    }
    .system-legend > span:last-child {
        font-size: 7px;
    }
}

#content {
    position: relative;
}
/* HEVI-ERKLÄRUNG
 * LADEZUSTAND: Der Loader nimmt schon die endgültige Diagrammfläche ein; dadurch springt der
 * umgebende Rahmen später nicht erneut.
 */
.chart-loader {
    position: absolute;
    inset: 74px 0 0;
    z-index: 20;
    min-height: 210px;
    background: var(--surface);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 12px;
    font-size: 12px;
    color: var(--muted);
    pointer-events: none;
}
.chart-loader[hidden],
.chart-retry[hidden] {
    display: none !important;
}
.chart-retry {
    pointer-events: auto;
}
.loading-spinner {
    width: 29px;
    height: 29px;
    flex: none;
    border: 2px solid var(--line);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: hevi-loading 0.8s linear infinite;
}
.load-error .loading-spinner {
    display: none;
}
.pending-panel {
    position: relative;
    min-height: 360px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.pending-status {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    gap: 13px;
    color: var(--muted);
    font-size: 13px;
    padding: 18px 22px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
}
.loading-grid {
    position: absolute;
    inset: 44px 45px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    opacity: 0.5;
}
.loading-grid i {
    display: block;
    border-top: 1px solid var(--line);
}
@keyframes hevi-loading {
    to {
        transform: rotate(360deg);
    }
}
/* Anpassung für (max-width:780px): überschreibt nur die hierfür geltenden Grundregeln. */
@media (max-width: 780px) {
    .chart-loader {
        inset: 105px 0 0;
        min-height: 180px;
    }
    .pending-panel {
        min-height: 320px;
    }
    .pending-status {
        font-size: 12px;
    }
    .loading-grid {
        inset: 35px 25px;
    }
}
/* Apply the final chart frame before scripts and diagram markup have loaded. */
body.chart-page .workspace {
    height: 100svh;
    display: flex;
    flex-direction: column;
}
body.chart-page #content {
    flex: 1;
    min-height: 440px;
}
body.chart-page .page-panel {
    height: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
}
body.chart-page #s_content {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}
body.chart-page .topbar,
body.chart-page #infobox,
body.chart-page #footer,
body.chart-page .page-tools,
body.chart-page #s_nav {
    flex-shrink: 0;
}
body.chart-page #footer {
    padding: 10px 0;
    flex: none;
}
#chart_div,
#s_chart_div {
    flex: 1;
    min-height: 260px;
    height: auto;
    contain: size layout;
    min-width: 0;
}
body.chart-page .pending-panel {
    min-height: 0;
}
.chart-loader {
    inset: 0;
    min-height: 0;
    border: 1px solid var(--line);
    border-radius: var(--radius);
}
/* Anpassung für (max-width:780px): überschreibt nur die hierfür geltenden Grundregeln. */
@media (max-width: 780px) {
    body.chart-page .workspace {
        height: calc(100svh - 44px);
        padding-bottom: 68px;
    }
    body.chart-page #content {
        min-height: 390px;
    }
    body.chart-page #footer {
        padding: 7px 0;
    }
}
/* Anpassung für (prefers-reduced-motion:reduce): überschreibt nur die hierfür geltenden Grundregeln. */
@media (prefers-reduced-motion: reduce) {
    .loading-spinner {
        animation: none;
        border-color: var(--line);
        border-top-color: var(--accent);
    }
}

/* HEVI-ERKLÄRUNG
 * SVG-ZWISCHENBILD: Bleibt während der Größenanpassung über dem neu zeichnenden Diagramm sichtbar
 * und nimmt keine Eingaben entgegen.
 */
.chart-renderer,
.chart-resize-preview {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}
.chart-resize-preview {
    z-index: 2;
    pointer-events: none;
    background: var(--surface);
}
.chart-resize-preview[hidden] {
    display: none !important;
}
.chart-resize-preview > svg {
    display: block;
    width: 100%;
    height: 100%;
}

/* Distribute spare phone height through the overview cards, retaining diagram proportions. */
/* Anpassung für (max-width:780px): überschreibt nur die hierfür geltenden Grundregeln. */
@media (max-width: 780px) {
    body.overview-page .workspace {
        min-height: calc(100svh - 46px);
        padding-bottom: 68px;
        display: flex;
        flex-direction: column;
    }
    body.overview-page .topbar,
    body.overview-page #infobox,
    body.overview-page #footer {
        flex-shrink: 0;
    }
    body.overview-page #content {
        flex: 1;
        display: flex;
        flex-direction: column;
    }
    body.overview-page .live-grid {
        flex: 1 0 auto;
    }
    body.overview-page .live-metric {
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
    }
    body.overview-page .metric-title {
        min-height: 18px;
        flex: none;
    }
    body.overview-page .metric-number {
        font-size: clamp(22px, 3.1svh, 28px);
    }
    body.overview-page .system-card {
        flex: none;
    }
    body.overview-page .status-grid {
        flex: 1 0 auto;
    }
    body.overview-page .status-card {
        display: flex;
        flex-direction: column;
        justify-content: center;
    }
    body.overview-page #footer {
        padding: 7px 0;
    }
}

.stove-warning:not([hidden]) {
    animation: stove-warning-pulse 2.4s ease-in-out infinite;
    transform-origin: center;
}
@keyframes stove-warning-pulse {
    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.6;
        transform: scale(1.08);
    }
}
/* Anpassung für (prefers-reduced-motion:reduce): überschreibt nur die hierfür geltenden Grundregeln. */
@media (prefers-reduced-motion: reduce) {
    .stove-warning:not([hidden]) {
        animation: none;
    }
}

.day-value.saving-negative dd,
#stattab td.saving-negative {
    color: #b55f32;
}
[data-theme="dark"] .day-value.saving-negative dd,
[data-theme="dark"] #stattab td.saving-negative {
    color: #efa471;
}

.savings-method {
    font-size: 11px;
    color: var(--muted);
    margin: 0 0 6px;
}
.savings-method summary {
    cursor: pointer;
    width: max-content;
    max-width: 100%;
    color: var(--accent);
    padding: 3px 0;
}
.savings-method p {
    margin: 5px 0 10px;
    max-width: 800px;
    line-height: 1.5;
}
#stattab th,
#stattab td {
    padding: 8px 11px;
    line-height: 1.4;
}
/* Anpassung für (max-width:780px): überschreibt nur die hierfür geltenden Grundregeln. */
@media (max-width: 780px) {
    .stat-mobile {
        gap: 8px;
    }
    .day-card {
        padding: 0 11px 9px;
        border-radius: 11px;
    }
    .day-header {
        padding: 4px 0;
        gap: 7px;
    }
    .day-header time {
        font-size: 12px;
    }
    .day-outside {
        font-size: 10px;
    }
    .day-outside span {
        display: inline;
        font-size: 9px;
        margin-right: 4px;
    }
    .day-edit {
        width: 30px;
        min-height: 30px;
        border-radius: 7px;
    }
    .day-edit .icon {
        width: 14px;
        height: 14px;
    }
    .day-grid {
        gap: 7px 11px;
        margin: 7px 0 0;
    }
    .day-value dt {
        font-size: 9px;
        margin-bottom: 2px;
    }
    .day-value dd {
        font-size: 11px;
        line-height: 1.4;
    }
    .runtime-divider {
        color: var(--muted);
    }
    .table-hint {
        font-size: 9px;
        margin: 0 0 7px;
    }
}

.mobile-subnav,
.nav-more {
    display: none;
}
/* Anpassung für (max-width:780px): überschreibt nur die hierfür geltenden Grundregeln. */
@media (max-width: 780px) {
    #navigation a {
        position: relative;
    }
    .nav-more {
        display: block;
        position: absolute;
        right: 9px;
        top: 9px;
        width: 10px;
        height: 10px;
        fill: none;
        stroke: currentColor;
        stroke-width: 1.6;
        stroke-linecap: round;
        stroke-linejoin: round;
    }
    /* HEVI-ERKLÄRUNG
 * MOBILES UNTERMENÜ: Zusätzliche Auswahl bei Heizung und Statistik, solange die Zielansicht lädt.
 * Sichtbarkeit und Timer werden von app.js gesteuert.
 */
    .mobile-subnav {
        position: fixed;
        bottom: calc(78px + env(safe-area-inset-bottom));
        right: 13px;
        z-index: 650;
        width: 220px;
        padding: 5px;
        border: 1px solid var(--line);
        border-radius: 12px;
        background: var(--surface);
        box-shadow: 0 8px 30px #142f3626;
    }
    .mobile-subnav[data-open="heating"],
    .mobile-subnav[data-open="statistics"] {
        display: block;
    }
    .mobile-subnav[data-open="heating"] {
        right: calc(25% + 7px);
    }
    .mobile-subnav nav {
        display: none;
        gap: 5px;
    }
    .mobile-subnav[data-open="heating"] [data-submenu="heating"],
    .mobile-subnav[data-open="statistics"] [data-submenu="statistics"] {
        display: flex;
    }
    .mobile-subnav a {
        flex: 1;
        text-align: center;
        text-decoration: none;
        font-size: 12px;
        font-weight: 550;
        padding: 11px 7px;
        border-radius: 8px;
        color: var(--ink);
    }
    .mobile-subnav a.active,
    .mobile-subnav a:hover {
        background: var(--accent-soft);
        color: var(--accent);
    }
}

/* HEVI-ERKLÄRUNG
 * TARIFEINGABE: Die Gestaltung allein vergibt keine Berechtigung. Ob dieses Formular ausgegeben
 * wird, entscheidet die serverseitige Heimnetzprüfung.
 */
.tariff-form {
    margin: 10px 0 12px;
    max-width: 380px;
}
.tariff-form label {
    display: block;
    font-size: 11px;
    color: var(--ink);
    margin-bottom: 5px;
}
.tariff-input-row {
    display: flex;
    gap: 8px;
    align-items: center;
}
.tariff-input-row input {
    width: 95px;
    min-height: 36px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 7px 9px;
    color: var(--ink);
    background: var(--surface);
}
.tariff-input-row .button {
    min-height: 36px;
    padding: 7px 11px;
}
.tariff-saved {
    font-size: 11px;
    color: var(--accent);
    margin: 0 0 8px;
}

#push-status[data-kind="success"] {
    color: var(--accent);
}
#push-status[data-kind="warning"] {
    color: #b26f25;
}
#notifications-button[data-push-state="active"] {
    position: relative;
}
#notifications-button[data-push-state="active"]:after,
#notifications-button[data-push-state="pending"]:after {
    content: "";
    position: absolute;
    right: 5px;
    top: 5px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #159c83;
}
#notifications-button[data-push-state="pending"] {
    position: relative;
}
#notifications-button[data-push-state="pending"]:after {
    background: #d4953a;
}
/* Anpassung für (min-width:781px): überschreibt nur die hierfür geltenden Grundregeln. */
@media (min-width: 781px) {
    body.overview-page .workspace {
        height: 100svh;
        display: flex;
        flex-direction: column;
        padding-top: 16px;
    }
    body.overview-page .topbar {
        margin-bottom: 10px;
        flex: none;
    }
    body.overview-page .topbar h1 {
        font-size: 27px;
    }
    body.overview-page #infobox {
        margin-bottom: 10px;
        flex: none;
    }
    body.overview-page .section-label {
        margin-bottom: 6px;
    }
    body.overview-page .kpi {
        padding: 8px 13px;
    }
    body.overview-page .kpi:first-child {
        padding-top: 6px;
    }
    body.overview-page .kpi-label {
        font-size: 11px;
        margin-bottom: 3px;
    }
    body.overview-page .kpi-value {
        font-size: 21px;
    }
    body.overview-page .kpi-energy {
        font-size: 10px;
        margin-top: 2px;
        min-height: 14px;
    }
    body.overview-page #content {
        flex: 1;
        min-height: 0;
        display: flex;
        flex-direction: column;
    }
    body.overview-page .live-grid {
        flex: none;
        margin-bottom: 10px;
        gap: 10px;
    }
    body.overview-page .live-metric {
        padding: 9px 13px;
    }
    body.overview-page .metric-number {
        font-size: 23px;
        margin-top: 4px;
    }
    body.overview-page .metric-detail {
        margin-top: 3px;
        min-height: 14px;
        font-size: 10px;
    }
    body.overview-page .charge-track {
        margin-top: 5px;
    }
    body.overview-page .system-card {
        flex: 1;
        min-height: 170px;
        display: flex;
        flex-direction: column;
    }
    body.overview-page .card-header {
        padding: 9px 17px 4px;
        flex: none;
    }
    body.overview-page .system-stage {
        flex: 1;
        min-height: 0;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    body.overview-page .system-frame {
        flex: none;
        max-height: none;
        width: 0;
        height: 0;
    }
    body.overview-page .system-legend {
        padding: 6px 0;
        font-size: 10px;
        flex: none;
        margin: 0 17px;
    }
    body.overview-page .status-grid {
        flex: none;
        margin-top: 9px;
        gap: 10px;
    }
    body.overview-page .status-card {
        padding: 8px 13px;
    }
    body.overview-page #footer {
        flex: none;
        padding: 8px 0;
        font-size: 9px;
    }
}
/* HEVI-ERKLÄRUNG
 * WETTERWERTE: Tagesminimum und -maximum kompakt unter der aktuellen Temperatur darstellen, ohne
 * die Hauptzahl zu verdrängen.
 */
.outdoor-extremes {
    display: flex;
    align-items: center;
    gap: clamp(8px, 1.1vw, 18px);
    font-variant-numeric: tabular-nums;
    letter-spacing: 0;
    flex-wrap: wrap;
}
.outdoor-extremes > span {
    white-space: nowrap;
}
.outdoor-extremes strong {
    font-weight: 550;
    color: var(--ink);
}
