/* Charte UI/UX Nixxis (Charte-UI-UX-portable.md v1.0) appliquée aux pages du serveur (connexion, accueil,
   administration, données), propre à IVR Studio. Chargée après hosted.css. Apparence par défaut ; « Classique »
   (data-ui="classique" sur <html>, réglage mémorisé ivrb-ui, menu du compte) garde l'apparence d'avant : valeurs de
   hosted.css et replis de ses variables (var(--fs-13, 13px)…), rien d'ici ne s'y applique.
   Trois niveaux (§ 2.1) : primitives --x-*, sémantiques --color-* …, puis les variables de hosted.css (--accent, --bg,
   --card…) construites sur les sémantiques. Même jeu de valeurs que packages/canvas/src/charte.css (éditeur). */

/* Police embarquée (§ 4.1) : Inter Variable (SIL OFL 1.1, fonts/Inter-OFL.txt), servie par le serveur, sans CDN ;
   latin + latin étendu (turc, langues d'Europe centrale). Déclarée dans le document : l'éditeur (racine fantôme) en
   profite aussi. Repli : Segoe UI Variable, Segoe UI, system-ui. */
@font-face { font-family: "Inter Variable"; font-style: normal; font-weight: 100 900; font-display: swap; src: url("/static/fonts/inter-latin-wght-normal.woff2") format("woff2-variations");
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: "Inter Variable"; font-style: normal; font-weight: 100 900; font-display: swap; src: url("/static/fonts/inter-latin-ext-wght-normal.woff2") format("woff2-variations");
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF; }

/* ===== 1. PRIMITIVES ===== */
:root:not([data-ui="classique"]) {
  --x-slate-0:#fff; --x-slate-25:#f7f8fa; --x-slate-50:#f3f5f8; --x-slate-100:#eef1f5;
  --x-slate-200:#d9dee6; --x-slate-400:#7d8799; /* charte : #8a94a6, assombri pour 3:1 aussi sur les surfaces grisées (contrastes.mjs) */ --x-slate-500:#5d687b; --x-slate-600:#4f5a6d;
  --x-slate-750:#323b4b; --x-slate-850:#232b39; --x-slate-875:#1c2330; --x-slate-900:#161c26;
  --x-slate-950:#0f141c; --x-slate-ink:#1a2130;
  --x-green-50:#e3f4ea; --x-green-600:#177a40; /* charte : #1a7f45, assombri pour 4,5:1 sur la surface neutre */ --x-green-800:#11592f;
  --x-amber-50:#fdf0d5; --x-amber-600:#b26b00; --x-amber-700:#8a5a00; --x-amber-800:#6b4100;
  --x-red-50:#fce8e8; --x-red-600:#c62828; --x-red-700:#a31f1f; --x-red-800:#8e1b1b;
  --x-violet-50:#f1ebfb; --x-violet-600:#6d3fc0; --x-violet-800:#4b2a87;
  --x-font-sans:"Inter Variable","Inter","Segoe UI Variable Text","Segoe UI",system-ui,sans-serif;
  --x-accent-50:#eef6fc; --x-accent-100:#e1eefa; --x-accent-600:#0b66a8; --x-accent-700:#0a5288; --x-accent-800:#0a3f68;
  --x-accent-d-fg:#5aaef0; --x-accent-d-hover:#7cc0f4; --x-accent-d-on:#04223a; --x-accent-d-container:#14304a; --x-accent-d-link:#6cb6f2;
}
/* Accents proposés (2026-11-19, Nicolas) : palettes précalculées (§ 3.1), teinte foncée pour le texte et les boutons,
   teinte pâle pour les fonds ; jaune pastel et vert amande : la couleur pure est trop claire pour du texte (≈ 1,3:1),
   l'ocre et l'olive dérivés la portent. Statuts jamais tirés de l'accent. Vérifiés par scripts/contrastes.mjs. */
