:root {
    color-scheme: dark;

    --bg: #0b0f14;
    --panel: #131920;
    --panel2: #19212a;
    --line: #27313c;

    --text: #edf2f6;
    --muted: #8694a2;

    --accent: #ffb454;
    --blue: #65b5f6;
    --green: #68d391;
    --red: #ff7777;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;

    background:
        radial-gradient(
            circle at 70% -20%,
            #192635,
            transparent 46%
        ),
        var(--bg);

    color: var(--text);

    font-family:
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
}

header {
    max-width: 1500px;
    margin: auto;

    padding:
        42px
        32px
        28px;

    display: flex;
    justify-content: space-between;
    align-items: flex-end;
}

h1 {
    margin: 4px 0 3px;
    font-size: 34px;
    letter-spacing: -.04em;
}

h2 {
    margin: 4px 0 0;
    font-size: 20px;
}

.eyebrow {
    color: var(--accent);

    font-size: 11px;
    font-weight: 700;
    letter-spacing: .18em;
}

.subtitle,
.muted {
    color: var(--muted);
}

.header-right {
    text-align: right;
}

#clock {
    font-size: 17px;
    margin-bottom: 8px;
}

main {
    max-width: 1500px;
    margin: auto;

    padding:
        0
        32px
        40px;
}

.hero-grid {
    display: grid;

    grid-template-columns:
        repeat(
            6,
            minmax(150px, 1fr)
        );

    gap: 14px;
    margin-bottom: 14px;
}

.metric,
.panel {
    background:
        linear-gradient(
            145deg,
            rgba(255,255,255,.025),
            transparent 60%
        ),
        var(--panel);

    border:
        1px
        solid
        var(--line);

    border-radius: 16px;
}

.metric {
    padding: 20px;
    min-height: 125px;
}

.metric span {
    color: var(--muted);
    font-size: 13px;
}

.metric strong {
    display: block;

    font-size: 31px;

    margin:
        10px
        0
        2px;

    letter-spacing: -.04em;
}

.metric small {
    color: var(--muted);
}

.metric.accent {
    border-color: #65513a;
}

.panel {
    padding: 22px;
    margin-bottom: 14px;
}

.panel-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;

    margin-bottom: 20px;
}

.two-column {
    display: grid;

    grid-template-columns:
        1.1fr
        .9fr;

    gap: 14px;
}

.chart {
    height: 290px;
}

.chart.small {
    height: 260px;
}

svg {
    width: 100%;
    height: 100%;
    overflow: visible;
}

.grid-line {
    stroke: #27313b;
    stroke-width: 1;
}

.axis-text {
    fill: #6f7e8c;
    font-size: 10px;
}

.chart-line {
    fill: none;
    stroke-width: 2.2;

    vector-effect:
        non-scaling-stroke;
}

.chart-supply {
    stroke: var(--accent);
}

.chart-outside {
    stroke: var(--blue);
}

.chart-forecast {
    stroke: var(--green);
}

.legend {
    display: flex;
    gap: 18px;

    color: var(--muted);
    font-size: 12px;
}

.dot {
    width: 8px;
    height: 8px;

    display: inline-block;

    border-radius: 100%;

    margin-right: 6px;
}

.dot.supply {
    background: var(--accent);
}

.dot.outside {
    background: var(--blue);
}

.dot.forecast {
    background: var(--green);
}

.rooms {
    display: grid;
    gap: 8px;
}

.room {
    background: var(--panel2);

    border:
        1px
        solid
        var(--line);

    border-radius: 11px;

    padding:
        12px
        14px;

    display: grid;

    grid-template-columns:
        1fr
        auto
        auto
        auto;

    gap: 18px;

    align-items: center;
}

.room-name {
    font-weight: 600;
}

.room-value {
    text-align: right;
}

.room-value small {
    color: var(--muted);

    display: block;

    font-size: 10px;
}

.collector-grid {
    display: grid;

    grid-template-columns:
        repeat(
            auto-fit,
            minmax(220px,1fr)
        );

    gap: 10px;
}

.collector {
    background: var(--panel2);

    border:
        1px
        solid
        var(--line);

    border-radius: 11px;

    padding: 14px;
}

