/* =========================================================================
   Gestionnaire d'accès réseau — feuille de style du portail
   -------------------------------------------------------------------------
   Écrite à la main. Aucune ressource externe : polices système uniquement,
   aucune image distante, aucun CDN. L'application doit fonctionner sur un
   réseau fermé (spécification §20).

   Repère visuel principal : le « rail de fraîcheur ». Chaque carte, bannière
   et pastille porte simultanément une couleur, une marque typographique et un
   libellé textuel. Aucune information d'état ne repose sur la seule couleur.

   Contraintes : contraste AA, thème clair et sombre, aucune règle « style »
   en ligne (la politique de sécurité du contenu interdit « unsafe-inline »).
   ========================================================================= */

/* -------------------------------------------------------------------------
   1. Jetons de conception
   ------------------------------------------------------------------------- */

:root {
  color-scheme: light;

  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, "Noto Sans", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "Cascadia Mono", Menlo, Consolas,
    "Liberation Mono", monospace;

  --step--1: 0.8125rem;
  --step-0: 0.9375rem;
  --step-1: 1.0625rem;
  --step-2: 1.3125rem;
  --step-3: 1.75rem;
  --step-4: 2.25rem;

  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;

  --radius-sm: 3px;
  --radius-md: 5px;
  --radius-lg: 8px;
  --rail: 3px;

  --sidebar-width: 15.5rem;
  --content-max: 78rem;

  /* Surfaces et texte — thème clair */
  --bg: #e9edf1;
  --surface: #ffffff;
  --surface-2: #f4f7f9;
  --surface-3: #e7edf2;
  --border: #cfd8e1;
  --border-strong: #a9b6c4;
  --text: #16212c;
  --text-muted: #52616f;
  --shadow: 0 1px 2px rgba(16, 32, 48, 0.08), 0 6px 16px rgba(16, 32, 48, 0.06);

  /* Accent institutionnel : bleu ardoise sobre */
  --accent: #17506e;
  --accent-hover: #0f3b53;
  --accent-soft: #e3edf3;
  --accent-contrast: #ffffff;

  /* États — toujours accompagnés d'une marque et d'un libellé */
  --ok: #185f43;
  --ok-bg: #e5f1ea;
  --ok-border: #9bc9b3;
  --warn: #7d4c00;
  --warn-bg: #faf0dd;
  --warn-border: #ddb877;
  --crit: #9a1f29;
  --crit-bg: #fbe8ea;
  --crit-border: #e0a0a6;
  --neutral: #46535f;
  --neutral-bg: #eaeff3;
  --neutral-border: #c6d1db;

  --focus: #0b6ea8;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0d131a;
    --surface: #151e26;
    --surface-2: #1c2731;
    --surface-3: #24313d;
    --border: #2b3844;
    --border-strong: #3d4c5a;
    --text: #e3eaf1;
    --text-muted: #a2b0bd;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 20px rgba(0, 0, 0, 0.3);

    --accent: #6fb5d7;
    --accent-hover: #93cbe7;
    --accent-soft: #132935;
    --accent-contrast: #08131b;

    --ok: #5cc094;
    --ok-bg: #11251d;
    --ok-border: #2b5a45;
    --warn: #e0ad55;
    --warn-bg: #2a2113;
    --warn-border: #5c4720;
    --crit: #f08d95;
    --crit-bg: #2b1417;
    --crit-border: #63282e;
    --neutral: #9dabb8;
    --neutral-bg: #1e2a34;
    --neutral-border: #33424f;

    --focus: #7cc3ea;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d131a;
  --surface: #151e26;
  --surface-2: #1c2731;
  --surface-3: #24313d;
  --border: #2b3844;
  --border-strong: #3d4c5a;
  --text: #e3eaf1;
  --text-muted: #a2b0bd;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 20px rgba(0, 0, 0, 0.3);

  --accent: #6fb5d7;
  --accent-hover: #93cbe7;
  --accent-soft: #132935;
  --accent-contrast: #08131b;

  --ok: #5cc094;
  --ok-bg: #11251d;
  --ok-border: #2b5a45;
  --warn: #e0ad55;
  --warn-bg: #2a2113;
  --warn-border: #5c4720;
  --crit: #f08d95;
  --crit-bg: #2b1417;
  --crit-border: #63282e;
  --neutral: #9dabb8;
  --neutral-bg: #1e2a34;
  --neutral-border: #33424f;

  --focus: #7cc3ea;
}

