/* M2PRO B.V. | Author: Codex | Service-wide accessible light/dark surfaces.
 * Explicit root selector overrides later tab CSS without altering page layout. */
:root { color-scheme: light; }
.theme-picker { display: flex; align-items: center; gap: .5rem; margin: 0; font-size: 13px; }
.theme-picker select { width: auto; margin: 0; padding: .4rem .55rem; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--ink); }
html[data-theme=dark] {
    color-scheme: dark;
    --ink: #e7e9ef; --muted: #b3bac9; --purple: #eda9df;
    --line: #414958; --surface: #202631; --bg: #151922;
    --teal: #71d5b6; --blue: #7ec7e1; --amber: #f1c675;
    --chart-1: #eca4df; --chart-2: #6cdbd1; --chart-3: #ffbf70;
    --chart-4: #99c4ff; --chart-5: #ff9cae; --chart-6: #a9d786;
    --chart-7: #c9b1ff; --chart-8: #c6cbd3;
}
html[data-theme=dark] body { color: var(--ink); background: var(--bg); }
html[data-theme=dark] :is(.card,.panel,.energy-panel,.charging-panel,.history-chart,.measurements,.settings-section,.product-intro,.log-detail-card,.bms-chart-box) { background: var(--surface); border-color: var(--line); }
html[data-theme=dark] :is(input,select,textarea,.settings-device) { color: var(--ink); background: #171d27; border-color: var(--line); accent-color: var(--purple); }
html[data-theme=dark] :is(input,select,textarea):disabled { color: var(--muted); background: #2c3340; }
html[data-theme=dark] :is(button,.system-tabs a[aria-current],.settings-categories a[aria-current],.history-ranges a[aria-current],.phase.active) { background: #833075; color: #fff; }
html[data-theme=dark] :is(.secondary,.history-legend button,.phase) { background: #303746; color: var(--ink); border-color: var(--line); }
html[data-theme=dark] #history-explorer .system-tabs button { background: #303746; color: var(--ink); border-color: var(--line); }
html[data-theme=dark] #history-explorer .system-tabs button[aria-pressed=true] { background: #833075; color: #fff; }
html[data-theme=dark] :is(.service-message,.log-detail-message,.log-detail-card h3,.log-detail-row:hover) { background: #382a3c; color: var(--ink); }
html[data-theme=dark] :is(.system-tabs,.settings-row,.log-detail-field,.settings-savebar,.firmware-remove form) { border-color: var(--line); }
html[data-theme=dark] :is(.history-controls label,#history-session-label,.history-readout,.log-detail-field small) { color: var(--muted); }
html[data-theme=dark] :is(.status-error,.errorlist,[role=alert],.service-form .errorlist,.settings-editor .errorlist) { color: #ffabb1; }
html[data-theme=dark] .log-io-state.is-active { background: #193f30; color: #9ce0b0; }
html[data-theme=dark] .log-io-state.is-inactive { background: #303641; color: #bdc3cc; }
html[data-theme=dark] .is-active .log-io-dot { background: #7bd698; }
html[data-theme=dark] :is(.history-plot svg text,#bms-chart text,.chart-label,.node-label,.node-value) { fill: var(--ink); }
html[data-theme=dark] :is(.node-unit,.node-note) { fill: var(--muted); }
html[data-theme=dark] :is(.history-grid,.chart-grid,#bms-chart line) { stroke: var(--line); }
html[data-theme=dark] .history-cursor { stroke: #ced6e4; }
html[data-theme=dark] .flow-node rect { fill: #28323f; stroke: #66768b; }
html[data-theme=dark] .flow-node.solar rect { fill: #3c3425; stroke: #a68a48; }
html[data-theme=dark] .flow-node.battery rect { fill: #263d34; stroke: #678b78; }
html[data-theme=dark] .flow-hub circle { fill: #833075; stroke: #392d40; }
html[data-theme=dark] .flow-icon { stroke: #b1c2d8; }
html[data-theme=dark] .storage-shell { fill: #233c30; }
html[data-theme=dark] .storage-empty { fill: #38482e; }
html[data-theme=dark] .storage-soc { fill: #b1e5b6; }
html[data-theme=dark] .brand { background: #fff; border-radius: 8px; padding: 6px 10px; }
html[data-theme=dark] .login img { background: #fff; padding: 8px; border-radius: 6px; }
html[data-theme=dark] :is(select,textarea,summary):focus-visible { outline: 3px solid var(--purple); outline-offset: 3px; }
/* Context 2026-11-13: brighter text accents are separate from dark purple
 * button fills. Original logo and authenticator QR keep white backing; never
 * invert artwork. SVG data geometry and status meanings remain unchanged. */

/* Readability review 2026-11-13: keep inactive labels legible without implying
 * interactivity; underline/grey/dashed styling also distinguishes their state. */
html[data-theme=dark] .history-legend button[aria-pressed=false] {
    opacity: 1; color: var(--muted); background: #303746;
    border-style: dashed; text-decoration: line-through;
}
html[data-theme=dark] button:disabled {
    opacity: 1; color: var(--muted); background: #303746;
    border: 1px solid var(--line); cursor: not-allowed;
}
html[data-theme=dark] nav.tabs a[aria-current] {
    color: var(--purple); border-bottom: 3px solid var(--green);
    font-weight: 700;
}
html[data-theme=dark] :is(input,textarea)::placeholder { color: var(--muted); opacity: 1; }
html[data-theme=dark] .history-plot path[stroke-opacity] { stroke-opacity: .65; }
html[data-theme=dark] #bms-chart line[stroke-dasharray] { stroke: #ced6e4; }
html[data-theme=dark] #bms-chart circle[fill="#b3261e"] { fill: #ffabb1; }
html[data-theme=dark] :is(.charger-body,.car-body) { fill: #303746; stroke: #a3afc1; }
html[data-theme=dark] .charger-screen { fill: #833075; }
html[data-theme=dark] .car-window { fill: #182a38; stroke: #92a4b8; }
html[data-theme=dark] .car-wheel { fill: #18212d; stroke: #a3afc1; }
html[data-theme=dark] .log-detail-message { border-left-color: var(--purple); }
/* Chart extrema retain identical coordinates; only opacity changes in dark.
 * Bright markers/cursor preserve error and selection visibility above grid. */
