/* ═══════════════════════════════════════════════════════════════════
   STEEL METAL GROUP — feuille de style de l'ERP
   Direction « Atelier » (novembre 2026) : papier blanc acier, feuilles au
   filet fin, colonne de navigation bleu pétrole, titres en Newsreader. Un
   seul orange plein par écran : l'action principale. Le reste se tait.

   tokens.css  : les valeurs de base (héritées de « Glass Pro »).
   glass.css   : les matières communes (feuilles, pastilles, bulles).
   atelier.css : la direction en vigueur — ses jetons remplacent ceux de
                 tokens.css, puis la colonne, le cartouche, les tableaux.
   Ici         : le contenu des écrans, partagé entre les modules.
     IBM Plex Sans → toute l'interface.
     IBM Plex Mono → les numéros de document, et rien d'autre.
   ═══════════════════════════════════════════════════════════════════ */

@import url("/fonts/fonts.css");
@import url("/css/tokens.css");
@import url("/css/glass.css");
@import url("/css/barre-outils.css");
@import url("/css/dialogue.css");
/* La direction en vigueur ; chaque page porte <html data-direction="atelier">. */
@import url("/css/atelier.css");


/* Le gras des polices chargées s'arrête à 600 : un 700 (ou le « bolder »
   par défaut de <strong>) serait fabriqué par le navigateur, plus baveux. */
strong, b { font-weight: 600; }

/* Sans cette règle, les liens gardent le bleu et le violet du navigateur. */
a { color: var(--petrole); }

* { box-sizing: border-box; }

/* L'attribut [hidden] doit toujours masquer, même sur un élément dont une
   classe pose `display` (ex. .form-grid { display: grid }) : à spécificité
   égale les styles d'auteur l'emportent sinon sur le display:none par
   défaut du navigateur — piège classique rencontré au Sprint 13. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: var(--t-base);
  line-height: 1.55;
  color: var(--encre);
  /* Pas de fond ici : il couvrirait les calques fixes de glass.css. */
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums; /* les montants s'alignent en colonne */
}


/* ═══ 1. La charpente ═══════════════════════════════════════════════
   La barre et le rail flottent (glass.css) : le contenu prend toute la
   page et leur laisse la place par ses marges. */
main.container {
  padding: calc(var(--hauteur-barre) + var(--e-6)) var(--e-7) var(--e-7) 104px;
  max-width: 1344px;
  width: 100%;
  min-width: 0;
  margin: 0 auto;
}

/* Un écran de lecture se borne à une largeur confortable ; une grille
   financière de 14 colonnes, elle, prend ce qu'on lui donne. */
main.container.pleine-largeur { max-width: none; }

/* Mode espion : un bandeau qu'on ne peut pas manquer, au-dessus de tout.
   Filet orange, couleur de la maison : c'est une visite autorisée, pas une
   erreur. */
.espion-bandeau {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: var(--z-bandeau);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .7rem;
  min-height: 40px;
  padding: .4rem 1rem;
  background: var(--flottant);
  border-bottom: 2px solid var(--orange);
  color: #fff;
  font-size: var(--t-m);
}
.espion-bandeau svg { width: 18px; height: 18px; flex: none; color: var(--orange); }
.espion-quitter {
  margin-left: .4rem;
  min-height: 28px;
  padding: 0 .8rem;
  border-radius: var(--r-petit);
  border: 1px solid rgba(255, 255, 255, .35);
  background: transparent;
  color: #fff;
  font: inherit;
  font-size: var(--t-s);
  cursor: pointer;
}
.espion-quitter:hover { background: rgba(255, 255, 255, .12); }
body.en-espion main.container { padding-top: calc(var(--hauteur-barre) + var(--e-6) + 40px); }
body.en-espion .barre { top: 40px; }

/* ═══ 3. L'en-tête de page ══════════════════════════════════════════ */
.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 2rem;
  flex-wrap: wrap;
  margin-bottom: var(--e-6);
}
/* Le texte cède la place, les actions restent à droite du titre sur toutes
   les pages : avant l'audit d'octobre 2026, une description un peu longue
   (Catalogue, Trésorerie, fiche bon de commande) renvoyait les boutons
   sous le titre, alors qu'ils étaient à droite ailleurs. */
.page-head-texte { flex: 1 1 22rem; min-width: 0; }
.page-head > .page-actions { flex: 0 0 auto; margin-left: auto; }

h1 {
  font-weight: 400;
  font-size: var(--t-titre);
  line-height: 1.15;
  letter-spacing: -.015em;
  color: var(--encre);
  margin: 0;
}

.page-sous-titre {
  margin: .5rem 0 0;
  color: var(--gris);
  font-size: var(--t-base);
  max-width: 62ch;
}

.page-actions {
  display: flex;
  align-items: center;
  gap: .55rem;
  flex-wrap: wrap;
  margin-top: .3rem;
}
/* Filet qui met à part une action destructrice des actions courantes. */
.actions-separateur {
  width: 1px;
  height: 24px;
  margin: 0 var(--e-2);
  background: var(--trait-fort);
}

/* Fil d'Ariane / retour sur les écrans de détail */
.retour {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  color: var(--gris);
  text-decoration: none;
  font-size: var(--t-m);
  margin-bottom: .9rem;
  transition: color var(--temps) var(--courbe);
}
.retour:hover { color: var(--petrole); }
.retour svg { width: 14px; height: 14px; }

/* ═══ 4. Sections ═══════════════════════════════════════════════════
   Le verre vient de glass.css ; ici, l'espace entre les blocs. */
main section { margin: 0 0 var(--e-5); }

h2 {
  font-family: inherit;
  font-size: var(--t-base);
  font-weight: 600;
  letter-spacing: .005em;
  color: var(--encre);
  margin: 0 0 1rem;
}

