/* Tableau de bord des statistiques — charte Primaire Ouverte (bleu anthracite, orange). */
:root {
  --encre: #1d2b3a;
  --orange: #ff5a0a;
  --orange-fort: #c93d00;
  --orange-doux: #fff1e6;
  --gris: #66707a;
  --filet: #e4e7eb;
  --surface: #f6f7f9;
  --vert: #1f7a46;
  --bleu: #2a78d6;
  /* Rampe ordinale de la carte et des barres (une teinte, clair → foncé), validée par
     scripts/validate_palette.js --ordinal sur le fond #eef3f8 : niveau clair 2,14:1. */
  --rampe-1: #ee9150;
  --rampe-2: #e2722f;
  --rampe-3: #cc5716;
  --rampe-4: #a3420b;
  --rampe-5: #712d05;
  --rampe-piste: #fbe3d3;
  --fond-carte: #eef3f8;
  --sans-donnee: #dde3ea;
  --grille: #e4e7eb;
  /* Types d'événement du flux : palette catégorielle de référence, ordre fixe (CVD
     ΔE ≥ 9,1 entre voisins ; contraste < 3:1 compensé par le libellé de chaque ligne). */
  --type-vue: #2a78d6;
  --type-lecture: #eb6834;
  --type-partage: #1baf7a;
  --type-duel: #eda100;
  --type-lecteur: #e87ba4;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  color: var(--encre);
  background: var(--surface);
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
h1 {
  margin: 0 0 16px;
  font-size: 26px;
  font-weight: 800;
}
h2 {
  margin: 0 0 12px;
  font-size: 16px;
  font-weight: 800;
}
h2 small,
.libelle small {
  color: var(--gris);
  font-weight: 400;
}
button {
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid var(--encre);
  border-radius: 999px;
  background: var(--encre);
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
button.secondaire,
.periodes button[aria-pressed='false'] {
  background: #fff;
  color: var(--encre);
}
button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 3px solid var(--orange);
  outline-offset: 2px;
}
.marque {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 20px;
  font-weight: 800;
}
.marque span {
  color: var(--orange);
}
.marque em {
  color: var(--gris);
  font-style: normal;
  font-weight: 600;
}
.entete {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--filet);
  background: #fff;
}
.etat {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--gris);
  font-weight: 700;
}
.pastille {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--gris);
}
.en-ligne {
  color: var(--vert);
}
.en-ligne .pastille {
  background: #2fa865;
  box-shadow: 0 0 0 4px #2fa86533;
  animation: pouls 1.6s infinite;
}
.hors-ligne {
  color: var(--orange-fort);
}
.hors-ligne .pastille {
  background: var(--orange-fort);
}
@keyframes pouls {
  50% {
    box-shadow: 0 0 0 8px #2fa86500;
  }
}
main {
  display: grid;
  gap: 32px;
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px;
}
.tuiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}
.tuile,
.panneau {
  padding: 18px;
  border: 1px solid var(--filet);
  border-radius: 14px;
  background: #fff;
}
.tuile.accent {
  border-color: var(--orange);
  background: var(--orange-doux);
}
.valeur {
  margin: 0;
  font-size: 40px;
  font-weight: 800;
  line-height: 1;
}
.accent .valeur {
  color: var(--orange-fort);
}
.libelle {
  margin: 6px 0 0;
  color: var(--gris);
  font-weight: 600;
}
.grille {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
.grille.trois {
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}
.courbe {
  display: block;
  width: 100%;
  height: auto;
}
.courbe {
  touch-action: pan-y;
}
.courbe .aire {
  fill: var(--rampe-3);
  fill-opacity: 0.1;
}
.courbe .trait {
  fill: none;
  stroke: var(--rampe-3);
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}
.courbe .grille,
.courbe .base {
  stroke: var(--grille);
  stroke-width: 1;
  shape-rendering: crispEdges;
}
.courbe .base {
  stroke: #cfd5dc;
}
.courbe .echelle {
  fill: var(--gris);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.courbe .reticule {
  stroke: var(--encre);
  stroke-width: 1;
  shape-rendering: crispEdges;
}
.courbe .point {
  fill: var(--rampe-3);
  stroke: #fff;
  stroke-width: 2;
}
.courbe:focus-visible {
  outline: 3px solid var(--orange);
  outline-offset: 2px;
}
/* Info-bulle partagée : la valeur en avant, le libellé en second. */
.infobulle {
  position: absolute;
  z-index: 10;
  display: grid;
  gap: 2px;
  padding: 8px 10px;
  border: 1px solid var(--filet);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 4px 16px #1d2b3a1f;
  pointer-events: none;
}
.infobulle strong {
  font-size: 15px;
}
.infobulle span {
  color: var(--gris);
  font-size: 13px;
}
/* Barres des classements : une seule série → une seule teinte ; piste = ton clair de la
   même rampe ; bout de donnée arrondi, base carrée. */
.classement meter {
  appearance: none;
  border-radius: 0 4px 4px 0;
  background: var(--rampe-piste);
}
.classement meter::-webkit-meter-bar {
  border: 0;
  border-radius: 0 4px 4px 0;
  background: var(--rampe-piste);
}
.classement meter::-webkit-meter-optimum-value {
  border-radius: 0 4px 4px 0;
  background: var(--rampe-3);
}
.classement meter::-moz-meter-bar {
  border-radius: 0 4px 4px 0;
  background: var(--rampe-3);
}
.liste {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.liste li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  overflow-wrap: anywhere;
}
.flux {
  display: grid;
  max-height: 340px;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
}
.flux li {
  display: grid;
  grid-template-columns: 76px 190px 1fr;
  gap: 12px;
  padding: 8px 0 8px 10px;
  border-bottom: 1px solid var(--filet);
  border-left: 3px solid var(--filet);
  overflow-wrap: anywhere;
}
.flux time {
  color: var(--gris);
  font-variant-numeric: tabular-nums;
}
.flux .t-vue {
  border-left-color: var(--type-vue);
}
.flux .t-lecture {
  border-left-color: var(--type-lecture);
}
.flux .t-partage {
  border-left-color: var(--type-partage);
}
.flux .t-duel {
  border-left-color: var(--type-duel);
}
.flux .t-lecteur {
  border-left-color: var(--type-lecteur);
}
.titre-periode {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.titre-periode h1 {
  margin: 0;
}
.periodes {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.classement {
  width: 100%;
  border-collapse: collapse;
}
.classement th,
.classement td {
  padding: 6px 4px;
  border-bottom: 1px solid var(--filet);
  text-align: left;
  vertical-align: middle;
}
.classement th {
  max-width: 220px;
  font-weight: 600;
  overflow-wrap: anywhere;
}
.classement meter {
  width: 100%;
  min-width: 60px;
  height: 10px;
}
.classement .n {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  white-space: nowrap;
}
.discret {
  color: var(--gris);
  font-weight: 400;
}
.vide {
  color: var(--gris);
}
.archives {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.archives li {
  display: flex;
  gap: 12px;
}
.archives a {
  color: var(--orange-fort);
  font-weight: 700;
}
.aide {
  color: var(--gris);
}
/* Carte de localisation (PRIMAIREOU-126) */
.titre-carte {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.titre-carte h2 {
  margin: 0;
}
.carte {
  display: block;
  width: 100%;
  height: auto;
  background: var(--fond-carte);
  border-radius: 10px;
}
.carte .zone {
  stroke: #fff;
  stroke-width: 0.6;
  stroke-linejoin: round;
}
.carte .zone:hover {
  stroke: var(--encre);
  stroke-width: 1.2;
}
.niv-0 {
  fill: var(--sans-donnee);
  background: var(--sans-donnee);
}
.niv-1 {
  fill: var(--rampe-1);
  background: var(--rampe-1);
}
.niv-2 {
  fill: var(--rampe-2);
  background: var(--rampe-2);
}
.niv-3 {
  fill: var(--rampe-3);
  background: var(--rampe-3);
}
.niv-4 {
  fill: var(--rampe-4);
  background: var(--rampe-4);
}
.niv-5 {
  fill: var(--rampe-5);
  background: var(--rampe-5);
}
.carte .ville .cible {
  fill: transparent;
}
.carte .ville .point {
  fill: var(--encre);
  fill-opacity: 0.7;
  stroke: #fff;
  stroke-width: 2;
  paint-order: stroke;
}
.carte .ville:hover .point {
  fill-opacity: 1;
}
.carte .pouls {
  fill: none;
  stroke: var(--bleu);
  stroke-width: 2.5;
  paint-order: stroke;
  transform-box: fill-box;
  transform-origin: center;
  animation: onde 1.8s ease-out infinite;
}
@keyframes onde {
  from {
    transform: scale(0.6);
    stroke-opacity: 1;
  }
  to {
    transform: scale(2.4);
    stroke-opacity: 0;
  }
}
.echelle-carte {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 8px 0 0;
  color: var(--gris);
  font-size: 13px;
}
.echelle-carte i {
  width: 28px;
  height: 10px;
  border-radius: 3px;
}
.echelle-carte span {
  margin: 0 4px;
}
.echelle-carte .cle-ville,
.echelle-carte .cle-direct {
  width: 10px;
  height: 10px;
  margin-left: 16px;
  border-radius: 50%;
}
.echelle-carte .cle-ville {
  background: var(--encre);
}
.echelle-carte .cle-direct {
  border: 2.5px solid var(--bleu);
}
.credits {
  margin: 0;
  color: var(--gris);
  font-size: 13px;
}
.credits a {
  color: inherit;
}
/* Connexion */
body.connexion {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 20px;
}
.carte-connexion {
  display: grid;
  gap: 8px;
  width: min(420px, 100%);
  padding: 32px;
  border: 1px solid var(--filet);
  border-radius: 16px;
  background: #fff;
}
.carte-connexion form {
  display: grid;
  gap: 8px;
}
.carte-connexion label {
  margin-top: 8px;
  font-weight: 700;
}
.carte-connexion input {
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--gris);
  border-radius: 10px;
  font: inherit;
}
.carte-connexion button {
  margin-top: 16px;
  min-height: 48px;
  background: var(--orange-fort);
  border-color: var(--orange-fort);
}
.erreur {
  margin: 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--orange-doux);
  color: var(--orange-fort);
  font-weight: 700;
}
@media (max-width: 800px) {
  .grille {
    grid-template-columns: 1fr;
  }
  .flux li {
    grid-template-columns: 70px 1fr;
  }
  .flux li span {
    grid-column: 2;
  }
  main {
    padding: 16px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .en-ligne .pastille,
  .carte .pouls {
    animation: none;
  }
}
