/**
 * SIA — Design System
 * Charte: BUESA 2026 (Mathilde Morel) — Bleu SIA / Rouge Signal / Noir Profond / Blanc Technique
 * Version: 3.0
 */

/* ============================================
   PALETTE CHARTE BUESA
   ============================================ */
:root {
  /* Safe areas iOS / Android (encoche, Dynamic Island, home indicator).
     viewport-fit=cover requis dans le <meta viewport> pour que ces env() soient non nuls. */
  --sia-safe-top: env(safe-area-inset-top, 0px);
  --sia-safe-bottom: env(safe-area-inset-bottom, 0px);
  --sia-safe-left: env(safe-area-inset-left, 0px);
  --sia-safe-right: env(safe-area-inset-right, 0px);

  /* Offset sous le chrome haut = topnav + safe-area (surchargé si topnav collapse) */
  --sia-chrome-top: calc(var(--sia-topnav-height, 52px) + var(--sia-safe-top));

  /* Fonds & surfaces */
  --sia-bg-deep: #080B12;          /* Noir Profond */
  --sia-bg-raised: #111723;        /* Bleu Prusse */
  --sia-bg-elevated: #1B2436;      /* Prusse éclairci (teinte dérivée) */
  --sia-bg-light: #F7F7F7;         /* Blanc Technique */
  --sia-surface-light: #FFFFFF;

  /* Marque & texte */
  --sia-brand: #17176B;            /* Bleu SIA — navy profond */
  --sia-brand-hover: #2A2A8F;      /* Bleu SIA éclairci (hover, dérivé) */
  --sia-workspace-bg: #E4EAF4;     /* Cadre workspace (référence chat) */
  --sia-chrome-bg: #FFFFFF;        /* L blanc sous nav / colonnes */
  --sia-pill-bg: #DDE5F5;          /* Pills inactives */
  --sia-muted: #5C6575;            /* Bleu Ardoise */
  --sia-text-on-dark: #F7F7F7;     /* Blanc Technique */
  --sia-text-on-light: #17176B;    /* Bleu SIA — texte sur fond clair */
  --sia-border: rgba(92, 101, 117, 0.35);  /* Ardoise 35 % */

  /* Bleu roi — couleur structurante des surfaces agentiques (mode Agent du
     chat + page Agents). Distincte du navy --sia-brand, qui reste la couleur
     du reste de l'application. Valeur déjà largement présente dans chat.css
     avant d'être nommée ici : ce token en fait le point de bascule unique. */
  --sia-agent-blue: #173F9B;
  --sia-agent-blue-hover: #2A55C0;

  /* Palette secondaire (interface) */
  --sia-lavande: #DDE5F5;
  --sia-rouge-poudre: #E3A8A6;
  --sia-rouge-signal: #E52827;     /* Signal uniquement — jamais de surface dominante */

  /* Hero institutionnel (seul dégradé décoratif autorisé) */
  --gradient-hero: linear-gradient(135deg, #080B12 0%, #111723 50%, #17176B 100%);

  /* Alias rétrocompatibilité (charte précédente) */
  --sia-primary: var(--sia-text-on-light);
  --sia-secondary: var(--sia-bg-light);
  --sia-accent: var(--sia-muted);
  
  /* === COULEURS PRIMAIRES (mappées charte BUESA) === */
  /* Noir Profond - Institutionnel */
  --color-night-blue: #080B12;
  --color-night-blue-dark: #080B12;
  --color-night-blue-light: #5C6575;

  /* Bleu SIA - Autorité digitale */
  --color-sovereign-blue: #17176B;
  --color-sovereign-blue-dark: #111723;
  --color-sovereign-blue-light: #5C6575;

  /* === COULEURS NEUTRES (mappées charte BUESA) === */
  /* Blanc Technique - Fonds */
  --color-ivory: #F7F7F7;
  --color-ivory-dark: #F7F7F7;
  --color-ivory-light: #F7F7F7;

  /* Bleu Ardoise - Textes secondaires */
  --color-stone-gray: #5C6575;
  --color-stone-gray-dark: #080B12;
  --color-stone-gray-light: #5C6575;

  /* Ardoise / Lavande - Neutre, séparation */
  --color-silver: #5C6575;
  --color-silver-dark: #111723;
  --color-silver-light: #DDE5F5;

  /* Blanc Pur */
  --color-white: #FFFFFF;
  --color-white-off: #F7F7F7;

  /* === COULEURS SÉMANTIQUES (palette charte uniquement) === */
  /* Success - Bleu SIA */
  --color-success: #17176B;
  --color-success-bg: #DDE5F5;
  --color-success-border: #17176B;

  /* Warning - Rouge Poudré (texte foncé pour le contraste) */
  --color-warning: #080B12;
  --color-warning-bg: #E3A8A6;
  --color-warning-border: #C98886;

  /* Error - Rouge Signal (signal, jamais de surface dominante) */
  --color-error: #E52827;
  --color-error-bg: #FBEAE9;
  --color-error-border: #E52827;

  /* Info - Bleu Ardoise */
  --color-info: #5C6575;
  --color-info-bg: #DDE5F5;
  --color-info-border: #5C6575;

  /* Cryptographique - Preuve (Bleu SIA) */
  --color-crypto: #17176B;
  --color-crypto-bg: #DDE5F5;
  --color-crypto-glow: #17176B;
  
  --gradient-noble: var(--sia-bg-light);
  --gradient-blue-depth: var(--sia-bg-deep);

  /* Typographie charte BUESA — Source Serif Pro Italic (H1) · Source Sans Pro */
  --font-display: 'Source Serif Pro', Georgia, 'Times New Roman', serif;
  --font-serif: var(--font-display);
  --font-sans: 'Source Sans Pro', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', Monaco, Consolas, monospace;

  /* Tailles UI (base html 18px) */
  --text-xs: 0.75rem;        /* 13.5px */
  --text-sm: 0.875rem;       /* 15.75px */
  --text-base: 1rem;         /* 18px */
  --text-lg: 1.125rem;       /* 20.25px */
  --text-xl: 1.25rem;        /* 22.5px */
  --text-2xl: 1.5rem;        /* 27px */
  --text-3xl: 1.875rem;      /* 33.75px */
  --text-4xl: 2.25rem;       /* 40.5px */
  --text-5xl: 3rem;          /* 54px */
  --text-6xl: 3.5rem;        /* 63px */

  /* Fourchettes typo charte BUESA planche 05 (px absolus)
     H1 Serif Italic 48–64 · H2 Sans Bold 32–40 · Corps Sans Regular 18–24
     H3 mots cles Sans Regular 16–18 · Micro Sans 12–14 */
  --typo-h1: clamp(48px, 4.5vw, 64px);
  --typo-h2: clamp(32px, 3vw, 40px);
  --typo-body: clamp(18px, 1.2vw, 24px);
  --typo-keywords: clamp(16px, 1.1vw, 18px);
  --typo-micro: clamp(12px, 0.9vw, 14px);
  
  /* Poids */
  --font-light: 300;
  --font-normal: 400;
  --font-medium: 500;
  --font-semibold: 600;
  --font-bold: 700;
  
  /* Interlignage */
  --leading-tight: 1.2;
  --leading-normal: 1.4;
  --leading-relaxed: 1.6;
  --leading-loose: 1.8;
  
  /* === ESPACEMENTS === */
  --space-0: 0;
  --space-1: 0.25rem;        /* 4px */
  --space-2: 0.5rem;         /* 8px */
  --space-3: 0.75rem;        /* 12px */
  --space-4: 1rem;           /* 16px */
  --space-5: 1.25rem;        /* 20px */
  --space-6: 1.5rem;         /* 24px */
  --space-8: 2rem;           /* 32px */
  --space-10: 2.5rem;        /* 40px */
  --space-12: 3rem;          /* 48px */
  --space-16: 4rem;          /* 64px */
  --space-20: 5rem;          /* 80px */
  --space-24: 6rem;          /* 96px */
  
  /* === RAYONS === */
  --radius-xs: 0.125rem;     /* 2px */
  --radius-sm: 0.25rem;      /* 4px */
  --radius-md: 0.5rem;       /* 8px */
  --radius-lg: 0.75rem;      /* 12px */
  --radius-xl: 1rem;         /* 16px */
  --radius-2xl: 1.5rem;      /* 24px */
  --radius-3xl: 2rem;        /* 32px */
  --radius-full: 9999px;
  
  /* === OMBRES === */
  --shadow-xs: 0 1px 2px rgba(8, 11, 18, 0.05);
  --shadow-sm: 0 2px 4px rgba(8, 11, 18, 0.1);
  --shadow-md: 0 4px 8px rgba(8, 11, 18, 0.15);
  --shadow-lg: 0 8px 16px rgba(8, 11, 18, 0.2);
  --shadow-xl: 0 16px 32px rgba(8, 11, 18, 0.25);
  --shadow-2xl: 0 24px 48px rgba(8, 11, 18, 0.3);
  --shadow-accent: 0 4px 16px rgba(23, 23, 107, 0.3);
  --shadow-accent-lg: 0 8px 32px rgba(23, 23, 107, 0.4);
  --shadow-crypto: 0 0 20px rgba(23, 23, 107, 0.3);
  
  /* === TRANSITIONS === */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 300ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-bounce: 400ms cubic-bezier(0.68, -0.55, 0.265, 1.55);
  
  /* === BREAKPOINTS === */
  --breakpoint-xs: 0px;
  --breakpoint-sm: 640px;
  --breakpoint-md: 768px;
  --breakpoint-lg: 1024px;
  --breakpoint-xl: 1280px;
  --breakpoint-2xl: 1536px;
  
  /* === Z-INDEX === */
  --z-base: 0;
  --z-dropdown: 1000;
  --z-sticky: 1020;
  --z-fixed: 1030;
  --z-modal-backdrop: 1040;
  --z-modal: 1050;
  --z-popover: 1060;
  --z-tooltip: 1070;

  /* === VIEWPORT MOBILE === */
  --app-height: 100vh;
}

/* Hauteur viewport dynamique : la barre d'URL mobile (iOS Safari,
   Android Chrome) ne doit pas masquer le bas de page ni sauter */
@supports (height: 100dvh) {
  :root { --app-height: 100dvh; }
}
@supports (height: 100svh) {
  :root { --app-height: 100svh; }
}

/* Pas de halo gris au tap (iOS) ; le feedback passe par :active */
body {
  -webkit-tap-highlight-color: transparent;
}

/* ============================================
   MODE SOMBRE — Charte BUESA (Noir Profond dominant)
   ============================================ */
[data-theme="dark"] {
  /* Noir Profond 45 %, surfaces Bleu Prusse */
  --sia-bg-deep: #080B12;
  --sia-bg-raised: #111723;
  --sia-bg-elevated: #1B2436;
  --sia-text-on-dark: #F7F7F7;
  --sia-muted: #9AA3B2;            /* Ardoise éclairci (dérivé, contraste) */
  --sia-border: rgba(154, 163, 178, 0.45);
  --sia-brand-hover: #6C8FE4;      /* Bleu SIA éclairci (dérivé, liens) */
  /* #173F9B n'atteint pas le contraste AA sur le Bleu Prusse : éclairci. */
  --sia-agent-blue: #5C86E8;
  --sia-agent-blue-hover: #7FA3F0;
  --sia-workspace-bg: #1a2030;
  --sia-chrome-bg: #080B12;
  --sia-pill-bg: #1B2436;

  --sia-primary: var(--sia-text-on-dark);
  --sia-secondary: var(--sia-bg-deep);
  --sia-accent: var(--sia-muted);

  --bg-primary: var(--sia-bg-deep);
  --bg-secondary: var(--sia-bg-raised);
  --text-primary: var(--sia-text-on-dark);
  --text-secondary: var(--sia-muted);
  --accent: var(--sia-brand);

  --color-night-blue: var(--sia-text-on-dark);
  --color-night-blue-light: var(--sia-muted);
  --color-sovereign-blue: #6C8FE4;
  --color-sovereign-blue-light: var(--sia-muted);

  --color-ivory: var(--sia-bg-raised);
  --color-ivory-dark: var(--sia-bg-deep);
  --color-ivory-light: var(--sia-bg-elevated);

  --color-stone-gray: var(--sia-muted);
  --color-stone-gray-dark: #7E8798;
  --color-stone-gray-light: var(--sia-text-on-dark);

  --color-silver: #1B2436;
  --color-silver-dark: var(--sia-bg-raised);
  --color-silver-light: #2A3550;

  --color-white: var(--sia-bg-deep);
  --color-white-off: var(--sia-bg-raised);

  /* Sémantique — palette charte, teintes dérivées pour le contraste nocturne */
  --color-success: #6C8FE4;
  --color-success-bg: #101A33;
  --color-success-border: #173F9B;
  --color-warning: #080B12;
  --color-warning-bg: #E3A8A6;
  --color-warning-border: #E3A8A6;
  --color-error: #F5635C;
  --color-error-bg: #2A0E10;
  --color-error-border: #E52827;
  --color-info: #9AA3B2;
  --color-info-bg: #111723;
  --color-info-border: #5C6575;

  --color-crypto: #6C8FE4;
  --color-crypto-bg: #101A33;
  --color-crypto-glow: #173F9B;

  --gradient-noble: var(--sia-bg-raised);
  --gradient-blue-depth: var(--sia-bg-deep);
  --gradient-hero: linear-gradient(135deg, #080B12 0%, #111723 55%, #173F9B 100%);

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 16px rgba(0, 0, 0, 0.45);
  --shadow-xl: 0 16px 32px rgba(0, 0, 0, 0.5);
  --shadow-2xl: 0 24px 48px rgba(0, 0, 0, 0.6);
  --shadow-accent: 0 4px 16px rgba(23, 63, 155, 0.25);
  --shadow-accent-lg: 0 8px 32px rgba(23, 63, 155, 0.3);
  --shadow-crypto: 0 0 20px rgba(23, 63, 155, 0.3);
}

/* Transition douce lors du changement de thème */
html.theme-transitioning,
html.theme-transitioning *,
html.theme-transitioning *::before,
html.theme-transitioning *::after {
  transition: background-color var(--theme-transition, 300ms) ease,
              color var(--theme-transition, 300ms) ease,
              border-color var(--theme-transition, 300ms) ease,
              box-shadow var(--theme-transition, 300ms) ease !important;
}

/* ============================================
   🔤 RÉINITIALISATION & BASE
   ============================================ */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 18px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
}

html[data-font-scale="small"] { font-size: 16px; }
html[data-font-scale="large"] { font-size: 20px; }

body {
  font-family: var(--font-sans);
  font-size: var(--typo-body);       /* Corps : Source Sans Regular 18–24px */
  font-weight: var(--font-normal);
  line-height: var(--leading-relaxed);
  color: var(--sia-text-on-light);
  background: var(--sia-bg-light);
}

/* Chat / app dense : le corps suit Petit/Normal/Grand (rem sur html) */
body.sia-chat-page,
body.sia-parametres-page,
body.sia-admin-page,
body.sia-coffre-page,
body.sia-coffre-fort-page,
body.sia-agents-page,
body.sia-corpus-page,
body.sia-blockchain-page,
body.sia-verification-popr-page,
body.org-profile-page,
body.sia-crm-page,
body.sia-quel-modele-page {
  font-size: 1rem;
}

[data-theme="dark"] body {
  color: var(--sia-text-on-dark);
  background: var(--sia-bg-deep);
}

/* ============================================
   📝 TYPOGRAPHIE — planche 05 BUESA (hierarchie recommandee)
   H1 / accroche     : Source Serif Pro Italic · 48–64px
   H2 / section      : Source Sans Pro Bold    · 32–40px
   Corps             : Source Sans Pro Regular · 18–24px
   H3 / mots cles    : Source Sans Pro Regular · 16–18px · uppercase
   Micro-texte       : Source Sans Pro         · 12–14px · italic
   (Kit livré : pas de Medium — micro en Italic Regular)
   ============================================ */
h1, h2, h3, h4, h5, h6 {
  line-height: var(--leading-tight);
  color: var(--sia-primary);
  margin-bottom: var(--space-4);
}

/* H1 / ACCROCHE */
h1 {
  font-size: var(--typo-h1);
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 400;
  letter-spacing: 0.02em;
}

/* H2 / SECTION */
h2 {
  font-size: var(--typo-h2);
  font-family: var(--font-sans);
  font-style: normal;
  font-weight: var(--font-bold);
  letter-spacing: 0.02em;
}

/* H3 / MOTS CLÉS */
h3 {
  font-size: var(--typo-keywords);
  font-family: var(--font-sans);
  font-style: normal;
  font-weight: var(--font-normal);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* Sous-niveaux UI (hors planche) — Sans Regular/Bold, jamais serif */
h4 {
  font-size: var(--typo-body);
  font-family: var(--font-sans);
  font-style: normal;
  font-weight: var(--font-bold);
  text-transform: none;
  letter-spacing: 0.01em;
}

h5, h6 {
  font-size: var(--typo-keywords);
  font-family: var(--font-sans);
  font-style: normal;
  font-weight: var(--font-normal);
  text-transform: none;
  letter-spacing: 0.01em;
}

/* CORPS */
p {
  margin-bottom: var(--space-4);
  font-family: var(--font-sans);
  font-style: normal;
  font-weight: var(--font-normal);
  font-size: var(--typo-body);
  line-height: var(--leading-relaxed);
}

small,
.sia-typo-micro {
  font-family: var(--font-sans);
  font-weight: var(--font-normal);
  font-size: var(--typo-micro);
  font-style: italic;
}

/* Utilitaires charte (forcer un niveau hors balise semantique) */
.sia-typo-h1 {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 400;
  font-size: var(--typo-h1);
  letter-spacing: 0.02em;
  text-transform: none;
}
.sia-typo-h2 {
  font-family: var(--font-sans);
  font-style: normal;
  font-weight: var(--font-bold);
  font-size: var(--typo-h2);
  letter-spacing: 0.02em;
  text-transform: none;
}
.sia-typo-body {
  font-family: var(--font-sans);
  font-style: normal;
  font-weight: var(--font-normal);
  font-size: var(--typo-body);
  text-transform: none;
}
.sia-typo-keywords {
  font-family: var(--font-sans);
  font-style: normal;
  font-weight: var(--font-normal);
  font-size: var(--typo-keywords);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* Titre de section app (quand un h3 ne doit PAS etre des mots cles) */
.sia-typo-section {
  font-family: var(--font-sans);
  font-style: normal;
  font-weight: var(--font-bold);
  font-size: var(--typo-h2);
  letter-spacing: 0.02em;
  text-transform: none;
}

/* App dense : h3 reste un sous-titre UI, pas des mots cles marketing */
.sia-chat-page h3,
.sia-admin-page h3,
.sia-parametres-page h3,
.sia-coffre-page h3,
.topnav ~ * h3.sia-ui-title,
h3.sia-ui-title {
  font-size: var(--text-xl);
  font-weight: var(--font-bold);
  letter-spacing: 0.01em;
  text-transform: none;
}

a {
  color: var(--sia-brand);
  text-decoration: none;
  transition: color var(--transition-fast);
  font-weight: var(--font-medium);
}

a:hover {
  color: var(--sia-brand-hover);
  text-decoration: underline;
}

/* Lien cryptographique */
a.crypto-link {
  color: var(--sia-accent);
  position: relative;
}

a.crypto-link::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--sia-accent);
  transition: width var(--transition-base);
}

a.crypto-link:hover::after {
  width: 100%;
}

/* Liens lisibles sur Noir Profond (Bleu SIA éclairci) */
[data-theme="dark"] a {
  color: var(--sia-brand-hover);
}

[data-theme="dark"] a:hover {
  color: #8FA8EE;
}

/* ============================================
   🔘 BOUTONS
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-6);
  font-size: var(--text-base);
  font-weight: var(--font-semibold);
  line-height: 1;
  border-radius: var(--radius-md);
  border: 2px solid transparent;
  cursor: pointer;
  transition: all var(--transition-base);
  text-decoration: none;
  white-space: nowrap;
  font-family: var(--font-sans);
}

.btn:hover {
  transform: translateY(-2px);
  text-decoration: none;
}

.btn:active {
  transform: translateY(0);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* Bouton primaire — Bleu SIA */
.btn-primary {
  background: var(--sia-brand);
  color: #FFFFFF;
  border-color: var(--sia-brand);
  box-shadow: 0 4px 12px rgba(23, 23, 107, 0.35);
}

.btn-primary:hover {
  box-shadow: var(--shadow-lg);
  background: var(--sia-brand-hover);
  border-color: var(--sia-brand-hover);
}

/* Bouton Secondaire - Ivoire bleuté */
.btn-secondary {
  background: var(--sia-secondary);
  color: var(--sia-primary);
  border-color: var(--sia-accent);
}

.btn-secondary:hover {
  background: var(--sia-accent);
  color: var(--sia-secondary);
  box-shadow: var(--shadow-md);
}

/* Bouton Ghost */
.btn-ghost {
  background: transparent;
  color: var(--sia-primary);
  border-color: var(--sia-primary);
}

.btn-ghost:hover {
  background: var(--sia-primary);
  color: var(--sia-secondary);
}

/* Bouton Crypto */
.btn-crypto {
  background: var(--sia-accent);
  color: var(--sia-secondary);
  border-color: var(--sia-accent);
  box-shadow: var(--shadow-crypto);
}

.btn-crypto:hover {
  box-shadow: var(--shadow-crypto);
  opacity: 0.9;
}

/* Tailles */
.btn-sm {
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
}

.btn-lg {
  padding: var(--space-4) var(--space-8);
  font-size: var(--text-lg);
}

/* Boutons — contraste renforcé en mode sombre */
[data-theme="dark"] .btn-primary {
  color: #FFFFFF;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

[data-theme="dark"] .btn-secondary {
  background: var(--sia-bg-elevated);
  color: var(--sia-text-on-dark);
  border-color: rgba(154, 163, 178, 0.55);
}

[data-theme="dark"] .btn-secondary:hover {
  background: rgba(154, 163, 178, 0.2);
  color: #FFFFFF;
  border-color: var(--sia-brand);
}

[data-theme="dark"] .btn-ghost {
  color: var(--sia-text-on-dark);
  border-color: rgba(154, 163, 178, 0.5);
}

[data-theme="dark"] .btn-ghost:hover {
  background: rgba(154, 163, 178, 0.15);
  color: #FFFFFF;
  border-color: var(--sia-brand);
}

[data-theme="dark"] .btn-crypto {
  color: var(--sia-bg-deep);
}

/* ============================================
   📦 CARDS
   ============================================ */
.card {
  background: var(--sia-secondary);
  border: 1px solid var(--sia-accent);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-base);
}

.card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--sia-primary);
  transform: translateY(-2px);
}