h3 {
  font-size: var(--t-m);
  font-weight: 600;
  color: var(--encre);
  margin: 0 0 .6rem;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1.25rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.section-head h2 { margin: 0; }

/* Un bloc qui est vraiment un objet (et non une section) prend une surface. */
.panneau { padding: var(--e-5); }

.muted { color: var(--gris); }
.montant { text-align: right; font-variant-numeric: tabular-nums; }

/* Les références de document sont des identifiants machine : elles ont
   droit à la chasse fixe. Rien d'autre dans l'interface n'y a droit. */
.ref {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-weight: 500;
  font-size: var(--t-s);
  letter-spacing: -.01em;
  color: var(--gris);
}

/* ═══ 5. Tableaux ═══════════════════════════════════════════════════ */
.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }

thead th {
  text-align: left;
  padding: 0 .9rem .6rem;
  font-size: var(--t-xs);
  font-weight: 600;
  letter-spacing: .01em;
  color: var(--gris);
  border-bottom: 1px solid var(--trait-fort);
  white-space: nowrap;
}
thead th.montant { text-align: right; }

tbody td {
  padding: .7rem .9rem;
  border-bottom: 1px solid var(--trait);
  font-size: var(--t-base);
  vertical-align: middle;
}
tbody tr { transition: background var(--temps) var(--courbe); }
tbody tr:hover { background: var(--voile); }

/* Une ligne qui s'ouvre (cf. js/ui.js::activerLignesCliquables) le dit au
   survol : curseur main, et le lien d'ouverture prend la couleur de marque. */
tbody tr:has(:is([data-ligne-principale], a.link-retour, [data-ouvrir], [data-modifier])) { cursor: pointer; }
tbody tr:has(a.link-retour):hover a.link-retour { text-decoration: underline; }

/* Première et dernière colonne alignées sur le bord du contenu */
thead th:first-child, tbody td:first-child { padding-left: 0; }
thead th:last-child,  tbody td:last-child  { padding-right: 0; }

td.actions { text-align: right; white-space: nowrap; }

/* Le chevron d'ouverture en bout de ligne : toute la ligne est cliquable,
   il ne fait que le signaler (remplace les liens « Détails »). */
.btn-chevron { min-width: 32px; padding: 0; color: var(--gris-clair); }
.btn-chevron svg { width: 16px; height: 16px; }
tbody tr:hover .btn-chevron { color: var(--petrole); }

/* Une deuxième ligne d'information dans une cellule (le type sous l'objet). */
.sous-ligne { display: block; margin-top: .1rem; font-size: var(--t-s); color: var(--gris); }

/* Combien de lignes la liste affiche, juste au-dessus du tableau. */
.compteur { margin: 0 0 .6rem; font-size: var(--t-s); color: var(--gris); }

/* Le numéro de document est l'identifiant de la ligne : il se lit en encre
   normale, pas en gris secondaire (audit d'octobre 2026). */
td .ref { color: var(--encre); }
a.ref { text-decoration: none; }
tbody tr:hover a.ref { color: var(--petrole); }

/* Une cellule sans valeur affiche un tiret discret plutôt que du vide. */
.vide-cellule { color: var(--gris-clair); }

.lignes-total td {
  font-weight: 600;
  border-top: 1px solid var(--trait-fort);
  border-bottom: none;
  padding-top: .9rem;
}

/* ═══ 6. Écrans vides et chargement ═════════════════════════════════
   Un écran vide est une invitation à agir, pas un cul-de-sac. */
.vide {
  padding: 2.25rem 1.5rem;
  text-align: center;
  color: var(--gris);
}
.vide strong {
  display: block;
  font-size: var(--t-l);
  font-weight: 500;
  color: var(--encre);
  margin-bottom: .35rem;
}
.vide p { margin: 0 auto 1.1rem; max-width: 42ch; font-size: var(--t-base); }

.chargement {
  padding: 2rem 0;
  color: var(--gris);
  font-size: var(--t-base);
}

/* ═══ 7. Boutons ════════════════════════════════════════════════════
   Quatre variantes, et on s'y tient : principal, secondaire, discret,
   danger. Un seul .btn-principal par écran : c'est lui qui porte l'orange,
   donc c'est lui qu'on voit en premier.

   Audit d'octobre 2026 : un bouton d'envoi (type=submit) n'est PLUS orange
   d'office. Cette règle par défaut fabriquait des écrans à deux ou trois
   oranges (fiche devis, fiche bon de commande, panneaux de détail…). Un
   bouton est orange parce qu'on l'a décidé, avec la classe .btn-principal ;
   sinon il est secondaire. Les alias hérités (.btn, .btn-link, .btn-danger,
   button.link, button.secondary) ont disparu. */
button,
.btn-principal,
.btn-secondaire,
.btn-discret {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  min-height: 40px;
  padding: 0 1.05rem;
  border: 1px solid transparent;
  border-radius: var(--r-pilule);
  font-family: inherit;
  font-size: var(--t-m);
  font-weight: 500;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--temps) var(--courbe),
              border-color var(--temps) var(--courbe),
              color var(--temps) var(--courbe),
              transform var(--temps) var(--courbe);
}
button svg, .btn-principal svg, .btn-secondaire svg, .btn-discret svg { width: 16px; height: 16px; flex: none; }

/* Un bouton qui s'enfonce légèrement sous le doigt : l'interface a entendu. */
:is(button, .btn-principal, .btn-secondaire):active:not(:disabled) { transform: scale(.98); }

