/* ============================================================
   FIDUNEXT · Design Tokens
   Point d'entrée unique. Importer ce fichier dans tout artefact.
   ============================================================ */

/* --- Fonts (Google Fonts substitutes — flagged in README) --- */
@import url('https://fonts.googleapis.com/css2?family=Geist:wght@400;500;600;700&family=Geist+Mono:wght@400;500&family=Instrument+Serif:ital@0;1&display=swap');

:root {
  /* ============ COULEURS ============ */

  /* Encre — texte, fond sombre */
  --ink-50:  #F4F5F8;
  --ink-100: #E6E8EE;
  --ink-200: #C9CDD8;
  --ink-300: #9AA1B2;
  --ink-400: #6B7388;
  --ink-500: #4A5268;
  --ink-600: #2E3651;
  --ink-700: #1C253F;
  --ink-800: #131E37;
  --ink-900: #0E1B33;  /* primary ink */
  --ink:     #0E1B33;

  /* Frost — fond d'application */
  --frost-50:  #FBFCFE;
  --frost-100: #F6F9FC;
  --frost-200: #F2F7FA;  /* default app bg */
  --frost-300: #E8EDF4;
  --frost-400: #DAE2EC;
  --frost:     #F2F7FA;

  /* Surface — cartes, inputs */
  --surface:        #FFFFFF;
  --surface-sunken: #EFF2F6;

  /* Lignes & bordures */
  --line:        #DEE5EC;   /* sur frost */
  --line-strong: #C6CDD4;
  --line-on-surface: #E9E9EE;

  /* Primary — bleu électrique (CTA, liens, focus) */
  --primary-50:  #EEF2FF;
  --primary-100: #DCE3FF;
  --primary-200: #B6C4FF;
  --primary-300: #8AA0FF;
  --primary-400: #5C7AFF;
  --primary-500: #2D5BFF;   /* base */
  --primary-600: #1F46D9;
  --primary-700: #1736A8;
  --primary-800: #122880;
  --primary-900: #0A1A57;
  --primary:     #2D5BFF;

  /* Success — pastel Pennylane neutral (semantic) */
  --success-50:  #ECFAF1;
  --success-100: #D1F1DE;
  --success-200: #A6E2C0;
  --success-300: #71CDA0;
  --success-400: #45B584;
  --success-500: #2F9F6B;   /* base */
  --success-600: #1F8556;
  --success-700: #166842;
  --success-800: #114A30;
  --success-900: #0C311F;
  --success:     #2F9F6B;

  /* Warning — pastel Pennylane neutral (semantic) */
  --warning-50:  #FDF6E5;
  --warning-100: #FAE9BD;
  --warning-200: #F4D689;
  --warning-300: #ECC053;
  --warning-400: #E3A934;
  --warning-500: #D89B22;   /* base */
  --warning-600: #B3811A;
  --warning-700: #8B6313;
  --warning-800: #5F420C;
  --warning-900: #392606;
  --warning:     #D89B22;

  /* Danger — pastel Pennylane neutral (semantic) */
  --danger-50:  #FDECEC;
  --danger-100: #FBD2D2;
  --danger-200: #F6AAAA;
  --danger-300: #ED7676;
  --danger-400: #DE5A5A;
  --danger-500: #D34A4A;   /* base */
  --danger-600: #B33232;
  --danger-700: #8C2424;
  --danger-800: #5F1717;
  --danger-900: #3A0E0E;
  --danger:     #D34A4A;

  /* Info — sky-blue Tailwind-aligned (semantic, NEW gap fill) */
  --info-50:  #F0F9FF;
  --info-100: #E0F2FE;
  --info-200: #BAE6FD;
  --info-300: #7DD3FC;
  --info-400: #38BDF8;
  --info-500: #0EA5E9;   /* base */
  --info-600: #0284C7;
  --info-700: #0369A1;
  --info-800: #075985;
  --info-900: #0C4A6E;
  --info:     #0EA5E9;

  /* ============ SÉMANTIQUES ============ */
  --bg-app:         var(--frost-200);
  --bg-surface:     var(--surface);
  --bg-sunken:      var(--surface-sunken);
  --bg-hover:       var(--frost-300);
  --bg-overlay:     rgba(14, 27, 51, 0.38);
  --bg-topbar-glass: rgba(255, 255, 255, 0.85);  /* topbar sticky + backdrop-filter blur */

  --fg-1:           var(--ink-900);   /* texte principal */
  --fg-2:           var(--ink-500);   /* texte secondaire */
  --fg-3:           var(--ink-400);   /* tertiaire, labels */
  --fg-muted:       var(--ink-300);   /* placeholders */
  --fg-on-accent:   #FFFFFF;
  --fg-on-ink:      #FFFFFF;
  --fg-on-ink-muted: rgba(255, 255, 255, 0.6);  /* texte attenue sur fond encre (chevron pill, etc.) */

  --link:           var(--primary-500);
  --link-hover:     var(--primary-600);
  --focus-ring:     0 0 0 3px rgba(45, 91, 255, 0.18);

  /* VAGUE 7 -- accent de chrome (defaut = bleu primary ; .fx-theme-admin -> rouge) */
  --sidebar-accent-bg: var(--primary-50);
  --sidebar-accent-fg: var(--primary-700);
  --sidebar-brand:     var(--primary-600);
  --chrome-avatar-bg:  var(--primary-600);

  /* ============ TYPOGRAPHIE ============ */
  --font-sans:    'Geist', 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-serif:   'Instrument Serif', 'Times New Roman', serif;
  --font-mono:    'Geist Mono', 'JetBrains Mono', ui-monospace, monospace;

  /* Échelle (rem-based, root = 16px) */
  --fs-xs:    12px;
  --fs-sm:    13px;
  --fs-base:  14px;
  --fs-md:    16px;
  --fs-lg:    18px;
  --fs-xl:    22px;
  --fs-2xl:   28px;
  --fs-3xl:   36px;
  --fs-4xl:   56px;
  --fs-display: 80px;

  --lh-tight:   1.15;
  --lh-snug:    1.3;
  --lh-base:    1.5;
  --lh-relaxed: 1.65;

  --tracking-tight:  -0.01em;
  --tracking-tighter: -0.02em;
  --tracking-display: -0.03em;
  --tracking-label:   0.08em;
  --tracking-mono:    0;

  --fw-regular: 400;
  --fw-medium:  500;
  --fw-semi:    600;
  --fw-bold:    700;

  /* ============ ESPACEMENTS (grille 4px) ============ */
  --space-0:  0;
  --space-1:  2px;
  --space-2:  4px;
  --space-3:  8px;
  --space-4:  12px;
  --space-5:  16px;
  --space-6:  20px;
  --space-7:  24px;
  --space-8:  32px;
  --space-9:  40px;
  --space-10: 56px;
  --space-11: 80px;
  --space-12: 120px;

  /* ============ RAYONS ============ */
  --r-xs:   4px;
  --r-sm:   6px;
  --r-md:   10px;
  --r-lg:   14px;
  --r-xl:   20px;
  --r-pill: 999px;

  /* ============ OMBRES ============ */
  --shadow-1: 0 1px 2px rgba(14, 27, 51, 0.04);
  --shadow-2: 0 4px 12px rgba(14, 27, 51, 0.06);
  --shadow-3: 0 12px 32px rgba(14, 27, 51, 0.12);
  --shadow-inner: inset 0 1px 0 rgba(255,255,255,0.4);

  /* ============ TRANSITIONS ============ */
  --ease:        cubic-bezier(0.2, 0, 0, 1);
  --ease-in:     cubic-bezier(0.4, 0, 1, 1);
  --t-micro:     120ms var(--ease);
  --t-base:      200ms var(--ease);
  --t-slow:      320ms var(--ease);

  /* Toast notifications (ADR-0029) */
  --z-toast: 1100;
  --toast-max-w: 24rem;
  --toast-gap: 0.75rem;
  --toast-padding: 1rem;
  --toast-radius: 0.75rem;
  --toast-shadow: var(--shadow-3);
  --toast-stagger-ms: 500;
  --toast-progress-h: 3px;
}

