/* =====================================================================
   Soclai Ferrailleur — systeme de design
   ---------------------------------------------------------------------
   Contexte : poste de pesee, souvent sur tablette, debout, parfois au
   soleil ou de nuit. D'ou : contrastes eleves, cibles >= 44 px, chiffres
   en chasse fixe, et un mode sombre reel (pas un simple filtre).

   Palette : neutres ardoise + un bleu acier comme couleur d'action, et
   un cuivre en couleur d'alerte — les deux metaux du metier.
   ===================================================================== */

/* ---------------------------------------------------------------- jetons */
:root {
  color-scheme: light;

  /* neutres */
  --n0:  #ffffff;
  --n5:  #f7f8fa;
  --n10: #eef1f5;
  --surface:      #ffffff;
  --surface-2:    #f7f8fa;
  --surface-3:    #eef1f5;
  --fond:         #f2f4f7;
  --bord:         #dfe4ea;
  --bord-fort:    #c6cdd7;
  --texte:        #0f1720;
  --texte-doux:   #5a6675;
  --texte-faible: #8a94a2;

  /* acier : action */
  --acier-50:  #eaf2f8;
  --acier-100: #cfe2ef;
  --acier-500: #1d6491;
  --acier-600: #17537a;
  --acier-700: #114060;

  /* cuivre : attention */
  --cuivre-50:  #fdf3e8;
  --cuivre-200: #f3d6ae;
  --cuivre-600: #a85f1c;

  /* etats */
  --vert-50:  #e9f6ee;  --vert-200: #b3ddc3;  --vert-700: #15703c;
  --rouge-50: #fdecec;  --rouge-200: #f0b7b7; --rouge-700: #a3201f;

  /* semantique */
  --accent:        var(--acier-500);
  --accent-fort:   var(--acier-600);
  --accent-doux:   var(--acier-50);
  --sur-accent:    #ffffff;   /* texte posé sur la couleur principale */
  --succes-fond:   var(--vert-50);   --succes-bord: var(--vert-200);  --succes-texte: var(--vert-700);
  --erreur-fond:   var(--rouge-50);  --erreur-bord: var(--rouge-200); --erreur-texte: var(--rouge-700);
  --avert-fond:    var(--cuivre-50); --avert-bord: var(--cuivre-200); --avert-texte: var(--cuivre-600);

  /* formes */
  --r-sm: 6px;  --r-md: 10px;  --r-lg: 14px;  --r-pill: 999px;
  --ombre-1: 0 1px 2px rgba(15, 23, 32, .06), 0 1px 1px rgba(15, 23, 32, .04);
  --ombre-2: 0 2px 4px rgba(15, 23, 32, .06), 0 4px 12px rgba(15, 23, 32, .07);
  --ombre-3: 0 8px 28px rgba(15, 23, 32, .14);

  /* rythme */
  --e1: 4px; --e2: 8px; --e3: 12px; --e4: 16px; --e5: 20px;
  --e6: 24px; --e7: 32px; --e8: 40px;

  --nav-l: 248px;
  /* écran très large : au-delà, le contenu reste centré sur le fond gris */
  --contenu-max: 1920px;
  --transition: 140ms cubic-bezier(.4, 0, .2, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --surface:      #161c24;
    --surface-2:    #1d242e;
    --surface-3:    #252d38;
    --fond:         #0e131a;
    --bord:         #2b3440;
    --bord-fort:    #3c4756;
    --texte:        #e8edf3;
    --texte-doux:   #9aa6b5;
    --texte-faible: #6f7c8c;

    --acier-50:  #14212c;
    --acier-100: #1b3244;
    --acier-500: #5aa9d6;
    --acier-600: #7cc0e6;
    --acier-700: #9ad2f0;

    --cuivre-50: #2a1e10;  --cuivre-200: #5c4220;  --cuivre-600: #e0a862;
    --vert-50:   #12261a;  --vert-200:   #2b5a3a;  --vert-700:   #7fd3a0;
    --rouge-50:  #2c1617;  --rouge-200:  #5d2b2c;  --rouge-700:  #f0a0a0;

    --ombre-1: 0 1px 2px rgba(0, 0, 0, .4);
    --ombre-2: 0 2px 6px rgba(0, 0, 0, .45);
    --ombre-3: 0 10px 34px rgba(0, 0, 0, .6);
  }
}

* { box-sizing: border-box; }

/* Toute regle "display:flex/grid" ecrite ici a la meme specificite que le
   [hidden] de la feuille du navigateur, et gagne parce qu'elle vient apres.
   Sans ce garde-fou, un element marque hidden reste visible : c'est ce qui
   affichait la fiche vendeur vide et les champs cheque en meme temps que
   ceux du virement. */
[hidden] { display: none !important; }

/* la place de la barre de défilement est toujours réservée : la barre haute
   ne se décale plus d'une page à l'autre */
html { -webkit-text-size-adjust: 100%; scrollbar-gutter: stable; }

body {
  margin: 0;
  background: var(--fond);
  color: var(--texte);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { line-height: 1.25; letter-spacing: -.01em; }

a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-fort); }

::selection { background: var(--acier-100); color: var(--texte); }

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

.sr, .saut-contenu {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.saut-contenu:focus {
  position: fixed; top: 12px; left: 12px; z-index: 100;
  width: auto; height: auto; margin: 0; clip: auto;
  padding: 10px 16px; background: var(--surface); color: var(--texte);
  border-radius: var(--r-md); box-shadow: var(--ombre-3);
}

.oblig { color: var(--erreur-texte); font-weight: 700; }
.maj { text-transform: uppercase; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
/* "table.t th, table.t td" (0,1,1) bat ".num" (0,1,0) : sans ces deux
   selecteurs plus specifiques, aucune colonne de chiffres n'est alignee. */
table.t th.num, table.t td.num { text-align: right; }

/* =====================================================================
   Coque : rail lateral + barre haute
   ===================================================================== */

.app { display: flex; min-height: 100vh; }

.rail {
  position: fixed; inset: 0 auto 0 0; z-index: 40;
  width: var(--nav-l);
  display: flex; flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--bord);
}

.rail-marque {
  display: flex; align-items: center; gap: 10px;
  padding: var(--e5) var(--e4) var(--e4);
  border-bottom: 1px solid var(--bord);
}
.rail-logo {
  display: grid; place-items: center;
  width: 34px; height: 34px; flex: none;
  border-radius: var(--r-md);
  background: linear-gradient(140deg, var(--acier-500), var(--acier-700));
  color: var(--sur-accent); font-weight: 800; font-size: 15px; letter-spacing: -.02em;
}
.rail-nom { display: block; font-weight: 700; font-size: 15px; line-height: 1.2; }
.rail-sous { display: block; font-size: 11.5px; color: var(--texte-faible); }

.rail-nav { flex: 1; overflow-y: auto; padding: var(--e3) var(--e2); }
.rail-groupe {
  padding: var(--e4) var(--e3) var(--e2);
  font-size: 10.5px; font-weight: 700; letter-spacing: .09em;
  text-transform: uppercase; color: var(--texte-faible);
}
.rail-nav ul { list-style: none; margin: 0; padding: 0; }
.rail-nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 9px var(--e3); margin-bottom: 2px;
  border-radius: var(--r-md);
  color: var(--texte-doux); text-decoration: none;
  font-size: 14px; font-weight: 500;
  transition: background var(--transition), color var(--transition);
}
.rail-nav a:hover { background: var(--surface-3); color: var(--texte); }
.rail-nav a[aria-current="page"] {
  background: var(--acier-50); color: var(--accent-fort); font-weight: 650;
}
.rail-nav a[aria-current="page"] .ico { color: var(--accent); }
.ico { width: 18px; height: 18px; flex: none; color: var(--texte-faible); }

.rail-pied {
  padding: var(--e2) var(--e2) var(--e3);
  border-top: 1px solid var(--bord);
  font-size: 11.5px; color: var(--texte-faible);
}
.rail-legal { margin: var(--e2) var(--e3) 0; line-height: 1.4; }
.rail-replier {
  display: flex; align-items: center; gap: 11px; width: 100%;
  padding: 8px var(--e3); border: 0; border-radius: var(--r-md);
  background: none; color: var(--texte-doux); font: inherit; font-size: 13px; cursor: pointer;
}
.rail-replier:hover { background: var(--surface-3); color: var(--texte); }
a.rail-replier { text-decoration: none; }
/* bureautique : menu resserré, il tient sur la hauteur d'un écran de bureau */
body.mode-bureau .rail-nav { padding-top: var(--e1); }
body.mode-bureau .rail-groupe { margin: 0; padding: 10px var(--e3) 2px; }
body.mode-bureau .rail-nav a { padding: 6px var(--e3); margin-bottom: 1px; font-size: 13.5px; }
body.mode-bureau .rail-marque { padding-top: var(--e3); padding-bottom: var(--e3); }
body.mode-bureau .rail-pied .rail-replier { padding-top: 6px; padding-bottom: 6px; }
a.rail-replier[aria-current="page"] { background: var(--acier-50); color: var(--accent-fort); font-weight: 650; }
.rail-replier .ico { transition: transform var(--transition); }
/* flèche ronde à cheval sur le bord droit du menu, toujours visible */
.rail-poignee {
  position: absolute; top: 55px; right: -16px; z-index: 2;
  display: grid; place-items: center; width: 32px; height: 32px; padding: 0;
  border: 1px solid var(--bord-fort); border-radius: 50%;
  background: var(--surface); color: var(--accent); box-shadow: var(--ombre-2, var(--ombre-1));
  cursor: pointer; transition: background var(--transition), transform var(--transition);
}
.rail-poignee .ico { width: 18px; height: 18px; color: currentColor; transition: transform var(--transition); }
.rail-poignee:hover { background: var(--accent); color: var(--sur-accent); border-color: var(--accent); }
.rail-poignee:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* --- zone principale --- */
.principal { flex: 1; min-width: 0; margin-left: var(--nav-l); }

.barre-haute {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: var(--e4);
  padding: var(--e3) var(--e6);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.6) blur(10px);
  border-bottom: 1px solid var(--bord);
}
.barre-titre { font-size: 17px; font-weight: 650; margin: 0; }
.barre-actions-haut { margin-left: auto; display: flex; align-items: center; gap: var(--e3); }

.puce-user {
  display: flex; text-decoration: none; color: var(--texte); align-items: center; gap: var(--e2);
  padding: 5px 6px 5px 5px; border-radius: var(--r-pill);
  background: var(--surface-3);
}
.puce-rond {
  display: grid; place-items: center;
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--acier-500); color: var(--sur-accent);
  font-size: 12px; font-weight: 700;
}
.puce-texte { font-size: 12.5px; line-height: 1.2; padding-right: var(--e2); }
.puce-role { display: block; color: var(--texte-faible); font-size: 11px; }

.ouvre-rail {
  display: none; width: 40px; height: 40px;
  align-items: center; justify-content: center;
  border: 1px solid var(--bord); border-radius: var(--r-md);
  background: var(--surface); color: var(--texte); cursor: pointer;
}
.voile { display: none; }

.contenu { max-width: var(--contenu-max); margin: 0 auto; padding: var(--e6); }

@media (max-width: 1000px) {
  .rail {
    transform: translateX(-100%);
    transition: transform var(--transition);
    box-shadow: var(--ombre-3);
  }
  body.rail-ouvert .rail { transform: none; }
  body.rail-ouvert .voile {
    display: block; position: fixed; inset: 0; z-index: 35;
    background: rgba(8, 12, 18, .5);
  }
  .principal { margin-left: 0; }
  .ouvre-rail { display: inline-flex; }
  .contenu { padding: var(--e4); }
  .barre-haute { padding: var(--e3) var(--e4); }
}

/* =====================================================================
   Cartes, grilles, indicateurs
   ===================================================================== */


.carte {
  --carte-p: var(--e5);
  background: var(--surface);
  border: 1px solid var(--bord);
  border-radius: var(--r-lg);
  padding: var(--carte-p);
  box-shadow: var(--ombre-1);
  min-width: 0;
}
/* titre de bloc : le MÊME partout (cartes, fieldsets, modules) */
.carte h2, legend {
  margin: 0 0 var(--e4);
  font-size: 11.5px; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--texte-faible);
}
.carte > h2:not(:first-child) { margin-top: var(--e6); }

.kpi-valeur {
  font-size: 28px; font-weight: 700; letter-spacing: -.02em;
  font-variant-numeric: tabular-nums; line-height: 1.1;
}
.kpi-detail { color: var(--texte-doux); font-size: 13px; margin-top: var(--e1); }

/* =====================================================================
   Tableaux
   ===================================================================== */

.tableau-enveloppe {
  overflow-x: auto;
  border: 1px solid var(--bord);
  border-radius: var(--r-lg);
  background: var(--surface);
}
.carte .tableau-enveloppe { border: 0; border-radius: 0; background: none; }

table.t { width: 100%; border-collapse: collapse; }
table.t th, table.t td {
  padding: 11px var(--e4); text-align: left;
  border-bottom: 1px solid var(--bord); font-size: 14px;
}
table.t thead th {
  position: sticky; top: 0;
  background: var(--surface-2);
  font-size: 11px; font-weight: 700; letter-spacing: .07em;
  text-transform: uppercase; color: var(--texte-faible);
  white-space: nowrap;
}
table.t tbody tr { transition: background var(--transition); }
table.t tbody tr:hover { background: var(--surface-2); }
table.t tbody tr:last-child td { border-bottom: 0; }
table.t tfoot td {
  font-weight: 700; background: var(--surface-2);
  border-top: 2px solid var(--bord-fort); border-bottom: 0;
}
table.t a { font-weight: 600; text-decoration: none; white-space: nowrap; }
table.t a:hover { text-decoration: underline; }

