/* ==========================================================================
   QUALITEK — Design System V2 · « Mosa II »
   Dark · violet→cyan · glass · pro-tool density
   --------------------------------------------------------------------------
   Compatibilité : tous les NOMS de variables et toutes les CLASSES générées
   par le JavaScript existant (nav.js, ui.js, gauge.js, *.js de page) sont
   conservés. Les valeurs et l'apparence sont entièrement repensées.
   ========================================================================== */

:root {
  /* ─── Surfaces (échelle de profondeur recalibrée) ─────────────────────── */
  --bg-deep:         #05070E;
  --bg-app:          #080B14;
  --bg-panel:        #0C1019;
  --bg-panel-raised: #111728;
  --bg-panel-high:   #171E31;
  --bg-input:        #090D16;
  --bg-hover:        rgba(255,255,255,0.04);
  --bg-active:       rgba(124,108,255,0.10);

  /* opaque variants (when blur isn't desired) */
  --surface-1:       #0C1019;
  --surface-2:       #111728;
  --surface-3:       #171E31;

  /* ─── Glass ───────────────────────────────────────────────────────────── */
  --glass-bg:        rgba(17,22,38,0.55);
  --glass-bg-strong: rgba(12,16,28,0.74);
  --glass-border:    rgba(255,255,255,0.07);
  --glass-blur:      blur(18px) saturate(160%);
  --glass-sheen:     linear-gradient(180deg, rgba(255,255,255,0.055), rgba(255,255,255,0) 60%);

  /* ─── Borders ─────────────────────────────────────────────────────────── */
  --border:          #20283C;
  --border-soft:     #161C2C;
  --border-strong:   #2B3550;
  --border-focus:    #7C6CFF;
  --hairline:        rgba(255,255,255,0.06);

  /* ─── Text ────────────────────────────────────────────────────────────── */
  --text-primary: #ECF0FA;
  --text-muted:   #9AA7C4;
  --text-faint:   #7C89A8;
  --text-invert:  #070A14;

  /* ─── Accent (signal = violet-indigo) ─────────────────────────────────── */
  --signal:        #7C6CFF;
  --signal-strong: #8E80FF;
  --signal-dim:    #463CA6;
  --signal-glow:   rgba(124,108,255,0.16);
  --violet:        #7C6CFF;          /* alias historique (JS/landing) */

  /* ─── Gradient brand ──────────────────────────────────────────────────── */
  --accent-cyan:     #34D0C8;
  --accent-blue:     #5B8DEF;
  --grad-brand:      linear-gradient(120deg, #7C6CFF 0%, #6470F2 48%, #34C8D0 100%);
  --grad-brand-soft: linear-gradient(120deg, rgba(124,108,255,0.18), rgba(52,208,200,0.13));
  --grad-text:       linear-gradient(100deg, #C2BBFF 0%, #8FE9E2 100%);
  --grad-line:       linear-gradient(90deg, transparent, rgba(124,108,255,0.55), rgba(52,208,200,0.45), transparent);
  --glow-violet:     0 10px 32px -12px rgba(124,108,255,0.55);
  --glow-cyan:       0 10px 32px -12px rgba(52,208,200,0.42);
  --ambient-1: radial-gradient(680px circle at 8% -10%,  rgba(124,108,255,0.12), transparent 60%);
  --ambient-2: radial-gradient(760px circle at 104% 0%,  rgba(52,208,200,0.08),  transparent 56%);
  --ambient-3: radial-gradient(620px circle at 60% 116%, rgba(91,141,239,0.06),  transparent 60%);

  /* ─── Sémantiques ─────────────────────────────────────────────────────── */
  --ok:          #7C6CFF;
  --ok-glow:     rgba(124,108,255,0.12);
  --warn:        #F0A94A;
  --warn-dim:    #8A5E1A;
  --warn-glow:   rgba(240,169,74,0.12);
  --danger:      #F2606B;
  --danger-dim:  #8A323C;
  --danger-glow: rgba(242,96,107,0.12);
  --info:        #5B8DEF;
  --info-dim:    #2E4E94;
  --info-glow:   rgba(91,141,239,0.12);
  --success:     #34D0C8;

  /* ─── Rôles ───────────────────────────────────────────────────────────── */
  --role-technicien: #5B8DEF;
  --role-manager:    #F0A94A;
  --role-admin:      #7C6CFF;
  --role-km:         #34D0C8;

  /* ─── Typographie ─────────────────────────────────────────────────────── */
  --font-display: 'Outfit', 'DM Sans', system-ui, sans-serif;
  --font-body:    'DM Sans', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --font-mono:    'JetBrains Mono', 'SFMono-Regular', Consolas, monospace;

  /* Type scale — base d'app dense (corps = 14px) */
  --fs-micro:   11px;   /* labels mono, en-têtes de table */
  --fs-meta:    12px;   /* méta, captions */
  --fs-sm:      13px;   /* cellules, nav, boutons, pills */
  --fs-base:    14px;   /* corps, inputs, descriptions */
  --fs-md:      15px;   /* titres de carte (h3) */
  --fs-lg:      18px;   /* titres de section (h2) */
  --fs-xl:      22px;   /* titres de page (h1) */
  --fs-2xl:     28px;   /* valeurs KPI, titres de drawer */
  --fs-3xl:     40px;   /* score de résultat */
  --fs-display: clamp(40px, 5.4vw, 64px);

  --lh-tight:  1.14;
  --lh-snug:   1.32;
  --lh-base:   1.6;

  --tk-tightest: -0.04em;
  --tk-tighter:  -0.028em;
  --tk-tight:    -0.015em;
  --tk-wide:      0.02em;
  --tk-caps:      0.08em;

  /* ─── Espacement (base 4px) ───────────────────────────────────────────── */
  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px; --sp-5: 20px;
  --sp-6: 24px; --sp-7: 28px; --sp-8: 32px; --sp-10: 40px; --sp-12: 48px;
  --sp-16: 64px; --sp-20: 80px;

  /* ─── Layout ──────────────────────────────────────────────────────────── */
  --sidebar-w:           248px;
  --sidebar-w-collapsed: 74px;
  --topbar-h:            56px;
  --content-max:         1320px;

  /* ─── Radius ──────────────────────────────────────────────────────────── */
  --radius-xs:   6px;
  --radius-sm:   8px;
  --radius-md:   11px;
  --radius-lg:   14px;
  --radius-xl:   20px;
  --radius-pill: 999px;

  /* ─── Élévation ───────────────────────────────────────────────────────── */
  --ring:        inset 0 0 0 1px rgba(255,255,255,0.05);
  --shadow-xs:   0 1px 2px rgba(0,0,0,0.35);
  --shadow-sm:   0 1px 0 rgba(0,0,0,0.4), 0 4px 16px -8px rgba(0,0,0,0.55);
  --shadow-md:   0 1px 0 rgba(0,0,0,0.5), 0 14px 34px -14px rgba(0,0,0,0.6);
  --shadow-lg:   0 1px 0 rgba(0,0,0,0.55), 0 30px 70px -16px rgba(0,0,0,0.72);
  --focus-ring:  0 0 0 3px var(--signal-glow);

  /* ─── Timing ──────────────────────────────────────────────────────────── */
  --ease-out:    cubic-bezier(0.16, 1, 0.3, 1);
  --ease-expo:   cubic-bezier(0.19, 1, 0.22, 1);
  --ease-in:     cubic-bezier(0.4, 0, 1, 1);
  --ease-spring: cubic-bezier(0.22, 1, 0.36, 1);
  --t-fast:      120ms;
  --t-base:      200ms;
  --t-slow:      320ms;
  --t-slower:    480ms;

  /* ─── Z-index ─────────────────────────────────────────────────────────── */
  --z-base:    1;
  --z-sticky:  10;
  --z-rail:    20;
  --z-drawer:  50;
  --z-modal:   60;
  --z-toast:   80;
  --z-overlay: 100;
  --z-command: 120;
}

/* ══════════════════════════════════════════════════════════════════════════
   RESET & BASE
   ══════════════════════════════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  background: var(--bg-app);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: var(--fs-base);
  line-height: var(--lh-base);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-variant-ligatures: common-ligatures;
  text-rendering: optimizeLegibility;
}

/* Ambient brand field (very subtle, fixed) + grain */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background: var(--ambient-1), var(--ambient-2), var(--ambient-3);
}
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  margin: 0;
  letter-spacing: var(--tk-tighter);
  line-height: var(--lh-tight);
  color: var(--text-primary);
}
p { margin: 0; }

