:root {
    --bg: #fbfaf8;
    --fg: #1d1d1f;
    --muted: #5f5f66;
    --rule: #e4e1dc;
    --accent: #0a66c2;
    --accent-fg: #ffffff;
    /* The price chart: energy.js reads these, and redraws when the scheme changes. */
    --chart-bar: #0a66c2;
    --chart-past: #b9c6d6;
    --chart-now: #c2410c;
    --chart-band: rgba(10, 102, 194, 0.16);
    /* One per supplier, in the API's order; all eight validated for CVD separation on --bg. */
    --series-1: #2a78d6;
    --series-2: #eb6834;
    --series-3: #1baf7a;
    --series-4: #eda100;
    --series-5: #e87ba4;
    --series-6: #008300;
    --series-7: #6250d6;
    --series-8: #e34948;
    color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #141416;
        --fg: #ececee;
        --muted: #a0a0a8;
        --rule: #2c2c31;
        --accent: #4f9be8;
        --accent-fg: #0b1220;
        --chart-bar: #4f9be8;
        --chart-past: #3a4250;
        --chart-now: #fb923c;
        --chart-band: rgba(79, 155, 232, 0.22);
        --series-1: #3987e5;
        --series-2: #d95926;
        --series-3: #199e70;
        --series-4: #c98500;
        --series-5: #d55181;
        --series-6: #008300;
        --series-7: #9085e9;
        --series-8: #e66767;
    }
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--fg);
    font: 1.0625rem/1.65 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

[hidden] {
    display: none !important;
}

main {
    flex: 1;
    width: 100%;
    max-width: 40rem;
    margin: 0 auto;
    padding: clamp(3rem, 12vh, 7rem) 1rem 3rem;
}

main.wide {
    max-width: 60rem;
}

header {
    margin-bottom: 2.5rem;
}

h1 {
    font-size: clamp(2.25rem, 7vw, 3.25rem);
    line-height: 1.1;
    letter-spacing: -0.02em;
    margin: 0;
}

h2 {
    font-size: 0.8125rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
    margin: 0 0 0.75rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--rule);
}

section {
    margin-bottom: 2.5rem;
}

p {
    margin: 0 0 1rem;
}

.headline {
    font-size: 1.25rem;
    color: var(--muted);
    margin: 0.5rem 0 0;
}

a {
    color: var(--accent);
    text-underline-offset: 0.15em;
}

a:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
    border-radius: 2px;
}

.button {
    display: inline-block;
    padding: 0.6rem 1.1rem;
    border-radius: 0.5rem;
    background: var(--accent);
    color: var(--accent-fg);
    font-weight: 600;
    text-decoration: none;
}

.button:hover {
    filter: brightness(1.08);
}

footer {
    max-width: 40rem;
    width: 100%;
    margin: 0 auto;
    padding: 1.5rem 1rem 2rem;
    font-size: 0.875rem;
    color: var(--muted);
}

footer a {
    color: inherit;
}

.status,
.note {
    color: var(--muted);
    font-size: 0.9375rem;
}

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
    gap: 0.75rem;
    margin: 0 0 1.25rem;
}

.stats div {
    border: 1px solid var(--rule);
    border-radius: 0.5rem;
    padding: 0.6rem 0.8rem;
}

.stats dt {
    font-size: 0.8125rem;
    color: var(--muted);
}

.stats dd {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.stats dd small {
    font-size: 0.8125rem;
    font-weight: 400;
    color: var(--muted);
}

/* Chart.js sizes the canvas to this box (responsive, no fixed aspect ratio). */
.chart {
    position: relative;
    height: clamp(16rem, 45vh, 24rem);
    margin: 0 0 1rem;
}

.table-scroll {
    overflow-x: auto;
    margin: 0 0 1rem;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9375rem;
    font-variant-numeric: tabular-nums;
}

th,
td {
    text-align: left;
    padding: 0.5rem 0.75rem 0.5rem 0;
    border-bottom: 1px solid var(--rule);
    white-space: nowrap;
}

th {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--muted);
}