/* =====================================================================
   Formulaires
   ===================================================================== */

/* un fieldset a l'allure d'une carte ; sa légende (flottante) est rangée
   DANS le cadre, comme le titre d'une carte, et non à cheval sur la bordure */
fieldset {
  border: 1px solid var(--bord); border-radius: var(--r-lg);
  padding: var(--e5); margin: 0 0 var(--e4); min-width: 0;
  background: var(--surface); box-shadow: var(--ombre-1);
}
legend { float: left; width: 100%; padding: 0; }
legend + * { clear: both; }

.champs { display: grid; gap: var(--e3); grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.champ { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.champ label, .etiquette {
  font-size: 12.5px; font-weight: 650; color: var(--texte-doux);
}
.champ .aide { font-size: 12px; color: var(--texte-faible); line-height: 1.4; }

input, select, textarea {
  font: inherit; color: var(--texte);
  background: var(--surface);
  border: 1px solid var(--bord-fort); border-radius: var(--r-md);
  padding: 10px 12px; min-height: 44px; width: 100%;
  transition: border-color var(--transition), box-shadow var(--transition);
}
input::placeholder { color: var(--texte-faible); }
input:hover, select:hover, textarea:hover { border-color: var(--texte-faible); }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}
input[readonly] { background: var(--surface-3); color: var(--texte-doux); border-style: dashed; }
input[aria-invalid="true"] { border-color: var(--erreur-texte); }
textarea { min-height: 84px; resize: vertical; }
select {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%235a6675' stroke-width='1.8' stroke-linecap='round'%3E%3Cpath d='M4 6.5 8 10.5 12 6.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
  background-size: 16px; padding-right: 34px;
}
input[type="checkbox"], input[type="radio"] { width: auto; min-height: 0; accent-color: var(--accent); }

/* =====================================================================
   Boutons
   ===================================================================== */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--e2);
  padding: 10px 18px; min-height: 44px;
  border: 1px solid transparent; border-radius: var(--r-md);
  background: var(--accent); color: var(--sur-accent);
  font: inherit; font-weight: 650; font-size: 14px;
  text-decoration: none; cursor: pointer; white-space: nowrap;
  box-shadow: var(--ombre-1);
  transition: background var(--transition), transform var(--transition),
              box-shadow var(--transition);
}
.btn:hover { background: var(--accent-fort); color: var(--sur-accent); box-shadow: var(--ombre-2); }
.btn:active { transform: translateY(1px); box-shadow: var(--ombre-1); }

.btn-secondaire {
  background: var(--surface); color: var(--texte);
  border-color: var(--bord-fort);
}
.btn-secondaire:hover { background: var(--surface-3); color: var(--texte); }

.btn-danger { background: var(--erreur-texte); }
.btn-danger:hover { background: color-mix(in srgb, var(--erreur-texte) 82%, #000); }

.btn-mince { padding: 6px 12px; min-height: 34px; font-size: 13px; font-weight: 600; }
/* Clients particuliers : « Particulier » / « Pro », classement après coup (app.js) */
.classer-vendeur { display: inline-flex; gap: 4px; }
.classer-vendeur.en-cours { opacity: .6; pointer-events: none; }

.barre-actions { display: flex; flex-wrap: wrap; gap: var(--e3); margin: var(--e5) 0; }

/* =====================================================================
   Alertes et pastilles
   ===================================================================== */

/* sans icône : bloc de texte ordinaire (en flex, chaque <strong> ou <code>
   devenait une colonne) ; avec icône : icône à gauche, texte dans UN <span> */
.alerte {
  display: block;
  padding: var(--e3) var(--e4); margin: 0 0 var(--e4);
  border: 1px solid; border-left-width: 4px;
  border-radius: var(--r-md); font-size: 14px;
}
.alerte:has(> .ico) { display: flex; gap: var(--e3); align-items: flex-start; }
.alerte-succes { background: var(--succes-fond); border-color: var(--succes-bord); color: var(--succes-texte); }
.alerte-erreur { background: var(--erreur-fond); border-color: var(--erreur-bord); color: var(--erreur-texte); }
.alerte-avert  { background: var(--avert-fond);  border-color: var(--avert-bord);  color: var(--avert-texte); }
.alerte ul { margin: var(--e2) 0 0; padding-left: var(--e5); }
.alerte li + li { margin-top: 3px; }
.alerte .ico { color: currentColor; margin-top: 2px; }

.pastille {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: var(--r-pill);
  font-size: 12px; font-weight: 650; white-space: nowrap;
  border: 1px solid transparent;
}
.pastille::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: currentColor;
}
.pastille-valide  { background: var(--succes-fond); color: var(--succes-texte); border-color: var(--succes-bord); }
.pastille-attente { background: var(--avert-fond);  color: var(--avert-texte);  border-color: var(--avert-bord); }
.pastille-annule  { background: var(--erreur-fond); color: var(--erreur-texte); border-color: var(--erreur-bord); }

/* =====================================================================
   Connexion
   ===================================================================== */

.page-connexion {
  min-height: 100vh; display: grid; place-items: center; padding: var(--e5);
  background:
    radial-gradient(1100px 520px at 12% -8%, var(--acier-50), transparent 62%),
    radial-gradient(900px 460px at 88% 108%, var(--cuivre-50), transparent 62%),
    var(--fond);
}
.boite-connexion { width: 100%; max-width: 396px; }
.boite-connexion .carte { padding: var(--e7); box-shadow: var(--ombre-3); }
.boite-marque { display: flex; align-items: center; gap: var(--e3); margin-bottom: var(--e5); }
.boite-connexion h1 { margin: 0; font-size: 21px; }
.boite-connexion .sous { color: var(--texte-doux); font-size: 13.5px; margin: 2px 0 0; }
.connexion-pied {
  margin: var(--e5) 0 0; text-align: center;
  font-size: 11.5px; color: var(--texte-faible); line-height: 1.5;
}

/* =====================================================================
   Ecrans de saisie : etapes, pesee, barre de totaux
   ===================================================================== */

.saisie { padding-bottom: 104px; }

.etape {
  background: var(--surface);
  border: 1px solid var(--bord);
  border-radius: var(--r-lg);
  padding: var(--e5);
  margin-bottom: var(--e4);
  box-shadow: var(--ombre-1);
}
.etape-titre {
  display: flex; align-items: center; gap: var(--e3);
  margin: 0 0 var(--e5); font-size: 16px; font-weight: 650;
}
.etape-num {
  display: grid; place-items: center;
  width: 28px; height: 28px; flex: none; border-radius: 50%;
  background: var(--accent); color: var(--sur-accent);
  font-size: 13px; font-weight: 700;
}

.champs-serres { display: flex; flex-wrap: wrap; gap: var(--e3); margin-bottom: var(--e3); }
.champs-serres .champ { flex: 1 1 170px; }
.champs-serres .champ-large { flex: 3 1 280px; }
.champs-serres .champ-cp { flex: 0 0 120px; }
.champs-serres .champ-civilite { flex: 0 0 auto; }
.champs-serres .champ-piece { flex: 0 0 200px; }
.champs-serres .champ-iban { flex: 3 1 330px; }
.champs-serres .champ-bic { flex: 0 0 150px; }

/* --- recherche vendeur --- */
.recherche-vendeur { position: relative; margin-bottom: var(--e5); }
.recherche-label { display: block; font-weight: 650; font-size: 13px; margin-bottom: 6px; }
.recherche-vendeur input[type="search"] {
  font-size: 16px; min-height: 54px; padding-left: 42px;
  border-width: 2px; border-color: var(--accent);
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%231d6491' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='9' cy='9' r='5.5'/%3E%3Cpath d='M13.2 13.2 17 17'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: 13px center; background-size: 20px;
}
.resultats {
  position: absolute; z-index: 25; left: 0; right: 0; top: calc(100% + 4px);
  background: var(--surface); border: 1px solid var(--bord-fort);
  border-radius: var(--r-md); box-shadow: var(--ombre-3);
  max-height: 320px; overflow-y: auto; padding: var(--e1);
}
.resultats button {
  display: block; width: 100%; text-align: left;
  padding: 10px var(--e3); border: 0; border-radius: var(--r-sm);
  background: none; font: inherit; color: var(--texte); cursor: pointer;
}
.resultats button:hover, .resultats button:focus { background: var(--acier-50); }
.resultats .r-nom { font-weight: 650; }
.resultats .r-detail { display: block; font-size: 12.5px; color: var(--texte-faible); }

.fiche-vendeur {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--e4); padding: var(--e4);
  background: var(--succes-fond); border: 1px solid var(--succes-bord);
  border-radius: var(--r-md); margin-bottom: var(--e5);
}
.fiche-detail { display: block; font-size: 12.5px; color: var(--texte-doux); }

/* --- boutons segmentes --- */
.segmente {
  display: inline-flex; padding: 3px;
  background: var(--surface-3); border-radius: var(--r-md);
}
.segmente label { position: relative; }
.segmente input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.segmente span {
  display: block; padding: 9px 18px; min-height: 38px;
  border-radius: var(--r-sm); cursor: pointer;
  font-weight: 650; font-size: 13.5px; color: var(--texte-doux);
  white-space: nowrap; transition: all var(--transition);
}
.segmente input:checked + span {
  background: var(--surface); color: var(--accent-fort); box-shadow: var(--ombre-1);
}
.segmente input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }
.segmente-large span { padding: 11px 30px; font-size: 14.5px; }
.champ-mode { margin-bottom: var(--e4); }

/* --- acces rapide metaux --- */
.acces-rapide { display: flex; flex-wrap: wrap; gap: var(--e2); margin-bottom: var(--e4); }
.jeton {
  padding: 9px 14px; min-height: 40px;
  border: 1px solid var(--bord-fort); border-radius: var(--r-pill);
  background: var(--surface); color: var(--texte);
  font: inherit; font-size: 13px; font-weight: 650; cursor: pointer;
  transition: all var(--transition);
}
.jeton:hover {
  border-color: var(--accent); color: var(--accent-fort);
  background: var(--acier-50); transform: translateY(-1px);
}
.jeton:active { transform: none; }
.jeton-mince { padding: 4px 10px; min-height: 28px; font-size: 12px; font-weight: 600; }
.jeton.actif {
  border-color: var(--accent); background: var(--acier-50);
  color: var(--accent-fort);
}
/* jetons des métaux de la quittance : prix du jour affiché, modifiable sur place */
.barre-metaux {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: var(--e2); margin-bottom: var(--e2);
}
.jeton-metal { display: inline-flex; align-items: center; gap: 6px; }
.jeton .jeton-prix {
  margin-left: 4px; font-weight: 500; color: var(--texte-faible);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.jeton:hover .jeton-prix { color: inherit; }
.jeton-prix-saisie { display: none; }
.acces-rapide.prix-edition .jeton-metal {
  padding: 3px 4px 3px 14px; border: 1px dashed var(--accent);
  border-radius: var(--r-pill); background: var(--acier-50);
}
.acces-rapide.prix-edition .jeton {
  padding: 0; min-height: 0; border: 0; background: none; cursor: default; transform: none;
}
.acces-rapide.prix-edition .jeton .jeton-prix { display: none; }
.acces-rapide.prix-edition .jeton-prix-saisie {
  display: block; width: 92px; min-height: 34px; padding: 4px 10px;
  border-radius: var(--r-pill); text-align: right;
}
body:not(.perso-edition) [data-perso-liste] > .perso-masque { display: none; }
/* « Personnaliser » : les jetons se rangent au glisser, l'œil les masque */
body.perso-edition .perso-liste-edition > [data-cle] {
  position: relative; cursor: grab; touch-action: none;
  border-radius: var(--r-pill); outline: 2px dashed var(--acier-100); outline-offset: 2px;
}
body.perso-edition .perso-liste-edition > [data-cle]:focus-visible { outline: 2px solid var(--accent); }
body.perso-edition .perso-liste-edition > [data-cle] .jeton { pointer-events: none; }
body.perso-edition .perso-liste-edition > .perso-glisse { opacity: .55; cursor: grabbing; }
body.perso-edition .perso-liste-edition > .perso-masque { opacity: .4; }
body.perso-edition .perso-liste-edition > .perso-masque .jeton { text-decoration: line-through; }
.perso-oeil {
  width: 26px; height: 26px; padding: 0; border: 1px solid var(--bord-fort);
  border-radius: 50%; background: var(--surface); color: var(--texte-doux);
  font-size: 14px; line-height: 1; cursor: pointer;
}
.perso-oeil:hover { border-color: var(--accent); color: var(--accent-fort); }

/* --- suggestion de commune d'apres le code postal --- */
.communes-suggestion {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  margin-top: 6px;
}
.communes-dept {
  font-size: 12px; color: var(--texte-faible);
  margin-right: 2px; white-space: nowrap;
}

/* --- lignes de pesee --- */
.lignes-pesee { width: 100%; border-collapse: separate; border-spacing: 0 6px; }
.lignes-pesee th {
  font-size: 11px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--texte-faible); text-align: left; padding: 0 var(--e2) var(--e1);
  font-weight: 700;
}
.lignes-pesee td { padding: 0 3px; vertical-align: middle; }
.lignes-pesee .col-total input { background: var(--surface-3); font-weight: 700; border-style: solid; }
/* vente au détail : ligne libre (désignation écrite à la main, sans métal) */
.lignes-pesee .in-designation { display: none; margin-top: 6px; }
.lignes-pesee .ligne-libre .in-designation,
.lignes-pesee .ligne-deduction .in-designation { display: block; }
/* quittance : ligne de déduction (poids et montant négatifs) et retenue de frais */
.etq-deduction { display: none; }
.lignes-pesee .ligne-deduction .etq-deduction {
  display: block; margin-bottom: 4px; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em; color: var(--erreur-texte);
}
.lignes-pesee .ligne-deduction .in-poids,
.lignes-pesee .ligne-deduction .in-total { color: var(--erreur-texte); }
.lignes-pesee .ligne-deduction .btn-peser { display: none; }
.lignes-pesee .ligne-frais td { padding-top: var(--e2); }
.lignes-pesee .ligne-frais td:first-child { text-align: right; color: var(--texte-doux); font-weight: 650; padding-right: var(--e3); }
.lignes-pesee .ligne-frais input { background: var(--surface-3); border-style: solid; color: var(--erreur-texte); font-weight: 700; }
.barre-lignes-boutons { display: inline-flex; flex-wrap: wrap; gap: var(--e2); }
.col-suppr { width: 46px; }
.btn-suppr {
  width: 38px; height: 44px; line-height: 1;
  border: 1px solid transparent; border-radius: var(--r-md);
  background: none; color: var(--texte-faible);
  font-size: 20px; cursor: pointer; transition: all var(--transition);
}
.btn-suppr:hover { background: var(--erreur-fond); color: var(--erreur-texte); }

