/* app.serpas.fr — interface reprise À L'IDENTIQUE de LAB Manager (src/app/globals.css de lab-manager, 28/11/2026),
   à la demande d'Oos. Seuls ajouts : la remise à zéro de base (Tailwind la fournissait à LAB), les polices
   (next/font les fournissait), et en fin de fichier quelques éléments propres aux factures. */
@font-face{font-family:"Inter";src:url(/fonts/inter-latin-wght-normal.woff2) format("woff2");font-weight:100 900;font-display:swap}
@font-face{font-family:"Space Grotesk";src:url(/fonts/space-grotesk-latin-wght-normal.woff2) format("woff2");font-weight:300 700;font-display:swap}
@font-face{font-family:"IBM Plex Sans";src:url(/fonts/ibm-plex-sans-latin-400-normal.woff2) format("woff2");font-weight:400;font-display:swap}
@font-face{font-family:"IBM Plex Sans";src:url(/fonts/ibm-plex-sans-latin-600-normal.woff2) format("woff2");font-weight:500 700;font-display:swap}
:root{--font-inter:"Inter";--font-grotesk:"Space Grotesk";--font-plex:"IBM Plex Sans"}
/* Remise à zéro (équivalent du « preflight » de Tailwind utilisé par LAB) */
*,::before,::after{box-sizing:border-box;border:0 solid;margin:0;padding:0}
html{-webkit-text-size-adjust:100%;tab-size:4}
ol,ul,menu{list-style:none}
img,svg,video,iframe{display:block;vertical-align:middle}
button,input,select,optgroup,textarea{font:inherit;color:inherit;letter-spacing:inherit;background:transparent}
button,[role=button]{cursor:pointer}
table{text-indent:0;border-color:inherit;border-collapse:collapse}
summary{display:list-item}


/* ═══════════════════ Système visuel LAB Manager ═══════════════════
   Tous les composants n'utilisent QUE ces variables et les classes ci-dessous (jamais de couleur en dur).

   Styles (data-theme sur <html>, enum Prisma Theme, liste dans src/lib/themes.ts) :
   CABINET   bleu marine et ivoire, sobre (défaut des nouveaux comptes)
   ARDOISE   gris neutre, accent vert sapin, texte un peu plus grand
   CONTRASTE contraste élevé : noir sur blanc, contours marqués (accessibilité, AA+ partout)
   NUIT      sombre doux
   A classique · B clair minimal (navigation en haut) · C sombre compact (styles historiques)

   1. Jetons de structure (échelle typographique, espacements, densité) – communs.
   2. Jetons de couleur – un bloc par style.
   3. Composants. */

/* ── 1. Structure ── */
:root {
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px; --space-5: 20px; --space-6: 24px; --space-8: 32px;
  --fs-xs: 12px;   /* étiquettes, en-têtes de colonnes, pastilles */
  --fs-sm: 13px;   /* texte secondaire */
  --fs: 14px;      /* texte courant */
  --fs-md: 15px;   /* titres de carte */
  --fs-lg: 18px;
  --h1: clamp(21px, 1rem + 0.55vw, 27px); /* typographie fluide : plus grand sur grand écran */
  --lh: 1.45;
  --radius: 10px;
  --radius-sm: 8px;
  --radius-pill: 6px;
  --pad: clamp(16px, 0.6rem + 0.6vw, 24px);  /* marge intérieure des cartes (fluide : 17 px à 1280, 24 px à 2560) */
  --gap: clamp(12px, 0.5rem + 0.5vw, 20px);  /* espacement entre blocs */
  --cell-y: 9px;         /* densité des tableaux */
  --cell-x: clamp(8px, 0.15rem + 0.45vw, 16px); /* plus serré sur portable, plus aéré sur grand écran */
  --control-h: 40px;     /* boutons et champs sur ordinateur (souris) */
  --tap: 44px;           /* cibles tactiles (téléphone, tablette) */
  --nav-w: clamp(224px, 200px + 2vw, 260px); /* menu latéral déployé */
  --nav-rail-w: 72px;    /* menu latéral réduit (icônes seules) */
  /* Largeurs de contenu (voir « Largeurs d'écran » plus bas) */
  --content-max: 1880px; /* conteneur principal : listes, tableaux, tableaux de bord */
  --form-max: 920px;     /* formulaires : jamais étirés sur toute la largeur */
  --measure: 88ch;       /* longueur de ligne des textes */
  --shell-pad-x: clamp(16px, 0.25rem + 1.9vw, 56px);
  --shell-pad-y: clamp(18px, 0.6rem + 0.9vw, 36px);
  --tabbar-h: 60px;
  --focus-w: 2px;
  --font-body: var(--font-inter), system-ui, sans-serif;
  --font-head: var(--font-inter), system-ui, sans-serif;
  --font-brand: Georgia, "Times New Roman", serif;
  --th-transform: none;
  --link-decoration: none;
}

/* ── 2. Couleurs ── */
:root, [data-theme="CABINET"] {
  --bg: #F6F3EC;
  --surface: #FFFFFF;
  --surface-2: #FAF8F3;
  --border: #DFD8C8;
  --border-soft: #ECE7DB;
  --row-hover: #FBF9F4;
  --text: #1A2233;
  --muted: #565D6C;
  --accent: #1F3F77;
  --accent-hover: #142C57;
  --accent-soft: #E8ECF4;
  --on-accent: #FFFFFF;
  --brand: #C2A05A;
  --on-brand: #14213D;
  --focus: #1F3F77;
  --nav-bg: #14213D;
  --nav-text: #D9DEEA;
  --nav-muted: #9AA6BF;
  --nav-hover: #1E2E52;
  --nav-border: #24345A;
  --nav-active-bg: #263B66;
  --nav-active-text: #FFFFFF;
  --nav-active-mark: #C2A05A;
  --hi-bg: #FBE4DC; --hi-fg: #8A2A12; --hi-solid: #B23A1C;
  --mid-bg: #F9EDCB; --mid-fg: #694700; --mid-solid: #C48A16;
  --lo-bg: #E2EAF5; --lo-fg: #1E4680; --lo-solid: #5A84C2;
  --ok-bg: #DFEFE5; --ok-fg: #1A5431; --ok-solid: #2E7A4E;
  --gr-bg: #EDEAE2; --gr-fg: #444955;
  --pill-border: transparent;
  --on-danger: #FFFFFF;
  --overlay: rgb(20 33 61 / .45);
  --shadow: 0 1px 2px rgb(20 33 61 / .06);
  --shadow-lg: 0 12px 32px rgb(20 33 61 / .18);
  color-scheme: light;
}
[data-theme="CABINET"] { --h1: clamp(22px, 1rem + 0.6vw, 28px); }

[data-theme="ARDOISE"] {
  --bg: #F1F2F2;
  --surface: #FFFFFF;
  --surface-2: #F6F7F7;
  --border: #D5DADC;
  --border-soft: #E5E8E9;
  --row-hover: #F6F8F7;
  --text: #14181B;
  --muted: #4A5359;
  --accent: #1B5A44;
  --accent-hover: #124331;
  --accent-soft: #E0EDE7;
  --on-accent: #FFFFFF;
  --brand: #1B5A44;
  --on-brand: #FFFFFF;
  --focus: #1B5A44;
  --nav-bg: #E6E9EA;
  --nav-text: #262E33;
  --nav-muted: #535D63;
  --nav-hover: #D8DDDF;
  --nav-border: #D0D5D8;
  --nav-active-bg: #FFFFFF;
  --nav-active-text: #124331;
  --nav-active-mark: #1B5A44;
  --hi-bg: #FAE2D9; --hi-fg: #872A10; --hi-solid: #B03A17;
  --mid-bg: #F8EDCC; --mid-fg: #654400; --mid-solid: #BF8714;
  --lo-bg: #E0E8F3; --lo-fg: #1D4479; --lo-solid: #5B82BB;
  --ok-bg: #DDEDE5; --ok-fg: #124331; --ok-solid: #1B5A44;
  --gr-bg: #E9ECED; --gr-fg: #3E464B;
  --pill-border: transparent;
  --on-danger: #FFFFFF;
  --overlay: rgb(20 24 27 / .45);
  --shadow: 0 1px 2px rgb(20 24 27 / .06);
  --shadow-lg: 0 12px 32px rgb(20 24 27 / .18);
  --fs: 15px;
  --fs-sm: 14px;
  --fs-xs: 12.5px;
  --fs-md: 16px;
  --lh: 1.5;
  color-scheme: light;
}

[data-theme="CONTRASTE"] {
  --bg: #FFFFFF;
  --surface: #FFFFFF;
  --surface-2: #F0F0F0;
  --border: #1A1A1A;
  --border-soft: #767676;
  --row-hover: #F0F0F0;
  --text: #000000;
  --muted: #333333;
  --accent: #0A3A8C;
  --accent-hover: #061F4D;
  --accent-soft: #E3ECFA;
  --on-accent: #FFFFFF;
  --brand: #FFD500;
  --on-brand: #000000;
  --focus: #000000;
  --nav-bg: #000000;
  --nav-text: #FFFFFF;
  --nav-muted: #D6D6D6;
  --nav-hover: #2B2B2B;
  --nav-border: #5C5C5C;
  --nav-active-bg: #FFD500;
  --nav-active-text: #000000;
  --nav-active-mark: #FFD500;
  --hi-bg: #FFE9E3; --hi-fg: #7A1600; --hi-solid: #A31D00;
  --mid-bg: #FFF2C2; --mid-fg: #4D3300; --mid-solid: #8F6100;
  --lo-bg: #E3ECFA; --lo-fg: #0A3070; --lo-solid: #0A3A8C;
  --ok-bg: #DFF3E5; --ok-fg: #0B4020; --ok-solid: #0B5A2C;
  --gr-bg: #F0F0F0; --gr-fg: #1A1A1A;
  --pill-border: currentColor;
  --on-danger: #FFFFFF;
  --overlay: rgb(0 0 0 / .6);
  --shadow: none;
  --shadow-lg: 0 0 0 2px #000000;
  --fs: 15px;
  --fs-sm: 14px;
  --fs-xs: 13px;
  --fs-md: 16px;
  --focus-w: 3px;
  --link-decoration: underline;
  color-scheme: light;
}