/* Niveau 2 (par défaut) — les actions possibles mais pas attendues */
button,
.btn-secondaire {
  background: var(--verre-fort);
  color: var(--petrole);
  border-color: var(--trait-fort);
}
button:hover,
.btn-secondaire:hover { background: var(--voile); border-color: var(--petrole); }

/* Niveau 1 — l'action principale de l'écran. Déclaré après le niveau 2 :
   à spécificité égale, c'est la classe qui gagne. */
.btn-principal {
  background: var(--braise);
  color: #fff;
  border-color: var(--braise);
}
.btn-principal:hover { background: var(--braise-fonce); border-color: var(--braise-fonce); }

/* Niveau 3 — discret, dans le fil du contenu */
.btn-discret {
  background: none;
  border-color: transparent;
  color: var(--petrole);
  min-height: 32px;
  padding: 0 .4rem;
  text-decoration: none;
}
.btn-discret:hover { background: var(--voile); color: var(--petrole); text-decoration: none; }

/* Destructif — rouge uniquement, jamais plein tant qu'on n'a pas confirmé */
button.danger {
  background: var(--verre-fort);
  color: var(--danger);
  border-color: var(--danger-trait);
}
button.danger:hover { background: var(--refus-fond); border-color: var(--danger); }

button:disabled,
[aria-disabled="true"]:is(.btn-principal, .btn-secondaire) { opacity: .45; cursor: not-allowed; }

/* Un seul anneau de focus pour toute l'interface : visible (pétrole en
   « Atelier »),
   toujours au même endroit. */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--blanc);
  outline-offset: 2px;
}

/* ═══ 8. Formulaires ════════════════════════════════════════════════ */
form label {
  display: block;
  margin-bottom: 1.05rem;
  font-size: var(--t-s);
  font-weight: 500;
  color: var(--gris);
}

input, select, textarea {
  display: block;
  width: 100%;
  min-height: 40px;
  padding: .5rem .7rem;
  margin-top: .3rem;
  border: 1px solid var(--trait-champ);
  border-radius: var(--r-petit);
  background-color: var(--voile);
  color: var(--encre);
  font-family: inherit;
  font-size: var(--t-base);
  font-weight: 400;
  transition: border-color var(--temps) var(--courbe), box-shadow var(--temps) var(--courbe);
}
option { background: var(--surface); color: var(--encre); }
textarea { min-height: 88px; resize: vertical; line-height: 1.5; }

input::placeholder, textarea::placeholder { color: var(--gris-clair); }

/* ── Listes déroulantes cherchables (js/liste-cherchable.js) ─────────
   Le bouton prend exactement l'allure d'un champ : rien ne signale le
   remplacement, sauf la loupe qui apparaît à l'ouverture. */
.lc { position: relative; display: block; margin-top: .3rem; }
.lc-natif {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: 0;
  opacity: 0; pointer-events: none; overflow: hidden;
}
.lc-bouton {
  width: 100%;
  min-height: 40px;
  justify-content: space-between;
  gap: .5rem;
  padding: .5rem .6rem .5rem .7rem;
  border: 1px solid var(--trait-champ);
  border-radius: var(--r-petit);
  background: var(--voile);
  color: var(--encre);
  font-size: var(--t-base);
  font-weight: 400;
  text-align: left;
}
.lc-bouton:hover { background: var(--voile); border-color: var(--petrole); }
.lc-bouton:active:not(:disabled) { transform: none; }
.lc-bouton[aria-expanded="true"] { border-color: var(--petrole); box-shadow: 0 0 0 3px var(--halo-focus); }
.lc-bouton.est-vide .lc-libelle { color: var(--gris-clair); }
.lc-bouton:disabled { background: var(--voile); color: var(--gris); opacity: 1; }
.lc-libelle { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lc-bouton svg { width: 15px; height: 15px; color: var(--gris); }

.lc-panneau {
  position: fixed;
  z-index: calc(var(--z-tiroir) + 2);
  display: flex;
  flex-direction: column;
  max-height: 320px;
  background: var(--surface);
  border: 1px solid var(--trait-fort);
  border-radius: var(--r-moyen);
  box-shadow: var(--ombre-flottant);
  overflow: hidden;
}
.lc-recherche {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .55rem .75rem;
  border-bottom: 1px solid var(--trait);
  color: var(--gris);
}
.lc-recherche svg { width: 15px; height: 15px; flex: none; }
.lc-recherche input {
  background: none;
  margin: 0;
  min-height: 30px;
  padding: 0;
  border: 0;
  box-shadow: none;
  font-size: var(--t-m);
}
.lc-recherche input:focus { box-shadow: none; border: 0; }
.lc-liste { list-style: none; margin: 0; padding: .3rem; overflow-y: auto; }
.lc-liste li {
  padding: .5rem .6rem;
  border-radius: var(--r-petit);
  font-size: var(--t-m);
  color: var(--encre);
  cursor: pointer;
}
.lc-liste li.est-actif { background: var(--voile); color: var(--petrole); }
.lc-liste li[aria-selected="true"] { font-weight: 600; }
.lc-liste .lc-aucun { color: var(--gris); cursor: default; }

/* Tout champ de recherche porte sa loupe, à gauche (demande de Mat,
   octobre 2026) : on le reconnaît avant d'avoir lu son libellé. Même
   dessin que le picto « recherche » de js/ui.js, en data-URL comme la
   flèche des listes déroulantes (une variable CSS n'y entre pas : le gris
   est écrit en dur, c'est --gris). */
input[type="search"] {
  padding-left: 2.1rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23aab6bd' stroke-width='1.6' stroke-linecap='round'%3E%3Ccircle cx='7.2' cy='7.2' r='4.2'/%3E%3Cpath d='m10.4 10.4 2.8 2.8'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left .7rem center;
  background-size: 15px;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--petrole);
  box-shadow: 0 0 0 3px var(--halo-focus);
}
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; }

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23aab6bd' stroke-width='1.6' stroke-linecap='round'%3E%3Cpath d='M4 6.5 8 10.5l4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .6rem center;
  background-size: 15px;
  padding-right: 2rem;
}

