/* Sid Transit Logistics — feuille de style de l'application.
   Palette tirée du logo : bleu nuit #0B1E3D, vert logistique #479C5A, bleu d'action
   #1D5FA8, fond clair #F4F7FB. Le vert sert à la marque (menu actif, accueil) ; les
   statuts gardent leurs propres couleurs (succès, attention, danger). */

:root {
  color-scheme: light;
  --marine: #0B1E3D;
  --marine-2: #14305C;
  --bleu: #1D5FA8;
  --accent: #479C5A;
  --accent-texte: #2F7A43;
  --bleu-clair: #e3eef8;
  --ciel: #a9dcc6;
  --fond: #f4f7fb;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --surface-3: #eef3f9;
  --texte: #142033;
  --texte-2: #4a5a70;
  --texte-3: #6b7a8f;
  --bord: #dce4ee;
  --bord-fort: #c4d1e1;
  --ok: #15803d;
  --ok-fond: #e7f6ec;
  --attention: #a15c07;
  --attention-fond: #fdf3e2;
  --danger: #b42318;
  --danger-fond: #fdecea;
  --info-fond: #e8f1fb;
  --ombre: 0 1px 2px rgba(11, 30, 61, .06), 0 4px 16px rgba(11, 30, 61, .06);
  --ombre-forte: 0 12px 40px rgba(11, 30, 61, .18);
  --rayon: 10px;
  --rayon-petit: 7px;
  --menu-fond: #0B1E3D;
  --menu-texte: #c9d8ea;
  --menu-actif: #ffffff;
  --serie-1: #1D5FA8;
  --serie-2: #479C5A;
  --grille: #e6ecf3;
  --police: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bleu: #4da3e8;
    --bleu-clair: #13314f;
    --fond: #0a1422;
    --surface: #101d30;
    --surface-2: #13233a;
    --surface-3: #182b45;
    --texte: #e6edf6;
    --texte-2: #b3c1d3;
    --texte-3: #8798ad;
    --bord: #22354f;
    --bord-fort: #2e4563;
    --ok: #4ade80;
    --ok-fond: #0f2e1d;
    --attention: #f6b34a;
    --attention-fond: #33250d;
    --danger: #f87171;
    --danger-fond: #3a1515;
    --info-fond: #112a45;
    --menu-fond: #08162d;
    --accent: #6CC17E;
    --accent-texte: #6CC17E;
    --serie-1: #4d8fe0;
    --serie-2: #6cc17e;
    --grille: #1d2f47;
    --ombre: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bleu: #4da3e8;
  --bleu-clair: #13314f;
  --fond: #0a1422;
  --surface: #101d30;
  --surface-2: #13233a;
  --surface-3: #182b45;
  --texte: #e6edf6;
  --texte-2: #b3c1d3;
  --texte-3: #8798ad;
  --bord: #22354f;
  --bord-fort: #2e4563;
  --ok: #4ade80;
  --ok-fond: #0f2e1d;
  --attention: #f6b34a;
  --attention-fond: #33250d;
  --danger: #f87171;
  --danger-fond: #3a1515;
  --info-fond: #112a45;
  --menu-fond: #08162d;
  --serie-1: #4d8fe0;
  --serie-2: #6cc17e;
  --grille: #1d2f47;
  --ombre: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
  --accent: #6CC17E;
  --accent-texte: #6CC17E;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.5 var(--police); color: var(--texte); background: var(--fond); -webkit-font-smoothing: antialiased; }
a { color: var(--bleu); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0; }
h2 { font-size: 16px; font-weight: 650; }
h3 { font-size: 14px; font-weight: 650; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--bleu); outline-offset: 2px; }
.noscript { padding: 24px; }

/* Logos selon le thème */
.logo-sombre-seul { display: none; }
:root[data-theme="dark"] .logo-clair-seul { display: none; }
:root[data-theme="dark"] .logo-sombre-seul { display: inline; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .logo-clair-seul { display: none; }
  :root:not([data-theme="light"]) .logo-sombre-seul { display: inline; }
}

/* ---------- Démarrage, connexion ---------- */
.demarrage { position: fixed; inset: 0; display: grid; place-content: center; justify-items: center; gap: 22px; background: var(--fond); }
.demarrage img { width: min(320px, 70vw); height: auto; }
.chargeur { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--bord); border-top-color: var(--accent); animation: tourne .8s linear infinite; }
@keyframes tourne { to { transform: rotate(360deg); } }