[data-theme="NUIT"] {
  --bg: #1A1D24;
  --surface: #22262F;
  --surface-2: #2A2F3A;
  --border: #3A404D;
  --border-soft: #2F3541;
  --row-hover: #272C36;
  --text: #E4E7ED;
  --muted: #A9B0BD;
  --accent: #93B6EE;
  --accent-hover: #B7CDF4;
  --accent-soft: #2B3650;
  --on-accent: #11151C;
  --brand: #D6B676;
  --on-brand: #15181E;
  --focus: #B7CDF4;
  --nav-bg: #15181E;
  --nav-text: #C8CDD7;
  --nav-muted: #8F97A5;
  --nav-hover: #22262F;
  --nav-border: #262A33;
  --nav-active-bg: #2B3650;
  --nav-active-text: #FFFFFF;
  --nav-active-mark: #D6B676;
  --hi-bg: #45281F; --hi-fg: #F6BBA4; --hi-solid: #E07A5A;
  --mid-bg: #41361D; --mid-fg: #F1D48D; --mid-solid: #D6A440;
  --lo-bg: #213249; --lo-fg: #AECBF3; --lo-solid: #6F9BD8;
  --ok-bg: #1F3A2D; --ok-fg: #A3DBB8; --ok-solid: #55AE7D;
  --gr-bg: #2F3541; --gr-fg: #C8CDD7;
  --pill-border: transparent;
  --on-danger: #1A1D24;
  --overlay: rgb(0 0 0 / .55);
  --shadow: none;
  --shadow-lg: 0 12px 32px rgb(0 0 0 / .5);
  color-scheme: dark;
}

[data-theme="A"] {
  --bg: #F4F5F8;
  --surface: #FFFFFF;
  --surface-2: #F7F8FA;
  --border: #E3E6EE;
  --border-soft: #EEF0F4;
  --row-hover: #F9FAFC;
  --text: #14171F;
  --muted: #5B6275;
  --accent: #2453D6;
  --accent-hover: #1A3FA8;
  --accent-soft: #EEF3FD;
  --on-accent: #FFFFFF;
  --brand: #2453D6;
  --on-brand: #FFFFFF;
  --focus: #2453D6;
  --nav-bg: #171B26;
  --nav-text: #C9CEDA;
  --nav-muted: #8C93A6;
  --nav-hover: #252A38;
  --nav-border: #252A38;
  --nav-active-bg: #2453D6;
  --nav-active-text: #FFFFFF;
  --nav-active-mark: #2453D6;
  --hi-bg: #FDE7DA; --hi-fg: #9A3412; --hi-solid: #C2410C;
  --mid-bg: #FEF3C7; --mid-fg: #854D0E; --mid-solid: #E3A008;
  --lo-bg: #DCEBFB; --lo-fg: #1E4E8C; --lo-solid: #5B8DEF;
  --ok-bg: #E2F3EC; --ok-fg: #14532D; --ok-solid: #0F766E;
  --gr-bg: #EEF0F4; --gr-fg: #3D4354;
  --pill-border: transparent;
  --on-danger: #FFFFFF;
  --overlay: rgb(23 27 38 / .45);
  --shadow: none;
  --shadow-lg: 0 12px 32px rgb(23 27 38 / .2);
  --radius: 12px;
  --radius-pill: 999px;
  --h1: clamp(22px, 1rem + 0.6vw, 28px);
  color-scheme: light;
}

[data-theme="B"] {
  --bg: #FFFFFF;
  --surface: #FFFFFF;
  --surface-2: #F3F6F4;
  --border: #E2E7E4;
  --border-soft: #ECEFED;
  --row-hover: #F7F9F8;
  --text: #1B1F1D;
  --muted: #4A524E;
  --accent: #0F6B5C;
  --accent-hover: #0A4F44;
  --accent-soft: #DDEDE8;
  --on-accent: #FFFFFF;
  --brand: #0F6B5C;
  --on-brand: #FFFFFF;
  --focus: #0F6B5C;
  --nav-bg: #FFFFFF;
  --nav-text: #4A524E;
  --nav-muted: #6B736F;
  --nav-hover: #F1F4F2;
  --nav-border: #ECEFED;
  --nav-active-bg: #1B1F1D;
  --nav-active-text: #FFFFFF;
  --nav-active-mark: #1B1F1D;
  --hi-bg: #FBE6DA; --hi-fg: #8A3409; --hi-solid: #B4460F;
  --mid-bg: #FBF0D2; --mid-fg: #7A5306; --mid-solid: #C98A0B;
  --lo-bg: #E3EAF6; --lo-fg: #2F4E86; --lo-solid: #5C7DB8;
  --ok-bg: #DDEDE8; --ok-fg: #0A4F44; --ok-solid: #0F6B5C;
  --gr-bg: #F1F4F2; --gr-fg: #4A524E;
  --pill-border: transparent;
  --on-danger: #FFFFFF;
  --overlay: rgb(27 31 29 / .4);
  --shadow: none;
  --shadow-lg: 0 12px 32px rgb(27 31 29 / .16);
  --radius: 20px;
  --radius-sm: 999px;
  --radius-pill: 999px;
  --pad: clamp(20px, 0.8rem + 0.8vw, 32px);
  --font-head: var(--font-grotesk), var(--font-inter), sans-serif;
  --h1: clamp(25px, 1.1rem + 0.8vw, 34px);
  color-scheme: light;
}

[data-theme="C"] {
  --bg: #0E1117;
  --surface: #151A23;
  --surface-2: #1C2230;
  --border: #232A38;
  --border-soft: #1C2230;
  --row-hover: #1A202B;
  --text: #E6E9EF;
  --muted: #8B93A3;
  --accent: #7FB2FF;
  --accent-hover: #A9CBFF;
  --accent-soft: #1C2A44;
  --on-accent: #0E1117;
  --brand: #F59E0B;
  --on-brand: #0E1117;
  --focus: #7FB2FF;
  --nav-bg: #0A0D12;
  --nav-text: #A3ABBA;
  --nav-muted: #7C8496;
  --nav-hover: #151A23;
  --nav-border: #1C2230;
  --nav-active-bg: #1C2230;
  --nav-active-text: #FFFFFF;
  --nav-active-mark: #F59E0B;
  --hi-bg: #3A1E10; --hi-fg: #FDBA74; --hi-solid: #F97316;
  --mid-bg: #3A2E0E; --mid-fg: #FCD34D; --mid-solid: #F59E0B;
  --lo-bg: #10283A; --lo-fg: #93C5FD; --lo-solid: #60A5FA;
  --ok-bg: #12301F; --ok-fg: #86EFAC; --ok-solid: #22C55E;
  --gr-bg: #1C2230; --gr-fg: #A3ABBA;
  --pill-border: transparent;
  --on-danger: #0E1117;
  --overlay: rgb(0 0 0 / .6);
  --shadow: none;
  --shadow-lg: 0 12px 32px rgb(0 0 0 / .5);
  --radius: 8px;
  --radius-sm: 6px;
  --radius-pill: 4px;
  --pad: 16px;
  --gap: 12px;
  --cell-y: 8px;
  --font-body: var(--font-plex), system-ui, sans-serif;
  --font-head: var(--font-plex), system-ui, sans-serif;
  --fs: 13px;
  --fs-md: 13px;
  --h1: 22px;
  --th-transform: uppercase;
  color-scheme: dark;
}


/* ── 3. Base ── */
html, body { background: var(--bg); color: var(--text); }
body { font-family: var(--font-body); font-size: var(--fs); line-height: var(--lh); margin: 0; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
h1, h2, h3 { font-family: var(--font-head); margin: 0; line-height: 1.25; }
h1 { font-size: var(--h1); font-weight: 700; letter-spacing: -0.01em; overflow-wrap: anywhere; }
h3 { font-size: var(--fs-md); font-weight: 600; }
a { color: var(--accent); text-decoration: var(--link-decoration); text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); text-decoration: underline; }
:focus-visible { outline: var(--focus-w) solid var(--focus); outline-offset: 2px; border-radius: 2px; }
[data-theme="CONTRASTE"] :focus-visible { outline: 3px solid var(--focus); box-shadow: 0 0 0 6px var(--brand); }
::selection { background: var(--accent-soft); color: var(--text); }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skiplink { position: absolute; left: 8px; top: -60px; z-index: 100; background: var(--surface); color: var(--accent); padding: 10px 14px; border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); }
.skiplink:not(:focus) { box-shadow: none; }
.skiplink:focus { top: 8px; }
svg.lucide { flex: none; }
/* Paragraphes successifs dans une carte : espacement (le reset de Tailwind met les marges à 0). */
:where(.card-body, .notice) > p:not(:last-child) { margin-bottom: .6em; }