a { color: var(--signal); text-decoration: none; transition: color var(--t-fast), opacity var(--t-fast); }
a:hover { color: var(--signal-strong); }

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

::selection { background: rgba(124,108,255,0.32); color: #fff; }

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

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

/* Helpers */
.grad-text {
  background: var(--grad-text);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}
.mono {
  font-family: var(--font-mono);
  font-size: 0.92em;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}
.cell-mono { font-family: var(--font-mono); font-size: var(--fs-meta); font-variant-numeric: tabular-nums; }
.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.score-ok     { color: var(--signal); }
.score-warn   { color: var(--warn); }
.score-danger { color: var(--danger); }
.score-faint  { color: var(--text-faint); }

/* Scrollbars */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: var(--radius-pill);
  border: 2px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--signal-dim); background-clip: padding-box; }
* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }

/* ══════════════════════════════════════════════════════════════════════════
   ICONS (système SVG inline — sizing/couleur ; sprite injecté côté pages)
   ══════════════════════════════════════════════════════════════════════════ */
.ico {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; flex-shrink: 0;
  vertical-align: -0.18em;
}
.ico svg { width: 100%; height: 100%; display: block; }
.ico svg [stroke] { stroke: currentColor; }
.ico-sm { width: 15px; height: 15px; }
.ico-lg { width: 22px; height: 22px; }

/* ══════════════════════════════════════════════════════════════════════════
   APP SHELL
   ══════════════════════════════════════════════════════════════════════════ */
.app-shell { display: flex; min-height: 100dvh; position: relative; }

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background:
    linear-gradient(180deg, rgba(124,108,255,0.06), transparent 200px),
    var(--glass-bg-strong);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border-right: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  padding: var(--sp-4) var(--sp-3);
  position: sticky;
  top: 0;
  height: 100dvh;
  overflow-y: auto;
  z-index: var(--z-sticky);
}

.sidebar-brand {
  display: flex; align-items: center; gap: 11px;
  padding: 6px 8px var(--sp-4);
  margin-bottom: var(--sp-3);
  border-bottom: 1px solid var(--border-soft);
}
.sidebar-brand .mark {
  width: 34px; height: 34px;
  border-radius: var(--radius-sm);
  background: var(--grad-brand);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 700;
  color: #fff; font-size: 16px;
  flex-shrink: 0; position: relative;
  box-shadow: var(--glow-violet);
}
.sidebar-brand .mark::after {
  content: ''; position: absolute; inset: 0; border-radius: inherit;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.35), inset 0 -1px 0 rgba(0,0,0,0.22);
}
.sidebar-brand .name {
  font-family: var(--font-display); font-size: var(--fs-md);
  font-weight: 700; letter-spacing: var(--tk-tight); color: var(--text-primary);
}
.sidebar-brand .sub {
  font-size: 10px; color: var(--text-faint);
  font-family: var(--font-mono); letter-spacing: var(--tk-caps);
  text-transform: uppercase; margin-top: 2px;
}

/* Nav */
.sidebar-nav { display: flex; flex-direction: column; gap: 1px; flex: 1; }
.sidebar-nav .nav-section {
  padding: var(--sp-4) 10px 6px;
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: var(--tk-caps);
}
.sidebar-nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: var(--fs-sm);
  font-weight: 500;
  letter-spacing: 0.005em;
  position: relative;
  border: 1px solid transparent;
  transition: background var(--t-fast), color var(--t-fast), transform var(--t-fast) var(--ease-out);
}
.sidebar-nav a:hover { background: var(--bg-hover); color: var(--text-primary); }
.sidebar-nav a:active { transform: translateX(1px); }
.sidebar-nav a.active {
  background: var(--grad-brand-soft);
  color: var(--text-primary);
  border-color: rgba(124,108,255,0.20);
}
.sidebar-nav a.active::before {
  content: ''; position: absolute; left: -1px; top: 8px; bottom: 8px;
  width: 3px; border-radius: 0 3px 3px 0;
  background: var(--grad-brand);
  box-shadow: 0 0 12px rgba(124,108,255,0.7);
}
.sidebar-nav .icon {
  width: 18px; height: 18px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; opacity: 0.6;
  transition: opacity var(--t-fast), color var(--t-fast);
}
.sidebar-nav .icon svg { width: 17px; height: 17px; }
.sidebar-nav a:hover .icon { opacity: 0.95; }
.sidebar-nav a.active .icon { opacity: 1; color: var(--signal); }
.sidebar-nav a .label { flex: 1; min-width: 0; }
.sidebar-nav a .badge-count {
  font-family: var(--font-mono); font-size: var(--fs-micro); font-weight: 600;
  color: var(--text-faint);
  background: var(--bg-panel-high);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-pill);
  padding: 1px 7px; min-width: 20px; text-align: center;
}

