/* =====================================================================
   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;
  --n20: #e992a0; /* non utilise, garde-fou visuel si mal reference */
  --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);
  --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;
  --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; }

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

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: #fff; 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(--e3) var(--e4);
  border-top: 1px solid var(--bord);
  font-size: 11.5px; color: var(--texte-faible);
}

/* --- 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; 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: #fff;
  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: 1320px; 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
   ===================================================================== */

.grille { display: grid; gap: var(--e4); }
.grille-4 { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.grille-2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }

.carte {
  background: var(--surface);
  border: 1px solid var(--bord);
  border-radius: var(--r-lg);
  padding: var(--e5);
  box-shadow: var(--ombre-1);
}
.carte h2 {
  margin: 0 0 var(--e4);
  font-size: 11.5px; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--texte-faible);
}

.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
   ===================================================================== */

fieldset {
  border: 1px solid var(--bord); border-radius: var(--r-lg);
  padding: var(--e5); margin: 0 0 var(--e4);
  background: var(--surface); box-shadow: var(--ombre-1);
}
legend {
  padding: 0 var(--e2); font-weight: 700; font-size: 12px;
  letter-spacing: .06em; text-transform: uppercase; color: var(--accent);
}

.champs { display: grid; gap: var(--e3); grid-template-columns: repeat(auto-fit, minmax(200px, 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: #fff;
  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: #fff; 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; }

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

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

.alerte {
  display: flex; gap: var(--e3);
  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-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: #fff;
  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);
}

/* --- 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; }
.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);
}
.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, .carte, fieldset { padding: 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);
}