.card-header {
  margin-bottom: var(--space-6);
  padding-bottom: var(--space-4);
  border-bottom: 2px solid var(--color-ivory-dark);
}

.card-title {
  font-size: var(--text-2xl);
  font-weight: 600;
  margin-bottom: var(--space-2);
  color: inherit;
  font-family: var(--font-sans);
}

.card-body {
  margin-bottom: var(--space-4);
  color: var(--sia-primary);
}

.card-footer {
  margin-top: var(--space-6);
  padding-top: var(--space-4);
  border-top: 2px solid var(--color-ivory-dark);
}

/* Card Premium - Accent */
.card-premium {
  border-color: var(--sia-accent);
  background: var(--sia-secondary);
  position: relative;
  overflow: hidden;
}

.card-premium::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--sia-accent);
}

/* ============================================
   📝 FORMULAIRES
   ============================================ */
.form-group {
  margin-bottom: var(--space-6);
}

.form-label {
  display: block;
  margin-bottom: var(--space-2);
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  color: var(--color-night-blue);
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-base);
  font-family: var(--font-sans);
  color: var(--color-night-blue);
  background: var(--color-ivory);
  border: 2px solid var(--color-silver);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--sia-primary);
  box-shadow: 0 0 0 4px rgba(23, 63, 155, 0.12);
  background: var(--sia-secondary);
}