.collector strong {
    display: block;
    margin-bottom: 7px;
}

.badge {
    display: inline-block;

    padding:
        5px
        9px;

    border-radius: 30px;

    font-size: 11px;

    border:
        1px
        solid
        var(--line);
}

.badge.good {
    color: var(--green);
}

.badge.bad {
    color: var(--red);
}

footer {
    color: #596573;

    text-align: center;

    padding:
        20px
        0
        38px;

    font-size: 12px;
}

@media (max-width: 1100px) {

    .hero-grid {
        grid-template-columns:
            repeat(3, 1fr);
    }

    .two-column {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 650px) {

    header,
    main {
        padding-left: 15px;
        padding-right: 15px;
    }

    header {
        align-items: flex-start;
    }

    .hero-grid {
        grid-template-columns:
            repeat(2, 1fr);
    }

    .metric strong {
        font-size: 25px;
    }

    .room {
        grid-template-columns:
            1fr auto;
    }

    .header-right {
        display: none;
    }
}


/* H40 Heizungs-/Raumstatus */

.hero-grid {
    grid-template-columns:
        repeat(
            auto-fit,
            minmax(150px, 1fr)
        );
}


.room {
    grid-template-columns:
        minmax(180px, 1.4fr)
        auto
        auto
        auto
        minmax(200px, 1fr);
}


.room-value strong {
    font-size: 17px;
}


.temp-cold {
    color: #65b5f6;
}

.temp-ok {
    color: #68d391;
}

.temp-hot {
    color: #c9762b;
}


.heat-state {
    margin-top: 5px;

    color: var(--muted);

    font-size: 11px;

    display: flex;
    align-items: center;
    gap: 6px;
}


.heat-dot {
    width: 9px;
    height: 9px;

    display: inline-block;

    border-radius: 50%;
}


.heat-dot.active {
    background: #ffb454;

    box-shadow:
        0 0 8px
        rgba(255,180,84,.55);
}


.heat-dot.inactive {
    background: #46515d;
}


.actuator-list {
    display: grid;
    gap: 5px;

    min-width: 190px;
}


.actuator {
    display: grid;

    grid-template-columns:
        1fr auto;

    column-gap: 8px;

    font-size: 11px;
}


.actuator span {
    color: var(--muted);

    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}


.actuator strong {
    text-align: right;
}


.actuator small {
    grid-column: 1 / -1;

    color: #667483;

    text-align: right;

    font-size: 9px;
}


.state-on {
    color: #ffb454;
}

.state-off {
    color: #687583;
}


@media (max-width: 750px) {

    .room {
        grid-template-columns:
            repeat(3, 1fr);
    }

    .room-main,
    .actuator-list {
        grid-column: 1 / -1;
    }

    .room-value {
        text-align: left;
    }
}


/* H40_HEATING_ANALYSIS_V3_CSS */

.chart {
    height: 340px;
}


.chart-eg-supply {
    stroke: #68d391;
}

.chart-ww-return {
    stroke: #e879b9;
}

.chart-boiler-setpoint {
    stroke: #f3d36a;
    stroke-dasharray: 7 4;
}

.chart-vpt-supply {
    stroke: #63e6e2;
}

.chart-vpt-return {
    stroke: #b794f4;
}

.chart-spread {
    stroke: #ffb454;
}

.chart-flow {
    stroke: #65b5f6;
}

.chart-burner {
    stroke: #ff7777;
}


.dot.eg-supply {
    background: #68d391;
}

.dot.ww-return {
    background: #e879b9;
}

.dot.boiler-setpoint {
    background: #f3d36a;
}

.dot.vpt-supply {
    background: #63e6e2;
}

.dot.vpt-return {
    background: #b794f4;
}


.legend-wrap {
    flex-wrap: wrap;
    row-gap: 8px;
}


.legend-button {
    appearance: none;

    border: 0;
    background: transparent;
    color: var(--muted);

    padding: 3px 5px;

    cursor: pointer;

    font: inherit;
    font-size: 12px;

    border-radius: 5px;
}


.legend-button:hover {
    background:
        rgba(
            255,
            255,
            255,
            .05
        );
}


.legend-button.disabled {
    opacity: .3;
}


.heating-meta {
    display: flex;
    flex-wrap: wrap;

    gap: 7px;

    justify-content: flex-end;
    align-items: center;
}


.status-chip {
    display: inline-block;

    padding:
        5px 9px;

    border:
        1px solid
        var(--line);

    border-radius: 20px;

    font-size: 11px;

    background:
        rgba(
            255,
            255,
            255,
            .025
        );
}


.analysis-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;

    margin-bottom: 16px;
}