.porte { min-height: 100%; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); }
.porte-visuel { background: linear-gradient(155deg, #0B1E3D 0%, #102a52 58%, #0d4a45 100%); color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.porte-visuel::after { content: ""; position: absolute; right: -120px; bottom: -120px; width: 420px; height: 420px; border-radius: 50%; border: 60px solid rgba(71, 156, 90, .14); }
.porte-visuel img { width: 380px; max-width: 85%; }
.porte-visuel h2 { font-size: 28px; font-weight: 600; max-width: 460px; line-height: 1.25; margin: 40px 0 12px; }
.porte-visuel p { color: #c9d8ea; max-width: 440px; }
.porte-visuel ul { list-style: none; padding: 0; margin: 24px 0 0; display: grid; gap: 8px; color: #dbe7f5; }
.porte-visuel li::before { content: "—"; color: var(--accent); margin-right: 8px; }
.porte-formulaire { display: grid; place-content: center; padding: 32px 20px; background: var(--surface); }
.porte-formulaire form { width: min(380px, 90vw); display: grid; gap: 14px; }
.porte-formulaire h1 { font-size: 24px; font-weight: 650; }
.porte-formulaire .sous { color: var(--texte-3); margin-top: -6px; }
.porte-logo-mobile { display: none; width: 220px; margin-bottom: 8px; }
@media (max-width: 860px) {
  .porte { grid-template-columns: 1fr; }
  .porte-visuel { display: none; }
  .porte-logo-mobile { display: block; }
}

/* ---------- Mise en page ---------- */
.appli { display: grid; grid-template-columns: 252px minmax(0, 1fr); min-height: 100%; }
.menu { background: var(--menu-fond); color: var(--menu-texte); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow: hidden; }
.menu-marque { display: block; padding: 20px 18px 14px; }
.menu-marque img { width: 100%; max-width: 230px; height: auto; display: block; }
.menu-liens { flex: 1; overflow-y: auto; padding: 4px 10px 16px; scrollbar-width: thin; scrollbar-color: #2b4a70 transparent; }
.menu-groupe { margin-top: 14px; }
.menu-groupe > span { display: block; padding: 0 10px 4px; font-size: 10.5px; letter-spacing: .09em; text-transform: uppercase; color: #7f9ab8; font-weight: 600; }
.menu-lien { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--menu-texte); font-weight: 500; white-space: nowrap; overflow: hidden; }
.menu-lien span.libelle { overflow: hidden; text-overflow: ellipsis; }
.menu-lien:hover { background: rgba(255, 255, 255, .07); color: #fff; text-decoration: none; }
.menu-lien.actif { background: rgba(71, 156, 90, .16); color: var(--menu-actif); box-shadow: inset 3px 0 0 var(--accent); }
.menu-lien svg { width: 18px; height: 18px; flex: none; opacity: .9; }
.menu-lien .compteur { margin-left: auto; background: #b42318; color: #fff; border-radius: 10px; font-size: 11px; padding: 0 7px; font-weight: 600; }
.menu-pied { padding: 12px 18px 16px; font-size: 11.5px; color: #7f9ab8; border-top: 1px solid rgba(255, 255, 255, .08); }
.principal { min-width: 0; display: flex; flex-direction: column; }
.barre-haut { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 14px; padding: 10px 24px; background: color-mix(in srgb, var(--fond) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--bord); min-height: 60px; }
.titre-page { font-size: 18px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.barre-haut .menu-bouton { display: none; }
.recherche-globale { margin-left: auto; display: flex; align-items: center; gap: 8px; min-width: 0; width: min(420px, 40vw); padding: 7px 12px; background: var(--surface); border: 1px solid var(--bord); border-radius: 9px; color: var(--texte-3); cursor: pointer; text-align: left; }
.recherche-globale .texte { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.recherche-globale kbd { font: 11px var(--police); border: 1px solid var(--bord); border-radius: 5px; padding: 1px 6px; background: var(--surface-2); }
.recherche-globale:hover { border-color: var(--bord-fort); }
.profil { position: relative; }
.profil-bouton { display: flex; align-items: center; gap: 8px; background: none; border: 0; cursor: pointer; padding: 4px 6px; border-radius: 8px; }
.profil-bouton:hover { background: var(--surface-3); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--marine); color: #fff; display: grid; place-content: center; font-weight: 650; font-size: 12.5px; }
.profil-nom { text-align: left; line-height: 1.2; }
.profil-nom small { display: block; color: var(--texte-3); font-size: 11.5px; }
.vue { padding: 22px 24px 48px; min-width: 0; outline: none; }
.voile { position: fixed; inset: 0; background: rgba(2, 20, 40, .45); z-index: 40; }
@media (max-width: 1080px) {
  .appli { grid-template-columns: 1fr; }
  .menu { position: fixed; left: 0; top: 0; bottom: 0; width: 272px; z-index: 50; transform: translateX(-100%); transition: transform .2s; }
  .menu.ouvert { transform: none; box-shadow: var(--ombre-forte); }
  .barre-haut .menu-bouton { display: inline-grid; }
  .profil-nom { display: none; }
}
@media (max-width: 640px) {
  .barre-haut { padding: 8px 12px; gap: 8px; }
  .recherche-globale { width: auto; flex: 0 0 auto; }
  .recherche-globale .texte, .recherche-globale kbd { display: none; }
  .vue { padding: 16px 12px 40px; }
  .titre-page { font-size: 16px; }
}

/* ---------- Éléments ---------- */
.carte { background: var(--surface); border: 1px solid var(--bord); border-radius: var(--rayon); box-shadow: var(--ombre); }
.carte-corps { padding: 16px 18px; }
.carte-tete { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--bord); flex-wrap: wrap; }
.carte-tete h2 { flex: 1 1 220px; min-width: 0; }
.carte + .carte, .carte + .grille, .grille + .carte, .grille + .grille { margin-top: 16px; }
.grille > .carte, .grille > .grille, .grille > * { margin-top: 0; min-width: 0; }
.carte { min-width: 0; overflow-wrap: anywhere; }
.carte > table.liste { display: block; overflow-x: auto; }
.grille { display: grid; gap: 16px; }
.grille-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grille-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grille-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1180px) { .grille-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grille-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 760px) { .grille-2, .grille-3, .grille-4 { grid-template-columns: 1fr; } }

.entete-page { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.entete-page .titre { flex: 1; min-width: 220px; }
.entete-page h2 { font-size: 20px; font-weight: 650; }
.entete-page .sous { color: var(--texte-3); margin-top: 2px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.bouton { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 7px 14px; border-radius: 8px; border: 1px solid var(--bord-fort); background: var(--surface); color: var(--texte); font-weight: 550; cursor: pointer; white-space: nowrap; min-height: 36px; }
.bouton:hover { background: var(--surface-3); text-decoration: none; }
.bouton.principal { background: var(--marine); border-color: var(--marine); color: #fff; }
.bouton.principal:hover { background: var(--marine-2); }
:root[data-theme="dark"] .bouton.principal { background: #1a62b0; border-color: #1a62b0; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .bouton.principal { background: #1a62b0; border-color: #1a62b0; } }
.bouton.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.bouton.discret { border-color: transparent; background: transparent; color: var(--bleu); }
.bouton.discret:hover { background: var(--bleu-clair); }
.bouton.petit { padding: 4px 10px; min-height: 30px; font-size: 13px; }
.bouton:disabled { opacity: .55; cursor: not-allowed; }
.bouton-icone { display: inline-grid; place-content: center; width: 36px; height: 36px; border-radius: 8px; border: 1px solid transparent; background: transparent; cursor: pointer; font-size: 18px; color: var(--texte-2); }
.bouton-icone:hover { background: var(--surface-3); }
.lien-danger { color: var(--danger); background: none; border: 0; cursor: pointer; font-weight: 550; }

/* Formulaires */
.champ { display: grid; gap: 4px; min-width: 0; }
.champ > span { font-size: 12.5px; font-weight: 600; color: var(--texte-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.champ > span .requis { color: var(--danger); }
.champ small { color: var(--texte-3); font-size: 12px; }
input, select, textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--bord-fort); border-radius: var(--rayon-petit); background: var(--surface); min-height: 38px; }
textarea { min-height: 74px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--bleu); box-shadow: 0 0 0 3px color-mix(in srgb, var(--bleu) 22%, transparent); }
input[readonly] { background: var(--surface-2); }
input[type="checkbox"], input[type="radio"] { width: 16px; height: 16px; min-height: 0; accent-color: var(--bleu); }
.case { display: flex; align-items: center; gap: 8px; font-weight: 500; cursor: pointer; }
.formulaire { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 12px 14px; }
.formulaire > * { grid-column: span 6; }
.formulaire .l3 { grid-column: span 3; } .formulaire .l4 { grid-column: span 4; } .formulaire .l12 { grid-column: 1 / -1; } .formulaire .l8 { grid-column: span 8; } .formulaire .l6 { grid-column: span 6; }
.formulaire .titre-section { grid-column: 1 / -1; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--bleu); font-weight: 700; margin-top: 6px; padding-top: 10px; border-top: 1px solid var(--bord); }
@media (max-width: 760px) { .formulaire > *, .formulaire .l3, .formulaire .l4, .formulaire .l6, .formulaire .l8 { grid-column: 1 / -1; } }
.message-erreur { background: var(--danger-fond); color: var(--danger); border-radius: 8px; padding: 9px 12px; margin: 10px 0 0; white-space: pre-line; }

/* Filtres et tableaux */
.filtres { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; padding: 12px 16px; border-bottom: 1px solid var(--bord); }
.filtres .champ { min-width: 140px; flex: 0 1 180px; }
.filtres .champ.large { flex: 1 1 260px; }
.filtres input, .filtres select { min-height: 34px; padding: 6px 9px; }
.tableau-boite { overflow-x: auto; }
table.liste { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
table.liste th { position: sticky; top: 0; text-align: left; font-size: 12px; font-weight: 650; color: var(--texte-2); background: var(--surface-2); padding: 9px 12px; border-bottom: 1px solid var(--bord); white-space: nowrap; }
table.liste th.triable { cursor: pointer; user-select: none; }
table.liste th.triable:hover { color: var(--bleu); }
table.liste th .fleche { font-size: 10px; margin-left: 4px; color: var(--bleu); }
table.liste td { padding: 9px 12px; border-bottom: 1px solid var(--bord); vertical-align: middle; max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.liste td.renvoi, table.liste td.multi { white-space: normal; }
table.liste td.multi { min-width: 150px; }
.attention-texte { color: var(--attention); }
table.liste td.boutons { max-width: none; overflow: visible; white-space: nowrap; }
table.liste tbody tr:hover td { background: var(--surface-2); }
table.liste tbody tr.cliquable { cursor: pointer; }
table.liste tbody tr.selection td { background: var(--bleu-clair); }
table.liste .n { text-align: right; font-variant-numeric: tabular-nums; }
table.liste tfoot td { font-weight: 650; background: var(--surface-2); border-top: 1px solid var(--bord-fort); }
table.liste .col-case { width: 34px; }
.pagination { display: flex; align-items: center; gap: 10px; padding: 10px 16px; color: var(--texte-3); font-size: 13px; flex-wrap: wrap; }
.pagination .espace { flex: 1; }
.vide { padding: 32px 16px; text-align: center; color: var(--texte-3); }
.vide strong { display: block; color: var(--texte-2); margin-bottom: 4px; font-size: 15px; }
.barre-selection { display: flex; gap: 10px; align-items: center; padding: 8px 16px; background: var(--bleu-clair); border-bottom: 1px solid var(--bord); font-weight: 550; flex-wrap: wrap; }

/* Pastilles */
.pastille { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-3); color: var(--texte-2); white-space: nowrap; }
.pastille::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.pastille.sans-point::before { display: none; }
.pastille.ok { background: var(--ok-fond); color: var(--ok); }
.pastille.attention { background: var(--attention-fond); color: var(--attention); }
.pastille.danger { background: var(--danger-fond); color: var(--danger); }
.pastille.info { background: var(--info-fond); color: var(--bleu); }
.pastille.marine { background: var(--marine); color: #fff; }
.etiquette-op { font-size: 11px; font-weight: 700; letter-spacing: .04em; padding: 2px 7px; border-radius: 5px; }
.etiquette-op.import { background: #e4edf8; color: #1D5FA8; }
.etiquette-op.export { background: #fdecdf; color: #b4501f; }
.etiquette-op.vide { background: #eceff3; color: #4a5a70; }
:root[data-theme="dark"] .etiquette-op.import { background: #13314f; color: #7cc0f5; }
:root[data-theme="dark"] .etiquette-op.export { background: #3a2212; color: #f4a06c; }
:root[data-theme="dark"] .etiquette-op.vide { background: #1d2b3e; color: #b3c1d3; }

/* Indicateurs */
.indicateur { padding: 14px 16px; display: grid; gap: 4px; position: relative; }
.indicateur .libelle { font-size: 12.5px; color: var(--texte-3); font-weight: 600; }
.indicateur .valeur { font-size: 24px; font-weight: 700; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.indicateur .valeur small { font-size: 13px; font-weight: 600; color: var(--texte-3); }
.indicateur .detail { font-size: 12.5px; color: var(--texte-3); }
.indicateur.alerte .valeur { color: var(--danger); }
.indicateur a.recouvrir { position: absolute; inset: 0; }
.indicateur.lien:hover { background: var(--surface-2); }

/* Fiches */
.fiche-entete { display: flex; gap: 14px; align-items: flex-start; flex-wrap: wrap; margin-bottom: 14px; }
.fiche-entete .titre { flex: 1; min-width: 240px; }
.fiche-entete h2 { font-size: 22px; font-weight: 700; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.fiche-entete .sous { color: var(--texte-3); margin-top: 4px; }
.retour { display: inline-flex; gap: 6px; align-items: center; color: var(--texte-3); font-size: 13px; margin-bottom: 8px; }
dl.infos { display: grid; grid-template-columns: minmax(120px, 38%) minmax(0, 1fr); gap: 7px 12px; margin: 0; }
dl.infos dt { color: var(--texte-3); font-size: 13px; }
dl.infos dd { margin: 0; font-weight: 550; overflow-wrap: anywhere; }
.onglets { display: flex; gap: 2px; border-bottom: 1px solid var(--bord); margin-bottom: 16px; overflow-x: auto; scrollbar-width: thin; }
.onglets button, .onglets a { padding: 9px 14px; border: 0; background: none; cursor: pointer; color: var(--texte-3); font-weight: 600; border-bottom: 2px solid transparent; white-space: nowrap; }
.onglets .actif { color: var(--bleu); border-bottom-color: var(--bleu); }
.onglets a:hover { text-decoration: none; color: var(--texte); }

/* Étapes du dossier */
.frise { display: flex; gap: 0; overflow-x: auto; padding: 6px 2px 2px; }
.frise .pas { flex: 1 0 86px; position: relative; text-align: center; font-size: 11.5px; line-height: 1.25; color: var(--texte-3); padding-top: 26px; }
.frise .pas::before { content: ""; position: absolute; top: 10px; left: 0; right: 0; height: 3px; background: var(--bord); }
.frise .pas:first-child::before { left: 50%; } .frise .pas:last-child::before { right: 50%; }
.frise .pas .rond { position: absolute; top: 3px; left: calc(50% - 9px); width: 18px; height: 18px; border-radius: 50%; background: var(--surface); border: 3px solid var(--bord-fort); z-index: 1; }
.frise .pas.fait { color: var(--texte-2); }
.frise .pas.fait::before { background: var(--bleu); }
.frise .pas.fait .rond { background: var(--bleu); border-color: var(--bleu); }
.frise .pas.courant { color: var(--texte); font-weight: 650; }
.frise .pas.courant .rond { border-color: var(--bleu); box-shadow: 0 0 0 4px color-mix(in srgb, var(--bleu) 25%, transparent); }

/* Alertes */
.alertes { display: grid; gap: 6px; }
.alerte-ligne { display: flex; gap: 10px; align-items: flex-start; padding: 8px 12px; border-radius: 8px; background: var(--surface-2); border-left: 3px solid var(--bord-fort); font-size: 13.5px; }
.alerte-ligne.haute { border-left-color: var(--danger); background: var(--danger-fond); }
.alerte-ligne.moyenne { border-left-color: var(--attention); background: var(--attention-fond); }
.alerte-ligne .quoi { flex: 1; min-width: 0; }
.encadre { padding: 10px 14px; border-radius: 8px; background: var(--info-fond); color: var(--texte-2); font-size: 13.5px; }
.encadre.attention { background: var(--attention-fond); color: var(--attention); }
.encadre.danger { background: var(--danger-fond); color: var(--danger); }

/* Fenêtres */
dialog.dialogue { border: 0; padding: 0; border-radius: 14px; box-shadow: var(--ombre-forte); width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 32px); background: var(--surface); color: var(--texte); }
dialog.dialogue.large { width: min(900px, calc(100vw - 24px)); }
dialog.dialogue.tres-large { width: min(1180px, calc(100vw - 24px)); }
dialog::backdrop { background: rgba(2, 20, 40, .5); backdrop-filter: blur(2px); }
.dialogue-corps { display: flex; flex-direction: column; max-height: calc(100vh - 32px); }
.dialogue-tete { display: flex; align-items: center; gap: 10px; padding: 16px 20px 12px; border-bottom: 1px solid var(--bord); }
.dialogue-tete h2 { flex: 1; font-size: 17px; }
.dialogue-contenu { padding: 16px 20px; overflow-y: auto; }
.dialogue-corps > .message-erreur { margin: 0 20px 10px; }
.dialogue-corps .actions { padding: 12px 20px 16px; border-top: 1px solid var(--bord); justify-content: flex-end; }
.dialogue-corps p { margin: 0 0 10px; }

/* Messages */
.toasts { position: fixed; right: 18px; bottom: 18px; display: grid; gap: 8px; z-index: 100; max-width: min(420px, calc(100vw - 36px)); }
.toast { background: var(--marine); color: #fff; padding: 11px 16px; border-radius: 10px; box-shadow: var(--ombre-forte); transition: opacity .3s, transform .3s; }
.toast-erreur { background: #8f1d13; }
.toast-succes { background: #116132; }
.toast.sortie { opacity: 0; transform: translateY(8px); }

/* Recherche globale */
.recherche-resultats { display: grid; gap: 2px; margin-top: 10px; max-height: 60vh; overflow-y: auto; }
.recherche-resultats a { display: flex; gap: 10px; align-items: center; padding: 9px 10px; border-radius: 8px; color: var(--texte); }
.recherche-resultats a:hover, .recherche-resultats a.actif { background: var(--bleu-clair); text-decoration: none; }
.recherche-resultats .type { font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--texte-3); width: 92px; flex: none; font-weight: 700; }
.recherche-resultats .detail { color: var(--texte-3); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Graphiques */
.graphique { position: relative; }
.graphique svg { display: block; width: 100%; height: auto; overflow: visible; }
.graphique .axe { font-size: 11px; fill: var(--texte-3); }
.graphique .grille-ligne { stroke: var(--grille); stroke-width: 1; }
.legende { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--texte-2); }
.legende span { display: inline-flex; align-items: center; gap: 6px; }
.legende i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.infobulle { position: fixed; z-index: 120; pointer-events: none; background: var(--surface); color: var(--texte); border: 1px solid var(--bord-fort); border-radius: 8px; box-shadow: var(--ombre-forte); padding: 8px 10px; font-size: 12.5px; max-width: 260px; }
.infobulle strong { display: block; margin-bottom: 2px; }
.barre-h { display: grid; grid-template-columns: minmax(90px, 32%) minmax(0, 1fr) auto; gap: 10px; align-items: center; font-size: 13px; padding: 4px 0; }
.barre-h .piste { height: 14px; position: relative; }
.barre-h .plein { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 0 4px 4px 0; background: var(--serie-1); min-width: 2px; }
.barre-h .nom { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--texte-2); }
.barre-h .val { text-align: right; font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; min-width: 36px; }

/* Divers */
.muet { color: var(--texte-3); }
.petit { font-size: 12.5px; }
.gras { font-weight: 650; }
.mono { font-family: Consolas, "Cascadia Mono", monospace; font-size: 13px; }
.droite { text-align: right; }
.positif { color: var(--ok); }
.negatif { color: var(--danger); }
.sep { height: 1px; background: var(--bord); margin: 14px 0; }
.ligne-flex { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.espace { flex: 1; }
.pieces-liste { display: grid; gap: 6px; }
.piece { display: flex; gap: 10px; align-items: center; padding: 7px 10px; border: 1px solid var(--bord); border-radius: 8px; }
.piece .nom { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chronologie { display: grid; gap: 0; }
.chronologie .evt { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 10px; padding: 7px 0; border-bottom: 1px dashed var(--bord); font-size: 13px; }
.chronologie .evt .quand { color: var(--texte-3); }
.permissions { display: grid; gap: 6px; }
.permissions .ligne-module { display: grid; grid-template-columns: minmax(160px, 260px) 1fr; gap: 10px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--bord); }
.permissions .actions-module { display: flex; gap: 12px; flex-wrap: wrap; }
.etape-couleur { width: 10px; height: 10px; border-radius: 50%; display: inline-block; margin-right: 6px; vertical-align: middle; }
.lignes-saisie table { width: 100%; border-collapse: collapse; }
.lignes-saisie td, .lignes-saisie th { padding: 4px; text-align: left; font-size: 12.5px; }
.lignes-saisie input, .lignes-saisie select { min-height: 32px; padding: 5px 7px; }
.totaux-saisie { display: grid; justify-content: end; gap: 3px; margin-top: 8px; text-align: right; font-variant-numeric: tabular-nums; }
.totaux-saisie .ttc { font-size: 17px; font-weight: 700; }
.plan-mois { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
@media (max-width: 760px) { .plan-mois { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.mois { border: 1px solid var(--bord); border-radius: 8px; padding: 8px; font-size: 12.5px; }
.mois.cloturee { background: var(--ok-fond); border-color: transparent; }
.cache-sm { }
@media (max-width: 640px) { .cache-sm { display: none !important; } }
.pile-cartes { display: grid; gap: 16px; }
.code-secours { font: 700 24px/1.2 ui-monospace, Consolas, monospace; letter-spacing: 2px; text-align: center; padding: 14px; border: 2px dashed var(--accent); border-radius: var(--rayon); background: var(--surface-2); user-select: all; }
button.lien { background: none; border: 0; padding: 0; color: var(--bleu); text-decoration: underline; cursor: pointer; font: inherit; min-height: 0; }
.piece.ancienne { opacity: .55; }
.piece .nom { display: flex; flex-direction: column; min-width: 0; }
.piece .nom a { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.actions-ligne { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

/* ---------- SID AI ---------- */
.sid-ai { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 16px; align-items: start; }
.sid-ai-historique .carte-corps { display: flex; flex-direction: column; gap: 4px; max-height: 70vh; overflow-y: auto; }
.sid-ai-conv { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; background: none; border: 1px solid transparent; border-radius: var(--rayon-petit); padding: 8px 10px; color: var(--texte); cursor: pointer; font: inherit; }
.sid-ai-conv:hover { background: var(--surface-2); }
.sid-ai-conv.actif { background: var(--bleu-clair); border-color: var(--bord); }
.sid-ai-fil > .carte-corps { min-height: 50vh; max-height: 68vh; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.sid-ai-msg { display: flex; }
.sid-ai-msg.moi { justify-content: flex-end; }
.sid-ai-msg .bulle { max-width: 82%; background: var(--surface-2); border: 1px solid var(--bord); border-radius: var(--rayon); padding: 10px 12px; }
.sid-ai-msg.moi .bulle { background: var(--marine); color: #fff; border-color: var(--marine); }
.sid-ai-texte { white-space: pre-wrap; line-height: 1.5; }
.sid-ai-saisie { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--bord); align-items: flex-end; }
.sid-ai-saisie textarea { flex: 1; resize: vertical; min-height: 44px; }
.sid-ai-suggestions { display: flex; flex-wrap: wrap; gap: 6px; }
.puce { background: var(--surface); border: 1px solid var(--bord-fort); border-radius: 16px; padding: 5px 12px; font: inherit; font-size: 13px; color: var(--texte); cursor: pointer; text-align: left; }
.puce:hover { border-color: var(--bleu); color: var(--bleu); }
.sid-ai-accueil { display: flex; flex-direction: column; gap: 12px; }
@media (max-width: 900px) {
  .sid-ai { grid-template-columns: 1fr; }
  .sid-ai-historique { order: 2; }
  .sid-ai-msg .bulle { max-width: 100%; }
}
