/* ==========================================================================
   Feuille de style du backoffice « Secours Médical ».

   Les jetons de couleur reprennent exactement les noms et les valeurs
   « oklch(...) » de « docs/JETONS-DESIGN.md », qui reste la référence côté web.
   Aucune couleur n'est inventée, aucune n'est approximée, aucune n'est
   convertie en hexadécimal ici.

   Thème clair uniquement : les sources ne définissent aucun jeu sombre.
   Aucun style n'est écrit en ligne dans les gabarits, à la seule exception de
   la largeur des colonnes de grille, calculée par le contexte de page.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Polices locales, Public Sans et JetBrains Mono, et rien d'autre.
   Déposez les fichiers « .woff2 » dans « app/static/fonts/ », voir le README
   de ce répertoire. En leur absence, les replis « system-ui » et
   « ui-monospace » prennent le relais sans dégrader la mise en page.
   -------------------------------------------------------------------------- */

@font-face {
  font-family: "Public Sans";
  src: url("/static/fonts/PublicSans-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Public Sans";
  src: url("/static/fonts/PublicSans-Medium.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Public Sans";
  src: url("/static/fonts/PublicSans-SemiBold.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Public Sans";
  src: url("/static/fonts/PublicSans-Bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "JetBrains Mono";
  src: url("/static/fonts/JetBrainsMono-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "JetBrains Mono";
  src: url("/static/fonts/JetBrainsMono-Medium.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

/* --------------------------------------------------------------------------
   2. Jetons de design, section 1 à 6 de « docs/JETONS-DESIGN.md »
   -------------------------------------------------------------------------- */

:root {
  /* 5. Typographie, deux familles seulement. */
  --police-sans: "Public Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --police-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", monospace;

  /* 5. Échelle de tailles relevée, en pixels. */
  --taille-micro-libelle: 10.5px;
  --taille-badge: 10px;
  --taille-mention: 11px;
  --taille-pastille: 12px;
  --taille-mono: 12.5px;
  --taille-secondaire: 13px;
  --taille-cellule: 13.5px;
  --taille-corps: 14px;
  --taille-bouton: 13.5px;
  --taille-titre-page: 19px;
  --taille-indicateur: 25px;
  --taille-synthese: 33px;

  /* 1. Palette de base, neutres. */
  --texte: oklch(0.45 0.010 255);
  --texte-fort: oklch(0.30 0.012 255);
  --texte-faible: oklch(0.55 0.009 255);
  --texte-tres-faible: oklch(0.60 0.008 255);
  --texte-inverse: #ffffff;
  --bordure: oklch(0.90 0.005 255);
  --bordure-forte: oklch(0.84 0.006 255);
  --bordure-faible: oklch(0.955 0.004 255);
  --fond: #ffffff;
  --fond-doux: oklch(0.985 0.003 255);
  --fond-gris: oklch(0.97 0.004 255);
  --fond-gris-2: oklch(0.93 0.004 255);
  --sombre: oklch(0.22 0.012 255);
  --sombre-2: oklch(0.26 0.012 255);
  --gris-moyen: oklch(0.74 0.008 255);

  /* 1. Voiles dérivés du fond sombre, opacités relevées. */
  --voile-14: oklch(0.22 0.012 255 / 0.14);
  --voile-18: oklch(0.22 0.012 255 / 0.18);
  --voile-24: oklch(0.22 0.012 255 / 0.24);
  --voile-28: oklch(0.22 0.012 255 / 0.28);
  --voile-30: oklch(0.22 0.012 255 / 0.30);
  --voile-35: oklch(0.22 0.012 255 / 0.35);
  --voile-40: oklch(0.22 0.012 255 / 0.40);
  --voile-55: oklch(0.22 0.012 255 / 0.55);

  /* 2. Couleur primaire. */
  --primaire: oklch(0.44 0.10 255);
  --primaire-fonce: oklch(0.34 0.10 255);
  --primaire-tres-fonce: oklch(0.30 0.10 255);
  --primaire-clair: oklch(0.97 0.014 255);
  --primaire-clair-2: oklch(0.93 0.025 255);
  --bleu-graphe: oklch(0.62 0.09 240);
  --bleu-graphe-2: oklch(0.62 0.09 250);

  /* 3.1 Famille « ok », conforme, vert. */
  --ok-fond: oklch(0.955 0.030 150);
  --ok-bordure: oklch(0.85 0.06 150);
  --ok-texte: oklch(0.36 0.11 150);
  --ok-plein: oklch(0.50 0.11 150);
  --ok-repere: oklch(0.62 0.13 150);
  --ok-reseau: oklch(0.72 0.13 150);

  /* 3.2 Famille « warn », à contrôler, orange. */
  --warn-fond: oklch(0.960 0.040 70);
  --warn-bordure: oklch(0.86 0.08 70);
  --warn-texte: oklch(0.42 0.13 65);
  --warn-plein: oklch(0.55 0.13 65);
  --warn-repere: oklch(0.74 0.15 70);
  --warn-bandeau: oklch(0.78 0.14 70);

  /* 3.3 Famille « bad », anomalie, rouge. */
  --bad-fond: oklch(0.955 0.035 25);
  --bad-bordure: oklch(0.85 0.09 25);
  --bad-texte: oklch(0.40 0.17 25);
  --bad-cellule: oklch(0.44 0.17 25);
  --bad-plein: oklch(0.50 0.17 25);
  --bad-repere: oklch(0.58 0.19 25);

  /* 3.4 Famille « info », bleu, et « neutre », gris. */
  --info-fond: oklch(0.960 0.020 240);
  --info-bordure: oklch(0.84 0.05 240);
  --info-texte: oklch(0.36 0.09 240);
  --info-texte-encart: oklch(0.34 0.06 240);
  --neutre-fond: oklch(0.97 0.004 255);
  --neutre-texte: oklch(0.45 0.010 255);

  /* 4. Code couleur des localités, imposé par le maître d'ouvrage. */
  --localite-supervision: #ffffff;
  --localite-supervision-contour: oklch(0.60 0.008 255);
  --localite-conforme: oklch(0.62 0.13 150);
  --localite-a-controler: oklch(0.74 0.15 70);
  --localite-anomalie: oklch(0.58 0.19 25);
  --localite-non-controle: oklch(0.74 0.008 255);

  /* 6. Rayons. */
  --rayon-pastille: 4px;
  --rayon-champ: 4px;
  --rayon-carte: 6px;
  --rayon-grande-carte: 8px;
  --rayon-puce: 3px;
  --rayon-pilule: 999px;

  /* 6. Hauteurs de contrôle imposées, côté web. */
  --hauteur-champ: 38px;
  --hauteur-bouton-secondaire: 36px;
  --hauteur-bouton-principal: 38px;

  /* Dimensions de coquille. */
  --largeur-barre-laterale: 250px;
  --largeur-tiroir: 560px;
  --ombre-tiroir: -8px 0 24px var(--voile-14);
  --ombre-modale: 0 8px 24px var(--voile-24);
  --ombre-toast: 0 8px 24px var(--voile-30);
}

/* --------------------------------------------------------------------------
   3. Réinitialisation minimale
   -------------------------------------------------------------------------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

/* L'attribut « hidden » masque, sans condition et quel que soit le sélecteur
   qui suit. Le navigateur ne le pose que par une règle de sa feuille par
   défaut, « display: none », que la moindre règle d'auteur écrase. Les voiles
   de la coquille déclarent tous « display: flex » : la modale de création, la
   modale d'import et la visionneuse de document restaient donc affichées,
   plein écran, alors que leur gabarit les servait fermées. La visionneuse,
   posée au-dessus des autres, interceptait les clics de la modale de création
   et rendait toute création impossible à la souris.

   Cette règle vaut pour tout ce qui viendra : un voile nouveau n'aura pas à se
   souvenir de la poser. « !important » est ici à sa place, l'attribut devant
   l'emporter par construction sur la mise en page qui le porte. */
[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--police-sans);
  font-size: var(--taille-corps);
  line-height: 1.45;
  color: var(--texte-fort);
  background: var(--fond-doux);
}

a {
  color: var(--primaire);
  text-decoration: none;
}

a:hover,
a:focus-visible {
  text-decoration: underline;
}

button,
input,
select,
textarea {
  font-family: inherit;
  font-size: inherit;
}

:focus-visible {
  outline: 2px solid var(--primaire);
  outline-offset: 2px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* --------------------------------------------------------------------------
   4. Coquille de l'application, barre latérale et zone principale
   -------------------------------------------------------------------------- */

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--largeur-barre-laterale) 1fr;
}

.sidebar {
  background: var(--sombre);
  color: var(--texte-inverse);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar__brand {
  padding: 15px 18px;
  border-bottom: 1px solid rgb(255 255 255 / 0.12);
}

.sidebar__brand-name {
  font-size: var(--taille-corps);
  font-weight: 700;
  letter-spacing: -0.01em;
}

.sidebar__brand-baseline {
  font-size: var(--taille-micro-libelle);
  opacity: 0.6;
  font-family: var(--police-mono);
}

.sidebar__nav {
  padding: 6px 8px 16px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  overflow-y: auto;
  flex: 1;
}

.sidebar__group-title {
  padding: 11px 12px 4px;
  font-family: var(--police-mono);
  font-size: 9.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  opacity: 0.45;
}

.sidebar__item {
  padding: 7px 12px;
  border-radius: var(--rayon-champ);
  font-size: var(--taille-secondaire);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: rgb(255 255 255 / 0.8);
}

.sidebar__item:hover {
  background: var(--sombre-2);
  color: var(--texte-inverse);
  text-decoration: none;
}

.sidebar__item--active {
  background: var(--primaire);
  color: var(--texte-inverse);
  font-weight: 600;
}

.sidebar__badge {
  background: var(--bad-repere);
  color: var(--texte-inverse);
  font-size: var(--taille-badge);
  font-weight: 700;
  border-radius: var(--rayon-pilule);
  padding: 1px 6px;
}

.sidebar__footer {
  padding: 11px 18px;
  border-top: 1px solid rgb(255 255 255 / 0.12);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.sidebar__version {
  font-family: var(--police-mono);
  font-size: var(--taille-micro-libelle);
  opacity: 0.6;
}

.sidebar__logout {
  background: none;
  border: none;
  color: var(--texte-inverse);
  font-size: 11.5px;
  opacity: 0.8;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
}

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* --------------------------------------------------------------------------
   5. Barre supérieure
   -------------------------------------------------------------------------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 11px 22px;
  background: var(--fond);
  border-bottom: 1px solid var(--bordure);
  position: sticky;
  top: 0;
  z-index: 5;
  flex-wrap: wrap;
}

.topbar__search {
  height: var(--hauteur-bouton-secondaire);
  padding: 0 12px;
  border: 1px solid var(--bordure-forte);
  border-radius: var(--rayon-champ);
  font-size: var(--taille-secondaire);
  flex: 1;
  min-width: 220px;
  background: var(--fond);
  color: var(--texte-fort);
}

.topbar__scope {
  height: 32px;
  padding: 0 11px;
  border: 1px solid var(--bordure);
  border-radius: var(--rayon-champ);
  background: var(--fond-gris);
  font-family: var(--police-mono);
  font-size: 11.5px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--texte-fort);
}

.topbar__identity {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.topbar__avatar {
  width: 30px;
  height: 30px;
  border-radius: var(--rayon-pilule);
  background: var(--primaire-clair-2);
  color: var(--primaire-tres-fonce);
  font-size: var(--taille-pastille);
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.topbar__names {
  font-size: var(--taille-mono);
  line-height: 1.2;
}

.topbar__name {
  font-weight: 600;
  display: block;
  color: var(--texte-fort);
}

.topbar__role {
  color: var(--texte-faible);
}

/* --------------------------------------------------------------------------
   6. Zone de contenu et en-tête de page
   -------------------------------------------------------------------------- */

.content {
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex: 1;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}

.page-header__breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--taille-mono);
  color: var(--texte);
  margin-bottom: 4px;
}

.page-header__breadcrumb-current {
  color: var(--sombre);
  font-weight: 500;
}

.page-header__title {
  font-size: var(--taille-indicateur);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0;
  color: var(--texte-fort);
}

.page-header__subtitle {
  font-size: var(--taille-cellule);
  color: var(--texte);
  margin-top: 3px;
  max-width: 96ch;
  line-height: 1.5;
}

.page-header__actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* --------------------------------------------------------------------------
   7. Boutons
   -------------------------------------------------------------------------- */

.button {
  height: var(--hauteur-bouton-secondaire);
  padding: 0 14px;
  border-radius: var(--rayon-champ);
  font: 600 var(--taille-secondaire) var(--police-sans);
  cursor: pointer;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}

.button--primary {
  height: var(--hauteur-bouton-principal);
  background: var(--primaire);
  color: var(--texte-inverse);
  border-color: var(--primaire);
}

.button--primary:hover {
  background: var(--primaire-fonce);
  text-decoration: none;
}

.button--secondary {
  background: var(--fond);
  color: var(--texte-fort);
  border-color: var(--bordure-forte);
}

.button--secondary:hover {
  border-color: var(--primaire);
  text-decoration: none;
}

.button--danger {
  background: var(--fond);
  color: var(--bad-cellule);
  border-color: var(--bad-plein);
}

.button--ghost {
  background: transparent;
  color: var(--texte-inverse);
  border-color: rgb(255 255 255 / 0.35);
  height: 32px;
  padding: 0 12px;
  font-size: var(--taille-mono);
}

.button--small {
  height: 32px;
  padding: 0 12px;
  font-size: var(--taille-mono);
}

.button--modal {
  height: var(--hauteur-bouton-principal);
  padding: 0 15px;
  font-size: var(--taille-bouton);
}

/* --------------------------------------------------------------------------
   8. Carte, filtres, tableau, pagination
   -------------------------------------------------------------------------- */

.card {
  background: var(--fond);
  border: 1px solid var(--bordure);
  border-radius: var(--rayon-grande-carte);
  overflow: hidden;
}

.filters {
  display: flex;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--bordure);
  flex-wrap: wrap;
  align-items: center;
}

.filters__search {
  height: 34px;
  padding: 0 11px;
  border: 1px solid var(--bordure-forte);
  border-radius: var(--rayon-champ);
  font-size: var(--taille-secondaire);
  flex: 1;
  min-width: 180px;
  background: var(--fond);
  color: var(--texte-fort);
}

.filters__select {
  height: 34px;
  padding: 0 11px;
  border: 1px solid var(--bordure-forte);
  border-radius: var(--rayon-champ);
  font-size: var(--taille-mono);
  background: var(--fond);
  color: var(--texte-fort);
  cursor: pointer;
}

.filters__select:hover {
  border-color: var(--primaire);
}

.table-scroll {
  overflow-x: auto;
}

.table {
  min-width: 980px;
}

.table__head,
.table__row {
  display: grid;
  gap: 12px;
  align-items: center;
}

.table__head {
  padding: 9px 14px;
  background: var(--fond-gris);
  border-bottom: 1px solid var(--bordure);
  font-family: var(--police-mono);
  font-size: var(--taille-micro-libelle);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--texte);
}

.table__row {
  padding: 11px 14px;
  border-bottom: 1px solid var(--bordure-faible);
  color: var(--texte-fort);
}

.table__row:nth-child(even) {
  background: var(--fond-doux);
}

.table__row:hover {
  background: var(--primaire-clair);
  text-decoration: none;
}

.table__open {
  text-align: right;
  font-size: var(--taille-mono);
  color: var(--primaire);
  font-weight: 600;
  white-space: nowrap;
}

.cell-defaut {
  font-size: var(--taille-cellule);
}

.cell-gras {
  font-size: var(--taille-cellule);
  font-weight: 500;
}

.cell-mono {
  font-family: var(--police-mono);
  font-size: var(--taille-mono);
}

.cell-num {
  font-family: var(--police-mono);
  font-size: var(--taille-mono);
  text-align: right;
}

.cell-rouge {
  font-size: var(--taille-cellule);
  color: var(--bad-cellule);
  font-weight: 500;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 11px 14px;
  border-top: 1px solid var(--bordure);
  flex-wrap: wrap;
}

.pagination__footer {
  font-size: var(--taille-mono);
  color: var(--texte);
}

.pagination__list {
  display: flex;
  align-items: center;
  gap: 6px;
}

.pagination__link {
  width: 30px;
  height: 30px;
  border: 1px solid var(--bordure-forte);
  border-radius: var(--rayon-champ);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: var(--taille-mono);
  color: var(--texte-fort);
}

.pagination__link:hover {
  border-color: var(--primaire);
  text-decoration: none;
}

.pagination__link--current {
  border-color: var(--primaire);
  background: var(--primaire);
  color: var(--texte-inverse);
  font-weight: 600;
}

.pagination__link--disabled {
  border-color: var(--fond-gris-2);
  color: var(--gris-moyen);
  pointer-events: none;
}

/* --------------------------------------------------------------------------
   9. Pastilles de statut, encarts de règle, repères de localité
   -------------------------------------------------------------------------- */

.chip {
  font-size: var(--taille-pastille);
  padding: 3px 8px;
  border-radius: var(--rayon-pastille);
  white-space: nowrap;
  display: inline-block;
}

.chip--ok {
  background: var(--ok-fond);
  color: var(--ok-texte);
}

.chip--warn {
  background: var(--warn-fond);
  color: var(--warn-texte);
}

.chip--bad {
  background: var(--bad-fond);
  color: var(--bad-texte);
  font-weight: 500;
}

.chip--info {
  background: var(--info-fond);
  color: var(--info-texte);
}

.chip--neutre {
  background: var(--neutre-fond);
  color: var(--neutre-texte);
}

.note {
  border-radius: var(--rayon-carte);
  padding: 12px 14px;
  font-size: var(--taille-mono);
  line-height: 1.5;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  border: 1px solid transparent;
}

.note__icon {
  font-weight: 700;
}

.note--info {
  border-color: var(--info-bordure);
  background: var(--info-fond);
  color: var(--info-texte-encart);
}

.note--warn {
  border-color: var(--warn-bordure);
  background: var(--warn-fond);
  color: var(--warn-texte);
}

.note--bad {
  border-color: var(--bad-bordure);
  background: var(--bad-fond);
  color: var(--bad-texte);
}

.note--ok {
  border-color: var(--ok-bordure);
  background: var(--ok-fond);
  color: var(--ok-texte);
}

.note--neutre {
  border-color: var(--bordure);
  background: var(--fond-gris);
  color: var(--neutre-texte);
}

/* Repère carré du code couleur des localités, toujours doublé d'un libellé. */

.locality-dot {
  width: 13px;
  height: 13px;
  border-radius: var(--rayon-puce);
  flex: none;
  display: inline-block;
  border: 1px solid transparent;
}

.locality-dot--supervision {
  background: var(--localite-supervision);
  border-color: var(--localite-supervision-contour);
}

.locality-dot--conforme {
  background: var(--localite-conforme);
}

.locality-dot--a-controler {
  background: var(--localite-a-controler);
}

.locality-dot--anomalie {
  background: var(--localite-anomalie);
}

.locality-dot--non-controle {
  background: var(--localite-non-controle);
}

/* --------------------------------------------------------------------------
   10. Surcouches : tiroir, modales, visionneuse, bandeau de retour
   -------------------------------------------------------------------------- */

.overlay {
  position: fixed;
  inset: 0;
  background: var(--voile-35);
  z-index: 20;
  border: none;
  padding: 0;
  width: 100%;
  cursor: default;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: var(--largeur-tiroir);
  max-width: 94vw;
  background: var(--fond);
  z-index: 21;
  box-shadow: var(--ombre-tiroir);
  display: flex;
  flex-direction: column;
}

.drawer__header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--bordure);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.drawer__ref {
  font-family: var(--police-mono);
  font-size: 11.5px;
  color: var(--texte);
}

.drawer__title {
  font-size: var(--taille-titre-page);
  font-weight: 700;
  letter-spacing: -0.015em;
  margin: 2px 0 0;
  color: var(--texte-fort);
}

.drawer__subtitle {
  font-size: var(--taille-secondaire);
  color: var(--texte);
  margin-top: 3px;
}

.drawer__body {
  padding: 18px 20px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.drawer__footer {
  padding: 14px 20px;
  border-top: 1px solid var(--bordure);
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  background: var(--fond-doux);
}

.icon-button {
  width: 30px;
  height: 30px;
  border: 1px solid var(--bordure);
  border-radius: var(--rayon-champ);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: var(--taille-corps);
  background: var(--fond);
  color: var(--texte-fort);
  flex: none;
}

.block {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.block__title {
  font-family: var(--police-mono);
  font-size: 10px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--texte);
  margin-bottom: 6px;
}

/* Deux colonnes alignées à gauche, l'intitulé au-dessus de la valeur dès que
   la place manque. L'alignement à droite d'origine renvoyait la fin des valeurs
   longues à la ligne, lettre par lettre : « externe » se lisait « extern / e ».
   La grille fixe la colonne des intitulés, la valeur prend ce qui reste. */
.block__row {
  display: grid;
  grid-template-columns: minmax(96px, 30%) 1fr;
  align-items: baseline;
  gap: 2px 16px;
  font-size: var(--taille-secondaire);
  padding: 9px 0;
  border-top: 1px solid var(--bordure-faible);
}

.block__key {
  color: var(--texte);
  line-height: 1.45;
}

.block__value {
  font-size: var(--taille-secondaire);
  font-weight: 500;
  text-align: left;
  line-height: 1.45;
  color: var(--texte-fort);
  /* La césure ne s'autorise qu'en dernier recours : elle sauve une adresse
     électronique ou un lien, et laisse les phrases se couper aux espaces. */
  overflow-wrap: anywhere;
}

/* Tiroir étroit ou téléphone : l'intitulé passe au-dessus, la valeur dispose
   alors de toute la largeur plutôt que d'un tiers. */
@media (max-width: 560px) {
  .block__row {
    grid-template-columns: 1fr;
    gap: 3px;
  }
}

.doc-block,
.comment-block {
  border: 1px solid var(--bordure);
  border-radius: var(--rayon-carte);
  padding: 12px 14px;
  background: var(--fond-doux);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.doc-block__head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.doc-block__icon {
  width: 34px;
  height: 42px;
  border: 1px solid var(--texte-tres-faible);
  border-radius: 2px;
  background: var(--fond);
  display: inline-flex;
  align-items: flex-end;
  justify-content: center;
  font-family: var(--police-mono);
  font-size: 8.5px;
  padding-bottom: 3px;
  flex: none;
}

.doc-block__name {
  display: block;
  font-size: var(--taille-cellule);
  font-weight: 600;
}

.doc-block__info {
  display: block;
  font-size: var(--taille-pastille);
  color: var(--texte);
}

.doc-block__actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.photos {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.photos__item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.photos__thumb {
  aspect-ratio: 1;
  border: 1px solid var(--bordure);
  border-radius: var(--rayon-champ);
  background: repeating-linear-gradient(
    45deg,
    var(--bordure-faible) 0 6px,
    var(--fond-gris-2) 6px 12px
  );
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 4px;
  font-family: var(--police-mono);
  font-size: 9px;
  color: var(--texte);
}

.photos__caption {
  font-size: 9.5px;
  color: var(--texte);
  line-height: 1.3;
}

.signature {
  border: 1px solid var(--bordure);
  border-radius: var(--rayon-champ);
  height: 58px;
  display: flex;
  align-items: flex-end;
  padding: 0 10px 6px;
  background: var(--fond);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--voile-40);
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
}

.modal {
  background: var(--fond);
  border-radius: var(--rayon-grande-carte);
  width: 100%;
  max-width: 760px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--ombre-modale);
}

.modal--wide {
  max-width: 780px;
}

.modal__header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--bordure);
}

.modal__title {
  font-size: var(--taille-titre-page);
  font-weight: 700;
  letter-spacing: -0.015em;
  margin: 0;
  color: var(--texte-fort);
}

.modal__subtitle {
  font-size: var(--taille-secondaire);
  color: var(--texte);
  margin-top: 3px;
  line-height: 1.45;
}

.modal__body {
  padding: 20px 22px;
  overflow-y: auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.modal__body--stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Refus de saisie, en tête du corps de la modale. Le corps est une grille à
   deux colonnes : l'encart les traverse, sans quoi il occuperait une demi-
   largeur et se lirait comme un champ de plus. */
.modal__error {
  grid-column: 1 / -1;
  margin-bottom: 2px;
}

.modal__footer {
  padding: 14px 22px;
  border-top: 1px solid var(--bordure);
  background: var(--fond-doux);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.modal__footer--end {
  justify-content: flex-end;
}

.modal__note {
  font-size: var(--taille-mono);
  color: var(--texte);
  max-width: 56ch;
  line-height: 1.4;
}

/* Bouton qui doit se lire comme un lien. Il sert là où l'action demande un
   « POST » mais où la place est celle d'un lien : la déconnexion depuis le pied
   de l'écran de changement de mot de passe. */
.link-button {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: var(--primaire);
  cursor: pointer;
}

.link-button:hover,
.link-button:focus-visible {
  text-decoration: underline;
}

.modal__buttons {
  display: flex;
  gap: 8px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field--wide {
  grid-column: 1 / -1;
}

.field__label {
  font: 600 var(--taille-secondaire) var(--police-sans);
  color: var(--texte-fort);
}

.field__help {
  font-size: var(--taille-pastille);
  color: var(--texte);
}

.field__input,
.field__select {
  height: var(--hauteur-champ);
  padding: 0 11px;
  border: 1px solid var(--bordure-forte);
  border-radius: var(--rayon-champ);
  font-size: var(--taille-cellule);
  width: 100%;
  background: var(--fond);
  color: var(--texte-fort);
}

.block__value--copiable {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  font-family: var(--police-mono, monospace);
  font-size: var(--taille-pastille);
  overflow-wrap: anywhere;
}

.field__password {
  display: flex;
  gap: 8px;
  align-items: center;
}

.field__password .field__input {
  font-family: var(--police-mono, monospace);
  letter-spacing: 0.02em;
}

.field__password .button {
  flex: none;
  white-space: nowrap;
}

.field__checks {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 11px;
  border: 1px solid var(--bordure-forte);
  border-radius: var(--rayon-champ);
  background: var(--fond);
  max-height: 340px;
  overflow-y: auto;
}

.field__check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--taille-cellule);
  color: var(--texte-fort);
  cursor: pointer;
}

.field__check input {
  flex: none;
  margin: 0;
}

/* Case à cocher enrichie : intitulé, éventuel badge, et une ligne d'impact.
   Employée à la sélection des rôles pour montrer ce que chaque profil accorde
   et s'il exige un second facteur, plutôt qu'un simple « R2 / R3 ». */
.field__check--rich {
  align-items: flex-start;
  gap: 9px;
  padding: 3px 2px;
}

.field__check--rich + .field__check--rich {
  border-top: 1px solid var(--bordure);
  padding-top: 7px;
}

.field__check--rich input {
  margin-top: 2px;
}

.field__check-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.field__check-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
}

.field__check-label {
  font-weight: 600;
  color: var(--texte-fort);
}

.field__check-note {
  font-size: 12px;
  line-height: 1.45;
  color: var(--texte-faible);
}

.field__badge {
  display: inline-flex;
  align-items: center;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 1px 7px;
  border-radius: var(--rayon-pilule);
  white-space: nowrap;
}

.field__badge--totp {
  color: var(--warn-texte);
  background: var(--warn-fond);
  border: 1px solid var(--warn-bordure);
}

.field__textarea {
  min-height: 62px;
  padding: 9px 11px;
  border: 1px solid var(--bordure-forte);
  border-radius: var(--rayon-champ);
  font-size: var(--taille-cellule);
  width: 100%;
  resize: vertical;
  background: var(--fond);
  color: var(--texte-fort);
}

.field__file {
  height: var(--hauteur-champ);
  padding: 6px 10px;
  border: 1px solid var(--bordure-forte);
  border-radius: var(--rayon-champ);
  font-size: var(--taille-mono);
  width: 100%;
  background: var(--fond);
  color: var(--texte-fort);
}

/* Assistant d'import à trois étapes */

.steps {
  display: flex;
  align-items: center;
  gap: 8px;
}

.steps__dot {
  width: 24px;
  height: 24px;
  border-radius: var(--rayon-pilule);
  font-size: var(--taille-pastille);
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  background: var(--fond);
  border: 1px solid var(--bordure-forte);
  color: var(--texte-faible);
}

.steps__dot--current {
  background: var(--primaire);
  color: var(--texte-inverse);
  border-color: var(--primaire);
}

.steps__dot--done {
  background: var(--ok-plein);
  color: var(--texte-inverse);
  border-color: var(--ok-plein);
}

.steps__bar {
  flex: 1;
  height: 2px;
  background: var(--bordure);
}

.steps__bar--done {
  background: var(--ok-plein);
}

.steps__labels {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  font-size: var(--taille-pastille);
  color: var(--texte);
}

.steps__labels span:nth-child(2) {
  text-align: center;
}

.steps__labels span:nth-child(3) {
  text-align: right;
}

.dropzone {
  border: 2px dashed var(--bordure-forte);
  border-radius: var(--rayon-grande-carte);
  padding: 26px;
  text-align: center;
  background: var(--fond-doux);
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
}

.dropzone__title {
  font-size: 14.5px;
  font-weight: 600;
}

.dropzone__hint {
  font-size: var(--taille-mono);
  color: var(--texte);
}

.mapping {
  border: 1px solid var(--bordure);
  border-radius: var(--rayon-carte);
  overflow: hidden;
}

.mapping__head,
.mapping__row {
  display: grid;
  grid-template-columns: 1fr 1fr 100px;
  gap: 12px;
  padding: 9px 14px;
  align-items: center;
}

.mapping__head {
  background: var(--fond-gris);
  border-bottom: 1px solid var(--bordure);
  font-family: var(--police-mono);
  font-size: var(--taille-micro-libelle);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--texte);
}