.barre-lignes {
  display: flex; flex-wrap: wrap; gap: var(--e4);
  align-items: center; justify-content: space-between; margin-top: var(--e4);
}
.bascule { display: inline-flex; align-items: center; gap: var(--e2); font-size: 13.5px; cursor: pointer; }

.rappel-legal {
  display: flex; gap: var(--e3); align-items: flex-start;
  margin: 0 0 var(--e4); padding: var(--e3) var(--e4);
  background: var(--avert-fond); border-left: 4px solid var(--avert-bord);
  color: var(--avert-texte); font-size: 13px;
  border-radius: 0 var(--r-md) var(--r-md) 0;
}

.repli { margin-top: var(--e3); border-top: 1px solid var(--bord); padding-top: var(--e3); }
.repli summary {
  cursor: pointer; font-size: 13.5px; font-weight: 650;
  color: var(--accent); padding: var(--e1) 0; list-style: none;
}
.repli summary::-webkit-details-marker { display: none; }
.repli summary::before {
  content: "▸"; display: inline-block; margin-right: 7px;
  transition: transform var(--transition);
}
.repli[open] summary::before { transform: rotate(90deg); }

/* --- barre de totaux --- */
.barre-totaux {
  position: fixed; left: var(--nav-l); right: 0; bottom: 0; z-index: 28;
  display: flex; flex-wrap: wrap; gap: var(--e3) var(--e6);
  align-items: center; justify-content: flex-end;
  padding: var(--e3) var(--e6);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: saturate(1.6) blur(10px);
  border-top: 1px solid var(--bord);
  box-shadow: 0 -4px 20px rgba(15, 23, 32, .08);
}
/* un champ qui prend le focus s'arrête au-dessus de la barre (hauteur posée par app.js) */
html { scroll-padding-bottom: var(--barre-bas, 0px); }
.bt-chiffres { display: flex; gap: var(--e7); margin-right: auto; }
.bt-etq {
  display: block; font-size: 10.5px; text-transform: uppercase;
  letter-spacing: .08em; color: var(--texte-faible); font-weight: 700;
}
.bt-val { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.bt-montant { color: var(--accent); }
.bt-unite { font-size: 13px; color: var(--texte-faible); margin-left: 3px; }
.bt-alertes { font-size: 13px; color: var(--avert-texte); max-width: 42ch; }
.bt-alertes:empty { display: none; }
.btn-valider { padding: 13px 28px; font-size: 15px; min-height: 52px; }

.total-bandeau {
  display: flex; flex-wrap: wrap; gap: var(--e5); justify-content: flex-end;
  padding: var(--e4); margin-top: var(--e3);
  background: var(--acier-50); border: 1px solid var(--bord);
  border-radius: var(--r-md);
}
.total-bandeau .etq { display: block; font-size: 12px; color: var(--texte-doux); }
.total-bandeau .val { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* =====================================================================
   Adaptation ecrans etroits
   ===================================================================== */

@media (max-width: 1000px) {
  .barre-totaux { left: 0; padding: var(--e3) var(--e4); }
}

@media (max-width: 760px) {
  .contenu { padding: var(--e4) var(--e3) var(--e6); }
  .kpi-valeur { font-size: 24px; }
  .bt-chiffres { gap: var(--e5); }
  .bt-val { font-size: 21px; }
  .btn-valider { flex: 1 1 100%; }
  .saisie { padding-bottom: 168px; }
  .etape, fieldset { padding: var(--e4); }
  .carte { --carte-p: var(--e4); }

  /* le tableau de pesee devient une pile de fiches */
  .lignes-pesee, .lignes-pesee tbody, .lignes-pesee tr, .lignes-pesee td { display: block; width: 100%; }
  .lignes-pesee thead { display: none; }
  .lignes-pesee tr {
    position: relative;
    border: 1px solid var(--bord); border-radius: var(--r-md);
    padding: var(--e3); margin-bottom: var(--e3); background: var(--surface-2);
  }
  .lignes-pesee td { padding: 0 0 var(--e2); }
  .lignes-pesee td::before {
    content: attr(data-etq); display: block;
    font-size: 11px; font-weight: 700; letter-spacing: .06em;
    text-transform: uppercase; color: var(--texte-faible); margin-bottom: 3px;
  }
  .lignes-pesee .col-suppr { position: absolute; top: 6px; right: 6px; width: auto; padding: 0; }
  .lignes-pesee .col-suppr::before { content: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* =====================================================================
   Impression d'un ecran (les documents ont leur propre feuille)
   ===================================================================== */
@media print {
  .rail, .barre-haute, .barre-totaux, .barre-actions, .voile { display: none !important; }
  .principal { margin-left: 0; }
  .carte, .etape, fieldset, .tableau-enveloppe { box-shadow: none; border-color: #ccc; }
  body { background: #fff; }
}

/* --- second facteur : QR code d'enrolement --- */
.qr-cadre {
  display: inline-block; padding: var(--e3); margin-top: var(--e3);
  background: #fff; border: 1px solid var(--bord); border-radius: var(--r-md);
}
.qr-cadre svg { width: 100%; max-width: 260px; height: auto; }
.cle-mfa {
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 15px; letter-spacing: .08em; word-break: break-all;
  padding: var(--e3); margin-top: 6px;
  background: var(--surface-2); border-radius: var(--r-md);
}
.lien-otpauth {
  font-family: ui-monospace, monospace; font-size: 11.5px;
  word-break: break-all; margin-top: 6px; color: var(--texte-doux);
}

/* ---------------------------------------------------------------------
   Notifications (toastManager) et zone d'erreurs des formulaires API
   --------------------------------------------------------------------- */
.toasts {
  /* en haut à droite : en bas, le toast masquerait la barre de totaux et son bouton */
  position: fixed; right: 16px; top: 76px; z-index: 1000;
  display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 32px));
}
.toast {
  padding: 12px 16px; border-radius: 10px; border: 1px solid; cursor: pointer;
  box-shadow: var(--ombre-2); font-size: 14px; line-height: 1.4;
  animation: toast-entree .25s ease-out; transition: opacity .35s, transform .35s;
}
.toast-success { background: var(--succes-fond); border-color: var(--succes-bord); color: var(--succes-texte); }
.toast-error   { background: var(--erreur-fond); border-color: var(--erreur-bord); color: var(--erreur-texte); }
.toast-warning { background: var(--avert-fond);  border-color: var(--avert-bord);  color: var(--avert-texte); }
.toast-info    { background: var(--surface-2, #fff); border-color: var(--bord, #ccc); color: var(--texte); }
.toast-sortie  { opacity: 0; transform: translateY(8px); }
@keyframes toast-entree { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.zone-erreurs[hidden] { display: none; }
.masque { color: var(--texte-doux); letter-spacing: .05em; }

/* =====================================================================
   Petits utilitaires communs
   ===================================================================== */
.bloc-replie { display: none; }          /* repli sans [hidden] : les champs partent avec le formulaire */
.resultats-vide { padding: 11px 14px; color: var(--texte-doux); }
.vide { margin: 0; color: var(--texte-faible); }
.texte-doux { color: var(--texte-doux); }
.texte-avert { color: var(--avert-texte); }
.kpi-valeur small { font-size: 13px; font-weight: 650; color: var(--texte-faible); }
.pastille-facture, .pastille-payee  { background: var(--succes-fond); color: var(--succes-texte); border-color: var(--succes-bord); }
.pastille-emise, .pastille-envoyee  { background: var(--acier-50); color: var(--accent-fort); border-color: var(--acier-100); }
.pastille-brouillon                  { background: var(--surface-3); color: var(--texte-doux); border-color: var(--bord); }
.liste-tronquee { margin: var(--e2) 0 0; font-size: 13px; color: var(--avert-texte); }

/* =====================================================================
   Bascule bureautique / simplifiée (barre haute)
   ===================================================================== */
.bascule-mode {
  display: inline-flex; padding: 3px; gap: 2px;
  background: var(--surface-3); border-radius: var(--r-pill);
}
.bascule-mode button {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 13px; min-height: 34px; border: 0; border-radius: var(--r-pill);
  background: none; color: var(--texte-doux); font: inherit; font-size: 13px; font-weight: 650;
  cursor: pointer; transition: background var(--transition), color var(--transition);
}
.bascule-mode button:hover { color: var(--texte); }
.bascule-mode button[aria-pressed="true"] { background: var(--surface); color: var(--accent-fort); box-shadow: var(--ombre-1); }
.bascule-mode button[aria-pressed="true"] .ico { color: var(--accent); }

@media (max-width: 1180px) {
  .puce-texte, .lib-quitter { display: none; }
  .puce-user { padding: 4px; }
}
@media (max-width: 760px) {
  .bascule-mode span { display: none; }
  .bascule-mode button { padding: 6px 10px; }
  .barre-titre { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .barre-haute { gap: var(--e2); }
}

/* =====================================================================
   Menu réduit à ses icônes (préférence de l'utilisateur, écrans > 1000 px)
   ===================================================================== */
@media (min-width: 1001px) {
  body.menu-reduit { --nav-l: 70px; }
  body.menu-reduit .rail-identite,
  body.menu-reduit .rail-lib,
  body.menu-reduit .rail-legal,
  body.menu-reduit .rail-groupe { display: none; }
  body.menu-reduit .rail-marque { justify-content: center; padding-left: 0; padding-right: 0; }
  body.menu-reduit .rail-nav { padding: var(--e2) 8px; }
  body.menu-reduit .rail-nav ul { padding-bottom: 6px; margin-bottom: 6px; border-bottom: 1px solid var(--bord); }
  body.menu-reduit .rail-nav ul:last-child { border-bottom: 0; }
  body.menu-reduit .rail-nav a, body.menu-reduit .rail-replier { justify-content: center; padding: 11px 0; }
  body.menu-reduit .rail-replier .ico,
  body.menu-reduit .rail-poignee .ico { transform: rotate(180deg); }
}
@media (max-width: 1000px) {
  #btn-menu-reduit, .rail-poignee { display: none; }
}

/* =====================================================================
   Grands écrans : on se sert de la largeur pour tout voir sans défiler
   ===================================================================== */
@media (min-width: 1900px) {
  .contenu { padding: 28px 36px; }
  body { font-size: 15.5px; }
}
@media (min-width: 2400px) {
  :root { --contenu-max: 2100px; }
  body { font-size: 16.5px; }
}

/* Liste longue : seul le tableau défile, en-tête et totaux figés ; filtres
   et boutons restent à l'écran. */
@media (min-width: 1001px) and (min-height: 640px) {
  .tableau-enveloppe.liste-defile {
    max-height: calc(100vh - var(--liste-haut, 270px));
    overflow: auto;
  }
  .tableau-enveloppe.liste-defile tfoot td { position: sticky; bottom: 0; }
}

/* Saisies (rachat, vente, bon, facture) : sur grand écran, identité et
   règlement à gauche, pesée à droite — tout tient dans la hauteur. */
@media (min-width: 1400px) {
  .saisie-colonnes .etape { padding: var(--e4) var(--e5); }
  .saisie-colonnes .etape-titre { margin-bottom: var(--e3); }
  .saisie-colonnes .champs-serres { margin-bottom: var(--e2); }
  .saisie-colonnes .recherche-vendeur { margin-bottom: var(--e3); }
  .saisie-colonnes .rappel-legal { margin-bottom: var(--e3); padding: var(--e2) var(--e3); }
  .saisie-colonnes .repli { margin-top: var(--e2); padding-top: var(--e2); }
  body.mode-bureau .saisie-colonnes input,
  body.mode-bureau .saisie-colonnes select { min-height: 40px; padding-top: 8px; padding-bottom: 8px; }
  body.mode-bureau .saisie-colonnes .segmente span { padding: 7px 16px; min-height: 34px; }
  body.mode-bureau .saisie-colonnes .recherche-vendeur input[type="search"] { min-height: 48px; }
}
.champs-serres .champ-plaque { flex: 0 1 240px; }

/* rachat : fiche vendeur comme l'ancien logiciel — identité à gauche,
   adresse et contact à droite, libellé devant chaque champ */
.fiche-dti {
  display: grid; gap: var(--e3) var(--e5);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 460px), 1fr));
}
.fiche-dti > .dti-col {
  margin: 0; padding: var(--e4); box-shadow: none; background: var(--surface-2);
  display: flex; flex-direction: column; gap: var(--e2);
}
.fiche-dti legend { margin-bottom: var(--e2); }
.dti-ligne { display: grid; grid-template-columns: 165px minmax(0, 1fr); align-items: center; gap: var(--e3); }
.dti-ligne > label, .dti-ligne > .etiquette { font-size: 12.5px; font-weight: 650; color: var(--texte-doux); line-height: 1.25; }
.dti-ligne > label small { display: block; font-weight: 400; color: var(--texte-faible); }
.dti-ligne .aide { font-size: 12px; color: var(--texte-faible); line-height: 1.3; }
.dti-ligne textarea { min-height: 44px; resize: vertical; }
.dti-ligne > .segmente { justify-self: start; }
.dti-champs { display: flex; align-items: center; gap: var(--e2); min-width: 0; }
.dti-champs > * { flex: 1 1 0; min-width: 0; }
.dti-champs > .dti-date { flex: 0 0 165px; }
.dti-champs > .dti-court { flex: 0 0 76px; }
.dti-champs > .dti-indice { flex: 0 0 140px; }
.dti-champs > .dti-cp { flex: 0 0 96px; }
.dti-champs > .dti-plaque { flex: 0 0 180px; }
.dti-champs > .dti-lien, .dti-champs > .aide { flex: 0 1 auto; }
.dti-champs > .btn-mince { flex: 0 0 auto; }
.dti-lien { font-size: 13px; color: var(--texte-doux); }
@media (max-width: 560px) {
  .dti-ligne { grid-template-columns: 1fr; gap: var(--e1); }
  .dti-champs { flex-wrap: wrap; }
}

/* rachat à un professionnel (deploy-19) : bascule particulier / entreprise, puis
   le bloc Entreprise (liseré de couleur) au-dessus de la personne qui apporte le métal */
.qualite-vendeur { display: flex; align-items: center; flex-wrap: wrap; gap: var(--e2) var(--e3); margin-bottom: var(--e3); }
.qualite-vendeur > .etiquette { font-size: 12.5px; font-weight: 650; color: var(--texte-doux); }
.bloc-entreprise { margin-bottom: var(--e3); }
.bloc-entreprise > .dti-col { border-left: 3px solid var(--accent); }
.bloc-entreprise .recherche-vendeur { margin-bottom: var(--e2); }
.bloc-entreprise > .dti-col > .aide { margin: 0; font-size: 12px; color: var(--texte-faible); line-height: 1.35; }
.etiquette-personne { margin: 0 0 var(--e2); font-weight: 650; font-size: 13px; }

/* rachat, bloc Vendeur en bureautique : serré au maximum pour tout voir sans
   défiler (recherche sur une ligne, champs bas, petits écarts). L'interface
   simplifiée garde ses grands champs tactiles. */
body.mode-bureau #form-achat > .etape-a {
  padding: var(--e3) var(--e4);
  display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: var(--e2) var(--e5);
}
body.mode-bureau #form-achat > .etape-a > * { grid-column: 1 / -1; }
/* titre, puis recherche (ou vendeur choisi) sur la même ligne */
body.mode-bureau #form-achat > .etape-a > .etape-titre { grid-column: 1; margin: 0; font-size: 15px; }
body.mode-bureau #form-achat > .etape-a > :is(.recherche-vendeur, .fiche-vendeur) { grid-column: 2; margin: 0; }
body.mode-bureau #form-achat > .etape-a > .fiche-vendeur { padding: 4px var(--e3); }
body.mode-bureau #form-achat > .etape-a > .qualite-vendeur { grid-column: 2; margin: 0; }
body.mode-bureau #form-achat > .etape-a > .bloc-entreprise { margin: 0; }
body.mode-bureau #form-achat > .etape-a > .etiquette-personne { grid-column: 1; margin: 0; font-size: 12.5px; white-space: nowrap; }
body.mode-bureau #form-achat > .etape-a .etape-num { width: 24px; height: 24px; font-size: 12px; }
body.mode-bureau #form-achat .recherche-vendeur {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center;
  gap: var(--e3); margin-bottom: var(--e2);
}
body.mode-bureau #form-achat .recherche-label { margin: 0; font-size: 12.5px; white-space: nowrap; }
body.mode-bureau #form-achat .recherche-vendeur .aide { margin: 0; font-size: 12px; color: var(--texte-faible); }
body.mode-bureau #form-achat .recherche-vendeur input[type="search"] {
  min-height: 34px; padding: 3px 10px 3px 34px; font-size: 14px;
  background-position: 10px center; background-size: 16px;
}
body.mode-bureau #form-achat .fiche-dti { gap: var(--e2) var(--e3); }
body.mode-bureau #form-achat .fiche-dti > .dti-col { padding: var(--e2) var(--e3); gap: 3px; }
body.mode-bureau #form-achat .fiche-dti legend { margin-bottom: 3px; font-size: 10.5px; }
body.mode-bureau #form-achat .dti-ligne { grid-template-columns: 150px minmax(0, 1fr); gap: var(--e2); }
body.mode-bureau #form-achat .dti-ligne > label,
body.mode-bureau #form-achat .dti-ligne > .etiquette { font-size: 12px; line-height: 1.15; }
body.mode-bureau #form-achat .dti-ligne > label small { display: inline; margin-left: 3px; font-size: 10.5px; }
body.mode-bureau #form-achat .fiche-dti :is(input, select, textarea) {
  min-height: 29px; height: 29px; padding: 2px 8px; font-size: 13.5px; border-radius: var(--r-sm);
}
body.mode-bureau #form-achat .fiche-dti textarea { height: auto; }
body.mode-bureau #form-achat .fiche-dti .segmente { padding: 2px; }
body.mode-bureau #form-achat .fiche-dti .segmente span { padding: 3px 14px; min-height: 0; font-size: 12.5px; }
body.mode-bureau #form-achat .dti-champs > .dti-date { flex-basis: 138px; }
body.mode-bureau #form-achat .dti-champs > .dti-court { flex-basis: 60px; }
body.mode-bureau #form-achat .dti-champs > .dti-indice { flex-basis: 120px; }
body.mode-bureau #form-achat .dti-champs > .dti-cp { flex-basis: 76px; }
body.mode-bureau #form-achat .dti-champs > .dti-plaque { flex-basis: 150px; }
body.mode-bureau #form-achat .dti-ligne .aide { font-size: 11px; }

/* rachat, blocs Pesée et Règlement en bureautique : même densité que le bloc
   Vendeur (titre et outils sur une ligne, champs bas, petits écarts) */
body.mode-bureau #form-achat > :is(.etape-b, .etape-c) { padding: var(--e3) var(--e4); }
body.mode-bureau #form-achat > :is(.etape-b, .etape-c) .etape-titre { margin: 0; font-size: 15px; }
body.mode-bureau #form-achat > :is(.etape-b, .etape-c) .etape-num { width: 24px; height: 24px; font-size: 12px; }
body.mode-bureau #form-achat > :is(.etape-b, .etape-c) :is(input:not([type="checkbox"]):not([type="radio"]), select) {
  min-height: 29px; height: 29px; padding: 2px 8px; font-size: 13.5px; border-radius: var(--r-sm);
}
body.mode-bureau #form-achat > :is(.etape-b, .etape-c) .champ { gap: 2px; }
body.mode-bureau #form-achat > :is(.etape-b, .etape-c) .champ label,
body.mode-bureau #form-achat > :is(.etape-b, .etape-c) .etiquette { font-size: 12px; }
body.mode-bureau #form-achat > :is(.etape-b, .etape-c) .aide { font-size: 11px; }
body.mode-bureau #form-achat > :is(.etape-b, .etape-c) .segmente { padding: 2px; }
body.mode-bureau #form-achat > :is(.etape-b, .etape-c) .segmente span { padding: 3px 14px; min-height: 0; font-size: 12.5px; }
body.mode-bureau #form-achat > :is(.etape-b, .etape-c) .btn:not(.btn-valider) { min-height: 29px; padding: 3px 12px; font-size: 12.5px; }

