* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    background: #f4f6f8;
    color: #17202a;
}

.page {
    width: min(1200px, calc(100% - 32px));
    margin: 32px auto;
}

.header {
    margin-bottom: 24px;
}

    .header h1 {
        margin: 0 0 8px;
        font-size: 32px;
    }

    .header p {
        margin: 0;
        color: #5d6d7e;
    }

.brand-title {
    display: inline-flex;
    align-items: baseline;
    gap: 0;
    letter-spacing: 0.02em;
}

.brand-bess {
    color: #ffffff;
}

.brand-quant {
    color: #ffb02e;
}

.card {
    background: #ffffff;
    border: 1px solid #d7dde3;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

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

    .card h3 {
        margin: 0 0 8px;
        font-size: 17px;
    }

.grid,
.generator-grid,
.historical-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
}

.generator-panel,
.historical-panel {
    border: 1px solid #d7dde3;
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 16px;
    background: #fbfcfd;
}

.function-actions {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 16px;
}

.export-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 16px;
}

.card-footer-actions {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 16px;
    margin-top: 16px;
    flex-wrap: wrap;
}

.optimization-main-actions {
    align-items: center;
}

.optimization-run-button {
    min-height: 44px;
    padding: 11px 20px;
    border: 1px solid #1b5e20;
    border-radius: 10px;
    background:
        linear-gradient(135deg, #1f7a32, #12351c);
    color: #ffffff;
    box-shadow:
        0 8px 18px rgba(27, 94, 32, 0.18),
        inset 0 0 0 1px rgba(255, 255, 255, 0.14);
}

.optimization-run-button:hover {
    color: #ffffff;
    transform: translateY(-1px);
    box-shadow:
        0 10px 22px rgba(27, 94, 32, 0.24),
        inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}

.optimization-run-button:focus-visible {
    outline: 3px solid #ffff00;
    outline-offset: 3px;
}

.optimization-run-button:disabled {
    transform: none;
}

.optimization-run-title {
    font-size: 15px;
    font-weight: 800;
    line-height: 1.2;
}

.optimization-run-status {
    min-height: 24px;
    color: #566573;
    font-weight: 600;
}

label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 14px;
    color: #34495e;
}

input,
textarea,
button,
select {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 14px;
}

input,
textarea,
select {
    border: 1px solid #ccd3da;
    border-radius: 8px;
    padding: 10px;
    background: #ffffff;
    color: #17202a;
}

textarea {
    width: 100%;
    min-height: 180px;
    resize: vertical;
    font-family: Consolas, "Courier New", monospace;
    line-height: 1.45;
}

button {
    border: none;
    border-radius: 8px;
    padding: 10px 16px;
    background: transparent;
    color: #ffff00;
    cursor: pointer;
    font-weight: 600;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 14px;
    line-height: 20px;
    display: inline-flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    text-decoration: none;
    white-space: nowrap;
    appearance: none;
    -webkit-appearance: none;
}

    button:hover {
        color: #ffffff;
    }

    button:disabled {
        opacity: 0.6;
        cursor: not-allowed;
    }

.hidden-file-input {
    display: none !important;
}

.button-row {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}

.section-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}

.hint {
    margin-top: -4px;
    color: #6b7785;
    font-size: 14px;
}

.price-source-row {
    margin: -6px 0 14px;
    color: #6b7785;
    font-size: 14px;
}

.price-source-row strong {
    color: #34495e;
}

.price-source-selector {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin: 0 0 14px;
}

.price-source-option {
    position: relative;
    display: block;
    cursor: pointer;
}

.price-source-option input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.price-source-option span {
    display: flex;
    min-height: 64px;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    padding: 12px 14px;
    border: 1px solid #d7dde3;
    border-radius: 13px;
    background: #f7faf8;
    color: #17202a;
    transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease, box-shadow 0.12s ease;
}

.price-source-option strong {
    font-size: 14px;
    line-height: 1.2;
}

.price-source-option small {
    color: #6b7785;
    font-size: 12px;
    line-height: 1.25;
}

.price-source-option:hover span {
    transform: translateY(-1px);
    border-color: #63c07a;
    box-shadow: 0 8px 18px rgba(27, 94, 32, 0.10);
}

.price-source-option input:focus-visible + span {
    outline: 2px solid #1b5e20;
    outline-offset: 2px;
}

.price-source-option input:checked + span {
    border-color: #1b5e20;
    background:
        linear-gradient(135deg, rgba(155, 231, 172, 0.40), rgba(99, 192, 122, 0.12)),
        #eef9f0;
    box-shadow:
        0 10px 22px rgba(27, 94, 32, 0.14),
        inset 0 0 0 1px rgba(27, 94, 32, 0.18);
}

.price-source-panel-hidden {
    display: none !important;
}

.date-picker-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
}

.date-picker-row input {
    min-width: 0;
}

.calendar-button {
    min-height: 40px;
    padding: 10px 12px;
    border: 1px solid #ccd3da;
    border-radius: 8px;
    background: #ffffff;
    color: #34495e;
}

.calendar-button:hover {
    color: #17202a;
    border-color: #8996a3;
}

.historical-calendar {
    margin-top: 14px;
    max-width: 360px;
    border: 1px solid #ccd3da;
    border-radius: 12px;
    padding: 12px;
    background: #ffffff;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.12);
}

.historical-calendar.hidden {
    display: none;
}

.calendar-header {
    display: grid;
    grid-template-columns: 40px 1fr 40px;
    gap: 8px;
    align-items: center;
    margin-bottom: 10px;
}

.calendar-header strong {
    text-align: center;
    font-size: 15px;
}

.calendar-header button,
.calendar-day {
    border: 1px solid #ccd3da;
    background: #fbfcfd;
    color: #17202a;
    border-radius: 8px;
    padding: 8px;
    min-height: 36px;
}

.calendar-header button:hover,
.calendar-day:hover {
    color: #17202a;
    background: #eef2f7;
    border-color: #8996a3;
}

.calendar-weekdays,
.calendar-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
}

.calendar-weekdays {
    margin-bottom: 6px;
    color: #6b7785;
    font-size: 12px;
    text-align: center;
}

.calendar-day-spacer {
    min-height: 36px;
}

.calendar-day.today {
    border-color: #ffff00;
}

.calendar-day.selected {
    background: #ffff00;
    border-color: #ffff00;
    color: #000000;
    font-weight: 700;
}

.actions {
    display: flex;
    align-items: center;
    gap: 16px;
    margin: 0;
    flex-wrap: wrap;
}

#status {
    color: #566573;
}

    #status.success {
        color: #1b5e20;
    }

    #status.error,
    .error {
        color: #c0392b;
    }

.summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

    .summary div {
        border: 1px solid #d7dde3;
        border-radius: 10px;
        padding: 14px;
        background: #fbfcfd;
    }

.summary-label {
    display: block;
    font-size: 13px;
    color: #6b7785;
    margin-bottom: 6px;
}

.summary strong {
    font-size: 22px;
}

.charts-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 28px;
    margin-bottom: 36px;
}

.chart-card {
    border: 1px solid #d7dde3;
    border-radius: 10px;
    padding: 16px;
    background: #fbfcfd;
}

    .chart-card h3 {
        margin: 0 0 8px;
        font-size: 17px;
    }

.chart-note {
    margin: -2px 0 12px;
    color: #6b7785;
    font-size: 13px;
}

.chart-wrap {
    position: relative;
    height: 320px;
}

.table-wrap {
    overflow-x: auto;
    border: 1px solid #d7dde3;
    border-radius: 10px;
    margin-top: 8px;
}

table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    min-width: 760px;
}

th,
td {
    width: 16.666%;
    padding: 10px 12px;
    border-bottom: 1px solid #e3e8ee;
    font-size: 14px;
    vertical-align: middle;
    text-align: center;
}

th {
    background: #f8fafc;
    color: #34495e;
    font-weight: 700;
}

tr:last-child td {
    border-bottom: none;
}

.empty {
    text-align: center;
    color: #7b8794;
    padding: 24px;
}

.action {
    display: inline-flex;
    min-width: 86px;
    justify-content: center;
    align-items: center;
    text-align: center;
    border-radius: 999px;
    padding: 3px 10px;
    font-weight: 700;
    font-size: 12px;
}

