/* Portail du consortium. Deux couleurs porteuses de sens : le cramoisi pour le risque cardiaque,
   la sarcelle pour ce qui est chiffré. Tout le reste reste neutre. */
:root {
  color-scheme: light;
  --papier: #f6f8f7;
  --surface: #ffffff;
  --encre: #1c2427;
  --encre-2: #4d5a5f;
  --encre-3: #6f7b80;
  --trait: #d9dfe0;
  --trait-fort: #b9c3c5;
  --risque: #b0243a;
  --risque-fond: #fbeef0;
  --sur: #1f6f4a;
  --sur-fond: #eaf5ef;
  --chiffre: #0f6b73;
  --chiffre-fond: #e6f2f3;
  --attention: #8a5a00;
  --serie-1: #2a78d6; --serie-2: #eb6834; --serie-3: #1baf7a; --serie-4: #eda100;
  --rayon: 6px;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --texte: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --papier: #121719; --surface: #1a2023; --encre: #e7ecec; --encre-2: #b6c0c2; --encre-3: #8f9a9d;
    --trait: #2c3538; --trait-fort: #3d484b; --risque: #f0727f; --risque-fond: #3a1d22; --sur: #6ccf9c;
    --sur-fond: #183026; --chiffre: #5cc3cb; --chiffre-fond: #14303a; --attention: #e0b04c;
    --serie-1: #3987e5; --serie-2: #d95926; --serie-3: #199e70; --serie-4: #c98500;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --papier: #121719; --surface: #1a2023; --encre: #e7ecec; --encre-2: #b6c0c2; --encre-3: #8f9a9d;
  --trait: #2c3538; --trait-fort: #3d484b; --risque: #f0727f; --risque-fond: #3a1d22; --sur: #6ccf9c;
  --sur-fond: #183026; --chiffre: #5cc3cb; --chiffre-fond: #14303a; --attention: #e0b04c;
  --serie-1: #3987e5; --serie-2: #d95926; --serie-3: #199e70; --serie-4: #c98500;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--papier); color: var(--encre);
  font: 16px/1.55 var(--texte); font-variant-numeric: tabular-nums;
}
main { max-width: 1180px; margin: 0 auto; padding: 0 20px 48px; }
h1 { font-size: 1.9rem; line-height: 1.2; letter-spacing: -0.01em; margin: 32px 0 12px; font-weight: 650; max-width: 22em; }
h2 { font-size: 1.05rem; margin: 28px 0 12px; font-weight: 650; }
p { margin: 0 0 12px; }
.chapo { color: var(--encre-2); max-width: 44em; font-size: 1.04rem; }
code { font-family: var(--mono); font-size: 0.88em; background: var(--chiffre-fond); color: var(--chiffre); padding: 1px 5px; border-radius: 4px; }
a { color: var(--chiffre); }
:focus-visible { outline: 3px solid var(--chiffre); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ------------------------------------------------ en-tête */
.entete {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 14px 20px; border-bottom: 1px solid var(--trait); background: var(--surface);
}
.marque { display: flex; align-items: center; gap: 12px; }
.trace { width: 56px; height: 22px; flex: none; }
.trace path { fill: none; stroke: var(--risque); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.marque-nom { margin: 0; font-weight: 650; line-height: 1.2; }
.marque-sous { margin: 0; font-size: 0.85rem; color: var(--encre-3); }
.onglets { display: flex; gap: 4px; flex-wrap: wrap; }
.onglets a {
  text-decoration: none; color: var(--encre-2); padding: 8px 14px; border-radius: var(--rayon); font-weight: 550;
}
.onglets a:hover { color: var(--encre); background: var(--papier); }
.onglets a[aria-current="page"] { color: var(--encre); background: var(--papier); box-shadow: inset 0 -2px 0 var(--risque); }

/* ------------------------------------------------ formulaires */
label { display: block; font-weight: 550; margin-bottom: 6px; }
input, select {
  font: inherit; width: 100%; padding: 9px 11px; color: var(--encre); background: var(--surface);
  border: 1px solid var(--trait-fort); border-radius: var(--rayon);
}
input[aria-invalid="true"], select[aria-invalid="true"] { border-color: var(--risque); }
button {
  font: inherit; font-weight: 600; cursor: pointer; border-radius: var(--rayon); padding: 10px 18px;
  border: 1px solid var(--encre); background: var(--encre); color: var(--surface);
}
button:hover { opacity: 0.9; }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button.secondaire { background: transparent; color: var(--encre); border-color: var(--trait-fort); }
button.danger { background: transparent; color: var(--risque); border-color: var(--risque); }
button.lien { background: none; border: 0; padding: 0; color: var(--chiffre); font-weight: 500; text-decoration: underline; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; align-items: center; }
.message { min-height: 1.5em; margin-top: 10px; color: var(--encre-2); }
.message.erreur { color: var(--risque); }

.connexion { max-width: 640px; }
.ligne-form { margin-top: 28px; }
.champ-bouton { display: flex; gap: 10px; }
.champ-bouton input { flex: 1; }

.barre-client { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 22px 0 6px; color: var(--encre-2); flex-wrap: wrap; }
.barre-client p { margin: 0; }

.grille-predire { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 36px; align-items: start; margin-top: 12px; }
.bascule { display: inline-flex; border: 1px solid var(--trait-fort); border-radius: var(--rayon); padding: 3px; margin-bottom: 20px; background: var(--surface); }
.bascule button { background: transparent; color: var(--encre-2); border: 0; padding: 7px 14px; font-weight: 550; }
.bascule button[aria-selected="true"] { background: var(--encre); color: var(--surface); }
.champs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 20px; }
.champ small { display: block; color: var(--encre-3); font-size: 0.82rem; margin-top: 4px; }
.unite { color: var(--encre-3); font-weight: 400; }
.fichier { display: inline-flex; margin: 0; }
.fichier input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.fichier span { border: 1px dashed var(--trait-fort); border-radius: var(--rayon); padding: 10px 16px; cursor: pointer; font-weight: 550; background: var(--surface); }
.fichier input:focus-visible + span { outline: 3px solid var(--chiffre); outline-offset: 2px; }

/* ------------------------------------------------ trajet des données (l'élément signature) */
.trajet {
  background: var(--surface); border: 1px solid var(--trait); border-radius: 10px; padding: 20px 22px 18px;
  position: sticky; top: 16px;
}
.trajet h2 { margin-top: 0; }
.etapes { list-style: none; margin: 0; padding: 0; counter-reset: e; }
.etapes li {
  position: relative; padding: 0 0 16px 38px; counter-increment: e; color: var(--encre-3);
}
.etapes li::before {
  content: counter(e); position: absolute; left: 0; top: 0; width: 26px; height: 26px; border-radius: 50%;
  border: 1.5px solid var(--trait-fort); display: grid; place-items: center; font-size: 0.8rem; font-weight: 650; background: var(--surface);
}
.etapes li:not(:last-child)::after { content: ""; position: absolute; left: 12.5px; top: 28px; bottom: 2px; width: 1.5px; background: var(--trait); }
.etapes strong { display: block; color: var(--encre-2); font-weight: 600; }
.etapes span { display: block; font-size: 0.9rem; }
.etapes em { display: block; font-style: normal; font-family: var(--mono); font-size: 0.8rem; color: var(--chiffre); margin-top: 3px; }
.etapes li.encours::before { border-color: var(--chiffre); color: var(--chiffre); animation: pouls 1s ease-in-out infinite; }
.etapes li.fait { color: var(--encre-2); }
.etapes li.fait strong { color: var(--encre); }
.etapes li.fait::before { content: "✓"; background: var(--chiffre); border-color: var(--chiffre); color: var(--surface); }
.etapes li.echec::before { content: "!"; border-color: var(--risque); color: var(--risque); }
@keyframes pouls { 50% { box-shadow: 0 0 0 5px var(--chiffre-fond); } }
@media (prefers-reduced-motion: reduce) { .etapes li.encours::before { animation: none; } }
.octets { margin: 6px 0 0; padding-top: 14px; border-top: 1px solid var(--trait); }
.octets figcaption { font-size: 0.85rem; color: var(--encre-2); margin-bottom: 8px; }
.octets pre {
  margin: 0; font-family: var(--mono); font-size: 0.78rem; line-height: 1.5; color: var(--chiffre);
  background: var(--chiffre-fond); padding: 10px 12px; border-radius: var(--rayon); white-space: pre-wrap; word-break: break-all;
}

/* ------------------------------------------------ résultat */
.resultat { margin-top: 36px; border-top: 1px solid var(--trait); padding-top: 26px; }
.verdict { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px 32px; align-items: center; }
.pourcentage { font-size: clamp(3.2rem, 9vw, 5.2rem); font-weight: 700; line-height: 1; letter-spacing: -0.03em; color: var(--encre); }
.pourcentage.haut { color: var(--risque); }
.pourcentage.bas { color: var(--sur); }
.verdict-texte h2 { margin: 0 0 4px; font-size: 1.3rem; }
.verdict-texte p { margin: 0; color: var(--encre-2); }
.jauge { grid-column: 1 / -1; position: relative; height: 10px; border-radius: 5px; background: var(--trait); margin: 18px 0 6px; overflow: visible; }
.jauge-remplie { position: absolute; inset: 0 auto 0 0; border-radius: 5px; background: var(--encre-3); }
.jauge-remplie.haut { background: var(--risque); }
.jauge-remplie.bas { background: var(--sur); }
.jauge-seuil { position: absolute; left: 50%; top: -5px; bottom: -5px; width: 2px; background: var(--encre); }
.jauge-legende { grid-column: 1 / -1; display: flex; justify-content: space-between; font-size: 0.82rem; color: var(--encre-3); }
.details-resultat { margin-top: 18px; color: var(--encre-2); font-size: 0.92rem; }
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 0.82rem; font-weight: 600; }
.badge.haut { background: var(--risque-fond); color: var(--risque); }
.badge.bas { background: var(--sur-fond); color: var(--sur); }
.badge.chiffre { background: var(--chiffre-fond); color: var(--chiffre); }