/* Pesée : titre + « Modifier les prix du jour » sur une ligne, puis métaux et lignes */
body.mode-bureau #form-achat > .etape-b {
  display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: var(--e2) var(--e5);
}
body.mode-bureau #form-achat > .etape-b > * { grid-column: 1 / -1; margin: 0; }
body.mode-bureau #form-achat > .etape-b > .etape-titre { grid-column: 1; }
body.mode-bureau #form-achat > .etape-b > .barre-metaux { grid-column: 2; }
body.mode-bureau #form-achat .acces-rapide { gap: 4px; }
body.mode-bureau #form-achat .jeton { padding: 3px 10px; min-height: 26px; font-size: 12.5px; }
body.mode-bureau #form-achat .acces-rapide.prix-edition .jeton-metal { padding: 1px 2px 1px 10px; }
body.mode-bureau #form-achat .acces-rapide.prix-edition .jeton-prix-saisie { height: 24px; min-height: 24px; width: 70px; }
body.mode-bureau #form-achat .panneau-balance { padding: var(--e2) var(--e3); }
body.mode-bureau #form-achat .pb-valeur { font-size: 24px; }
body.mode-bureau #form-achat .lignes-pesee { border-spacing: 0 3px; }
body.mode-bureau #form-achat .lignes-pesee th { font-size: 10.5px; padding-bottom: 0; }
body.mode-bureau #form-achat .lignes-pesee .in-designation { margin-top: 3px; }
body.mode-bureau #form-achat .lignes-pesee .ligne-deduction .etq-deduction { margin-bottom: 2px; font-size: 10.5px; }
body.mode-bureau #form-achat .lignes-pesee .ligne-frais td { padding-top: 2px; }
body.mode-bureau #form-achat .lignes-pesee .ligne-frais td:first-child { font-size: 12.5px; }
body.mode-bureau #form-achat .btn-suppr { height: 29px; width: 32px; font-size: 17px; }
body.mode-bureau #form-achat .col-suppr { width: 36px; }
body.mode-bureau #form-achat .btn-peser { padding: 4px 8px; font-size: 12px; }
body.mode-bureau #form-achat .barre-lignes { gap: var(--e2) var(--e4); }
body.mode-bureau #form-achat .barre-lignes .bascule { font-size: 12.5px; }

/* Règlement : titre + rappel légal, puis mode et type de virement côte à côte */
body.mode-bureau #form-achat > .etape-c {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--e2) var(--e5);
}
body.mode-bureau #form-achat > .etape-c > * { flex: 1 1 100%; margin: 0; }
body.mode-bureau #form-achat > .etape-c > .etape-titre { flex: 0 0 auto; }
body.mode-bureau #form-achat > .etape-c > .rappel-legal { flex: 1 1 260px; padding: 4px var(--e3); font-size: 11.5px; line-height: 1.3; }
body.mode-bureau #form-achat > .etape-c > .champ-mode { flex: 0 1 auto; flex-direction: row; align-items: center; gap: var(--e2); }
body.mode-bureau #form-achat > .etape-c > .champs-serres { gap: var(--e2); }
body.mode-bureau #form-achat > .etape-c .champs-serres .champ { flex: 1 1 120px; }
body.mode-bureau #form-achat > .etape-c .champs-serres .champ-iban { flex: 2 1 200px; }
body.mode-bureau #form-achat > .etape-c .champs-serres .champ-large { flex: 2 1 150px; }
body.mode-bureau #form-achat > .etape-c .champs-serres .champ-bic { flex: 0 0 95px; }
/* l'explication longue du titulaire passe en infobulle et en exemple dans le champ */
body.mode-bureau #form-achat > .etape-c .aide-titulaire { display: none; }
body.mode-bureau #form-achat > .etape-c > .repli { padding-top: var(--e2); }
body.mode-bureau #form-achat > .etape-c .repli summary { font-size: 12.5px; padding: 0; }
body.mode-bureau #form-achat > .etape-c .repli .champs-serres { margin-top: var(--e2) !important; margin-bottom: 0; }

/* rachat : compte du vendeur (virement) sous Observation, dans le bloc Vendeur */
.fiche-dti .dti-banque { display: flex; flex-direction: column; gap: inherit; }
.dti-champs > .dti-bic { flex: 0 0 120px; }

/* rachat : le règlement est dans la barre du bas, à gauche des totaux */
#form-achat .barre-totaux { justify-content: flex-start; }
#form-achat .bt-reglement { display: flex; flex-wrap: wrap; align-items: center; gap: var(--e2) var(--e4); }
#form-achat .bt-choix { display: flex; align-items: center; gap: var(--e2); }
#form-achat .bt-choix .etiquette { white-space: nowrap; }
#form-achat .bt-choix .bt-cheque-num { width: 130px; }
#form-achat .bt-choix .bt-cheque-banque { width: 180px; }
#form-achat .bt-chiffres { margin-right: auto; }
#form-achat .btn-valider { margin-left: auto; }