.form-textarea {
  min-height: 120px;
  resize: vertical;
}

.form-help {
  display: block;
  margin-top: var(--space-2);
  font-size: var(--text-sm);
  color: var(--color-stone-gray);
}

.form-error {
  display: block;
  margin-top: var(--space-2);
  font-size: var(--text-sm);
  color: var(--color-error);
}

/* ============================================
   🏷️ BADGES
   ============================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  border-radius: var(--radius-full);
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge-premium {
  background: var(--sia-accent);
  color: var(--sia-secondary);
}

.badge-crypto {
  background: var(--sia-accent);
  color: var(--sia-secondary);
}

.badge-success {
  background: var(--color-success-bg);
  color: var(--color-success);
}

.badge-warning {
  background: var(--color-warning-bg);
  color: var(--color-warning);
}

.badge-error {
  background: var(--color-error-bg);
  color: var(--color-error);
}

/* ============================================
   📊 ALERTS
   ============================================ */
.alert {
  padding: var(--space-4);
  border-radius: var(--radius-lg);
  border: 2px solid;
  margin-bottom: var(--space-4);
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
}

.alert-icon {
  font-size: var(--text-xl);
  flex-shrink: 0;
}

.alert-success {
  background: var(--color-success-bg);
  border-color: var(--color-success);
  color: var(--color-success);
}

