/*
 * Mecapix — prototype v2 (modernisation du gabarit)
 * Feuille de style autonome, sans dépendance à Bootstrap.
 */

:root {
  /* Palette Mecapix — reprend les couleurs historiques du thème (styles.css) */
  --teal: #12bbad;          /* couleur de marque : fonds, icônes, accents */
  --accent: #1b6f9e;        /* actions (boutons, liens) : milieu du dégradé teal→indigo, contraste 5,5:1 */
  --accent-hover: #155a82;
  --teal-dark: var(--accent); /* alias conservé pour les anciennes règles */
  --indigo: #4f70ce;        /* couleur secondaire (dégradé des icônes) */
  --complement: #ff6a00;    /* orange vif, complémentaire de --accent (teinte 202° → 25°) : indicateurs de chargement, texte incrusté sur les images */
  --disabled: #b8c2ca;      /* texte d'une option inactive */
  /* Repères tracés sur les images : couleurs saturées, visibles sur n'importe quelle photo */
  --mark: #ff2d2d;          /* sélections, croix, lignes de mesure */
  --mark-ok: #00e05a;       /* éléments réglables : seuil, zone de mise au point */
  --mark-zone: rgba(27, 111, 158, 0.35); /* zones exclues (masque), teinte --accent */
  --danger: #c0392b;
  --warning: #b7791f;
  --success: #2f855a;
  --ink: #16202a;
  --ink-soft: #4a5a68;
  --muted: #7c8a96;
  --surface: #ffffff;
  --bg: #f6f8f9;
  --border: #e4e9ec;
  --shadow-sm: 0 1px 2px rgba(16, 24, 32, 0.06);
  --shadow-md: 0 8px 24px rgba(16, 24, 32, 0.08);
  --shadow-lg: 0 20px 48px rgba(16, 24, 32, 0.14);
  --radius: 14px;
  --radius-sm: 8px;
  --max-width: 1120px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  /* Page de démarrage : pied de page en bas de l'écran, contenu centré dans l'espace restant */
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.page-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

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

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

img {
  max-width: 100%;
  vertical-align: middle;
}

.wrap {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
}

/* ---------- Navbar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--border);
}

.topbar .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--ink);
  letter-spacing: -0.01em;
}

/* Traînée de 3 points opaques chevauchés de 4 px, du plus clair (gauche) au plus soutenu (droite).
   Teintes = dégradé de marque mélangé au blanc (25 %, 55 %, 100 %), sans transparence. */
.nav-brand .dots {
  display: inline-flex;
  align-items: center;
}

.nav-brand .dots span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--teal), var(--indigo));
}

.nav-brand .dots span + span { margin-left: -4px; }
.nav-brand .dots span:nth-child(1) { background: linear-gradient(135deg, #c4eeeb, #d3dbf3); }
.nav-brand .dots span:nth-child(2) { background: linear-gradient(135deg, #7ddad2, #9eb0e4); }

.nav-logos {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* Logos monochromes (couleur --ink) */
.nav-logos .logo {
  display: flex;
  align-items: center;
}

.nav-logos .logo img {
  display: block;
  width: auto;
  height: var(--logo-h);
}

/* Hauteurs ajustées pour équilibrer visuellement les deux logos */
.nav-logos .logo-ecn { --logo-h: 34px; }
.nav-logos .logo-gem { --logo-h: 36px; }

.nav-logos-sep {
  width: 1px;
  height: 26px;
  background: var(--border);
}

@media (max-width: 480px) {
  .nav-logos { gap: 10px; }
  .nav-logos .logo-ecn { --logo-h: 26px; }
  .nav-logos .logo-gem { --logo-h: 28px; }
}

/* ---------- Hero ---------- */

.hero {
  padding: 72px 0 48px;
  text-align: center;
}

.hero h1 {
  font-size: clamp(1.9rem, 4vw, 2.8rem);
  font-weight: 700;
  letter-spacing: -0.015em;
  margin: 0 0 14px;
  color: var(--ink);
}

.hero p {
  font-size: 1.05rem;
  color: var(--ink-soft);
  max-width: 640px;
  margin: 0 auto;
}

/* ---------- Module grid ---------- */

.modules {
  padding: 8px 0 80px;
}

/* 4 colonnes, puis 2, puis 1 : jamais de carte orpheline */
.grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}

@media (max-width: 1000px) {
  .grid { grid-template-columns: repeat(2, 1fr); }
}

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

.module-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: flex-start;
  text-align: left;
}

.module-card:hover,
.module-card:focus-visible {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
  border-color: rgba(18, 187, 173, 0.45);
}

/* Navigation clavier : anneau de focus visible */
.module-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.card-icon {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--teal), var(--indigo));
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.15);
}