.action-C {
    background: #e8f5e9;
    color: #1b5e20;
}

.action-D {
    background: #fdecea;
    color: #922b21;
}

.action-N {
    background: #eef2f7;
    color: #566573;
}

@media (prefers-color-scheme: dark) {
    body {
        background: #050505;
        color: #f8fafc;
    }

    .header p,
    .hint,
    .chart-note,
    .price-source-row {
        color: #b8c0cc;
    }

    .card,
    .chart-card,
    .summary div,
    .generator-panel,
.historical-panel {
        background: #000000;
        border-color: #d7dde3;
    }

    .price-source-row strong {
        color: #f8fafc;
    }

    .price-source-option span {
        background: #050505;
        border-color: #d7dde3;
        color: #f8fafc;
    }

    .price-source-option small {
        color: #b8c0cc;
    }

    .price-source-option:hover span {
        border-color: #9be7ac;
        box-shadow: 0 8px 18px rgba(155, 231, 172, 0.10);
    }

    .price-source-option input:focus-visible + span {
        outline-color: #ffff00;
    }

    .price-source-option input:checked + span {
        border-color: #9be7ac;
        background:
            linear-gradient(135deg, rgba(155, 231, 172, 0.24), rgba(18, 53, 28, 0.72)),
            #12351c;
        box-shadow:
            0 10px 22px rgba(155, 231, 172, 0.10),
            inset 0 0 0 1px rgba(155, 231, 172, 0.22);
    }

    .optimization-run-button {
        border-color: #9be7ac;
        background:
            linear-gradient(135deg, #1f7a32, #12351c);
        box-shadow:
            0 8px 18px rgba(155, 231, 172, 0.12),
            inset 0 0 0 1px rgba(155, 231, 172, 0.20);
    }

    .calendar-button,
    .historical-calendar,
    .calendar-header button,
    .calendar-day {
        background: #050505;
        color: #f8fafc;
        border-color: #d7dde3;
    }

    .calendar-button:hover,
    .calendar-header button:hover,
    .calendar-day:hover {
        color: #ffff00;
        background: #111111;
        border-color: #ffff00;
    }

    .historical-calendar {
        box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
    }

    .calendar-weekdays {
        color: #b8c0cc;
    }

    .calendar-day.selected {
        background: #ffff00;
        border-color: #ffff00;
        color: #000000;
    }

    label {
        color: #d8dee9;
    }

    input,
    textarea,
    select {
        background: #050505;
        color: #f8fafc;
        border-color: #d7dde3;
    }

        input:focus,
        textarea:focus,
        select:focus {
            outline: 2px solid #ffff00;
            outline-offset: 1px;
        }

    .summary-label {
        color: #d8dee9;
    }

    .table-wrap {
        border-color: #d7dde3;
    }

    table {
        color: #f8fafc;
    }

    th {
        background: #050505;
        color: #f8fafc;
    }

    th,
    td {
        border-bottom-color: #d7dde3;
    }

    .empty {
        color: #b8c0cc;
    }

    #status {
        color: #d8dee9;
    }

        #status.success {
            color: #8fd19e;
        }

        #status.error,
        .error {
            color: #ff8a80;
        }

    .action-C {
        background: #12351c;
        color: #9be7ac;
    }

    .action-D {
        background: #3d1515;
        color: #ffb4a9;
    }

    .action-N {
        background: #1f2937;
        color: #d8dee9;
    }

    .position-value {
        display: inline-block;
        min-width: 80px;
        text-align: right;
        font-weight: 700;
    }

    .position-value-positive {
        color: #8fd19e;
    }

    .position-value-negative {
        color: #ff8a80;
    }

    .position-value-neutral {
        color: inherit;
    }
}

@media (max-width: 700px) {
    .section-title-row {
        align-items: stretch;
        flex-direction: column;
    }

    .button-row,
    .export-actions,
    .function-actions,
    .card-footer-actions,
    .actions {
        flex-direction: column;
        align-items: stretch;
    }

    .summary {
        grid-template-columns: 1fr;
    }

    .page {
        width: min(100% - 20px, 1200px);
        margin: 20px auto;
    }

    .chart-wrap {
        height: 260px;
    }
}
.position-value {
    display: inline-block !important;
    min-width: 80px !important;
    text-align: right !important;
    font-weight: 800 !important;
}

td.position-value-positive {
    color: #8fd19e !important;
    font-weight: 800;
}

td.position-value-negative {
    color: #ff8a80 !important;
    font-weight: 800;
}

td.position-value-neutral {
    color: #f8fafc !important;
    font-weight: 700;
}

/* Result summary spacing polish */
.results-card h2 {
    margin-bottom: 22px;
}

.summary {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 20px;
    margin-bottom: 34px;
}

    .summary div {
        min-height: 96px;
        padding: 18px 20px;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }

.summary-label {
    font-size: 14px;
    margin-bottom: 10px;
}

.summary strong {
    font-size: 25px;
    line-height: 1.15;
}

@media (max-width: 700px) {
    .summary {
        grid-template-columns: 1fr;
        gap: 14px;
    }

        .summary div {
            min-height: 82px;
        }
}

/* Visual battery configurator */
.battery-intro {
    margin-bottom: 16px;
}

.battery-configurator {
    display: grid;
    grid-template-columns: minmax(0, 1.08fr) minmax(360px, 0.92fr);
    gap: 18px;
    align-items: stretch;
}

.battery-visual-card,
.battery-control-card {
    border: 1px solid #d7dde3;
    border-radius: 12px;
    background: #fbfcfd;
    padding: 16px;
}

.battery-dashboard-row {
    display: grid;
    grid-template-columns: 1fr 1.25fr 1fr;
    gap: 12px;
    margin-bottom: 18px;
}

.battery-mini-card,
.battery-derived-card {
    border: 1px solid #d7dde3;
    border-radius: 12px;
    padding: 14px;
    background: #ffffff;
}

.battery-mini-card span,
.battery-derived-card span,
.battery-side-labels span {
    display: block;
    color: #6b7785;
    font-size: 13px;
    margin-bottom: 6px;
}

.battery-mini-card strong {
    display: block;
    font-size: 26px;
    line-height: 1.1;
}

.battery-mini-card small {
    display: block;
    color: #6b7785;
    margin-top: 6px;
}

.battery-mini-card-primary {
    background: #e8f5e9;
    border-color: #b9dfc0;
}

.battery-graphic-row {
    display: grid;
    grid-template-columns: 104px minmax(210px, 1fr) 180px;
    gap: 18px;
    align-items: center;
}

