:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f3f2ee;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, .10);
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 8px 24px rgba(0, 0, 0, .04);
  --s1: #2a78d6;   /* bleu   — DC, MPPT 1, L1, 1re année */
  --s2: #eb6834;   /* orange — production AC, MPPT 2, L2 */
  --s3: #1baf7a;   /* aqua   — L3 */
  --s4: #eda100;   /* jaune */
  --accent: #eb6834;
  --accent-track: #fbe1d6;
  --heat-0: #fdf3ee;
  --heat-1: #f6b393;
  --heat-2: #eb6834;
  --heat-3: #9c3b12;
  --good: #0ca30c;
  --good-text: #006300;
  --bad-text: #b42828;
  --warning: #fab219;
  --critical: #d03b3b;
  --radius: 16px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--page);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
main, .top, footer { max-width: 1240px; margin: 0 auto; padding: 0 24px; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 18px; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 17px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
h3 { font-size: 14px; font-weight: 600; color: var(--text-2); margin-bottom: 8px; }
.sub { color: var(--muted); font-size: 13px; font-weight: 400; }
.label { color: var(--text-2); font-size: 13px; }
.muted { color: var(--muted); }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* En-tête */
.top { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-top: 28px; padding-bottom: 20px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-icon { width: 36px; height: 36px; color: var(--accent); padding: 6px; background: var(--accent-track); border-radius: 10px; }
.brand-icon circle { fill: currentColor; stroke: none; }
.top-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border-radius: 999px;
        background: var(--surface); border: 1px solid var(--border); font-size: 13px; color: var(--text-2); }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.chip.on .dot { background: var(--good); box-shadow: 0 0 0 4px color-mix(in srgb, var(--good) 20%, transparent); animation: pulse 2s infinite; }
.chip.off .dot { background: var(--critical); }
.chip-warning { cursor: help; }
.chip-warning svg { width: 14px; height: 14px; }
.chip-warning svg path:first-child { fill: var(--warning); stroke: var(--warning); stroke-width: 1.5; }
.chip-warning svg .ink { stroke: #0b0b0b; stroke-width: 1.6; }
@keyframes pulse { 50% { box-shadow: 0 0 0 7px color-mix(in srgb, var(--good) 0%, transparent); } }
@media (prefers-reduced-motion: reduce) { .chip.on .dot, .spinner { animation: none !important; } }

button { font: inherit; color: inherit; cursor: pointer; }
.icon-btn { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 9px;
            background: var(--surface); border: 1px solid var(--border); color: var(--text-2); }
.icon-btn:hover, .ghost:hover { background: var(--surface-2); color: var(--text); }
.icon-btn:disabled { opacity: .35; cursor: default; background: var(--surface); }
.ghost { height: 32px; padding: 0 12px; border-radius: 9px; background: transparent; border: 1px solid var(--border); color: var(--text-2); font-size: 13px; }
.ghost[aria-pressed="true"] { background: var(--surface-2); color: var(--text); }
.icon-text { display: inline-flex; align-items: center; gap: 6px; }
.icon-text svg { width: 15px; height: 15px; }
.date-input { height: 32px; padding: 0 8px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface);
              color: var(--text); font: inherit; font-size: 13px; }
:focus-visible { outline: 2px solid var(--s1); outline-offset: 2px; }

/* Cartes */
main { display: flex; flex-direction: column; gap: 16px; padding-bottom: 32px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); min-width: 0; position: relative; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.nav { display: flex; gap: 4px; align-items: center; }
.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-2); border-radius: 10px; }
.seg button { border: 0; background: transparent; height: 26px; padding: 0 12px; border-radius: 7px; font-size: 13px; color: var(--text-2); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.12); font-weight: 550; }

/* Chargement / erreur */
.spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--grid); border-top-color: var(--accent);
           animation: spin .8s linear infinite; display: none; }
[aria-busy="true"] .spinner { display: inline-block; }
[aria-busy="true"] .chart { opacity: .45; transition: opacity .2s; }
@keyframes spin { to { transform: rotate(360deg); } }
.err { display: flex; gap: 12px; align-items: center; justify-content: center; padding: 12px; margin-top: 8px;
       border-radius: 10px; background: color-mix(in srgb, var(--critical) 8%, var(--surface)); color: var(--bad-text); font-size: 13.5px; }
.err[hidden] { display: none; }
.err button { height: 28px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: 13px; }