/* barre des totaux du rachat : plus basse (téléphone : inchangée, elle passe sur deux lignes) */
@media (min-width: 761px) {
  body.mode-bureau .saisie#form-achat { padding-bottom: 76px; }
  body.mode-bureau #form-achat .barre-totaux { padding: 6px var(--e5); gap: var(--e2) var(--e5); }
  body.mode-bureau #form-achat .bt-chiffres { gap: var(--e6); }
  body.mode-bureau #form-achat .bt-val { font-size: 21px; }
  body.mode-bureau #form-achat .btn-valider { min-height: 40px; padding: 8px 22px; font-size: 14px; }
  body.mode-bureau #form-achat .bt-choix :is(input:not([type="radio"])) { min-height: 30px; height: 30px; padding: 2px 8px; font-size: 13.5px; }
  body.mode-bureau #form-achat .bt-choix .segmente { padding: 2px; }
  body.mode-bureau #form-achat .bt-choix .segmente span { padding: 4px 14px; min-height: 0; font-size: 13px; }
  body.mode-bureau #form-achat .bt-choix .etiquette { font-size: 12px; }
}

/* =====================================================================
   Tableau de bord modulable
   ===================================================================== */
.tb-barre {
  display: flex; align-items: center; justify-content: space-between; gap: var(--e3);
  margin: -6px 0 var(--e3);
}
.tb-bonjour { margin: 0; color: var(--texte-doux); font-size: 14px; font-weight: 600; }
.tb-outils { display: flex; gap: var(--e2); margin-left: auto; }
.tb-outils [aria-pressed="true"] { background: var(--acier-50); border-color: var(--accent); color: var(--accent-fort); }
.tb-form-masquer { margin: 0; }
/* tableau de bord masqué : fenêtre du mot de passe */
.alerte-info { background: var(--acier-50); border-color: var(--accent); color: var(--texte); }
.tb-dialogue {
  width: min(380px, calc(100vw - 32px)); padding: var(--e5);
  border: 1px solid var(--bord); border-radius: var(--r-lg);
  background: var(--surface); color: var(--texte); box-shadow: var(--ombre-3);
}
.tb-dialogue::backdrop { background: rgba(8, 12, 18, .5); }
.tb-dialogue h2 { margin: 0 0 var(--e4); font-size: 17px; }
.tb-dialogue .champ { margin-bottom: var(--e4); }
.tb-dialogue .barre-actions { display: flex; justify-content: flex-end; gap: var(--e2); margin: 0; }

.tb-edition {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--e3);
  padding: var(--e3) var(--e4); margin-bottom: var(--e4);
  background: var(--acier-50); border: 1px dashed var(--accent); border-radius: var(--r-md);
}
.tb-edition-aide { margin: 0; font-size: 13.5px; color: var(--accent-fort); }
.tb-edition-aide .ico { width: 15px; height: 15px; vertical-align: -3px; color: var(--accent); }
.tb-edition-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--e2); }
.tb-edition-actions select { width: auto; min-width: 260px; max-width: 420px; min-height: 36px; padding-top: 6px; padding-bottom: 6px; }

.tb-grille {
  /* 8 rangées tiennent dans la hauteur de l'écran (disposition par défaut) */
  --tb-rang: max(104px, calc((100vh - 286px) / 8));
  display: grid; gap: var(--e4);
  grid-template-columns: repeat(12, minmax(0, 1fr));
  grid-auto-rows: var(--tb-rang);
  grid-auto-flow: row dense;
}
.module {
  position: relative; min-width: 0; min-height: 0;
  grid-column: span var(--w, 4); grid-row: span var(--h, 2);
  display: flex; flex-direction: column;
  padding: 11px 16px 12px;
  background: var(--surface); border: 1px solid var(--bord);
  border-radius: var(--r-lg); box-shadow: var(--ombre-1);
}
.module-tete { display: flex; align-items: center; gap: var(--e2); margin-bottom: 6px; min-height: 22px; }
.module-tete h2 {
  flex: 1; min-width: 0; margin: 0;
  font-size: 11.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--texte-faible); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.module-corps { flex: 1; min-height: 0; overflow: auto; position: relative; }
.module-corps:has(> .kpi-valeur) { display: flex; flex-direction: column; justify-content: center; overflow: visible; }
.module-corps .kpi-valeur { white-space: nowrap; line-height: 1.15; }
.module-corps .kpi-detail { margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* outils d'édition : visibles seulement en mode « Personnaliser » */
.module-poignee, .module-outils, .module-redim { display: none; }
.edition .module { outline: 2px dashed var(--acier-100); outline-offset: -1px; }
.edition .module:hover { outline-color: var(--accent); }
.edition .module-poignee {
  display: grid; place-items: center; width: 30px; height: 30px; flex: none;
  border: 1px solid var(--bord); border-radius: var(--r-sm);
  background: var(--surface-2); color: var(--texte-doux); cursor: grab; touch-action: none;
}
.edition .module-poignee:active { cursor: grabbing; }
.edition .module-outils { display: inline-flex; gap: 3px; flex: none; }
.module-outils button {
  display: grid; place-items: center; width: 30px; height: 30px; padding: 0;
  border: 1px solid var(--bord); border-radius: var(--r-sm);
  background: var(--surface); color: var(--texte-doux); font: inherit; font-size: 16px; font-weight: 700; cursor: pointer;
}
.module-outils button:hover { border-color: var(--accent); color: var(--accent-fort); }
.module-outils button[data-act="masquer"]:hover { border-color: var(--erreur-bord); color: var(--erreur-texte); background: var(--erreur-fond); }
.module-outils .ico { width: 15px; height: 15px; color: currentColor; }
.edition .module-redim {
  display: grid; place-items: center; position: absolute; right: 3px; bottom: 3px;
  width: 24px; height: 24px; border-radius: var(--r-sm);
  background: var(--acier-50); color: var(--accent); cursor: nwse-resize; touch-action: none;
}
.module-redim .ico { width: 14px; height: 14px; color: currentColor; }
.module.en-deplacement { opacity: .55; outline: 2px solid var(--accent) !important; }
.module.en-redim { outline: 2px solid var(--accent) !important; box-shadow: var(--ombre-3); }

/* tableaux compacts des modules */
table.t.t-compacte th, table.t.t-compacte td { padding: 7px 10px; font-size: 13.5px; }
table.t.t-compacte thead th { font-size: 10.5px; }

/* tuiles d'accès rapide */
.tuiles { display: grid; gap: var(--e2); grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); }
.tuile {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 7px;
  min-height: 84px; padding: 10px 8px; text-align: center;
  border: 1px solid var(--bord); border-radius: var(--r-md);
  background: var(--surface-2); color: var(--texte); text-decoration: none;
  font-size: 13px; font-weight: 650; line-height: 1.2;
  transition: background var(--transition), border-color var(--transition), transform var(--transition);
}
.tuile .ico { width: 26px; height: 26px; color: var(--accent); }
.tuile:hover { border-color: var(--accent); background: var(--acier-50); color: var(--accent-fort); transform: translateY(-1px); }
.tuile-principale { background: var(--accent); border-color: var(--accent); color: var(--sur-accent); }
.tuile-principale .ico { color: var(--sur-accent); }
.tuile-principale:hover { background: var(--accent-fort); color: var(--sur-accent); }

/* histogramme d'activité : une série, une teinte */
.module-activite .module-corps { display: flex; flex-direction: column; overflow: visible; }
.graphe-resume { margin: 0 0 var(--e2); font-size: 13px; color: var(--texte-doux); font-variant-numeric: tabular-nums; }
.graphe-barres { flex: 1; min-height: 40px; display: flex; align-items: flex-end; gap: 2px; }
.barre {
  flex: 1; min-width: 2px; height: calc(var(--v) * 100%); min-height: 1px;
  background: var(--accent); border-radius: 4px 4px 0 0; opacity: .82;
  transition: opacity var(--transition);
}
.barre:hover { opacity: 1; }
.barre-jour { background: var(--accent-fort); opacity: 1; }
.graphe-axe {
  display: flex; justify-content: space-between; padding-top: 4px; margin-top: 2px;
  border-top: 1px solid var(--bord); font-size: 11px; color: var(--texte-faible);
}
.graphe-bulle {
  position: absolute; z-index: 5; pointer-events: none; white-space: nowrap;
  padding: 5px 9px; border-radius: var(--r-sm);
  background: var(--texte); color: var(--surface); font-size: 12px; box-shadow: var(--ombre-2);
}

/* état du registre */
.etat-registre { display: flex; gap: var(--e3); align-items: flex-start; }
.etat-registre .ico { width: 30px; height: 30px; flex: none; }
.etat-registre strong { display: block; font-size: 16px; }
.etat-registre .kpi-detail { display: block; }
.etat-ok .ico { color: var(--succes-texte); }
.etat-alerte .ico { color: var(--avert-texte); }