input[type="checkbox"], input[type="radio"] {
  width: auto; min-height: 0; margin: 0;
  accent-color: var(--petrole);
}
input[type="file"] { padding: .4rem .5rem; font-size: var(--t-m); }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 0 1.5rem; }
.form-wide { grid-column: 1 / -1; }
.form-actions { display: flex; gap: .55rem; flex-wrap: wrap; margin-top: .4rem; }

.aide { display: block; margin-top: .3rem; font-size: var(--t-s); font-weight: 400; color: var(--gris); }

/* Une valeur calculée posée dans un formulaire : même place qu'un champ,
   mais lue, pas saisie (ex. l'encours d'un client). */
.champ-lu { margin-bottom: 1.05rem; font-size: var(--t-s); }
.champ-lu-libelle { display: block; font-weight: 500; color: var(--gris); }
.champ-lu-valeur {
  display: flex;
  align-items: center;
  gap: var(--e-2);
  min-height: 40px;
  margin-top: .3rem;
  font-size: var(--t-m);
  color: var(--encre);
  font-variant-numeric: tabular-nums;
}

/* Un groupe de champs qui va ensemble (ex. la décomposition d'un coût de
   revient) : encadré léger, titre discret. */
fieldset {
  border: 1px solid var(--trait);
  border-radius: var(--r-moyen);
  padding: 1.1rem 1.25rem .4rem;
  margin: 0 0 1.05rem;
  min-width: 0;
}
legend {
  padding: 0 .45rem;
  font-size: var(--t-s);
  font-weight: 600;
  color: var(--encre);
}
fieldset p { font-size: var(--t-m); }

.error {
  color: var(--danger);
  font-size: var(--t-m);
  margin: .4rem 0 0;
}

/* ── Barre d'outils d'une liste : recherche + filtres ─────────────── */
.toolbar {
  display: flex;
  align-items: flex-end;
  gap: .8rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}
/* La barre de filtres n'est pas dans un <form> : sans cette règle, ses
   libellés prenaient la taille et l'encre du texte courant, plus gros que
   le tableau qu'ils filtrent (audit d'octobre 2026). Même registre que les
   libellés de formulaire. */
.toolbar label {
  flex: 0 1 200px;
  margin-bottom: 0;
  font-size: var(--t-s);
  font-weight: 500;
  color: var(--gris);
}
.toolbar label.recherche { flex: 0 1 340px; }
.toolbar .checkbox {
  display: flex; align-items: center; gap: .45rem;
  flex: 0 0 auto; margin-bottom: 0; min-height: 40px;
  font-size: var(--t-m); color: var(--encre); font-weight: 400;
}
.toolbar .checkbox input { margin-top: 0; }

/* ── Onglets (Devis / Achats en édition) ──────────────────────────── */
.tabs {
  display: flex;
  gap: .15rem;
  margin: 0 0 2rem;
  border-bottom: 1px solid var(--trait);
  flex-wrap: wrap;
}
.tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  min-height: 42px;
  padding: 0 .95rem;
  color: var(--gris);
  font-size: var(--t-m);
  font-weight: 500;
  margin-bottom: -1px;
}
.tab-btn:hover { background: none; color: var(--encre); border-color: transparent; }
.tab-btn.is-active, .tab-btn.active {
  color: var(--petrole);
  border-bottom-color: var(--orange);
  background: none;
}

/* ── Pagination ───────────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 1.25rem;
  font-size: var(--t-m);
  color: var(--gris);
}
.pagination-boutons { display: flex; align-items: center; gap: .3rem; }
.pagination-boutons button { min-height: 34px; padding: 0 .7rem; font-size: var(--t-m); }
.pagination-boutons button.is-active {
  background: var(--petrole);
  border-color: var(--petrole);
  color: var(--sur-accent);
}

/* ═══ 9. Badges de statut ═══════════════════════════════════════════ */
.badge {
  display: inline-block;
  padding: .2rem .55rem;
  border-radius: var(--r-pilule);
  font-size: var(--t-xs);
  font-weight: 500;
  white-space: nowrap;
}
.badge-attente { background: var(--attente-fond); color: var(--attente-encre); }
.badge-validee { background: var(--ok-fond);      color: var(--ok-encre); }
.badge-refusee,
.badge-annulee { background: var(--refus-fond);   color: var(--refus-encre); }
.badge-neutre  { background: var(--neutre-fond);  color: var(--neutre-encre); }

/* ═══ 10. Chiffres clés ═════════════════════════════════════════════ */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: var(--e-5); }
.kpi-card { padding: var(--e-5); }
.kpi-label { font-size: var(--t-s); color: var(--gris); }
.kpi-value {
  font-size: var(--t-xl);
  font-weight: 500;
  letter-spacing: -.015em;
  color: var(--encre);
  margin-top: .25rem;
  font-variant-numeric: tabular-nums;
}

/* ═══ 11. Tiroir latéral ════════════════════════════════════════════
   Les formulaires de création vivaient en haut des pages et poussaient
   la liste hors de l'écran. Ils entrent maintenant par la droite : la
   liste reste à sa place, on garde son contexte. */
.tiroir-fond {
  position: fixed;
  inset: 0;
  background: rgba(4, 10, 14, .58);
  z-index: var(--z-tiroir);
  opacity: 0;
  transition: opacity var(--temps) var(--courbe);
}
.tiroir-fond.is-ouvert { opacity: 1; }