/* ============================================================
   STYLES SÉMANTIQUES (à composer dans les pages)
   ============================================================ */

/* Reset léger applicable au document */
.fx-base {
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: var(--lh-base);
  color: var(--fg-1);
  background: var(--bg-app);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'cv11', 'ss01', 'ss03';
}

/* --- Titres --- */
.fx-display {
  font-family: var(--font-sans);
  font-size: var(--fs-display);
  line-height: 0.98;
  letter-spacing: -0.035em;
  font-weight: var(--fw-semi);
  color: var(--fg-1);
}

.fx-h1 {
  font-family: var(--font-sans);
  font-size: var(--fs-3xl);
  line-height: var(--lh-tight);
  letter-spacing: var(--tracking-tighter);
  font-weight: var(--fw-semi);
  color: var(--fg-1);
}

.fx-h2 {
  font-size: var(--fs-2xl);
  line-height: var(--lh-snug);
  letter-spacing: var(--tracking-tight);
  font-weight: var(--fw-semi);
  color: var(--fg-1);
}

.fx-h3 {
  font-size: var(--fs-xl);
  line-height: var(--lh-snug);
  letter-spacing: var(--tracking-tight);
  font-weight: var(--fw-semi);
  color: var(--fg-1);
}

.fx-h4 {
  font-size: var(--fs-lg);
  line-height: var(--lh-snug);
  font-weight: var(--fw-semi);
  color: var(--fg-1);
}

/* --- Corps --- */
.fx-body    { font-size: var(--fs-base); line-height: var(--lh-base);    color: var(--fg-1); }
.fx-body-lg { font-size: var(--fs-md);   line-height: var(--lh-relaxed); color: var(--fg-1); }
.fx-body-sm { font-size: var(--fs-sm);   line-height: var(--lh-base);    color: var(--fg-2); }

/* --- Labels et meta --- */
.fx-label {
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--fg-3);
}

.fx-caption {
  font-size: var(--fs-xs);
  line-height: var(--lh-base);
  color: var(--fg-2);
}

/* --- Numéros (montants) --- */
.fx-num {
  font-family: var(--font-sans);
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum';
  letter-spacing: var(--tracking-tight);
}

.fx-num-display {
  font-family: var(--font-sans);
  font-weight: var(--fw-medium);
  font-variant-numeric: tabular-nums;
  font-size: var(--fs-3xl);
  line-height: 1;
  letter-spacing: -0.025em;
  color: var(--fg-1);
}

/* --- Code / mono --- */
.fx-code {
  font-family: var(--font-mono);
  font-size: 0.92em;
  background: var(--bg-sunken);
  padding: 1px 6px;
  border-radius: var(--r-xs);
  color: var(--fg-1);
}

/* --- Lien --- */
.fx-link {
  color: var(--link);
  text-decoration: none;
  text-underline-offset: 3px;
  transition: color var(--t-micro);
}
.fx-link:hover { color: var(--link-hover); text-decoration: underline; }

/* ============================================================
   RESET GLOBAL
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
[x-cloak] { display: none !important; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: var(--r-pill); }
::-webkit-scrollbar-thumb:hover { background: var(--ink-300); }

/* ============================================================
   FORM WIDGETS -- .fx-input + scope .fx-form
   Style "filled" : fond gris neutre au repos, fond blanc + anneau couleur au focus.
   Coherent avec le pattern utilise dans iam/auth/login.html et password_reset_*.html.

   REGLE PROJET (racine du style des formulaires) : toute balise <form> recoit
   la classe `fx-form`. Les widgets Django rendus nus ({{ form.field }}) heritent
   alors automatiquement du style .fx-input -- AUCUN attrs widget ni markup
   par champ n'est requis pour etre conforme au design system. Les erreurs de
   champ utilisent .fx-form-error ; le .errorlist par defaut de Django est
   style en filet de securite.
   ============================================================ */
.fx-input,
.fx-form input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="submit"]):not([type="button"]):not([type="hidden"]),
.fx-form select,
.fx-form textarea {
  display: block;
  width: 100%;
  height: 3rem;
  padding: 0 0.875rem;
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
  line-height: 1;
  color: var(--fg-1);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  outline: none;
  transition: border-color var(--t-base), box-shadow var(--t-base), background var(--t-base);
  -webkit-font-smoothing: antialiased;
}
.fx-input::placeholder,
.fx-form input::placeholder,
.fx-form textarea::placeholder { color: var(--fg-muted); }
.fx-input:focus,
.fx-form input:focus,
.fx-form select:focus,
.fx-form textarea:focus {
  background: var(--bg-surface);
  border-color: var(--primary-500);
  box-shadow: 0 0 0 3px rgba(45, 91, 255, 0.18);
}
.fx-input:disabled,
.fx-input[readonly],
.fx-form input:disabled,
.fx-form input[readonly],
.fx-form select:disabled,
.fx-form textarea:disabled,
.fx-form textarea[readonly] {
  opacity: 0.6;
  cursor: not-allowed;
}
.fx-input--icon-left  { padding-left: 2.75rem; }
.fx-input--icon-right { padding-right: 2.75rem; }
.fx-input--error {
  border-color: var(--danger-500);
  background: var(--danger-50);
}
.fx-input--error:focus {
  border-color: var(--danger-600);
  box-shadow: 0 0 0 3px rgba(197, 68, 46, 0.18);
}
.fx-input--mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