/* Icônes SVG blanches (générées par tools/make_card_icons.py) */
.card-icon img {
  height: 40px;
  width: 40px;
  display: block;
}

/* Titres sur 2 lignes réservées : les descriptions démarrent toutes à la même hauteur */
.module-card h2 {
  margin: 0;
  font-size: 1.08rem;
  font-weight: 650;
  line-height: 1.3;
  min-height: 2.6em;
  display: flex;
  align-items: flex-start;
  color: var(--ink);
}

.module-card p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.9rem;
  flex-grow: 1;
}

.card-cta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--teal-dark);
}

.card-cta .arrow {
  transition: transform 0.15s ease;
}

.module-card:hover .card-cta .arrow,
.module-card:focus-visible .card-cta .arrow {
  transform: translateX(3px);
}

/* ---------- Footer ---------- */

.footer {
  border-top: 1px solid var(--border);
  padding: 28px 0;
  text-align: center;
}

.footer p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.82rem;
}

/* Crédits des algorithmes du module, au-dessus du copyright */
.footer .footer-credits {
  margin-bottom: 6px;
  color: var(--muted);
}

.footer .footer-credits a { color: inherit; text-decoration: underline; }
.footer .footer-credits a:hover,
.footer .footer-credits a:focus-visible { color: var(--accent); }

.nav-left {
  display: flex;
  align-items: center;
  gap: 20px;
}

/* Pastille de version, à côté du nom Mecapix */
.version {
  padding: 1px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  color: var(--ink-soft);
  white-space: nowrap;
  cursor: default;
}

.footer .icons {
  display: inline-flex;
  gap: 10px;
  margin-left: 10px;
  vertical-align: middle;
}

.footer .icons img {
  height: 16px;
  opacity: 0.6;
}

.footer .icons a:hover img,
.footer .icons a:focus-visible img {
  opacity: 1;
}

/* Spinner : voir templates/mecapix/spinner.html (points qui glissent) */

@media (max-width: 640px) {
  .hero { padding: 48px 0 32px; }
}

/* Moins d'animations si l'utilisateur l'a demandé dans son système */
@media (prefers-reduced-motion: reduce) {
  .module-card,
  .card-cta .arrow {
    transition: none;
  }
  .module-card:hover,
  .module-card:focus-visible {
    transform: none;
  }
  .module-card:hover .card-cta .arrow,
  .module-card:focus-visible .card-cta .arrow {
    transform: none;
  }
}

/* =====================================================================
 * Pages des modules (pathFINDER, …)
 * Chargé APRÈS styles.css (Bootstrap 4) : classes préfixées pour éviter
 * toute collision (.topbar, .ui-*, .pf-*).
 * ===================================================================== */

/* Pages des modules : barre du haut et pied de page à la largeur du contenu */
.app-page .topbar .wrap,
.app-page .footer .wrap { max-width: 1440px; }

.app-main {
  flex: 1;
  text-align: left;
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 20px 24px 32px;
}

/* --- Barre du haut : fil d'Ariane module + liens --- */
.topbar .crumb {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-weight: 600;
}

.topbar .crumb-sep {
  color: var(--border);
  font-weight: 400;
  font-size: 1.3rem;
}

.topbar .crumb-icon {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--teal), var(--indigo));
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.topbar .crumb-icon img { width: 20px; height: 20px; }

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

.topbar-links a {
  padding: 7px 14px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--ink-soft);
}

.topbar-links a:hover,
.topbar-links a:focus-visible {
  background: var(--bg);
  color: var(--ink);
  text-decoration: none;
}

.topbar-links a.is-active {
  background: rgba(27, 111, 158, 0.10);
  color: var(--teal-dark);
}

