:root {
    --bg: #f4f6f8;
    --card: #ffffff;
    --surface: #edf2f7;
    --surface-hover: #e2e8f0;
    --input-bg: #ffffff;
    --primary: #2b6cb0;
    --primary-dark: #234e7d;
    --danger: #c53030;
    --danger-dark: #9b2c2c;
    --border: #e2e8f0;
    --text: #1a202c;
    --muted: #718096;
    --topbar: #2b6cb0;
    --topbar-text: #ffffff;
    --shadow: rgba(0, 0, 0, 0.06);
    --backdrop: rgba(0, 0, 0, 0.45);
    --accent: #eb4b19;
    --accent-hover: #cf3c10;
    --solar: #23b95a;
    --grid: #2378c9;
    --gauge-track: #d8dde3;
    --gauge-neutral: #9aa3ad;
    color-scheme: light;
}

:root[data-theme="dark"] {
    --bg: #111315;
    --card: #1b1e21;
    --surface: #292d31;
    --surface-hover: #353a40;
    --input-bg: #23272b;
    --primary: #3182ce;
    --primary-dark: #2b6cb0;
    --danger: #e05252;
    --danger-dark: #c53030;
    --border: #353a40;
    --text: #f7fafc;
    --muted: #a0aec0;
    --topbar: #181b1e;
    --topbar-text: #f7fafc;
    --shadow: rgba(0, 0, 0, 0.3);
    --backdrop: rgba(0, 0, 0, 0.7);
    --accent: #f04a17;
    --accent-hover: #ff5b28;
    --solar: #4ade72;
    --grid: #55a8f5;
    --gauge-track: #d7d9dc;
    --gauge-neutral: #6b7480;
    color-scheme: dark;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: var(--topbar);
    color: var(--topbar-text);
    border-bottom: 1px solid transparent;
}

.topbar h1 { margin: 0; font-size: 1.25rem; }

.topbar-actions { display: flex; align-items: center; gap: 1rem; }

.session { display: flex; align-items: center; gap: 1rem; font-size: 0.9rem; }

.theme-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    background: rgba(255, 255, 255, 0.14);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: var(--topbar-text);
}

.theme-toggle:hover { background: rgba(255, 255, 255, 0.24); }
.theme-toggle-icon { font-size: 1.15rem; line-height: 1; }

main {
    max-width: 1540px;
    margin: 1.25rem auto 3rem;
    padding: 0 1.25rem;
}

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 1px 3px var(--shadow);
}

.login-card { max-width: 360px; margin: 4rem auto; }

.section-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

h2 { margin-top: 0; }

label {
    display: block;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    color: var(--muted);
}

input, select {
    display: block;
    width: 100%;
    margin-top: 0.35rem;
    padding: 0.55rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 1rem;
    background: var(--input-bg);
    color: var(--text);
}

button {
    cursor: pointer;
    border: none;
    border-radius: 6px;
    padding: 0.55rem 1rem;
    font-size: 0.95rem;
    background: var(--primary);
    color: #fff;
}
button:hover { background: var(--primary-dark); }
button:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-secondary { background: var(--surface); color: var(--text); }
.btn-secondary:hover { background: var(--surface-hover); }

.btn-danger { background: var(--danger); }
.btn-danger:hover { background: var(--danger-dark); }

table.users {
    width: 100%;
    border-collapse: collapse;
}

table.users th, table.users td {
    text-align: left;
    padding: 0.6rem 0.5rem;
    border-bottom: 1px solid var(--border);
}

table.users th { color: var(--muted); font-size: 0.8rem; text-transform: uppercase; }

.actions { display: flex; gap: 0.5rem; justify-content: flex-end; }

.empty { text-align: center; color: var(--muted); padding: 1.5rem 0; }

