/* Page Statistiques (cadrage §3.9). Mobile d'abord, colonne centrée au-delà.
   Couleurs : variables de tokens.css uniquement ; séries par --serie-*. */

html, body { height: auto; min-height: 100%; }

.page { min-height: 100dvh; display: flex; flex-direction: column; }
.page .entete { flex-shrink: 0; }

.stats {
  flex: 1;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 16px 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.stats-titre { margin: 0; font-size: 22px; font-weight: 800; }
.stats h2 { margin: 0; font-size: 17px; font-weight: 800; }
.bandeau { font-size: 13px; color: var(--texte-2); }
.bandeau a { color: var(--texte-2); }

.stats .ligne-date { margin: 0 -8px; }
.stats .date-libelle { text-align: center; }

.stats-bloc { display: flex; flex-direction: column; gap: 12px; padding-top: 16px; border-top: 1px solid var(--bordure); }
.stats-bloc.chargement { opacity: 0.5; transition: opacity 0.2s; }
.bloc-entete { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

.selection {
  min-height: var(--cible-tactile);
  max-width: 60%;
  padding: 0 8px;
  border: 1px solid var(--bordure);
  border-radius: var(--rayon-s);
  background: var(--surface);
  color: var(--texte);
  font: inherit;
  font-size: 14px;
}

/* Séries : la couleur suit l'indicateur, jamais son rang. */
.serie-mobilises { --serie: var(--serie-mobilises); }
.serie-bloques { --serie: var(--serie-bloques); }
.serie-fermes { --serie: var(--serie-fermes); }

.cle-ligne { display: inline-block; flex-shrink: 0; width: 16px; height: 2px; margin-right: 6px; vertical-align: middle; background: var(--serie); }
.cle-ligne.serie-fermes { background: repeating-linear-gradient(to right, var(--serie) 0 4px, transparent 4px 7px); }

/* ---------- Tuiles et tableau ---------- */

.tuiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.tuile {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--bordure);
  border-radius: var(--rayon-m);
  font-size: 12px;
}
.tuile-titre { display: flex; align-items: center; font-size: 13px; font-weight: 600; }
.tuile-nombre { font-size: 28px; font-weight: 800; line-height: 1.1; }
.tuile-part { font-size: 14px; }

.tableau { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.tableau caption { padding-bottom: 6px; text-align: left; color: var(--texte-2); font-size: 12px; }
.tableau th, .tableau td { padding: 6px 4px; border-bottom: 1px solid var(--bordure); text-align: right; }
.tableau th:first-child { text-align: left; }
.tableau thead th { font-weight: 600; color: var(--texte-2); }
.tableau tbody th { font-weight: 600; }

/* ---------- Courbe ---------- */

.legende-courbe { display: flex; flex-wrap: wrap; gap: 14px; font-size: 13px; }
.legende-courbe > span { display: inline-flex; align-items: center; }

.courbe { position: relative; min-height: 220px; }
.courbe-svg { display: block; touch-action: pan-y; }
.courbe-svg:focus-visible { outline: 2px solid var(--texte); outline-offset: 2px; }
.courbe-grille { stroke: var(--bordure); stroke-width: 1; }
.courbe-axe { fill: var(--texte-2); font-size: 11px; font-variant-numeric: tabular-nums; }
.courbe-ligne { fill: none; stroke: var(--serie); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.courbe-ligne.serie-fermes { stroke-dasharray: 5 4; stroke-linecap: butt; }
.courbe-point { fill: var(--serie); stroke: var(--fond); stroke-width: 2; }
.courbe-valeur { fill: var(--texte); font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; }
.courbe-reticule { stroke: var(--texte-2); stroke-width: 1; pointer-events: none; }

.courbe-bulle {
  position: absolute;
  top: 4px;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--bordure);
  border-radius: var(--rayon-s);
  box-shadow: 0 2px 8px rgb(0 0 0 / 0.12);
  font-size: 12px;
  white-space: nowrap;
  pointer-events: none;
}
.courbe-bulle p { display: flex; align-items: center; gap: 4px; }
.courbe-bulle strong { font-size: 14px; font-variant-numeric: tabular-nums; }
.courbe-bulle-date { color: var(--texte-2); }

.tableau-repli summary { min-height: var(--cible-tactile); display: flex; align-items: center; cursor: pointer; font-size: 14px; }
.tableau-repli[open] summary { margin-bottom: 4px; }

/* ---------- Répartition ---------- */

.barres { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; }
.barre-ligne {
  display: grid;
  grid-template-columns: minmax(0, 9em) 1fr auto;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}
.barre-nom { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.barre-piste { height: 10px; }
.barre-piste span { display: block; height: 100%; min-width: 2px; border-radius: 0 4px 4px 0; background: var(--serie); }
.barre-valeur { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.barre-valeur .secondaire { font-size: 12px; }

/* ---------- Méthode et pied ---------- */

.methode p { font-size: 14px; line-height: 1.5; }

.pied { padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--bordure); background: var(--surface); }