/* --- Boutons --- */
.ui-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.3;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.ui-btn:hover { text-decoration: none; }

.ui-btn-primary { background: var(--teal-dark); color: #fff; }
.ui-btn-primary:hover, .ui-btn-primary:focus-visible { background: var(--accent-hover); color: #fff; }

.ui-btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--border); }
.ui-btn-secondary:hover, .ui-btn-secondary:focus-visible { border-color: var(--accent); color: var(--accent); }

.ui-btn-sm { padding: 5px 12px; font-size: 0.82rem; }

/* Bouton de fin d'étape (Validate, Upload) : pilule au dégradé de marque,
   pour le distinguer des boutons d'action ordinaires */
.ui-btn-confirm {
  padding: 10px 22px;
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--teal), var(--indigo));
  color: #fff;
  box-shadow: 0 4px 14px rgba(79, 112, 206, 0.35);
  transition: box-shadow 0.15s ease, transform 0.15s ease, filter 0.15s ease;
}
.ui-btn-confirm:hover,
.ui-btn-confirm:focus-visible {
  color: #fff;
  box-shadow: 0 6px 20px rgba(79, 112, 206, 0.5);
  transform: translateY(-1px);
  filter: brightness(1.04);
}
.ui-btn-confirm:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ui-btn-confirm:active { transform: none; box-shadow: 0 2px 8px rgba(79, 112, 206, 0.35); }
.ui-btn-confirm:disabled { opacity: 0.55; cursor: default; transform: none; box-shadow: none; }

/* ---------- Zone de dépôt de fichiers ----------
 * Construite par le script de app_base.html autour de chaque input[type=file].
 * L'input natif recouvre toute la zone (opacity 0) : clic et glisser-déposer
 * restent gérés par le navigateur, le formulaire n'est pas modifié. */
.ui-drop {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: min(100%, 520px);
  margin: 8px 0;
  padding: 26px 20px;
  border: 2px dashed #c9d3da;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink-soft);
  text-align: center;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}
.ui-drop.is-centered { margin-inline: auto; }
.ui-drop input[type="file"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  font-size: 0; /* évite le curseur texte sur certains navigateurs */
}
.ui-drop:hover,
.ui-drop.is-dragover {
  border-color: var(--accent);
  background: #f2f8fb;
}
.ui-drop.is-dragover { box-shadow: 0 0 0 4px rgba(27, 111, 158, 0.12); }
.ui-drop:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(27, 111, 158, 0.25); }
.ui-drop.has-files { border-style: solid; border-color: var(--teal); }

.ui-drop-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--teal), var(--indigo));
  color: #fff;
}
.ui-drop-icon svg { width: 22px; height: 22px; }
.ui-drop-title { font-weight: 600; color: var(--ink); }
.ui-drop-title u { color: var(--accent); text-underline-offset: 3px; }
.ui-drop-hint { font-size: 0.8rem; color: var(--muted); }