/* ── Cartes ── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--pad); min-width: 0; box-shadow: var(--shadow); }
[data-theme="B"] .card { border-color: transparent; background: var(--surface-2); }
.card-title { font-size: var(--fs-md); font-weight: 650; margin-bottom: var(--space-3); display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.card-title > a, .card-title .card-action { font-size: var(--fs-sm); font-weight: 500; font-family: var(--font-body); }
[data-theme="CABINET"] .card-title, [data-theme="ARDOISE"] .card-title { letter-spacing: -0.005em; }
[data-theme="C"] .card { padding: 0; }
[data-theme="C"] .card > .card-title { padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: 13px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); margin: 0; }
[data-theme="C"] .card > .card-body { padding: 16px; }
.card-flush { padding: 0; overflow: hidden; }
.card-flush > .card-title { padding: var(--pad) var(--pad) 0; }
.card-flush > .card-body { padding: 0; }
/* Un tableau trop large défile dans sa carte, jamais la page. */
.card-body:has(.table), .card:has(> .table) { overflow-x: auto; }

/* ── Pastilles (statuts) ── */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; min-height: 22px; box-sizing: border-box; border-radius: var(--radius-pill); border: 1px solid var(--pill-border); font-size: var(--fs-xs); font-weight: 600; line-height: 1.3; white-space: nowrap; vertical-align: middle; }
[data-theme="C"] .pill { padding: 2px 8px; font-size: 11px; }
.pill-hi { background: var(--hi-bg); color: var(--hi-fg); }
.pill-mid { background: var(--mid-bg); color: var(--mid-fg); }
.pill-lo { background: var(--lo-bg); color: var(--lo-fg); }
.pill-ok { background: var(--ok-bg); color: var(--ok-fg); }
.pill-gr { background: var(--gr-bg); color: var(--gr-fg); }
a.pill { text-decoration: none; }
/* Niveau de risque : la forme (1, 2 ou 3 barres pleines) double la couleur et le libellé. */
.risk::before { content: ""; flex: none; width: 11px; height: 10px;
  --off: color-mix(in srgb, currentColor 28%, transparent);
  background:
    linear-gradient(var(--b1, var(--off)), var(--b1, var(--off))) 0 100% / 3px 4px no-repeat,
    linear-gradient(var(--b2, var(--off)), var(--b2, var(--off))) 4px 100% / 3px 7px no-repeat,
    linear-gradient(var(--b3, var(--off)), var(--b3, var(--off))) 8px 100% / 3px 10px no-repeat; }
.risk-1 { --b1: currentColor; }
.risk-2 { --b1: currentColor; --b2: currentColor; }
.risk-3 { --b1: currentColor; --b2: currentColor; --b3: currentColor; }
.risk-0::before { background: none; border: 1.5px dashed currentColor; border-radius: 50%; width: 9px; height: 9px; box-sizing: border-box; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }

/* ── Boutons ── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: var(--tap); padding: 0 16px; border-radius: var(--radius-sm); font: inherit; font-size: var(--fs); font-weight: 600; line-height: 1.2; cursor: pointer; border: 1px solid var(--border); background: var(--surface); color: var(--text); text-decoration: none; box-sizing: border-box; }
.btn:hover { border-color: var(--muted); color: var(--text); text-decoration: none; background: var(--surface-2); }
.btn-primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--on-accent); }
.btn-danger { background: var(--hi-solid); color: var(--on-danger); border-color: var(--hi-solid); }
.btn-danger:hover { background: var(--hi-fg); border-color: var(--hi-fg); color: var(--on-danger); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--accent); }
.btn-ghost:hover { background: var(--accent-soft); border-color: transparent; color: var(--accent-hover); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.btn svg { width: 18px; height: 18px; }
[data-theme="CONTRASTE"] .btn { border-width: 2px; border-color: var(--border); }
[data-theme="CONTRASTE"] .btn-primary { border-color: var(--accent); }
/* Ordinateur (souris) : contrôles plus denses ; téléphone et tablette gardent 44 px. */
@media (min-width: 901px) and (pointer: fine) {
  .btn, .input, .field input, .field select { min-height: var(--control-h); }
  [data-theme="C"] .btn, [data-theme="C"] .field input, [data-theme="C"] .field select { min-height: 36px; }
}

/* ── Champs ── */
.field { display: flex; flex-direction: column; gap: 4px; font-size: var(--fs-xs); font-weight: 500; color: var(--muted); min-width: 0; }
.field > select, .field > input:not([type="checkbox"]):not([type="radio"]) { min-width: 0; }
.input, .field input, .field select, .field textarea {
  min-height: var(--tap); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0 12px; box-sizing: border-box; max-width: 100%;
  font: inherit; font-size: var(--fs); font-weight: 400; color: var(--text); background: var(--surface);
}
[data-theme="B"] .field input, [data-theme="B"] .field select { border-radius: 10px; }
.field input:hover, .field select:hover, .field textarea:hover { border-color: var(--muted); }
.input:focus-visible, .field input:focus-visible, .field select:focus-visible, .field textarea:focus-visible { outline: var(--focus-w) solid var(--focus); outline-offset: 0; border-color: var(--focus); }
.field textarea { padding: 10px 12px; min-height: 88px; }
.field input::placeholder, .field textarea::placeholder { color: var(--muted); opacity: .85; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); width: 18px; height: 18px; }
.field input[type="checkbox"], .field input[type="radio"] { min-height: 0; padding: 0; }
input[type="file"] { font-size: var(--fs-sm); color: var(--muted); }
input[type="file"]::file-selector-button { font: inherit; font-weight: 600; color: var(--text); background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 12px; margin-right: 10px; cursor: pointer; }
.field input[type="file"] { padding: 6px; display: flex; align-items: center; }
[data-theme="C"] .field input, [data-theme="C"] .field select, [data-theme="C"] .field textarea { background: var(--bg); }
[data-theme="CONTRASTE"] .field input, [data-theme="CONTRASTE"] .field select, [data-theme="CONTRASTE"] .field textarea { border: 2px solid var(--border); }
.error { color: var(--hi-fg); background: var(--hi-bg); border: 1px solid var(--pill-border); border-left: 3px solid var(--hi-solid); border-radius: var(--radius-sm); padding: 10px 12px; font-size: var(--fs); }
.notice { color: var(--text); background: var(--accent-soft); border: 1px solid var(--pill-border); border-left: 3px solid var(--accent); border-radius: var(--radius-sm); padding: 12px 14px; font-size: var(--fs); }
.success { color: var(--ok-fg); background: var(--ok-bg); border-left: 3px solid var(--ok-solid); border-radius: var(--radius-sm); padding: 10px 12px; }

/* ── Tableaux ──
   .cell-main : texte principal sur une ligne (ellipse) ; .cell-sub : sous-ligne secondaire.
   .col-opt : colonne secondaire masquée sur téléphone. .nil : valeur vide discrète.
   Sur téléphone, `table responsive` passe en cartes (data-label sur chaque td) ; td.primary = titre de la carte. */
.table { border-collapse: collapse; width: 100%; font-size: var(--fs); }
.table th { text-align: left; font-size: var(--fs-xs); color: var(--muted); font-weight: 600; padding: 8px var(--cell-x); border-bottom: 1px solid var(--border); white-space: nowrap; text-transform: var(--th-transform); letter-spacing: .01em; background: var(--surface-2); }
.card .table th { background: transparent; }
.table td { padding: var(--cell-y) var(--cell-x); border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--row-hover); }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.cell-main { display: block; max-width: 34ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
a.cell-main { color: var(--accent); }
.cell-sub { display: block; max-width: 40ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--fs-xs); color: var(--muted); margin-top: 1px; }
/* Colonne « Client » de tous les tableaux : nom sur une ligne (ellipse, nom complet au survol via title si fourni). */
.table td[data-label="Client"] > a:only-child { display: block; max-width: 32ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.nil { color: var(--muted); }
[data-theme="C"] .table th { font-size: 11px; letter-spacing: .04em; font-weight: 500; padding: 8px clamp(10px, 0.3rem + 0.5vw, 16px); }
[data-theme="C"] .table td { padding: 8px clamp(10px, 0.3rem + 0.5vw, 16px); }
/* Mode cartes : selon la largeur du conteneur du tableau (carte, colonne), pas de l'écran : téléphone, tablette,
   mais aussi une demi-colonne étroite sur ordinateur. Jamais de défilement horizontal pour ces tableaux. */
@container (max-width: 799.98px) {
  .table.responsive thead { display: none; }
  .table.responsive, .table.responsive tbody, .table.responsive tr, .table.responsive td { display: block; width: 100%; box-sizing: border-box; }
  .table.responsive tr { border-bottom: 1px solid var(--border); padding: 10px 0; }
  .table.responsive tbody tr:last-child { border-bottom: 0; }
  .table.responsive tbody tr:hover td { background: transparent; }
  .table.responsive td { border: 0; padding: 3px 4px; display: flex; justify-content: space-between; align-items: center; gap: 12px; text-align: right; min-height: 26px; }
  .table.responsive td::before { content: attr(data-label); color: var(--muted); font-size: var(--fs-xs); text-align: left; flex: 0 1 auto; max-width: 45%; }
  .table.responsive td[data-label=""]::before { content: none; }
  .table.responsive td.primary, .table.responsive td[data-label="Client"]:first-child { display: block; text-align: left; padding-bottom: 6px; }
  .table.responsive td.primary::before, .table.responsive td[data-label="Client"]:first-child::before { content: none; }
  .table.responsive td[data-label="Client"]:first-child > a:only-child { max-width: 100%; }
  .table.responsive td.primary .cell-main, .table.responsive td.primary .cell-sub { max-width: 100%; }
  .table.responsive td.col-opt, .table.responsive td[data-empty] { display: none; }
  .table.responsive td > .cell-main { max-width: 60%; }
  /* Variante « cards-grid » : valeurs en grille 2 colonnes, libellé au-dessus (cartes plus courtes). */
  .table.responsive.cards-grid tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 12px; padding: 12px 0; }
  .table.responsive.cards-grid td::before { max-width: none; }
  .table.responsive.cards-grid td { display: flex; flex-direction: column; align-items: flex-start; justify-content: flex-start; text-align: left; gap: 2px; padding: 0 4px; min-height: 0; }
  .table.responsive.cards-grid td.primary { grid-column: 1 / -1; padding-bottom: 2px; order: -1; }
}
/* Colonnes secondaires : masquées selon la largeur réellement disponible pour le tableau (requête de conteneur),
   pas selon l'écran : le menu réduit ou déployé, une colonne latérale, etc. sont pris en compte. */