.mapping__row {
  border-bottom: 1px solid var(--bordure-faible);
  font-size: var(--taille-secondaire);
}

.mapping__source {
  font-family: var(--police-mono);
  font-size: var(--taille-pastille);
}

.tallies {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.tally {
  border-radius: var(--rayon-carte);
  padding: 12px 14px;
  border: 1px solid transparent;
}

.tally__label {
  font-size: var(--taille-pastille);
}

.tally__value {
  font-size: 24px;
  font-weight: 700;
}

.tally--ok {
  border-color: var(--ok-bordure);
  background: var(--ok-fond);
  color: var(--ok-texte);
}

.tally--warn {
  border-color: var(--warn-bordure);
  background: var(--warn-fond);
  color: var(--warn-texte);
}

.tally--bad {
  border-color: var(--bad-bordure);
  background: var(--bad-fond);
  color: var(--bad-texte);
}

.rejects {
  border: 1px solid var(--bordure);
  border-radius: var(--rayon-carte);
  overflow: hidden;
}

.rejects__row {
  display: grid;
  grid-template-columns: 74px 1fr 1.4fr;
  gap: 12px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--bordure-faible);
  font-size: var(--taille-mono);
  align-items: center;
}

.rejects__line,
.rejects__content {
  font-family: var(--police-mono);
  font-size: 11.5px;
}