.ui-drop-files {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  width: 100%;
  max-height: 160px;
  overflow: auto;
  text-align: left;
  font-size: 0.82rem;
}
.ui-drop-files li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 10px;
  border-radius: 6px;
}
.ui-drop-files li:nth-child(odd) { background: var(--bg); }
.ui-drop-files .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); }
.ui-drop-files .size { flex: none; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- Listes de choix (select) ----------
 * Apparence native retirée, flèche dessinée en SVG : rendu identique
 * dans Chrome, Edge, Opera, Firefox et Safari. */
.app-page select:not([multiple]):not([size]) {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  max-width: 100%;
  padding: 7px 36px 7px 12px;
  border: 1px solid #c9d3da;
  border-radius: var(--radius-sm);
  background-color: var(--surface);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 6l4 4 4-4' fill='none' stroke='%231b6f9e' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 14px 14px;
  box-shadow: var(--shadow-sm);
  color: var(--ink);
  font: inherit;
  font-size: 0.9rem;
  line-height: 1.3;
  cursor: pointer;
  vertical-align: middle;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.app-page select:not([multiple]):not([size]):hover { border-color: var(--accent); }
.app-page select:not([multiple]):not([size]):focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(27, 111, 158, 0.25);
}
.app-page select:disabled { opacity: 0.55; cursor: default; }
.app-page select::-ms-expand { display: none; } /* anciens Edge/IE */

/* Libellé du sélecteur de caméra : icône caméra devant « Camera: » */
.app-page label[for="cameraSelect"] {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  color: var(--ink-soft);
  vertical-align: middle;
}
.app-page label[for="cameraSelect"]::before {
  content: "";
  width: 18px;
  height: 18px;
  flex: none;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231b6f9e' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M15 10l5-3v10l-5-3z'/%3E%3Crect x='3' y='6' width='12' height='12' rx='2'/%3E%3C/svg%3E") no-repeat center / contain;
}

/* ---------- camTEST distorsion : damier indicatif sur la vidéo ----------
 * Même durée (2,4 s) et même délai (5 s) que .glow-pulse (animation « attention ») :
 * le damier apparaît pendant les pulsations de la consigne « Place a checkerboard ». */
.checker-hint {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.checker-hint[hidden] { display: none; }
.checker-hint::before {
  content: "";
  width: 46%;
  aspect-ratio: 6 / 4;              /* damier 6 × 4 cases */
  background: repeating-conic-gradient(#16202a 0 25%, #ffffff 0 50%) 0 0 / calc(100% / 3) calc(100% / 2);
  box-shadow: 0 0 0 6px #ffffff, 0 6px 18px rgba(16, 24, 32, 0.35);   /* marge blanche d'un damier imprimé */
  border-radius: 2px;
  opacity: 0;
  animation: checker-blink 2.4s ease-in-out 5s infinite;
}
@keyframes checker-blink {
  0%   { opacity: 0; }
  10%  { opacity: 0.6; }
  40%  { opacity: 0.6; }
  55%  { opacity: 0; }
  100% { opacity: 0; }
}
body.spinner-active .checker-hint::before { animation-play-state: paused; }
@media (prefers-reduced-motion: reduce) {
  .checker-hint::before { animation: none; opacity: 0.3; }
}

/* ---------- Page d'accès (access_portal.html) ---------- */
.access-main {
  align-items: center;
  padding: 40px 16px;
}
.access-card {
  width: min(100%, 420px);
  padding: 28px 28px 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  text-align: center;
}
.access-card h1 { font-size: 1.35rem; margin: 6px 0 6px; letter-spacing: -0.01em; }
.access-lead { margin: 0 0 18px; color: var(--ink-soft); font-size: 0.92rem; }
.access-lead strong { color: var(--ink); word-break: break-all; }

/* Étapes 1 · 2 */
.access-steps {
  display: flex;
  justify-content: center;
  gap: 18px;
  margin: 0 0 18px;
  padding: 0;
  list-style: none;
  font-size: 0.78rem;
  color: var(--muted);
}
.access-steps li { display: inline-flex; align-items: center; gap: 6px; }
.access-steps li span {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1px solid var(--border);
  font-weight: 600;
  font-size: 0.72rem;
}
.access-steps li.is-current { color: var(--ink); font-weight: 600; }
.access-steps li.is-current span { border: none; background: var(--accent); color: #fff; }
.access-steps li.is-done span { border-color: var(--teal); color: var(--teal); }

.access-icon {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  margin: 0 auto;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--teal), var(--indigo));
  color: #fff;
  box-shadow: 0 6px 18px rgba(79, 112, 206, 0.3);
}
.access-icon svg { width: 26px; height: 26px; }

.access-form { display: flex; flex-direction: column; gap: 8px; text-align: left; }
.access-label { font-size: 0.82rem; font-weight: 600; color: var(--ink-soft); }
.access-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #c9d3da;
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.access-input::placeholder { color: #a9b4bc; }
.access-input:hover { border-color: var(--accent); }
.access-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(27, 111, 158, 0.25); }
.access-code {
  text-align: center;
  font-size: 1.8rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.45em;
  padding-left: calc(12px + 0.45em); /* compense l'espacement après le dernier chiffre */
}
.access-submit { width: 100%; margin-top: 8px; }

.access-alert {
  margin: 0 0 14px;
  padding: 10px 12px;
  border: 1px solid #f5c2bd;
  border-radius: var(--radius-sm);
  background: #fdecea;
  color: var(--danger);
  font-size: 0.88rem;
  text-align: left;
}
.access-note { margin: 14px 0 0; font-size: 0.78rem; color: var(--muted); }
.access-back { margin-top: 6px; }
.access-link {
  padding: 4px;
  border: none;
  background: none;
  color: var(--accent);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}
.access-link:hover, .access-link:focus-visible { text-decoration: underline; }

/* ---------- Administration des accès (access_admin.html) ---------- */
.adm-crumb { font-weight: 600; color: var(--ink-soft); }
.adm-main { flex: 1; padding: 28px 0 40px; }
.adm-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.adm-head h1 { margin: 0; font-size: 1.5rem; letter-spacing: -0.01em; }

.adm-alert { margin: 0 0 16px; padding: 10px 14px; border-radius: var(--radius-sm); border: 1px solid; font-size: 0.9rem; }
.adm-alert.is-ok { background: #e8f5ee; border-color: #b7e0c8; color: var(--success); }
.adm-alert.is-error { background: #fdecea; border-color: #f5c2bd; color: var(--danger); }

/* Chiffres clés */
.adm-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.adm-stat {
  display: flex; flex-direction: column; gap: 2px;
  padding: 14px 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); color: var(--ink); text-decoration: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.adm-stat:hover, .adm-stat:focus-visible { border-color: var(--accent); box-shadow: var(--shadow-md); text-decoration: none; }
.adm-stat .n { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--accent); }
.adm-stat .l { font-size: 0.8rem; color: var(--muted); }
.adm-stat.is-warn .n { color: var(--warning); }

/* Actions rapides */
.adm-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.adm-actions .ui-panel, .adm-table-panel { margin: 0 0 16px; }
.adm-actions .ui-panel { margin: 0; }
.adm-actions h2, .adm-table-panel h2 { display: flex; align-items: center; gap: 8px; margin: 0 0 6px; font-size: 1rem; }
.adm-hint { margin: 0 0 10px; font-size: 0.8rem; color: var(--muted); }
.adm-inline { display: flex; gap: 8px; flex-wrap: wrap; }
.adm-inline .access-input { flex: 1 1 180px; width: auto; padding: 8px 10px; font-size: 0.9rem; }
.adm-btn-danger { background: var(--danger); color: #fff; }
.adm-btn-danger:hover, .adm-btn-danger:focus-visible { background: #a93226; color: #fff; }

.adm-count {
  padding: 1px 9px; border-radius: 999px;
  background: var(--bg); border: 1px solid var(--border);
  font-size: 0.75rem; font-weight: 600; color: var(--ink-soft); font-variant-numeric: tabular-nums;
}
.adm-count.is-ok { background: #e8f5ee; border-color: #b7e0c8; color: var(--success); }
.adm-count.is-warn { background: #fff4e0; border-color: #f3d39a; color: var(--warning); }

/* Tableaux */
.adm-table-wrap { overflow-x: auto; margin: 8px -4px 0; }
.adm-scroll { max-height: 360px; overflow-y: auto; }
.adm-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.adm-table th {
  position: sticky; top: 0; z-index: 1;
  padding: 8px 10px; background: var(--surface);
  border-bottom: 1px solid var(--border);
  text-align: left; font-size: 0.72rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted);
}
.adm-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.adm-table tbody tr:last-child td { border-bottom: none; }
.adm-table tbody tr:hover td { background: #f7fafb; }
.adm-table code { font-size: 0.82rem; color: var(--ink-soft); }
.adm-code { padding: 2px 6px; border-radius: 6px; background: var(--bg); letter-spacing: 0.08em; color: var(--ink) !important; }
.adm-nowrap { white-space: nowrap; }
.adm-empty { padding: 18px 10px !important; text-align: center; color: var(--muted); }
.adm-col-actions { text-align: right; white-space: nowrap; }
.adm-row-actions { display: inline-flex; gap: 6px; }
.adm-row-actions form, .adm-col-actions form { display: inline; margin: 0; }
.adm-mini {
  padding: 4px 10px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--surface); color: var(--ink-soft);
  font: inherit; font-size: 0.78rem; font-weight: 600; cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}
.adm-mini:hover, .adm-mini:focus-visible { border-color: var(--accent); color: var(--accent); }
.adm-mini.is-danger:hover, .adm-mini.is-danger:focus-visible { border-color: var(--danger); color: var(--danger); }

.adm-badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  background: var(--bg); border: 1px solid var(--border);
  font-size: 0.74rem; font-weight: 600; color: var(--ink-soft); white-space: nowrap;
}
.adm-badge.is-warn { background: #fff4e0; border-color: #f3d39a; color: var(--warning); }
.adm-badge.is-danger { background: #fdecea; border-color: #f5c2bd; color: var(--danger); }

@media (max-width: 760px) {
  .adm-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .adm-actions { grid-template-columns: 1fr; }
}

/* Libellé masqué visuellement mais lu par les lecteurs d'écran */
.ui-visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

/* Icône dans un bouton */
.ui-btn .ui-icon { width: 16px; height: 16px; flex: none; }

@media (prefers-reduced-motion: reduce) {
  .ui-btn-confirm, .ui-btn-confirm:hover, .ui-btn-confirm:focus-visible { transition: none; transform: none; }
}

/* --- Panneaux --- */
.ui-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 18px 20px;
}

.ui-panel h2 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 14px;
  font-size: 0.95rem;
  font-weight: 650;
  color: var(--ink);
}

.ui-panel h2 .step {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
  font-size: 0.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.ui-panel .hint { color: var(--muted); font-size: 0.8rem; margin: 6px 0 0; }

.ui-field {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
  color: var(--ink-soft);
}

.ui-field input[type="number"] {
  width: 96px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit;
  color: var(--ink);
}

.ui-field input[type="number"]:focus {
  outline: 2px solid rgba(27, 111, 158, 0.35);
  border-color: var(--accent);
}

.ui-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

/* --- Sélecteur à deux options --- */
.ui-seg {
  display: inline-flex;
  padding: 3px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  margin: 0;
}

.ui-seg button,
.ui-seg span {
  border: 0;
  background: transparent;
  padding: 5px 14px;
  border-radius: 999px;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink-soft);
  cursor: pointer;
}

.ui-seg button:hover { color: var(--ink); }

.ui-seg .is-active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
  cursor: default;
}

/* --- pathFINDER : session --- */
.pf-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 20px;
  align-items: stretch;   /* les deux colonnes ont la même hauteur */
}

/* La rangée des tuiles d'étapes s'allonge pour aligner leur bas sur celui des résultats */
.pf-left { display: grid; gap: 20px; grid-template-rows: auto auto 1fr; }

.pf-title {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px 14px;
  margin: 0 0 4px;
}

.pf-title h1 { margin: 0; font-size: 1.25rem; font-weight: 700; line-height: 1.3; color: var(--ink); }

.ui-chip {
  font-size: 0.78rem;
  color: var(--ink-soft);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 9px;
  font-variant-numeric: tabular-nums;
}

.pf-media { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.pf-media figure { margin: 0; }

.pf-media .frame {
  background: #000;
  border-radius: var(--radius-sm);
  overflow: hidden;
}

/* Les deux vignettes viennent de la même vidéo : même proportion, pas de bandes noires */
.pf-media .frame video,
.pf-media .frame img { width: 100%; height: auto; display: block; }

.pf-media figcaption { margin-top: 6px; font-size: 0.78rem; color: var(--muted); }

.pf-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

/* Résultats : même hauteur que la colonne de gauche */
.pf-results {
  display: flex;
  flex-direction: column;
}

.pf-results .pf-placeholder { flex: 1; }
.pf-results .pf-results-foot { margin-top: auto; padding-top: 16px; }

.pf-results-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.pf-results-head h2 { margin: 0; }

.pf-graphs { display: grid; gap: 6px; justify-items: center; }
.pf-graphs img { max-width: 100%; height: auto; }

.pf-visual {
  position: relative;
  margin: 0 auto;
  width: min(100%, 520px);
  aspect-ratio: 1;
  background: #000;
  border-radius: var(--radius-sm);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pf-visual img { max-width: 100%; max-height: 100%; object-fit: contain; }

.pf-visual .time {
  position: absolute;
  left: 10px;
  bottom: 10px;
  padding: 2px 8px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
}

.pf-range { margin: 14px auto 0; width: min(100%, 520px); }

.pf-range-values {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

.pf-range input[type="range"] { width: 100%; accent-color: var(--teal); display: block; }

.pf-results-foot { display: flex; justify-content: flex-end; }

.pf-placeholder {
  min-height: 320px;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}

/* État vide : aucune vidéo chargée */
.pf-empty {
  max-width: 560px;
  margin: 40px auto;
  text-align: center;
  padding: 40px 32px;
}

.pf-empty .card-icon { margin: 0 auto 18px; }
.pf-empty h1 { font-size: 1.35rem; font-weight: 700; margin: 0 0 8px; color: var(--ink); }
.pf-empty p { color: var(--ink-soft); margin: 0 0 22px; }
.pf-empty .ui-actions { justify-content: center; }
.pf-empty .credits { margin-top: 22px; font-size: 0.8rem; color: var(--muted); }

@media (max-width: 1000px) {
  .pf-layout { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .pf-controls, .pf-media { grid-template-columns: 1fr; }
  .topbar .crumb-label { display: none; }
}

/* =====================================================================
 * Harmonisation des pages encore construites avec Bootstrap 4 (styles.css)
 * Uniquement dans les pages des modules (body.app-page).
 * ===================================================================== */

.app-main a:not(.ui-btn):not(.btn) { color: var(--teal-dark); }
.app-main a:not(.ui-btn):not(.btn):hover { color: var(--ink); }

.app-page h1, .app-page h2, .app-page h3,
.app-page h4, .app-page h5, .app-page h6 {
  color: var(--ink);
  font-weight: 650;
  letter-spacing: -0.005em;
}

.app-page .btn {
  border-radius: var(--radius-sm);
  font-weight: 600;
  box-shadow: none;
}

.app-page .btn-primary,
.app-page .btn-primary:not(:disabled):not(.disabled):active {
  background: var(--teal-dark);
  border-color: var(--teal-dark);
  color: #fff;
}

.app-page .btn-primary:hover,
.app-page .btn-primary:focus { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }

/* btn-secondary (bleu) et btn-info (gris) : bouton neutre à contour */
.app-page .btn-secondary,
.app-page .btn-info,
.app-page .btn-light {
  background: var(--surface);
  border-color: var(--border);
  color: var(--ink);
}

.app-page .btn-secondary:hover, .app-page .btn-secondary:focus,
.app-page .btn-info:hover, .app-page .btn-info:focus,
.app-page .btn-light:hover, .app-page .btn-light:focus {
  background: var(--surface);
  border-color: var(--accent);
  color: var(--accent);
}

.app-page .btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.app-page .btn-warning { background: #f6c453; border-color: #f6c453; color: var(--ink); }

.app-page .bg-primary { background-color: var(--teal) !important; }
.app-page .text-primary { color: var(--teal-dark) !important; }

.app-page .alert { border-radius: var(--radius-sm); }
.app-page .alert-danger { background: #fdecea; border-color: #f5c2bd; color: var(--danger); }
.app-page .alert-success { background: #e8f5ee; border-color: #b7e0c8; color: var(--success); }

/* ---------- Curseurs (input range) ----------
 * Style unique pour Chrome, Edge, Safari (::-webkit-*) et Firefox (::-moz-*).
 * La partie remplie de la piste est peinte par un dégradé entre --fs et --fe,
 * mis à jour par le script de app_base.html (sans script : piste grise unie).
 * data-fill="end" : remplit à droite du curseur (borne basse d'un intervalle).
 * #threshold (curseur sur histogramme) garde son style propre. */
.app-page input[type="range"]:not(#threshold) {
  -webkit-appearance: none;
  appearance: none;
  height: 22px;
  margin: 4px 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
  vertical-align: middle;
  --fs: 0%;
  --fe: 0%;
  --range-track: #d5dde3;
  --range-fill: var(--accent);
  --range-bg: linear-gradient(to right,
      var(--range-track) 0 var(--fs),
      var(--range-fill) var(--fs) var(--fe),
      var(--range-track) var(--fe) 100%);
}

.app-page input[type="range"]:not(#threshold):focus { outline: none; }

/* Piste */
.app-page input[type="range"]:not(#threshold)::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 999px;
  background: var(--range-bg);
}
.app-page input[type="range"]:not(#threshold)::-moz-range-track {
  height: 6px;
  border-radius: 999px;
  background: var(--range-bg);
}
.app-page input[type="range"]:not(#threshold)::-moz-range-progress { background: transparent; }

/* Curseur rond */
.app-page input[type="range"]:not(#threshold)::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  box-sizing: border-box;
  width: 18px;
  height: 18px;
  margin-top: -6px; /* (6 - 18) / 2 : centre le curseur sur la piste */
  border: 2px solid var(--accent);
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(16, 24, 32, 0.25);
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}
.app-page input[type="range"]:not(#threshold)::-moz-range-thumb {
  box-sizing: border-box;
  width: 18px;
  height: 18px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(16, 24, 32, 0.25);
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}

/* Survol, focus clavier, glisser */
.app-page input[type="range"]:not(#threshold):hover::-webkit-slider-thumb { box-shadow: 0 0 0 6px rgba(27, 111, 158, 0.12), 0 1px 3px rgba(16, 24, 32, 0.25); }
.app-page input[type="range"]:not(#threshold):hover::-moz-range-thumb { box-shadow: 0 0 0 6px rgba(27, 111, 158, 0.12), 0 1px 3px rgba(16, 24, 32, 0.25); }
.app-page input[type="range"]:not(#threshold):focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 4px rgba(27, 111, 158, 0.35); }
.app-page input[type="range"]:not(#threshold):focus-visible::-moz-range-thumb { box-shadow: 0 0 0 4px rgba(27, 111, 158, 0.35); }
.app-page input[type="range"]:not(#threshold):active::-webkit-slider-thumb { transform: scale(1.12); }
.app-page input[type="range"]:not(#threshold):active::-moz-range-thumb { transform: scale(1.12); }

/* Désactivé */
.app-page input[type="range"]:not(#threshold):disabled { cursor: default; opacity: 0.5; }

@media (prefers-reduced-motion: reduce) {
  .app-page input[type="range"]:not(#threshold)::-webkit-slider-thumb { transition: none; }
  .app-page input[type="range"]:not(#threshold)::-moz-range-thumb { transition: none; }
}

/* Lien suggéré dans la barre du haut (aucune image encore chargée) */
.topbar-links a.is-hint {
  color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(27, 111, 158, 0.35);
}

/* =====================================================================
 * Mise en avant « en attente du joueur » (comme dans les jeux sur mobile) :
 * double battement + onde qui s'élargit, pause, et on recommence tant que
 * l'utilisateur n'a pas agi. S'arrête au survol / focus.
 *   .glow-pulse   : messages d'invite des pages des modules
 *   .ui-attention : bouton principal d'un écran d'accueil
 *   .is-hint      : lien suggéré de la barre du haut
 * ===================================================================== */
.glow-pulse {
  display: inline-block;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  background: rgba(27, 111, 158, 0.07);
  border: 1px solid rgba(27, 111, 158, 0.28);
  color: var(--accent) !important;
}

.glow-pulse,
.ui-attention,
.topbar-links a.is-hint {
  animation: attention 2.4s ease-in-out infinite;
  transform-origin: center;
}

.ui-attention { animation-delay: 3s; }
.topbar-links a.is-hint { animation-delay: 3s; }

@keyframes attention {
  0%   { transform: scale(1);    box-shadow: 0 0 0 0 rgba(27, 111, 158, 0.55); }
  10%  { transform: scale(1.07); }
  20%  { transform: scale(1); }
  30%  { transform: scale(1.05); }
  40%  { transform: scale(1); }
  55%  { box-shadow: 0 0 0 18px rgba(27, 111, 158, 0); }
  100% { transform: scale(1);    box-shadow: 0 0 0 0 rgba(27, 111, 158, 0); }
}

.glow-pulse:hover,
.ui-attention:hover, .ui-attention:focus-visible,
.topbar-links a.is-hint:hover, .topbar-links a.is-hint:focus-visible {
  animation: none;
}

/* Sans animation (réglage système) : mise en avant fixe mais bien visible */
@media (prefers-reduced-motion: reduce) {
  .glow-pulse, .ui-attention, .topbar-links a.is-hint {
    animation: none;
    box-shadow: 0 0 0 3px rgba(27, 111, 158, 0.35);
  }
}