:root[data-theme="light"] {
  color-scheme: light;
}

/* -------------------------------------------------------------------------
   2. Réinitialisation légère
   ------------------------------------------------------------------------- */

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--step-0);
  line-height: 1.55;
}

h1,
h2,
h3,
h4,
p,
ul,
ol,
dl,
dd,
figure {
  margin: 0;
}

ul,
ol {
  padding: 0;
  list-style: none;
}

img,
svg {
  max-width: 100%;
}

a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

a:hover {
  color: var(--accent-hover);
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

code,
.num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

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

.muted {
  color: var(--text-muted);
}

.note {
  font-size: var(--step--1);
}

.stack > * + * {
  margin-top: var(--space-4);
}

.cluster {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
}

/* -------------------------------------------------------------------------
   3. Structure générale
   ------------------------------------------------------------------------- */

.skip-link {
  position: absolute;
  left: var(--space-3);
  top: -4rem;
  z-index: 20;
  padding: var(--space-2) var(--space-4);
  background: var(--accent);
  color: var(--accent-contrast);
  border-radius: var(--radius-md);
  text-decoration: none;
  transition: top 120ms ease-in;
}

.skip-link:focus {
  top: var(--space-3);
  color: var(--accent-contrast);
}

.env-strip {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-4);
  background: var(--warn-bg);
  color: var(--warn);
  border-bottom: 1px solid var(--warn-border);
  font-size: var(--step--1);
  letter-spacing: 0.02em;
}

.env-strip__dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  min-height: 100vh;
  align-items: start;
}

.app-shell--bare {
  grid-template-columns: minmax(0, 1fr);
}

.app-main {
  min-width: 0;
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--space-5) var(--space-5) var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.app-content {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  flex: 1 1 auto;
}

/* -------------------------------------------------------------------------
   4. Barre latérale
   ------------------------------------------------------------------------- */

.app-sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  max-height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  padding: var(--space-4) var(--space-3);
  background: var(--surface);
  border-right: 1px solid var(--border);
}

.app-sidebar__brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  flex: none;
  border-radius: var(--radius-md);
  background: var(--accent);
  color: var(--accent-contrast);
  font-family: var(--font-mono);
  font-size: var(--step--1);
  font-weight: 700;
  letter-spacing: 0.04em;
}

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

.brand-text__name {
  font-weight: 650;
  font-size: var(--step--1);
  line-height: 1.25;
}

.brand-text__role {
  color: var(--text-muted);
  font-size: var(--step--1);
}

.app-nav {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  flex: 1 1 auto;
}

.app-nav__heading {
  margin: 0 var(--space-2) var(--space-2);
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.11em;
  color: var(--text-muted);
  font-weight: 650;
}

.app-nav__list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.app-nav__link {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  border-left: var(--rail) solid transparent;
  color: var(--text);
  text-decoration: none;
  font-size: var(--step--1);
}

.app-nav__link:hover {
  background: var(--surface-2);
  color: var(--text);
}

.app-nav__link.is-current {
  background: var(--accent-soft);
  border-left-color: var(--accent);
  color: var(--accent);
  font-weight: 650;
}

.app-nav__list--compact .app-nav__link {
  padding-block: var(--space-1);
}

.app-sidebar__foot {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
}

.app-sidebar__user {
  display: flex;
  flex-direction: column;
  padding: 0 var(--space-2);
  font-size: var(--step--1);
  word-break: break-word;
}

.app-sidebar__user-name {
  font-weight: 650;
}

.app-sidebar__logout {
  margin: 0;
}

/* -------------------------------------------------------------------------
   5. En-tête de page
   ------------------------------------------------------------------------- */

.page-header {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  align-items: flex-end;
  justify-content: space-between;
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--border);
}