.card:has(> .table), .card-body:has(.table), .table-wrap { container-type: inline-size; }
@container (max-width: 1039.98px) { .table th.col-opt, .table td.col-opt { display: none; } }

/* ── Indicateurs ── */
.kpi { display: flex; flex-direction: column; gap: 2px; text-decoration: none; color: var(--text); }
a.kpi:hover { text-decoration: none; color: var(--text); border-color: var(--accent); }
.kpi-label { font-size: var(--fs-sm); color: var(--muted); font-weight: 500; display: flex; align-items: center; gap: 8px; }
.kpi-label svg { width: 16px; height: 16px; }
.kpi-value { font-size: 30px; font-weight: 700; margin-top: 4px; font-family: var(--font-head); line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: var(--fs-xs); color: var(--muted); margin-top: 4px; }
.kpi-hi .kpi-value { color: var(--hi-fg); }
.kpi-accent .kpi-value { color: var(--accent); }
[data-theme="C"] .card.kpi { padding: 12px 16px; }
[data-theme="C"] .kpi-label { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
[data-theme="C"] .kpi-value { font-size: 28px; font-weight: 600; }

.muted { color: var(--muted); }
.small { font-size: var(--fs-sm); }
.progress { height: 8px; background: var(--border-soft); border-radius: 4px; overflow: hidden; }
.progress > span { display: block; height: 100%; }
[data-theme="CONTRASTE"] .progress { outline: 1px solid var(--border); }

/* ── Listes compactes (alertes, actions) ── */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { border-bottom: 1px solid var(--border-soft); }
.list > li:last-child { border-bottom: 0; }
.list-row { display: flex; align-items: center; gap: var(--space-3); padding: 9px 0; min-width: 0; }
.list-main { flex: 1; min-width: 0; }
.list-title { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.list-sub { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--fs-xs); color: var(--muted); }
.list-meta { flex: none; font-size: var(--fs-xs); color: var(--muted); text-align: right; white-space: nowrap; }
.list-icon { flex: none; width: 36px; height: 36px; border-radius: var(--radius-sm); display: inline-flex; align-items: center; justify-content: center; background: var(--accent-soft); color: var(--accent); }
.list-icon svg { width: 18px; height: 18px; }
.list-icon.tone-hi { background: var(--hi-bg); color: var(--hi-fg); }
.list-icon.tone-mid { background: var(--mid-bg); color: var(--mid-fg); }
.list-icon.tone-ok { background: var(--ok-bg); color: var(--ok-fg); }
a.list-row { color: var(--text); text-decoration: none; min-height: var(--tap); padding: 7px 8px; margin: 0 -8px; border-radius: var(--radius-sm); box-sizing: border-box; }
a.list-row:hover { color: var(--text); text-decoration: none; background: var(--row-hover); }
a.list-row:hover .list-title { color: var(--accent); }
.list-row .chev { color: var(--muted); width: 18px; height: 18px; }

/* ── État vide ── */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; padding: var(--space-6) var(--space-4); color: var(--muted); }
.empty svg { width: 28px; height: 28px; color: var(--ok-solid); }
.empty b { color: var(--text); font-weight: 600; }

/* ── Paires clé / valeur ── */
.kv { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: var(--space-6); margin: 0; }
.kv > div { display: grid; grid-template-columns: minmax(110px, 40%) 1fr; gap: var(--space-3); padding: 7px 0; border-bottom: 1px solid var(--border-soft); align-items: baseline; }
.kv dt { font-size: var(--fs-sm); color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; min-width: 0; }
.kv > .kv-wide { grid-column: 1 / -1; grid-template-columns: minmax(110px, calc(20% - 6px)) 1fr; }
@media (max-width: 760px) { .kv { grid-template-columns: 1fr; } .kv > .kv-wide { grid-template-columns: minmax(110px, 40%) 1fr; } }

/* ── Onglets défilables (indicateur de défilement : fondu et flèche) ── */
.tabs-wrap { position: relative; min-width: 0; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; }
.tabs::-webkit-scrollbar { display: none; }
.tab { display: inline-flex; align-items: center; gap: 6px; min-height: var(--tap); padding: 0 12px; font-size: var(--fs); color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; scroll-snap-align: start; text-decoration: none; }
.tab:hover { color: var(--text); text-decoration: none; background: var(--row-hover); }
.tab[aria-current="page"] { color: var(--text); font-weight: 600; border-bottom-color: var(--accent); }
.tabs-wrap::before, .tabs-wrap::after { content: ""; position: absolute; top: 0; bottom: 1px; width: 36px; pointer-events: none; opacity: 0; transition: opacity .15s; }
.tabs-wrap::before { left: 0; background: linear-gradient(to right, var(--bg), transparent); }
.tabs-wrap::after { right: 0; background: linear-gradient(to left, var(--bg) 30%, transparent); }
.tabs-wrap[data-more-left]::before, .tabs-wrap[data-more-right]::after { opacity: 1; }
.tabs-more { position: absolute; right: 0; top: 0; bottom: 0; min-height: var(--tap); z-index: 1; display: none; align-items: center; justify-content: center; width: 32px; border: 0; background: transparent; color: var(--accent); cursor: pointer; padding: 0; }
.tabs-wrap[data-more-right] .tabs-more { display: flex; }
.tabs-more svg { width: 20px; height: 20px; }
[data-theme="C"] .tabs { gap: 8px; }
[data-theme="C"] .tab[aria-current="page"] { border-bottom-color: var(--mid-solid); }
[data-theme="B"] .tabs { border-bottom: 0; gap: 6px; }
[data-theme="B"] .tab { border: 0; border-radius: 999px; padding: 0 14px; margin: 0; }
[data-theme="B"] .tab[aria-current="page"] { background: var(--nav-active-bg); color: var(--nav-active-text); }
[data-theme="CONTRASTE"] .tab[aria-current="page"] { border-bottom-width: 4px; }

/* ── En-tête de dossier (fiche client) ── */
.entity-head { display: flex; flex-direction: column; gap: var(--space-3); }
.entity-top { display: flex; gap: var(--space-4); align-items: flex-start; min-width: 0; }
.entity-mark { flex: none; width: 48px; height: 48px; border-radius: var(--radius-sm); background: var(--accent-soft); color: var(--accent); display: inline-flex; align-items: center; justify-content: center; }
.entity-mark svg { width: 24px; height: 24px; }
.entity-id { min-width: 0; flex: 1; }
.entity-sub { margin-top: 4px; font-size: var(--fs-sm); color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 14px; }
.entity-pills { display: flex; flex-wrap: wrap; gap: 6px; margin-top: var(--space-2); }
.facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin: 0; border-top: 1px solid var(--border-soft); padding-top: var(--space-3); gap: var(--space-3); }
.facts > div { min-width: 0; }
.facts dt { font-size: var(--fs-xs); color: var(--muted); display: flex; align-items: center; gap: 6px; }
.facts dt svg { width: 14px; height: 14px; }
.facts dd { margin: 2px 0 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 760px) {
  .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .entity-mark { width: 40px; height: 40px; }
}
.crumbs { font-size: var(--fs-sm); color: var(--muted); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; min-width: 0; }
.crumbs a { display: inline-flex; align-items: center; min-height: 24px; }
@media (max-width: 900px) { .crumbs a { min-height: var(--tap); } }
.crumbs .crumb-current { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; max-width: 100%; }

