:root {
  color-scheme: light;
  --page: #f1f4f6; --surface: #fcfcfb; --encre: #0b0b0b; --encre2: #52514e; --filet: #e1e0d9;
  --serie: #2a78d6; --hausse: #0a7a0a; --baisse: #c8203f;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--page); color: var(--encre); font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
main { max-width: 1080px; margin: 0 auto; padding: 24px 16px 32px; }
h1 { margin: 0 0 6px; font-size: clamp(1.6rem, 5vw, 2.2rem); line-height: 1.15; letter-spacing: -.01em; text-wrap: balance; }
h2 { margin: 0; font-size: 1.05rem; }
.synthese { margin: 0 0 20px; font-size: 1.08rem; color: var(--encre2); max-width: 68ch; text-wrap: pretty; }
.cartes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.carte, .bloc { background: var(--surface); border: 1px solid var(--filet); border-radius: 10px; }
.carte { padding: 14px 16px; }
.carte h2 { font-size: .85rem; font-weight: 600; color: var(--encre2); }
.valeur { margin: 2px 0; font-size: 1.85rem; font-weight: 650; line-height: 1.2; white-space: nowrap; }
.valeur span { font-size: .95rem; font-weight: 500; }
.valeur.hausse { color: var(--hausse); }
.valeur.baisse { color: var(--baisse); }
.detail { margin: 0; font-size: .82rem; line-height: 1.35; color: var(--encre2); }
.bloc { padding: 16px; margin-bottom: 16px; }
.entete { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 20px; margin-bottom: 12px; }
.reglages { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 18px; }

/* Bouton à deux positions : rail creusé, position active en saillie */
.bascule { display: inline-flex; gap: 4px; padding: 5px; border-radius: 12px; background: #d5dbe1; border: 1px solid #bcc5cd;
  box-shadow: inset 0 2px 5px rgba(20, 35, 50, .32), inset 0 -1px 0 rgba(255, 255, 255, .7), 0 1px 0 #fff; }
.bascule button { font: inherit; font-size: .88rem; line-height: 1.25; min-height: 40px; padding: 8px 14px; border: 1px solid transparent; border-radius: 8px;
  background: none; color: #38424c; cursor: pointer; }
.bascule button span { white-space: nowrap; }
.bascule button:hover { color: #0b0b0b; }
.bascule button[aria-pressed="true"] { font-weight: 650; color: #0b3c74; background: linear-gradient(#fff, #e9eff6); border-color: #aebccb;
  box-shadow: 0 3px 6px rgba(20, 35, 50, .34), 0 1px 1px rgba(20, 35, 50, .25), inset 0 1px 0 #fff; }
.bascule button:active { box-shadow: inset 0 2px 4px rgba(20, 35, 50, .3); }
.periode { font-size: .88rem; color: var(--encre2); }
.periode select { font: inherit; color: var(--encre); min-height: 40px; margin-left: 6px; padding: 6px 8px; border: 1px solid #bcc5cd; border-radius: 8px; background: #fff; }
:focus-visible { outline: 3px solid #86b6ef; outline-offset: 2px; }

#graphique { position: relative; height: 440px; touch-action: pan-y; border-radius: 6px; }
#graphique svg { display: block; width: 100%; height: 100%; overflow: visible; }
#graphique text { font-size: 12px; fill: var(--encre2); font-variant-numeric: tabular-nums; }
#graphique .lim-nom { fill: var(--encre2); }
#graphique .lim-val { fill: var(--encre); font-weight: 650; }
.bulle { position: absolute; top: 0; left: 0; pointer-events: none; padding: 8px 11px; border-radius: 8px; background: #fff; border: 1px solid #c3c2b7;
  box-shadow: 0 4px 14px rgba(20, 35, 50, .18); font-size: .84rem; line-height: 1.4; white-space: nowrap; color: var(--encre2); }
.bulle strong { display: block; font-size: 1.05rem; color: var(--encre); }
.bulle[hidden] { display: none; }
.note { margin: 8px 0 0; font-size: .82rem; color: var(--encre2); }
#hors-fenetre { margin: 0 0 10px; padding: 8px 12px; border-radius: 8px; background: #fff3df; color: #5c3a00; }

table { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: .92rem; }
th, td { text-align: left; vertical-align: top; padding: 9px 10px 9px 0; border-bottom: 1px solid var(--filet); }
thead th { font-size: .8rem; color: var(--encre2); font-weight: 600; }
tbody th { font-weight: 600; }
td.num, th.num { text-align: right; padding-right: 22px; white-space: nowrap; font-variant-numeric: tabular-nums; }
tbody tr:last-child > * { border-bottom: 0; }
footer { font-size: .85rem; color: var(--encre2); }
a { color: #1c5cab; }

@media (max-width: 860px) { .cartes { grid-template-columns: 1fr 1fr; } }
@media (max-width: 560px) {
  main { padding: 18px 16px 24px; }
  .carte { padding: 12px; }
  .valeur { font-size: 1.45rem; }
  .bloc { padding: 14px 12px; }
  .reglages, .bascule { width: 100%; }
  .bascule button { flex: 1; padding: 8px 6px; }
  #graphique { height: 400px; }
  #graphique text { font-size: 11px; }
  thead { position: absolute; clip-path: inset(50%); width: 1px; height: 1px; overflow: hidden; }
  tbody tr { display: grid; grid-template-columns: 1fr auto; padding: 9px 0; border-bottom: 1px solid var(--filet); }
  tbody tr:last-child { border-bottom: 0; }
  tbody th, td { border: 0; padding: 0; }
  td.num { padding: 0 0 0 12px; font-weight: 600; }
  td:last-child { grid-column: 1 / -1; font-size: .84rem; color: var(--encre2); }
}