.battery-side-labels {
    min-height: 360px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.battery-side-labels strong {
    font-size: 22px;
}

.battery-shell-wrap {
    position: relative;
    display: flex;
    justify-content: center;
    padding-top: 14px;
}

.battery-cap {
    position: absolute;
    top: 2px;
    width: 62px;
    height: 14px;
    border-radius: 10px 10px 0 0;
    background: #8d959f;
}

.battery-shell {
    position: relative;
    width: 210px;
    height: 360px;
    overflow: hidden;
    border: 6px solid #8d959f;
    border-radius: 30px;
    background: #f2f5f7;
}

.battery-zone {
    position: absolute;
    left: 0;
    right: 0;
}

.battery-blocked-zone {
    background: repeating-linear-gradient(
        -45deg,
        rgba(105, 115, 125, 0.42) 0,
        rgba(105, 115, 125, 0.42) 8px,
        rgba(210, 216, 222, 0.64) 8px,
        rgba(210, 216, 222, 0.64) 16px
    );
}

.battery-usable-zone {
    background: repeating-linear-gradient(
        -45deg,
        rgba(72, 163, 91, 0.56) 0,
        rgba(72, 163, 91, 0.56) 8px,
        rgba(184, 229, 193, 0.78) 8px,
        rgba(184, 229, 193, 0.78) 16px
    );
}

.battery-initial-fill {
    position: absolute;
    left: 0;
    right: 0;
    background: rgba(143, 209, 158, 0.24);
    border-top: 1px solid rgba(27, 94, 32, 0.35);
    pointer-events: none;
}

.battery-initial-marker {
    position: absolute;
    left: -8px;
    right: -8px;
    height: 4px;
    border-radius: 999px;
    background: #ffff00;
    box-shadow: 0 0 14px rgba(255, 255, 0, 0.45);
    pointer-events: none;
}

.battery-derived-stack {
    display: grid;
    gap: 10px;
}

.battery-derived-card strong {
    display: block;
    font-family: Consolas, "Courier New", monospace;
    font-size: 15px;
    line-height: 1.25;
}

.battery-control-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.battery-slider-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.battery-slider-row input[type="range"] {
    padding: 0;
    accent-color: #1b5e20;
}

.battery-slider-row strong {
    min-width: 48px;
    text-align: right;
}

.power-mode-fieldset {
    margin: 16px 0 0;
    padding: 14px;
    border: 1px solid #d7dde3;
    border-radius: 14px;
    background:
        linear-gradient(135deg, rgba(99, 192, 122, 0.08), rgba(255, 255, 255, 0) 52%),
        #ffffff;
}

.power-mode-fieldset legend {
    padding: 0 8px;
    font-weight: 700;
}

.power-mode-options {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin-top: 4px;
}

.power-mode-option {
    position: relative;
    display: block;
    height: 100%;
    padding: 0;
    cursor: pointer;
}

.power-mode-option input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.power-mode-card {
    display: flex;
    height: 100%;
    min-height: 94px;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    padding: 14px 12px;
    border: 1px solid #d7dde3;
    border-radius: 13px;
    background: #f7faf8;
    color: #17202a;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.75);
    transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease, box-shadow 0.12s ease;
}

.power-mode-card strong {
    font-size: 14px;
    line-height: 1.2;
}

.power-mode-card small {
    color: #6b7785;
    font-size: 12px;
    line-height: 1.25;
}

.power-mode-option:hover .power-mode-card {
    transform: translateY(-1px);
    border-color: #63c07a;
    box-shadow: 0 8px 18px rgba(27, 94, 32, 0.10);
}

.power-mode-option input:focus-visible + .power-mode-card {
    outline: 2px solid #1b5e20;
    outline-offset: 2px;
}

.power-mode-option input:checked + .power-mode-card {
    border-color: #1b5e20;
    background:
        linear-gradient(135deg, rgba(155, 231, 172, 0.40), rgba(99, 192, 122, 0.12)),
        #eef9f0;
    box-shadow:
        0 10px 22px rgba(27, 94, 32, 0.14),
        inset 0 0 0 1px rgba(27, 94, 32, 0.18);
}

.power-mode-option input:checked + .power-mode-card::before {
    content: "✓";
    position: absolute;
    top: 10px;
    right: 10px;
    display: grid;
    width: 22px;
    height: 22px;
    place-items: center;
    border-radius: 999px;
    background: #1b5e20;
    color: #ffffff;
    font-size: 13px;
    font-weight: 700;
}

.raw-derived-inputs {
    display: none !important;
}

.soc-slider-panel {
    margin-top: 18px;
    border: 1px solid #d7dde3;
    border-radius: 12px;
    padding: 14px;
    background: #ffffff;
}

.soc-slider-row {
    display: grid;
    grid-template-columns: 120px minmax(0, 1fr);
    gap: 14px;
    align-items: center;
    margin-bottom: 14px;
}

.soc-slider-row:last-child {
    margin-bottom: 0;
}

.soc-slider-label span {
    display: block;
    color: #6b7785;
    font-size: 13px;
    margin-bottom: 4px;
}

.soc-slider-label strong {
    display: block;
    font-size: 18px;
    color: #17202a;
}

.soc-slider-row input[type="range"] {
    width: 100%;
    padding: 0;
    accent-color: #1b5e20;
}

@media (prefers-color-scheme: dark) {
    .battery-visual-card,
    .battery-control-card,
    .battery-mini-card,
    .battery-derived-card {
        background: #000000;
        border-color: #d7dde3;
    }

    .battery-mini-card span,
    .battery-derived-card span,
    .battery-side-labels span,
    .battery-mini-card small {
        color: #b8c0cc;
    }

    .battery-mini-card-primary {
        background: #12351c;
        border-color: #9be7ac;
    }

    .battery-shell {
        background: #050505;
        border-color: #d7dde3;
    }

    .battery-cap {
        background: #d7dde3;
    }

    .battery-blocked-zone {
        background: repeating-linear-gradient(
            -45deg,
            rgba(180, 190, 202, 0.22) 0,
            rgba(180, 190, 202, 0.22) 8px,
            rgba(40, 46, 54, 0.92) 8px,
            rgba(40, 46, 54, 0.92) 16px
        );
    }

    .battery-usable-zone {
        background: repeating-linear-gradient(
            -45deg,
            rgba(58, 132, 75, 0.78) 0,
            rgba(58, 132, 75, 0.78) 8px,
            rgba(28, 83, 43, 0.92) 8px,
            rgba(28, 83, 43, 0.92) 16px
        );
    }

    .battery-initial-fill {
        background: rgba(143, 209, 158, 0.22);
        border-top-color: rgba(155, 231, 172, 0.6);
    }

    .battery-derived-card strong,
    .battery-mini-card strong,
    .battery-side-labels strong {
        color: #f8fafc;
    }

    .power-mode-fieldset {
        border-color: #d7dde3;
        background:
            linear-gradient(135deg, rgba(143, 209, 158, 0.10), rgba(0, 0, 0, 0) 52%),
            #000000;
    }

    .power-mode-card {
        background: #050505;
        border-color: #d7dde3;
        color: #f8fafc;
        box-shadow: none;
    }

    .power-mode-card small {
        color: #b8c0cc;
    }

    .power-mode-option:hover .power-mode-card {
        border-color: #9be7ac;
        box-shadow: 0 8px 18px rgba(155, 231, 172, 0.10);
    }

    .power-mode-option input:focus-visible + .power-mode-card {
        outline-color: #ffff00;
    }

    .power-mode-option input:checked + .power-mode-card {
        border-color: #9be7ac;
        background:
            linear-gradient(135deg, rgba(155, 231, 172, 0.24), rgba(18, 53, 28, 0.72)),
            #12351c;
        box-shadow:
            0 10px 22px rgba(155, 231, 172, 0.10),
            inset 0 0 0 1px rgba(155, 231, 172, 0.22);
    }

    .power-mode-option input:checked + .power-mode-card::before {
        background: #9be7ac;
        color: #000000;
    }

    .battery-slider-row input[type="range"],
    .soc-slider-row input[type="range"] {
        accent-color: #9be7ac;
    }

    .soc-slider-panel {
        background: #000000;
        border-color: #d7dde3;
    }

    .soc-slider-label span {
        color: #b8c0cc;
    }

    .soc-slider-label strong {
        color: #f8fafc;
    }
}

@media (max-width: 900px) {
    .battery-configurator {
        grid-template-columns: 1fr;
    }

    .battery-graphic-row {
        grid-template-columns: 90px minmax(180px, 1fr) 160px;
    }
}

@media (max-width: 700px) {
    .optimization-main-actions {
        width: 100%;
    }

    .price-source-selector {
        grid-template-columns: 1fr;
    }

    .power-mode-options {
        grid-template-columns: 1fr;
    }

    .power-mode-card {
        min-height: 66px;
    }

    .battery-dashboard-row,
    .battery-control-grid {
        grid-template-columns: 1fr;
    }

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

    .battery-side-labels {
        min-height: auto;
        flex-direction: row;
        gap: 12px;
    }

    .battery-shell {
        width: 180px;
        height: 320px;
    }

    .soc-slider-row {
        grid-template-columns: 1fr;
        gap: 8px;
    }
}


/* V3: two-handle SoC window slider */
.soc-slider-panel {
    margin-top: 18px;
    border: 1px solid #d7dde3;
    border-radius: 12px;
    padding: 16px;
    background: #ffffff;
}

.soc-slider-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 12px;
}

.soc-slider-label span {
    display: block;
    color: #6b7785;
    font-size: 13px;
    margin-bottom: 4px;
}

.soc-slider-label strong {
    display: block;
    font-size: 18px;
    color: #17202a;
}

.soc-slider-label-right {
    text-align: right;
}

.soc-range-shell {
    position: relative;
    height: 54px;
    margin: 4px 8px 0;
}

.soc-range-track,
.soc-range-selected {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    height: 5px;
    border-radius: 999px;
}

.soc-range-track {
    left: 0;
    right: 0;
    background: #2f3a45;
}

