:root {
  --fond: #f7f6f3;
  --carte: #ffffff;
  --encre: #1f2530;
  --encre-doux: #5b6472;
  --trait: #e2e0da;
  --accent: #2f6f6a;
  --accent-doux: #e8f1f0;
  --rouge: #b4231f;
  --rouge-doux: #fdecea;
  --orange: #b3600b;
  --orange-doux: #fdf0e0;
  --jaune: #8a7413;
  --jaune-doux: #fbf6df;
  --vert: #2f6f3a;
  --rayon: 10px;
  --largeur: 46rem;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  background: var(--fond);
  color: var(--encre);
  line-height: 1.55;
  font-size: 17px;
}

.enveloppe { max-width: var(--largeur); margin: 0 auto; padding: 1.5rem 1.1rem 5rem; }
.enveloppe.large { max-width: 68rem; }

header.bandeau {
  background: var(--carte);
  border-bottom: 1px solid var(--trait);
  padding: 0.85rem 1.1rem;
  position: sticky; top: 0; z-index: 20;
}
header.bandeau .interieur {
  max-width: var(--largeur); margin: 0 auto;
  display: flex; align-items: baseline; gap: 0.7rem; flex-wrap: wrap;
}
header.bandeau.large .interieur { max-width: 68rem; }
header.bandeau strong { font-size: 0.95rem; letter-spacing: 0.01em; }
header.bandeau span { color: var(--encre-doux); font-size: 0.85rem; }

h1 { font-size: 1.65rem; line-height: 1.25; margin: 0.4rem 0 0.6rem; }
h2 { font-size: 1.2rem; margin: 2rem 0 0.6rem; }
h3 { font-size: 1rem; margin: 1.4rem 0 0.4rem; }
p { margin: 0.5rem 0; }
.doux { color: var(--encre-doux); }
.petit { font-size: 0.87rem; }
.centre { text-align: center; }

.carte {
  background: var(--carte);
  border: 1px solid var(--trait);
  border-radius: var(--rayon);
  padding: 1.1rem 1.15rem;
  margin: 0.9rem 0;
}
.carte.serree { padding: 0.75rem 0.9rem; }

.encadre {
  border-left: 3px solid var(--accent);
  background: var(--accent-doux);
  padding: 0.7rem 0.9rem;
  border-radius: 0 var(--rayon) var(--rayon) 0;
  margin: 1rem 0;
  font-size: 0.94rem;
}
.encadre.alerte { border-color: var(--rouge); background: var(--rouge-doux); }
.encadre.attention { border-color: var(--orange); background: var(--orange-doux); }

/* ---------------------------------------------------------- formulaire */
.question { padding: 1rem 0; border-bottom: 1px solid var(--trait); }
.question:last-child { border-bottom: none; }
.question > .intitule, .intitule {
  display: block; font-weight: 600; margin-bottom: 0.15rem;
}
.question .aide { color: var(--encre-doux); font-size: 0.87rem; margin: 0.1rem 0 0.55rem; }
.question.requise > .intitule::after { content: " *"; color: var(--accent); font-weight: 400; }
.question.erreur { background: var(--rouge-doux); border-radius: var(--rayon); padding-left: 0.7rem; padding-right: 0.7rem; }
.message-erreur { color: var(--rouge); font-size: 0.87rem; margin-top: 0.35rem; }

.choix { display: flex; flex-direction: column; gap: 0.3rem; margin-top: 0.5rem; }
.choix label {
  display: flex; gap: 0.6rem; align-items: flex-start;
  padding: 0.5rem 0.65rem; border: 1px solid var(--trait);
  border-radius: 8px; cursor: pointer; background: var(--carte);
}
.choix label:hover { border-color: var(--accent); }
.choix input:checked + span { font-weight: 600; }
.choix label:has(input:checked) { border-color: var(--accent); background: var(--accent-doux); }
.choix input { margin-top: 0.28rem; flex: none; }

input[type="text"], input[type="email"], input[type="number"], textarea, select {
  width: 100%; padding: 0.55rem 0.65rem; font: inherit;
  border: 1px solid var(--trait); border-radius: 8px; background: var(--carte); color: var(--encre);
  margin-top: 0.4rem;
}
textarea { min-height: 5.5rem; resize: vertical; }
input:focus, textarea:focus, select:focus, button:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent);
}
.compteur { text-align: right; font-size: 0.78rem; color: var(--encre-doux); }