.table-defile { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 0.93rem; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--trait); vertical-align: top; }
thead th { font-weight: 600; color: var(--encre-2); border-bottom: 1.5px solid var(--trait-fort); }
td.num, th.num { text-align: right; }

/* ------------------------------------------------ consortium */
.tete-vue { margin-bottom: 8px; }
.phases { list-style: none; padding: 0; margin: 24px 0 8px; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.phases li { border-top: 4px solid var(--trait); padding-top: 8px; color: var(--encre-3); font-size: 0.9rem; }
.phases li strong { display: block; color: var(--encre-2); font-size: 0.95rem; }
.phases li.faite { border-color: var(--chiffre); }
.phases li.active { border-color: var(--risque); color: var(--encre-2); }
.phases li.active strong { color: var(--encre); }
.grille-consortium { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 36px; }
.graphique { background: var(--surface); border: 1px solid var(--trait); border-radius: 10px; padding: 14px 14px 8px; min-height: 120px; position: relative; }
.graphique svg { display: block; width: 100%; height: auto; overflow: visible; }
.graphique .axe { stroke: var(--trait); stroke-width: 1; }
.graphique .axe-texte { fill: var(--encre-3); font-size: 11px; }
.graphique .serie { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.graphique .etiquette { font-size: 11px; fill: var(--encre-2); }
.graphique .vide { color: var(--encre-3); padding: 28px 8px; margin: 0; }
.legende { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 4px 4px 8px; font-size: 0.85rem; color: var(--encre-2); padding: 0; list-style: none; }
.legende li { display: flex; align-items: center; gap: 6px; }
.legende i { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }
.infobulle { position: absolute; pointer-events: none; background: var(--encre); color: var(--surface); font-size: 0.8rem; padding: 6px 9px; border-radius: 5px; white-space: nowrap; transform: translate(-50%, -110%); }
.hopitaux { display: grid; gap: 0; border-top: 1px solid var(--trait); }
.hopital { display: grid; grid-template-columns: 14px minmax(0, 1fr) auto; gap: 4px 12px; padding: 12px 2px; border-bottom: 1px solid var(--trait); align-items: baseline; }
.point-etat { width: 10px; height: 10px; border-radius: 50%; background: var(--trait-fort); transform: translateY(1px); }
.point-etat.en-ligne { background: var(--sur); }
.hopital-nom { font-weight: 600; }
.hopital-meta { grid-column: 2 / -1; font-size: 0.85rem; color: var(--encre-3); }
.hopital-meta code { font-size: 0.8rem; }
.hopital-score { font-weight: 600; text-align: right; }
.journal { list-style: none; padding: 0; margin: 0; max-height: 460px; overflow-y: auto; border-top: 1px solid var(--trait); }
.journal li { padding: 9px 2px; border-bottom: 1px solid var(--trait); font-size: 0.9rem; color: var(--encre-2); }
.journal time { display: block; font-size: 0.78rem; color: var(--encre-3); }
.admin { margin-top: 26px; border: 1px solid var(--trait); border-radius: 10px; padding: 12px 16px; background: var(--surface); }
.admin summary { cursor: pointer; font-weight: 600; }
.admin form { margin-top: 14px; }

/* ------------------------------------------------ sécurité */
.matrice td.oui { color: var(--risque); font-weight: 600; }
.matrice td.non { color: var(--chiffre); }
.matrice td.part { color: var(--attention); }
.matrice th[scope="row"] { font-weight: 600; color: var(--encre); }
.colonnes-texte { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 36px; margin-top: 12px; }
.colonnes-texte p { max-width: 38em; color: var(--encre-2); }

.pied { max-width: 1180px; margin: 0 auto; padding: 20px; border-top: 1px solid var(--trait); color: var(--encre-3); font-size: 0.85rem; }

@media (max-width: 860px) {
  .grille-predire, .grille-consortium, .colonnes-texte { grid-template-columns: minmax(0, 1fr); }
  .trajet { position: static; }
  .phases { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 520px) {
  main { padding: 0 16px 40px; }
  h1 { font-size: 1.55rem; }
  .champs { grid-template-columns: minmax(0, 1fr); }
  .champ-bouton { flex-direction: column; }
  .verdict { grid-template-columns: minmax(0, 1fr); }
}
#colonnes-csv { overflow-wrap: anywhere; }

/* ------------------------------------------------ échanges mesurés */
.bandeau-echanges { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin: 22px 0 6px; }
.chiffre-echange { background: var(--surface); border: 1px solid var(--trait); border-radius: 10px; padding: 12px 14px; }
.chiffre-echange strong { display: block; font-size: 1.35rem; letter-spacing: -0.01em; line-height: 1.2; }
.chiffre-echange span { display: block; color: var(--encre-3); font-size: 0.82rem; margin-top: 3px; }
.flux { max-height: 640px; overflow-y: auto; border: 1px solid var(--trait); border-radius: 10px; background: var(--surface); }
.flux table { font-size: 0.86rem; }
.flux thead th { position: sticky; top: 0; background: var(--surface); }
.flux td { white-space: nowrap; }
.flux td:nth-child(2) { white-space: normal; min-width: 130px; }
.flux td:nth-child(3) { white-space: normal; min-width: 220px; }
.grille-echanges { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 28px; }
#table-acteurs td, #table-chrono td { white-space: nowrap; }
#table-acteurs td:first-child, #table-chrono td:first-child { white-space: normal; }
#table-acteurs th, #table-chrono th { font-size: 0.82rem; }
.flux .badge { margin-top: 3px; font-size: 0.74rem; font-weight: 550; }
.badge.neutre { background: var(--papier); color: var(--encre-3); }
.apercu { display: block; margin-top: 4px; font-size: 0.72rem; word-break: break-all; white-space: normal; }
tr.refuse td { color: var(--risque); }
.aide-echanges { color: var(--encre-3); font-size: 0.85rem; margin-top: 8px; }
#table-acteurs, #table-chrono { font-size: 0.88rem; }
@media (max-width: 860px) { .bandeau-echanges { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grille-echanges { grid-template-columns: minmax(0, 1fr); } }