.soc-range-selected {
    left: 0;
    width: 100%;
    background: #63c07a;
    box-shadow: 0 0 14px rgba(99, 192, 122, 0.28);
}

.soc-range-input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 54px;
    margin: 0;
    padding: 0;
    border: none;
    background: transparent;
    pointer-events: none;
    appearance: none;
    -webkit-appearance: none;
}

.soc-range-input::-webkit-slider-runnable-track {
    height: 5px;
    background: transparent;
    border: none;
}

.soc-range-input::-webkit-slider-thumb {
    pointer-events: auto;
    width: 28px;
    height: 28px;
    border-radius: 999px;
    border: 4px solid #2b323a;
    background: #8a949f;
    box-shadow: 0 0 0 2px rgba(255,255,255,0.12), 0 4px 10px rgba(0,0,0,0.35);
    cursor: grab;
    appearance: none;
    -webkit-appearance: none;
    margin-top: -11.5px;
}

.soc-range-input::-moz-range-track {
    height: 5px;
    background: transparent;
    border: none;
}

.soc-range-input::-moz-range-thumb {
    pointer-events: auto;
    width: 20px;
    height: 20px;
    border-radius: 999px;
    border: 4px solid #2b323a;
    background: #8a949f;
    box-shadow: 0 0 0 2px rgba(255,255,255,0.12), 0 4px 10px rgba(0,0,0,0.35);
    cursor: grab;
}

.soc-range-input-min {
    z-index: 3;
}

.soc-range-input-max {
    z-index: 4;
}

.soc-slider-hint {
    margin: 2px 0 0;
    color: #6b7785;
    font-size: 13px;
    line-height: 1.4;
}

@media (prefers-color-scheme: dark) {
    .soc-slider-panel {
        background: #000000;
        border-color: #d7dde3;
    }

    .soc-slider-label span,
    .soc-slider-hint {
        color: #b8c2cc;
    }

    .soc-slider-label strong {
        color: #f8fafc;
    }

    .soc-range-track {
        background: #303947;
    }

    .soc-range-selected {
        background: #8fd19e;
        box-shadow: 0 0 18px rgba(143, 209, 158, 0.28);
    }

    .soc-range-input::-webkit-slider-thumb {
        border-color: #2f3944;
        background: #7c8792;
    }

    .soc-range-input::-moz-range-thumb {
        border-color: #2f3944;
        background: #7c8792;
    }
}

/* V7: vertical three-handle SoC control beside the battery */
.battery-graphic-row {
    grid-template-columns: 86px 54px minmax(190px, 1fr) 180px;
    gap: 16px;
}

.battery-side-labels {
    min-height: 360px;
}

.battery-soc-range-stack {
    position: relative;
    width: 54px;
    height: 360px;
    align-self: center;
    justify-self: center;
}

.battery-soc-range-track,
.battery-soc-range-selected {
    position: absolute;
    left: 50%;
    width: 6px;
    transform: translateX(-50%);
    border-radius: 999px;
}

.battery-soc-range-track {
    top: 0;
    bottom: 0;
    background: #303947;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.08);
}

.battery-soc-range-selected {
    bottom: 0;
    height: 100%;
    background: #63c07a;
    box-shadow: 0 0 14px rgba(99, 192, 122, 0.35);
}

.battery-soc-range-input {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 360px;
    height: 54px;
    margin: 0;
    padding: 0;
    border: none;
    background: transparent;
    pointer-events: none;
    appearance: none;
    -webkit-appearance: none;
    transform: translate(-50%, -50%) rotate(-90deg);
    transform-origin: center;
}

.battery-soc-range-input::-webkit-slider-runnable-track {
    height: 6px;
    background: transparent;
    border: none;
}

.battery-soc-range-input::-webkit-slider-thumb {
    pointer-events: auto;
    width: 28px;
    height: 28px;
    border-radius: 999px;
    border: 4px solid #2f3944;
    background: #7c8792;
    box-shadow: 0 0 0 2px rgba(255,255,255,0.14), 0 4px 10px rgba(0,0,0,0.36);
    cursor: grab;
    appearance: none;
    -webkit-appearance: none;
    margin-top: -11px;
}

.battery-soc-range-input::-moz-range-track {
    height: 6px;
    background: transparent;
    border: none;
}

.battery-soc-range-input::-moz-range-thumb {
    pointer-events: auto;
    width: 20px;
    height: 20px;
    border-radius: 999px;
    border: 4px solid #2f3944;
    background: #7c8792;
    box-shadow: 0 0 0 2px rgba(255,255,255,0.14), 0 4px 10px rgba(0,0,0,0.36);
    cursor: grab;
}

.battery-soc-range-input-min {
    z-index: 4;
}

.battery-soc-range-input-initial {
    z-index: 6;
}

.battery-soc-range-input-max {
    z-index: 5;
}

.battery-soc-range-input-initial::-webkit-slider-thumb {
    width: 24px;
    height: 24px;
    border: 3px solid #2f3944;
    background: #ffff00;
    box-shadow: 0 0 0 2px rgba(255,255,255,0.18), 0 0 16px rgba(255,255,0,0.42), 0 4px 10px rgba(0,0,0,0.36);
    margin-top: -9px;
}

.battery-soc-range-input-initial::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border: 3px solid #2f3944;
    background: #ffff00;
    box-shadow: 0 0 0 2px rgba(255,255,255,0.18), 0 0 16px rgba(255,255,0,0.42), 0 4px 10px rgba(0,0,0,0.36);
}

.soc-slider-panel {
    display: none !important;
}

@media (prefers-color-scheme: dark) {
    .battery-soc-range-track {
        background: #303947;
    }

    .battery-soc-range-selected {
        background: #8fd19e;
        box-shadow: 0 0 18px rgba(143, 209, 158, 0.32);
    }

    .battery-soc-range-input::-webkit-slider-thumb {
        border-color: #2f3944;
        background: #7c8792;
    }

    .battery-soc-range-input::-moz-range-thumb {
        border-color: #2f3944;
        background: #7c8792;
    }

    .battery-soc-range-input-initial::-webkit-slider-thumb,
    .battery-soc-range-input-initial::-moz-range-thumb {
        background: #ffff00;
    }
}

@media (max-width: 900px) {
    .battery-graphic-row {
        grid-template-columns: 82px 50px minmax(180px, 1fr) 160px;
        gap: 14px;
    }

    .battery-soc-range-stack {
        height: 340px;
    }

    .battery-soc-range-input {
        width: 340px;
    }
}

@media (max-width: 700px) {
    .battery-graphic-row {
        grid-template-columns: 82px 50px minmax(170px, 1fr);
        align-items: center;
    }

    .battery-derived-stack {
        grid-column: 1 / -1;
        grid-template-columns: 1fr;
    }

    .battery-soc-range-stack {
        height: 320px;
    }

    .battery-soc-range-input {
        width: 320px;
    }
}

/* V9: custom three-handle SoC control.
   This replaces the overlapping native range inputs so all handles remain reachable. */
.battery-soc-range-stack {
    cursor: pointer;
    touch-action: none;
    user-select: none;
}

.battery-soc-range-handle {
    position: absolute;
    left: 50%;
    bottom: 0;
    width: 28px;
    height: 28px;
    min-height: 0;
    padding: 0;
    border-radius: 999px;
    border: 4px solid #2f3944;
    background: #7c8792;
    box-shadow: 0 0 0 2px rgba(255,255,255,0.14), 0 4px 10px rgba(0,0,0,0.36);
    cursor: grab;
    appearance: none;
    -webkit-appearance: none;
    transform: translate(calc(-50% + var(--soc-handle-offset, 0px)), 50%);
    z-index: 7;
}

.battery-soc-range-handle:hover,
.battery-soc-range-handle:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(255,255,255,0.18), 0 0 18px rgba(143, 209, 158, 0.35), 0 4px 10px rgba(0,0,0,0.36);
}

.battery-soc-range-handle:active,
.battery-soc-range-handle.is-dragging {
    cursor: grabbing;
}

.battery-soc-range-handle-initial {
    width: 24px;
    height: 24px;
    border: 3px solid #2f3944;
    background: #ffff00;
    box-shadow: 0 0 0 2px rgba(255,255,255,0.18), 0 0 16px rgba(255,255,0,0.42), 0 4px 10px rgba(0,0,0,0.36);
    z-index: 9;
}