.tiroir {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(520px, 100vw);
  z-index: calc(var(--z-tiroir) + 1);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  box-shadow: var(--ombre-modale);
  transform: translateX(100%);
  transition: transform calc(var(--temps) * 1.6) var(--courbe);
}
.tiroir.is-ouvert { transform: translateX(0); }

.tiroir-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.5rem 1.75rem 1.1rem;
  border-bottom: 1px solid var(--trait);
}
.tiroir-head h2 { margin: 0; font-size: var(--t-l); font-weight: 600; }
.tiroir-head p { margin: .3rem 0 0; font-size: var(--t-m); color: var(--gris); }
.tiroir-fermer {
  flex: none;
  width: 34px; height: 34px;
  min-height: 0; padding: 0;
  border-color: transparent;
  color: var(--gris);
}
.tiroir-fermer:hover { background: var(--voile); border-color: var(--trait-fort); }

.tiroir-corps { flex: 1; overflow-y: auto; padding: 1.5rem 1.75rem; }
.tiroir-corps .form-grid { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }

.tiroir-pied {
  display: flex;
  justify-content: flex-end;
  gap: .55rem;
  padding: 1.1rem 1.75rem;
  border-top: 1px solid var(--trait);
}

/* ═══ 12. Notification brève ════════════════════════════════════════ */
.toast-zone {
  position: fixed;
  left: 50%; bottom: 2rem;
  transform: translateX(-50%);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: .5rem;
  align-items: center;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: .55rem;
  padding: .7rem 1.1rem;
  border-radius: var(--r-pilule);
  background: var(--flottant);
  color: var(--encre);
  font-size: var(--t-m);
  box-shadow: var(--ombre-flottant);
  animation: toast-entre calc(var(--temps) * 1.6) var(--courbe);
}
.toast.est-erreur { background: var(--refus-plein); color: var(--blanc); }
.toast svg { width: 16px; height: 16px; flex: none; }

@keyframes toast-entre {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

/* ═══ 13. Panneau de détail (Clients, Fournisseurs, Branches) ═══════ */
.panel { padding: var(--e-5); margin-bottom: var(--e-5); }
.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.1rem;
}
.panel-header h2 { margin: 0; font-size: var(--t-l); }
.panel-close { min-height: 34px; padding: 0 .75rem; font-size: var(--t-m); }

.sous-liste { margin-top: 1.75rem; padding-top: 1.35rem; border-top: 1px solid var(--trait); }
.sous-liste h3 { font-size: var(--t-m); color: var(--gris); margin: 0 0 .75rem; }
.ligne-compacte {
  display: flex; justify-content: space-between; align-items: center; gap: .9rem;
  padding: .6rem 0; border-bottom: 1px solid var(--trait); font-size: var(--t-m);
}
.ligne-compacte:last-child { border-bottom: none; }

.verrou {
  display: flex;
  align-items: flex-start;
  gap: .6rem;
  background: var(--attente-fond);
  color: var(--attente-encre);
  border-radius: var(--r-petit);
  padding: .75rem 1rem;
  font-size: var(--t-m);
  margin-bottom: 1.5rem;
}
.verrou svg { width: 16px; height: 16px; flex: none; margin-top: .12rem; }

/* Le bandeau « la page n'a pas pu se charger » et son bouton « Réessayer »
   (js/ui.js::echecChargement) : le même encart, le bouton au bout. */
.echec-chargement { align-items: center; flex-wrap: wrap; }
.echec-chargement button { margin-left: auto; }

.marge-positive { color: var(--ok-encre); }
.marge-negative { color: var(--danger); }

/* ═══ 14. Graphiques (js/charts.js) ═════════════════════════════════ */
.chart { position: relative; }
.chart-svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart-grid { stroke: var(--trait); stroke-width: 1; }
.chart-axis-label { fill: var(--gris); font-size: var(--t-xs); font-family: inherit; }
/* Graphiques dessinés à leur taille réelle (barChart) : texte à taille lisible. */
.chart-axis-label-reel { font-size: var(--t-xs); }
.chart-end-label { fill: var(--encre); font-size: var(--t-xs); font-weight: 500; font-family: inherit; }
.chart-crosshair { stroke: var(--trait-fort); stroke-width: 1; }
.chart-tooltip {
  position: absolute; top: 6%;
  background: var(--flottant); color: var(--encre);
  padding: .45rem .65rem; border-radius: var(--r-petit);
  font-size: var(--t-s); line-height: 1.5;
  pointer-events: none; white-space: nowrap;
  box-shadow: var(--ombre-flottant);
}
.chart-tooltip-x { color: rgba(255, 255, 255, .68); font-size: var(--t-xs); margin-bottom: .15rem; }
.chart-tooltip-dot, .chart-legend-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: .4rem; }
.chart-legend { display: flex; gap: 1.25rem; justify-content: center; margin-top: .6rem; font-size: var(--t-s); color: var(--gris); flex-wrap: wrap; }
.chart-legend-item { display: flex; align-items: center; }
.chart-table { margin-top: .7rem; }
.chart-table summary { color: var(--gris); font-size: var(--t-s); cursor: pointer; }
.chart-table summary:hover { color: var(--petrole); }
.chart-table > table { margin-top: .6rem; display: block; overflow-x: auto; }
.chart-table th, .chart-table td { text-align: right; white-space: nowrap; }
.chart-table thead th:first-child, .chart-table tbody th { text-align: left; color: var(--gris); font-weight: 500; }


/* Classement horizontal (js/charts.js::classement) — top fournisseurs,
   top clients. Une seule couleur : c'est un rang, pas une identité. */
