/* =====================================================================
   STE LAHLAL SAMU PLUS — feuille de style de l'application

   Parti pris visuel : une salle de regulation. L'interface est dense,
   calme, lisible de loin, et reserve la couleur a ce qui porte une
   information — un statut, une alerte, un ecart de montant. Le rouge
   d'urgence identifie la societe ; le cyan signale le sanitaire ;
   l'ambre, l'attente d'une piece.

   Aucune ressource externe n'est chargee : la politique de securite du
   contenu interdit toute origine tierce.
   ===================================================================== */

/* ------------------------------------------------------------------ */
/*  1. Jetons de couleur                                               */
/* ------------------------------------------------------------------ */

:root {
  color-scheme: light;

  --encre: #101822;
  --encre-douce: #46536a;
  --encre-faible: #6e7c93;

  --fond: #eef1f6;
  --surface: #ffffff;
  --surface-2: #f6f8fb;
  --surface-3: #eceff5;
  --surface-active: #e3e9f3;

  --trait: #dbe1ea;
  --trait-fort: #c3ccd9;

  --accent: #c8102e;
  --accent-clair: #e14257;
  --accent-doux: rgba(200, 16, 46, .09);
  --accent-contraste: #ffffff;

  --info: #1668b8;      --info-doux: rgba(22, 104, 184, .10);
  --succes: #0a7d55;    --succes-doux: rgba(10, 125, 85, .11);
  --attente: #a55b00;   --attente-doux: rgba(165, 91, 0, .11);
  --danger: #b4162c;    --danger-doux: rgba(180, 22, 44, .10);
  --sanitaire: #0b7285; --sanitaire-doux: rgba(11, 114, 133, .10);
  --neutre: #5b6675;    --neutre-doux: rgba(91, 102, 117, .10);

  --rail-fond: #0d1520;
  --rail-encre: #c3cddc;
  --rail-encre-vive: #ffffff;
  --rail-actif: rgba(255, 255, 255, .09);
  --rail-trait: rgba(255, 255, 255, .08);

  --ombre-1: 0 1px 2px rgba(16, 24, 34, .06), 0 1px 3px rgba(16, 24, 34, .05);
  --ombre-2: 0 4px 12px rgba(16, 24, 34, .09), 0 2px 4px rgba(16, 24, 34, .05);
  --ombre-3: 0 18px 44px rgba(16, 24, 34, .18), 0 4px 12px rgba(16, 24, 34, .09);

  --rayon-s: 5px;
  --rayon: 9px;
  --rayon-l: 14px;

  --largeur-rail: 244px;
  --hauteur-barre: 58px;

  --police: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Arial, sans-serif;
  --police-chiffres: "SF Mono", "Cascadia Mono", Consolas, "Roboto Mono", ui-monospace, monospace;

  --transition: 140ms cubic-bezier(.4, 0, .2, 1);
}

/* Theme sombre : applique explicitement, ou suivant le systeme lorsque
   l'utilisateur n'a pas choisi. */
:root[data-theme="dark"],
:root[data-theme="auto"] {
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root[data-theme="auto"] { color-scheme: light; }
}

:root[data-theme="dark"],
:root[data-theme="auto"]:not([data-resolu="clair"]) {
  --encre: #e8edf4;
  --encre-douce: #a3b0c4;
  --encre-faible: #78869c;

  --fond: #0a1017;
  --surface: #131c27;
  --surface-2: #182231;
  --surface-3: #1e2a3a;
  --surface-active: #253247;

  --trait: #263344;
  --trait-fort: #35455c;

  --accent: #ef4a63;
  --accent-clair: #ff6b81;
  --accent-doux: rgba(239, 74, 99, .14);

  --info: #59a5f0;      --info-doux: rgba(89, 165, 240, .13);
  --succes: #34c48a;    --succes-doux: rgba(52, 196, 138, .13);
  --attente: #e0a33c;   --attente-doux: rgba(224, 163, 60, .14);
  --danger: #f4677e;    --danger-doux: rgba(244, 103, 126, .13);
  --sanitaire: #3bbcd4; --sanitaire-doux: rgba(59, 188, 212, .13);
  --neutre: #93a0b3;    --neutre-doux: rgba(147, 160, 179, .12);

  --rail-fond: #070d14;
  --rail-encre: #8e9db3;
  --rail-trait: rgba(255, 255, 255, .06);

  --ombre-1: 0 1px 2px rgba(0, 0, 0, .34);
  --ombre-2: 0 4px 14px rgba(0, 0, 0, .40);
  --ombre-3: 0 20px 50px rgba(0, 0, 0, .56);
}