/* ── Coque de l'application ── */
.shell { display: flex; min-height: 100dvh; }
.shell-main { flex: 1; min-width: 0; width: 100%; padding: var(--shell-pad-y) var(--shell-pad-x) 48px; display: flex; flex-direction: column; gap: var(--gap); max-width: calc(var(--content-max) + 2 * var(--shell-pad-x)); margin-inline: auto; box-sizing: border-box; container: main / inline-size; }
.sidenav { width: var(--nav-w); flex: none; box-sizing: border-box; background: var(--nav-bg); border-right: 1px solid var(--nav-border); padding: 18px 12px 12px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100dvh; overflow-y: auto; }
.navgroups { display: flex; flex-direction: column; gap: 14px; }
.navgroup { display: flex; flex-direction: column; gap: 2px; }
.navgroup-title { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--nav-muted); padding: 0 12px 4px; }
.navlink { display: flex; align-items: center; gap: 10px; min-height: 38px; padding: 0 10px 0 12px; border-radius: var(--radius-sm); color: var(--nav-text); font-size: var(--fs); text-decoration: none; position: relative; }
.navlink:hover { background: var(--nav-hover); color: var(--nav-text); text-decoration: none; }
.navlink[aria-current="page"] { background: var(--nav-active-bg); color: var(--nav-active-text); font-weight: 600; }
.sidenav .navlink[aria-current="page"]::before { content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--nav-active-mark); }
[data-theme="ARDOISE"] .sidenav .navlink[aria-current="page"] { box-shadow: 0 1px 2px rgb(20 24 27 / .08); }
.navicon { width: 18px; height: 18px; opacity: .9; }
.navlabel { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.navcount { flex: none; min-width: 20px; height: 20px; padding: 0 6px; box-sizing: border-box; border-radius: 10px; background: var(--brand); color: var(--on-brand); font-size: 11px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; font-variant-numeric: tabular-nums; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--nav-text); padding: 4px 8px 18px; }
[data-theme="ARDOISE"] .brand, [data-theme="B"] .brand { color: var(--text); }
.brand-mark { flex: none; width: 32px; height: 32px; border-radius: 8px; background: var(--brand); color: var(--on-brand); display: inline-flex; align-items: center; justify-content: center; font-family: var(--font-brand); font-weight: 700; font-size: 18px; }
.brand-name { font-weight: 700; font-size: 16px; line-height: 1.2; letter-spacing: -0.01em; }
[data-theme="CABINET"] .brand-name { font-family: var(--font-brand); font-size: 17px; letter-spacing: 0; }
.brand small { display: block; font-size: 11.5px; font-weight: 400; color: var(--nav-muted); margin-top: 1px; font-family: var(--font-body); letter-spacing: .02em; }
.navuser { margin-top: auto; padding: 12px 4px 0; border-top: 1px solid var(--nav-border); color: var(--nav-text); font-size: var(--fs-sm); display: flex; align-items: center; gap: 10px; }
.navuser-id { flex: 1; min-width: 0; }
.navuser-name { color: var(--nav-text); font-weight: 600; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.navuser-name:hover { color: var(--nav-text); text-decoration: underline; }
.navuser small { display: block; color: var(--nav-muted); font-size: var(--fs-xs); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.navlogout { background: none; border: 0; padding: 0; color: var(--nav-muted); font: inherit; font-size: var(--fs-sm); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-width: 36px; min-height: 36px; border-radius: var(--radius-sm); }
.navlogout:hover { color: var(--nav-text); background: var(--nav-hover); }
.navlogout svg { width: 18px; height: 18px; }
.avatar { width: 36px; height: 36px; flex: none; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: inline-flex; align-items: center; justify-content: center; font-weight: 600; font-size: 13px; text-decoration: none; }
.sidenav .avatar, .mobiletop .avatar, .mobilemenu-head .avatar { background: var(--nav-hover); color: var(--nav-text); }

[data-theme="C"] .sidenav { width: 220px; padding: 16px 10px; }
[data-theme="C"] .navlink { font-size: 13px; min-height: 34px; border-radius: 6px; }
[data-theme="CONTRASTE"] .navlink[aria-current="page"] { outline: 2px solid var(--nav-text); outline-offset: -2px; }

/* Style B : navigation en haut */
.topnav { display: none; }
[data-theme="B"] .shell { flex-direction: column; }
[data-theme="B"] .sidenav { display: none; }
[data-theme="B"] .topnav { display: flex; align-items: center; gap: 8px 16px; padding: 12px var(--shell-pad-x); border-bottom: 1px solid var(--border-soft); flex-wrap: wrap; position: sticky; top: 0; z-index: 20; background: var(--nav-bg); }
[data-theme="B"] .topnav .brand { padding: 0; font-family: var(--font-head); }
[data-theme="B"] .topnav nav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
[data-theme="B"] .topnav .navlink { padding: 0 clamp(8px, 0.1rem + 0.6vw, 14px); min-height: 40px; border-radius: 999px; }
[data-theme="B"] .topnav .navicon { display: none; }
[data-theme="B"] .shell-main { padding: clamp(24px, 0.8rem + 1vw, 44px) var(--shell-pad-x) 48px; }

/* Téléphone et tablette : bandeau du haut + barre d'onglets en bas, menu complet en feuille. */
.mobiletop, .mobilebar { display: none; }
@media (max-width: 900px) {
  .shell, [data-theme="B"] .shell { flex-direction: column; }
  .sidenav, [data-theme="B"] .topnav { display: none !important; }
  .mobiletop { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 16px; min-height: 56px; box-sizing: border-box; background: var(--nav-bg); position: sticky; top: 0; z-index: 20; border-bottom: 1px solid var(--nav-border); }
  .mobiletop .brand { padding: 0; }
  .mobiletop .brand-mark { width: 28px; height: 28px; font-size: 16px; }
  .mobiletop .avatar { width: 44px; height: 44px; }
  .mobilebar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--nav-bg); border-top: 1px solid var(--nav-border); padding: 4px 4px calc(4px + env(safe-area-inset-bottom, 0px)); box-shadow: 0 -2px 10px rgb(0 0 0 / .08); }
  .tablink { flex: 1 1 0; min-width: 0; min-height: 52px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; border-radius: var(--radius-sm); color: var(--nav-muted); font-size: 11px; font-weight: 600; text-decoration: none; cursor: pointer; list-style: none; position: relative; }
  .tablink > span:last-child { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .tablink:hover { color: var(--nav-text); text-decoration: none; }
  .tablink[aria-current="page"] { color: var(--nav-text); }
  .tablink[aria-current="page"] .tabicon { background: var(--nav-active-bg); color: var(--nav-active-text); }
  .tabicon { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 48px; height: 28px; border-radius: 14px; }
  .tabicon svg { width: 20px; height: 20px; }
  .tabcount { position: absolute; top: -4px; right: 2px; min-width: 18px; height: 18px; padding: 0 4px; box-sizing: border-box; border-radius: 9px; background: var(--brand); color: var(--on-brand); font-size: 10.5px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
  .mobilebar details { flex: 1 1 0; min-width: 0; display: flex; }
  .mobilebar details > summary { width: 100%; }
  .mobilebar details summary::-webkit-details-marker { display: none; }
  .mobilebar details[open] > summary { color: var(--nav-text); }
  /* Fond assombri : un toucher en dehors de la feuille referme le menu (clic sur le résumé). */
  .mobilebar details[open] > summary::before { content: ""; position: fixed; inset: 0; background: var(--overlay); z-index: -1; cursor: default; }
  .mobilemenu { position: fixed; left: 0; right: 0; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px)); max-height: calc(100dvh - var(--tabbar-h) - 72px); overflow-y: auto; background: var(--nav-bg); padding: 8px 12px 12px; display: flex; flex-direction: column; gap: 10px; border-radius: 16px 16px 0 0; box-shadow: var(--shadow-lg); z-index: 1; overscroll-behavior: contain; }
  .mobilemenu-head { display: flex; align-items: center; gap: 10px; padding: 8px 4px 10px; border-bottom: 1px solid var(--nav-border); color: var(--nav-text); }
  .mobilemenu-head b { display: block; }
  .mobilemenu-head small { color: var(--nav-muted); font-size: var(--fs-xs); }
  .mobilemenu .navlink { min-height: var(--tap); font-size: 15px; }
  .mobilemenu .navlogout { min-height: var(--tap); justify-content: flex-start; padding: 0 12px; font-size: 15px; color: var(--nav-text); width: 100%; }
  .shell-main, [data-theme="B"] .shell-main, [data-theme="C"] .shell-main { padding: 16px 16px calc(var(--tabbar-h) + 24px + env(safe-area-inset-bottom, 0px)); gap: 14px; max-width: none; }
  [data-theme="C"] .btn, [data-theme="C"] .field input, [data-theme="C"] .field select, [data-theme="C"] .tab, [data-theme="C"] .navlink { min-height: var(--tap); }
  h1 { font-size: clamp(20px, 5.6vw, var(--h1)); }
}

/* ── Mise en page ── */
.grid-kpi { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--gap); }
@media (max-width: 1100px) { .grid-kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.grid-kpi.auto { grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr)); }
.grid-kpi.auto .kpi-value { font-size: 24px; }
.grid-kpi.auto > .card { padding: 12px 16px; }
a.kpi[aria-current="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
@media (max-width: 560px) {
  .grid-kpi { gap: 10px; }
  .grid-kpi .kpi-label svg { display: none; }
  .grid-kpi > .card { padding: 12px 14px; }
  [data-theme="C"] .grid-kpi > .card { padding: 0; }
  .grid-kpi .kpi-value { font-size: 24px; }
  .grid-kpi .kpi-label { font-size: var(--fs-xs); }
}
.grid-2 { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: var(--gap); align-items: start; }
@media (max-width: 1100px) { .grid-2 { grid-template-columns: minmax(0, 1fr); } }
.page-head { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: flex-end; justify-content: space-between; }
.page-head > div:first-child { min-width: 0; }
.page-head p { margin: 4px 0 0; color: var(--muted); font-size: var(--fs); }
@media (max-width: 560px) {
  .page-head { align-items: stretch; }
  .page-head > .cluster { width: 100%; }
  .page-head > .cluster > .btn { flex: 1 1 auto; }
}
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.stack { display: flex; flex-direction: column; gap: var(--gap); }
.cluster { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* Filtres : une ligne compacte sur ordinateur ; sur téléphone, les filtres secondaires se déplient. */
/* Grille : les champs gardent une largeur raisonnable (jamais un sélecteur étiré sur toute la ligne). */
.filters { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 168px), 1fr)); gap: 10px 12px; align-items: end; padding: 14px var(--pad); }
.filters > .field { min-width: 0; }
.filters > .field.grow { grid-column: span 2; }
.filters > .btn { justify-self: start; }
.filters-toggle { display: none !important; }
@media (max-width: 720px) {
  .filters { padding: 12px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 10px; }
  .filters > .field.grow { grid-column: 1 / -1; }
  .filters-toggle { display: inline-flex !important; justify-content: flex-start; padding: 0 4px; }
  .filters:not([data-open]) > .filters-extra { display: none; }
}
@media (max-width: 380px) { .filters { grid-template-columns: minmax(0, 1fr); } }