.classement { list-style: none; margin: 0; padding: 0; }
.classement li + li { border-top: 1px solid var(--trait); }
.classement-ligne {
  display: grid;
  grid-template-columns: 1.4rem minmax(0, 11rem) minmax(0, 1fr) auto;
  align-items: center;
  gap: .8rem;
  width: 100%;
  padding: .6rem 0;
  background: none;
  border: none;
  font: inherit;
  color: inherit;
  text-align: left;
}
button.classement-ligne { cursor: pointer; border-radius: var(--r-petit); }
button.classement-ligne:hover { background: var(--voile); }
.classement-rang { color: var(--gris); font-size: var(--t-s); text-align: right; }
.classement-libelle { font-size: var(--t-m); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.classement-piste { height: 8px; background: var(--voile); border-radius: var(--r-mini); overflow: hidden; }
.classement-barre { display: block; height: 100%; border-radius: 0 4px 4px 0; }
.classement-valeur { font-size: var(--t-m); font-weight: 500; min-width: 6.5rem; text-align: right; }

/* ═══ 16. Accueil personnalisable ═══════════════════════════════════ */
.widgets-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(275px, 1fr)); gap: var(--e-5); align-items: start; }
.widget-tile { position: relative; padding: var(--e-5); }
.widget-tile-header { display: flex; justify-content: space-between; align-items: flex-start; gap: .5rem; margin-bottom: .9rem; }
.widget-tile-header h3 { margin: 0; font-size: var(--t-s); color: var(--gris); font-weight: 500; }
.widget-tile .kpi-grid { gap: 1rem; }
.widget-tile .kpi-card { padding: 0; }

.widget-shortcut { display: flex; align-items: center; justify-content: space-between; gap: 1rem; text-decoration: none; color: inherit; }
.widget-shortcut span { font-weight: 500; color: var(--petrole); font-size: var(--t-l); }
.widget-shortcut .fleche { color: var(--orange); display: inline-flex; }
.widget-shortcut .fleche svg { width: 18px; height: 18px; }

/* ═══ 17. Connexion ═════════════════════════════════════════════════ */
body.ecran-connexion {
  display: grid;
  grid-template-columns: 1fr;
  place-items: center;
  min-height: 100vh;
  padding: 1.5rem;
}
.login-box {
  width: 100%;
  max-width: 392px;
  padding: 2.75rem 2.5rem 2.5rem;
}
.login-brand { display: flex; flex-direction: column; align-items: center; gap: .9rem; margin-bottom: 2.25rem; }
.login-brand img { width: 58px; height: auto; }
/* La marque s'écrit comme dans le rail : capitales espacées, en Plex. */
.login-brand span {
  font-size: var(--t-base);
  font-weight: 600;
  letter-spacing: .13em;
  color: var(--encre);
}
.login-box button[type="submit"] { width: 100%; margin-top: .3rem; }
/* Le titre de la page, pour les lecteurs d'écran ; la direction « Atelier »
   l'affiche (css/atelier.css). */
.login-titre {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ═══ 18. Écrans étroits ════════════════════════════════════════════ */
@media (max-width: 1000px) {
  main.container { padding-right: var(--e-5); }
  .page-head { margin-bottom: 1.75rem; }
}

@media (max-width: 720px) {
  .widgets-grid { grid-template-columns: minmax(0, 1fr); }
  /* La barre devient statique et le rail passe en bas (glass.css) : la
     marge de gauche du rail n'a plus lieu d'être. Cette règle vit ici, et
     pas dans glass.css, parce que glass.css est importé avant la règle de
     base de main.container : à spécificité égale, elle perdait (audit
     design du 10/11/2026). */
  main.container { padding: var(--e-5) var(--e-4) 96px; }
  body.en-espion main.container { padding-top: var(--e-5); }
}

@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
  .page-head { align-items: flex-start; }
  .page-actions { width: 100%; }
  .page-actions .btn-link, .page-actions .btn-principal { flex: 1; }
  .tiroir { width: 100vw; }
  .tiroir-head, .tiroir-corps, .tiroir-pied { padding-left: 1.25rem; padding-right: 1.25rem; }
}

/* ═══ 19. Mouvement réduit ══════════════════════════════════════════
   Règle d'accessibilité : qui a demandé moins d'animation n'en reçoit
   aucune. Le tiroir apparaît, il ne glisse plus. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  .tiroir { transform: none; opacity: 0; pointer-events: none; }
  .tiroir.is-ouvert { opacity: 1; pointer-events: auto; }
}

/* ═══ 20. Budget de trésorerie ══════════════════════════════════════
   Le tableau annuel repris de SMG PILOT : 12 mois en colonnes, des
   postes en lignes, repliables sur 3 niveaux. C'est le seul écran de
   l'application assez dense pour mériter ses propres règles — ailleurs,
   l'espace fait la structure ; ici, c'est la grille. */

.tb-onglets {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  flex-wrap: wrap;
  margin: 2rem 0 0;
  border-bottom: 1px solid var(--trait);
}
.tb-annees, .tb-perimetres { display: flex; gap: .15rem; flex-wrap: wrap; }

.tb-onglet {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  min-height: 40px;
  padding: 0 .85rem;
  margin-bottom: -1px;
  color: var(--gris);
  font-size: var(--t-m);
  font-weight: 500;
}
.tb-onglet:hover { background: none; color: var(--encre); border-color: transparent; }
.tb-onglet.is-active { color: var(--petrole); border-bottom-color: var(--orange); background: none; }

/* Les périmètres se distinguent des années : ils filtrent, ils ne
   naviguent pas dans le temps. */
.tb-perimetres .tb-onglet { font-size: var(--t-m); }
.tb-perimetres .tb-onglet.is-active { color: var(--encre); }