.analysis-stats {
    display: grid;

    grid-template-columns:
        repeat(
            4,
            minmax(130px, 1fr)
        );

    gap: 8px;

    margin-bottom: 20px;
}


.analysis-stats > div {
    background: var(--panel2);

    border:
        1px solid
        var(--line);

    border-radius: 10px;

    padding: 12px;
}


.analysis-stats span {
    display: block;

    color: var(--muted);

    font-size: 10px;
}


.analysis-stats strong {
    display: block;

    margin-top: 4px;

    font-size: 19px;
}


.hydraulic-row {
    display: grid;

    grid-template-columns:
        125px
        minmax(0, 1fr);

    gap: 12px;

    align-items: center;

    padding:
        7px
        0;

    border-top:
        1px solid
        var(--line);
}


.hydraulic-label strong {
    display: block;

    font-size: 12px;
}


.hydraulic-label small {
    display: block;

    margin-top: 3px;

    color: var(--muted);

    font-size: 10px;
}


.hydraulic-chart {
    height: 105px;
}


.mode-strip {
    height: 34px;
}


.mode-heat {
    fill: #355f48;
}


.mode-ww {
    fill: #825929;
}


.mode-other {
    fill: #3e4650;
}


.analysis-note {
    color: var(--muted);

    font-size: 11px;

    line-height: 1.5;

    margin:
        15px
        0
        0;
}


@media (max-width: 700px) {

    .analysis-stats {
        grid-template-columns:
            repeat(2, 1fr);
    }

    .hydraulic-row {
        grid-template-columns: 1fr;
    }

    .heating-meta {
        justify-content:
            flex-start;
    }
}


/* H40_TOP_HEATING_STATUS_CSS */

.plant-status-top {
    display: grid;

    grid-template-columns:
        repeat(
            5,
            minmax(150px, 1fr)
        );

    gap: 10px;

    margin:
        0 0 18px;
}