/* Aperçu miniature d'un style (sélecteur de /profil) : rendu avec les variables du style visé. */
.theme-preview { display: grid; grid-template-columns: 30% 1fr; height: 84px; width: 100%; border-radius: 8px; overflow: hidden; border: 1px solid var(--border); background: var(--bg); }
.theme-preview .tp-nav { background: var(--nav-bg); padding: 8px 6px; display: flex; flex-direction: column; gap: 5px; }
.theme-preview .tp-nav i { display: block; height: 5px; border-radius: 3px; background: var(--nav-muted); opacity: .6; }
.theme-preview .tp-nav i.on { background: var(--nav-active-mark); opacity: 1; }
.theme-preview .tp-body { padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.theme-preview .tp-card { background: var(--surface); border: 1px solid var(--border); border-radius: 4px; padding: 6px; display: flex; gap: 4px; align-items: center; }
.theme-preview .tp-line { height: 5px; border-radius: 3px; background: var(--text); opacity: .75; flex: 1; }
.theme-preview .tp-pill { width: 16px; height: 8px; border-radius: 4px; }
.theme-preview .tp-btn { width: 40%; height: 12px; border-radius: 3px; background: var(--accent); }
[data-theme="B"].theme-preview { grid-template-columns: 1fr; grid-template-rows: 14px 1fr; }
[data-theme="B"].theme-preview .tp-nav { flex-direction: row; padding: 4px 6px; border-bottom: 1px solid var(--border-soft); }
[data-theme="B"].theme-preview .tp-nav i { width: 14px; height: 5px; }
.theme-option { width: 100%; height: auto; padding: 12px; flex-direction: column; align-items: stretch; gap: 8px; text-align: left; border-width: 2px; border-radius: var(--radius); }
.theme-option[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.theme-option .theme-name { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.theme-option .theme-desc { font-weight: 400; font-size: var(--fs-sm); color: var(--muted); }
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 210px), 1fr)); gap: 12px; }

/* Pages sans coque (connexion, dépôt public) */
.auth-wrap { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 16px; box-sizing: border-box; background: var(--bg); }
.auth-card { width: 100%; max-width: 400px; }
.auth-brand { display: flex; align-items: center; gap: 10px; }
.auth-brand .brand-mark { width: 40px; height: 40px; font-size: 22px; }
.auth-brand b { display: block; font-size: 17px; }
.auth-brand small { color: var(--muted); font-size: var(--fs-sm); }
[data-theme="CABINET"] .auth-brand b { font-family: var(--font-brand); font-size: 18px; }
.public-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; background: var(--nav-bg); color: var(--nav-text); }
[data-theme="ARDOISE"] .public-head, [data-theme="B"] .public-head { color: var(--text); }
.public-head b { font-size: 16px; }

/* Zones sûres (encoche, barre d'état, barre de gestes). env(safe-area-inset-*) vaut 0 sauf avec
   viewport-fit=cover, posé uniquement dans l'appli native (mobile/) : aucun effet dans un navigateur. */
.shell { padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px); }
.sidenav { top: env(safe-area-inset-top, 0px); height: calc(100dvh - env(safe-area-inset-top, 0px)); }
@media (max-width: 900px) {
  /* Téléphone : le bandeau du haut passe sous la barre d'état, avec la couleur de navigation du style ;
     la barre d'onglets du bas tient compte de la barre de gestes. */
  .shell { padding-top: 0; padding-bottom: 0; }
  .mobiletop { padding-top: calc(6px + env(safe-area-inset-top, 0px)); }
}

@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }
@media print { .sidenav, .topnav, .mobiletop, .mobilebar, .skiplink { display: none !important; } .shell-main { padding: 0; } }
/* QR code d'activation de la double authentification : toujours sur fond blanc (lisibilité du scan). */
.qr { align-self: center; background: #FFFFFF; padding: 8px; border-radius: 8px; }
/* État vide d'une carte (« Aucun … ») : encadré discret plutôt qu'une ligne perdue. */
.card-body > p.muted:only-child, .card-body > .muted:only-child { margin: 0; padding: 14px 16px; text-align: center; border: 1px dashed var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }

/* ═══════════ Ergonomie : recherche, palette, raccourcis, confirmations ═══════════ */
/* Texte trouvé (recherche) */
mark.hl { background: var(--mid-bg); color: inherit; border-radius: 2px; padding: 0 1px; box-decoration-break: clone; -webkit-box-decoration-break: clone; }
[data-theme="CONTRASTE"] mark.hl { outline: 1px solid var(--mid-fg); }
kbd { font: inherit; font-size: 11px; font-weight: 600; line-height: 1; padding: 3px 5px; border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 4px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
@keyframes lab-spin { to { transform: rotate(360deg); } }
.spin { animation: lab-spin .9s linear infinite; }
@media (prefers-reduced-motion: reduce) { .spin { animation: none; } }

/* Champ de recherche avec loupe et indicateur de chargement */
.search-field { position: relative; display: flex; align-items: center; }
.search-field input { width: 100%; padding-left: 36px; padding-right: 34px; }
.search-field-icon { position: absolute; left: 11px; width: 16px; height: 16px; color: var(--muted); pointer-events: none; }
.search-field-busy { position: absolute; right: 10px; width: 16px; height: 16px; color: var(--muted); pointer-events: none; }
.filters > .btn svg { width: 16px; height: 16px; }

/* Liste occupée (filtrage en cours) : contenu atténué, sans saut de mise en page */
[data-pending] { opacity: .6; transition: opacity .15s; }

/* En-têtes triables */
.table th a.sort { color: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: 4px; min-height: 28px; }
.table th a.sort:hover { color: var(--text); }
.table th a.sort svg { width: 13px; height: 13px; opacity: .45; }
.table th a.sort svg[data-active] { opacity: 1; color: var(--accent); }
.table th[aria-sort] { color: var(--text); }

/* Ligne entière cliquable : le lien principal couvre la ligne (accessible : un seul lien par ligne) */
.table.rowlink tbody tr { position: relative; }
.table.rowlink tbody tr:hover { cursor: pointer; }
.table.rowlink td.primary a.cell-main::after { content: ""; position: absolute; inset: 0; z-index: 1; }
.table.rowlink td.primary a.cell-main:focus-visible { outline: none; }
.table.rowlink tbody tr:has(a.cell-main:focus-visible) { outline: var(--focus-w) solid var(--focus); outline-offset: -2px; }
.table.rowlink tbody tr:hover a.cell-main { text-decoration: underline; }

/* Longues listes : sur ordinateur, la carte défile et l'en-tête du tableau reste visible */
@media (min-width: 901px) {
  .sticky-head { max-height: max(420px, calc(100dvh - 140px)); overflow: auto; overscroll-behavior: contain; }
  .sticky-head .table thead th { position: sticky; top: 0; z-index: 2; background: var(--surface); box-shadow: inset 0 -1px 0 var(--border); }
  [data-theme="B"] .sticky-head .table thead th { background: var(--surface-2); }
}

/* Bouton « Recherche » de la coque */
.searchbtn { display: flex; align-items: center; gap: 8px; min-height: 38px; padding: 0 10px; margin: 0 0 14px; border-radius: var(--radius-sm); border: 1px solid var(--nav-border); background: transparent; color: var(--nav-muted); font: inherit; font-size: var(--fs); cursor: pointer; text-align: left; }
.searchbtn:hover { background: var(--nav-hover); color: var(--nav-text); }
.searchbtn svg { width: 16px; height: 16px; }
.searchbtn .searchbtn-label { flex: 1; }
.searchbtn kbd { background: transparent; border-color: var(--nav-border); color: var(--nav-muted); }
.searchbtn-top { margin: 0; min-height: 40px; border-color: var(--border); color: var(--muted); }
.searchbtn-top kbd { border-color: var(--border); color: var(--muted); }
.searchbtn-icon { display: inline-flex; align-items: center; justify-content: center; width: var(--tap); height: var(--tap); margin-left: auto; border: 0; border-radius: 50%; background: transparent; color: var(--nav-text); cursor: pointer; }
.searchbtn-icon:hover { background: var(--nav-hover); }
.searchbtn-icon svg { width: 22px; height: 22px; }
[data-theme="ARDOISE"] .searchbtn-icon, [data-theme="B"] .searchbtn-icon { color: var(--text); }

/* Palette de recherche et fenêtre d'aide (élément <dialog> natif) */
dialog.palette { padding: 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); width: min(640px, calc(100vw - 24px)); max-height: min(560px, calc(100dvh - 48px)); margin: 10vh auto auto; overflow: hidden; }
dialog.palette::backdrop { background: var(--overlay); }
.palette-box { display: flex; flex-direction: column; max-height: min(560px, calc(100dvh - 48px)); }
.palette-head { display: flex; align-items: center; gap: 8px; padding: 6px 10px 6px 14px; border-bottom: 1px solid var(--border); }
.palette-icon { width: 18px; height: 18px; color: var(--muted); }
.palette-input { flex: 1; min-width: 0; min-height: 48px; border: 0; outline: 0; background: transparent; color: var(--text); font: inherit; font-size: 16px; }
.palette-input::placeholder { color: var(--muted); }
.palette-close { border: 1px solid var(--border); background: var(--surface-2); color: var(--muted); border-radius: 4px; font: inherit; font-size: 11px; font-weight: 600; padding: 4px 6px; cursor: pointer; min-height: 28px; }
.palette-back { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--accent); cursor: pointer; }
.palette-back:hover { background: var(--accent-soft); }
.palette-back svg { width: 18px; height: 18px; }
.palette-list { overflow-y: auto; padding: 6px 8px 8px; flex: 1; overscroll-behavior: contain; }
.palette-group + .palette-group { margin-top: 6px; }
.palette-group-title { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 8px 8px 4px; }
.palette-opt { display: flex; align-items: center; gap: var(--space-3); min-height: var(--tap); padding: 6px 8px; border-radius: var(--radius-sm); cursor: pointer; box-sizing: border-box; }
.palette-opt[aria-selected="true"] { background: var(--accent-soft); }
.palette-opt[aria-selected="true"] .list-title { color: var(--accent); }
.palette-opt .list-icon { width: 32px; height: 32px; background: var(--surface-2); color: var(--muted); }
.palette-opt[aria-selected="true"] .list-icon { background: var(--surface); color: var(--accent); }
.palette-enter { width: 16px; height: 16px; color: var(--muted); flex: none; }
.palette-empty { margin: 0; padding: 18px 8px; text-align: center; color: var(--muted); }
.palette-foot { display: flex; justify-content: space-between; gap: 12px; padding: 8px 14px; border-top: 1px solid var(--border-soft); font-size: var(--fs-xs); color: var(--muted); background: var(--surface-2); }
.palette-keys kbd { margin: 0 1px; }
[data-theme="CONTRASTE"] .palette-opt[aria-selected="true"] { outline: 2px solid var(--focus); }
@media (max-width: 720px) {
  dialog.palette { margin: 8px auto auto; width: calc(100vw - 16px); max-height: calc(100dvh - 16px); }
  .palette-box { max-height: calc(100dvh - 16px); }
  .palette-keys { display: none; }
}
.shortcut-list { margin: 0; padding: 8px 16px 12px; display: grid; gap: 2px; }
.shortcut-list > div { display: flex; justify-content: space-between; gap: 16px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border-soft); }
.shortcut-list dd { margin: 0; color: var(--text); text-align: right; }