.battery-soc-range-handle-max {
    z-index: 8;
}

.battery-soc-range-handle-min {
    z-index: 8;
}

.date-limit-hint {
    display: block;
    margin-top: 6px;
    color: #6b7785;
    font-size: 12px;
}

.calendar-day:disabled,
.calendar-day.disabled {
    cursor: not-allowed;
    opacity: 0.35;
    background: #eef2f6;
    color: #8a97a6;
    box-shadow: none;
}

.calendar-header button:disabled {
    cursor: not-allowed;
    opacity: 0.45;
}


.custom-price-actions {
    margin: 4px 0 12px;
}

.custom-prices-textarea {
    display: block;
    width: 100% !important;
    max-width: none;
    min-width: 100%;
    min-height: 240px;
    margin-top: 0;
    resize: vertical;
}


/* V32: one-card dispatch layout. Price source selection is now SQL-only. */
.combined-dispatch-card .battery-intro {
    margin-bottom: 14px;
}

.battery-configurator-compact {
    grid-template-columns: minmax(0, 1.08fr) minmax(340px, 0.92fr);
    gap: 16px;
}

.dispatch-control-card {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 14px;
}

.control-section {
    border: 1px solid #d7dde3;
    border-radius: 12px;
    padding: 12px;
    background: #ffffff;
}

.control-section h3 {
    margin: 0 0 10px;
    font-size: 15px;
}

.compact-control-grid {
    gap: 10px;
}

.compact-control-grid label,
.market-control-grid label {
    gap: 5px;
    font-size: 13px;
}

.compact-control-grid input,
.compact-control-grid select,
.market-control-grid input,
.market-control-grid select {
    padding: 8px 10px;
    min-height: 38px;
}

.compact-control-grid .battery-slider-row {
    gap: 8px;
}

.compact-control-grid .battery-slider-row strong {
    min-width: 42px;
}

.market-control-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

.market-input-section .hint {
    margin: -4px 0 10px;
    font-size: 13px;
}

.market-input-section .date-limit-hint {
    font-size: 12px;
}

.market-input-section .historical-calendar {
    max-width: none;
    margin-top: 10px;
}

.dispatch-action-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.dispatch-run-button {
    min-width: 148px;
}

.dispatch-export-actions {
    margin-top: auto;
}

.hidden-price-buffer {
    display: none !important;
}

@media (max-width: 1000px) {
    .battery-configurator-compact {
        grid-template-columns: 1fr;
    }
}

@media (prefers-color-scheme: dark) {
    .control-section {
        background: #050505;
        border-color: #d7dde3;
    }
}


/* V33: make the visual battery panel carry the primary action and use the empty space. */
.combined-dispatch-card .battery-visual-card {
    display: flex;
    flex-direction: column;
    min-height: 720px;
}

.combined-dispatch-card .battery-dashboard-row {
    margin-bottom: 14px;
}

.combined-dispatch-card .battery-graphic-row {
    grid-template-columns: 88px 60px minmax(250px, 1fr) 170px;
    gap: 18px;
    align-items: center;
    flex: 1;
}

.combined-dispatch-card .battery-side-labels {
    min-height: 460px;
}

.combined-dispatch-card .battery-soc-range-stack {
    height: 460px;
}

.combined-dispatch-card .battery-shell {
    width: 245px;
    height: 460px;
    border-radius: 34px;
}

.combined-dispatch-card .battery-cap {
    width: 72px;
    height: 16px;
}

.combined-dispatch-card .battery-derived-stack {
    align-content: start;
    align-self: center;
}

.visual-dispatch-action-row {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid #d7dde3;
    flex-wrap: wrap;
}

.visual-dispatch-action-row .dispatch-run-button {
    min-width: 160px;
}

.market-input-section {
    flex: 1;
}

.market-input-section .historical-calendar {
    position: relative;
    z-index: 10;
}

@media (max-width: 1180px) {
    .combined-dispatch-card .battery-graphic-row {
        grid-template-columns: 84px 56px minmax(220px, 1fr) 160px;
    }

    .combined-dispatch-card .battery-shell {
        width: 225px;
        height: 430px;
    }

    .combined-dispatch-card .battery-side-labels,
    .combined-dispatch-card .battery-soc-range-stack {
        min-height: 430px;
        height: 430px;
    }
}

@media (max-width: 1000px) {
    .combined-dispatch-card .battery-visual-card {
        min-height: auto;
    }
}

@media (max-width: 700px) {
    .combined-dispatch-card .battery-graphic-row {
        grid-template-columns: 1fr;
    }

    .combined-dispatch-card .battery-side-labels {
        min-height: auto;
        height: auto;
    }

    .combined-dispatch-card .battery-soc-range-stack {
        height: 320px;
    }

    .combined-dispatch-card .battery-shell {
        width: 180px;
        height: 320px;
    }
}

@media (prefers-color-scheme: dark) {
    .visual-dispatch-action-row {
        border-top-color: #d7dde3;
    }
}


/* V34: keep the left-panel dispatch layout, but stop the raw cards from overflowing. */
.combined-dispatch-card .battery-visual-card {
    min-height: 0;
}

.combined-dispatch-card .battery-graphic-row {
    grid-template-columns: 82px 54px minmax(210px, 1fr);
    gap: 16px;
    align-items: center;
}

.combined-dispatch-card .battery-shell {
    width: 230px;
    height: 430px;
    border-radius: 32px;
}

.combined-dispatch-card .battery-cap {
    width: 68px;
    height: 15px;
}

.combined-dispatch-card .battery-side-labels {
    min-height: 430px;
}

.combined-dispatch-card .battery-soc-range-stack {
    height: 430px;
}

.combined-dispatch-card .battery-derived-stack {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    width: 100%;
    margin-top: 12px;
    align-self: stretch;
}

.combined-dispatch-card .battery-derived-card {
    min-width: 0;
    padding: 12px;
}

.combined-dispatch-card .battery-derived-card strong {
    font-size: 13px;
    overflow-wrap: anywhere;
}

.visual-dispatch-action-row {
    margin-top: 12px;
}

@media (max-width: 1180px) {
    .combined-dispatch-card .battery-graphic-row {
        grid-template-columns: 78px 50px minmax(190px, 1fr);
        gap: 14px;
    }

    .combined-dispatch-card .battery-shell {
        width: 210px;
        height: 400px;
    }

    .combined-dispatch-card .battery-side-labels {
        min-height: 400px;
    }

    .combined-dispatch-card .battery-soc-range-stack {
        height: 400px;
    }

    .combined-dispatch-card .battery-derived-stack {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 700px) {
    .combined-dispatch-card .battery-derived-stack {
        grid-template-columns: 1fr;
    }
}


/* V35: compact market box and no separate Calendar button. */
.market-input-section {
    flex: 0 0 auto;
}

.market-input-section .date-picker-row {
    grid-template-columns: minmax(0, 1fr);
}

.dispatch-export-actions {
    margin-top: 12px;
}

.market-input-section .historical-calendar {
    max-width: 360px;
}


/* V36: move Run dispatch back to the right panel and align it with config download. */
.dispatch-control-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-top: auto;
    padding-top: 14px;
    border-top: 1px solid #d7dde3;
    flex-wrap: wrap;
}

.dispatch-control-run-group {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    flex-wrap: wrap;
}

.dispatch-control-footer .dispatch-export-actions {
    margin-top: 0;
    margin-left: auto;
}

.dispatch-control-footer .dispatch-run-button {
    min-width: 150px;
}

.dispatch-control-footer .optimization-run-status {
    white-space: nowrap;
}

.visual-dispatch-action-row {
    display: none !important;
}

@media (max-width: 760px) {
    .dispatch-control-footer {
        align-items: flex-start;
        flex-direction: column;
    }

    .dispatch-control-footer .dispatch-export-actions {
        margin-left: 0;
    }

    .dispatch-control-footer .optimization-run-status {
        white-space: normal;
    }
}

@media (prefers-color-scheme: dark) {
    .dispatch-control-footer {
        border-top-color: #d7dde3;
    }
}


/* V37: file import/export actions live together in the card header. */
.config-file-actions {
    align-items: center;
    gap: 10px;
}