/* Ajustements scope .fx-form : la hauteur fixe 3rem ne convient pas au textarea. */
.fx-form textarea {
  height: auto;
  min-height: 6rem;
  padding: 0.75rem 0.875rem;
  line-height: 1.5;
}

/* ============================================================
   .fx-form--compact : variante dense (opt-in) pour les grilles de
   saisie (ecriture comptable, etc.). Rayons reduits + hauteur de champ
   resserree + cartes moins padees -> rendu compact et sobre. Active
   par la classe `fx-form--compact` sur <form> ; ne touche AUCUN autre
   formulaire (design system global inchange -- ADR-0028).
   ============================================================ */
.fx-form--compact .fx-input,
.fx-form--compact select.fx-input,
.fx-form--compact textarea.fx-input {
  height: 2.5rem;              /* 40px (vs 48) -- compact */
  padding: 0 0.625rem;         /* 10px lateral (vs 14) */
  border-radius: var(--r-sm);  /* 5px (vs 12) -- rayons reduits */
  font-size: var(--fs-sm);     /* 13px */
}
.fx-form--compact textarea.fx-input {
  height: auto;
  min-height: 2.5rem;
  padding: 0.5rem 0.625rem;
  line-height: 1.45;
}
.fx-form--compact .fx-card { border-radius: var(--r-lg); }    /* 12px (vs 16) */
.fx-form--compact .fx-card-body { padding: var(--space-5); }  /* 16px (vs 32) */

/* Message d'erreur de champ -- utilise par les templates ({{ field.errors }}). */
.fx-form-error {
  margin-top: 0.25rem;
  font-size: var(--fs-xs);
  color: var(--danger-600);
}

/* Filet de securite : rendu par defaut de Django ({{ form.field.errors }} nu
   ou {{ form }} complet) -- ul.errorlist style comme .fx-form-error. */
.fx-form .errorlist {
  margin: 0.25rem 0 0;
  padding: 0;
  list-style: none;
  font-size: var(--fs-xs);
  color: var(--danger-600);
}

/* ============================================================
   BOUTONS -- .fx-btn
   ============================================================ */
.fx-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  line-height: 1.25;
  border-radius: var(--r-sm);
  border: none;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  transition: transform var(--t-micro), box-shadow var(--t-base), background-color var(--t-micro);
  touch-action: manipulation;
  -webkit-font-smoothing: antialiased;
}
.fx-btn:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}
.fx-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
  pointer-events: none;
}
.fx-btn--sm { padding: 0.375rem 0.75rem; font-size: var(--fs-xs); border-radius: var(--r-sm); }
.fx-btn--lg { padding: 0.75rem 1.5rem; font-size: var(--fs-md); border-radius: var(--r-sm); }
.fx-btn--full { width: 100%; }

.fx-btn--primary {
  background: var(--primary-500);
  color: var(--fg-on-accent);
  box-shadow: 0 1px 3px rgba(45, 91, 255, 0.18);
}
.fx-btn--primary:hover:not(:disabled) {
  background: var(--primary-600);
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(45, 91, 255, 0.24);
}
.fx-btn--secondary {
  background: var(--bg-surface);
  color: var(--fg-1);
  box-shadow: inset 0 0 0 1px var(--line-strong), var(--shadow-1);
}
.fx-btn--secondary:hover:not(:disabled) {
  background: var(--bg-hover);
  transform: translateY(-1px);
  box-shadow: inset 0 0 0 1px var(--line-strong), var(--shadow-2);
}
.fx-btn--danger {
  background: var(--danger-500);
  color: var(--fg-on-accent);
  box-shadow: 0 1px 3px rgba(197, 68, 46, 0.18);
}
.fx-btn--danger:hover:not(:disabled) {
  background: var(--danger-600);
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(197, 68, 46, 0.24);
}
.fx-btn--ghost {
  background: transparent;
  color: var(--fg-2);
  box-shadow: none;
}
.fx-btn--ghost:hover:not(:disabled) {
  background: var(--bg-hover);
  color: var(--fg-1);
}

/* ============================================================
   CARDS -- .fx-card
   ============================================================ */
.fx-card {
  background: var(--bg-surface);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-1);
}
/* Carte avec table en pleine largeur : clipper le contenu a la forme arrondie
   pour eviter les coins bas a 90deg de la fx-table-wrap qui depasse l'arrondi.
   Cible uniquement les cartes contenant une table (pas de risque sur texte/forms). */
.fx-card:has(.fx-table-wrap) { overflow: hidden; }
.fx-card--sm { border-radius: var(--r-sm); }
.fx-card-body { padding: var(--space-8); }
.fx-card-section {
  padding-bottom: var(--space-7);
  margin-bottom: var(--space-7);
}
.fx-card-section:last-child { padding-bottom: 0; margin-bottom: 0; }

/* ============================================================
   BADGES -- .fx-badge
   ============================================================ */
.fx-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.625rem;
  border-radius: var(--r-sm);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  white-space: nowrap;
  line-height: 1.4;
}
.fx-badge--default { background: var(--ink-50);    color: var(--ink-600);    box-shadow: inset 0 0 0 1px var(--ink-100); }
.fx-badge--primary { background: var(--primary-50); color: var(--primary-700); box-shadow: inset 0 0 0 1px var(--primary-200); }
.fx-badge--success { background: var(--success-50);   color: var(--success-700);   box-shadow: inset 0 0 0 1px var(--success-200); }
.fx-badge--warning { background: var(--warning-50);  color: var(--warning-600);  box-shadow: inset 0 0 0 1px var(--warning-200); }
.fx-badge--danger  { background: var(--danger-50);  color: var(--danger-600);  box-shadow: inset 0 0 0 1px var(--danger-200); }
.fx-badge--info    { background: var(--primary-50); color: var(--primary-700); box-shadow: inset 0 0 0 1px var(--primary-200); }
.fx-badge--pulse .fx-badge-dot { animation: fx-pulse 1.5s ease-in-out infinite; }
@keyframes fx-pulse {
  0%, 100% { opacity: 0.85; }
  50%      { opacity: 0.35; }
}
.fx-badge-dot {
  width: 0.375rem; height: 0.375rem;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.85;
  flex-shrink: 0;
}