.rejects__reason {
  font-size: var(--taille-mono);
  color: var(--bad-cellule);
}

.radio-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  font-size: var(--taille-secondaire);
}

.radio-row label {
  display: flex;
  gap: 8px;
  align-items: center;
  cursor: pointer;
}

/* Visionneuse de document */

.viewer {
  position: fixed;
  inset: 0;
  background: var(--voile-55);
  z-index: 40;
  display: flex;
  flex-direction: column;
}

.viewer__bar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 20px;
  background: var(--sombre);
  color: var(--texte-inverse);
  flex-wrap: wrap;
}

.viewer__name {
  font-family: var(--police-mono);
  font-size: var(--taille-mono);
}

.viewer__info {
  font-size: var(--taille-pastille);
  opacity: 0.7;
}

.viewer__actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
  align-items: center;
}

.viewer__scroll {
  flex: 1;
  overflow-y: auto;
  padding: 26px;
  display: flex;
  justify-content: center;
}

.sheet {
  background: var(--fond);
  width: 794px;
  max-width: 100%;
  min-height: 1000px;
  box-shadow: 0 8px 24px var(--voile-28);
  padding: 44px 48px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.sheet__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  border-bottom: 2px solid var(--sombre);
  padding-bottom: 14px;
}

.sheet__issuer {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.sheet__address {
  font-size: 11.5px;
  color: var(--texte);
  line-height: 1.5;
  margin-top: 3px;
}

.sheet__mark {
  width: 62px;
  height: 62px;
  background: repeating-conic-gradient(var(--sombre) 0% 25%, var(--fond) 0% 50%) 50% /
    8px 8px;
  outline: 1px solid var(--sombre);
}

.sheet__title {
  text-align: center;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.sheet__headers {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 20px;
  font-size: var(--taille-pastille);
  border: 1px solid var(--bordure);
  padding: 12px 14px;
}

.sheet__header-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.sheet__header-key {
  color: var(--texte);
}

.sheet__header-value {
  font-family: var(--police-mono);
  font-weight: 500;
}

.sheet__lines-head,
.sheet__line,
.sheet__total {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 0.8fr 0.9fr;
  gap: 8px;
  padding: 8px;
}

.sheet__lines-head {
  padding: 7px 8px;
  background: var(--sombre);
  color: var(--texte-inverse);
  font-size: var(--taille-micro-libelle);
  font-family: var(--police-mono);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.sheet__line {
  border-bottom: 1px solid var(--fond-gris-2);
  font-size: 11.5px;
}

.sheet__total {
  font-size: 11.5px;
  font-weight: 700;
  border-top: 1px solid var(--sombre);
}

.sheet__mono {
  font-family: var(--police-mono);
}

.sheet__num {
  font-family: var(--police-mono);
  text-align: right;
}

.sheet__notice {
  border: 1px solid var(--bordure);
  padding: 10px 12px;
  font-size: var(--taille-mention);
  line-height: 1.6;
  color: var(--texte-fort);
}

.sheet__signatures {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-top: auto;
  padding-top: 30px;
}

.sheet__signature {
  border-top: 1px solid var(--texte-tres-faible);
  padding-top: 6px;
  font-size: var(--taille-micro-libelle);
  color: var(--texte);
}

.sheet__footer {
  display: flex;
  justify-content: space-between;
  font-family: var(--police-mono);
  font-size: 9.5px;
  color: var(--texte-faible);
  border-top: 1px solid var(--fond-gris-2);
  padding-top: 8px;
}

/* Bandeau de retour */

.toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  background: var(--sombre);
  color: var(--texte-inverse);
  padding: 12px 18px;
  border-radius: var(--rayon-carte);
  font-size: var(--taille-cellule);
  box-shadow: var(--ombre-toast);
}

/* --------------------------------------------------------------------------
   11. États vide, chargement, erreur, et écran d'authentification
   -------------------------------------------------------------------------- */

.state {
  padding: 40px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
  color: var(--texte);
}

.state__title {
  font-size: 15px;
  font-weight: 600;
  color: var(--texte-fort);
}

.state__text {
  font-size: var(--taille-secondaire);
  max-width: 60ch;
  line-height: 1.5;
}

.spinner {
  width: 22px;
  height: 22px;
  border: 2px solid var(--bordure-forte);
  border-top-color: var(--primaire);
  border-radius: var(--rayon-pilule);
  animation: spin 700ms linear infinite;
}

.error-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
}

.error-card {
  background: var(--fond);
  border: 1px solid var(--bordure);
  border-radius: var(--rayon-grande-carte);
  padding: 32px 36px;
  max-width: 640px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.error-card__code {
  font-family: var(--police-mono);
  font-size: 11.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--texte);
}

.error-card__title {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0;
  color: var(--texte-fort);
}

.error-card__message {
  font-size: var(--taille-corps);
  line-height: 1.6;
}

.error-card__details {
  margin: 0;
  padding-left: 18px;
  font-size: var(--taille-secondaire);
  color: var(--texte);
}

.error-card__correlation {
  font-family: var(--police-mono);
  font-size: 11.5px;
  color: var(--texte-faible);
}

.auth {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.05fr 1fr;
}

.auth__aside {
  background: var(--sombre);
  color: var(--texte-inverse);
  padding: 52px 56px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 40px;
}

.auth__brand {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.auth__baseline {
  font-family: var(--police-mono);
  font-size: 11.5px;
  opacity: 0.6;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.auth__claim {
  font-size: var(--taille-synthese);
  line-height: 1.15;
  font-weight: 700;
  letter-spacing: -0.02em;
  max-width: 34ch;
}

.auth__text {
  font-size: 15px;
  line-height: 1.6;
  opacity: 0.78;
  max-width: 34ch;
}

.auth__reference {
  font-family: var(--police-mono);
  font-size: 11.5px;
  opacity: 0.55;
}

.auth__panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 28px;
  padding: 40px 32px;
  background: var(--fond-gris);
}

/* Le logo a un texte sombre sur fond transparent : il ne vit que sur le
   panneau clair, jamais sur le bandeau sombre. */
.auth__logo {
  width: 148px;
  height: auto;
}

/* Formulaire de connexion : quelques champs empilés, une colonne étroite se
   lit mieux qu'une modale de saisie pleine largeur. */
.modal--auth {
  max-width: 420px;
}

/* Le bouton passe en tête du pied, sur toute la largeur, et la mention
   secondaire se range dessous : dans 420 pixels, les deux côte à côte
   s'enroulaient et rejetaient le bouton sous le texte. */
.modal--auth .modal__footer {
  flex-direction: column-reverse;
  align-items: stretch;
  text-align: center;
}

.modal--auth .modal__buttons .button {
  flex: 1;
  justify-content: center;
}

/* --------------------------------------------------------------------------
   12. Animations et préférences d'accessibilité
   -------------------------------------------------------------------------- */

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes slideIn {
  from {
    transform: translateX(24px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.overlay,
.modal-backdrop,
.viewer,
.toast {
  animation: fadeIn 120ms ease-out;
}

.drawer {
  animation: slideIn 160ms ease-out;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* --------------------------------------------------------------------------
   13. Adaptation aux petits écrans et à l'impression
   -------------------------------------------------------------------------- */

@media (max-width: 1024px) {
  .app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .auth {
    grid-template-columns: 1fr;
  }

  .auth__aside {
    padding: 32px 24px;
  }

  .modal__body {
    grid-template-columns: 1fr;
  }
}

@media print {
  .sidebar,
  .topbar,
  .page-header__actions,
  .viewer__bar,
  .toast {
    display: none !important;
  }

  .viewer,
  .viewer__scroll {
    position: static;
    background: var(--fond);
    padding: 0;
    overflow: visible;
  }

  .sheet {
    box-shadow: none;
    width: auto;
  }
}