:root:not([data-ui="classique"])[data-accent="marine"] {
  --x-accent-50:#eef2f8; --x-accent-100:#dfe6f1; --x-accent-600:#1f3a68; --x-accent-700:#182e54; --x-accent-800:#122340;
  --x-accent-d-fg:#8fb0e6; --x-accent-d-hover:#a9c3ee; --x-accent-d-on:#0a1830; --x-accent-d-container:#1a2a45; --x-accent-d-link:#9dbbec;
}
:root:not([data-ui="classique"])[data-accent="chocolat"] {
  --x-accent-50:#f8f1ec; --x-accent-100:#efe2d8; --x-accent-600:#6b4226; --x-accent-700:#56351f; --x-accent-800:#432918;
  --x-accent-d-fg:#d4a27f; --x-accent-d-hover:#e0b799; --x-accent-d-on:#2a170b; --x-accent-d-container:#3a281d; --x-accent-d-link:#dcae8d;
}
:root:not([data-ui="classique"])[data-accent="anthracite"] {
  --x-accent-50:#f2f3f4; --x-accent-100:#e4e6e8; --x-accent-600:#3d4247; --x-accent-700:#303438; --x-accent-800:#24272a;
  --x-accent-d-fg:#b8bfc6; --x-accent-d-hover:#ccd2d8; --x-accent-d-on:#16191c; --x-accent-d-container:#2c3136; --x-accent-d-link:#c4cbd2;
}
:root:not([data-ui="classique"])[data-accent="jaune"] {
  --x-accent-50:#fdf9e6; --x-accent-100:#faf1c4; --x-accent-600:#7a5f00; --x-accent-700:#644e00; --x-accent-800:#4d3c00;
  --x-accent-d-fg:#f2d86a; --x-accent-d-hover:#f6e28e; --x-accent-d-on:#2b2100; --x-accent-d-container:#3a3214; --x-accent-d-link:#f4dd7a;
}
:root:not([data-ui="classique"])[data-accent="amande"] {
  --x-accent-50:#f3f8ea; --x-accent-100:#e5f0d2; --x-accent-600:#4a6b1e; --x-accent-700:#3c5718; --x-accent-800:#2f4413;
  --x-accent-d-fg:#b5d68a; --x-accent-d-hover:#c6e0a3; --x-accent-d-on:#182409; --x-accent-d-container:#26331a; --x-accent-d-link:#bfdc97;
}
:root:not([data-ui="classique"])[data-accent="cuivre"] {
  --x-accent-50:#eaf6f5; --x-accent-100:#d3ecea; --x-accent-600:#1f6f6a; --x-accent-700:#185955; --x-accent-800:#134643;
  --x-accent-d-fg:#5fc4be; --x-accent-d-hover:#80d1cc; --x-accent-d-on:#062624; --x-accent-d-container:#143634; --x-accent-d-link:#6fcbc5;
}