.plant-kpi {
    min-width: 0;

    padding:
        14px 15px;

    border:
        1px solid
        var(--line, #30353d);

    border-radius:
        12px;

    background:
        var(
            --panel,
            #171a1f
        );
}


.plant-kpi-label {
    display: block;

    margin-bottom: 7px;

    color:
        var(
            --muted,
            #8f969f
        );

    font-size: 11px;

    text-transform: uppercase;

    letter-spacing: .04em;
}


.plant-kpi-value {
    display: block;

    overflow: hidden;

    font-size: 19px;

    line-height: 1.15;

    text-overflow: ellipsis;

    white-space: nowrap;
}


.plant-kpi small {
    display: block;

    overflow: hidden;

    margin-top: 7px;

    color:
        var(
            --muted,
            #8f969f
        );

    font-size: 10px;

    text-overflow: ellipsis;

    white-space: nowrap;
}


.plant-kpi-value.state-on,
.plant-kpi-value.state-heat {
    color: #df9a48;
}


.plant-kpi-value.state-ww {
    color: #6da9de;
}


.plant-kpi-value.state-off {
    opacity: .65;
}


@media (
    max-width: 1000px
) {

    .plant-status-top {
        grid-template-columns:
            repeat(
                3,
                minmax(150px, 1fr)
            );
    }
}


@media (
    max-width: 650px
) {

    .plant-status-top {
        grid-template-columns:
            repeat(
                2,
                minmax(130px, 1fr)
            );
    }
}


/* H40_DASHBOARD_CLEANUP_CSS */


/* Aktuell beheizter Raum */

.room-heating-active {
    color: #df9a48 !important;
}


/* Betriebsarten-Band */

.mode-heat {
    fill: #4f8f63;
}

.mode-ww {
    fill: #d88a3d;
}

.mode-other {
    fill: #555d68;
}


.mode-legend {
    display: flex;
    flex-wrap: wrap;

    gap: 14px;

    margin-top: 6px;

    color:
        var(
            --muted,
            #8f969f
        );

    font-size: 10px;
}


.mode-legend span {
    display: inline-flex;

    align-items: center;

    gap: 5px;
}


.mode-key {
    display: inline-block;

    width: 10px;
    height: 10px;

    border-radius: 3px;
}


.mode-key-heat {
    background: #4f8f63;
}

.mode-key-ww {
    background: #d88a3d;
}

.mode-key-other {
    background: #555d68;
}


/* Obere Anlagenkarten etwas kompakter */

.plant-status-top {
    align-items: stretch;
}

.plant-kpi {
    padding: 12px 14px;
}

.plant-kpi-value {
    font-size: 18px;
}

.plant-kpi small {
    line-height: 1.35;
}


/* Wetter */

.weather-forecast-card {
    margin:
        0 0 18px;

    padding: 16px;

    border:
        1px solid
        var(--line);

    border-radius: 12px;

    background:
        var(--panel);
}


.weather-head {
    display: flex;

    align-items: flex-start;
    justify-content: space-between;

    gap: 20px;

    margin-bottom: 14px;
}


.weather-head h2 {
    margin:
        2px 0 0;

    font-size: 17px;
}


.weather-head small {
    color: var(--muted);
}


.weather-hours {
    display: grid;

    grid-template-columns:
        repeat(
            4,
            minmax(120px, 1fr)
        );

    gap: 9px;
}


.weather-hour {
    padding: 12px;

    border:
        1px solid
        var(--line);

    border-radius: 10px;

    background:
        var(--panel2);
}


.weather-hour-time {
    color: var(--muted);

    font-size: 11px;

    text-transform: uppercase;
}


.weather-icon {
    margin:
        6px 0 2px;

    font-size: 32px;
}


.weather-temp {
    font-size: 22px;

    font-weight: 700;
}


.weather-desc {
    min-height: 28px;

    margin:
        2px 0 8px;

    color: var(--muted);

    font-size: 11px;
}


.weather-detail {
    display: flex;

    gap: 7px;

    margin-top: 4px;

    font-size: 11px;
}


@media (
    max-width: 800px
) {

    .weather-hours {
        grid-template-columns:
            repeat(
                2,
                minmax(120px, 1fr)
            );
    }
}


/* H40_ROOM_TRENDS_CSS */


/* Die redundante Statuszeile verschwindet endgültig. */

.h40-remove-room-status {
    display: none !important;
}


/* Tatsächlich aktuell angesteuerter Heizaktor */

.h40-room-heating {
    color: #df9a48 !important;
}


/* Temperaturtendenz */

.h40-room-trend {
    display: inline-block;

    margin-left: 7px;

    font-size: .85em;

    font-weight: 700;

    vertical-align: middle;
}


.h40-room-trend.trend-up {
    color: #cf7352;
}


.h40-room-trend.trend-down {
    color: #71a9d3;
}


.h40-room-trend.trend-stable {
    color: var(--muted);
}


.h40-room-trend.window-suspected {
    font-size: .9em;
}


/* Hydraulikband */

.mode-text-heat {
    color: #4f8f63;
    font-weight: 700;
}


.mode-text-ww {
    color: #d88a3d;
    font-weight: 700;
}


/* Alte zusätzliche Legende vorsichtshalber verstecken */

.mode-legend {
    display: none !important;
}



/* H40_WEATHER_OBSERVED_CSS */

.weather-observed {
    display: flex;

    align-items: center;
    justify-content: space-between;

    gap: 20px;

    margin-bottom: 12px;

    padding:
        10px 13px;

    border:
        1px solid
        var(--line);

    border-radius: 9px;

    background:
        rgba(
            255,
            255,
            255,
            .025
        );
}


.weather-observed-label {
    color:
        var(--muted);

    font-size: 10px;

    letter-spacing: .05em;
}


.weather-observed-values {
    display: flex;

    align-items: baseline;

    gap: 18px;
}


.weather-observed-values strong {
    font-size: 20px;
}


.weather-observed-values span {
    color:
        var(--muted);

    font-size: 14px;
}


#weather-run {
    max-width: 520px;

    text-align: right;

    line-height: 1.5;
}