.error {
    color: var(--danger);
    font-size: 0.9rem;
    margin: 0.5rem 0;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: var(--backdrop);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal { width: 100%; max-width: 420px; }

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

/* Navigation par onglets */
.tabs { display: flex; gap: 0.5rem; margin-bottom: 1rem; }
.tabs button { border: 1px solid transparent; }
.tabs button.active { background: var(--accent); color: #fff; }
.tabs button.active:hover { background: var(--accent-hover); }

/* Historique énergétique */
.history-card h2 { margin-bottom: 0; }
.history-table-wrapper {
    max-height: none;
    overflow: visible;
}

.history-toolbar {
    display: flex;
    align-items: flex-end;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.history-period {
    min-width: 210px;
    margin: 0;
}

.history-period span {
    display: block;
    margin-bottom: 0.35rem;
    font-size: 0.75rem;
    font-weight: 600;
}

.history-period select { margin: 0; }
.history-display-modes {
    display: flex;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 6px;
}

.history-display-modes button {
    min-height: 39px;
    border-radius: 0;
    border-right: 1px solid var(--border);
}

.history-display-modes button:last-child { border-right: 0; }
.history-display-modes button.active { background: var(--accent); color: #fff; }

.history-table {
    width: 100%;
    border-collapse: collapse;
}

.history-table th,
.history-table td {
    padding: 0.9rem 0.75rem;
    border-bottom: 1px solid var(--border);
    text-align: right;
}

.history-table th {
    color: var(--muted);
    font-size: 0.75rem;
    text-transform: uppercase;
}

.history-table th:first-child,
.history-table td:first-child {
    text-align: left;
}

.history-table tbody tr:last-child td { border-bottom: 0; }
.history-table tfoot th,
.history-table tfoot td {
    border-top: 2px solid var(--border);
    border-bottom: 0;
    background: var(--surface);
    font-weight: 700;
}

.history-table tfoot th { text-align: left; }
.history-solar { color: var(--solar); font-weight: 600; }
.history-grid { color: var(--grid); font-weight: 600; }

.history-chart-panel {
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 6px;
}

.history-chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border);
    color: var(--muted);
    font-size: 0.75rem;
}

.history-chart-legend span { display: inline-flex; align-items: center; gap: 0.35rem; }
.history-chart-legend i { width: 0.7rem; height: 0.7rem; border-radius: 2px; }
.history-chart-legend .solar,
.history-bar.solar { background: var(--solar); }
.history-chart-legend .eco,
.history-bar.eco { background: var(--accent); }
.history-chart-legend .grid,
.history-bar.grid { background: var(--grid); }

.history-chart-scroll {
    overflow-x: auto;
    overflow-y: hidden;
    padding: 1rem 0.8rem 0.4rem;
}

.history-chart {
    display: grid;
    grid-template-columns: repeat(var(--history-days), minmax(34px, 1fr));
    height: 330px;
    border-bottom: 1px solid var(--border);
}

.history-chart-day {
    display: grid;
    grid-template-rows: 1fr 2rem;
    min-width: 0;
}

.history-bars {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 2px;
    min-height: 0;
    padding: 0 3px;
    border-bottom: 1px solid var(--border);
    background-image: linear-gradient(to top, var(--border) 1px, transparent 1px);
    background-size: 100% 25%;
}

.history-bar {
    width: 28%;
    min-height: 1px;
    border-radius: 2px 2px 0 0;
    transition: opacity 0.15s ease;
}

.history-bar:hover { opacity: 0.72; }
.history-chart-day small {
    padding-top: 0.45rem;
    color: var(--muted);
    font-size: 0.62rem;
    text-align: center;
    white-space: nowrap;
    transform: rotate(-45deg);
}

.history-chart-totals {
    display: grid;
    grid-template-columns: 1fr repeat(3, minmax(0, 1fr));
    gap: 0.75rem;
    padding: 1rem;
    background: var(--surface);
    text-align: right;
}

.history-chart-totals strong { text-align: left; }
.history-total-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.history-total-item small {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.35rem;
    color: var(--muted);
    font-size: 0.68rem;
}

.history-total-item i {
    width: 0.6rem;
    height: 0.6rem;
    border-radius: 2px;
}

.history-total-item i.solar { background: var(--solar); }
.history-total-item i.eco { background: var(--accent); }
.history-total-item i.grid { background: var(--grid); }

.history-line-scroll {
    overflow-x: auto;
    overflow-y: hidden;
    padding: 1rem 0.8rem 0.4rem;
}

.history-line-chart { overflow: hidden; }

.history-line-chart svg {
    display: block;
    width: 100%;
    height: 280px;
    overflow: hidden;
}

.history-line-grid {
    stroke: var(--border);
    stroke-width: 1;
    vector-effect: non-scaling-stroke;
}

.history-line {
    fill: none;
    stroke-width: 3;
    stroke-linecap: round;
    stroke-linejoin: round;
    vector-effect: non-scaling-stroke;
}

.history-line.solar { stroke: var(--solar); }
.history-line.eco { stroke: var(--accent); }
.history-line.grid { stroke: var(--grid); }
.history-point {
    stroke: var(--card);
    stroke-width: 2;
    vector-effect: non-scaling-stroke;
}
.history-point.solar { fill: var(--solar); }
.history-point.eco { fill: var(--accent); }
.history-point.grid { fill: var(--grid); }

.history-line-labels {
    display: grid;
    height: 2rem;
}

.history-line-labels small {
    padding-top: 0.45rem;
    color: var(--muted);
    font-size: 0.62rem;
    text-align: center;
    white-space: nowrap;
    transform: rotate(-45deg);
}

.annual-history {
    margin-top: 1.25rem;
    overflow-x: auto;
    overflow-y: hidden;
    border: 1px solid var(--border);
    border-radius: 6px;
}

.annual-history-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem;
    border-bottom: 1px solid var(--border);
}

.annual-history-head h3 { margin: 0; }
.annual-history-controls {
    display: flex;
    align-items: flex-end;
    gap: 0.75rem;
}

.annual-history-controls label {
    min-width: 170px;
    margin: 0;
}

.annual-history-controls label span {
    display: block;
    margin-bottom: 0.35rem;
    font-size: 0.75rem;
    font-weight: 600;
}

.annual-history-controls select { margin: 0; }

.annual-chart {
    display: grid;
    grid-template-columns: repeat(12, minmax(54px, 1fr));
    min-width: 760px;
    height: 350px;
    padding: 1rem 0.8rem 0.5rem;
    overflow-x: hidden;
    overflow-y: hidden;
}

.annual-chart-month {
    display: grid;
    grid-template-rows: 1fr 2.4rem;
    min-width: 0;
}

.annual-chart-month small,
.annual-line-labels small {
    align-self: start;
    padding-top: 0.6rem;
    color: var(--muted);
    font-size: 0.68rem;
    text-align: center;
    text-transform: capitalize;
    white-space: nowrap;
}

.annual-line-chart {
    min-width: 760px;
    padding: 1rem 0.8rem 0.5rem;
    overflow: hidden;
}

.annual-line-chart svg {
    display: block;
    width: 100%;
    height: 280px;
}

.annual-line-labels {
    display: grid;
    grid-template-columns: repeat(12, minmax(54px, 1fr));
    overflow: hidden;
}

.annual-totals {
    min-width: 760px;
    border-top: 1px solid var(--border);
}

/* Tableau de bord */
.dashboard-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.dashboard-heading h2 { margin: 0; font-size: 1.45rem; }

.eyebrow {
    margin: 0 0 0.25rem;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.sse-state {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 600;
}

.status-dot {
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    background: var(--muted);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--muted) 15%, transparent);
}