/* ===== 2. SÉMANTIQUES : clair ===== */
:root:not([data-ui="classique"]) {
  --color-bg:var(--x-slate-50); --color-surface:var(--x-slate-0); --color-surface-sunken:var(--x-slate-25);
  --color-surface-muted:var(--x-slate-100); --color-surface-selected:var(--x-accent-100);
  --color-surface-hover:rgba(26,33,48,.05); --color-scrim:rgba(15,20,28,.45);
  --color-border:var(--x-slate-200); --color-border-strong:var(--x-slate-400);
  --color-text:var(--x-slate-ink); --color-text-secondary:var(--x-slate-600); --color-text-tertiary:var(--x-slate-500);
  --color-text-disabled:var(--x-slate-400);
  --color-primary:var(--x-accent-600); --color-primary-hover:var(--x-accent-700); --color-on-primary:#fff;
  --color-primary-container:var(--x-accent-100); --color-on-primary-container:var(--x-accent-800);
  --color-link:var(--x-accent-600); --color-focus-ring:var(--x-accent-600);
  --color-success:var(--x-green-600); --color-success-container:var(--x-green-50); --color-on-success-container:var(--x-green-800);
  --color-warning:var(--x-amber-700); --color-warning-graphic:var(--x-amber-600);
  --color-warning-container:var(--x-amber-50); --color-on-warning-container:var(--x-amber-800);
  --color-danger:var(--x-red-600); --color-danger-hover:var(--x-red-700); --color-on-danger:#fff;
  --color-danger-container:var(--x-red-50); --color-on-danger-container:var(--x-red-800);
  --color-info:var(--x-violet-600); --color-info-container:var(--x-violet-50); --color-on-info-container:var(--x-violet-800);
  --elevation-1:0 1px 2px rgba(16,24,40,.06),0 1px 3px rgba(16,24,40,.08);
  --elevation-2:0 4px 8px -2px rgba(16,24,40,.10),0 2px 4px -2px rgba(16,24,40,.06);
  --elevation-3:0 20px 24px -4px rgba(16,24,40,.14),0 8px 8px -4px rgba(16,24,40,.06);
  color-scheme: light;
}
/* ===== 2. SÉMANTIQUES : sombre ===== */
:root:not([data-ui="classique"])[data-theme="dark"] {
  --color-bg:var(--x-slate-950); --color-surface:var(--x-slate-900); --color-surface-sunken:var(--x-slate-875);
  --color-surface-muted:var(--x-slate-850); --color-surface-selected:var(--x-accent-d-container);
  --color-surface-hover:rgba(232,236,242,.06); --color-scrim:rgba(0,0,0,.6);
  --color-border:var(--x-slate-750); --color-border-strong:#6b778c;
  --color-text:#e8ecf2; --color-text-secondary:#b4bdcb; --color-text-tertiary:#97a2b3; --color-text-disabled:#5f6b80;
  --color-primary:var(--x-accent-d-fg); --color-primary-hover:var(--x-accent-d-hover); --color-on-primary:var(--x-accent-d-on);
  --color-primary-container:var(--x-accent-d-container); --color-on-primary-container:#d6e9fa;
  --color-link:var(--x-accent-d-link); --color-focus-ring:var(--x-accent-d-link);
  --color-success:#5cc98a; --color-success-container:#12301f; --color-on-success-container:#b6ebcb;
  --color-warning:#f0b445; --color-warning-graphic:#f0b445;
  --color-warning-container:#352708; --color-on-warning-container:#f8dca4;
  --color-danger:#ff8a80; --color-danger-hover:#ffa59d; --color-on-danger:#2a0b0b;
  --color-danger-container:#3d1717; --color-on-danger-container:#ffc2bc;
  --color-info:#b9a1f0; --color-info-container:#2a1f45; --color-on-info-container:#ddd0fa;
  --elevation-1:0 1px 2px rgba(0,0,0,.40); --elevation-2:0 6px 16px -4px rgba(0,0,0,.55); --elevation-3:0 24px 40px -8px rgba(0,0,0,.70);
  color-scheme: dark;
}

/* Indépendant du thème (§ 4) */
:root:not([data-ui="classique"]) {
  --font-sans:var(--x-font-sans);
  --text-xs:12px; --text-sm:14px; --text-md:16px; --text-lg:20px; --text-xl:24px; --text-2xl:32px;
  --weight-regular:400; --weight-medium:500; --weight-semibold:600;
  --space-1:4px; --space-2:8px; --space-3:12px; --space-4:16px; --space-5:20px; --space-6:24px; --space-8:32px;
  --radius-sm:4px; --radius-md:8px; --radius-lg:12px; --radius-full:999px;
  --duration-fast:120ms; --focus-ring-width:2px; --focus-ring-offset:2px;
  --density-control-h:36px; --density-topbar-h:56px; --density-pad-x:16px;
}
:root:not([data-ui="classique"])[data-density="compact"] { --density-control-h:32px; --density-topbar-h:48px; --density-pad-x:12px; }
@media (pointer: coarse) { :root:not([data-ui="classique"]) { --density-control-h:44px; } }

