/* h2sim · Leitwarte (ISA-101): grey is normal */

@font-face {
    font-family: "Heebo";
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url("fonts/heebo-latin-var.woff2") format("woff2");
}

:root {
    --hmi-ground: #d7d9d6;
    --hmi-panel: #eef0ee;
    --hmi-field: #f7f8f6;
    --hmi-ink: #2b2f31;
    --hmi-ink-2: #545c61;
    --hmi-rule: #b9bebc;
    --hmi-rule-soft: #cfd3d1;
    --hmi-blue: #3d6e9e;
    --hmi-blue-ink: #2f5a84;
    --hmi-amber: #e0a100;
    --hmi-amber-ink: #7d5a00;
    --hmi-red: #c62828;
    --hmi-font: "Heebo", "Segoe UI", Arial, sans-serif;
    --hmi-gap: 12px;

    --bs-body-font-family: var(--hmi-font);
    --bs-body-color: var(--hmi-ink);
    --bs-body-bg: var(--hmi-ground);
    --bs-primary: var(--hmi-blue);
    --bs-primary-rgb: 61, 110, 158;
    --bs-border-color: var(--hmi-rule);
    --bs-border-radius: 2px;
    --bs-border-radius-sm: 2px;
    --bs-link-color: var(--hmi-blue-ink);
    --bs-link-color-rgb: 47, 90, 132;
}

html,
body {
    background: var(--hmi-ground);
    color: var(--hmi-ink);
    font-family: var(--hmi-font);
    font-variant-numeric: tabular-nums;
    overflow-x: hidden;
}

::selection {
    background: #bcd0e3;
    color: var(--hmi-ink);
}

* {
    scrollbar-width: thin;
    scrollbar-color: #a9afad transparent;
}

:focus-visible {
    outline: 2px solid var(--hmi-blue);
    outline-offset: 1px;
}

/* ---------- Frame ---------- */
.hmi-app {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.hmi-titlebar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 10px 20px 8px;
    border-bottom: 1px solid var(--hmi-rule);
}

.hmi-title {
    margin: 0;
    font-size: 30px; /* cap ≈ 21px */
    font-weight: 700;
    letter-spacing: 0.01em;
    text-transform: uppercase;
    color: #304656;
    white-space: nowrap;
}

.hmi-runinfo {
    margin-left: auto;
    font-size: 15px;
    font-weight: 400;
    color: var(--hmi-ink-2);
    white-space: nowrap;
}

.hmi-exports {
    display: flex;
    gap: 6px;
    white-space: nowrap;
}

.hmi-conv:empty {
    display: none;
}

.hmi-conv .alert {
    margin: 0;
    padding: 2px 28px 2px 8px;
    font-size: 12px;
    border-radius: 2px;
    border: 1px solid var(--hmi-rule);
    background: var(--hmi-panel);
    color: var(--hmi-ink-2);
}

.hmi-conv .alert-warning {
    border-color: var(--hmi-amber);
    color: var(--hmi-amber-ink);
}

.hmi-conv .btn-close {
    padding: 4px;
    font-size: 9px;
}

/* ---------- Status strip ---------- */
.hmi-strip-wrap {
    position: relative;
    padding: 12px 20px 0;
}

.hmi-strip {
    display: grid;
    grid-template-columns: 1.15fr 1fr 1fr 1fr;
    background: var(--hmi-panel);
    border: 1px solid var(--hmi-rule);
}

.hmi-readout {
    padding: 14px 20px 12px;
    min-width: 0;
}

.hmi-readout + .hmi-readout {
    border-left: 1px solid var(--hmi-rule);
}

.hmi-readout-label {
    font-size: 15px;
    font-weight: 500;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: var(--hmi-ink);
}