/* ------------------------------------------------------------------ */
/*  2. Base                                                            */
/* ------------------------------------------------------------------ */

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--police);
  font-size: 14px;
  line-height: 1.5;
  color: var(--encre);
  background: var(--fond);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 { margin: 0; font-weight: 650; line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: 22px; }
h2 { font-size: 17px; }
h3 { font-size: 14.5px; }
p { margin: 0 0 10px; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

button, input, select, textarea { font: inherit; color: inherit; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.lien-evitement {
  position: absolute; top: -60px; left: 10px; z-index: 100;
  background: var(--accent); color: #fff; padding: 9px 15px;
  border-radius: var(--rayon-s); transition: top var(--transition);
}
.lien-evitement:focus { top: 10px; }

.chiffres { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

/* ------------------------------------------------------------------ */
/*  3. Ecran de demarrage                                              */
/* ------------------------------------------------------------------ */

.ecran-demarrage {
  position: fixed; inset: 0; z-index: 90;
  display: grid; place-items: center;
  background: var(--rail-fond); color: var(--accent-clair);
}
.ecran-demarrage[hidden] { display: none; }
.demarrage-marque { text-align: center; }
.demarrage-pouls svg { overflow: visible; }
.demarrage-pouls polyline {
  stroke-dasharray: 240; stroke-dashoffset: 240;
  animation: trace 1.6s cubic-bezier(.6,.05,.3,1) infinite;
}
@keyframes trace {
  0%   { stroke-dashoffset: 240; opacity: .25; }
  45%  { stroke-dashoffset: 0;   opacity: 1; }
  75%  { stroke-dashoffset: 0;   opacity: 1; }
  100% { stroke-dashoffset: -240; opacity: .25; }
}
.demarrage-texte {
  margin-top: 14px; color: var(--rail-encre);
  font-size: 12.5px; letter-spacing: .4px;
}

/* ------------------------------------------------------------------ */
/*  4. Ossature                                                        */
/* ------------------------------------------------------------------ */

.application { display: flex; min-height: 100vh; }
.application[hidden] { display: none; }

.rail {
  width: var(--largeur-rail);
  flex-shrink: 0;
  background: var(--rail-fond);
  color: var(--rail-encre);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  border-right: 1px solid var(--rail-trait);
  z-index: 30;
}

.rail-marque {
  display: flex; align-items: center; gap: 11px;
  padding: 15px 16px; border-bottom: 1px solid var(--rail-trait);
  min-height: var(--hauteur-barre);
}
.marque-sigle {
  width: 34px; height: 34px; flex-shrink: 0;
  display: grid; place-items: center;
  background: var(--accent); color: #fff;
  border-radius: 8px; font-weight: 800; font-size: 13px; letter-spacing: .5px;
}
.marque-texte { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.marque-texte strong { color: var(--rail-encre-vive); font-size: 13.5px; letter-spacing: .4px; }
.marque-texte span { font-size: 10.5px; color: var(--rail-encre); opacity: .75; letter-spacing: .8px; text-transform: uppercase; }

.rail-nav { flex: 1; overflow-y: auto; padding: 12px 9px; }
.nav-groupe { margin-bottom: 16px; }
.nav-titre {
  font-size: 10px; text-transform: uppercase; letter-spacing: 1.1px;
  color: var(--rail-encre); opacity: .5; padding: 0 9px 6px; font-weight: 700;
}
.nav-lien {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--rayon-s);
  color: var(--rail-encre); font-size: 13.5px; font-weight: 500;
  transition: background var(--transition), color var(--transition);
  position: relative;
}
.nav-lien:hover { background: var(--rail-actif); color: var(--rail-encre-vive); text-decoration: none; }
.nav-lien.actif { background: var(--rail-actif); color: var(--rail-encre-vive); font-weight: 600; }
.nav-lien.actif::before {
  content: ""; position: absolute; left: -9px; top: 7px; bottom: 7px;
  width: 3px; background: var(--accent); border-radius: 0 3px 3px 0;
}
.nav-pastille {
  margin-left: auto; min-width: 19px; height: 19px; padding: 0 6px;
  display: grid; place-items: center; border-radius: 10px;
  background: var(--accent); color: #fff; font-size: 10.5px; font-weight: 700;
}
.nav-pastille.calme { background: rgba(255,255,255,.14); color: var(--rail-encre-vive); }

.rail-pied { border-top: 1px solid var(--rail-trait); padding: 9px; }
.bouton-rail {
  width: 100%; display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border: 0; background: transparent; color: var(--rail-encre);
  border-radius: var(--rayon-s); cursor: pointer; font-size: 13px; text-align: left;
  transition: background var(--transition);
}
.bouton-rail:hover { background: var(--rail-actif); color: var(--rail-encre-vive); }

.carte-utilisateur {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; margin-top: 4px;
  border-radius: var(--rayon-s); background: rgba(255,255,255,.05); cursor: pointer;
  transition: background var(--transition);
}
.carte-utilisateur:hover { background: var(--rail-actif); }
.avatar {
  width: 31px; height: 31px; flex-shrink: 0; border-radius: 50%;
  display: grid; place-items: center; font-size: 11.5px; font-weight: 700;
  background: linear-gradient(135deg, var(--accent), var(--accent-clair)); color: #fff;
}
.carte-utilisateur .infos { min-width: 0; line-height: 1.25; }
.carte-utilisateur .nom {
  color: var(--rail-encre-vive); font-size: 12.5px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.carte-utilisateur .role { font-size: 10.5px; opacity: .7; }

/* --- Zone principale --- */
.zone { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.barre {
  height: var(--hauteur-barre); flex-shrink: 0;
  display: flex; align-items: center; gap: 13px; padding: 0 18px;
  background: var(--surface); border-bottom: 1px solid var(--trait);
  position: sticky; top: 0; z-index: 20;
}
.bouton-menu {
  display: none; border: 0; background: transparent; padding: 7px;
  border-radius: var(--rayon-s); cursor: pointer;
}
.fil { flex: 1; min-width: 0; display: flex; align-items: center; gap: 7px; font-size: 13px; }
.fil .separateur { color: var(--encre-faible); }
.fil .courant { font-weight: 600; }
.fil a { color: var(--encre-douce); }

.recherche-declencheur {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px; border: 1px solid var(--trait); background: var(--surface-2);
  border-radius: var(--rayon-s); color: var(--encre-faible); cursor: pointer;
  font-size: 12.5px; transition: border-color var(--transition), background var(--transition);
}
.recherche-declencheur:hover { border-color: var(--trait-fort); background: var(--surface-3); }
kbd {
  font-family: var(--police); font-size: 10px; padding: 1px 5px;
  border: 1px solid var(--trait-fort); border-bottom-width: 2px;
  border-radius: 4px; background: var(--surface); color: var(--encre-faible);
}

.barre-actions { display: flex; align-items: center; gap: 8px; }

.contenu { flex: 1; padding: 22px; max-width: 1680px; width: 100%; }
.contenu:focus { outline: none; }

/* ------------------------------------------------------------------ */
/*  5. En-tete de page et cartes                                       */
/* ------------------------------------------------------------------ */

.page-entete {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 18px; margin-bottom: 18px; flex-wrap: wrap;
}
.page-entete .accroche { color: var(--encre-douce); font-size: 13px; margin-top: 3px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.carte {
  background: var(--surface); border: 1px solid var(--trait);
  border-radius: var(--rayon); box-shadow: var(--ombre-1);
}
.carte + .carte { margin-top: 16px; }
.carte-entete {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 13px 16px; border-bottom: 1px solid var(--trait); flex-wrap: wrap;
}
.carte-entete h2 { font-size: 14.5px; }
.carte-entete .sous { color: var(--encre-faible); font-size: 12px; margin-top: 2px; }
.carte-corps { padding: 16px; }
.carte-corps.serre { padding: 0; }

.grille { display: grid; gap: 16px; }
.grille.c2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grille.c3 { grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }
.grille.c4 { grid-template-columns: repeat(auto-fit, minmax(198px, 1fr)); }

/* --- Tuiles d'indicateurs --- */
.tuile {
  background: var(--surface); border: 1px solid var(--trait);
  border-radius: var(--rayon); padding: 15px 16px; position: relative; overflow: hidden;
}
.tuile::after {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--teinte, var(--neutre));
}
.tuile .etiquette {
  font-size: 11px; text-transform: uppercase; letter-spacing: .7px;
  color: var(--encre-faible); font-weight: 650;
}
.tuile .valeur {
  font-size: 25px; font-weight: 700; margin-top: 5px; letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}
.tuile .valeur .unite { font-size: 14px; font-weight: 600; color: var(--encre-douce); margin-left: 3px; }
.tuile .detail { font-size: 12px; color: var(--encre-douce); margin-top: 5px; }
.tuile.accent { --teinte: var(--accent); }
.tuile.succes { --teinte: var(--succes); }
.tuile.info   { --teinte: var(--info); }
.tuile.attente{ --teinte: var(--attente); }
.tuile.danger { --teinte: var(--danger); }

/* ------------------------------------------------------------------ */
/*  6. Tableaux                                                        */
/* ------------------------------------------------------------------ */

.table-enveloppe { overflow-x: auto; }

table.donnees { width: 100%; border-collapse: collapse; font-size: 13px; }
table.donnees thead th {
  position: sticky; top: 0; z-index: 2;
  background: var(--surface-2); text-align: left; font-weight: 650; font-size: 11.5px;
  text-transform: uppercase; letter-spacing: .5px; color: var(--encre-douce);
  padding: 9px 12px; border-bottom: 1px solid var(--trait); white-space: nowrap;
}
table.donnees thead th.num { text-align: right; }
table.donnees thead th.triable { cursor: pointer; user-select: none; }
table.donnees thead th.triable:hover { color: var(--encre); }
table.donnees thead th .fleche { opacity: .45; margin-left: 3px; }

table.donnees tbody td {
  padding: 9px 12px; border-bottom: 1px solid var(--trait); vertical-align: middle;
}
table.donnees tbody td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.donnees tbody tr { transition: background var(--transition); }
table.donnees tbody tr:hover { background: var(--surface-2); }
table.donnees tbody tr.cliquable { cursor: pointer; }
table.donnees tbody tr.selectionnee { background: var(--accent-doux); }
table.donnees .principal { font-weight: 600; }
table.donnees .secondaire { color: var(--encre-faible); font-size: 12px; }
table.donnees tfoot td {
  padding: 10px 12px; font-weight: 650; background: var(--surface-2);
  border-top: 2px solid var(--trait-fort);
}

.vide {
  padding: 46px 22px; text-align: center; color: var(--encre-faible);
}
.vide .titre { font-weight: 650; color: var(--encre-douce); margin-bottom: 5px; font-size: 14px; }

/* ------------------------------------------------------------------ */
/*  7. Pastilles et marqueurs                                          */
/* ------------------------------------------------------------------ */

.pastille {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 650; white-space: nowrap;
  background: var(--neutre-doux); color: var(--neutre);
}
.pastille::before {
  content: ""; width: 5px; height: 5px; border-radius: 50%;
  background: currentColor; flex-shrink: 0;
}
.pastille.sans-point::before { display: none; }
.pastille.succes   { background: var(--succes-doux);    color: var(--succes); }
.pastille.info     { background: var(--info-doux);      color: var(--info); }
.pastille.attente  { background: var(--attente-doux);   color: var(--attente); }
.pastille.danger   { background: var(--danger-doux);    color: var(--danger); }
.pastille.sanitaire{ background: var(--sanitaire-doux); color: var(--sanitaire); }
.pastille.accent   { background: var(--accent-doux);    color: var(--accent); }

/* Marqueur discret d'une ligne ajustee (RG-17.4) */
.marqueur-ajuste {
  display: inline-flex; align-items: center; gap: 4px;
  color: var(--attente); font-size: 11px; font-weight: 700;
  cursor: help; border-bottom: 1px dotted currentColor;
}
.marqueur-ajuste .glyphe { font-size: 12px; }

tr.ligne-ajustee td:first-child { box-shadow: inset 3px 0 0 var(--attente); }

/* ------------------------------------------------------------------ */
/*  8. Boutons                                                         */
/* ------------------------------------------------------------------ */

.bouton {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 7px 14px; border-radius: var(--rayon-s); border: 1px solid var(--trait-fort);
  background: var(--surface); color: var(--encre);
  font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap;
  transition: background var(--transition), border-color var(--transition), transform var(--transition);
}
.bouton:hover:not(:disabled) { background: var(--surface-3); border-color: var(--encre-faible); }
.bouton:active:not(:disabled) { transform: translateY(1px); }
.bouton:disabled { opacity: .5; cursor: not-allowed; }

.bouton.principal {
  background: var(--accent); border-color: var(--accent); color: var(--accent-contraste);
}
.bouton.principal:hover:not(:disabled) { background: var(--accent-clair); border-color: var(--accent-clair); }

.bouton.sourdine { border-color: transparent; background: transparent; color: var(--encre-douce); }
.bouton.sourdine:hover:not(:disabled) { background: var(--surface-3); color: var(--encre); }

.bouton.danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.bouton.danger:hover:not(:disabled) { background: var(--danger-doux); }

.bouton.petit { padding: 4px 9px; font-size: 12px; }
.bouton.large { padding: 10px 20px; font-size: 14px; }
.bouton.pleine-largeur { width: 100%; }

.groupe-boutons { display: inline-flex; }
.groupe-boutons .bouton { border-radius: 0; margin-left: -1px; }
.groupe-boutons .bouton:first-child { border-radius: var(--rayon-s) 0 0 var(--rayon-s); margin-left: 0; }
.groupe-boutons .bouton:last-child { border-radius: 0 var(--rayon-s) var(--rayon-s) 0; }
.groupe-boutons .bouton.actif { background: var(--accent-doux); color: var(--accent); border-color: var(--accent); z-index: 1; }

/* ------------------------------------------------------------------ */
/*  9. Formulaires                                                     */
/* ------------------------------------------------------------------ */

.champ { margin-bottom: 14px; }
.champ > label {
  display: block; font-size: 12.5px; font-weight: 600;
  color: var(--encre-douce); margin-bottom: 5px;
}
.champ > label .obligatoire { color: var(--accent); margin-left: 2px; }
.champ .aide { font-size: 11.5px; color: var(--encre-faible); margin-top: 4px; }
.champ .erreur { font-size: 12px; color: var(--danger); margin-top: 4px; font-weight: 600; }

.saisie, select.saisie, textarea.saisie {
  width: 100%; padding: 7.5px 11px;
  border: 1px solid var(--trait-fort); border-radius: var(--rayon-s);
  background: var(--surface); color: var(--encre); font-size: 13.5px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.saisie:hover:not(:disabled) { border-color: var(--encre-faible); }
.saisie:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-doux);
}
.saisie:disabled, .saisie[readonly] {
  background: var(--surface-3); color: var(--encre-faible); cursor: not-allowed;
}
.saisie.en-erreur { border-color: var(--danger); }
.saisie.num { text-align: right; font-variant-numeric: tabular-nums; }
textarea.saisie { resize: vertical; min-height: 70px; line-height: 1.5; }
select.saisie { cursor: pointer; }

.ligne-champs { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.ligne-champs.deux { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }

.case { display: flex; align-items: flex-start; gap: 9px; cursor: pointer; padding: 5px 0; }
.case input { margin-top: 2px; width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }
.case .texte { font-size: 13px; }
.case .texte .sous { color: var(--encre-faible); font-size: 11.5px; }

fieldset { border: 1px solid var(--trait); border-radius: var(--rayon); padding: 14px 16px; margin: 0 0 16px; }
legend { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; color: var(--encre-douce); padding: 0 6px; }

/* Barre de filtres */
.filtres {
  display: flex; gap: 9px; flex-wrap: wrap; align-items: flex-end;
  padding: 13px 16px; border-bottom: 1px solid var(--trait); background: var(--surface-2);
}
.filtres .champ { margin: 0; min-width: 148px; }
.filtres .champ.large { min-width: 240px; flex: 1; }
.filtres .champ > label { font-size: 11px; margin-bottom: 3px; }

/* ------------------------------------------------------------------ */
/*  10. Editeur de lignes de prestation                                */
/* ------------------------------------------------------------------ */

.editeur-lignes { border: 1px solid var(--trait); border-radius: var(--rayon); overflow: hidden; }
.editeur-lignes table { width: 100%; border-collapse: collapse; font-size: 13px; }
.editeur-lignes thead th {
  background: var(--surface-2); font-size: 11px; text-transform: uppercase;
  letter-spacing: .5px; color: var(--encre-douce); font-weight: 650;
  padding: 8px 9px; text-align: left; border-bottom: 1px solid var(--trait); white-space: nowrap;
}
.editeur-lignes thead th.num { text-align: right; }
.editeur-lignes tbody td { padding: 5px 6px; border-bottom: 1px solid var(--trait); vertical-align: middle; }
.editeur-lignes tbody td .saisie { padding: 5px 8px; font-size: 13px; }
.editeur-lignes tbody tr.alerte { background: var(--attente-doux); }
.editeur-lignes tbody tr.bloquee { background: var(--danger-doux); }
.editeur-lignes tfoot td { padding: 9px; background: var(--surface-2); }

.ligne-note {
  font-size: 11.5px; padding: 3px 9px 7px; display: flex; align-items: center; gap: 6px;
}
.ligne-note.avertissement { color: var(--attente); }
.ligne-note.blocage { color: var(--danger); font-weight: 600; }

.recap-totaux { display: flex; justify-content: flex-end; padding: 14px 16px; }
.recap-totaux table { min-width: 290px; font-size: 13.5px; }
.recap-totaux td { padding: 4px 9px; }
.recap-totaux td.libelle { color: var(--encre-douce); }
.recap-totaux td.valeur { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.recap-totaux tr.ventilation td { font-size: 12px; color: var(--encre-faible); }
.recap-totaux tr.grand td {
  border-top: 2px solid var(--trait-fort); padding-top: 8px;
  font-size: 17px; font-weight: 700; color: var(--accent);
}

/* ------------------------------------------------------------------ */
/*  11. Modales                                                        */
/* ------------------------------------------------------------------ */

.conteneur-modales:empty { display: none; }
.modale-fond {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(8, 13, 20, .58);
  backdrop-filter: blur(2px);
  display: grid; place-items: center; padding: 20px;
  animation: apparition 130ms ease-out;
}
@keyframes apparition { from { opacity: 0; } to { opacity: 1; } }

.modale {
  background: var(--surface); border: 1px solid var(--trait);
  border-radius: var(--rayon-l); box-shadow: var(--ombre-3);
  width: 100%; max-width: 560px; max-height: 88vh;
  display: flex; flex-direction: column;
  animation: montee 160ms cubic-bezier(.2,.8,.3,1);
}
@keyframes montee { from { transform: translateY(14px) scale(.985); opacity: 0; } to { transform: none; opacity: 1; } }
.modale.large { max-width: 880px; }
.modale.tres-large { max-width: 1180px; }

.modale-entete {
  padding: 15px 19px; border-bottom: 1px solid var(--trait);
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
}
.modale-entete .sous { color: var(--encre-faible); font-size: 12.5px; margin-top: 3px; }
.modale-corps { padding: 19px; overflow-y: auto; flex: 1; }
.modale-pied {
  padding: 13px 19px; border-top: 1px solid var(--trait);
  display: flex; justify-content: flex-end; gap: 9px; flex-wrap: wrap;
  background: var(--surface-2); border-radius: 0 0 var(--rayon-l) var(--rayon-l);
}
.bouton-fermer {
  border: 0; background: transparent; cursor: pointer; padding: 5px;
  border-radius: var(--rayon-s); color: var(--encre-faible); line-height: 1;
}
.bouton-fermer:hover { background: var(--surface-3); color: var(--encre); }

/* ------------------------------------------------------------------ */
/*  12. Notifications                                                  */
/* ------------------------------------------------------------------ */

.conteneur-notifications {
  position: fixed; bottom: 18px; right: 18px; z-index: 80;
  display: flex; flex-direction: column; gap: 9px; max-width: 430px;
}
.notification {
  display: flex; gap: 11px; align-items: flex-start;
  padding: 12px 14px; border-radius: var(--rayon);
  background: var(--surface); border: 1px solid var(--trait);
  border-left: 3px solid var(--teinte, var(--info));
  box-shadow: var(--ombre-2);
  animation: glisse 190ms cubic-bezier(.2,.8,.3,1);
}
@keyframes glisse { from { transform: translateX(22px); opacity: 0; } to { transform: none; opacity: 1; } }
.notification.succes { --teinte: var(--succes); }
.notification.erreur { --teinte: var(--danger); }
.notification.attention { --teinte: var(--attente); }
.notification .corps { flex: 1; min-width: 0; }
.notification .titre { font-weight: 650; font-size: 13.5px; }
.notification .message { font-size: 12.5px; color: var(--encre-douce); margin-top: 2px; word-wrap: break-word; }
.notification.sortante { animation: retrait 160ms ease-in forwards; }
@keyframes retrait { to { transform: translateX(22px); opacity: 0; } }

/* Encadres d'information contextuelle */
.encadre {
  padding: 11px 14px; border-radius: var(--rayon-s); font-size: 13px;
  border-left: 3px solid var(--teinte, var(--info));
  background: var(--fond-doux, var(--info-doux)); margin-bottom: 14px;
}
.encadre .titre { font-weight: 650; margin-bottom: 3px; }
.encadre ul { margin: 6px 0 0; padding-left: 19px; }
.encadre li { margin-bottom: 3px; }
.encadre.attention { --teinte: var(--attente); --fond-doux: var(--attente-doux); }
.encadre.danger    { --teinte: var(--danger);  --fond-doux: var(--danger-doux); }
.encadre.succes    { --teinte: var(--succes);  --fond-doux: var(--succes-doux); }

/* ------------------------------------------------------------------ */
/*  13. Palette de recherche                                           */
/* ------------------------------------------------------------------ */

.palette { position: fixed; inset: 0; z-index: 70; }
.palette[hidden] { display: none; }
.palette-fond { position: absolute; inset: 0; background: rgba(8,13,20,.55); backdrop-filter: blur(2px); }
.palette-boite {
  position: relative; max-width: 600px; margin: 11vh auto 0;
  background: var(--surface); border: 1px solid var(--trait);
  border-radius: var(--rayon-l); box-shadow: var(--ombre-3); overflow: hidden;
  animation: montee 150ms cubic-bezier(.2,.8,.3,1);
}
.palette-champ {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 16px; border-bottom: 1px solid var(--trait);
}
.palette-champ input {
  flex: 1; border: 0; background: transparent; font-size: 15px; outline: none;
}
.palette-resultats { max-height: 54vh; overflow-y: auto; padding: 6px; }
.palette-resultat {
  display: flex; align-items: center; gap: 11px; padding: 9px 11px;
  border-radius: var(--rayon-s); cursor: pointer;
}
.palette-resultat:hover, .palette-resultat.survol { background: var(--surface-3); }
.palette-resultat .type {
  font-size: 10px; text-transform: uppercase; letter-spacing: .6px;
  padding: 2px 7px; border-radius: 4px; background: var(--accent-doux);
  color: var(--accent); font-weight: 700; flex-shrink: 0;
}
.palette-resultat .libelle { flex: 1; min-width: 0; }
.palette-resultat .libelle .principal { font-weight: 600; font-size: 13.5px; }
.palette-resultat .libelle .secondaire { font-size: 12px; color: var(--encre-faible); }
.palette-vide { padding: 30px; text-align: center; color: var(--encre-faible); font-size: 13px; }

/* ------------------------------------------------------------------ */
/*  14. Connexion                                                      */
/* ------------------------------------------------------------------ */

.page-connexion {
  min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr;
  background: var(--fond);
}
.connexion-recit {
  background: var(--rail-fond); color: var(--rail-encre);
  padding: 52px; display: flex; flex-direction: column; justify-content: space-between;
  position: relative; overflow: hidden;
}
.connexion-recit::before {
  content: ""; position: absolute; right: -140px; top: -140px;
  width: 440px; height: 440px; border-radius: 50%;
  background: radial-gradient(circle, rgba(200,16,46,.24), transparent 68%);
}
.connexion-recit .marque { display: flex; align-items: center; gap: 13px; position: relative; }
.connexion-recit .marque .marque-sigle { width: 42px; height: 42px; font-size: 15px; }
.connexion-recit .marque strong { color: #fff; font-size: 16px; letter-spacing: .5px; }
.connexion-recit .marque span { display: block; font-size: 11px; opacity: .7; letter-spacing: .9px; text-transform: uppercase; }
.connexion-recit .propos { position: relative; max-width: 430px; }
.connexion-recit .propos h2 { color: #fff; font-size: 27px; line-height: 1.28; margin-bottom: 14px; letter-spacing: -.02em; }
.connexion-recit .propos p { font-size: 14px; line-height: 1.65; opacity: .82; }
.connexion-recit .metiers { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 22px; }
.connexion-recit .metiers span {
  font-size: 11.5px; padding: 4px 11px; border-radius: 999px;
  border: 1px solid var(--rail-trait); background: rgba(255,255,255,.04);
}
.connexion-recit .pied { position: relative; font-size: 11.5px; opacity: .55; line-height: 1.7; }

.connexion-formulaire { display: grid; place-items: center; padding: 40px 24px; }
.connexion-boite { width: 100%; max-width: 372px; }
.connexion-boite h1 { margin-bottom: 6px; }
.connexion-boite .accroche { color: var(--encre-douce); font-size: 13.5px; margin-bottom: 26px; }
.connexion-boite .mention-securite {
  margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--trait);
  font-size: 11.5px; color: var(--encre-faible); line-height: 1.6;
}

/* ------------------------------------------------------------------ */
/*  15. Onglets, chronologie, divers                                   */
/* ------------------------------------------------------------------ */

.onglets { display: flex; gap: 2px; border-bottom: 1px solid var(--trait); margin-bottom: 16px; overflow-x: auto; }
.onglet {
  padding: 9px 15px; border: 0; background: transparent; cursor: pointer;
  font-size: 13.5px; font-weight: 600; color: var(--encre-faible);
  border-bottom: 2px solid transparent; white-space: nowrap;
  transition: color var(--transition), border-color var(--transition);
}
.onglet:hover { color: var(--encre); }
.onglet.actif { color: var(--accent); border-bottom-color: var(--accent); }

.chronologie { position: relative; padding-left: 22px; }
.chronologie::before {
  content: ""; position: absolute; left: 5px; top: 5px; bottom: 5px;
  width: 2px; background: var(--trait);
}
.chrono-entree { position: relative; padding-bottom: 17px; }
.chrono-entree::before {
  content: ""; position: absolute; left: -21px; top: 4px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--teinte, var(--neutre));
}
.chrono-entree.critical { --teinte: var(--danger); }
.chrono-entree.warning  { --teinte: var(--attente); }
.chrono-entree.notice   { --teinte: var(--info); }
.chrono-entree .quand { font-size: 11.5px; color: var(--encre-faible); }
.chrono-entree .quoi { font-size: 13px; margin-top: 2px; }
.chrono-entree .qui { font-size: 11.5px; color: var(--encre-douce); font-weight: 600; }
.chrono-diff {
  margin-top: 6px; font-size: 12px; background: var(--surface-2);
  border: 1px solid var(--trait); border-radius: var(--rayon-s); padding: 7px 10px;
}
.chrono-diff .champ-diff { display: flex; gap: 7px; padding: 1px 0; }
.chrono-diff .champ-diff .cle { font-weight: 600; min-width: 130px; }
.chrono-diff .avant { color: var(--danger); text-decoration: line-through; }
.chrono-diff .apres { color: var(--succes); font-weight: 600; }

.definitions { display: grid; grid-template-columns: auto 1fr; gap: 7px 16px; font-size: 13px; }
.definitions dt { color: var(--encre-faible); font-size: 12.5px; }
.definitions dd { margin: 0; font-weight: 550; }

.chargement { display: grid; place-items: center; padding: 60px; color: var(--encre-faible); }
.rotateur {
  width: 26px; height: 26px; border: 2.5px solid var(--trait-fort);
  border-top-color: var(--accent); border-radius: 50%;
  animation: rotation .7s linear infinite;
}
@keyframes rotation { to { transform: rotate(360deg); } }

.pagination {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 11px 16px; border-top: 1px solid var(--trait); flex-wrap: wrap;
}
.pagination .info { font-size: 12.5px; color: var(--encre-faible); }

.icone { display: inline-flex; width: 17px; height: 17px; flex-shrink: 0; }
.icone svg { width: 100%; height: 100%; }

/* ------------------------------------------------------------------ */
/*  16. Adaptation aux petits ecrans                                   */
/* ------------------------------------------------------------------ */

@media (max-width: 1080px) {
  .page-connexion { grid-template-columns: 1fr; }
  .connexion-recit { display: none; }
}

@media (max-width: 860px) {
  .rail {
    position: fixed; left: 0; top: 0; bottom: 0;
    transform: translateX(-100%); transition: transform var(--transition);
    box-shadow: var(--ombre-3);
  }
  .rail.ouvert { transform: none; }
  .bouton-menu { display: inline-flex; }
  .recherche-declencheur span:not(.icone) { display: none; }
  .recherche-declencheur kbd { display: none; }
  .contenu { padding: 15px; }
  .conteneur-notifications { left: 12px; right: 12px; max-width: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

@media print {
  .rail, .barre, .page-actions, .filtres, .pagination { display: none !important; }
  .contenu { padding: 0; }
  .carte { border: 0; box-shadow: none; }
}

/* ------------------------------------------------------------------ */
/*  17. Sélecteur de client (recherche + création à la volée)          */
/* ------------------------------------------------------------------ */

.selecteur-client { position: relative; }

.selecteur-client .suggestions {
  position: absolute; left: 0; right: 0; top: calc(100% + 3px); z-index: 25;
  background: var(--surface); border: 1px solid var(--trait-fort);
  border-radius: var(--rayon); box-shadow: var(--ombre-2);
  max-height: 300px; overflow-y: auto; padding: 4px;
}
.selecteur-client .suggestions[hidden] { display: none; }

.suggestion {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 10px; border-radius: var(--rayon-s); cursor: pointer;
}
.suggestion:hover { background: var(--surface-3); }
.suggestion .principal { font-weight: 600; font-size: 13.5px; }
.suggestion .secondaire { font-size: 11.5px; color: var(--encre-faible); }

/* La création se distingue nettement des résultats existants. */
.suggestion.creation {
  justify-content: flex-start;
  border-top: 1px solid var(--trait); margin-top: 4px; padding-top: 10px;
  color: var(--accent);
}
.suggestion.creation .principal { color: var(--accent); }
.suggestion.creation:hover { background: var(--accent-doux); }

.suggestion-vide {
  padding: 14px; text-align: center; color: var(--encre-faible); font-size: 13px;
}

.client-retenu {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-top: 7px; padding: 9px 12px;
  border: 1px solid var(--trait); border-left: 3px solid var(--accent);
  border-radius: var(--rayon-s); background: var(--surface-2);
}
.client-retenu .nom { font-weight: 650; font-size: 13.5px; }
.client-retenu .detail { font-size: 11.5px; color: var(--encre-faible); margin-top: 2px; }

/* ------------------------------------------------------------------ */
/*  18. Bloc de signature des documents imprimés                       */
/* ------------------------------------------------------------------ */

.signatures {
  display: flex; gap: 10mm; margin-top: 8mm;
}
.signature-case {
  flex: 1; border: 1px solid var(--trait); border-radius: 3px;
  padding: 3mm 4mm; min-height: 24mm;
}
.signature-case .intitule {
  font-size: 7.5pt; text-transform: uppercase; letter-spacing: 1px;
  color: var(--gris); font-weight: 700;
}
.signature-case .consigne {
  font-size: 8pt; color: var(--gris); margin-top: 1mm;
}