/* ===== 3. VARIABLES DES PAGES (niveau composant), sur les sémantiques ===== */
:root:not([data-ui="classique"]) {
  --accent: var(--color-primary); --accent-fg: var(--color-on-primary); --accent-soft: var(--color-primary-container);
  --bg: var(--color-surface); --surface: var(--color-bg); --surface-2: var(--color-surface-muted); --card: var(--color-surface);
  --fg: var(--color-text); --muted: var(--color-text-secondary); --border: var(--color-border);
  --ok: var(--color-success); --ok-soft: var(--color-success-container);
  --warn: var(--color-warning); --warn-soft: var(--color-warning-container);
  --danger: var(--color-danger); --danger-soft: var(--color-danger-container);
  --info: var(--color-info); --info-soft: var(--color-info-container); --idle: var(--color-text-tertiary);
  --warn-bg: var(--color-warning-container); --warn-fg: var(--color-on-warning-container);
  --on-solid: var(--color-on-danger);
  --radius: var(--radius-md); --radius-card: var(--radius-lg); --shadow-card: none;
  --fs-11: var(--text-xs); --fs-11h: var(--text-xs); --fs-12: var(--text-xs); --fs-12h: var(--text-xs);
  --fs-13: var(--text-sm); --fs-14: var(--text-sm); --fs-14h: var(--text-sm); --fs-15: var(--text-md); --fs-16: var(--text-md);
  --fs-20: var(--text-lg); --fs-22: var(--text-xl); --fs-24: var(--text-xl);
  --fw-strong: var(--weight-semibold);
  --caps: none; /* majuscule au premier mot seulement (§ 9.1) */
  --r-6: var(--radius-md); --r-8: var(--radius-md); --r-9: var(--radius-lg); --r-10: var(--radius-lg); --r-999: var(--radius-full);
  --u-4: var(--space-1); --u-6: var(--space-2); --u-8: var(--space-2); --u-10: var(--space-3); --u-12: var(--space-3);
}
:root:not([data-ui="classique"]) body { font: var(--weight-regular) var(--text-sm)/20px var(--font-sans); background: var(--color-bg); }

/* Boutons (§ 5.1) : hauteur unique, rayon 8 px, trait ≥ 3:1, primaire pleine, danger en texte rouge */
:root:not([data-ui="classique"]) button { min-height: 24px; border-radius: var(--radius-md); border-color: var(--color-border-strong); transition: background var(--duration-fast), border-color var(--duration-fast); }
:root:not([data-ui="classique"]) :is(.actions-row, .card-head, .row, form, .center .card) > button:not(.link),
:root:not([data-ui="classique"]) button.primary { min-height: var(--density-control-h); padding: 0 var(--density-pad-x); }
:root:not([data-ui="classique"]) button:hover:not(:disabled) { border-color: var(--color-primary); }
:root:not([data-ui="classique"]) button.primary:hover:not(:disabled) { background: var(--color-primary-hover); border-color: var(--color-primary-hover); }
:root:not([data-ui="classique"]) button.danger { border-color: transparent; background: none; }
:root:not([data-ui="classique"]) button.link { min-height: 0; color: var(--color-link); }
:root:not([data-ui="classique"]) button:disabled { opacity: 1; color: var(--color-text-disabled); background: var(--color-surface-muted); border-color: var(--color-border); }
:root:not([data-ui="classique"]) :focus-visible { outline: var(--focus-ring-width) solid var(--color-focus-ring); outline-offset: var(--focus-ring-offset); }

/* Champs (§ 5.2) : libellé au-dessus 12 px semi-gras, trait ≥ 3:1, rayon 8 px */
:root:not([data-ui="classique"]) :is(input:not([type=checkbox]):not([type=radio]), select) { min-height: var(--density-control-h); border-color: var(--color-border-strong); border-radius: var(--radius-md); background: var(--color-surface); }
:root:not([data-ui="classique"]) textarea { border-color: var(--color-border-strong); border-radius: var(--radius-md); background: var(--color-surface); }
:root:not([data-ui="classique"]) :is(input, select, textarea):focus { border-color: var(--color-primary); }
:root:not([data-ui="classique"]) label:not(.check) { font-size: var(--text-xs); font-weight: var(--weight-semibold); color: var(--color-text-secondary); }
:root:not([data-ui="classique"]) label:not(.check) > :is(input, select, textarea) { font-size: var(--text-sm); font-weight: var(--weight-regular); color: var(--color-text); }
:root:not([data-ui="classique"]) [aria-invalid="true"] { border-color: var(--color-danger); }

/* Barre du haut commune (§ 6) : 56 px (48 en compact), sur la surface, suit le thème */
:root:not([data-ui="classique"]) .topbar { height: var(--density-topbar-h); background: var(--color-surface); border-bottom-color: var(--color-border); }
:root:not([data-ui="classique"]) .brand { font-weight: var(--weight-semibold); }
:root:not([data-ui="classique"]) .version { border-radius: var(--radius-full); }