.config-action-separator {
    color: #8a97a6;
    font-weight: 800;
    line-height: 1;
}

.dispatch-control-footer {
    justify-content: flex-start;
}

.dispatch-control-footer .dispatch-control-run-group {
    width: 100%;
}

.dispatch-control-footer .optimization-run-status {
    white-space: normal;
}

@media (max-width: 700px) {
    .config-file-actions {
        justify-content: flex-start;
    }
}

@media (prefers-color-scheme: dark) {
    .config-action-separator {
        color: #b8c0cc;
    }
}


/* V38: render the date picker as an overlay so opening it does not stretch the card. */
.dispatch-control-card,
.market-input-section {
    overflow: visible;
}

.market-input-section {
    position: relative;
}

.market-input-section .historical-calendar {
    position: absolute;
    top: calc(100% - 2px);
    left: 12px;
    width: min(360px, calc(100% - 24px));
    max-width: none;
    margin-top: 0;
    z-index: 80;
    box-shadow:
        0 18px 44px rgba(0, 0, 0, 0.32),
        0 0 0 1px rgba(255, 255, 255, 0.06);
}

.combined-dispatch-card,
.battery-configurator-compact,
.dispatch-control-card {
    overflow: visible;
}

@media (max-width: 700px) {
    .market-input-section .historical-calendar {
        left: 8px;
        width: calc(100% - 16px);
    }
}

@media (prefers-color-scheme: dark) {
    .market-input-section .historical-calendar {
        box-shadow:
            0 18px 44px rgba(0, 0, 0, 0.70),
            0 0 0 1px rgba(255, 255, 255, 0.10);
    }
}


/* V42: keep header config import/export actions neutral white. */
.config-file-actions button {
    color: #ffffff;
}

.config-file-actions button:hover {
    color: #ffffff;
}


/* V46: page header brand extension. */
.brand-title {
    flex-wrap: wrap;
    gap: 8px;
}

.brand-divider {
    color: #718294;
    font-weight: 700;
}

.brand-subtitle {
    color: #718294;
    font-weight: 700;
}

.brand-description {
    margin-top: 8px;
    color: #9fb1c3;
    font-size: 18px;
    letter-spacing: 0.01em;
}

@media (max-width: 700px) {
    .brand-description {
        font-size: 15px;
    }
}


/* V47: registration/login modal. */
.hidden {
    display: none !important;
}

.auth-overlay {
    position: fixed;
    inset: 0;
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(0, 0, 0, 0.68);
    backdrop-filter: blur(5px);
}

.auth-modal {
    width: min(460px, 100%);
    border: 1px solid #d7dde3;
    border-radius: 18px;
    padding: 22px;
    background:
        linear-gradient(135deg, rgba(255, 176, 46, 0.08), rgba(255, 255, 255, 0) 46%),
        #ffffff;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
}

.auth-modal-header h2 {
    margin: 0 0 6px;
    font-size: 24px;
}

.auth-modal-header p {
    margin: 0 0 18px;
    color: #5d6d7e;
}

.auth-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 14px;
}

.auth-tab {
    border: 1px solid #ccd3da;
    border-radius: 999px;
    padding: 10px 12px;
    background: #ffffff;
    color: #17202a;
}

.auth-tab.active {
    border-color: #ffb02e;
    background: rgba(255, 176, 46, 0.15);
    color: #17202a;
}

.auth-panel {
    display: grid;
    gap: 12px;
}

.auth-panel label {
    display: grid;
    gap: 6px;
    font-size: 13px;
    font-weight: 700;
}

.auth-panel input {
    min-height: 42px;
}

.auth-primary-button {
    margin-top: 4px;
    min-height: 44px;
    border-radius: 10px;
    border: 1px solid #1b8f3a;
    background: linear-gradient(135deg, #1f8f3a, #0f6b2a);
    color: #ffffff;
    font-weight: 800;
}

.auth-link-button {
    justify-self: start;
    padding: 0;
    border: none;
    background: transparent;
    color: #ffb02e;
    font-weight: 700;
}

.auth-message {
    margin: 0 0 14px;
    border: 1px solid rgba(143, 209, 158, 0.85);
    border-radius: 12px;
    padding: 10px 12px;
    background: rgba(143, 209, 158, 0.15);
    color: #1b5e20;
}

.auth-message.error {
    border-color: rgba(255, 138, 128, 0.85);
    background: rgba(255, 138, 128, 0.16);
    color: #b42318;
}

.auth-small-note {
    margin: 0;
    color: #5d6d7e;
    font-size: 12px;
}

@media (prefers-color-scheme: dark) {
    .auth-modal {
        background:
            linear-gradient(135deg, rgba(255, 176, 46, 0.10), rgba(255, 255, 255, 0) 46%),
            #101417;
        color: #f8fafc;
        border-color: #d7dde3;
    }

    .auth-modal-header p,
    .auth-small-note {
        color: #b8c0cc;
    }

    .auth-tab {
        background: #050505;
        color: #f8fafc;
        border-color: #d7dde3;
    }

    .auth-tab.active {
        border-color: #ffb02e;
        background: rgba(255, 176, 46, 0.18);
        color: #ffb02e;
    }

    .auth-message {
        color: #8fd19e;
    }

    .auth-message.error {
        color: #ff8a80;
    }
}


/* V51: period optimization date range and period result chart. */
.date-range-input-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.date-range-input-grid .historical-date-label {
    min-width: 0;
}

.date-range-input-grid input {
    width: 100%;
}

.period-positive {
    color: #8fd19e;
}

.period-negative {
    color: #ff8a80;
}

@media (max-width: 700px) {
    .date-range-input-grid {
        grid-template-columns: 1fr;
    }
}


/* V54: connect period aggregate results to selected-day dispatch details. */
.selected-day-detail-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.selected-day-detail-header h3 {
    margin: 2px 0 0;
}

.selected-day-eyebrow {
    display: block;
    color: #ffb02e;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.selected-day-summary {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
    color: #d7dde3;
    font-size: 13px;
}

.selected-day-summary span {
    border: 1px solid #d7dde3;
    border-radius: 999px;
    padding: 5px 9px;
    background: rgba(255, 255, 255, 0.03);
}

.period-day-row {
    cursor: pointer;
}

.period-day-row:hover {
    background: rgba(255, 176, 46, 0.08);
}

.period-day-row.selected-period-day {
    background: rgba(255, 176, 46, 0.14);
    outline: 1px solid rgba(255, 176, 46, 0.55);
    outline-offset: -1px;
}

@media (max-width: 700px) {
    .selected-day-summary {
        justify-content: flex-start;
    }
}


/* V55: selected-day detail starts hidden and dispatch table is collapsible. */
.selected-day-eyebrow {
    color: #ffffff;
}

.dispatch-table-details {
    margin-top: 16px;
    border: 1px solid #d7dde3;
    border-radius: 14px;
    overflow: hidden;
}

.dispatch-table-details > summary {
    cursor: pointer;
    padding: 14px 16px;
    color: #f8fafc;
    font-weight: 800;
    list-style: none;
    background: rgba(255, 255, 255, 0.03);
}

.dispatch-table-details > summary::-webkit-details-marker {
    display: none;
}

.dispatch-table-details > summary::after {
    content: "▾";
    float: right;
    color: #ffb02e;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.dispatch-table-details[open] > summary::after {
    content: "▴";
}

.dispatch-table-details .table-wrap {
    margin-top: 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
    border-radius: 0;
}

@media (prefers-color-scheme: dark) {
    .dispatch-table-details {
        border-color: #343d46;
    }
}


/* V56: dispatch drilldown ordering and compact collapse affordance. */
.dispatch-table-details > summary::after {
    font-size: 18px;
    line-height: 1;
    text-transform: none;
    letter-spacing: 0;
}


/* V57: selected-day dispatch header cleanup and spacing. */
.results-card > #singleDayChartCard {
    margin-top: 20px;
}

.results-card > #dispatchTableDetails {
    margin-top: 18px;
}

.selected-day-detail-header {
    padding-top: 2px;
}

.selected-day-detail-header h3 {
    margin-top: 0;
}


/* V58: period profit table is collapsible and selected daily bars are highlighted in the chart. */
.period-table-details {
    margin-top: 16px;
}

.period-table-details > summary {
    color: #f8fafc;
}