.page-header__text {
  min-width: 0;
}

.page-header__title {
  font-size: var(--step-3);
  line-height: 1.15;
  letter-spacing: -0.015em;
  font-weight: 680;
}

.page-header__subtitle {
  margin-top: var(--space-1);
  color: var(--text-muted);
  max-width: 60ch;
}

.page-header__side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--space-2);
}

.breadcrumbs {
  font-size: var(--step--1);
  color: var(--text-muted);
  margin-bottom: var(--space-1);
}

.breadcrumbs a {
  color: var(--text-muted);
}

.scope-tag {
  display: inline-flex;
  align-items: baseline;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-3);
  border: 1px solid var(--border);
  border-left: var(--rail) solid var(--accent);
  border-radius: var(--radius-md);
  background: var(--surface);
  font-size: var(--step--1);
}

.scope-tag__label {
  text-transform: uppercase;
  letter-spacing: 0.09em;
  font-size: 0.6875rem;
  color: var(--text-muted);
}

.scope-tag__value {
  font-weight: 650;
}

.section-head {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: baseline;
  justify-content: space-between;
}

.section-head__title {
  font-size: var(--step-2);
  font-weight: 660;
  letter-spacing: -0.01em;
}

.section-head__note {
  font-size: var(--step--1);
  max-width: 60ch;
}

/* -------------------------------------------------------------------------
   6. Cartes et grilles
   ------------------------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow);
}

.card--narrow {
  max-width: 44rem;
}

.card__head {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}

.card__title {
  font-size: var(--step-1);
  font-weight: 660;
}

.card__actions {
  margin-top: var(--space-4);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(19rem, 1fr));
  gap: var(--space-4);
}

.card-grid--metrics {
  grid-template-columns: repeat(auto-fit, minmax(12.5rem, 1fr));
}

/* Rail de fraîcheur : signale l'état d'un emplacement d'un seul coup d'œil. */
.card--rail-ok {
  border-left: var(--rail) solid var(--ok);
}

.card--rail-avertissement {
  border-left: var(--rail) solid var(--warn);
}

.card--rail-critique {
  border-left: var(--rail) solid var(--crit);
}

.card--rail-neutre {
  border-left: var(--rail) solid var(--neutral-border);
}

.card--site .datalist {
  margin-block: var(--space-4);
}

/* -------------------------------------------------------------------------
   7. Indicateurs chiffrés
   ------------------------------------------------------------------------- */

.metric {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: var(--rail) solid var(--neutral-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  box-shadow: var(--shadow);
}

.metric--ok {
  border-left-color: var(--ok);
}

.metric--warn {
  border-left-color: var(--warn);
}

.metric--crit {
  border-left-color: var(--crit);
}

.metric__value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: var(--step-4);
  line-height: 1.05;
  letter-spacing: -0.03em;
  font-weight: 600;
}

.metric__unit {
  font-size: var(--step-0);
  margin-left: 0.2em;
  color: var(--text-muted);
}

.metric__label {
  margin-top: var(--space-2);
  font-size: var(--step--1);
  font-weight: 620;
}

.metric__note {
  font-size: var(--step--1);
}

/* -------------------------------------------------------------------------
   8. Listes de données
   ------------------------------------------------------------------------- */

.datalist {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.datalist__row {
  display: flex;
  gap: var(--space-3);
  justify-content: space-between;
  align-items: baseline;
  padding: var(--space-1) 0;
  border-bottom: 1px dotted var(--border);
}

.datalist__row:last-child {
  border-bottom: 0;
}

.datalist dt {
  color: var(--text-muted);
  font-size: var(--step--1);
}

.datalist dd {
  text-align: right;
  min-width: 0;
}

/* -------------------------------------------------------------------------
   9. Tableaux
   ------------------------------------------------------------------------- */

.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--step--1);
}

.table caption {
  text-align: left;
  padding: var(--space-3) var(--space-4);
  color: var(--text-muted);
}

.table th,
.table td {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--border);
}

.table thead th {
  position: sticky;
  top: 0;
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  font-weight: 650;
  white-space: nowrap;
}