.tb-barre {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-wrap: wrap;
  padding: 1rem 0 1.25rem;
}

.tb-niveau { display: inline-flex; align-items: center; gap: .2rem; }
.tb-niveau-lbl { font-size: var(--t-s); color: var(--gris); margin-right: .35rem; }
.tb-niveau-btn {
  min-height: 32px;
  padding: 0 .6rem;
  font-size: var(--t-s);
  background: var(--voile);
  border-color: var(--trait-fort);
  color: var(--gris);
}
.tb-niveau-btn.is-active {
  background: var(--petrole);
  border-color: var(--petrole);
  color: var(--sur-accent);
}

.tb-legende { display: flex; gap: 1rem; font-size: var(--t-s); color: var(--gris); flex-wrap: wrap; }
.tb-legende i { font-style: normal; display: inline-flex; align-items: center; gap: .35rem; }
.tb-point { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.tb-point-reel { background: var(--petrole); }
.tb-point-prev { background: var(--trait-fort); border: 1px solid var(--gris); }

.tb-recherche { flex: 0 1 240px; margin: 0; }
.tb-recherche input { margin-top: 0; min-height: 36px; }

.tb-solde { display: inline-flex; align-items: center; gap: .5rem; font-size: var(--t-s); color: var(--gris); }
.tb-solde input { width: 130px; min-height: 36px; margin-top: 0; text-align: right; }

.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;
}

/* ── Barre d'actions groupées ─────────────────────────────────────── */
.tb-selection {
  position: sticky;
  top: calc(var(--hauteur-barre) + var(--e-2));
  z-index: var(--z-menu);
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
  padding: .7rem 1rem;
  margin-bottom: .75rem;
  background: var(--flottant);
  border-radius: var(--r-moyen);
  color: var(--encre);
  font-size: var(--t-m);
}
.tb-selection button { min-height: 32px; padding: 0 .7rem; font-size: var(--t-s); }
.tb-selection .btn-discret { color: rgba(255, 255, 255, .75); }
.tb-selection .btn-discret:hover { background: rgba(255, 255, 255, .12); color: #fff; }

/* ── La grille ────────────────────────────────────────────────────── */
.tb-wrap { overflow-x: auto; background: var(--surface); border-radius: var(--r-moyen); }

.tb-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--t-s);
  font-variant-numeric: tabular-nums;
}
.tb-table thead th {
  position: sticky;
  top: 0;
  z-index: var(--z-collant);
  background: var(--surface);
  padding: .55rem .5rem;
  font-size: var(--t-xs);
  font-weight: 600;
  color: var(--gris);
  border-bottom: 1px solid var(--trait-fort);
  white-space: nowrap;
}
/* Un mois clos ne se modifie plus : l'en-tête le dit discrètement. */
.tb-table thead th.tb-clos { color: var(--petrole); }
.tb-table thead th.tb-clos::after { content: " ·"; color: var(--orange); }

.tb-table td, .tb-table th { border-bottom: 1px solid var(--trait); }

/* La colonne des postes reste visible quand on fait défiler les mois. */
.tb-poste {
  position: sticky;
  left: 0;
  z-index: 5;
  background: var(--surface);
  text-align: left;
  font-weight: 400;
  padding: .38rem .6rem .38rem .25rem;
  min-width: 190px;
  max-width: 230px;
  line-height: 1.3;
}
.tb-table thead .tb-poste { z-index: 15; }

.tb-num { text-align: right; padding: .38rem .4rem; white-space: nowrap; }
.tb-total { font-weight: 600; border-left: 1px solid var(--trait-fort); }
.tb-pct { color: var(--gris); font-size: var(--t-xs); width: 52px; }
.tb-negatif { color: var(--danger); }

/* Niveaux : chaque rang s'enfonce un peu plus. */
.tb-rang-1 { padding-left: 1.15rem; }
.tb-rang-2 { padding-left: 2.1rem; }
.tb-rang-3 { padding-left: 3.05rem; }

.tb-lbl { display: block; }
.tb-sous { display: block; font-size: var(--t-xs); color: var(--gris); line-height: 1.25; }
.tb-vide { color: var(--gris); font-style: italic; font-size: var(--t-s); }

/* Section (niveau 0) : Encaissements, Décaissements, Synthèse. */
.tb-section th, .tb-section td {
  background: var(--voile);
  font-weight: 600;
  color: var(--encre);
  border-bottom: 1px solid var(--trait-fort);
  padding-top: .6rem;
  padding-bottom: .6rem;
}
.tb-section .tb-poste { font-size: var(--t-m); }

/* Espace (niveau 1) et sous-famille (niveau 2). */
.tb-espace th, .tb-espace td { font-weight: 600; }
.tb-espace .tb-poste { color: var(--petrole); }
.tb-sousfam th, .tb-sousfam td { font-weight: 500; }
.tb-sousfam .tb-poste { color: var(--encre); }

.tb-reel-row td, .tb-reel-row th { color: var(--encre); }
.tb-prev-row td, .tb-prev-row th { color: var(--gris); }

.tb-flux td, .tb-flux th { font-weight: 500; }
.tb-cumul td, .tb-cumul th {
  font-weight: 600;
  border-top: 1px solid var(--trait-fort);
  border-bottom: none;
}
.tb-cumul .tb-poste { color: var(--petrole); }

.tb-chevron {
  background: none;
  border: none;
  min-height: 0;
  width: 18px; height: 18px;
  padding: 0;
  margin-right: .4rem;
  color: var(--gris);
  vertical-align: -3px;
  transition: transform var(--temps) var(--courbe);
}
.tb-chevron svg { width: 12px; height: 12px; }
.tb-chevron.is-ouvert { transform: rotate(90deg); }
.tb-chevron:hover { background: none; color: var(--petrole); }