/* ============================================================
   SECTION HEADER (formulaires multi-sections)
   ============================================================ */
.fx-section-title {
  font-size: var(--fs-xs);
  font-weight: var(--fw-semi);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--fg-3);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--line);
  margin-bottom: var(--space-6);
}

/* ============================================================
   DIVIDER
   ============================================================ */
.fx-divider {
  border: none;
  border-top: 1px solid var(--line);
  margin: var(--space-7) 0;
}

/* ============================================================
   ICON TILE -- carre arrondi colore contenant un SVG
   Utilise dans stat cards, quick actions, section headers, empty states.
   Tones semantiques : success=sain, warning=attention, danger=alerte,
   info=info neutre, primary=CTA, neutral=technique.
   ============================================================ */
.fx-icon-tile {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: var(--r-md);
  background: var(--primary-50);
  color: var(--primary-700);
}
.fx-icon-tile--sm { width: 2.25rem; height: 2.25rem; border-radius: var(--r-sm); }
.fx-icon-tile--lg { width: 3rem; height: 3rem; }

.fx-icon-tile--primary  { background: var(--primary-50);  color: var(--primary-700); }
.fx-icon-tile--success { background: var(--success-50);    color: var(--success-700); }
.fx-icon-tile--warning { background: var(--warning-50);   color: var(--warning-600); }
.fx-icon-tile--danger  { background: var(--danger-50);   color: var(--danger-600); }
.fx-icon-tile--neutral { background: var(--ink-50);     color: var(--ink-600); }

/* ============================================================
   STAT CARD -- KPI card avec icon tile + numeric + label
   ============================================================ */
.fx-stat-card {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  background: var(--bg-surface);
  border-radius: var(--r-md);
  padding: var(--space-5);
  box-shadow: var(--shadow-1);
  transition: box-shadow var(--t-base), transform var(--t-micro);
  text-decoration: none;
  color: inherit;
}
.fx-stat-card--clickable:hover {
  box-shadow: var(--shadow-2);
  transform: translateY(-1px);
  cursor: pointer;
}
.fx-stat-card--gradient {
  background: linear-gradient(135deg, var(--surface) 0%, var(--frost-100) 100%);
}
.fx-stat-card-body { min-width: 0; flex: 1; }
.fx-stat-card-value {
  font-size: var(--fs-2xl);
  font-weight: var(--fw-semi);
  color: var(--fg-1);
  line-height: 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: var(--tracking-tight);
}
.fx-stat-card-label {
  font-size: var(--fs-xs);
  color: var(--fg-2);
  margin-top: var(--space-2);
}
.fx-stat-card-sublabel {
  font-size: var(--fs-xs);
  color: var(--fg-3);
  margin-top: var(--space-1);
}
.fx-stat-card-delta {
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  margin-top: var(--space-2);
}
.fx-stat-card-delta--positive { color: var(--success-700); }
.fx-stat-card-delta--negative { color: var(--danger-600); }

/* ============================================================
   QUICK ACTION -- card hoverable avec icone + texte
   ============================================================ */
.fx-quick-action {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  background: var(--bg-surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: var(--space-5);
  text-decoration: none;
  color: inherit;
  transition: border-color var(--t-base), background var(--t-base), transform var(--t-micro);
}
.fx-quick-action:hover {
  border-color: var(--primary-300);
  background: var(--primary-50);
  transform: translateY(-1px);
}
.fx-quick-action--coming-soon {
  cursor: not-allowed;
  pointer-events: none;
  animation: fx-coming-soon-pulse 2.4s ease-in-out infinite;
}
@keyframes fx-coming-soon-pulse {
  0%, 100% { opacity: 0.5; }
  50%      { opacity: 0.7; }
}
@media (prefers-reduced-motion: reduce) {
  .fx-quick-action--coming-soon {
    animation: none;
    opacity: 0.5;
  }
}
.fx-quick-action-body { min-width: 0; flex: 1; }
.fx-quick-action-title {
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--fg-1);
}
.fx-quick-action-subtitle {
  font-size: var(--fs-xs);
  color: var(--fg-2);
  margin-top: var(--space-1);
}

/* ============================================================
   PAGE HEADER -- H1 + subtitle + optional right-aligned CTA
   ============================================================ */
.fx-page-header {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  margin-bottom: var(--space-7);
}
@media (min-width: 640px) {
  .fx-page-header {
    flex-direction: row;
    align-items: flex-end;
    justify-content: space-between;
  }
}
.fx-page-header-title {
  font-size: var(--fs-2xl);
  font-weight: var(--fw-semi);
  color: var(--fg-1);
  letter-spacing: var(--tracking-tight);
  line-height: var(--lh-tight);
}
.fx-page-header-subtitle {
  font-size: var(--fs-sm);
  color: var(--fg-2);
  margin-top: var(--space-2);
}

/* ============================================================
   SECTION HEADER -- icone + titre h3 + optional action right
   ============================================================ */
.fx-section-header {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-5) var(--space-7);
  border-bottom: 1px solid var(--line);
}
.fx-section-header-title {
  flex: 1;
  font-size: var(--fs-md);
  font-weight: var(--fw-semi);
  color: var(--fg-1);
}

/* ============================================================
   TABLE -- .fx-table
   Direction "Epuree" : lignes fines, en-tete micro-label,
   survol frost doux, chiffres tabulaires alignes a droite.
   ============================================================ */
/* Densite "confortable/compact" : paddings en px intentionnellement hors grille
   --space-* (4px), cales sur la maquette validee direction "Epuree". Ne pas
   convertir en tokens (changerait la densite visuelle). */