.table tbody tr:last-child th,
.table tbody tr:last-child td {
  border-bottom: 0;
}

.table tbody tr:hover {
  background: var(--surface-2);
}

.table tbody th {
  font-weight: 620;
}

.table [data-sort] {
  cursor: pointer;
  user-select: none;
}

.table [data-sort]::after {
  content: " ↕";
  color: var(--text-muted);
}

.table [data-sort].is-sorted-asc::after {
  content: " ↑";
  color: var(--accent);
}

.table [data-sort].is-sorted-desc::after {
  content: " ↓";
  color: var(--accent);
}

.table--capabilities td:last-child {
  max-width: 32rem;
}

/* -------------------------------------------------------------------------
   10. Pastilles, bannières et messages
   ------------------------------------------------------------------------- */

.pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0.15rem var(--space-3);
  border-radius: 999px;
  border: 1px solid var(--neutral-border);
  background: var(--neutral-bg);
  color: var(--neutral);
  font-size: var(--step--1);
  font-weight: 620;
  line-height: 1.5;
  white-space: nowrap;
}

.pill__icon {
  font-family: var(--font-mono);
  font-weight: 700;
}

.pill__text {
  white-space: normal;
}

.pill--ok {
  border-color: var(--ok-border);
  background: var(--ok-bg);
  color: var(--ok);
}

.pill--warn {
  border-color: var(--warn-border);
  background: var(--warn-bg);
  color: var(--warn);
}

.pill--crit {
  border-color: var(--crit-border);
  background: var(--crit-bg);
  color: var(--crit);
}

.pill--neutral {
  border-color: var(--neutral-border);
  background: var(--neutral-bg);
  color: var(--neutral);
}

.pill--mini {
  font-size: 0.6875rem;
  padding: 0 var(--space-2);
  margin-left: var(--space-2);
}

.banner,
.flash {
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--neutral-border);
  border-left: var(--rail) solid var(--neutral);
  border-radius: var(--radius-md);
  background: var(--neutral-bg);
  color: var(--text);
  font-size: var(--step--1);
}

.banner__mark,
.flash__mark {
  font-family: var(--font-mono);
  font-weight: 700;
  line-height: 1.6;
  flex: none;
}

.banner__body,
.flash__body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.banner__title,
.flash__title {
  font-weight: 660;
}

.banner--ok,
.flash--ok {
  border-color: var(--ok-border);
  border-left-color: var(--ok);
  background: var(--ok-bg);
}

.banner--ok .banner__mark,
.banner--ok .banner__title,
.flash--ok .flash__mark,
.flash--ok .flash__title {
  color: var(--ok);
}

.banner--warn,
.flash--warn {
  border-color: var(--warn-border);
  border-left-color: var(--warn);
  background: var(--warn-bg);
}

.banner--warn .banner__mark,
.banner--warn .banner__title,
.flash--warn .flash__mark,
.flash--warn .flash__title {
  color: var(--warn);
}

.banner--crit,
.flash--crit {
  border-color: var(--crit-border);
  border-left-color: var(--crit);
  background: var(--crit-bg);
}

.banner--crit .banner__mark,
.banner--crit .banner__title,
.flash--crit .flash__mark,
.flash--crit .flash__title {
  color: var(--crit);
}

.flash--info {
  border-color: var(--border);
  border-left-color: var(--accent);
  background: var(--accent-soft);
}

.flash--info .flash__mark,
.flash--info .flash__title {
  color: var(--accent);
}