.sse-state.on { color: var(--solar); }
.sse-state.on .status-dot {
    background: var(--solar);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--solar) 15%, transparent);
}

.panel {
    min-width: 0;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 4px;
    box-shadow: 0 1px 4px var(--shadow);
}

.overview-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1rem;
}

.status-panel {
    display: flex;
    flex-direction: column;
    min-height: 315px;
    padding: 1.5rem 0 0;
    overflow: hidden;
}

.mode-title {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 0 1.25rem;
    font-size: 1.15rem;
}

.battery-icon {
    position: relative;
    display: inline-block;
    width: 28px;
    height: 14px;
    padding: 2px;
    border: 2px solid var(--text);
    border-radius: 2px;
}

.battery-icon::after {
    position: absolute;
    top: 3px;
    right: -5px;
    width: 3px;
    height: 6px;
    border-radius: 0 2px 2px 0;
    background: var(--text);
    content: "";
}

.battery-icon span { display: block; width: 62%; height: 100%; background: var(--solar); }

.clock {
    display: flex;
    flex: 1;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.clock > span { font-size: clamp(2rem, 3vw, 2.7rem); font-weight: 300; letter-spacing: -0.04em; }
.clock small { margin-top: 0.25rem; font-size: 1rem; }

.energy-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    border-top: 1px solid var(--border);
}

.energy-stats div {
    min-width: 0;
    padding: 0.9rem 0.65rem 1rem;
    text-align: center;
}

.energy-stats div + div { border-left: 1px solid var(--border); }
.energy-stats span { display: block; color: var(--muted); font-size: 0.68rem; font-weight: 700; }
.energy-stats strong { display: block; margin-top: 0.55rem; font-size: 1rem; font-weight: 500; }

.gauge-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 315px;
    padding: 1.1rem 0.9rem 0.85rem;
}