.selected-period-day {
    background: rgba(255, 176, 46, 0.14);
    outline: 1px solid rgba(255, 176, 46, 0.55);
    outline-offset: -1px;
}


/* V60: period chart zoom controls and clearer cumulative line. */
.period-chart-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 12px;
}

.period-chart-controls.hidden {
    display: none;
}

.period-chart-controls button {
    min-width: 36px;
    min-height: 32px;
    border-radius: 10px;
    border: 1px solid #343d46;
    background: rgba(255, 255, 255, 0.03);
    color: #f8fafc;
    font-weight: 900;
    cursor: pointer;
}

.period-chart-controls button:hover:not(:disabled) {
    border-color: #ffb02e;
    color: #ffb02e;
}

.period-chart-controls button:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.period-chart-controls span {
    color: #cbd5e1;
    font-size: 13px;
    min-width: 260px;
    text-align: center;
}

@media (max-width: 700px) {
    .period-chart-controls span {
        min-width: 100%;
        order: -1;
    }
}


/* V61: account/logout bar sits above the configurator instead of inside it. */
.account-bar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 14px;
    margin: -6px 0 14px;
    color: #d7dde3;
    font-size: 14px;
}

.account-bar.hidden {
    display: none !important;
}

.account-bar-email {
    color: #f8fafc;
    font-weight: 700;
}

.account-bar button {
    min-height: 32px;
    padding: 0;
    color: #ffffff;
}

.account-bar button:hover {
    color: #ffb02e;
}

@media (max-width: 700px) {
    .account-bar {
        align-items: flex-start;
        justify-content: flex-start;
        flex-direction: column;
        gap: 4px;
    }
}


/* V62: keep the BESSQuant / Dispatch Optimizer logo text visually aligned. */
.brand-title {
    align-items: center;
    line-height: 1;
}

.brand-title > span {
    display: inline-flex;
    align-items: center;
    line-height: 1;
}

.brand-bess,
.brand-quant,
.brand-divider,
.brand-subtitle {
    line-height: 1;
}

.brand-divider,
.brand-subtitle {
    transform: translateY(1px);
}

.brand-description {
    margin-top: 10px;
}


/* V63: lower the slash and Dispatch Optimizer text to align visually with BESSQuant. */
.brand-divider,
.brand-subtitle {
    transform: translateY(4px);
}


/* V64: align BESSQuant and Dispatch Optimizer to the same lower visual line. */
.brand-title {
    align-items: flex-end;
}

.brand-title > span {
    align-items: flex-end;
}

.brand-title > span:first-child {
    transform: translateY(2px);
}

.brand-divider,
.brand-subtitle {
    transform: translateY(2px);
}


/* V65: explicit differential logo alignment. 
   Previous patches moved both sides together, so the visual result barely changed.
   This lowers only BESSQuant to meet the Dispatch Optimizer baseline. */
.brand-title {
    display: inline-flex;
    align-items: flex-end;
    gap: 8px;
    line-height: 1;
}

.brand-main,
.brand-divider,
.brand-subtitle {
    display: inline-flex;
    align-items: flex-end;
    line-height: 1;
}

.brand-main {
    transform: translateY(5px) !important;
}

.brand-divider,
.brand-subtitle {
    transform: translateY(0) !important;
}


/* V66: align account/logout info with the brand line above the configurator. */
.header-top-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.header-top-row .brand-title {
    margin: 0;
}

.header-top-row .account-bar {
    margin: 0;
    align-items: center;
    justify-content: flex-end;
    transform: translateY(1px);
}

.header-top-row .account-bar-email {
    white-space: nowrap;
}

.header-top-row #logoutButton {
    white-space: nowrap;
}

@media (max-width: 900px) {
    .header-top-row {
        align-items: flex-start;
        flex-direction: column;
        gap: 8px;
    }

    .header-top-row .account-bar {
        justify-content: flex-start;
        transform: none;
    }
}


/* V67: undo the experimental logo vertical offsets.
   Align the brand text and subtitle on a normal shared baseline. */
.brand-title {
    align-items: baseline !important;
}

.brand-title > span,
.brand-main,
.brand-divider,
.brand-subtitle {
    align-items: baseline !important;
    line-height: 1 !important;
}

.brand-main {
    transform: translateY(0) !important;
}

.brand-divider,
.brand-subtitle {
    transform: translateY(0) !important;
}


/* V68: clearer battery colour model.
   - Grey = usable but currently empty capacity
   - Green = currently filled energy
   - Red = outside allowed operating SoC range, when Min/Max SoC are not 0/100
   - Amber = initial/current SoC marker
*/
.combined-dispatch-card .battery-shell,
.battery-shell {
    border-color: #5d6873;
    background: #11161c;
    box-shadow:
        inset 0 0 0 1px rgba(255, 255, 255, 0.05),
        0 10px 26px rgba(0, 0, 0, 0.28);
}

.combined-dispatch-card .battery-cap,
.battery-cap {
    background: #5d6873;
}

.combined-dispatch-card .battery-usable-zone,
.battery-usable-zone {
    /* Empty usable capacity. */
    background:
        linear-gradient(rgba(255, 255, 255, 0.015), rgba(255, 255, 255, 0.015)),
        repeating-linear-gradient(
            -45deg,
            #2d353d 0,
            #2d353d 8px,
            #20272f 8px,
            #20272f 16px
        );
}

.combined-dispatch-card .battery-initial-fill,
.battery-initial-fill {
    /* Filled energy. */
    background:
        linear-gradient(rgba(73, 214, 119, 0.10), rgba(73, 214, 119, 0.10)),
        repeating-linear-gradient(
            -45deg,
            #14552f 0,
            #14552f 8px,
            #1f7440 8px,
            #1f7440 16px
        );
    border-top: 1px solid rgba(255, 176, 46, 0.42);
    z-index: 3;
}

.combined-dispatch-card .battery-blocked-zone,
.battery-blocked-zone {
    /* Unavailable SoC outside configured operating limits. */
    background:
        linear-gradient(rgba(255, 90, 90, 0.10), rgba(255, 90, 90, 0.10)),
        repeating-linear-gradient(
            -45deg,
            #3a1718 0,
            #3a1718 8px,
            #231316 8px,
            #231316 16px
        );
    z-index: 2;
}

.combined-dispatch-card .battery-initial-marker,
.battery-initial-marker {
    height: 4px;
    background: #ffb02e;
    box-shadow:
        0 0 0 1px rgba(255, 176, 46, 0.55),
        0 0 18px rgba(255, 176, 46, 0.50);
    z-index: 5;
}