@media (max-width: 650px) {

    .weather-observed {
        align-items: flex-start;
        flex-direction: column;

        gap: 5px;
    }

    #weather-run {
        text-align: left;
    }
}



/* H40 Wettervergleich WEM / HmIP */

.weather-observed {
    display: flex !important;

    align-items: stretch !important;
    justify-content: flex-start !important;

    gap: 10px !important;

    margin-bottom: 12px;
}


.weather-reference {
    display: flex;
    flex-direction: column;

    align-items: flex-start;
    justify-content: center;

    min-width: 150px;

    padding:
        9px 12px;

    border-right:
        1px solid
        var(--line);
}


.weather-reference:last-child {
    border-right: 0;
}


.weather-reference strong {
    margin-top: 3px;

    font-size: 20px;
}


.weather-reference
.weather-observed-values {
    display: flex;

    align-items: baseline;

    justify-content: flex-start;

    gap: 12px;
}


.weather-reference
.weather-observed-values span {
    font-size: 13px;
}


@media (max-width: 650px) {

    .weather-observed {
        flex-direction: row !important;
        align-items: stretch !important;
    }

    .weather-reference {
        min-width: 0;
        flex: 1;
    }
}



/* H40_LIGHT_WEB_CSS */


.h40-light-card {
    margin: 0 0 18px;
    padding: 16px;

    border:
        1px solid var(--line);

    border-radius: 12px;

    background:
        var(--panel);
}


.h40-light-head {
    display: flex;

    justify-content: space-between;
    align-items: flex-start;

    gap: 20px;

    margin-bottom: 13px;
}


.h40-light-head h2 {
    margin: 2px 0 0;
    font-size: 17px;
}


.h40-light-meta {
    display: flex;
    flex-direction: column;

    align-items: flex-end;

    gap: 2px;
}


.h40-light-meta small {
    color:
        var(--muted);
}


.h40-light-devices {
    display: grid;

    grid-template-columns:
        repeat(
            2,
            minmax(190px, 1fr)
        );

    gap: 10px;
}


.h40-light-device {
    padding: 13px;

    border:
        1px solid var(--line);

    border-radius: 10px;

    background:
        var(--panel2);
}


.h40-light-title {
    display: flex;

    align-items: center;

    gap: 9px;

    margin-bottom: 8px;
}


.h40-light-color {
    display: inline-block;

    width: 18px;
    height: 18px;

    border-radius: 50%;

    border:
        1px solid
        rgba(255,255,255,.25);

    background: #222;

    box-shadow:
        0 0 8px
        rgba(255,255,255,.10);

    transition:
        background .4s ease;
}


.h40-light-row {
    display: flex;

    justify-content: space-between;

    padding: 4px 0;

    font-size: 12px;
}


.h40-light-row span {
    color:
        var(--muted);
}


@media (max-width: 650px) {

    .h40-light-devices {
        grid-template-columns:
            1fr;
    }

    .h40-light-meta {
        align-items: flex-start;
    }
}


/* H40_CONTEXT_VENTILATION_UI_V1 */
.ventilation-status {
    margin: 0.45rem 0.65rem 0;
    padding: 0.4rem 0.55rem;
    border-left: 3px solid currentColor;
    font-size: 0.82rem;
    line-height: 1.25;
}

.ventilation-status strong {
    display: block;
}

.ventilation-status small {
    display: block;
    margin-top: 0.15rem;
    opacity: 0.72;
}

.ventilation-ok {
    opacity: 0.62;
}

.ventilation-recommended {
    font-weight: 600;
}

.ventilation-warning {
    font-weight: 700;
}



.metric-action {
    margin-top: 0.55rem;
    padding: 0.35rem 0.7rem;
    cursor: pointer;
}

.metric-action:disabled {
    cursor: wait;
    opacity: 0.6;
}

#ww-push-status {
    min-height: 1em;
}