/* Footer / user */
.sidebar-footer { border-top: 1px solid var(--border-soft); padding-top: var(--sp-3); margin-top: var(--sp-3); }
.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 8px; border-radius: var(--radius-sm);
}
.sidebar-user .avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--grad-brand-soft);
  border: 1px solid rgba(124,108,255,0.28);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-size: var(--fs-micro); font-weight: 600;
  color: var(--text-primary); flex-shrink: 0;
}
.sidebar-user .who { line-height: 1.3; min-width: 0; }
.sidebar-user .who .n { font-size: var(--fs-sm); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user .who .r {
  font-size: 10px; color: var(--text-faint); font-family: var(--font-mono);
  text-transform: uppercase; letter-spacing: var(--tk-wide); margin-top: 1px;
}
.btn-logout {
  width: 100%; margin-top: 6px;
  background: transparent;
  border: 1px solid var(--border-soft);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: var(--fs-meta);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  transition: border-color var(--t-fast), color var(--t-fast), background var(--t-fast);
}
.btn-logout:hover { border-color: var(--danger-dim); color: var(--danger); background: var(--danger-glow); }

/* ── Main + topbar ───────────────────────────────────────────────────────── */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.statusline {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-4);
  padding: 0 var(--sp-7);
  min-height: var(--topbar-h);
  border-bottom: 1px solid var(--glass-border);
  font-family: var(--font-body); font-size: var(--fs-meta);
  color: var(--text-muted);
  background: var(--glass-bg);
  position: sticky; top: 0; z-index: var(--z-sticky);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
}
.statusline .left { display: flex; align-items: center; gap: var(--sp-4); }
.statusline .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--signal); box-shadow: 0 0 8px var(--signal);
  display: inline-block; margin-right: 7px;
  animation: sbf-pulse 3s ease-in-out infinite;
}
.statusline .breadcrumb { display: flex; align-items: center; gap: 6px; font-size: var(--fs-micro); color: var(--text-faint); }
.statusline .breadcrumb .sep { opacity: 0.4; }
.statusline .breadcrumb .current { color: var(--text-muted); }

/* Content */
.content {
  padding: var(--sp-7) var(--sp-8);
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  flex: 1;
}

.page-head { margin-bottom: var(--sp-7); }
.page-head h1 {
  font-size: var(--fs-xl);
  letter-spacing: var(--tk-tightest);
  font-weight: 700;
}
.page-head .desc {
  color: var(--text-muted);
  font-size: var(--fs-base);
  margin-top: 6px;
  line-height: var(--lh-base);
  max-width: 70ch;
}

/* En-tête de page avec action (partagé dashboards + admin) */
.dash-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; flex-wrap: wrap; margin-bottom: var(--sp-6); }
.dash-head h1 { font-size: var(--fs-xl); letter-spacing: var(--tk-tightest); }
.dash-head .desc { color: var(--text-muted); font-size: var(--fs-base); margin-top: 6px; line-height: var(--lh-base); }

/* ══════════════════════════════════════════════════════════════════════════
   CARDS & SURFACES
   ══════════════════════════════════════════════════════════════════════════ */
.card {
  position: relative;
  background: var(--bg-panel);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.card::before {
  content: ''; position: absolute; inset: 0; border-radius: inherit;
  background: var(--glass-sheen); pointer-events: none; opacity: 0.8;
}
.card > * { position: relative; }
.card-pad { padding: var(--sp-5) var(--sp-5); }
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-5);
  border-bottom: 1px solid var(--border-soft);
}
.card-head h2, .card-head h3 { font-size: var(--fs-md); font-weight: 600; letter-spacing: var(--tk-tight); }

/* Panneau opaque (sans blur) */
.panel {
  background: var(--surface-1);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
}

/* Double-bezel (high emphasis) */
.card-bezel {
  background: var(--bg-panel-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 2px;
  box-shadow: var(--shadow-md);
}
.card-bezel-inner {
  background: var(--bg-panel);
  border-radius: calc(var(--radius-xl) - 2px);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
  overflow: hidden;
}

/* ── Grids ───────────────────────────────────────────────────────────────── */
.grid { display: grid; gap: var(--sp-4); }
.grid-2, .grid-cols-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid-3, .grid-cols-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.grid-4, .grid-cols-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.grid-auto { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }

/* ══════════════════════════════════════════════════════════════════════════
   KPI / STAT
   ══════════════════════════════════════════════════════════════════════════ */
.kpi {
  position: relative;
  overflow: hidden;
  background: var(--bg-panel);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: var(--sp-5);
  box-shadow: var(--shadow-sm);
  transition: border-color var(--t-base) var(--ease-out),
              transform var(--t-base) var(--ease-out),
              box-shadow var(--t-base) var(--ease-out);
  --kpi-accent: var(--signal);
}
.kpi::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: var(--kpi-accent); opacity: 0.55;
}
.kpi:hover {
  border-color: color-mix(in srgb, var(--kpi-accent) 30%, transparent);
  transform: translateY(-2px);
}
.kpi .label {
  font-size: 12px; color: var(--text-muted);
  letter-spacing: 0; font-weight: 500;
  margin-bottom: var(--sp-3);
  display: flex; align-items: center; gap: 7px;
}
.kpi .value {
  font-family: var(--font-display);
  font-size: var(--fs-2xl);
  font-weight: 700;
  letter-spacing: var(--tk-tightest);
  line-height: 1;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}
.kpi .value .unit { font-size: var(--fs-md); color: var(--text-muted); margin-left: 3px; font-weight: 500; letter-spacing: 0; }
.kpi .trend {
  margin-top: var(--sp-2);
  font-size: var(--fs-meta); font-family: var(--font-mono);
  color: var(--text-faint);
  display: flex; align-items: center; gap: 5px;
}
.kpi .trend.up { color: var(--signal); }
.kpi .trend.down { color: var(--danger); }