/* Confirmations discrètes (toasts) */
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 60; display: flex; flex-direction: column; gap: 8px; max-width: min(380px, calc(100vw - 32px)); pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 10px; padding: 10px 8px 10px 14px; border-radius: var(--radius-sm); background: var(--surface); color: var(--text); border: 1px solid var(--border); border-left: 3px solid var(--ok-solid); box-shadow: var(--shadow-lg); font-size: var(--fs); }
.toast > svg { width: 18px; height: 18px; color: var(--ok-fg); flex: none; }
.toast-error { border-left-color: var(--hi-solid); }
.toast-error > svg { color: var(--hi-fg); }
.toast-info { border-left-color: var(--accent); }
.toast-info > svg { color: var(--accent); }
.toast > span { flex: 1; min-width: 0; }
.toast-close { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--muted); cursor: pointer; }
.toast-close:hover { background: var(--row-hover); color: var(--text); }
.toast-close svg { width: 16px; height: 16px; }
@media (max-width: 900px) { .toasts { left: 16px; right: 16px; max-width: none; bottom: calc(var(--tabbar-h) + 12px + env(safe-area-inset-bottom, 0px)); } .toast-close { width: var(--tap); height: var(--tap); } }

/* Combobox filtrable maison (choix d'un client, d'un utilisateur, d'un pays…) */
.combo { position: relative; display: flex; flex-direction: column; }
.combo-input { display: flex; align-items: center; position: relative; }
.combo-input input { width: 100%; padding-right: 40px; }
.combo-toggle { position: absolute; right: 2px; top: 50%; transform: translateY(-50%); display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border: 0; background: transparent; color: var(--muted); cursor: pointer; border-radius: var(--radius-sm); }
.combo-toggle svg { width: 16px; height: 16px; }
.combo-list { position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 40; max-height: 280px; overflow-y: auto; margin: 0; padding: 4px; list-style: none; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); font-size: var(--fs); font-weight: 400; color: var(--text); }
.combo-opt { display: flex; flex-direction: column; justify-content: center; min-height: var(--tap); padding: 4px 10px; border-radius: 6px; cursor: pointer; box-sizing: border-box; }
.combo-opt small { color: var(--muted); font-size: var(--fs-xs); }
.combo-opt[aria-selected="true"] { background: var(--accent-soft); color: var(--accent); }
.combo-opt[data-current] { font-weight: 600; }
.combo-empty { padding: 10px; color: var(--muted); }
@media (min-width: 901px) and (pointer: fine) { .combo-opt { min-height: 36px; } }

/* Fiche client : précédent / suivant dans la liste filtrée */
.crumbs-bar { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.pager-mini { display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-sm); color: var(--muted); }
.pager-mini .btn { min-height: 34px; padding: 0 10px; font-size: var(--fs-sm); }
.pager-mini .btn svg { width: 16px; height: 16px; }
@media (max-width: 900px) { .pager-mini .btn { min-height: var(--tap); } }

/* Suggestions d'entreprises (création de client) */
.suggest-meta { color: var(--muted); font-size: var(--fs-xs); }
/* Filtres appliqués automatiquement : bouton d'envoi réservé à l'absence de JavaScript */
.filters[data-js] .filters-submit { display: none !important; }

/* Bandeau discret de la surveillance (incident en cours), en tête du contenu. */
.monitor-banner { display: flex; gap: 8px; align-items: flex-start; margin: 0 0 12px; padding: 8px 12px; font-size: var(--fs-xs); color: var(--hi-fg); background: var(--hi-bg); border: 1px solid var(--pill-border); border-left: 3px solid var(--hi-solid); border-radius: var(--radius-sm); }
.monitor-banner svg { flex: none; margin-top: 2px; }
.monitor-banner a { color: inherit; text-decoration: underline; }

/* ═══════════ Largeurs d'écran : du téléphone au 2560 px ═══════════
   - Conteneur principal fluide et centré (--content-max), marges latérales fluides (--shell-pad-x).
   - Menu latéral : déployé, ou réduit en icônes (« rail ») ; réduit automatiquement entre 901 et 1279 px
     sauf choix mémorisé (cookie lab_nav, bouton « Réduire le menu »). Téléphone/tablette : barre du bas + feuille.
   - .masonry : cartes réparties en 1 à 4 colonnes selon la place (tableaux de bord, pages de synthèse).
   - .list-layout : liste avec filtres ; sur très grand écran, les filtres passent en colonne latérale.
   - .form-measure : formulaire à largeur lisible ; .measure : texte à longueur de ligne lisible. */

/* Bouton « Réduire le menu » (barre latérale, ordinateur seulement) */
.navtoggle { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 38px; margin-top: auto; padding: 0 12px; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--nav-muted); font: inherit; font-size: var(--fs-sm); cursor: pointer; text-align: left; }
.navtoggle:hover { background: var(--nav-hover); color: var(--nav-text); }
.navtoggle svg { width: 18px; height: 18px; flex: none; }
.navtoggle + .navuser { margin-top: 6px; }
.sidenav :focus-visible { outline-color: var(--nav-active-mark); outline-offset: -2px; }
.navuser .avatar:hover { text-decoration: none; outline: 2px solid var(--nav-border); }