@media (max-width: 1100px) {
  .tb-grille { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .module { grid-column: span min(6, calc((var(--w) + 1) / 2)); }
}
@media (max-width: 700px) {
  .tb-grille { grid-template-columns: minmax(0, 1fr); grid-auto-rows: auto; }
  .module { grid-column: 1 / -1; grid-row: auto; min-height: calc(var(--h) * 88px); max-height: 460px; }
  .tb-edition-actions select { min-width: 0; width: 100%; }
}

/* =====================================================================
   INTERFACE SIMPLIFIÉE
   Gros caractères, grosses cibles, l'essentiel seulement : les aides, les
   rappels et les colonnes secondaires (.col-sec) disparaissent. Chaque écran
   reste complet (mêmes actions, mêmes données obligatoires).
   ===================================================================== */
body.mode-simple { font-size: 17px; }
.mode-simple .aide,
.mode-simple .seulement-bureau,
.mode-simple .col-sec,
.mode-simple .rappel-legal,
.mode-simple .rail-legal,
.mode-simple .rail-groupe,
.mode-simple .puce-role,
.mode-simple .tb-bonjour,
.mode-simple .graphe-resume { display: none !important; }

.mode-simple .contenu { padding: 20px 24px 28px; }
.mode-simple .barre-titre { font-size: 22px; font-weight: 700; }
.mode-simple .barre-haute { padding-top: 14px; padding-bottom: 14px; }
.mode-simple .bascule-mode button { min-height: 42px; font-size: 14.5px; padding: 8px 16px; }

/* menu : gros boutons, groupes séparés par un trait au lieu d'un titre */
.mode-simple .rail-nav a { padding: 12px 14px; gap: 14px; font-size: 16.5px; font-weight: 600; }
.mode-simple .rail .ico { width: 24px; height: 24px; }
.mode-simple .rail-nav ul { padding-bottom: 8px; margin-bottom: 8px; border-bottom: 1px solid var(--bord); }
.mode-simple .rail-nav ul:last-child { border-bottom: 0; }
.mode-simple .rail-nav { padding-top: var(--e3); }

/* champs et boutons */
.mode-simple input, .mode-simple select, .mode-simple textarea { min-height: 54px; font-size: 17px; padding: 12px 14px; }
.mode-simple input[type="checkbox"], .mode-simple input[type="radio"] { min-height: 0; width: 22px; height: 22px; }
.mode-simple .segmente input { width: 100%; height: 100%; }
.mode-simple .champ label, .mode-simple .etiquette { font-size: 14.5px; }
.mode-simple .btn { min-height: 54px; padding: 12px 22px; font-size: 16.5px; }
.mode-simple .btn-mince { min-height: 46px; padding: 9px 16px; font-size: 15px; }
.mode-simple .btn-valider { min-height: 64px; padding: 16px 34px; font-size: 18.5px; }
.mode-simple .segmente span { padding: 13px 24px; min-height: 50px; font-size: 16px; }
.mode-simple .segmente-large span { padding: 15px 36px; font-size: 17px; }
.mode-simple .jeton { min-height: 52px; padding: 12px 20px; font-size: 16px; }
.mode-simple .recherche-vendeur input[type="search"] { min-height: 64px; font-size: 19px; }
.mode-simple .btn-suppr { height: 54px; width: 46px; font-size: 24px; }

/* étapes, cartes, chiffres */
.mode-simple .etape { padding: 22px 24px; }
.mode-simple .carte { --carte-p: 24px; }
.mode-simple .etape-titre { font-size: 21px; }
.mode-simple .etape-num { width: 38px; height: 38px; font-size: 17px; }
.mode-simple .carte h2, .mode-simple .module-tete h2 { font-size: 13.5px; }
.mode-simple .kpi-valeur { font-size: 34px; }
.mode-simple .kpi-detail { font-size: 15px; }
.mode-simple .bt-val { font-size: 32px; }
.mode-simple .bt-etq { font-size: 12px; }
.mode-simple .alerte { font-size: 16px; }
.mode-simple .pastille { font-size: 14px; padding: 5px 12px; }

/* tableaux : lignes hautes, texte lisible à distance */
.mode-simple table.t th, .mode-simple table.t td { padding: 14px 16px; font-size: 16px; }
.mode-simple table.t thead th { font-size: 12.5px; }
.mode-simple table.t.t-compacte th, .mode-simple table.t.t-compacte td { padding: 10px 12px; font-size: 15.5px; }
.mode-simple table.t a { font-size: 16.5px; }

/* tableau de bord simplifié : tuiles géantes */
.mode-simple .tb-grille { --tb-rang: max(128px, calc((100vh - 300px) / 6)); gap: 18px; }
.mode-simple .tuiles { gap: 14px; grid-template-columns: repeat(auto-fill, minmax(178px, 1fr)); }
.mode-simple .tuile { min-height: 128px; font-size: 18px; gap: 12px; border-width: 2px; }
.mode-simple .tuile .ico { width: 44px; height: 44px; }

@media (max-width: 760px) {
  body.mode-simple { font-size: 16.5px; }
  .mode-simple .contenu { padding: 14px 12px 24px; }
  .mode-simple .tuiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mode-simple .tuile { min-height: 112px; font-size: 16.5px; }
}
@media (min-width: 1900px) {
  .mode-simple .tuiles { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
}

@media print {
  .bascule-mode, .tb-barre, .tb-edition, .module-outils, .module-poignee, .module-redim { display: none !important; }
}

/* =====================================================================
   Barre de filtres des listes : une seule ligne, action principale à droite
   ===================================================================== */
.filtres {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--e3);
  padding: var(--e3) var(--e4); margin-bottom: var(--e4);
  background: var(--surface); border: 1px solid var(--bord);
  border-radius: var(--r-lg); box-shadow: var(--ombre-1);
}
.filtres .champ { flex: 0 1 170px; }
.filtres .champ-date { flex: 0 1 158px; }
.filtres .champ-q { flex: 1 1 220px; max-width: 360px; }
.filtres input, .filtres select { min-height: 40px; padding-top: 8px; padding-bottom: 8px; }
.filtres .btn { min-height: 40px; }
.filtres-actions { display: flex; flex-wrap: wrap; gap: var(--e2); margin-left: auto; }
.tfoot-lib { color: var(--texte-doux); font-weight: 650; }
.mode-simple .filtres input, .mode-simple .filtres select, .mode-simple .filtres .btn { min-height: 52px; }
.mode-simple .filtres .champ-date { flex-basis: 180px; }
@media (max-width: 760px) {
  .filtres .champ, .filtres .champ-date { flex: 1 1 140px; }
  .filtres .champ-q { flex: 1 1 100%; max-width: none; }
  .filtres-actions { margin-left: 0; width: 100%; }
  .filtres-actions .btn { flex: 1; }
}

/* =====================================================================
   Fiches (quittance, vente, bon, facture) : une seule grille de cartes
   ===================================================================== */
.fiche-grille .carte p { margin: 0; line-height: 1.7; }
.fiche-grille .carte form { margin-top: var(--e3); }
fieldset[disabled] input, fieldset[disabled] select, fieldset[disabled] textarea { background: var(--surface-2); color: var(--texte-doux); }
.fiche-grille > fieldset { margin: 0; min-width: 0; }
.champs .champ-bas { justify-content: flex-end; }
.carte h2 + form, .carte form + h2 { margin-top: 0; }
.carte form + h2 { margin-top: var(--e5); }
table.t tbody tr.ligne-choisie { background: var(--acier-50); }

/* Colonnes secondaires d'un tableau généré : <table data-sec="3 5"> (numéros de colonnes) */
.mode-simple table[data-sec~="1"] :is(thead, tbody) tr > :nth-child(1):not([colspan]) { display: none; }
.mode-simple table[data-sec~="2"] :is(thead, tbody) tr > :nth-child(2):not([colspan]) { display: none; }
.mode-simple table[data-sec~="3"] :is(thead, tbody) tr > :nth-child(3):not([colspan]) { display: none; }
.mode-simple table[data-sec~="4"] :is(thead, tbody) tr > :nth-child(4):not([colspan]) { display: none; }
.mode-simple table[data-sec~="5"] :is(thead, tbody) tr > :nth-child(5):not([colspan]) { display: none; }
.mode-simple table[data-sec~="6"] :is(thead, tbody) tr > :nth-child(6):not([colspan]) { display: none; }
.mode-simple table[data-sec~="7"] :is(thead, tbody) tr > :nth-child(7):not([colspan]) { display: none; }
.mode-simple table[data-sec~="8"] :is(thead, tbody) tr > :nth-child(8):not([colspan]) { display: none; }
.mode-simple table[data-sec~="9"] :is(thead, tbody) tr > :nth-child(9):not([colspan]) { display: none; }
.mode-simple table[data-sec~="10"] :is(thead, tbody) tr > :nth-child(10):not([colspan]) { display: none; }
.mode-simple table[data-sec~="11"] :is(thead, tbody) tr > :nth-child(11):not([colspan]) { display: none; }
.mode-simple table[data-sec~="12"] :is(thead, tbody) tr > :nth-child(12):not([colspan]) { display: none; }
.rapport-json { white-space: pre-wrap; font-size: 12px; max-height: 420px; overflow: auto; }
.mode-simple .recherche-label, .mode-simple .repli summary { font-size: 16px; }

/* =====================================================================
   Uniformisation des écrans
   ===================================================================== */

/* Rythme vertical : assuré par l'écart des grilles (voir « Grille des écrans ») */
.carte > .barre-actions:last-child, .carte form > .barre-actions:last-child { margin-bottom: 0; }

/* Tableau dans une carte : il occupe toute la largeur de la carte, et ses
   cellules s'alignent sur le titre de la carte (plus de double retrait) */
.carte > .tableau-enveloppe,
.carte > form > .tableau-enveloppe { margin-inline: calc(-1 * var(--carte-p)); }
.carte > .tableau-enveloppe table.t tr > :first-child,
.carte > form > .tableau-enveloppe table.t tr > :first-child { padding-left: var(--carte-p); }
.carte > .tableau-enveloppe table.t tr > :last-child,
.carte > form > .tableau-enveloppe table.t tr > :last-child { padding-right: var(--carte-p); }
.carte > .tableau-enveloppe:last-child { margin-bottom: calc(-1 * var(--carte-p)); }
.carte > .tableau-enveloppe:last-child table.t tbody tr:last-child td { border-bottom: 0; }
.carte > .tableau-enveloppe:last-child { border-radius: 0 0 var(--r-lg) var(--r-lg); }

/* Une carte ne pousse jamais la page vers le bas : au-delà de 60 % de
   l'écran, son tableau défile (en-tête figé) */
@media (min-width: 1001px) and (min-height: 640px) {
  .carte > .tableau-enveloppe,
  .carte > form > .tableau-enveloppe { max-height: max(320px, 60vh); overflow: auto; }
  .bloc-defile { max-height: max(320px, 60vh); overflow: auto; }
}

/* Case à cocher seule dans un champ : à gauche, à la hauteur d'un champ */
.champ > input[type="checkbox"] { align-self: flex-start; width: 20px; height: 20px; margin: 12px 0; }

/* Contrôles d'installation : mêmes colonnes d'un groupe à l'autre */
table.t-controles { table-layout: fixed; }
table.t-controles td:first-child { width: 32%; }
table.t-controles td:last-child { width: 150px; text-align: right; }
table.t-controles td { overflow-wrap: anywhere; }

/* Contenu technique (payload, rapport) : défile dans son cadre */
.bloc-code {
  margin: 0; padding: var(--e3) var(--e4); overflow: auto; max-height: 60vh;
  background: var(--surface-2); border-radius: var(--r-md);
  font: 12.5px/1.6 ui-monospace, SFMono-Regular, Consolas, monospace;
}
.cle-valeur { font: 12px/1.5 ui-monospace, SFMono-Regular, Consolas, monospace; overflow-wrap: anywhere; }
.cle-valeur + .cle-valeur { margin-top: var(--e3); }
.cle-valeur .etiquette { display: block; font-family: inherit; }

/* Tableau de bord : tableaux des modules sur une ligne, colonnes facultatives
   retirées quand le module est étroit */
.module { container: module / inline-size; }
.module table.t td { white-space: nowrap; }
.module table.t td:not(.num) { max-width: 240px; overflow: hidden; text-overflow: ellipsis; }
@container module (max-width: 560px) {
  .col-etroit { display: none; }
}
/* tuiles d'accès rapide d'un module : compactes (icône + libellé sur une
   ligne) pour que toutes restent lisibles sans défiler */
body.mode-bureau .module .tuiles { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
body.mode-bureau .module .tuile {
  flex-direction: row; justify-content: flex-start; gap: 9px;
  min-height: 40px; padding: 8px 10px; text-align: left;
}
body.mode-bureau .module .tuile .ico { width: 18px; height: 18px; }

/* barre de filtres : courte note à côté des champs, aide dans une étiquette */
.filtres-note { flex: 1 1 280px; margin: 0; align-self: center; font-size: 12.5px; color: var(--texte-faible); line-height: 1.4; }
.filtres label .aide { font-weight: 500; }
table.t-comptes td { white-space: nowrap; }
.nowrap { white-space: nowrap; }
/* balance des métaux : un résumé, la liste des écritures reste visible dessous */
@media (min-width: 1001px) and (min-height: 640px) {
  .carte-balance > .tableau-enveloppe { max-height: max(200px, 30vh); }
}
.carte p:last-child { margin-bottom: 0; }
/* tuiles géantes du module d'accès rapide : trois rangées tiennent dans le module */
.mode-simple .module .tuile { min-height: 104px; }
.mode-simple .module .tuiles { gap: 12px; }

/* =====================================================================
   Grille des écrans : chaque page est une grille de 12 colonnes, et chaque
   bloc (carte, filtres, tableau, étape de saisie…) y occupe --pw colonnes.
   perso.js permet à l'utilisateur de déplacer, élargir et replier ces
   blocs ; sans personnalisation, la disposition d'origine s'applique.
   ===================================================================== */
.contenu, .fiche-grille, .grille, .saisie-colonnes {
  display: grid; grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: var(--e4); align-items: start;
}
.fiche-grille, .grille, .saisie-colonnes { grid-auto-flow: row dense; }
.contenu > *, .fiche-grille > *, .grille > *, .saisie-colonnes > * {
  grid-column: span var(--pw, 12); min-width: 0; margin: 0;
}
/* boutons et liens posés seuls dans la page : à leur taille, pas étirés */
.contenu > :is(a, button, span) { justify-self: start; }
/* messages : toujours en tête, sur toute la largeur */
:is(.contenu, .fiche-grille, .grille, .saisie-colonnes) > :is(.alerte, .zone-erreurs, .flash, .perso-banniere) {
  grid-column: 1 / -1; order: -10;
}
.saisie-colonnes > .barre-totaux { order: 99; }
/* saisie sous 1400 px : une colonne, quelle que soit la personnalisation */
@media (max-width: 1399px) {
  .saisie-colonnes > * { grid-column: 1 / -1 !important; grid-row: auto !important; }
}

/* largeurs d'origine (posées sur chaque bloc : --pw ne s'hérite pas d'un bloc parent) */
.contenu > *, .grille > * { --pw: 12; }
.fiche-grille > * { --pw: 4; }
.fiche-grille > .carte-large { --pw: 8; }
.fiche-grille > .carte-pleine, .fiche-grille > .barre-actions { --pw: 12; }
.grille-4 > * { --pw: 3; }
.grille-2 > * { --pw: 6; }
.saisie-colonnes > * { --pw: 12; }

/* saisie sur grand écran : identité et règlement à gauche, pesée à droite
   (elle couvre trois rangées et reste visible pendant le défilement) */
@media (min-width: 1400px) {
  .saisie-colonnes > .etape-a, .saisie-colonnes > .etape-c, .saisie-colonnes > .etape-d { --pw: 5; }
  .saisie-colonnes > .etape-b { --pw: 7; grid-row: span 3; position: sticky; top: 76px; }
  .saisie-colonnes { row-gap: var(--e4); }
  /* rachat : fiche vendeur (deux colonnes) sur toute la largeur, puis les
     métaux, avec le règlement à côté */
  #form-achat > .etape-a { --pw: 12; }
  #form-achat > .etape-b { --pw: 12; grid-row: auto; position: static; }
}

/* écran moyen : deux blocs par rangée au plus ; petit écran : un seul */
@media (max-width: 1100px) {
  .fiche-grille > *, .grille > *, .contenu > * {
    grid-column: span min(12, max(6, calc((var(--pw, 12) - 6) * 100)));
  }
}
@media (max-width: 760px) {
  .contenu > *, .fiche-grille > *, .grille > *, .saisie-colonnes > * { grid-column: 1 / -1; }
}

/* disposition libre (perso.js), grand écran seulement : chaque bloc à sa
   colonne (--px), sa largeur (--pw), sa hauteur réglée (--ph) ou celle de son
   contenu ; rangées de 8 px (--prs rangées par bloc, écart compris) */
@media (min-width: 1101px) {
  :is(.contenu, .fiche-grille, .grille, .saisie-colonnes).perso-libre {
    grid-auto-rows: 8px; row-gap: 0; grid-auto-flow: row dense; align-items: start;
  }
  :is(.contenu, .fiche-grille, .grille, .saisie-colonnes).perso-libre > * {
    grid-column: var(--px, auto) / span var(--pw, 12) !important;
    grid-row: auto / span var(--prs, 1) !important;
    align-self: start;
  }
  :is(.contenu, .fiche-grille, .grille, .saisie-colonnes).perso-libre > :is(.alerte, .zone-erreurs, .flash, .perso-banniere, .onglets-module, .barre-totaux) {
    grid-column: 1 / -1 !important;
  }
  .perso-libre > .perso-h:not(.perso-replie) { height: calc(var(--ph) * 1px); overflow: auto; }
  .saisie-colonnes.perso-libre > .etape-b { position: static; }
}

/* ------------------------- personnalisation ------------------------- */
/* une mise en page enregistrée s'applique avant l'affichage (perso.js) ;
   si le script manque, la page s'affiche quand même au bout de 0,6 s */
body.perso-attente .contenu { visibility: hidden; animation: perso-reveler 0s .6s forwards; }
@keyframes perso-reveler { to { visibility: visible; } }

/* bloc replié : seul son titre reste */
.perso-replie > :not(h2):not(legend):not(.perso-outils):not(.etape-titre) { display: none !important; }
.perso-replie > :is(h2, legend, .etape-titre) { margin-bottom: 0; }
.perso-replie { cursor: default; }

.btn-perso[aria-pressed="true"] { background: var(--acier-50); border-color: var(--accent); color: var(--accent-fort); }
.btn-perso[aria-pressed="true"] .ico { color: var(--accent); }
@media (max-width: 1180px) { .lib-perso { display: none; } }

.perso-banniere {
  position: sticky; top: 64px; z-index: 26;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--e3);
  padding: var(--e2) var(--e4);
  background: var(--acier-50); border: 1px dashed var(--accent); border-radius: var(--r-md);
  box-shadow: var(--ombre-2);
}
.perso-banniere p { margin: 0; font-size: 13.5px; color: var(--accent-fort); }
.perso-banniere .ico { width: 15px; height: 15px; vertical-align: -3px; color: var(--accent); }
.perso-banniere-actions { display: flex; flex-wrap: wrap; gap: var(--e2); }

/* blocs en mode édition */
body.perso-edition .perso-bloc { position: relative; outline: 2px dashed var(--acier-100); outline-offset: 2px; }
body.perso-edition .perso-bloc:hover { outline-color: var(--accent); }
body.perso-edition .perso-bloc.perso-glisse { opacity: .55; outline: 2px solid var(--accent); }
/* outils posés AU-DESSUS des blocs (calque) : jamais rognés par un cadre qui défile */
.perso-calque { position: absolute; top: 0; left: 0; width: 0; height: 0; z-index: 27; }
.perso-outils {
  display: inline-flex; gap: 3px; align-items: center;
  position: absolute; padding: 2px; border-radius: var(--r-sm);
  background: var(--surface); border: 1px solid var(--accent); box-shadow: var(--ombre-2);
}
.perso-outils button[data-act="colonnes"] { font-size: 12px; font-weight: 650; padding: 0 8px; }
/* bouton dans une grille de champs : il passe à la ligne plutôt que de déborder */
.champs .btn { white-space: normal; text-align: center; }
.perso-outils button {
  display: grid; place-items: center; min-width: 28px; height: 26px; padding: 0 5px;
  border: 0; border-radius: 4px; background: none; color: var(--texte-doux);
  font: inherit; font-size: 15px; font-weight: 700; line-height: 1; cursor: pointer;
}
.perso-outils button:hover { background: var(--acier-50); color: var(--accent-fort); }
.perso-outils .perso-poignee { cursor: grab; touch-action: none; }
.perso-outils .perso-poignee:active { cursor: grabbing; }
.perso-outils .ico { width: 15px; height: 15px; color: currentColor; }
.perso-outils .perso-nom { padding: 0 6px; font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--accent-fort); white-space: nowrap; max-width: 180px; overflow: hidden; text-overflow: ellipsis; }