/* Cartes (§ 5.6) : surface, trait décoratif, rayon 12 px, pas d'ombre */
:root:not([data-ui="classique"]) .card { border-radius: var(--radius-lg); box-shadow: none; }
:root:not([data-ui="classique"]) .center .card { box-shadow: var(--elevation-1); }

/* Info-bulle d'identifiant : surface inversée sur jetons (au lieu de couleurs en dur) */
:root:not([data-ui="classique"]) .id-toast { background: var(--color-text); color: var(--color-surface); box-shadow: var(--elevation-2); }

/* Animations ≤ 200 ms, coupées par prefers-reduced-motion (§ 7.8) */
@media (prefers-reduced-motion: reduce) {
  :root:not([data-ui="classique"]) *, :root:not([data-ui="classique"]) *::before, :root:not([data-ui="classique"]) *::after { animation: none !important; transition: none !important; }
}

/* Tableaux (§ 5.4) : en-tête collant sur la surface en retrait, lignes à la hauteur de densité. */
:root:not([data-ui="classique"]) thead th { position: sticky; top: 0; z-index: 1; background: var(--color-surface-sunken); }
:root:not([data-ui="classique"]) tbody td { height: var(--density-control-h); }

/* Listes de choix (§ 5.3, common.js) : boutons segmentés et liste avec recherche à la place des <select> concernés. */
.choice-seg { display: inline-flex; flex-wrap: nowrap; max-width: 100%; border: 1px solid var(--color-border-strong); border-radius: var(--radius-md); overflow: hidden; align-self: flex-start; }
.choice-seg button { border: 0; border-left: 1px solid var(--color-border-strong); border-radius: 0; min-height: var(--density-control-h); padding: 0 var(--space-3);
  background: var(--color-surface); color: var(--color-text-secondary); font-weight: var(--weight-medium); white-space: nowrap; font-size: var(--text-sm); }
.choice-seg button:first-child { border-left: 0; }
.choice-seg button.on { background: var(--color-primary-container); color: var(--color-on-primary-container); font-weight: var(--weight-semibold); }
.choice-seg button:hover:not(:disabled):not(.on) { background: var(--color-surface-hover); }
.choice-seg button:focus-visible { outline-offset: -3px; }
.choice-search { position: relative; }
.choice-search input { width: 100%; }
.choice-search [role="listbox"] { position: absolute; z-index: 60; left: 0; right: 0; top: calc(100% + 2px); max-height: 280px; overflow: auto; margin: 0; padding: var(--space-1);
  list-style: none; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md); box-shadow: var(--elevation-2); }
.choice-search [role="option"] { padding: var(--space-1) var(--space-2); border-radius: var(--radius-sm); cursor: pointer; min-height: 28px; font-size: var(--text-sm); color: var(--color-text); font-weight: var(--weight-regular); }
.choice-search [role="option"].active { background: var(--color-surface-hover); }
.choice-search [role="option"][aria-selected="true"] { font-weight: var(--weight-semibold); }
.choice-empty { padding: var(--space-2); color: var(--color-text-secondary); font-weight: var(--weight-regular); }
/* Libellé étroit prévu pour une liste native : élargi à la mesure des boutons segmentés (libellés jamais coupés). */
:root:not([data-ui="classique"]) label:has(> .choice-seg) { width: auto; max-width: none; flex: none; }

/* Tri des tableaux (§ 5.4) : bouton dans l'en-tête, flèches tertiaires, colonne triée en primaire. */
:root:not([data-ui="classique"]) .th-sort { display: inline-flex; align-items: center; gap: var(--space-1); min-height: 24px; padding: 0; border: 0; background: none;
  font: inherit; color: inherit; text-transform: inherit; letter-spacing: inherit; cursor: pointer; }
:root:not([data-ui="classique"]) th.num .th-sort { flex-direction: row-reverse; }
:root:not([data-ui="classique"]) .th-sort .sort-icon { width: 14px; height: 14px; color: var(--color-text-tertiary); }
:root:not([data-ui="classique"]) th[aria-sort="ascending"] .th-sort, :root:not([data-ui="classique"]) th[aria-sort="descending"] .th-sort { color: var(--color-primary); }
:root:not([data-ui="classique"]) th[aria-sort="ascending"] .sort-icon path:first-child, :root:not([data-ui="classique"]) th[aria-sort="descending"] .sort-icon path:last-child { opacity: .25; }
