:root {
    color-scheme: light;
    --ink: #152542;
    --muted: #536780;
    --canvas: #f2f5fa;
    --line: #dfe7f0;
    --panel: #fff;
    --blue: #1a5acd;
    --teal: #008574;
    --orange: #ba5a14;
    --navy: #11213d;
    font-family: Inter, system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--canvas); color: var(--ink); line-height: 1.5; }
button, select, input, textarea { font: inherit; }
a { color: inherit; }
.layout { min-height: 100vh; display: grid; grid-template-columns: 214px minmax(0, 1fr); }
.sidebar { background: var(--navy); color: #e3ebfa; padding: 29px 16px; display: flex; flex-direction: column; gap: 34px; position: sticky; top: 0; height: 100dvh; }
.brand { font-size: 1.18rem; font-weight: 780; letter-spacing: -.04em; display: inline-flex; align-items: center; text-decoration: none; gap: 9px; padding: 0 9px; }
.brand-light { color: #9dc9ff; }
.brand-icon { display: grid; place-items: center; height: 31px; width: 31px; border-radius: 9px; background: #d7eeff; color: #1855ac; font-size: 1.25rem; }
.sidebar nav { display: grid; gap: 5px; }
.sidebar nav a { color: #d3ddef; padding: 10px 11px; text-decoration: none; border-radius: 9px; font-size: .92rem; display: flex; align-items: center; gap: 10px; }
.sidebar nav a span { min-width: 16px; font-size: 1.04rem; }
.sidebar nav a:hover, .sidebar nav a.selected { background: #253c61; color: white; }
.session { margin-top: auto; padding: 9px; color: #c8d8f1; overflow-wrap: anywhere; }
.session button { margin-top: 3px; border: 0; background: transparent; color: inherit; padding: 4px 0; text-decoration: underline; }
.content { width: min(100%, 1510px); padding: 36px clamp(19px, 3vw, 44px) 50px; }
.page-header { display: flex; align-items: center; justify-content: space-between; gap: 15px; margin-bottom: 21px; }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(1.65rem, 3.5vw, 2.55rem); letter-spacing: -.045em; line-height: 1.12; }
h2 { font-size: 1.04rem; font-weight: 750; }
p { color: var(--muted); }
.page-header p, .panel-header p { margin-top: 5px; font-size: .9rem; }
.status-pill, .tag { font-size: .82rem; font-weight: 730; padding: 6px 11px; border-radius: 999px; border: 1px solid #b9d5f6; color: #225c9f; background: #eaf3ff; white-space: nowrap; }
.status-pill i { display: inline-block; background: currentColor; width: 7px; height: 7px; border-radius: 50%; margin-right: 7px; }
.status-pill.off { color: var(--muted); border-color: var(--line); background: white; }
.status-pill.active { color: var(--teal); background: #edfaf8; border-color: #b0ded7; }
.notice { display: flex; gap: 6px 15px; flex-wrap: wrap; align-items: baseline; background: #fff5df; border: 1px solid #efd69f; color: #714612; padding: 11px 15px; border-radius: 11px; margin: 0 0 18px; font-size: .89rem; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 13px; margin-bottom: 15px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 17px 19px; min-width: 0; }
.content > .panel, [data-dashboard-snapshot] > .panel { margin-bottom: 15px; }
.dashboard-refresh-status { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-bottom: 10px; font-size: .82rem; }
.dashboard-refresh-status [data-dashboard-refresh-target="notice"] { color: #885025; }
.stat { display: grid; gap: 6px; align-content: start; }
.stat h2 { color: var(--muted); font-size: .84rem; }
.stat strong { font-size: clamp(1.25rem, 2.4vw, 2rem); letter-spacing: -.055em; }
.stat span, .rows small { color: var(--muted); font-size: .78rem; }
#dashboard-current-tariff a { justify-self: start; color: #25548d; font-size: .78rem; }
.panel-header { display: flex; gap: 12px; justify-content: space-between; align-items: center; }
.switch { display: flex; gap: 7px; align-items: center; color: var(--muted); font-size: .84rem; }
button, select { cursor: pointer; }
input, textarea, select, button { border: 1px solid #cbd7e6; border-radius: 8px; padding: 6px 10px; background: white; color: var(--ink); }
:focus-visible { outline: 3px solid #3a86ed; outline-offset: 3px; }
.primary { background: var(--blue); border-color: var(--blue); color: white; font-weight: 650; }
.danger { color: #982a32; border-color: #e6bdc0; background: #fff4f4; }
.chart-scroll { overflow-x: auto; margin: 12px 0 4px; padding: 4px; }
.price-chart { display: flex; height: 182px; width: max-content; min-width: 100%; position: relative; align-items: stretch; background: repeating-linear-gradient(to bottom, transparent 0, transparent 31px, #edf2f9 31px, #edf2f9 32px); }
.price-chart::before { content: ''; position: absolute; top: 75px; width: 100%; border-top: 1px solid #aebfd5; }
.interval { min-width: 16px; flex: 1 0 16px; padding: 0; border: 0; border-radius: 0; position: relative; background: transparent; }
.interval.current { box-shadow: inset 0 2px 0 #326dc0; background: #e8efff; }
.interval:hover { background-color: #edf3ff; }
.interval[aria-pressed="true"] { background-color: #d8e6ff; }
.interval:focus-visible { z-index: 1; outline-offset: -2px; }
.interval .bar, .interval .interval-flag { display: block; position: absolute; inset-inline: 0; margin-inline: auto; width: min(calc(100% - 4px), 26px); }
.interval .bar { bottom: 107px; border-radius: 3px 3px 0 0; background: #9aaec8; }
.interval .bar.negative { top: 75px; bottom: auto; border-radius: 0 0 3px 3px; }
.interval .charge, .key.charge::before { background: var(--teal); }
.interval .discharge, .key.discharge::before { background: var(--orange); }
.interval .hold, .key.hold::before { background: #5c7da8; }
.interval .historic-plan, .key.historic-plan::before { outline: 1px dashed var(--navy); }
.interval .invalid, .key.invalid::before { background: #c2ccd9; }
.interval .blocked, .key.blocked::before { background: repeating-linear-gradient(135deg, #93582a 0 2px, #f8e8d9 2px 4px); }
.interval .blocked { bottom: 34px; height: 6px; border-radius: 2px; }
.interval .actual { bottom: 23px; height: 7px; border-radius: 2px; }
.interval .confirmed, .key.confirmed::before { background: var(--teal); }
.interval .unresolved:not(.confirmed), .key.unresolved::before { background: #8c5aa6; }
.interval .confirmed.unresolved { background: repeating-linear-gradient(135deg, var(--teal) 0 3px, #8c5aa6 3px 6px); }
.interval .booked { outline: 1px solid var(--navy); }
.tick { position: absolute; bottom: 1px; font-size: .6rem; white-space: nowrap; color: var(--muted); }
.legend { display: flex; flex-wrap: wrap; gap: 7px 17px; color: var(--muted); font-size: .8rem; }
.key::before { content: ''; display: inline-block; width: 9px; height: 9px; background: #9aaec8; border-radius: 2px; margin-right: 6px; }
.key.booked::before { background: white; outline: 1px solid var(--navy); }
.key.current::before { background: #d8e6ff; border-top: 2px solid #326dc0; }
.chart-detail { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr)); gap: 9px 16px; margin: 14px 0 6px; border-top: 1px solid var(--line); padding-top: 12px; font-size: .84rem; }
.chart-detail dt { color: var(--muted); }
.chart-detail dd { margin: 0; font-weight: 570; }
.plan-table .current-quarter { background: #edf3ff; }
.plan-table [data-historic-plan] td small { display: block; color: var(--muted); }
.empty-chart { display: grid; place-items: center; min-height: 152px; padding: 19px; margin: 15px 0; color: var(--muted); border-radius: 9px; border: 1px dashed #c6d2e4; text-align: center; }
.pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-bottom: 15px; }
.dashboard-operation { grid-column: 1 / -1; }
.dashboard-diagnostics { display: inline-block; margin-top: 12px; color: #25548d; font-size: .86rem; }
.rows { margin: 8px 0 0; }
.rows > div { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; border-bottom: 1px solid #edf2f7; padding: 8px 0; font-size: .86rem; }
.rows > div:last-child { border-bottom: 0; }
.rows dd { text-align: right; margin: 0; font-weight: 650; }
.rows small { display: block; font-weight: 400; }
.actions { display: flex; flex-wrap: wrap; gap: 7px; padding-top: 9px; font-size: .83rem; }
summary { cursor: pointer; color: #25548d; padding: 8px 0; font-size: .88rem; }
.table-scroll { overflow: auto; }
.cost-report-panel { display: grid; gap: 14px; }
.cost-report-header { flex-wrap: wrap; }
.cost-periods { display: flex; flex-wrap: wrap; gap: 4px; padding: 4px; background: #edf2f9; border-radius: 10px; }
.cost-periods a { display: block; padding: 7px 11px; border-radius: 7px; text-decoration: none; color: var(--ink); font-size: .86rem; font-weight: 650; }
.cost-periods a:hover { background: #dfeafd; }
.cost-periods a[aria-current="page"] { background: var(--blue); color: white; }
.cost-report-empty { padding: 23px 18px; border: 1px dashed #cbd7e6; border-radius: 10px; background: #f6f9fd; }
.cost-report-empty p, .cost-report-note { font-size: .86rem; color: var(--muted); }
.cost-report-empty p, .cost-report-note p { margin-top: 4px; }
.cost-report-note summary { cursor: pointer; color: #25548d; }
.cost-report-table td { font-variant-numeric: tabular-nums; }
.cost-report-table th { min-width: 7ch; white-space: normal; }
@media (max-width: 450px) { .cost-periods a { padding-inline: 8px; } }
table { border-collapse: collapse; width: 100%; font-size: .82rem; }
th, td { padding: 7px 9px; border-bottom: 1px solid var(--line); text-align: left; }
td:first-child, th { white-space: nowrap; }
.plan-comparison p { margin-top: 6px; font-size: .88rem; }
.plan-comparison .table-scroll { margin-top: 8px; }
.plan-comparison th[scope="row"] { font-weight: 620; white-space: normal; }
.plan-comparison th small { display: block; color: var(--muted); font-weight: 400; }
.plan-comparison td, .plan-comparison th[scope="col"]:not(:first-child) { text-align: right; }
.plan-comparison td { font-variant-numeric: tabular-nums; white-space: nowrap; }
.tariff-comparison .table-scroll, .tariff-comparison > p { margin-top: 8px; }
.tariff-comparison td:first-child { overflow-wrap: anywhere; white-space: normal; }
.tariff-comparison td small { display: block; color: var(--muted); }
.battery-soc { display: block; font-size: 2rem; margin: 9px 0 3px; }
meter { width: 100%; }
.config { display: grid; gap: 11px; }
.config > p { font-size: .88rem; }
textarea { width: 100%; font: .82rem/1.6 ui-monospace, monospace; min-height: 180px; tab-size: 4; }
.confirmation { display: flex; align-items: baseline; gap: 9px; font-size: .89rem; }
.config button { justify-self: start; }
.settings-form [hidden] { display: none; }
.settings-toolbar, .settings-footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; }
.settings-toolbar p, .settings-json p, .settings-hint { font-size: .86rem; }
.settings-editor { min-inline-size: 0; margin: 0; padding: 0; border: 0; }
.settings-screenreader { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.settings-section { border-block-start: 1px solid var(--line); }
.settings-section > summary { padding: 12px 4px; color: var(--ink); font-size: .96rem; font-weight: 720; }
.settings-section[open] { padding-bottom: 14px; }
.settings-hint { margin: 2px 0 10px; }
.settings-record { margin-bottom: 8px; padding: 0 10px; border: 1px solid var(--line); border-radius: 9px; background: #f9fbff; }
.settings-record > summary { color: var(--ink); font-weight: 620; overflow-wrap: anywhere; }
.settings-record[open] { padding-bottom: 10px; }
.settings-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 215px), 1fr)); gap: 10px 13px; margin-bottom: 9px; }
.settings-field { display: flex; flex-direction: column; justify-content: flex-end; gap: 4px; min-width: 0; font-size: .84rem; color: var(--ink); overflow-wrap: anywhere; }
.settings-field input:not([type="checkbox"]), .settings-field select { width: 100%; min-width: 0; }
.settings-field.settings-check { flex-direction: row-reverse; justify-content: flex-end; align-items: center; align-self: end; min-height: 36px; gap: 7px; }
.settings-add, .settings-remove, .settings-toolbar button { font-size: .84rem; }
.settings-json { display: grid; gap: 8px; }
.settings-json textarea { resize: vertical; }
.settings-footer { border-top: 1px solid var(--line); padding-top: 12px; }
.flash { padding: 9px 14px; border-radius: 9px; margin-bottom: 12px; background: #e5f7ee; color: #246648; }
.flash.error { background: #feeaed; color: #922732; }
.auth { min-height: 100dvh; width: 100%; display: grid; place-items: center; padding: 18px; }
.login { display: grid; width: min(100%, 375px); gap: 14px; padding: 27px; box-shadow: 0 12px 45px #18375b18; }
.login label { display: grid; gap: 4px; }
.login h1 { font-size: 1.8rem; }
.login input { width: 100%; }
@media (max-width: 1050px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 740px) {
    .layout { display: block; }
    .sidebar { height: auto; position: static; padding: 12px; display: grid; grid-template-columns: 1fr auto; gap: 10px; }
    .session { margin: 0; display: flex; align-items: baseline; gap: 9px; padding: 2px; }
    .sidebar nav { display: flex; grid-row: 2; grid-column: 1 / -1; overflow-x: auto; }
    .sidebar nav a { padding: 7px 8px; white-space: nowrap; font-size: .8rem; }
    .content { padding-top: 22px; }
    .pair { grid-template-columns: minmax(0,1fr); }
    .panel { padding: 13px; }
    .chart-panel .panel-header { flex-direction: column; align-items: flex-start; }
}
@media (max-width: 380px) {
    .content { padding-inline: 10px; }
    .session > span, .sidebar nav a span { display: none; }
    .switch { display: grid; }
}

.manual-battery-schedule { margin-top: 1rem; }
.manual-battery-schedule summary { cursor: pointer; }
.manual-battery-fields { display: flex; flex-wrap: wrap; align-items: end; gap: .75rem; margin: .75rem 0; }
.manual-battery-fields label { display: grid; gap: .25rem; min-width: 0; }
.manual-battery-windows { display: grid; gap: .75rem; margin-bottom: 0; padding: 0; list-style: none; }
.manual-battery-windows li { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .75rem; padding: .75rem 0; border-top: 1px solid var(--line); }
.manual-battery-windows span { display: block; font-size: .9rem; }