.flash-zone {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.flash {
  align-items: center;
}

.flash__close {
  margin-left: auto;
  border: 0;
  background: transparent;
  color: inherit;
  font-size: var(--step-1);
  line-height: 1;
  cursor: pointer;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
}

.flash__close:hover {
  background: rgba(127, 127, 127, 0.18);
}

/* -------------------------------------------------------------------------
   11. Jauges (crédits) — largeur pilotée par classe, jamais en ligne
   ------------------------------------------------------------------------- */

.credit {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.credit__total {
  font-size: var(--step--1);
}

.meter {
  display: inline-block;
  width: 7rem;
  height: 0.5rem;
  border-radius: 999px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  overflow: hidden;
  vertical-align: middle;
}

.meter__bar {
  display: block;
  height: 100%;
  background: var(--neutral);
  border-radius: inherit;
}

.meter__bar--ok {
  background: var(--ok);
}

.meter__bar--warn {
  background: var(--warn);
}

.meter__bar--crit {
  background: var(--crit);
}

.meter__bar--p0 { width: 0; }
.meter__bar--p5 { width: 5%; }
.meter__bar--p10 { width: 10%; }
.meter__bar--p15 { width: 15%; }
.meter__bar--p20 { width: 20%; }
.meter__bar--p25 { width: 25%; }
.meter__bar--p30 { width: 30%; }
.meter__bar--p35 { width: 35%; }
.meter__bar--p40 { width: 40%; }
.meter__bar--p45 { width: 45%; }
.meter__bar--p50 { width: 50%; }
.meter__bar--p55 { width: 55%; }
.meter__bar--p60 { width: 60%; }
.meter__bar--p65 { width: 65%; }
.meter__bar--p70 { width: 70%; }
.meter__bar--p75 { width: 75%; }
.meter__bar--p80 { width: 80%; }
.meter__bar--p85 { width: 85%; }
.meter__bar--p90 { width: 90%; }
.meter__bar--p95 { width: 95%; }
.meter__bar--p100 { width: 100%; }

/* -------------------------------------------------------------------------
   12. Fiabilité des données applicatives
   ------------------------------------------------------------------------- */

.confidence {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.confidence__source {
  font-size: var(--step--1);
}

/* -------------------------------------------------------------------------
   13. Boutons
   ------------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: var(--step--1);
  font-weight: 620;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease;
}

.btn:hover {
  background: var(--surface-2);
  color: var(--text);
}

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
}

.btn--primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: var(--accent-contrast);
}

.btn--danger {
  background: var(--crit-bg);
  border-color: var(--crit-border);
  color: var(--crit);
}

.btn--danger:hover {
  background: var(--crit);
  border-color: var(--crit);
  color: var(--surface);
}

.btn--ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}

.btn--ghost:hover {
  background: var(--surface-2);
}

.btn--block {
  width: 100%;
}

/* -------------------------------------------------------------------------
   14. Formulaires
   ------------------------------------------------------------------------- */

.form-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  margin: 0;
}

.form-field label,
.form-label {
  font-size: var(--step--1);
  font-weight: 620;
}

.form-input,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="number"],
input[type="date"],
input[type="time"],
input[type="datetime-local"],
select,
textarea {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: var(--step-0);
}

input[type="number"],
input[type="date"],
input[type="time"],
input[type="datetime-local"] {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

textarea {
  min-height: 6rem;
  resize: vertical;
}

.form-field--check {
  flex-direction: row;
  align-items: center;
  gap: var(--space-2);
}

.form-check,
input[type="checkbox"],
input[type="radio"] {
  width: 1rem;
  height: 1rem;
  accent-color: var(--accent);
  flex: none;
}

.form-field--check label {
  font-weight: 500;
}

.form-hint {
  font-size: var(--step--1);
  color: var(--text-muted);
}

.form-error {
  font-size: var(--step--1);
  color: var(--crit);
  font-weight: 620;
}

.form-error::before {
  content: "✕ ";
  font-family: var(--font-mono);
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin: 0;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr));
  gap: var(--space-4);
}

fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  margin: 0;
}

legend {
  padding: 0 var(--space-2);
  font-size: var(--step--1);
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

/* Listes de cases à cocher produites par WTForms */
fieldset ul,
.form-field ul {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-4);
}

fieldset ul li,
.form-field ul li {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--step--1);
}

/* -------------------------------------------------------------------------
   15. Pagination
   ------------------------------------------------------------------------- */

.pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.pagination__status {
  font-size: var(--step--1);
  color: var(--text-muted);
}

.pagination__list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  align-items: center;
}