.fx-table-wrap {
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  overflow-x: auto;
  background: var(--surface);
}
.fx-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
  color: var(--fg-1);
  background: var(--surface);
}
.fx-table thead th {
  text-align: left;
  font-size: var(--fs-xs);
  font-weight: var(--fw-semi);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--fg-3);
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.fx-table tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line-on-surface);
  color: var(--fg-1);
}
.fx-table tbody tr:last-child td { border-bottom: none; }
.fx-table tbody tr { transition: background var(--t-micro); }
.fx-table tbody tr:hover { background: var(--frost-100); }

/* Cellule numerique : montants alignes a droite, chasse fixe */
.fx-num-cell {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum';
}

/* Cellule alignee a droite SANS semantique numerique (libelles, actions, badges) */
.fx-cell--right { text-align: right; }

/* Ligne de total (tfoot) */
.fx-table-total td {
  font-weight: var(--fw-semi);
  border-top: 2px solid var(--line);
  border-bottom: none;
  background: var(--frost-100);
  color: var(--fg-1);
  padding: 11px 14px;
}
.fx-table-total + .fx-table-total td { border-top: none; }

/* Etat vide (ligne pleine largeur) */
.fx-table-empty td {
  text-align: center;
  padding: var(--space-7) var(--space-4);
  color: var(--fg-3);
  font-size: var(--fs-sm);
}

/* Variante compacte (longs registres : grand livre, balance) */
.fx-table--compact thead th { padding: 6px 12px; }
.fx-table--compact tbody td { padding: 6px 12px; }
.fx-table--compact .fx-table-total td { padding: 7px 12px; }

@media (prefers-reduced-motion: reduce) {
  .fx-table tbody tr { transition: none; }
}

/* ============================================================
   VAGUE 2 -- COMPAGNONS DE LISTE
   fx-amount / fx-toolbar / fx-pagination / fx-filter-chips
   Direction "Epuree" : sobre, lignes fines, couleur semantique
   opt-in, rayons discrets, transitions micro sous garde.
   ============================================================ */

/* --- fx-amount : montant formate ------------------------------------ */
/* Le formatage FR ("12 400,50") est produit par le filtre fx_amount.
   .fx-amount fixe la chasse tabulaire ; --neg/--pos sont OPT-IN (couleur). */
.fx-amount {
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum';
  white-space: nowrap;
}
.fx-amount--neg { color: var(--danger-600); }
.fx-amount--pos { color: var(--success-700); }
.fx-amount--zero { color: var(--fg-3); }

/* --- fx-toolbar : en-tete de liste --------------------------------- */
/* titre (+ compteur) a gauche, filtres au centre (slot), actions a droite.
   Stacke en colonne sous 640px. */
.fx-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-5);
}
.fx-toolbar-title {
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
  min-width: 0;
}
.fx-toolbar-count {
  font-size: var(--fs-xs);
  font-weight: var(--fw-semi);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--fg-3);
}
.fx-toolbar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-left: auto;
}
@media (max-width: 640px) {
  .fx-toolbar { flex-direction: column; align-items: stretch; }
  .fx-toolbar-actions { margin-left: 0; }
}

/* --- fx-pagination : navigation de pages --------------------------- */
.fx-pagination {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-5);
}
.fx-pagination-item {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--fg-2);
  font-size: var(--fs-sm);
  text-decoration: none;
  transition: background var(--t-micro), border-color var(--t-micro);
}
.fx-pagination-item:hover { background: var(--frost-100); border-color: var(--line-strong); }
.fx-pagination-item--active {
  border-color: var(--primary-600);
  background: var(--primary-600);
  color: var(--fg-on-accent);
  font-weight: var(--fw-semi);
}
.fx-pagination-item--active:hover { background: var(--primary-700); border-color: var(--primary-700); }
.fx-pagination-item--disabled {
  opacity: 0.45;
  pointer-events: none;
  cursor: default;
}
/* --- fx-filter-chips : filtres actifs supprimables ----------------- */
/* Reprend le langage de components/ui/chip.html (rounded-full, fx tokens),
   variante "filtre actif + bouton de suppression". */
.fx-filter-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}
.fx-filter-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 4px 6px 4px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  background: var(--surface);
  color: var(--fg-1);
  font-size: var(--fs-xs);
  line-height: 1.2;
}
.fx-filter-chip-label { white-space: nowrap; }
.fx-filter-chip-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: var(--r-pill);
  color: var(--fg-3);
  text-decoration: none;
  transition: background var(--t-micro), color var(--t-micro);
}
.fx-filter-chip-remove:hover { background: var(--frost-200); color: var(--danger-600); }
.fx-filter-chip-remove:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 1px; }

@media (prefers-reduced-motion: reduce) {
  .fx-pagination-item,
  .fx-filter-chip-remove { transition: none; }
}

/* ============================================================
   VAGUE 3 -- VUES DE DETAIL
   fx-deflist / fx-tooltip / fx-menu / fx-drawer
   Direction "Epuree" : sobre, lignes fines, couleur semantique,
   ombres legeres (--shadow-2 max), rayons discrets, transitions
   micro sous garde prefers-reduced-motion.
   ============================================================ */

/* --- utilitaire a11y : texte reserve lecteur d'ecran (W3-D4) -------- */
.fx-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;
}

/* --- fx-deflist : liste cle/valeur (<dl>) -------------------------- */
/* Defaut --inline : grille [cle etroite | valeur]. --stacked : cle
   au-dessus de la valeur. Cle = micro-label ; valeur = texte principal.
   --full : element pleine largeur (Description, etc.). */
.fx-deflist {
  display: grid;
  grid-template-columns: minmax(120px, max-content) 1fr;
  gap: var(--space-3) var(--space-5);
  margin: 0;
}
.fx-deflist-item {
  display: contents;
}
.fx-deflist-item--full {
  grid-column: 1 / -1;
  display: block;
}
.fx-deflist-item--full .fx-deflist-key { margin-bottom: 2px; }
.fx-deflist-key {
  font-size: var(--fs-xs);
  font-weight: var(--fw-semi);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--fg-3);
  margin: 0;
}
.fx-deflist-value {
  font-size: var(--fs-sm);
  color: var(--fg-1);
  margin: 0;
  min-width: 0;
}
/* --stacked : chaque item devient un bloc (cle au-dessus). */
.fx-deflist--stacked {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}
.fx-deflist--stacked .fx-deflist-item { display: block; }
.fx-deflist--stacked .fx-deflist-key { margin-bottom: 2px; }

/* --- fx-tooltip : infobulle survol/focus ---------------------------- */
/* Wrapper inline-flex ; declencheur = contenu ; bulle absolue masquee
   par defaut (x-cloak) -> affichee par Alpine au survol/focus. */