.gauge-panel h3,
.charging-panel > h3,
.portal-panel > h3 {
    align-self: stretch;
    margin: 0;
    padding: 0 0 0.75rem;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    font-size: 0.78rem;
    letter-spacing: 0;
    text-transform: none;
}

.gauge {
    --gauge-color: var(--solar);
    position: relative;
    display: grid;
    width: min(210px, 78%);
    aspect-ratio: 1;
    margin: 1rem auto 0.65rem;
    place-items: center;
    border-radius: 50%;
    background: conic-gradient(var(--gauge-color) var(--gauge-value), var(--gauge-track) 0);
}

.gauge::before {
    position: absolute;
    width: 80%;
    height: 80%;
    border-radius: 50%;
    background: var(--card);
    content: "";
}

.gauge-battery { --gauge-color: var(--accent); }
.gauge-solar { --gauge-color: var(--solar); }
.gauge-use { --gauge-color: #08c51a; }

.gauge-center {
    position: relative;
    z-index: 1;
    font-size: clamp(1.65rem, 2.5vw, 2.2rem);
    font-weight: 400;
}

.gauge-panel > small { color: var(--muted); text-align: center; }

.panel-error { margin: 1rem 0 0; padding: 0.8rem 1rem; }

.control-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.charging-panel {
    grid-column: 1 / span 2;
    padding: 1.1rem 0.9rem 1rem;
}

.charging-head {
    display: flex;
    align-items: center;
    min-height: 150px;
}

.power-button {
    display: flex;
    width: 108px;
    height: 52px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.05rem;
    background: var(--surface);
    color: var(--muted);
}

.power-button:hover { background: var(--surface-hover); }
.power-button.active { background: var(--accent); color: #fff; }
.power-button.active:hover { background: var(--accent-hover); }
.power-symbol { font-size: 1.2rem; line-height: 1; }
.power-button small { font-size: 0.5rem; font-weight: 700; }

.solar-hero {
    position: relative;
    display: flex;
    flex: 1;
    align-items: center;
    justify-content: center;
    gap: 2rem;
    color: var(--solar);
}

.mode-icon { font-size: clamp(4rem, 8vw, 7rem); line-height: 1; }
.solar-hero div { display: flex; flex-direction: column; }
.solar-hero strong { font-size: clamp(2.4rem, 5vw, 4.4rem); font-weight: 400; line-height: 1; text-transform: lowercase; }
.solar-hero small { margin-top: 1.1rem; font-size: 0.95rem; text-transform: uppercase; }
.solar-hero.grid { color: var(--grid); }
.solar-hero.stopped,
.solar-hero.starting { color: var(--danger); }

.startup-count {
    position: absolute;
    right: 0;
    font-size: clamp(3.5rem, 7vw, 6rem) !important;
    font-weight: 300 !important;
}

.wallbox-settings.hidden {
    visibility: hidden;
    pointer-events: none;
}

.segment-group {
    display: flex;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 3px;
}

.segment-group button {
    min-width: 0;
    flex: 1;
    border-radius: 0;
    background: transparent;
    color: var(--text);
}

.segment-group button + button { border-left: 1px solid var(--border); }
.segment-group button:hover { background: var(--surface); }
.segment-group button.active { background: var(--accent); color: #fff; }
.segment-group button.active:hover { background: var(--accent-hover); }

.charge-types button {
    display: flex;
    min-height: 52px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.15rem;
    font-size: 0.58rem;
}

.charge-types button span { font-size: 1rem; }

.control-section { margin-top: 0.9rem; }

.control-section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.55rem;
}

.control-section-title span { font-size: 0.92rem; }
.control-section-title strong { color: var(--solar); font-size: 0.85rem; font-weight: 600; }
.power-options button { padding: 0.45rem 0.35rem; font-size: 0.72rem; }

.mode-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
    width: 48%;
    margin: 0.9rem 0 0 auto;
}

.mode-button {
    display: flex;
    min-height: 50px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}

.mode-button:hover { background: var(--surface); }
.mode-button.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.mode-button small { margin-top: 0.2rem; font-size: 0.55rem; }

.range-row { display: flex; align-items: center; gap: 0.85rem; }
.range-row input[type="range"] { flex: 1; margin: 0; padding: 0; accent-color: var(--accent); }
.battery-level > small { display: block; margin-top: 0.45rem; }

.portal-panel {
    grid-column: 3;
    display: flex;
    flex-direction: column;
    padding: 1.1rem 0.9rem 1rem;
}

.reserved-panel {
    grid-column: 4;
}

.portal-action {
    display: flex;
    flex: 1;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
}

.portal-button {
    display: flex;
    min-width: 260px;
    min-height: 96px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    padding: 1.25rem 2rem;
    background: var(--accent);
    color: #fff;
}

.portal-button:hover { background: var(--accent-hover); }
.portal-icon { font-size: 2rem; line-height: 1; }
.portal-action small { color: var(--muted); text-align: center; }

.muted { color: var(--muted); }

@media (max-width: 1150px) {
    .overview-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .control-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .charging-panel { grid-column: 1 / -1; }
    .portal-panel { grid-column: 1; }
    .reserved-panel { grid-column: 2; }
}

@media (max-width: 640px) {
    .topbar { align-items: flex-start; }
    .topbar-actions { align-items: flex-end; flex-direction: column; gap: 0.65rem; }
    .session { align-items: flex-end; flex-direction: column; gap: 0.5rem; }
    .theme-toggle span:last-child { display: none; }
    main { margin-top: 0.8rem; padding: 0 0.65rem; }
    .dashboard-heading { align-items: flex-start; }
    .overview-grid { grid-template-columns: 1fr; }
    .control-grid { grid-template-columns: 1fr; }
    .charging-panel,
    .portal-panel,
    .reserved-panel { grid-column: 1; }
    .status-panel, .gauge-panel { min-height: 285px; }
    .charging-head { flex-direction: column-reverse; padding: 0.5rem 0; }
    .power-button { align-self: flex-start; }
    .solar-hero { width: 100%; gap: 1rem; }
    .charge-types { flex-direction: column; }
    .charge-types button + button { border-top: 1px solid var(--border); border-left: 0; }
    .mode-row { width: 100%; }
    .portal-button { width: 100%; min-width: 0; }

    .history-card { padding: 1rem; }
    .history-toolbar { align-items: stretch; flex-direction: column; }
    .history-period { width: 100%; min-width: 0; }
    .history-display-modes { width: 100%; }
    .history-display-modes button { flex: 1; }
    .history-table thead { display: none; }
    .history-table,
    .history-table tbody,
    .history-table tr,
    .history-table td { display: block; width: 100%; }
    .history-table tr {
        padding: 0.7rem 0;
        border-bottom: 1px solid var(--border);
    }
    .history-table tr:last-child { border-bottom: 0; }
    .history-table td {
        display: flex;
        justify-content: space-between;
        gap: 1rem;
        padding: 0.4rem 0;
        border: 0;
        text-align: right;
    }
    .history-table td::before {
        color: var(--muted);
        content: attr(data-label);
        font-size: 0.78rem;
        font-weight: 600;
        text-align: left;
    }
    .history-table td.empty { display: block; text-align: center; }
    .history-table td.empty::before { content: none; }
    .history-table tfoot {
        display: block;
        margin-top: 0.5rem;
        padding: 0.6rem 0;
        border-top: 2px solid var(--border);
        background: var(--surface);
    }
    .history-table tfoot tr,
    .history-table tfoot th,
    .history-table tfoot td {
        display: flex;
        width: 100%;
        border: 0;
        background: transparent;
    }
    .history-table tfoot tr { flex-direction: column; }
    .history-table tfoot th,
    .history-table tfoot td { justify-content: space-between; padding: 0.4rem 0.6rem; }
    .history-table tfoot td::before { color: var(--muted); font-size: 0.78rem; }
    .history-table tfoot td:nth-child(2)::before { content: "Production solaire"; }
    .history-table tfoot td:nth-child(3)::before { content: "Consommation éco"; }
    .history-table tfoot td:nth-child(4)::before { content: "Consommation réseau"; }
    .history-chart { height: 280px; }
    .history-chart-totals {
        grid-template-columns: 1fr;
        text-align: left;
    }
    .history-total-item small { justify-content: flex-start; }
    .history-line-chart svg { height: 240px; }
    .annual-history-head,
    .annual-history-controls {
        align-items: stretch;
        flex-direction: column;
    }
    .annual-history-controls label { width: 100%; min-width: 0; }
    .annual-history {
        overflow-x: auto;
    }
    .annual-history-head,
    .annual-history > .history-chart-legend {
        position: sticky;
        left: 0;
        min-width: calc(100vw - 3.3rem);
        background: var(--card);
        z-index: 1;
    }
}