.alert-warning {
  background: var(--color-warning-bg);
  border-color: var(--color-warning);
  color: var(--color-warning);
}

.alert-error {
  background: var(--color-error-bg);
  border-color: var(--color-error);
  color: var(--color-error);
}

.alert-info {
  background: var(--color-info-bg);
  border-color: var(--color-info);
  color: var(--color-info);
}

/* Pop-up « page en cours d'amélioration » (corpus) */
.sia-page-improvement-popup {
  position: fixed;
  inset: 0;
  z-index: 10050;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.sia-page-improvement-popup.is-visible {
  opacity: 1;
  pointer-events: auto;
}
.sia-page-improvement-popup.is-closing {
  opacity: 0;
  pointer-events: none;
}
.sia-page-improvement-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 11, 18, 0.6);
  cursor: pointer;
}
.sia-page-improvement-card {
  position: relative;
  max-width: 420px;
  width: 100%;
  padding: var(--space-6) var(--space-5);
  border-radius: var(--radius-xl, 12px);
  background: var(--color-warning-bg);
  border: 2px solid var(--color-warning-border);
  box-shadow: var(--shadow-xl, 0 16px 32px rgba(0, 0, 0, 0.2));
  text-align: center;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.sia-page-improvement-popup.is-visible .sia-page-improvement-card {
  animation: siaImprovementPopIn 0.25s ease-out;
}
.sia-page-improvement-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-2xl, 0 24px 48px rgba(0, 0, 0, 0.25));
}
.sia-page-improvement-icon {
  display: block;
  font-size: 2rem;
  line-height: 1;
  margin-bottom: var(--space-3);
}
.sia-page-improvement-title {
  margin: 0 0 var(--space-2);
  font-size: var(--text-lg, 1.125rem);
  font-weight: 700;
  color: var(--sia-text-on-light, #17176B);
}
.sia-page-improvement-text {
  margin: 0 0 var(--space-4);
  font-size: var(--text-sm, 0.875rem);
  line-height: 1.5;
  color: var(--color-stone-gray, #5C6575);
}
.sia-page-improvement-dismiss {
  margin: 0;
  font-size: var(--text-xs, 0.75rem);
  font-weight: 600;
  color: var(--color-warning-border);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
@keyframes siaImprovementPopIn {
  from {
    opacity: 0;
    transform: scale(0.94) translateY(8px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}
[data-theme="dark"] .sia-page-improvement-title {
  color: var(--text-primary);
}
[data-theme="dark"] .sia-page-improvement-text {
  color: var(--text-secondary);
}

/* ============================================
   📐 LAYOUT & CONTAINERS
   ============================================ */
.container {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 var(--space-4);
}

.container-sm { max-width: 640px; }
.container-md { max-width: 768px; }
.container-lg { max-width: 1024px; }
.container-xl { max-width: 1280px; }
.container-2xl { max-width: 1536px; }

.section {
  padding: var(--space-16) 0;
}

.section-tight {
  padding: var(--space-8) 0;
}

/* ============================================
   🎨 UTILITIES
   ============================================ */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.text-night { color: var(--sia-primary); }
.text-accent { color: var(--sia-accent); }
.text-crypto { color: var(--sia-accent); }
.text-muted { color: var(--sia-accent); }

.bg-primary { background: var(--sia-primary); }
.bg-secondary { background: var(--sia-secondary); }
.bg-accent { background: var(--sia-accent); }

.font-serif { font-family: var(--font-serif); }
.font-sans { font-family: var(--font-sans); }
.font-mono { font-family: var(--font-mono); }

.font-bold { font-weight: var(--font-bold); }
.font-semibold { font-weight: var(--font-semibold); }
.font-medium { font-weight: var(--font-medium); }
.font-normal { font-weight: var(--font-normal); }

/* ============================================
   📱 RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
  h1 { font-size: 48px; }              /* bas de fourchette H1 */
  h2 { font-size: 32px; }              /* bas de fourchette H2 */
  h3 { font-size: 16px; }              /* bas de fourchette mots cles */
  p, body { font-size: 18px; }         /* bas de fourchette corps */

  .section { padding: var(--space-8) 0; }

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

  .btn {
    width: 100%;
    min-height: 48px; /* Zone tactile Android 48dp (compatible Apple 44pt) */
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* Cibles tactiles 48dp + espacement anti mis-tap */
  .tab,
  .icon-btn,
  [role="button"] {
    min-height: 48px;
    min-width: 48px;
  }

  /* Pas de double-tap zoom sur les zones interactives */
  .btn,
  .tab,
  .icon-btn,
  [role="button"],
  a {
    touch-action: manipulation;
  }
}

@media (max-width: 1023px) {
  html,
  body {
    overflow-x: hidden; /* fallback navigateurs sans support de clip */
    overflow-x: clip;
    max-width: 100vw;
  }

  /* Topnav : réserve toujours la status bar.
     Exception chat mobile : topnav collapse (hauteur 0) — la safe-area
     est alors portée par .chat-header-mobile / panneaux (voir navigation.css). */
  body:not(.sia-chat-page) > .topnav {
    padding-top: var(--sia-safe-top);
  }

  /* Utilitaires : ancrage sous la safe-area / sous le chrome */
  .sia-inset-safe-top {
    padding-top: var(--sia-safe-top);
  }

  .sia-fixed-below-safe-top {
    top: var(--sia-safe-top) !important;
  }

  .sia-fixed-below-chrome {
    top: var(--sia-chrome-top) !important;
  }

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

  table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Anti-zoom iOS : Safari zoome au focus si la police < 16px */
  input,
  textarea,
  select {
    font-size: 16px;
  }

  /* Cadre workspace : le padding desktop (16+20) + un enfant nowrap
     (onglets, pastilles) élargissait la page au-delà du viewport. */
  .sia-app-shell {
    padding: 8px;
    padding-left: max(8px, env(safe-area-inset-left, 0px));
    padding-right: max(8px, env(safe-area-inset-right, 0px));
    max-width: 100%;
    min-width: 0;
    overflow-x: hidden;
    box-sizing: border-box;
  }

  .sia-workspace-card {
    padding: 10px 10px 20px;
    max-width: 100%;
    min-width: 0;
    overflow-x: hidden;
    box-sizing: border-box;
    border-radius: 12px;
  }

  .sia-workspace-card,
  .sia-workspace-card p,
  .sia-workspace-card h1,
  .sia-workspace-card h2,
  .sia-workspace-card h3,
  .sia-workspace-card li {
    overflow-wrap: break-word;
  }
}

/* ============================================
   ✨ ANIMATIONS
   ============================================ */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes accentPulse {
  0%, 100% {
    box-shadow: var(--shadow-accent);
  }
  50% {
    box-shadow: var(--shadow-accent-lg);
  }
}

@keyframes cryptoGlow {
  0%, 100% {
    filter: drop-shadow(0 0 5px rgba(23, 63, 155, 0.5));
  }
  50% {
    filter: drop-shadow(0 0 20px rgba(23, 63, 155, 0.8));
  }
}

.animate-fade-in { animation: fadeIn 0.5s ease-out; }
.animate-slide-up { animation: slideUp 0.5s ease-out; }
.animate-accent-pulse { animation: accentPulse 2s ease-in-out infinite; }
.animate-crypto-glow { animation: cryptoGlow 2s ease-in-out infinite; }

/* ============================================
   🏛️ MARQUEUR NOTARIAL
   ============================================ */
.notarial-accent {
  position: relative;
}

.notarial-accent::before {
  content: '';
  position: absolute;
  left: -1rem;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--sia-accent);
  border-radius: var(--radius-full);
}

/* ============================================
   🔒 SÉCURITÉ CRYPTOGRAPHIQUE
   ============================================ */
.crypto-seal {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  background: var(--color-crypto-bg);
  border: 2px solid var(--color-crypto);
  border-radius: var(--radius-full);
  color: var(--color-crypto);
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  font-family: var(--font-mono);
}

/* ============================================
   🌳 ARBRE DE LA CONFIANCE
   ============================================ */
.trust-tree {
  display: inline-block;
  width: 60px;
  height: 60px;
  background: var(--sia-accent);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-crypto);
}

.trust-tree-icon {
  width: 40px;
  height: 40px;
  color: var(--color-white);
}

/* ============================================
   CHROME APP — cadre workspace (référence chat)
   ============================================ */
.sia-app-shell {
  padding: 16px;
  background: var(--sia-chrome-bg, #FFFFFF);
  min-height: calc(100vh - var(--sia-chrome-top, 52px));
  box-sizing: border-box;
}

.sia-workspace-card {
  background: var(--sia-workspace-bg, #E4EAF4);
  border-radius: 16px;
  padding: 16px 20px 24px;
  min-height: calc(100vh - var(--sia-chrome-top, 52px) - 32px);
  box-sizing: border-box;
}

body.sia-agents-page,
body.sia-coffre-fort-page,
body.sia-parametres-page,
body.sia-corpus-page,
body.sia-blockchain-page,
body.sia-verification-popr-page,
body.org-profile-page,
body.sia-crm-page,
body.sia-admin-page,
body.sia-quel-modele-page {
  background: var(--sia-chrome-bg, #FFFFFF);
}

body.sia-admin-page > .container {
  background: var(--sia-workspace-bg, #E4EAF4);
  border-radius: 16px;
  margin: 16px;
  padding: 16px 20px 24px;
  box-sizing: border-box;
  min-height: calc(100vh - var(--sia-chrome-top, 52px) - 32px);
}