.fx-tooltip {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.fx-tooltip-trigger {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: help;
}
.fx-tooltip-icon { color: var(--fg-3); line-height: 0; }
.fx-tooltip-bubble {
  position: absolute;
  z-index: 60;
  max-width: 280px;
  width: max-content;
  padding: 6px 10px;
  background: var(--ink-900);
  color: var(--fg-on-ink);
  font-size: var(--fs-xs);
  font-weight: var(--fw-regular);
  line-height: 1.4;
  letter-spacing: normal;
  text-transform: none;
  text-align: left;
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-2);
  white-space: normal;
}
/* Position par defaut : au-dessus, centree. */
.fx-tooltip-bubble--top {
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
}
.fx-tooltip-bubble--bottom {
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
}

/* --- fx-menu : menu d'actions deroulant ----------------------------- */
.fx-menu { position: relative; display: inline-flex; }
.fx-menu-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--fg-2);
  cursor: pointer;
  transition: background var(--t-micro), border-color var(--t-micro);
}
.fx-menu-trigger:hover { background: var(--frost-100); border-color: var(--line); }
.fx-menu-trigger:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.fx-menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  z-index: 50;
  min-width: 180px;
  padding: var(--space-2);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-2);
}
.fx-menu-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: 6px 10px;
  border-radius: var(--r-sm);
  color: var(--fg-1);
  font-size: var(--fs-sm);
  text-align: left;
  text-decoration: none;
  background: transparent;
  transition: background var(--t-micro);
}
.fx-menu-item:hover { background: var(--frost-100); }
.fx-menu-item:focus-visible { outline: none; background: var(--frost-100); box-shadow: var(--focus-ring); }
.fx-menu-item--danger { color: var(--danger-600); }
.fx-menu-item-icon { line-height: 0; color: var(--fg-3); }
.fx-menu-item--danger .fx-menu-item-icon { color: var(--danger-600); }

/* --- fx-drawer : tiroir lateral coulissant (HTMX) ------------------- */
.fx-drawer-overlay {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: var(--bg-overlay);
}
.fx-drawer-panel {
  position: fixed;
  inset-block: 0;
  right: 0;
  z-index: 71;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 28rem;
  background: var(--surface);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow-2);
  outline: none;
}
.fx-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-5);
  border-bottom: 1px solid var(--line);
}
.fx-drawer-title {
  font-size: var(--fs-md);
  font-weight: var(--fw-semi);
  color: var(--fg-1);
  margin: 0;
}
.fx-drawer-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--fg-2);
  cursor: pointer;
  transition: background var(--t-micro);
}
.fx-drawer-close:hover { background: var(--frost-100); }
.fx-drawer-close:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.fx-drawer-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: var(--space-5);
  color: var(--fg-1);
  font-size: var(--fs-sm);
}
.fx-drawer-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--line);
}

@media (prefers-reduced-motion: reduce) {
  .fx-menu-trigger,
  .fx-menu-item,
  .fx-drawer-close { transition: none; }
}

/* ============================================================
   VAGUE 4 -- WORKFLOW & STATUT
   fx-timeline / fx-avatar / fx-segmented / fx-stepper /
   fx-skeleton / fx-banner / fx-progress
   Direction "Epuree" : sobre, lignes fines, couleur semantique,
   ombres legeres (--shadow-2 max), rayons discrets, animations/
   transitions sous garde prefers-reduced-motion.
   ============================================================ */

/* --- fx-timeline : frise d'activite (<ol>) ------------------------- */
/* Point + ligne verticale fine + label + horodatage. Ton par defaut
   primary ; tons semantiques optionnels via --success/--warning/etc. */
.fx-timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}
.fx-timeline-item {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
}
.fx-timeline-dot {
  flex-shrink: 0;
  margin-top: 5px;
  width: 8px;
  height: 8px;
  border-radius: var(--r-pill);
  background: var(--primary-500);
}
.fx-timeline-dot--success { background: var(--success-500); }
.fx-timeline-dot--warning { background: var(--warning-500); }
.fx-timeline-dot--danger  { background: var(--danger-500); }
.fx-timeline-dot--info    { background: var(--info-500); }
.fx-timeline-body { flex: 1 1 auto; min-width: 0; }
.fx-timeline-label {
  margin: 0;
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--fg-1);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.fx-timeline-time {
  margin: 0;
  font-size: var(--fs-xs);
  color: var(--fg-3);
}
.fx-timeline-empty {
  margin: 0;
  padding: var(--space-8) 0;
  text-align: center;
  font-size: var(--fs-sm);
  color: var(--fg-3);
}

/* --- fx-avatar : initiales ou image -------------------------------- */
.fx-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: var(--r-pill);
  background: var(--primary-600);
  color: var(--fg-on-ink);
  font-size: 10px;
  font-weight: var(--fw-semi);
  line-height: 1;
  text-transform: uppercase;
  overflow: hidden;
  user-select: none;
}
.fx-avatar--sm { width: 22px; height: 22px; font-size: 9px; }
.fx-avatar--lg { width: 40px; height: 40px; font-size: 14px; }
.fx-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
}

/* --- fx-segmented : controle segmente (bascule) -------------------- */
/* Etat actif sobre = blanc + ombre legere (miroir du toggle sidebar). */
.fx-segmented {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border-radius: var(--r-md);
  background: var(--ink-50);
}
.fx-segmented-option {
  flex: 1 1 auto;
  padding: 4px 12px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--fg-2);
  font-size: var(--fs-xs);
  font-weight: var(--fw-regular);
  text-align: center;
  cursor: pointer;
  transition: background var(--t-micro), color var(--t-micro), box-shadow var(--t-micro);
}
.fx-segmented-option:hover { color: var(--fg-1); }
.fx-segmented-option:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.fx-segmented-option--active {
  background: var(--surface);
  color: var(--fg-1);
  font-weight: var(--fw-medium);
  box-shadow: var(--shadow-1);
}