/* Héros */
.hero { display: grid; grid-template-columns: minmax(260px, 1fr) 2fr; gap: 28px; align-items: center; padding: 28px; }
.hero-value { font-size: 64px; font-weight: 650; letter-spacing: -.03em; line-height: 1.05; margin: 4px 0 16px; }
.hero-value small { font-size: 22px; font-weight: 500; color: var(--text-2); margin-left: 6px; letter-spacing: 0; }
.meter { height: 8px; border-radius: 999px; background: var(--accent-track); overflow: hidden; }
.meter-fill { height: 100%; width: 0; border-radius: 999px; background: var(--accent); transition: width .8s ease; }
.meter-caption { color: var(--muted); font-size: 13px; margin-top: 8px; }
.hero-facts { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; font-size: 13.5px; color: var(--text-2); }
.hero-facts li { display: flex; gap: 8px; align-items: center; }
.hero-facts svg { width: 16px; height: 16px; color: var(--muted); flex: none; }
.hero-facts b { color: var(--text); font-weight: 600; }
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.tile { background: var(--surface-2); border-radius: 12px; padding: 14px 16px; min-width: 0; position: relative; }
.tile .value { font-size: 24px; font-weight: 600; letter-spacing: -.02em; margin: 2px 0; white-space: nowrap; }
.tile .value small { font-size: 14px; font-weight: 500; color: var(--text-2); margin-left: 3px; }
.tile-fc .value .wx { font-size: 18px; margin-right: 6px; }
.delta { font-size: 12.5px; color: var(--text-2); }
.delta.up { color: var(--good-text); }
.delta.down { color: var(--bad-text); }
.spark { stroke: none; display: block; width: 100%; height: 28px; margin-top: 8px; overflow: visible; }

/* Graphiques */
.chart { width: 100%; height: 300px; }
.chart.tall { height: 340px; }
.chart.small { height: 200px; }
.section-title { margin-top: 12px; display: flex; gap: 10px; align-items: baseline; }
.grid-4 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }

.empty[hidden] { display: none; }
.empty { height: 300px; display: grid; place-items: center; text-align: center; color: var(--text-2); font-size: 14px; padding: 0 24px; }
.table-wrap { max-height: 320px; overflow: auto; border-top: 1px solid var(--grid); }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 8px 4px; border-bottom: 1px solid var(--grid); }
th { color: var(--muted); font-weight: 500; position: sticky; top: 0; background: var(--surface); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Santé */
.health { display: grid; grid-template-columns: 1fr 1.3fr 1.3fr; gap: 24px; }
.health-stats { display: grid; gap: 10px; align-content: start; }
.stat { background: var(--surface-2); border-radius: 12px; padding: 12px 14px; }
.stat .v { font-size: 20px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.stat .v .dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.list { list-style: none; padding: 0; margin: 0; max-height: 290px; overflow: auto; }
.list li { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; padding: 8px 0; border-bottom: 1px solid var(--grid); font-size: 13.5px; }
.list li:last-child { border-bottom: 0; }
.list .ico { grid-row: span 2; width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center; margin-top: 1px; }
.list .ico svg { width: 13px; height: 13px; }
.list .when { color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.ico-good { background: color-mix(in srgb, var(--good) 15%, var(--surface)); color: var(--good-text); }
.ico-idle { background: var(--surface-2); color: var(--muted); }
.ico-warn { background: color-mix(in srgb, var(--warning) 25%, var(--surface)); color: #6b4a00; }
.ico-bad { background: color-mix(in srgb, var(--critical) 14%, var(--surface)); color: var(--bad-text); }
.note { color: var(--muted); font-size: 12px; margin-top: 8px; }

footer { color: var(--muted); font-size: 12.5px; padding-bottom: 32px; }
footer a { color: var(--text-2); }

@media (max-width: 1080px) {
  .hero { grid-template-columns: 1fr; }
  .health { grid-template-columns: 1fr 1fr; }
  .health-stats { grid-column: 1 / -1; grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 760px) {
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .grid-4, .health { grid-template-columns: 1fr; }
  .health-stats { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) {
  main, .top, footer { padding-left: 16px; padding-right: 16px; }
  .hero { padding: 20px; gap: 20px; }
  .hero-value { font-size: 52px; }
  .tile { padding: 12px; }
  .tile .value { font-size: 20px; }
  .card { padding: 16px; }
  .chart.tall { height: 280px; }
}