.pagination__link {
  display: inline-block;
  min-width: 2.25rem;
  padding: var(--space-1) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  text-align: center;
  text-decoration: none;
  font-size: var(--step--1);
  font-variant-numeric: tabular-nums;
}

.pagination__link:hover {
  background: var(--surface-2);
  color: var(--text);
}

.pagination__link.is-current {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
  font-weight: 650;
}

.pagination__link.is-disabled {
  opacity: 0.5;
}

.pagination__gap {
  padding: 0 var(--space-1);
  color: var(--text-muted);
}

/* -------------------------------------------------------------------------
   16. États vides, étapes, secrets
   ------------------------------------------------------------------------- */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-6) var(--space-4);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--surface-2);
  text-align: center;
}

.empty-state__icon {
  font-family: var(--font-mono);
  font-size: var(--step-3);
  color: var(--text-muted);
  line-height: 1;
}

.empty-state__title {
  font-weight: 660;
  font-size: var(--step-1);
}

.empty-state__message {
  color: var(--text-muted);
  max-width: 46ch;
}

.steps {
  counter-reset: etape;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.steps li {
  counter-increment: etape;
  display: flex;
  gap: var(--space-3);
  align-items: baseline;
  font-size: var(--step--1);
}

.steps li::before {
  content: counter(etape);
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--accent);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 var(--space-2);
  flex: none;
}

.qr-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
}

/* Le code QR est toujours rendu sombre sur clair pour rester lisible. */
.qr-panel__code {
  padding: var(--space-3);
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  line-height: 0;
}

.qr-panel__code svg {
  width: 12rem;
  height: 12rem;
  display: block;
}

.qr-panel__note {
  font-size: var(--step--1);
  text-align: center;
}

.secret-block {
  display: block;
  padding: var(--space-2) var(--space-3);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  word-break: break-all;
  letter-spacing: 0.08em;
}

.error-code {
  font-size: var(--step-4);
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: -0.03em;
  line-height: 1;
  margin-bottom: var(--space-3);
}

.auth-card {
  max-width: 26rem;
  margin: var(--space-6) auto;
}

.auth-card__note {
  margin-top: var(--space-4);
  font-size: var(--step--1);
  text-align: center;
}

/* -------------------------------------------------------------------------
   17. Pied de page
   ------------------------------------------------------------------------- */

.app-footer {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  justify-content: space-between;
  align-items: baseline;
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: var(--step--1);
}

.app-footer__env {
  font-family: var(--font-mono);
}

.app-footer__right {
  max-width: 52ch;
  text-align: right;
}

/* -------------------------------------------------------------------------
   18. Utilitaires pilotés par le script
   ------------------------------------------------------------------------- */

.is-filtered-out {
  display: none;
}

/* Cellule d'horaire hebdomadaire (grilles de plages horaires). Déclarée ici
   plutôt que dans un gabarit : la politique de sécurité du contenu de
   production interdit les blocs « style » en ligne. */
.schedule-cell {
  white-space: nowrap;
}

.is-refreshing {
  opacity: 0.6;
}

/* -------------------------------------------------------------------------
   19. Adaptation aux petits écrans
   ------------------------------------------------------------------------- */

@media (max-width: 60rem) {
  .app-shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .app-sidebar {
    position: static;
    max-height: none;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .app-nav {
    flex-direction: row;
    flex-wrap: wrap;
    gap: var(--space-4);
  }

  .app-nav__list {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .app-sidebar__foot {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
  }

  .app-sidebar__logout,
  .app-sidebar__foot .btn--block {
    width: auto;
  }

  .app-main {
    padding: var(--space-4);
  }

  .page-header__side {
    align-items: flex-start;
  }

  .app-footer__right {
    text-align: left;
  }
}

@media (max-width: 34rem) {
  .table thead th {
    position: static;
  }

  .datalist__row {
    flex-direction: column;
    gap: 0;
  }

  .datalist dd {
    text-align: left;
  }
}

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

@media print {
  .app-sidebar,
  .env-strip,
  .skip-link,
  .page-header__actions,
  .flash__close {
    display: none;
  }

  .app-shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .card,
  .table-scroll {
    box-shadow: none;
  }
}