/* --- fx-stepper : etapes numerotees -------------------------------- */
.fx-stepper {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}
.fx-step {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
}
.fx-step:not(:last-child)::after {
  content: "";
  display: inline-block;
  width: 28px;
  height: 1px;
  background: var(--line);
}
.fx-step-marker {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--fg-3);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semi);
}
.fx-step-label {
  font-size: var(--fs-sm);
  color: var(--fg-3);
}
.fx-step--done .fx-step-marker {
  border-color: var(--success-500);
  background: var(--success-500);
  color: var(--fg-on-ink);
}
.fx-step--done .fx-step-label { color: var(--fg-2); }
.fx-step--current .fx-step-marker {
  border-color: var(--primary-500);
  background: var(--primary-50);
  color: var(--primary-700);
}
.fx-step--current .fx-step-label { color: var(--fg-1); font-weight: var(--fw-medium); }
.fx-step--upcoming .fx-step-marker {
  border-color: var(--line);
  background: var(--surface);
  color: var(--fg-3);
}
.fx-step--failed .fx-step-marker {
  border-color: var(--danger-500);
  background: var(--danger-500);
  color: var(--fg-on-ink);
}
.fx-step--failed .fx-step-label { color: var(--danger-700); }

/* --- fx-skeleton : placeholder de chargement ----------------------- */
.fx-skeleton {
  display: block;
  border-radius: var(--r-sm);
  background: var(--surface-sunken);
  background-image: linear-gradient(
    90deg,
    var(--surface-sunken) 0%,
    var(--frost-100) 50%,
    var(--surface-sunken) 100%
  );
  background-size: 200% 100%;
  animation: fx-skeleton-shimmer 1.4s ease-in-out infinite;
}
.fx-skeleton--text { height: 12px; width: 100%; margin-bottom: var(--space-2); }
.fx-skeleton--block { height: 96px; width: 100%; }
.fx-skeleton--row { height: 40px; width: 100%; margin-bottom: var(--space-2); }
@keyframes fx-skeleton-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* --- fx-banner : notice de page persistante ------------------------ */
/* Distinct de l'alert inline (feedback formulaire) et du toast (ephemere).
   Tons : info -> --info-* (vs alert qui mappe info -> primary). */
.fx-banner {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border: 1px solid;
  border-radius: var(--r-md);
}
.fx-banner-icon { flex-shrink: 0; line-height: 0; margin-top: 1px; }
.fx-banner-body { flex: 1 1 auto; min-width: 0; }
.fx-banner-title {
  margin: 0 0 2px;
  font-size: var(--fs-sm);
  font-weight: var(--fw-semi);
}
.fx-banner-message { margin: 0; font-size: var(--fs-sm); }
.fx-banner-action {
  display: inline-block;
  margin-top: var(--space-2);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  text-decoration: underline;
  color: inherit;
}
.fx-banner-close {
  flex-shrink: 0;
  border: 0;
  background: transparent;
  color: inherit;
  opacity: 0.6;
  cursor: pointer;
  line-height: 0;
  transition: opacity var(--t-micro);
}
.fx-banner-close:hover { opacity: 1; }
.fx-banner-close:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: var(--r-sm); }
.fx-banner--info {
  border-color: var(--info-200);
  background: var(--info-50);
  color: var(--info-700);
}
.fx-banner--success {
  border-color: var(--success-200);
  background: var(--success-50);
  color: var(--success-700);
}
.fx-banner--warning {
  border-color: var(--warning-200);
  background: var(--warning-50);
  color: var(--warning-700);
}
.fx-banner--danger {
  border-color: var(--danger-200);
  background: var(--danger-50);
  color: var(--danger-700);
}

/* --- fx-progress : barre de progression ---------------------------- */
.fx-progress {
  width: 100%;
  height: 8px;
  border-radius: var(--r-pill);
  background: var(--surface-sunken);
  overflow: hidden;
}
.fx-progress-bar {
  height: 100%;
  border-radius: inherit;
  background: var(--primary-500);
  transition: width var(--t-base);
}
.fx-progress-bar--primary { background: var(--primary-500); }
.fx-progress-bar--success { background: var(--success-500); }
.fx-progress-bar--warning { background: var(--warning-500); }
.fx-progress-bar--danger  { background: var(--danger-500); }

@media (prefers-reduced-motion: reduce) {
  .fx-skeleton { animation: none; }
  .fx-progress-bar { transition: none; }
  .fx-segmented-option,
  .fx-banner-close { transition: none; }
}

/* ============================================================
   VAGUE 5 -- MODALES & FEEDBACK
   fx-modal-* (overlay Alpine) / fx-dialog (<dialog> natif)
   Chrome partage par les deux mecanismes. Direction "Epuree" :
   surface sobre, bordure fine, ombre legere (--shadow-2 max),
   rayons discrets, transitions sous garde prefers-reduced-motion.
   ============================================================ */

/* --- fx-modal : overlay + panneau (variante overlay Alpine) -------- */
.fx-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  background: var(--bg-overlay);
}
.fx-modal {
  position: relative;
  width: 100%;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - var(--space-8));
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-2);
}
.fx-modal--sm { max-width: 24rem; }
.fx-modal--md { max-width: 32rem; }
.fx-modal--lg { max-width: 48rem; }
.fx-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--line);
}
.fx-modal-title {
  margin: 0;
  font-size: var(--fs-md);
  font-weight: var(--fw-semi);
  color: var(--fg-1);
}
.fx-modal-title--danger { color: var(--danger-700); }
.fx-modal-close {
  flex-shrink: 0;
  border: 0;
  background: transparent;
  color: var(--fg-2);
  line-height: 0;
  cursor: pointer;
  padding: var(--space-1);
  border-radius: var(--r-sm);
  transition: color var(--t-micro), background var(--t-micro);
}
.fx-modal-close:hover { color: var(--fg-1); background: var(--frost-100); }
.fx-modal-close:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.fx-modal-body {
  padding: var(--space-5);
  color: var(--fg-1);
  overflow-y: auto;
}
.fx-modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--line);
}

/* --- fx-dialog : <dialog> natif (top layer + ::backdrop) ----------- */
/* Pour les formulaires charges via HTMX (showModal()). Le chrome
   interne reutilise .fx-modal-header / -title / -close / -footer. */
.fx-dialog {
  width: 100%;
  max-width: 32rem;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-2);
  color: var(--fg-1);
}
.fx-dialog--lg { max-width: 48rem; }
.fx-dialog::backdrop { background: var(--bg-overlay); }

@media (prefers-reduced-motion: reduce) {
  .fx-modal-close { transition: none; }
}