/* choix des colonnes d'un tableau */
.perso-colonnes {
  position: absolute; z-index: 40; min-width: 220px; max-height: 60vh; overflow: auto;
  padding: var(--e2); background: var(--surface); border: 1px solid var(--bord-fort);
  border-radius: var(--r-md); box-shadow: var(--ombre-3);
}
.perso-colonnes label { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: var(--r-sm); font-size: 13.5px; cursor: pointer; }
.perso-colonnes label:hover { background: var(--surface-2); }
.perso-colonnes .perso-colonnes-titre { margin: 2px 8px 6px; font-size: 11px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--texte-faible); }

/* tri des tableaux : en-têtes cliquables */
table.t th.tri-possible { cursor: pointer; user-select: none; }
table.t th.tri-possible:hover { color: var(--accent-fort); }
table.t th.tri-possible::after { content: "\2195"; margin-left: 5px; opacity: .35; font-size: 11px; }
table.t th[aria-sort="ascending"]::after { content: "\2191"; opacity: 1; color: var(--accent); }
table.t th[aria-sort="descending"]::after { content: "\2193"; opacity: 1; color: var(--accent); }
.perso-col-cachee { display: none !important; }

/* un champ « double » occupe toute la ligne, même dans un bloc étroit à une colonne */
.champs .champ-2 { grid-column: 1 / -1; }
/* fiche à six blocs (paramètres de la société) : sur grand écran, les six
   côte à côte ; trois par rangée en dessous */
@media (min-width: 1800px) {
  .fiche-grille.grille-6 > * { --pw: 2; }
}

/* formulaire d'écran (paramètres, fiches) : le bouton d'enregistrement reste
   visible en bas de l'écran pendant le défilement */
.contenu > form[data-api] > .barre-actions:last-child {
  position: sticky; bottom: 0; z-index: 20;
  margin: 0; padding: var(--e3) 0;
  background: linear-gradient(to bottom, transparent, var(--fond) 35%);
}

/* indicateurs du tableau de bord : valeur et détail tiennent dans une rangée */
.module-corps .kpi-valeur { font-size: 26px; }
.module-tete { margin-bottom: 3px; }
.perso-outils-compact .perso-nom { display: none; }

/* poignée d'angle (taille du bloc) et groupes de blocs */
.perso-redim {
  position: absolute; z-index: 1; width: 22px; height: 22px; padding: 0;
  display: grid; place-items: center; cursor: nwse-resize; touch-action: none;
  border: 1px solid var(--accent); border-radius: 6px;
  background: var(--surface); color: var(--accent-fort); box-shadow: var(--ombre-1);
}
.perso-redim::before {
  content: ""; width: 8px; height: 8px; margin: 0 2px 2px 0;
  border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
}
.perso-redim:hover { background: var(--acier-50); }
.perso-redim:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
body.perso-edition .perso-bloc.perso-redim-actif { outline: 2px solid var(--accent); }
body.perso-edition .perso-bloc.perso-groupe { outline-style: dotted; outline-offset: 6px; }
.perso-outils-groupe .perso-nom { color: var(--texte-faible); }
.carte > .alerte:last-child { margin-bottom: 0; }

/* ------------------------------------------------ balance connectée (quittance) */
.panneau-balance {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--e2) var(--e4);
  margin-bottom: var(--e3); padding: var(--e3) var(--e4);
  background: var(--surface-2); border: 1px solid var(--bord); border-left: 4px solid var(--bord-fort);
  border-radius: var(--r-md);
}
.panneau-balance[data-etat="stable"] { border-left-color: var(--succes-texte); }
.panneau-balance[data-etat="mouvement"] { border-left-color: var(--avert-texte); }
.panneau-balance[data-etat="deconnectee"] { border-left-color: var(--erreur-texte); }
.pb-ecran { display: flex; align-items: baseline; gap: 6px; min-width: 9ch; }
.pb-valeur { font: 700 30px/1.1 ui-monospace, SFMono-Regular, Consolas, monospace; font-variant-numeric: tabular-nums; }
.pb-unite { color: var(--texte-doux); font-weight: 600; }
.pb-infos { display: flex; flex-wrap: wrap; align-items: center; gap: var(--e2); flex: 1 1 220px; }
.pb-etat { font-size: 14px; color: var(--texte-doux); }
.panneau-balance[data-etat="stable"] .pb-etat { color: var(--succes-texte); font-weight: 600; }
.pb-aide { flex-basis: 100%; margin: 0; }
.poids-pesee { display: flex; gap: 4px; align-items: center; }
.poids-pesee .in-poids { flex: 1 1 auto; min-width: 0; }
.btn-peser {
  flex: none; padding: 6px 9px; font: 600 12.5px/1 inherit; cursor: pointer;
  color: var(--accent-fort); background: var(--accent-doux); border: 1px solid var(--acier-100); border-radius: var(--r-sm);
}
.btn-peser:hover { background: var(--acier-100); }
.in-poids.poids-balance { border-color: var(--succes-texte); background: var(--succes-fond); }
.bandeau-correction { flex-wrap: wrap; }
.bandeau-correction .champ { flex: 1 1 100%; margin-top: var(--e2); }

/* ------------------------------------------------ actions sur une ligne de tableau */
.actions-ligne { white-space: nowrap; }
.actions-ligne form { display: inline-block; margin: 0 0 0 4px; }
.jeton-secret {
  display: inline-block; margin: 6px 0; padding: 6px 10px; user-select: all;
  font: 600 13.5px/1.4 ui-monospace, SFMono-Regular, Consolas, monospace; overflow-wrap: anywhere;
  background: var(--surface); border: 1px dashed var(--avert-texte); border-radius: var(--r-sm);
}
.liste-cases { list-style: none; margin: 0 0 var(--e3); padding: 0; display: grid; gap: 4px; max-height: 40vh; overflow: auto; }

/* =====================================================================
   Rotations de bennes : sous-menu du module, agenda, petits formulaires
   ===================================================================== */
.onglets-module {
  display: flex; flex-wrap: wrap; gap: var(--e1);
  padding: 4px; border-radius: var(--r-pill); background: var(--surface-3);
  justify-self: start; max-width: 100%;
}
.onglets-module a {
  padding: 7px 16px; border-radius: var(--r-pill); color: var(--texte-doux);
  font-weight: 650; font-size: 13.5px; text-decoration: none; white-space: nowrap;
}
.onglets-module a:hover { color: var(--accent-fort); }
.onglets-module a[aria-current="page"] { background: var(--surface); color: var(--accent-fort); box-shadow: var(--ombre-1); }

.form-ligne { display: inline-flex; flex-wrap: wrap; align-items: center; gap: var(--e2); }
.form-ligne input[type="date"] { width: auto; min-height: 34px; padding: 4px 8px; }

.agenda-tete { display: flex; flex-wrap: wrap; align-items: center; gap: var(--e2); margin-bottom: var(--e3); }
.agenda-tete h2 { margin: 0; min-width: 170px; text-align: center; }
.agenda-legende { margin-left: auto; display: inline-flex; gap: var(--e2); }
.agenda-legende .agenda-rot { display: inline-block; }
table.agenda { width: 100%; border-collapse: collapse; table-layout: fixed; }
table.agenda th {
  font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--texte-faible);
  padding: 0 0 var(--e1); text-align: left; font-weight: 700;
}
table.agenda td {
  vertical-align: top; height: 110px; padding: 6px; border: 1px solid var(--bord);
  background: var(--surface);
}
table.agenda td.hors-mois { background: var(--surface-3); }
table.agenda td.hors-mois .agenda-num { color: var(--texte-faible); }
table.agenda td.aujourdhui { box-shadow: inset 0 0 0 2px var(--accent); }
.agenda-jour { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.agenda-num { font-weight: 700; font-size: 13px; }
.agenda-jour-nom { display: none; }
.agenda-ajout {
  width: 24px; height: 24px; border-radius: 50%; display: inline-grid; place-items: center;
  color: var(--texte-faible); text-decoration: none; font-weight: 700; opacity: 0;
}
table.agenda td:hover .agenda-ajout, .agenda-ajout:focus-visible { opacity: 1; background: var(--acier-50); color: var(--accent-fort); }
.agenda-rot {
  display: block; margin-top: 3px; padding: 3px 7px; border-radius: var(--r-sm);
  font-size: 12px; line-height: 1.35; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  border-left: 3px solid;
}
.agenda-rot .agenda-benne { opacity: .75; font-weight: 600; }
.agenda-planifiee { background: var(--avert-fond); color: var(--avert-texte); border-color: var(--avert-bord); }
.agenda-realisee { background: var(--acier-50); color: var(--accent-fort); border-color: var(--accent); }
@media (hover: none) { .agenda-ajout { opacity: 1; } }
/* petit écran : l'agenda devient une liste de jours (jours vides masqués) */
@media (max-width: 760px) {
  table.agenda thead { display: none; }
  table.agenda, table.agenda tbody, table.agenda tr, table.agenda td { display: block; width: 100%; }
  table.agenda td { height: auto; border-width: 0 0 1px; }
  table.agenda td.hors-mois { display: none; }
  table.agenda td:not(:has(.agenda-rot)):not(.aujourdhui) { display: none; }
  .agenda-jour-nom { display: inline; font-weight: 500; color: var(--texte-faible); }
}

/* facture annulée : étapes « corriger puis refaire » */
.etapes-correction { margin: 0; padding-left: 22px; display: grid; gap: var(--e3); }
.etapes-correction > li { padding-left: 4px; }
.etapes-correction > li::marker { font-weight: 700; color: var(--accent-fort); }
.etapes-correction > li.fait { color: var(--texte-doux); }
.etapes-correction > li.fait::marker { color: var(--succes-texte); }
.etapes-correction .tableau-enveloppe, .etapes-correction .form-ligne { margin-top: var(--e2); }

/* =====================================================================
   Aide et manuel (aide/, contenu assets/libs/aide/manuel.md)
   ===================================================================== */
.manuel-outils { display: flex; flex-wrap: wrap; gap: var(--e2); align-items: center; margin-bottom: var(--e3); }
.manuel-outils input[type="search"] { flex: 1 1 260px; }
.manuel-liens { margin: 0; padding-left: 22px; columns: 2 260px; column-gap: var(--e6, 32px); }
.manuel-liens li { margin: 3px 0; break-inside: avoid; }
.manuel-vide { color: var(--texte-faible); margin: var(--e2) 0 0; }
.manuel-partie { scroll-margin-top: 80px; line-height: 1.6; }
.manuel-partie:target { outline: 2px solid var(--accent); outline-offset: 2px; }
.manuel-partie h3 { margin: var(--e4) 0 var(--e2); font-size: 15.5px; }
.manuel-partie ul, .manuel-partie ol { padding-left: 22px; margin: 0 0 var(--e3); }
.manuel-partie li { margin: 4px 0; }
.manuel-partie li > ul, .manuel-partie li > ol { margin: 4px 0 0; }
.manuel-partie p { margin: 0 0 var(--e3); }
.manuel-partie .aide-t td, .manuel-partie .aide-t th { white-space: normal; vertical-align: top; }
.manuel-partie .tableau-enveloppe { margin-bottom: var(--e3); }
.manuel-haut { font-size: 13px; }
.mode-simple .manuel-partie { font-size: 16px; }
@media print {
  .manuel-outils, .manuel-haut, .btn-aide, .btn-perso { display: none !important; }
  .manuel-partie { break-before: page; outline: none !important; }
  .manuel-partie[hidden] { display: block !important; }
}

/* aperçu du logo des documents (Référentiels > Société) */
.logo-apercu { padding: var(--e3); margin-bottom: var(--e3); background: #fff; border: 1px solid var(--bord); border-radius: var(--r-md); display: inline-block; }
.logo-apercu img { display: block; max-height: 80px; max-width: 280px; object-fit: contain; }

/* Utilisateurs > Tableau de bord masqué : cases des rôles sur plusieurs colonnes */
.cases-roles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--e2) var(--e4); box-shadow: none; }
.cases-roles legend { grid-column: 1 / -1; }