/* ══════════════════════════════════════════════════════════════════════════
   PILLS / BADGES
   ══════════════════════════════════════════════════════════════════════════ */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px;
  border-radius: var(--radius-pill);
  font-size: 10.5px; font-weight: 600;
  font-family: var(--font-mono);
  text-transform: uppercase; letter-spacing: var(--tk-wide);
  white-space: nowrap;
  border: 1px solid transparent;
}
.pill .led { width: 5px; height: 5px; border-radius: 50%; flex-shrink: 0; }
.pill.ok       { background: rgba(124,108,255,0.11); color: var(--signal); border-color: rgba(124,108,255,0.24); }
.pill.ok .led       { background: var(--signal); box-shadow: 0 0 6px var(--signal); }
.pill.warn     { background: rgba(240,169,74,0.10); color: var(--warn); border-color: rgba(240,169,74,0.22); }
.pill.warn .led     { background: var(--warn); }
.pill.danger   { background: rgba(242,96,107,0.10); color: var(--danger); border-color: rgba(242,96,107,0.22); }
.pill.danger .led   { background: var(--danger); }
.pill.neutral  { background: rgba(148,161,191,0.09); color: var(--text-muted); border-color: rgba(148,161,191,0.18); }
.pill.neutral .led  { background: var(--text-faint); }
.pill.info     { background: rgba(91,141,239,0.10); color: var(--info); border-color: rgba(91,141,239,0.22); }
.pill.info .led     { background: var(--info); }
.pill.violet   { background: rgba(52,208,200,0.11); color: var(--accent-cyan); border-color: rgba(52,208,200,0.24); }
.pill.violet .led   { background: var(--accent-cyan); box-shadow: 0 0 6px var(--accent-cyan); }

/* ══════════════════════════════════════════════════════════════════════════
   BUTTONS
   ══════════════════════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 8px 15px;
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm);
  font-weight: 600;
  letter-spacing: 0.005em;
  cursor: pointer;
  border: 1px solid transparent;
  white-space: nowrap; user-select: none;
  position: relative;
  transition: filter var(--t-fast), background var(--t-fast), border-color var(--t-fast),
              transform var(--t-fast) var(--ease-out), box-shadow var(--t-fast), color var(--t-fast);
}
.btn:active { transform: translateY(1px) scale(0.99); }

.btn-primary {
  background: var(--grad-brand);
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.25);
  box-shadow: var(--glow-violet), inset 0 1px 0 rgba(255,255,255,0.2);
}
.btn-primary:hover { filter: brightness(1.08); box-shadow: var(--glow-violet), 0 0 0 1px rgba(124,108,255,0.35), inset 0 1px 0 rgba(255,255,255,0.22); }

.btn-secondary {
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  color: var(--text-primary);
  border-color: var(--glass-border);
  box-shadow: var(--shadow-xs);
}
.btn-secondary:hover { background: var(--bg-panel-high); border-color: rgba(124,108,255,0.28); }

.btn-danger { background: rgba(242,96,107,0.10); color: var(--danger); border-color: rgba(242,96,107,0.24); }
.btn-danger:hover { background: rgba(242,96,107,0.17); border-color: rgba(242,96,107,0.4); }

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

.btn-sm { padding: 5px 10px; font-size: var(--fs-meta); border-radius: var(--radius-xs); }
.btn-lg { padding: 12px 22px; font-size: var(--fs-md); border-radius: var(--radius-md); }
.btn-block { width: 100%; }
.btn[disabled], .btn:disabled { opacity: 0.4; cursor: not-allowed; pointer-events: none; }

.btn-icon { width: 32px; height: 32px; padding: 0; border-radius: var(--radius-sm); flex-shrink: 0; }
.btn-icon.btn-sm { width: 27px; height: 27px; }

/* ══════════════════════════════════════════════════════════════════════════
   FORMS
   ══════════════════════════════════════════════════════════════════════════ */
label {
  display: block; font-size: var(--fs-meta); color: var(--text-muted);
  margin-bottom: 6px; font-weight: 500; letter-spacing: 0.005em;
}
input[type="text"], input[type="password"], input[type="email"],
input[type="number"], input[type="search"], input[type="date"],
select, textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: var(--fs-base);
  line-height: 1.4;
  transition: border-color var(--t-base), box-shadow var(--t-base), background var(--t-base);
  appearance: none; -webkit-appearance: none;
}
input::placeholder, textarea::placeholder { color: var(--text-faint); }
input:focus, select:focus, textarea:focus {
  border-color: var(--border-focus);
  box-shadow: var(--focus-ring);
  outline: none;
  background: var(--bg-panel);
}
input:disabled, select:disabled, textarea:disabled { opacity: 0.5; cursor: not-allowed; }

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' fill='none'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%237C6CFF' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center;
  padding-right: 30px; cursor: pointer;
}
select option { background: var(--surface-2); color: var(--text-primary); }
textarea { resize: vertical; min-height: 76px; }

.field { margin-bottom: var(--sp-4); }
.field-row { display: flex; gap: var(--sp-3); }
.field-row > .field { flex: 1; min-width: 0; }
.field-hint { font-size: var(--fs-meta); color: var(--text-faint); margin-top: 5px; }
.field-error { font-size: var(--fs-meta); color: var(--danger); margin-top: 5px; display: flex; align-items: center; gap: 4px; }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--danger-dim); }

.checkbox-row { display: flex; align-items: center; gap: 9px; }
.checkbox-row input[type="checkbox"] { width: 16px; height: 16px; padding: 0; accent-color: var(--signal); cursor: pointer; }
.checkbox-row label { margin: 0; cursor: pointer; color: var(--text-primary); }

.input-wrap { position: relative; }
.input-wrap .input-icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-faint); pointer-events: none; }
.input-wrap input { padding-left: 32px; }

/* Segmented control (nouveau) */
.segmented { display: inline-flex; gap: 2px; padding: 3px; background: var(--bg-input); border: 1px solid var(--border-soft); border-radius: var(--radius-md); }
.segmented button {
  border: none; background: transparent; color: var(--text-muted);
  font-size: var(--fs-meta); font-weight: 600; padding: 5px 12px;
  border-radius: var(--radius-sm); cursor: pointer; transition: background var(--t-fast), color var(--t-fast);
}
.segmented button.active { background: var(--bg-panel-high); color: var(--text-primary); box-shadow: var(--shadow-xs); }

/* ══════════════════════════════════════════════════════════════════════════
   TOOLBAR (en-tête de table : titre + recherche + filtres + actions)
   ══════════════════════════════════════════════════════════════════════════ */