/* ============================================================
   VAGUE 6 -- LAYOUT FORMULAIRE (fidele Gestica v1, transpose fx-*)
   fx-form-layout (2 colonnes) / fx-form-header (sticky haut) /
   fx-form-nav (ancres + scroll-spy). Direction "Epuree" : sobre,
   couleur semantique, transitions sous garde prefers-reduced-motion.
   ============================================================ */

/* --- layout 2 colonnes : nav ancres (gauche) + corps (droite) ----- */
.fx-form-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-6);
  padding-bottom: var(--space-6);
}
@media (min-width: 1024px) {
  .fx-form-layout { grid-template-columns: 240px 1fr; }
}

/* --- en-tete sticky (sous la topbar /app/ : top 52px, z 20 < 30) --- */
.fx-form-header {
  position: sticky;
  top: 52px;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  /* Bleed la padding du <main> (Tailwind p-6 = 24px = --space-7) : l'en-tete
     colle la topbar (haut) et s'etend sur toute la largeur du contenu
     principal (cotes), puis on restitue la padding horizontale (24px) pour
     aligner le contenu sous l'en-tete avec les cartes. */
  margin: calc(-1 * var(--space-7)) calc(-1 * var(--space-7)) var(--space-5);
  padding: var(--space-5) var(--space-7);
  background: color-mix(in srgb, var(--surface) 85%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.fx-form-header-main {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
}
.fx-form-header-back {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--r-md);
  background: transparent;
  border: 0;
  color: var(--fg-2);
  transition: background var(--t-micro), color var(--t-micro);
}
.fx-form-header-back:hover { background: var(--frost-100); color: var(--fg-1); }
.fx-form-header-back:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.fx-form-header-titles { min-width: 0; }
.fx-form-header-title {
  margin: 0;
  font-size: var(--fs-lg);
  font-weight: var(--fw-semi);
  color: var(--fg-1);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.fx-form-header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}
.fx-form-header-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--r-pill);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  background: var(--danger-50);
  color: var(--danger-700);
  border: 1px solid var(--danger-200);
}

/* --- fil d'Ariane (au-dessus du titre, style breadcrumbs.html) ----- */
.fx-form-breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--fs-xs);
  margin-bottom: 2px;
}
.fx-form-breadcrumb a { color: var(--primary-600); }
.fx-form-breadcrumb a:hover { text-decoration: underline; }
.fx-form-breadcrumb-sep { color: var(--fg-3); }
.fx-form-breadcrumb-current { color: var(--fg-2); }

/* --- nav ancres (colonne gauche) + scroll-spy ---------------------- */
.fx-form-nav { min-width: 0; }
@media (min-width: 1024px) {
  .fx-form-nav { position: sticky; top: 108px; align-self: start; }
}
.fx-form-nav-label {
  padding: 0 var(--space-3);
  margin-bottom: var(--space-2);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semi);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--fg-3);
}
.fx-form-nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.fx-form-nav-item {
  display: block;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--r-md);
  font-size: var(--fs-sm);
  color: var(--fg-2);
  transition: background var(--t-micro), color var(--t-micro);
}
.fx-form-nav-item:hover { background: var(--frost-100); color: var(--fg-1); }
.fx-form-nav-item--active {
  background: var(--primary-50);
  color: var(--primary-700);
  font-weight: var(--fw-medium);
  box-shadow: inset 0 0 0 1px var(--primary-100);
}

@media (prefers-reduced-motion: reduce) {
  .fx-form-header-back,
  .fx-form-nav-item { transition: none; }
}

/* --- VAGUE 6 fidelite v1 -- icone de section, libelle champ, badge "bientot" */

/* Gap A -- pastille icone section : degrade bleu + icone blanche */
.fx-form-section-icon {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: var(--r-md);
  background: linear-gradient(135deg, var(--primary-500), var(--primary-600));
  color: var(--fg-on-ink);
  box-shadow: var(--shadow-2);
}

/* Gap F -- libelle de champ : normal case (remplace fx-label MAJUSCULES) */
.fx-form-label {
  display: block;
  margin-bottom: 6px;
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--fg-2);
}

/* Notes/Activite stubs -- badge "Bientot" */
.fx-coming-soon-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: var(--r-pill);
  font-size: 10px;
  font-weight: var(--fw-medium);
  background: var(--warning-50);
  color: var(--warning-600);
  border: 1px solid var(--warning-200);
  vertical-align: middle;
}

/* ============================================================
   SIDEBAR APP -- repli + actif + groupes accordeon (Pass 2)
   Transitions de largeur sidebar + etat actif par item.
   Toutes les couleurs via var(--...) uniquement.
   ============================================================ */

/* Transition largeur sidebar (collapse/expand). */
.fx-sidebar {
  transition: width var(--t-base);
}

/* Item actif : degrade primary depuis la gauche. */
.fx-sidebar-item--active {
  background: linear-gradient(
    90deg,
    var(--primary-50),
    color-mix(in srgb, var(--primary-100) 50%, transparent)
  );
  color: var(--primary-700);
  font-weight: var(--fw-medium);
}

/* Item "Bientot" : texte mute pour signaler l'indisponibilite. */
.fx-sidebar-item--soon {
  color: var(--fg-3);
}

/* Chevron accordeon sidebar : rotation animee 0 -> 180deg a l'ouverture. */
.fx-sidebar-chevron {
  display: inline-flex;
  align-items: center;
  transition: transform var(--t-base);
}

@media (prefers-reduced-motion: reduce) {
  .fx-sidebar { transition: none; }
  .fx-sidebar-chevron { transition: none; }
}

/* ============================================================
   DROPDOWNS SHELL -- pastille avatar (selecteur societe, style v1)
   ============================================================ */
.fx-ws-avatar {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: var(--r-md);
  background: var(--primary-50);
  color: var(--primary-700);
  font-size: 11px;
  font-weight: var(--fw-semi);
  line-height: 1;
}
.fx-ws-avatar--muted { background: var(--ink-50); color: var(--ink-600); }

/* ============================================================
   VAGUE 7 -- PARITE SHELL SUPERADMIN (theme rouge)
   Redirige l'accent de chrome vers la rampe --danger-* sur le
   root de l'espace superadmin uniquement. Zero impact sur les
   shells cabinet/client/app (qui n'ont pas cette classe).
   ============================================================ */
.fx-theme-admin {
  --sidebar-accent-bg: var(--danger-50);
  --sidebar-accent-fg: var(--danger-700);
  --sidebar-brand:     var(--danger-600);
  --chrome-avatar-bg:  var(--danger-600);
}