.combined-dispatch-card .battery-soc-range-track,
.battery-soc-range-track {
    background: #2d353d;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.combined-dispatch-card .battery-soc-range-selected,
.battery-soc-range-selected {
    background: linear-gradient(180deg, #49d677, #1f7440);
    box-shadow: 0 0 18px rgba(73, 214, 119, 0.32);
}

.combined-dispatch-card .battery-soc-range-handle,
.battery-soc-range-handle {
    border-color: #1d232a;
    background: #7d8791;
}

.combined-dispatch-card .battery-soc-range-handle-initial,
.battery-soc-range-handle-initial {
    background: #ffb02e;
    box-shadow:
        0 0 0 2px rgba(255, 255, 255, 0.14),
        0 0 18px rgba(255, 176, 46, 0.48),
        0 4px 10px rgba(0, 0, 0, 0.36);
}


/* V73: force the dark demo theme in every browser, independent of Chrome/Edge appearance settings. */
html {
    color-scheme: dark;
}

body {
    background: #101417;
}

body {
        background: #050505;
        color: #f8fafc;
    }

    .header p,
    .hint,
    .chart-note,
    .price-source-row {
        color: #b8c0cc;
    }

    .card,
    .chart-card,
    .summary div,
    .generator-panel,
.historical-panel {
        background: #000000;
        border-color: #d7dde3;
    }

    .price-source-row strong {
        color: #f8fafc;
    }

    .price-source-option span {
        background: #050505;
        border-color: #d7dde3;
        color: #f8fafc;
    }

    .price-source-option small {
        color: #b8c0cc;
    }

    .price-source-option:hover span {
        border-color: #9be7ac;
        box-shadow: 0 8px 18px rgba(155, 231, 172, 0.10);
    }

    .price-source-option input:focus-visible + span {
        outline-color: #ffff00;
    }

    .price-source-option input:checked + span {
        border-color: #9be7ac;
        background:
            linear-gradient(135deg, rgba(155, 231, 172, 0.24), rgba(18, 53, 28, 0.72)),
            #12351c;
        box-shadow:
            0 10px 22px rgba(155, 231, 172, 0.10),
            inset 0 0 0 1px rgba(155, 231, 172, 0.22);
    }

    .optimization-run-button {
        border-color: #9be7ac;
        background:
            linear-gradient(135deg, #1f7a32, #12351c);
        box-shadow:
            0 8px 18px rgba(155, 231, 172, 0.12),
            inset 0 0 0 1px rgba(155, 231, 172, 0.20);
    }

    .calendar-button,
    .historical-calendar,
    .calendar-header button,
    .calendar-day {
        background: #050505;
        color: #f8fafc;
        border-color: #d7dde3;
    }

    .calendar-button:hover,
    .calendar-header button:hover,
    .calendar-day:hover {
        color: #ffff00;
        background: #111111;
        border-color: #ffff00;
    }

    .historical-calendar {
        box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
    }

    .calendar-weekdays {
        color: #b8c0cc;
    }

    .calendar-day.selected {
        background: #ffff00;
        border-color: #ffff00;
        color: #000000;
    }

    label {
        color: #d8dee9;
    }

    input,
    textarea,
    select {
        background: #050505;
        color: #f8fafc;
        border-color: #d7dde3;
    }

        input:focus,
        textarea:focus,
        select:focus {
            outline: 2px solid #ffff00;
            outline-offset: 1px;
        }

    .summary-label {
        color: #d8dee9;
    }

    .table-wrap {
        border-color: #d7dde3;
    }

    table {
        color: #f8fafc;
    }

    th {
        background: #050505;
        color: #f8fafc;
    }

    th,
    td {
        border-bottom-color: #d7dde3;
    }

    .empty {
        color: #b8c0cc;
    }

    #status {
        color: #d8dee9;
    }

        #status.success {
            color: #8fd19e;
        }

        #status.error,
        .error {
            color: #ff8a80;
        }

    .action-C {
        background: #12351c;
        color: #9be7ac;
    }

    .action-D {
        background: #3d1515;
        color: #ffb4a9;
    }

    .action-N {
        background: #1f2937;
        color: #d8dee9;
    }

    .position-value {
        display: inline-block;
        min-width: 80px;
        text-align: right;
        font-weight: 700;
    }

    .position-value-positive {
        color: #8fd19e;
    }

    .position-value-negative {
        color: #ff8a80;
    }

    .position-value-neutral {
        color: inherit;
    }

.battery-visual-card,
    .battery-control-card,
    .battery-mini-card,
    .battery-derived-card {
        background: #000000;
        border-color: #d7dde3;
    }

    .battery-mini-card span,
    .battery-derived-card span,
    .battery-side-labels span,
    .battery-mini-card small {
        color: #b8c0cc;
    }

    .battery-mini-card-primary {
        background: #12351c;
        border-color: #9be7ac;
    }

    .battery-shell {
        background: #050505;
        border-color: #d7dde3;
    }

    .battery-cap {
        background: #d7dde3;
    }

    .battery-blocked-zone {
        background: repeating-linear-gradient(
            -45deg,
            rgba(180, 190, 202, 0.22) 0,
            rgba(180, 190, 202, 0.22) 8px,
            rgba(40, 46, 54, 0.92) 8px,
            rgba(40, 46, 54, 0.92) 16px
        );
    }

    .battery-usable-zone {
        background: repeating-linear-gradient(
            -45deg,
            rgba(58, 132, 75, 0.78) 0,
            rgba(58, 132, 75, 0.78) 8px,
            rgba(28, 83, 43, 0.92) 8px,
            rgba(28, 83, 43, 0.92) 16px
        );
    }

    .battery-initial-fill {
        background: rgba(143, 209, 158, 0.22);
        border-top-color: rgba(155, 231, 172, 0.6);
    }

    .battery-derived-card strong,
    .battery-mini-card strong,
    .battery-side-labels strong {
        color: #f8fafc;
    }

    .power-mode-fieldset {
        border-color: #d7dde3;
        background:
            linear-gradient(135deg, rgba(143, 209, 158, 0.10), rgba(0, 0, 0, 0) 52%),
            #000000;
    }

    .power-mode-card {
        background: #050505;
        border-color: #d7dde3;
        color: #f8fafc;
        box-shadow: none;
    }

    .power-mode-card small {
        color: #b8c0cc;
    }

    .power-mode-option:hover .power-mode-card {
        border-color: #9be7ac;
        box-shadow: 0 8px 18px rgba(155, 231, 172, 0.10);
    }

    .power-mode-option input:focus-visible + .power-mode-card {
        outline-color: #ffff00;
    }

    .power-mode-option input:checked + .power-mode-card {
        border-color: #9be7ac;
        background:
            linear-gradient(135deg, rgba(155, 231, 172, 0.24), rgba(18, 53, 28, 0.72)),
            #12351c;
        box-shadow:
            0 10px 22px rgba(155, 231, 172, 0.10),
            inset 0 0 0 1px rgba(155, 231, 172, 0.22);
    }

    .power-mode-option input:checked + .power-mode-card::before {
        background: #9be7ac;
        color: #000000;
    }

    .battery-slider-row input[type="range"],
    .soc-slider-row input[type="range"] {
        accent-color: #9be7ac;
    }

    .soc-slider-panel {
        background: #000000;
        border-color: #d7dde3;
    }

    .soc-slider-label span {
        color: #b8c0cc;
    }

    .soc-slider-label strong {
        color: #f8fafc;
    }

.soc-slider-panel {
        background: #000000;
        border-color: #d7dde3;
    }

    .soc-slider-label span,
    .soc-slider-hint {
        color: #b8c2cc;
    }

    .soc-slider-label strong {
        color: #f8fafc;
    }

    .soc-range-track {
        background: #303947;
    }

    .soc-range-selected {
        background: #8fd19e;
        box-shadow: 0 0 18px rgba(143, 209, 158, 0.28);
    }

    .soc-range-input::-webkit-slider-thumb {
        border-color: #2f3944;
        background: #7c8792;
    }

    .soc-range-input::-moz-range-thumb {
        border-color: #2f3944;
        background: #7c8792;
    }

.battery-soc-range-track {
        background: #303947;
    }

    .battery-soc-range-selected {
        background: #8fd19e;
        box-shadow: 0 0 18px rgba(143, 209, 158, 0.32);
    }

    .battery-soc-range-input::-webkit-slider-thumb {
        border-color: #2f3944;
        background: #7c8792;
    }

    .battery-soc-range-input::-moz-range-thumb {
        border-color: #2f3944;
        background: #7c8792;
    }

    .battery-soc-range-input-initial::-webkit-slider-thumb,
    .battery-soc-range-input-initial::-moz-range-thumb {
        background: #ffff00;
    }

.control-section {
        background: #050505;
        border-color: #d7dde3;
    }

.visual-dispatch-action-row {
        border-top-color: #d7dde3;
    }

.dispatch-control-footer {
        border-top-color: #d7dde3;
    }

.config-action-separator {
        color: #b8c0cc;
    }

.market-input-section .historical-calendar {
        box-shadow:
            0 18px 44px rgba(0, 0, 0, 0.70),
            0 0 0 1px rgba(255, 255, 255, 0.10);
    }

.auth-modal {
        background:
            linear-gradient(135deg, rgba(255, 176, 46, 0.10), rgba(255, 255, 255, 0) 46%),
            #101417;
        color: #f8fafc;
        border-color: #d7dde3;
    }

    .auth-modal-header p,
    .auth-small-note {
        color: #b8c0cc;
    }

    .auth-tab {
        background: #050505;
        color: #f8fafc;
        border-color: #d7dde3;
    }

    .auth-tab.active {
        border-color: #ffb02e;
        background: rgba(255, 176, 46, 0.18);
        color: #ffb02e;
    }

    .auth-message {
        color: #8fd19e;
    }

    .auth-message.error {
        color: #ff8a80;
    }

.dispatch-table-details {
        border-color: #343d46;
    }