.hmi-readout-value {
    margin-top: 2px;
    font-size: 45px; /* cap ≈ 36px */
    line-height: 1.05;
    font-weight: 700;
    color: var(--hmi-blue-ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.hmi-readout:first-child .hmi-readout-value {
    font-size: 53px; /* cap 37.4px */
}

.hmi-alarm {
    color: var(--hmi-red);
}

.hmi-gauge {
    position: relative;
    height: 8px;
    margin-top: 10px;
    background: var(--hmi-rule-soft);
}

.hmi-gauge-fill {
    position: absolute;
    inset: 0;
    background: var(--hmi-blue);
    transform: scaleX(0);
    transform-origin: left center;
    transition: transform 420ms cubic-bezier(0.16, 1, 0.3, 1);
}

.hmi-gauge-tick {
    position: absolute;
    top: -5px;
    bottom: -5px;
    left: 0;
    width: 2px;
    margin-left: -1px;
    background: var(--hmi-ink);
    opacity: 0;
    transition: left 420ms cubic-bezier(0.16, 1, 0.3, 1);
}

.hmi-gauge-tick[style] {
    opacity: 1;
}

.hmi-gauge-scale {
    min-height: 16px;
    margin-top: 6px;
    font-size: 11.5px;
    color: var(--hmi-ink-2);
}

/* Stale results: hatched, never a warning box */
.hmi-strip-wrap:has(.hmi-stale) .hmi-strip {
    background-image: repeating-linear-gradient(
        -45deg,
        transparent 0 7px,
        rgba(84, 92, 97, 0.14) 7px 8px
    );
}

.hmi-strip-wrap:has(.hmi-stale) .hmi-readout-value {
    color: var(--hmi-ink-2);
}

.hmi-stale.alert {
    position: absolute;
    right: 32px;
    top: 18px;
    margin: 0;
    padding: 3px 30px 3px 10px;
    font-size: 12.5px;
    border-radius: 2px;
    border: 1px solid var(--hmi-rule);
    background: var(--hmi-field);
    color: var(--hmi-ink-2);
}

.hmi-stale .btn-close {
    padding: 6px;
    font-size: 9px;
}

/* ---------- Body ---------- */
.hmi-body {
    flex: 1;
    display: grid;
    grid-template-columns: minmax(280px, 21%) 1fr;
    grid-template-rows: minmax(0, 1fr) auto;
    gap: var(--hmi-gap);
    padding: var(--hmi-gap) 20px 0;
    min-height: 0;
    overflow: hidden;
}

.hmi-sidebar-wrap {
    min-width: 0;
    min-height: 0;
    height: 100%;
}

.hmi-sidebar {
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--hmi-panel);
    border: 1px solid var(--hmi-rule);
    padding: 0 14px;
}

.hmi-preset {
    display: flex;
    align-items: center;
    gap: 10px;
}

.hmi-label {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.hmi-keys {
    flex: 1;
}

.hmi-note {
    margin-top: 4px;
    font-size: 12px;
    color: var(--hmi-ink-2);
}

.hmi-note:empty {
    display: none;
}

/* Parameter groups */
.hmi-groups {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    margin: 6px -14px 0;
    padding: 0 14px;
    --bs-accordion-bg: transparent;
    --bs-accordion-border-color: var(--hmi-rule);
    --bs-accordion-btn-padding-x: 0;
    --bs-accordion-btn-padding-y: 7px;
    --bs-accordion-body-padding-x: 0;
    --bs-accordion-body-padding-y: 2px;
    --bs-accordion-active-bg: transparent;
    --bs-accordion-active-color: var(--hmi-ink);
    --bs-accordion-btn-focus-box-shadow: none;
    --bs-accordion-btn-icon-width: 0.8rem;
}

.hmi-groups .accordion-button {
    font-size: 15px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.01em;
    color: var(--hmi-ink);
}

.hmi-groups .accordion-button:focus-visible {
    outline: 2px solid var(--hmi-blue);
}

.hmi-param {
    margin-bottom: 2px;
}

.hmi-field {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 76px 62px;
    align-items: center;
    column-gap: 8px;
    min-height: 24px;
}

.hmi-field-name {
    margin: 0;
    font-size: 14px;
    color: var(--hmi-ink);
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.hmi-unit {
    font-size: 12.5px;
    color: var(--hmi-ink-2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.hmi-input.form-control {
    height: 22px;
    min-height: 0;
    padding: 0 6px;
    font-size: 14px;
    font-weight: 700;
    text-align: left;
    color: var(--hmi-blue-ink);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 2px;
    font-variant-numeric: tabular-nums;
}

.hmi-input.form-control:hover {
    border-color: var(--hmi-rule-soft);
}

.hmi-input.form-control:focus {
    border-color: var(--hmi-blue);
    background: var(--hmi-field);
    box-shadow: none;
}

.hmi-sidebar .form-control:not(.hmi-input),
.hmi-sidebar .form-check {
    font-size: 13px;
}

.hmi-sidebar .form-label:not(.hmi-field-name) {
    font-size: 13px;
    color: var(--hmi-ink-2);
}

/* Slim slider under a field */
.hmi-slider {
    padding: 0 !important;
    margin: 0 0 2px;
}

.hmi-slider .dash-slider-root {
    height: 10px;
}

.hmi-slider .dash-slider-track {
    height: 2px;
    background: var(--hmi-rule-soft);
    border-radius: 0;
}

.hmi-slider .dash-slider-range {
    background-color: var(--hmi-blue) !important;
}

.hmi-slider .dash-slider-thumb {
    width: 10px;
    height: 12px;
    border: 2px solid var(--hmi-blue);
    background: var(--hmi-field);
    border-radius: 1px;
    box-shadow: none;
}

.hmi-slider .dash-range-slider-input {
    display: none;
}

/* Run block */
.hmi-run-block {
    flex: none;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    margin: 14px -14px 0;
    padding: 10px 14px 14px;
    background: var(--hmi-panel);
    border-top: 1px solid var(--hmi-rule);
}

.hmi-run.btn {
    height: 46px;
    font-size: 17px;
    font-weight: 500;
    border-radius: 2px;
    background: var(--hmi-blue);
    border-color: var(--hmi-blue);
}

.hmi-run.btn:hover {
    background: var(--hmi-blue-ink);
    border-color: var(--hmi-blue-ink);
}

.hmi-run.btn:disabled {
    background: #8ea7bf;
    border-color: #8ea7bf;
}

.hmi-run-block .hmi-progress,
.hmi-run-block .hmi-note {
    grid-column: 1 / -1;
    grid-row: 1;
}

.hmi-run-block .hmi-note {
    grid-row: 2;
    margin-top: 0;
}

.hmi-run-block .hmi-run,
.hmi-run-block .hmi-cancel {
    grid-row: 3;
}

.hmi-progress.progress {
    height: 14px;
    border-radius: 0;
    background: var(--hmi-rule-soft);
    font-size: 10.5px;
}

.hmi-progress .progress-bar {
    background-color: var(--hmi-blue);
}

/* Keys (buttons) */
.btn.hmi-key,
.hmi-cancel.btn {
    border-radius: 2px;
    border: 1px solid var(--hmi-rule);
    background: var(--hmi-field);
    color: var(--hmi-ink);
    font-size: 13px;
}

.btn.hmi-key:hover,
.hmi-cancel.btn:hover {
    background: #e2e5e2;
    border-color: #9aa1a4;
}

.btn.hmi-key:disabled,
.hmi-cancel.btn:disabled {
    color: #7b8388;
    background: transparent;
}

/* ---------- Main + tabs ---------- */
/* Display selector spans the full width */
.hmi-main {
    display: contents;
}

.hmi-main .tab-content {
    grid-column: 2;
    grid-row: 1;
    min-width: 0;
}

.hmi-sidebar-wrap {
    grid-column: 1;
    grid-row: 1;
}

.hmi-tabs.nav-tabs {
    grid-column: 1 / -1;
    grid-row: 2;
}

.hmi-main .tab-content {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

.hmi-main .tab-content > .active,
.hmi-main .tab-content > .active > div {
    height: 100%;
}

.hmi-tabs.nav-tabs {
    border: 1px solid var(--hmi-rule);
    background: var(--hmi-panel);
    flex-wrap: nowrap;
    overflow-x: auto;
}

.hmi-tabs .nav-item {
    flex: 1 1 0;
}

.hmi-tabs .nav-link {
    width: 100%;
    margin: 0;
    padding: 11px 10px;
    font-size: 15px;
    text-align: center;
    color: var(--hmi-ink);
    border: 0;
    border-right: 1px solid var(--hmi-rule);
    border-radius: 0;
    white-space: nowrap;
}

.hmi-tabs .nav-link:hover {
    background: #e2e5e2;
    color: var(--hmi-ink);
}

.hmi-tabs .nav-link.active {
    background: var(--hmi-blue);
    color: #fff;
}

.hmi-panel {
    background: var(--hmi-panel);
    border: 1px solid var(--hmi-rule);
    padding: 12px 16px;
    min-width: 0;
}

.hmi-panel-title {
    margin: 0 0 4px;
    font-size: 17px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.01em;
    color: var(--hmi-ink);
}

.hmi-trends-view {
    display: grid;
    grid-template-rows: minmax(300px, 1fr) auto;
    gap: var(--hmi-gap);
    height: 100%;
}

.hmi-trend {
    display: flex;
    flex-direction: column;
}

.hmi-trend .dash-graph {
    flex: 1;
    min-height: 300px;
}

.hmi-modules {
    padding-bottom: 10px;
}

.hmi-modules .hmi-panel-title {
    font-size: 12px;
    font-weight: 500;
    color: var(--hmi-ink-2);
}

.hmi-module-row {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(96px, 1fr);
    overflow-x: auto;
}

.hmi-module {
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-rows: auto 1fr auto;
    column-gap: 12px;
    padding: 6px 16px 4px;
}

.hmi-module + .hmi-module {
    border-left: 1px solid var(--hmi-rule);
}

.hmi-module-name {
    grid-column: 1 / -1;
    font-size: 15px;
    font-weight: 500;
    text-transform: uppercase;
}

.hmi-vbar {
    grid-row: 2 / 4;
    position: relative;
    width: 18px;
    height: 72px;
    margin-top: 6px;
    background: var(--hmi-field);
    border: 1px solid var(--hmi-rule);
}

.hmi-vbar-fill {
    position: absolute;
    inset: 0;
    background: var(--hmi-blue);
    transform: scaleY(0);
    transform-origin: center bottom;
    transition: transform 420ms cubic-bezier(0.16, 1, 0.3, 1);
}

.hmi-vbar-fill.is-warn {
    background: var(--hmi-amber);
}

.hmi-vbar-fill.is-alarm {
    background: var(--hmi-red);
}

.hmi-vbar-tick {
    position: absolute;
    left: -5px;
    right: -5px;
    height: 2px;
    margin-bottom: -1px;
    background: var(--hmi-ink);
}

.hmi-module-value {
    font-size: 22px;
    font-weight: 700;
    color: var(--hmi-blue-ink);
    align-self: end;
}

.hmi-module-value.is-warn {
    color: var(--hmi-amber-ink);
}

.hmi-module-value.is-alarm {
    color: var(--hmi-red);
}

.hmi-module-sub {
    font-size: 13px;
    color: var(--hmi-ink-2);
}

.hmi-stack {
    display: flex;
    flex-direction: column;
    gap: var(--hmi-gap);
}

.hmi-two {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--hmi-gap);
}

.hmi-minors {
    display: flex;
    background: var(--hmi-panel);
    border: 1px solid var(--hmi-rule);
}

.hmi-minor {
    flex: 1;
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 16px;
}

.hmi-minor + .hmi-minor {
    border-left: 1px solid var(--hmi-rule);
}

.hmi-minor .hmi-readout-label {
    font-size: 12.5px;
}

.hmi-minor-value {
    font-size: 22px;
    font-weight: 700;
    color: var(--hmi-blue-ink);
}

/* Tables (policies, scenarios, history) */
.hmi-main .dash-table-container .dash-spreadsheet-container .dash-spreadsheet-inner th,
.hmi-main .dash-table-container .dash-spreadsheet-container .dash-spreadsheet-inner td {
    font-family: var(--hmi-font) !important;
    font-size: 14px !important;
    font-variant-numeric: tabular-nums;
    color: var(--hmi-ink) !important;
    background-color: var(--hmi-panel) !important;
    border-color: var(--hmi-rule-soft) !important;
    padding: 8px 10px !important;
}

.hmi-main .dash-table-container .dash-spreadsheet-inner th {
    font-weight: 700 !important;
    background-color: #e4e7e4 !important;
}

.hmi-main .card {
    border-radius: 2px;
    border: 1px solid var(--hmi-rule);
    background: var(--hmi-panel);
    box-shadow: none !important;
}

.hmi-main .tab-pane > .p-3,
.hmi-main .tab-pane > div:not([class]) {
    background: var(--hmi-panel);
    border: 1px solid var(--hmi-rule);
}

.modal-content {
    border-radius: 2px;
    background: var(--hmi-panel);
    border: 1px solid var(--hmi-rule);
}

/* ---------- Responsive ---------- */
@media (min-width: 768px) {
    #sidebar-collapse {
        display: block !important;
    }
}

@media (max-width: 1100px) {
    .hmi-strip {
        grid-template-columns: 1fr 1fr;
    }

    .hmi-readout:nth-child(3) {
        border-left: 0;
    }

    .hmi-readout:nth-child(n + 3) {
        border-top: 1px solid var(--hmi-rule);
    }

    .hmi-exports {
        display: none;
    }
}

@media (max-width: 767.98px) {
    .hmi-titlebar {
        flex-wrap: wrap;
        padding: 8px 12px;
        gap: 8px;
    }

    .hmi-title {
        font-size: 20px;
    }

    .hmi-runinfo {
        order: 5;
        width: 100%;
        margin: 0;
        font-size: 12.5px;
        white-space: normal;
    }

    .hmi-strip-wrap {
        padding: 8px 12px 0;
    }

    .hmi-readout {
        padding: 10px 12px;
    }

    .hmi-readout-label {
        font-size: 12px;
    }

    .hmi-readout-value,
    .hmi-readout:first-child .hmi-readout-value {
        font-size: 30px;
    }

    .hmi-app {
        height: auto;
        min-height: 100vh;
    }

    .hmi-body {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
        padding: 8px 12px 12px;
        overflow: visible;
    }

    .hmi-sidebar-wrap,
    .hmi-main .tab-content,
    .hmi-tabs.nav-tabs {
        grid-column: 1;
        grid-row: auto;
    }

    .hmi-run-block {
        position: static;
    }

    .hmi-sidebar {
        height: auto;
        overflow: visible;
    }

    .hmi-groups {
        overflow: visible;
    }

    .hmi-main .tab-content {
        overflow: visible;
    }

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

    .hmi-minors {
        flex-direction: column;
    }

    .hmi-minor + .hmi-minor {
        border-left: 0;
        border-top: 1px solid var(--hmi-rule);
    }

    .hmi-tabs .nav-item {
        flex: 0 0 auto;
    }

    .hmi-tabs .nav-link {
        padding: 10px 14px;
        font-size: 14px;
    }

    .hmi-stale.alert {
        position: static;
        margin-top: 6px;
    }

    .hmi-trends-view {
        grid-template-rows: auto auto;
    }

    .hmi-trend .dash-graph {
        min-height: 420px;
    }

    .hmi-module-row {
        grid-auto-flow: row;
        grid-template-columns: 1fr 1fr;
        overflow: visible;
    }

    .hmi-module {
        padding: 8px 10px;
        border-top: 1px solid var(--hmi-rule);
    }

    .hmi-module + .hmi-module {
        border-left: 0;
    }

    .hmi-module:nth-child(even) {
        border-left: 1px solid var(--hmi-rule);
    }

    .hmi-module-value {
        font-size: 18px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .hmi-gauge-fill,
    .hmi-gauge-tick,
    .hmi-vbar-fill {
        transition: none;
    }
}

.hmi-modules .hmi-panel-title {
    text-transform: none;
    letter-spacing: 0;
}

.hmi-vbar-label {
    position: absolute;
    left: 26px;
    font-size: 11px;
    line-height: 1;
    color: var(--hmi-ink-2);
    transform: translateY(50%);
    white-space: nowrap;
}

.hmi-vbar-label.is-top {
    top: 0;
    transform: none;
}

.hmi-vbar-label.is-bottom {
    bottom: 0;
    transform: none;
}

.hmi-module {
    grid-template-columns: 48px 1fr;
}

/* Sliders stay mounted for sync, hidden */
.hmi-slider {
    display: none !important;
}

.hmi-footer {
    height: 39px;
    padding: 3px 20px 0;
    text-align: right;
    font-size: 12px;
    color: var(--hmi-ink-2);
}

/* Scenario cards: color law, no traffic lights */
.hmi-main .badge {
    background-color: var(--hmi-ink-2) !important;
    border-radius: 2px;
    font-weight: 500;
}

.hmi-main [class*="btn-outline-"] {
    border-radius: 2px;
    border-color: var(--hmi-rule);
    background: var(--hmi-field);
    color: var(--hmi-ink);
}

.hmi-main [class*="btn-outline-"]:hover {
    background: #e2e5e2;
    color: var(--hmi-ink);
    border-color: #9aa1a4;
}

.hmi-main .card-header {
    background: transparent;
    border-bottom: 1px solid var(--hmi-rule-soft);
}

.btn-primary {
    --bs-btn-bg: var(--hmi-blue);
    --bs-btn-border-color: var(--hmi-blue);
    --bs-btn-hover-bg: var(--hmi-blue-ink);
    --bs-btn-hover-border-color: var(--hmi-blue-ink);
    --bs-btn-active-bg: var(--hmi-blue-ink);
    --bs-btn-disabled-bg: #8ea7bf;
    --bs-btn-disabled-border-color: #8ea7bf;
    border-radius: 2px;
}

.modal .form-control {
    border-radius: 2px;
    background: var(--hmi-field);
}

.hmi-pol-controls {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
    align-items: center;
    gap: 6px 24px;
}

.hmi-pol-actions {
    display: flex;
    gap: 8px;
}

.hmi-pol-actions .hmi-run.btn {
    height: 36px;
    font-size: 15px;
    padding: 0 18px;
}

@media (max-width: 1100px) {
    .hmi-pol-controls {
        grid-template-columns: 1fr 1fr;
    }
}