.toolbar {
  display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap;
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border-soft);
}
.toolbar h2, .toolbar h3 { font-size: var(--fs-md); font-weight: 600; letter-spacing: var(--tk-tight); }
.toolbar .toolbar-spacer { margin-left: auto; }
.toolbar .toolbar-controls { display: flex; align-items: center; gap: var(--sp-2); margin-left: auto; flex-wrap: wrap; }
.toolbar input[type="text"], .toolbar input[type="search"], .toolbar select { padding: 6px 10px; font-size: var(--fs-sm); width: auto; }
/* Les inputs à icône conservent l'espace de l'icône, même quand .toolbar/.filter-bar surchargent le padding */
.input-wrap input[type="text"], .input-wrap input[type="search"] { padding-left: 32px; }
.count-badge {
  font-family: var(--font-mono); font-size: var(--fs-micro); color: var(--text-faint);
  background: var(--bg-panel-high); border: 1px solid var(--border-soft);
  border-radius: var(--radius-pill); padding: 2px 8px;
}

/* ══════════════════════════════════════════════════════════════════════════
   TABLES (axe majeur — lisibles, scannables, respirantes)
   ══════════════════════════════════════════════════════════════════════════ */
.table-wrap { overflow-x: auto; border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
thead th {
  /* Sticky relatif au conteneur de défilement (.table-wrap, qui a overflow) :
     l'offset doit être 0 — sinon le header est poussé par-dessus la 1re ligne.
     Devient un vrai header collant si le .table-wrap reçoit une max-height. */
  position: sticky; top: 0; z-index: 2;
  text-align: left;
  font-family: var(--font-body);
  font-size: 11.5px;
  color: var(--text-muted);
  letter-spacing: 0.01em;
  font-weight: 600;
  padding: 11px var(--sp-4);
  background: var(--surface-1);
  border-bottom: 1px solid var(--border-soft);
  white-space: nowrap;
}
thead th:last-child { text-align: right; }
tbody td {
  padding: 12px var(--sp-4);
  border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
  color: var(--text-muted);
}
tbody td:first-child { color: var(--text-primary); }
tbody tr { transition: background var(--t-fast); }
tbody tr:hover { background: rgba(124,108,255,0.045); }
tbody tr:last-child td { border-bottom: none; }
.td-action { text-align: right; white-space: nowrap; }

/* Cellule d'identité (couche de scan) */
.cell-name strong { font-size: var(--fs-sm); font-weight: 600; display: block; color: var(--text-primary); letter-spacing: 0.005em; }
.cell-name span { font-family: var(--font-mono); font-size: var(--fs-micro); color: var(--text-faint); }
.t-id { display: flex; align-items: center; gap: 10px; min-width: 0; }
.t-id .av {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  background: var(--grad-brand-soft); border: 1px solid rgba(124,108,255,0.22);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-size: 10.5px; font-weight: 600; color: var(--text-primary);
}
.t-id .who { min-width: 0; }
.t-id .who strong { display: block; font-size: var(--fs-sm); font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.t-id .who span { font-family: var(--font-mono); font-size: var(--fs-micro); color: var(--text-faint); }

/* Actions révélées au survol */
.row-actions { display: inline-flex; gap: 6px; opacity: 0; transform: translateX(4px); transition: opacity var(--t-fast), transform var(--t-fast) var(--ease-out); }
tr:hover .row-actions, tr:focus-within .row-actions { opacity: 1; transform: translateX(0); }

/* ══════════════════════════════════════════════════════════════════════════
   ALERTS
   ══════════════════════════════════════════════════════════════════════════ */
.alert {
  padding: 11px 14px; border-radius: var(--radius-sm);
  font-size: var(--fs-sm); margin-bottom: var(--sp-4);
  border: 1px solid; display: flex; align-items: flex-start; gap: 9px;
  animation: rise var(--t-base) var(--ease-out);
}
.alert-danger { background: rgba(242,96,107,0.08); border-color: rgba(242,96,107,0.24); color: var(--danger); }
.alert-ok     { background: rgba(124,108,255,0.08); border-color: rgba(124,108,255,0.24); color: var(--signal); }
.alert-info   { background: rgba(91,141,239,0.08); border-color: rgba(91,141,239,0.24); color: var(--info); }
.alert-warn   { background: rgba(240,169,74,0.08); border-color: rgba(240,169,74,0.24); color: var(--warn); }

/* ══════════════════════════════════════════════════════════════════════════
   TABS
   ══════════════════════════════════════════════════════════════════════════ */
.tabs { display: flex; border-bottom: 1px solid var(--border-soft); margin-bottom: var(--sp-5); gap: 0; }
.tab {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 0; margin-right: var(--sp-5);
  color: var(--text-faint); font-size: var(--fs-sm); font-weight: 600;
  cursor: pointer; border-bottom: 2px solid transparent;
  transition: color var(--t-base), border-color var(--t-base);
  white-space: nowrap; user-select: none;
}
.tab:hover { color: var(--text-muted); }
.tab.active { color: var(--text-primary); border-bottom-color: var(--signal); }
.tab svg { width: 15px; height: 15px; opacity: 0.65; transition: opacity var(--t-base), color var(--t-base); }
.tab:hover svg { opacity: 0.9; }
.tab.active svg { opacity: 1; color: var(--signal); }

/* ══════════════════════════════════════════════════════════════════════════
   GAUGE
   ══════════════════════════════════════════════════════════════════════════ */
.gauge { position: relative; display: flex; align-items: center; justify-content: center; }
.gauge svg { display: block; }
.gauge .ring-bg  { fill: none; stroke: var(--border); }
.gauge .ring-val { fill: none; stroke-linecap: round; transition: stroke-dashoffset var(--t-slower) var(--ease-out); }
.gauge .ring-val.ok      { stroke: var(--signal); }
.gauge .ring-val.warn    { stroke: var(--warn); }
.gauge .ring-val.danger  { stroke: var(--danger); }
.gauge .ring-val.neutral { stroke: var(--text-faint); }
.gauge .gauge-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.gauge .gauge-value { font-family: var(--font-mono); font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.gauge .gauge-label { font-size: 9px; color: var(--text-faint); text-transform: uppercase; letter-spacing: var(--tk-wide); margin-top: 3px; }

/* ══════════════════════════════════════════════════════════════════════════
   DRAWER
   ══════════════════════════════════════════════════════════════════════════ */
.overlay {
  position: fixed; inset: 0;
  background: rgba(4,6,12,0.62);
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
  display: flex; justify-content: flex-end;
  z-index: var(--z-drawer);
  opacity: 0; pointer-events: none;
  transition: opacity var(--t-base) var(--ease-out);
}
.overlay.open { opacity: 1; pointer-events: auto; }
.drawer {
  width: min(600px, 94vw); height: 100%;
  background: var(--glass-bg-strong);
  -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur);
  border-left: 1px solid var(--glass-border);
  display: flex; flex-direction: column;
  transform: translateX(24px);
  transition: transform var(--t-slow) var(--ease-out);
  box-shadow: -20px 0 60px -16px rgba(0,0,0,0.66);
}
.overlay.open .drawer { transform: translateX(0); }
.drawer-head {
  display: flex; justify-content: space-between; align-items: flex-start; gap: var(--sp-3);
  padding: var(--sp-5) var(--sp-6) var(--sp-4);
  border-bottom: 1px solid var(--border-soft);
  flex-shrink: 0;
}
.drawer-head h2, .drawer-head h3 { font-size: var(--fs-lg); font-weight: 700; letter-spacing: var(--tk-tight); }
.drawer-close {
  background: none; border: none; color: var(--text-faint);
  cursor: pointer; font-size: 22px; line-height: 1; padding: 4px;
  border-radius: var(--radius-xs); margin-top: -2px;
  transition: color var(--t-fast), background var(--t-fast);
}
.drawer-close:hover { color: var(--text-primary); background: var(--bg-hover); }
.drawer-body { flex: 1; overflow-y: auto; padding: var(--sp-5) var(--sp-6); }

/* ══════════════════════════════════════════════════════════════════════════
   MODAL
   ══════════════════════════════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(4,6,12,0.68);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  z-index: var(--z-modal);
  opacity: 0; pointer-events: none;
  transition: opacity var(--t-base) var(--ease-out);
  padding: var(--sp-4);
}
.modal-overlay.open { opacity: 1; pointer-events: auto; }
.modal-box {
  position: relative;
  width: min(460px, 100%);
  background: var(--glass-bg-strong);
  -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: var(--sp-6);
  transform: scale(0.96) translateY(8px);
  transition: transform var(--t-base) var(--ease-spring);
  overflow: hidden;
}
.modal-box::before { content: ''; position: absolute; inset: 0 0 auto 0; height: 1px; background: var(--grad-line); }
.modal-overlay.open .modal-box { transform: scale(1) translateY(0); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: var(--sp-4) var(--sp-5); border-bottom: 1px solid var(--border-soft); }
.modal-head h2, .modal-head h3 { font-size: var(--fs-lg); font-weight: 700; }
.modal-body { padding: var(--sp-5); }
.modal-foot { display: flex; justify-content: flex-end; gap: var(--sp-2); padding: var(--sp-4) var(--sp-5); border-top: 1px solid var(--border-soft); background: var(--bg-panel-raised); }

/* ══════════════════════════════════════════════════════════════════════════
   EMPTY STATES
   ══════════════════════════════════════════════════════════════════════════ */
.empty { text-align: center; padding: var(--sp-16) var(--sp-5); color: var(--text-muted); }
.empty .glyph {
  font-size: 26px; margin: 0 auto var(--sp-3);
  width: 56px; height: 56px; border-radius: var(--radius-lg);
  display: flex; align-items: center; justify-content: center;
  background: var(--grad-brand-soft); border: 1px solid var(--glass-border);
  color: var(--signal);
}
.empty h3 { font-size: var(--fs-md); margin-bottom: 7px; color: var(--text-primary); }
.empty p { font-size: var(--fs-sm); color: var(--text-faint); max-width: 320px; margin: 0 auto; line-height: var(--lh-base); }
.empty .empty-action { margin-top: var(--sp-5); }

/* ══════════════════════════════════════════════════════════════════════════
   SKELETON
   ══════════════════════════════════════════════════════════════════════════ */
.skeleton {
  border-radius: 5px;
  background: linear-gradient(90deg, var(--bg-panel-raised) 25%, var(--bg-panel-high) 50%, var(--bg-panel-raised) 75%);
  background-size: 200% 100%;
  animation: skeleton-sweep 1.4s ease-in-out infinite;
}
.skeleton-row { display: flex; align-items: center; gap: var(--sp-3); padding: 12px var(--sp-4); border-bottom: 1px solid var(--border-soft); }
.skeleton-avatar { width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0; }
.skeleton-text { height: 11px; flex: 1; }
.skeleton-pill { width: 58px; height: 18px; border-radius: 5px; }
.skeleton-score { width: 42px; height: 11px; }

/* ══════════════════════════════════════════════════════════════════════════
   QCM — question / options
   ══════════════════════════════════════════════════════════════════════════ */
.question-block { margin-bottom: var(--sp-7); animation: rise var(--t-base) var(--ease-out) both; }
.question-block .q-num { font-family: var(--font-mono); color: var(--signal); font-size: var(--fs-micro); margin-bottom: 8px; letter-spacing: var(--tk-wide); text-transform: uppercase; }
.question-block .q-text { font-size: var(--fs-md); font-weight: 600; margin-bottom: var(--sp-4); line-height: var(--lh-snug); letter-spacing: var(--tk-tight); }
.option-row {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: 13px var(--sp-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: var(--sp-2);
  cursor: pointer;
  transition: border-color var(--t-fast), background var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast) var(--ease-out);
}
.option-row:hover { border-color: var(--signal-dim); background: rgba(124,108,255,0.05); }
.option-row.selected { border-color: var(--signal); background: rgba(124,108,255,0.10); box-shadow: 0 0 0 1px rgba(124,108,255,0.28); }
.option-row input { width: auto; margin: 0; flex-shrink: 0; accent-color: var(--signal); }
.option-row.correct   { border-color: var(--signal); background: rgba(124,108,255,0.11); }
.option-row.incorrect { border-color: var(--danger); background: rgba(242,96,107,0.09); }
.option-row .mark { margin-left: auto; font-family: var(--font-mono); font-size: var(--fs-meta); flex-shrink: 0; }

.progress-bar { height: 5px; background: var(--border); border-radius: var(--radius-pill); overflow: hidden; }
.progress-bar > div { height: 100%; width: 100%; background: var(--grad-brand); transform-origin: left; transform: scaleX(0); transition: transform var(--t-slow) var(--ease-out); }

/* ══════════════════════════════════════════════════════════════════════════
   FILTER BAR (legacy)
   ══════════════════════════════════════════════════════════════════════════ */
.filter-bar { display: flex; gap: var(--sp-2); align-items: center; flex-wrap: wrap; padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border-soft); }
.filter-bar input, .filter-bar select { padding: 6px 10px; font-size: var(--fs-sm); width: auto; }
.filter-bar input[type="text"] { min-width: 150px; }
.filter-bar select { min-width: 130px; }
.filter-bar .filter-label { font-family: var(--font-mono); font-size: 10.5px; color: var(--text-faint); text-transform: uppercase; letter-spacing: var(--tk-wide); white-space: nowrap; }

/* ══════════════════════════════════════════════════════════════════════════
   PAGE-SPECIFIC (composants partagés repensés)
   ══════════════════════════════════════════════════════════════════════════ */
/* QCM cards (catalogue) */
.qcm-card {
  position: relative;
  background: var(--bg-panel);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: var(--sp-4) var(--sp-5);
  display: flex; align-items: center; gap: var(--sp-4);
  transition: border-color var(--t-base) var(--ease-out), transform var(--t-base) var(--ease-out), box-shadow var(--t-base) var(--ease-out);
  animation: rise var(--t-slow) var(--ease-out) both;
}
.qcm-card:hover { border-color: rgba(124,108,255,0.28); transform: translateY(-2px); box-shadow: var(--shadow-sm), var(--glow-violet); }
.qcm-card .qcm-icon { width: 44px; height: 44px; border-radius: var(--radius-md); background: var(--grad-brand-soft); border: 1px solid rgba(124,108,255,0.2); color: var(--signal); display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0; }
.qcm-card .info { flex: 1; min-width: 0; }
.qcm-card .info h3 { font-size: var(--fs-md); font-weight: 600; margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qcm-card .info .meta { font-size: var(--fs-meta); color: var(--text-faint); display: flex; gap: var(--sp-3); flex-wrap: wrap; margin-top: 5px; font-family: var(--font-mono); }
.qcm-card .actions { display: flex; align-items: center; gap: var(--sp-3); flex-shrink: 0; }

/* Expand rows (génériques) */
.expand-chevron, .aqd-chev, .qd-chev, .tacc-chev, .pacc-chev { transition: transform var(--t-base) var(--ease-out); flex-shrink: 0; color: var(--text-faint); }
.is-open .expand-chevron, .open .aqd-chev, .open .qd-chev, .open .tacc-chev, .open .pacc-chev { transform: rotate(90deg); }

/* Maîtrise bar (générique) */
.maitrise-bar { width: 84px; height: 6px; background: var(--border); border-radius: var(--radius-pill); overflow: hidden; display: inline-block; vertical-align: middle; }
.maitrise-bar-fill { height: 100%; width: 100%; border-radius: var(--radius-pill); transform-origin: left; transform: scaleX(0); transition: transform var(--t-slower) var(--ease-out); }

/* Parcours */
.parcours-card { background: var(--bg-panel); border: 1px solid var(--glass-border); border-radius: var(--radius-lg); padding: var(--sp-5) var(--sp-5); margin-bottom: var(--sp-3); }
.parcours-card .phead { display: flex; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-4); padding-bottom: var(--sp-3); border-bottom: 1px solid var(--border-soft); }
.parcours-card .pnom { font-size: var(--fs-md); font-weight: 700; flex: 1; letter-spacing: var(--tk-tight); }
.parcours-card .pdesc { color: var(--text-muted); font-size: var(--fs-sm); margin-bottom: var(--sp-3); }
.qcm-slot { display: flex; align-items: center; gap: var(--sp-3); padding: 10px 12px; background: var(--bg-panel-raised); border-radius: var(--radius-md); margin-bottom: 6px; border: 1px solid var(--border-soft); }
.qcm-slot .ordre { font-family: var(--font-mono); font-size: var(--fs-micro); color: var(--text-faint); width: 20px; text-align: center; flex-shrink: 0; }
.qcm-slot .qnom { flex: 1; font-size: var(--fs-sm); font-weight: 600; }
.qcm-slot .arrow-btns { display: flex; flex-direction: column; gap: 2px; }
.arrow-btn { background: none; border: 1px solid var(--border); color: var(--text-muted); border-radius: 5px; width: 22px; height: 18px; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 9px; transition: border-color var(--t-fast), color var(--t-fast); }
.arrow-btn:hover { border-color: var(--signal-dim); color: var(--signal); }
.qcm-add-select { flex: 1; padding: 8px 10px; font-size: var(--fs-sm); background: var(--bg-input); border: 1px solid var(--border); color: var(--text-primary); border-radius: var(--radius-sm); }

/* ══════════════════════════════════════════════════════════════════════════
   ANIMATIONS
   ══════════════════════════════════════════════════════════════════════════ */
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes scale-in { from { opacity: 0; transform: scale(0.97); } to { opacity: 1; transform: scale(1); } }
@keyframes sbf-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
@keyframes skeleton-sweep { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
@keyframes slide-in-right { from { opacity: 0; transform: translateX(12px); } to { opacity: 1; transform: translateX(0); } }

/* Scroll-reveal (activé en JS via .in) */
.reveal { opacity: 0; transform: translateY(14px); transition: opacity var(--t-slower) var(--ease-out), transform var(--t-slower) var(--ease-out); }
.reveal.in { opacity: 1; transform: none; }

/* Entrée en cascade (utilitaire) */
.stagger > * { opacity: 0; animation: rise var(--t-slow) var(--ease-out) forwards; }
.stagger > *:nth-child(1) { animation-delay: 40ms; }
.stagger > *:nth-child(2) { animation-delay: 80ms; }
.stagger > *:nth-child(3) { animation-delay: 120ms; }
.stagger > *:nth-child(4) { animation-delay: 160ms; }
.stagger > *:nth-child(5) { animation-delay: 200ms; }
.stagger > *:nth-child(6) { animation-delay: 240ms; }

/* ══════════════════════════════════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════════════════════════════════ */
@media (min-width: 1500px) {
  .content { padding: var(--sp-8) var(--sp-10); }
}
@media (max-width: 1024px) {
  :root { --sidebar-w: 216px; }
  .content { padding: var(--sp-6) var(--sp-6); }
  .grid-4, .grid-cols-4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (max-width: 880px) {
  .login-brand-side { display: none; }
  .grid-2, .grid-3, .grid-4,
  .grid-cols-2, .grid-cols-3, .grid-cols-4 { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .app-shell { flex-direction: column; }
  .sidebar {
    width: 100%; height: auto; position: sticky; top: 0;
    flex-direction: row; align-items: center;
    padding: 9px var(--sp-3);
    overflow-x: auto; overflow-y: visible;
    border-right: none; border-bottom: 1px solid var(--glass-border);
  }
  .sidebar-brand { border-bottom: none; margin: 0 var(--sp-2) 0 0; padding: 0; flex-shrink: 0; }
  .sidebar-brand .name, .sidebar-brand .sub { display: none; }
  .sidebar-nav { flex-direction: row; gap: 2px; flex-shrink: 0; }
  .sidebar-nav .nav-section { display: none; }
  .sidebar-nav a .label { display: none; }
  .sidebar-nav a.active::before { display: none; }
  .sidebar-footer { display: none; }
  /* Une seule barre collante en haut sur mobile (la nav) : la statusline défile,
     pour éviter deux éléments sticky top:0 qui se recouvrent. */
  .statusline { padding: 0 var(--sp-4); min-height: 48px; position: static; }
  .content { padding: var(--sp-4); }
  .page-head { margin-bottom: var(--sp-5); }
  .page-head h1 { font-size: var(--fs-lg); }
  .field-row { flex-direction: column; gap: 0; }
  .tabs .tab { font-size: var(--fs-meta); margin-right: var(--sp-4); }
  .kpi .value { font-size: var(--fs-xl); }
  thead th, tbody td { padding: 10px 12px; }
}
@media (max-width: 480px) {
  .modal-box { margin: 0 6px; }
  .drawer { width: 100%; border-left: none; }
  .kpi .value { font-size: var(--fs-xl); }
}

/* ══════════════════════════════════════════════════════════════════════════
   PRÉFÉRENCES MOUVEMENT
   ══════════════════════════════════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
}

/* ══════════════════════════════════════════════════════════════════════════
   RC2.1 — Hero KPI · skeletons · tri · responsive tables · a11y · hover
   ══════════════════════════════════════════════════════════════════════════ */

/* KPI héro (métrique principale, dynamique et pertinente) */
.kpi-hero { grid-column: span 2; }
.kpi-hero .label { font-size: 12px; color: var(--text-muted); }
.kpi-hero .value { font-size: clamp(34px, 4vw, 44px); }
.kpi-hero .kpi-sub { margin-top: 9px; font-size: 12px; color: var(--text-muted); }
.kpi-hero::before { opacity: 0.9; height: 3px; }
@media (max-width: 560px) { .kpi-hero { grid-column: auto; } }

/* Skeletons */
.sk-card { display: flex; align-items: center; gap: 14px; padding: 15px 16px; border-bottom: 1px solid var(--border-soft); }
.sk-card:last-child { border-bottom: none; }
.sk-row td { padding-top: 14px; padding-bottom: 14px; }

/* Tri de colonnes */
th.th-sort { cursor: pointer; }
th.th-sort:hover { color: var(--text-primary); }
th.th-sort::after { content: '↕'; opacity: 0.35; margin-left: 6px; font-size: 10px; font-weight: 400; }
th.th-sort[data-sort="asc"]::after { content: '↑'; opacity: 1; color: var(--signal); }
th.th-sort[data-sort="desc"]::after { content: '↓'; opacity: 1; color: var(--signal); }

/* Validation inline des formulaires */
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--danger-dim); box-shadow: 0 0 0 3px var(--danger-glow); }

/* Actions révélées au survol : toujours visibles au toucher */
@media (hover: none) { .row-actions { opacity: 1 !important; transform: none !important; } }

/* Responsive : tables en cartes empilées (mobile) */
@media (max-width: 720px) {
  .table-wrap { overflow: visible; }
  .table-wrap table, .table-wrap tbody, .table-wrap tr, .table-wrap td { display: block; width: 100%; }
  .table-wrap thead { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); }
  .table-wrap tbody tr { border: 1px solid var(--border-soft); border-radius: var(--radius-md); margin-bottom: 10px; background: var(--bg-panel); overflow: hidden; }
  .table-wrap tbody tr:hover { background: var(--bg-panel); }
  .table-wrap tbody td { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 10px 14px; border: none; border-bottom: 1px solid var(--hairline); text-align: right; }
  .table-wrap tbody td:last-child { border-bottom: none; }
  .table-wrap tbody td[data-label]::before { content: attr(data-label); color: var(--text-faint); font-weight: 500; text-align: left; margin-right: auto; white-space: nowrap; }
  .table-wrap tbody td:empty { display: none; }
  .row-actions { opacity: 1; transform: none; }
}

/* ════════════════════════════════════════════════════════════════════════
   Gamification — puces de niveau (sobres) & toasts discrets (partagés)
   ════════════════════════════════════════════════════════════════════════ */
.tier { display:inline-flex; align-items:center; gap:6px; font-size:11px; font-weight:600;
  font-family:var(--font-mono); letter-spacing:.02em; padding:2px 9px; border-radius:100px;
  border:1px solid var(--border-soft); color:var(--text-muted); background:var(--bg-panel-raised); white-space:nowrap; }
.tier-dot { width:6px; height:6px; border-radius:50%; background:var(--text-faint); }
.tier-1 { color:color-mix(in srgb, var(--info) 78%, var(--text-primary)); border-color:color-mix(in srgb, var(--info) 30%, transparent); }
.tier-1 .tier-dot { background:var(--info); }
.tier-2 { color:color-mix(in srgb, var(--warn) 80%, var(--text-primary)); border-color:color-mix(in srgb, var(--warn) 32%, transparent); }
.tier-2 .tier-dot { background:var(--warn); }
.tier-3 { color:color-mix(in srgb, var(--signal) 82%, var(--text-primary)); border-color:color-mix(in srgb, var(--signal) 36%, transparent); background:color-mix(in srgb, var(--signal) 8%, var(--bg-panel-raised)); }
.tier-3 .tier-dot { background:var(--signal); box-shadow:0 0 6px color-mix(in srgb, var(--signal) 60%, transparent); }

#qt-toast-host { position:fixed; right:20px; bottom:20px; z-index:9999; display:flex; flex-direction:column; gap:10px; pointer-events:none; }
.qt-toast { display:flex; align-items:center; gap:10px; max-width:340px; padding:12px 15px;
  background:var(--bg-panel-raised); border:1px solid color-mix(in srgb, var(--signal) 32%, var(--border-soft));
  border-radius:var(--radius-md); box-shadow:0 8px 30px rgba(0,0,0,.35); color:var(--text-primary); font-size:13px; font-weight:500;
  opacity:0; transform:translateY(10px) scale(.98); transition:opacity .28s var(--ease-out), transform .28s var(--ease-out); }
.qt-toast.show { opacity:1; transform:translateY(0) scale(1); }
.qt-toast-ic { font-size:17px; line-height:1; flex-shrink:0; }
@media (prefers-reduced-motion: reduce) { .qt-toast { transition:opacity .2s; transform:none; } }