/* Mon compte : couleur de l'interface */
.couleur-choix { display: flex; flex-wrap: wrap; align-items: center; gap: var(--e3); margin-bottom: var(--e3); }
.couleur-choix input[type="color"] { width: 64px; height: 44px; padding: 3px; cursor: pointer; }
.couleur-apercu { display: flex; flex-wrap: wrap; align-items: center; gap: var(--e2); }

/* rachat : état du scanner de pièces du poste (à côté de la recherche) */
.scan-etat {
  display: inline-flex; align-items: center; gap: 6px; margin: 0; white-space: nowrap;
  padding: 3px 10px; border-radius: var(--r-pill); font-size: 12px; font-weight: 650;
  background: var(--succes-fond); color: var(--succes-texte); border: 1px solid var(--succes-bord);
}
.scan-etat::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.scan-etat.scan-hors-ligne { background: var(--avert-fond); color: var(--avert-texte); border-color: var(--avert-bord); white-space: normal; }

/* =====================================================================
   Assistant : bulle en bas à droite (AssistantBulleHtml, assets/js/assistant.js)
   Au-dessus de la barre des totaux des saisies (--barre-bas), sous les toasts.
   ===================================================================== */
.ia-bulle {
  position: fixed; right: 20px; bottom: calc(var(--barre-bas, 0px) + 20px); z-index: 900;
  width: 56px; height: 56px; border-radius: 50%; border: 0; cursor: pointer;
  display: grid; place-items: center;
  background: var(--accent); color: var(--sur-accent); box-shadow: var(--ombre-3);
  transition: transform var(--transition), background var(--transition);
}
.ia-bulle .ico { width: 26px; height: 26px; color: currentColor; }
.ia-bulle:hover { transform: scale(1.06); background: var(--accent-fort); }
.ia-bulle:focus-visible { outline: 3px solid var(--accent-doux); outline-offset: 3px; }
.ia-bulle.est-ouverte { transform: scale(.92); }
.ia-panneau {
  position: fixed; right: 20px; bottom: calc(var(--barre-bas, 0px) + 88px); z-index: 900;
  width: min(420px, calc(100vw - 40px)); height: min(640px, calc(100vh - var(--barre-bas, 0px) - 120px));
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface); color: var(--texte);
  border: 1px solid var(--bord); border-radius: 14px; box-shadow: var(--ombre-3);
}
.ia-tete {
  display: flex; align-items: center; justify-content: space-between; gap: var(--e2);
  padding: 8px 10px 8px 16px; background: var(--accent); color: var(--sur-accent);
}
.ia-titre { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; }
.ia-titre .ico { width: 18px; height: 18px; color: currentColor; }
.ia-actions { display: flex; gap: 2px; }
.ia-btn {
  width: 34px; height: 34px; display: grid; place-items: center;
  border: 0; border-radius: 8px; background: transparent; color: inherit; cursor: pointer;
}
.ia-btn:hover, .ia-btn:focus-visible { background: rgba(255, 255, 255, .18); }
.ia-btn .ico { width: 18px; height: 18px; color: currentColor; }
.ia-conversations { max-height: 45%; overflow-y: auto; background: var(--surface-2); border-bottom: 1px solid var(--bord); }
.ia-conv-tete {
  padding: 10px 16px 6px; font-size: 11px; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--texte-faible);
}
#ia-conv-liste { padding: 0 8px 8px; font-size: 13px; color: var(--texte-doux); }
.ia-conv { display: flex; align-items: center; gap: 4px; border-radius: 8px; }
.ia-conv.est-active { background: var(--acier-50); }
.ia-conv-titre {
  flex: 1; min-width: 0; padding: 7px 8px; text-align: left;
  border: 0; border-radius: 8px; background: none; font: inherit; color: var(--texte); cursor: pointer;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ia-conv-titre:hover, .ia-conv-titre:focus-visible { background: var(--acier-50); }
.ia-conv-date { display: block; font-size: 11.5px; color: var(--texte-faible); }
.ia-messages { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; background: var(--fond); }
.ia-msg { max-width: 92%; padding: 10px 12px; border-radius: 12px; font-size: 14px; line-height: 1.45; overflow-wrap: anywhere; }
.ia-msg p { margin: 0 0 6px; }
.ia-msg p:last-child { margin-bottom: 0; }
.ia-msg ul, .ia-msg ol { margin: 4px 0 6px; padding-left: 20px; }
.ia-msg li { margin: 2px 0; }
.ia-msg code { font-size: 12.5px; background: var(--surface-3); padding: 1px 4px; border-radius: 4px; }
.ia-msg a { color: var(--accent); font-weight: 600; }
.ia-msg-question {
  align-self: flex-end; white-space: pre-wrap;
  background: var(--accent); color: var(--sur-accent); border-bottom-right-radius: 4px;
}
.ia-msg-reponse { align-self: flex-start; background: var(--surface); border: 1px solid var(--bord); border-bottom-left-radius: 4px; }
.ia-msg-erreur { align-self: flex-start; background: var(--erreur-fond); color: var(--erreur-texte); }
.ia-msg-attente {
  align-self: flex-start; display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--bord); color: var(--texte-doux); font-size: 13px;
}
.ia-points { display: inline-flex; gap: 4px; }
.ia-points i { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: ia-point 1.2s infinite ease-in-out; }
.ia-points i:nth-child(2) { animation-delay: .15s; }
.ia-points i:nth-child(3) { animation-delay: .3s; }
@keyframes ia-point { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.ia-tableau { overflow-x: auto; margin: 6px 0; }
.ia-tableau table { border-collapse: collapse; font-size: 13px; width: 100%; }
.ia-tableau th, .ia-tableau td { padding: 4px 8px; border-bottom: 1px solid var(--bord); text-align: left; white-space: nowrap; }
.ia-tableau th { font-size: 11.5px; color: var(--texte-faible); }
.ia-tableau td.num { text-align: right; font-variant-numeric: tabular-nums; }
.ia-suggestions { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.ia-suggestion {
  padding: 8px 10px; text-align: left; cursor: pointer;
  border: 1px solid var(--bord-fort); border-radius: 10px; background: var(--surface-2);
  font: inherit; font-size: 13px; color: var(--texte);
}
.ia-suggestion:hover, .ia-suggestion:focus-visible { border-color: var(--accent); background: var(--acier-50); }
.ia-avis { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-top: 8px; }
.ia-avis > button {
  padding: 2px 6px; border: 1px solid transparent; border-radius: 6px;
  background: none; font-size: 14px; cursor: pointer; opacity: .55;
}
.ia-avis > button:hover, .ia-avis > button.est-choisi { opacity: 1; border-color: var(--bord); background: var(--surface-2); }
.ia-avis-note { display: flex; gap: 6px; width: 100%; margin-top: 4px; }
.ia-avis-note input { flex: 1; min-width: 0; font-size: 13px; }
.ia-saisie { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--bord); background: var(--surface); }
.ia-saisie textarea {
  flex: 1; min-height: 40px; max-height: 140px; resize: none;
  padding: 9px 12px; border-radius: 10px; font: inherit; font-size: 14px; line-height: 1.4;
}
.ia-envoyer {
  width: 40px; height: 40px; flex: 0 0 40px; display: grid; place-items: center;
  border: 0; border-radius: 10px; background: var(--accent); color: var(--sur-accent); cursor: pointer;
}
.ia-envoyer:disabled { opacity: .5; cursor: wait; }
.ia-envoyer .ico { width: 18px; height: 18px; color: currentColor; }
.ia-pied { padding: 0 12px 8px; font-size: 11px; text-align: center; color: var(--texte-faible); background: var(--surface); }
@media (max-width: 640px) {
  .ia-bulle { right: 14px; bottom: calc(var(--barre-bas, 0px) + 14px); }
  .ia-panneau { inset: 0; width: auto; height: auto; border-radius: 0; z-index: 1001; }
}
@media print { .ia-bulle, .ia-panneau { display: none !important; } }

/* ===== Statistiques et feuille du jour (deploy-19) ===== */
.st-libelle { margin: 0; font-size: 18px; font-weight: 650; display: flex; flex-wrap: wrap; align-items: center; gap: var(--e2); }
.carte > p.aide { margin: var(--e3) 0 0; font-size: 12.5px; color: var(--texte-faible); line-height: 1.4; }
.st-ecarts { white-space: normal !important; }
.st-hausse { color: var(--succes-texte); font-weight: 650; }
.st-baisse { color: var(--erreur-texte); font-weight: 650; }
/* graphique : une série, une teinte ; la période en cours en teinte forte */
.st-graphe svg { display: block; width: 100%; height: auto; max-height: 340px; overflow: visible; }
.st-grille line { stroke: var(--bord); stroke-width: 1; }
.st-grille text, .st-axe, .st-valeur { fill: var(--texte-faible); font-size: 12px; font-variant-numeric: tabular-nums; }
.st-valeur { fill: var(--texte-doux); font-size: 11.5px; }
.st-axe-courant { fill: var(--accent-fort); font-weight: 700; }
.st-barre { fill: var(--accent); opacity: .82; transition: opacity var(--transition); }
.st-barre:hover { opacity: 1; }
.st-barre-courant { fill: var(--accent-fort); opacity: 1; }
.st-modes { margin-top: var(--e4); }
.mode-simple .st-graphe svg { max-height: 260px; }

/* ===== Courrier reçu (R-0066) ===== */
.courrier-depot {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: var(--e2) var(--e3);
  padding: var(--e4); border: 2px dashed var(--bord); border-radius: 12px; background: var(--surface-3);
  text-align: center; transition: border-color var(--transition), background var(--transition);
}
.courrier-depot > .ico { width: 28px; height: 28px; color: var(--accent); }
.courrier-depot p { margin: 0; }
.courrier-depot .courrier-depot-etat { flex-basis: 100%; font-size: 13px; color: var(--texte-doux); }
.courrier-depot .courrier-depot-etat:empty { display: none; }
.courrier-depot-survol { border-color: var(--accent); background: var(--acier-50); }
.courrier-depot-envoi { opacity: .75; cursor: progress; }
.courrier-compteurs { display: flex; flex-wrap: wrap; gap: var(--e2); }
.courrier-compteurs a.pastille { text-decoration: none; font-size: 13px; padding: 4px 12px; }
tr.ligne-urgente > td:first-child { box-shadow: inset 3px 0 0 var(--erreur-texte); }
.courrier-apercu { display: block; width: 100%; height: 72vh; min-height: 420px; border: 1px solid var(--bord); border-radius: 8px; background: #fff; }
.courrier-apercu-image { height: auto; min-height: 0; max-height: 80vh; object-fit: contain; }
.courrier-statuts { display: flex; flex-wrap: wrap; gap: var(--e2); margin-bottom: var(--e3); }
.courrier-statut {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; border: 1px solid var(--bord);
  border-radius: var(--r-pill); cursor: pointer; font-weight: 600; font-size: 13.5px;
}
.courrier-statut input { margin: 0; }
.courrier-statut:has(input:checked) { border-color: var(--accent); background: var(--acier-50); color: var(--accent-fort); }
.courrier-statut-urgent:has(input:checked) { border-color: var(--erreur-bord); background: var(--erreur-fond); color: var(--erreur-texte); }
.courrier-statut-termine:has(input:checked) { border-color: var(--succes-bord); background: var(--succes-fond); color: var(--succes-texte); }
.courrier-champs { border: 0; padding: 0; margin: 0; min-width: 0; }
.courrier-client { display: flex; align-items: center; gap: var(--e2); }
.courrier-suggestions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.carte .courrier-depot { margin-bottom: var(--e3); }