/* Menu réduit : choix mémorisé (data-nav="rail") */
.shell[data-nav="rail"] .sidenav { width: var(--nav-rail-w); padding: 14px 10px 10px; }
.shell[data-nav="rail"] .brand { justify-content: center; padding: 4px 0 14px; }
.shell[data-nav="rail"] .brand-name,
.shell[data-nav="rail"] .searchbtn kbd,
.shell[data-nav="rail"] .navtoggle-label,
.shell[data-nav="rail"] .navuser-id { display: none; }
.shell[data-nav="rail"] .searchbtn { justify-content: center; padding: 0; min-height: 40px; }
.shell[data-nav="rail"] .navgroups { gap: 8px; }
.shell[data-nav="rail"] .navgroup-title { height: 1px; padding: 0; margin: 0 10px 6px; overflow: hidden; color: transparent; background: var(--nav-border); }
.shell[data-nav="rail"] .navlink { justify-content: center; padding: 0; min-height: 40px; }
.shell[data-nav="rail"] :is(.navlabel, .searchbtn-label) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.shell[data-nav="rail"] .navcount { position: absolute; top: 1px; right: 2px; min-width: 17px; height: 17px; padding: 0 4px; font-size: 10px; }
.shell[data-nav="rail"] .sidenav .navlink[aria-current="page"]::before { left: -10px; }
.shell[data-nav="rail"] .navtoggle { justify-content: center; padding: 0; }
.shell[data-nav="rail"] .navuser { flex-direction: column; justify-content: center; gap: 6px; padding: 10px 0 0; }
/* Menu réduit automatiquement sur portable / petite fenêtre (901–1279 px), sauf menu déployé mémorisé */
@media (min-width: 901px) and (max-width: 1279.98px) {
  .shell:not([data-nav="full"]) .sidenav { width: var(--nav-rail-w); padding: 14px 10px 10px; }
  .shell:not([data-nav="full"]) .brand { justify-content: center; padding: 4px 0 14px; }
  .shell:not([data-nav="full"]) .brand-name,
  .shell:not([data-nav="full"]) .searchbtn kbd,
  .shell:not([data-nav="full"]) .navtoggle-label,
  .shell:not([data-nav="full"]) .navuser-id { display: none; }
  .shell:not([data-nav="full"]) .searchbtn { justify-content: center; padding: 0; min-height: 40px; }
  .shell:not([data-nav="full"]) .navgroups { gap: 8px; }
  .shell:not([data-nav="full"]) .navgroup-title { height: 1px; padding: 0; margin: 0 10px 6px; overflow: hidden; color: transparent; background: var(--nav-border); }
  .shell:not([data-nav="full"]) .navlink { justify-content: center; padding: 0; min-height: 40px; }
  .shell:not([data-nav="full"]) :is(.navlabel, .searchbtn-label) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .shell:not([data-nav="full"]) .navcount { position: absolute; top: 1px; right: 2px; min-width: 17px; height: 17px; padding: 0 4px; font-size: 10px; }
  .shell:not([data-nav="full"]) .sidenav .navlink[aria-current="page"]::before { left: -10px; }
  .shell:not([data-nav="full"]) .navtoggle { justify-content: center; padding: 0; }
  .shell:not([data-nav="full"]) .navuser { flex-direction: column; justify-content: center; gap: 6px; padding: 10px 0 0; }
}
/* Écran peu haut (portable 1366×768, 1280×720…) : menu plus serré pour éviter le défilement */
@media (min-width: 901px) and (max-height: 820px) {
  .sidenav { padding-top: 10px; padding-bottom: 8px; }
  .sidenav .brand { padding-bottom: 10px; }
  .sidenav .searchbtn { margin-bottom: 8px; min-height: 34px; }
  .sidenav .navgroups { gap: 6px; }
  .sidenav .navgroup-title { padding-bottom: 2px; }
  .sidenav .navlink { min-height: 32px; }
  .sidenav .navtoggle { min-height: 32px; }
  .sidenav .navuser { padding-top: 8px; }
  .sidenav .avatar { width: 32px; height: 32px; }
}

/* Style B (menu en haut) : marque, recherche et profil sur une ligne, menu sur sa propre ligne sans retour à la
   ligne (défilement horizontal discret si la fenêtre est étroite) ; tout sur une seule ligne sur très grand écran. */
[data-theme="B"] .topnav { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; grid-template-areas: "brand . search avatar" "nav nav nav nav"; align-items: center; gap: 8px 12px; padding-top: 10px; padding-bottom: 6px; }
[data-theme="B"] .topnav > .brand { grid-area: brand; }
[data-theme="B"] .topnav > nav { grid-area: nav; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 calc(-1 * var(--shell-pad-x)); padding: 0 var(--shell-pad-x) 4px; }
[data-theme="B"] .topnav > nav::-webkit-scrollbar { display: none; }
[data-theme="B"] .topnav > .searchbtn { grid-area: search; }
[data-theme="B"] .topnav > .avatar { grid-area: avatar; }
[data-theme="B"] .topnav .navlink { flex: none; white-space: nowrap; }
@media (min-width: 901px) and (max-width: 1439.98px) {
  [data-theme="B"] .topnav .navlink { font-size: var(--fs-sm); }
}
@media (min-width: 901px) and (max-width: 2199.98px) {
  [data-theme="B"] .topnav > nav { -webkit-mask-image: linear-gradient(to right, black calc(100% - 48px), transparent); mask-image: linear-gradient(to right, black calc(100% - 48px), transparent); padding-right: 48px; }
}
@media (min-width: 2200px) {
  [data-theme="B"] .topnav { grid-template-columns: auto minmax(0, 1fr) auto auto; grid-template-areas: "brand nav search avatar"; padding-top: 12px; padding-bottom: 12px; }
  [data-theme="B"] .topnav > nav { margin: 0; padding: 0; }
}

/* Cartes réparties en colonnes (ordre conservé de haut en bas, aucune carte coupée) */
.masonry { columns: 4 400px; column-gap: var(--gap); }
.masonry > * { break-inside: avoid; margin-bottom: var(--gap); }
.masonry > :last-child { margin-bottom: 0; }
.masonry > :empty { display: none; }

/* Liste + filtres : filtres en colonne latérale quand la place le permet */
.list-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--gap); align-items: start; }
.list-layout > .list-main-col { display: flex; flex-direction: column; gap: var(--gap); min-width: 0; }
@container main (min-width: 1480px) {
  .list-layout { grid-template-columns: 280px minmax(0, 1fr); }
  .list-layout > .filters { grid-template-columns: minmax(0, 1fr); position: sticky; top: var(--shell-pad-y); padding: var(--pad); }
  .list-layout > .filters > .field.grow { grid-column: 1 / -1; }
}

/* Formulaires et textes : largeur lisible, même sur grand écran */
.form-measure { max-width: var(--form-max); }
.measure { max-width: var(--measure); }
.page-head p { max-width: var(--measure); }
.card-body > p, .card-body > .muted, .notice > p { max-width: var(--measure); }
.card-body > p.muted:only-child, .card-body > .muted:only-child { max-width: none; }
.stack > .field:not(:has(textarea)) { max-width: 640px; }

/* Grands écrans : plus d'indicateurs par ligne, texte légèrement plus grand (sauf styles à tailles propres) */
@container main (min-width: 1500px) {
  .grid-kpi.auto { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
}
@media (min-width: 1800px) {
  :root:is([data-theme="CABINET"], [data-theme="NUIT"], [data-theme="A"], [data-theme="B"]) { --fs: 15px; --fs-sm: 14px; --fs-xs: 12.5px; --fs-md: 16px; }
  :root[data-theme="C"] { --fs: 14px; --fs-md: 14px; }
  .kpi-value { font-size: 34px; }
}
.stack .field > input:is([type="number"], [type="date"], [type="month"]) { max-width: 260px; }
/* Boutons et noms courts d'un tableau : jamais coupés sur deux lignes (la colonne de texte long absorbe la place). */
.table td .btn { white-space: nowrap; }
.nowrap { white-space: nowrap; }

.empty svg.empty-warn { color: var(--hi-solid); }
/* Cartes de même rang (raccourcis, synthèses) : autant de colonnes que la place le permet, hauteurs alignées */
.grid-auto { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 360px), 1fr)); gap: var(--gap); }
.grid-auto > .card { display: flex; flex-direction: column; }
.grid-auto > .card > .card-body { flex: 1; }
/* Mode cartes : un bouton peut passer à la ligne ; tableau simple dans un conteneur étroit : en-têtes sur deux lignes */
@container (max-width: 799.98px) { .table.responsive td .btn { white-space: normal; text-align: center; } .table.responsive td > * { min-width: 0; } }
@container (max-width: 479.98px) { .table th { white-space: normal; } .table:not(.responsive) :is(th, td) { padding-inline: 6px; } }
@container (max-width: 799.98px) { .table.responsive.cards-grid td { min-width: 0; } .table.responsive.cards-grid td > .cell-main { max-width: 100%; } }
/* Liens dans un texte courant : soulignés (pas seulement la couleur, WCAG 1.4.1). Menus, boutons, pastilles,
   listes de navigation et titres de liste gardent leur apparence. */
:where(p, dd, blockquote, .notice, .error, .success, .kpi-sub, .cell-sub, .muted, .small, .list-sub) a:not(.btn):not(.pill):not(.list-row),
:where(ul:not(.list), ol):not(nav *) > li > a:not(.btn):not(.pill) { text-decoration: underline; text-underline-offset: 2px; }

/* ═══════════ Propre à l'espace factures (mêmes variables que LAB) ═══════════ */
.pdf-frame { width: 100%; min-height: min(78vh, 900px); border: 1px solid var(--border); border-radius: var(--radius-sm); background: #FFFFFF; }
@media (max-width: 900px) { .pdf-frame { min-height: 60vh; } }
.histog { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 4px; height: 120px; align-items: end; }
.colh { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 4px; height: 100%; }
.colh i { display: block; width: 100%; background: var(--border-soft); border-radius: 4px 4px 2px 2px; }
.colh i.act { background: var(--accent); }
.colh span { font-size: var(--fs-xs); color: var(--muted); }
.table tr.choisi td { background: var(--accent-soft); }
.table tr.choisi td.primary { box-shadow: inset 3px 0 0 var(--accent); }
.list-layout > .card.filters:first-child + .list-main-col { min-width: 0; }
details > summary { list-style: none; }
details > summary::-webkit-details-marker { display: none; }
.facts dd b { font-weight: 700; }
/* Décision sur téléphone : les deux boutons restent à portée du pouce, au-dessus de la barre d'onglets */
@media (max-width: 900px) {
  .decision { position: sticky; bottom: calc(var(--tabbar-h) + 8px + env(safe-area-inset-bottom, 0px)); z-index: 5; background: var(--surface); padding: 8px 0; }
  .decision .btn { flex: 1 1 0; }
}