/* échelle 0-N */
.echelle { display: flex; gap: 0.25rem; margin-top: 0.55rem; flex-wrap: wrap; }
.echelle label {
  position: relative; /* confine l'input masqué dans son libellé */
  flex: 1 1 2rem; min-width: 2.1rem; text-align: center;
  border: 1px solid var(--trait); border-radius: 7px; padding: 0.42rem 0.1rem;
  cursor: pointer; background: var(--carte); font-size: 0.9rem;
}
.echelle label:has(input:checked) { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; }
.echelle input { position: absolute; inset: 0; opacity: 0; margin: 0; appearance: none; cursor: pointer; }
.bornes { display: flex; justify-content: space-between; font-size: 0.78rem; color: var(--encre-doux); margin-top: 0.2rem; }

/* grille */
.grille { margin-top: 0.6rem; overflow-x: auto; }
.grille table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.grille th { font-weight: 500; color: var(--encre-doux); font-size: 0.76rem; padding: 0.2rem 0.15rem; text-align: center; }
.grille th:first-child { text-align: left; width: 42%; }
.grille td { padding: 0.28rem 0.15rem; text-align: center; border-top: 1px solid var(--trait); }
.grille td:first-child { text-align: left; font-size: 0.92rem; }
.grille td label { position: relative; display: block; cursor: pointer; padding: 0.35rem 0.1rem; border-radius: 6px; }
.grille td label:has(input:checked) { background: var(--accent); color: #fff; font-weight: 600; }
.grille td input { position: absolute; inset: 0; opacity: 0; margin: 0; appearance: none; cursor: pointer; }
.grille tr.manquante td { background: var(--rouge-doux); }

/* -------------------------------------------------------------- boutons */
button, .bouton {
  font: inherit; font-weight: 600; padding: 0.62rem 1.15rem;
  border-radius: 8px; border: 1px solid var(--accent);
  background: var(--accent); color: #fff; cursor: pointer;
  text-decoration: none; display: inline-block;
}
button.secondaire, .bouton.secondaire { background: var(--carte); color: var(--accent); }
button.discret { background: none; border-color: var(--trait); color: var(--encre-doux); font-weight: 500; }
button:disabled { opacity: 0.5; cursor: not-allowed; }
.actions { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; margin-top: 1.2rem; }

/* ------------------------------------------------------------ progression */
.progression { position: sticky; top: 0; z-index: 10; background: var(--fond); padding: 0.55rem 0 0.4rem; }
.barre { display: block; width: 100%; height: 5px; border: none; border-radius: 3px; background: var(--trait); appearance: none; }
.barre::-webkit-progress-bar { background: var(--trait); border-radius: 3px; }
.barre::-webkit-progress-value { background: var(--accent); border-radius: 3px; transition: width 0.25s; }
.barre::-moz-progress-bar { background: var(--accent); border-radius: 3px; }
.progression .infos { display: flex; justify-content: space-between; font-size: 0.8rem; color: var(--encre-doux); margin-bottom: 0.3rem; }

/* ---------------------------------------------------------------- listes */
table.liste { width: 100%; border-collapse: collapse; background: var(--carte); border: 1px solid var(--trait); border-radius: var(--rayon); overflow: hidden; }
table.liste th, table.liste td { padding: 0.6rem 0.7rem; text-align: left; border-bottom: 1px solid var(--trait); font-size: 0.92rem; }
table.liste th { background: #fbfaf8; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--encre-doux); }
table.liste tr:last-child td { border-bottom: none; }
table.liste a { color: var(--accent); font-weight: 600; }

.puce { display: inline-block; padding: 0.1rem 0.5rem; border-radius: 20px; font-size: 0.76rem; font-weight: 600; border: 1px solid; }
.puce.rouge { color: var(--rouge); background: var(--rouge-doux); border-color: #f0c4c1; }
.puce.orange { color: var(--orange); background: var(--orange-doux); border-color: #f0d6b1; }
.puce.jaune { color: var(--jaune); background: var(--jaune-doux); border-color: #e6dda8; }
.puce.aucun, .puce.neutre { color: var(--encre-doux); background: #f1efeb; border-color: var(--trait); }
.puce.vert { color: var(--vert); background: #e9f3ea; border-color: #c3ddc7; }

/* --------------------------------------------------------------- synthèse */
.zones { display: grid; gap: 0.9rem; grid-template-columns: repeat(auto-fit, minmax(19rem, 1fr)); }
.zone { background: var(--carte); border: 1px solid var(--trait); border-radius: var(--rayon); padding: 0.85rem 0.95rem; }
.zone h3 { margin: 0 0 0.5rem; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--encre-doux); }
.zone.pleine { grid-column: 1 / -1; }
.zone ul { margin: 0.3rem 0; padding-left: 1.1rem; }
.zone li { margin: 0.25rem 0; }
.zone .gros { font-size: 1.12rem; font-weight: 600; }

.mesure { display: flex; align-items: center; gap: 0.5rem; margin: 0.25rem 0; font-size: 0.9rem; }
.mesure .nom { flex: 1; }
.mesure .jauge { width: 5.5rem; height: 7px; flex: none; border: none; border-radius: 4px; background: var(--trait); appearance: none; }
.mesure .jauge::-webkit-meter-bar { background: var(--trait); border: none; border-radius: 4px; height: 7px; }
.mesure .jauge::-webkit-meter-optimum-value,
.mesure .jauge::-webkit-meter-suboptimum-value { background: var(--accent); border-radius: 4px; }
.mesure .jauge::-webkit-meter-even-less-good-value { background: var(--rouge); border-radius: 4px; }
.mesure .jauge:-moz-meter-optimum::-moz-meter-bar { background: var(--accent); }
.mesure .jauge:-moz-meter-sub-optimum::-moz-meter-bar { background: var(--accent); }
.mesure .jauge:-moz-meter-optimum { background: var(--trait); }
.mesure .val { width: 2rem; text-align: right; color: var(--encre-doux); font-variant-numeric: tabular-nums; }

.comparaison { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.comparaison td, .comparaison th { padding: 0.28rem 0.3rem; border-bottom: 1px solid var(--trait); }
.comparaison th { font-size: 0.74rem; text-transform: uppercase; color: var(--encre-doux); text-align: left; }
.comparaison tr.divergent { background: var(--jaune-doux); }

.drapeau { border-left: 3px solid; padding: 0.5rem 0.7rem; margin: 0.4rem 0; border-radius: 0 8px 8px 0; font-size: 0.9rem; }
.drapeau.rouge { border-color: var(--rouge); background: var(--rouge-doux); }
.drapeau.orange { border-color: var(--orange); background: var(--orange-doux); }
.drapeau.jaune { border-color: var(--jaune); background: var(--jaune-doux); }
.drapeau strong { display: block; }
.drapeau .conduite { color: var(--encre-doux); font-size: 0.85rem; margin-top: 0.15rem; }

.agenda { list-style: none; padding: 0; margin: 0.3rem 0; }
.agenda li { display: flex; gap: 0.7rem; padding: 0.3rem 0; border-bottom: 1px solid var(--trait); font-size: 0.9rem; }
.agenda li:last-child { border-bottom: none; }
.agenda .temps { flex: none; width: 5rem; color: var(--accent); font-weight: 600; font-variant-numeric: tabular-nums; }

.onglets { display: flex; gap: 0.3rem; border-bottom: 1px solid var(--trait); margin: 1.2rem 0 0; flex-wrap: wrap; }
.onglets button {
  background: none; border: 1px solid transparent; border-bottom: none; color: var(--encre-doux);
  border-radius: 8px 8px 0 0; padding: 0.5rem 0.85rem; font-weight: 500; font-size: 0.92rem;
}
.onglets button[aria-selected="true"] { background: var(--carte); border-color: var(--trait); color: var(--encre); font-weight: 600; margin-bottom: -1px; }
.panneau { display: none; }
.panneau.actif { display: block; }

.champ-ligne { display: grid; grid-template-columns: 11rem 1fr; gap: 0.5rem; align-items: start; margin: 0.45rem 0; }
.champ-ligne > label { font-size: 0.88rem; color: var(--encre-doux); padding-top: 0.6rem; }
@media (max-width: 34rem) { .champ-ligne { grid-template-columns: 1fr; } .champ-ligne > label { padding-top: 0; } }

.chargement { color: var(--encre-doux); padding: 2rem 0; text-align: center; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
code.jeton { font-size: 0.8rem; background: #f1efeb; padding: 0.15rem 0.35rem; border-radius: 5px; word-break: break-all; }

/* ------------------------------------------------- utilitaires (CSP : aucun style inline) */
.texte-rouge { color: var(--rouge); }
.texte-orange { color: var(--orange); }
.pousse-droite { margin-left: auto; }
.espace-haut { margin-top: 0.9rem; }

.echelle label:has(input:focus-visible),
.grille td label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 1px; }