/* Une case saisissable se signale au survol, pas au repos : douze
   colonnes encadrées feraient un damier illisible. */
.tb-saisie { cursor: pointer; }
.tb-saisie:hover { background: var(--voile); box-shadow: inset 0 0 0 1px var(--trait-fort); }
.tb-saisie.tb-prev { color: var(--gris); }
.tb-saisie.is-selectionnee {
  background: rgba(232, 99, 13, .22);
  box-shadow: inset 0 0 0 1px var(--braise);
}

.tb-case-input {
  width: 100%;
  min-height: 28px;
  margin: 0;
  padding: .15rem .3rem;
  text-align: right;
  font-size: var(--t-s);
  font-variant-numeric: tabular-nums;
}

.tb-propose { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.tb-propose button { min-height: 32px; padding: 0 .7rem; font-size: var(--t-s); margin-left: auto; }

.kpi-sub { font-size: var(--t-xs); color: var(--gris); margin-top: .25rem; }

@media (max-width: 1000px) {
  .tb-poste { position: static; min-width: 180px; }
  .tb-barre { gap: .75rem; }
}

/* ═══ 21. Catalogue et chiffrage ════════════════════════════════════
   Le catalogue se range en familles repliables (SMG PILOT), et le
   tiroir de saisie affiche le prix en direct — c'est cette boucle de
   retour qui fait comprendre ce qu'une heure de plus coûte au client. */

.cat-famille { margin-bottom: 2rem; }

.cat-famille-tete {
  display: flex;
  align-items: center;
  gap: .75rem;
  width: 100%;
  min-height: 44px;
  padding: 0 .25rem;
  background: none;
  border: none;
  border-bottom: 1px solid var(--trait-fort);
  border-radius: 0;
  justify-content: flex-start; /* un bouton centre son contenu par défaut */
  text-align: left;
  font-size: var(--t-base);
  color: var(--encre);
}
.cat-famille-tete:hover { background: var(--voile); border-color: var(--trait-fort); }
.cat-famille-tete strong { font-weight: 600; color: var(--petrole); }
.cat-famille-tete .montant { margin-left: auto; font-variant-numeric: tabular-nums; }

/* Une mention discrète à côté d'un libellé de champ (« facultatif »). */
.aide-inline { font-weight: 400; color: var(--gris-clair); }

/* Le tiroir « tarif » (js/tarif-tiroir.js) : la case du catalogue ouvre la
   référence et la famille juste en dessous. */
.tarif-case { margin-top: .5rem; }

/* ── Le chiffrage en direct, dans le tiroir ───────────────────────── */
.chiffrage {
  background: var(--voile);
  border: 1px solid var(--trait);
  border-radius: var(--r-moyen);
  padding: 1.1rem 1.25rem;
  margin-bottom: 1.05rem;
}
.chiffrage h3 { margin: 0 0 .75rem; font-size: var(--t-s); color: var(--gris); }

.chiffrage-detail { list-style: none; margin: 0 0 .9rem; padding: 0; }
.chiffrage-detail li {
  display: flex;
  align-items: baseline;
  gap: .6rem;
  padding: .25rem 0;
  font-size: var(--t-s);
  border-bottom: 1px solid var(--trait);
}
.chiffrage-detail li:last-child { border-bottom: none; }
.chiffrage-detail li .montant { margin-left: auto; font-variant-numeric: tabular-nums; }

.chiffrage-totaux { display: grid; gap: .3rem; }
.chiffrage-totaux > div {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-size: var(--t-m);
}
.chiffrage-totaux strong { font-variant-numeric: tabular-nums; }
.chiffrage-marge { padding-top: .3rem; }

/* Le prix : c'est la seule chose qu'on cherche des yeux en saisissant. */
.chiffrage-pv {
  margin-top: .5rem;
  padding-top: .6rem;
  border-top: 1px solid var(--trait-fort);
  align-items: baseline;
}
.chiffrage-pv span { color: var(--gris); font-size: var(--t-s); }
.chiffrage-pv strong {
  font-size: var(--t-xl);
  font-weight: 500;
  color: var(--petrole);
  letter-spacing: -.01em;
}

.champ-taux { width: 86px; display: inline-block; text-align: right; margin-top: 0; }

/* ═══ Glisser-déposer (js/glisser.js) ═══════════════════════════════
   L'élément attrapé flotte au-dessus de tout, légèrement soulevé ; sa place
   d'arrivée reste visible en creux pointillé. */
.glisse-fantome {
  position: fixed;
  z-index: var(--z-glisse);
  margin: 0;
  pointer-events: none;
  box-shadow: var(--ombre-modale);
  transform: rotate(-1deg) scale(1.02);
  opacity: .97;
  background: var(--surface);
}
.glisse-place {
  opacity: 1;
  background: var(--voile) !important;
  border: 1px dashed var(--trait-fort) !important;
  box-shadow: none !important;
}
.glisse-place > * { visibility: hidden; }
.glisse-saisi { outline: 2px solid var(--orange); outline-offset: 3px; }
body.glisse-en-cours, body.glisse-en-cours * { cursor: grabbing !important; user-select: none; }

@media (prefers-reduced-motion: reduce) {
  .glisse-fantome { transform: none; }
}
.tb-pieces { margin-top: 2.5rem; }

/* Facturé : une pièce close, pas une étape réussie — une teinte pétrole
   pleine, pour ne plus se confondre avec le vert d'« Accepté » (et pas un
   contour, qui se lisait comme un petit bouton). */
.badge-close { background: var(--close-fond, rgba(92, 196, 217, .16)); color: var(--close-encre, #9fdcea); }
