/* =====================================================================
   Bipstock — feuille de style unique.
   Mobile d'abord : l'utilisateur principal est sur un téléphone, souvent
   avec des gants, dans une cave mal éclairée. D'où les cibles tactiles
   de 48 px minimum et les contrastes élevés.
   ===================================================================== */

:root {
  --encre:        #0f172a;
  --encre-douce:  #475569;
  --encre-pale:   #94a3b8;
  --fond:         #f1f5f9;
  --surface:      #ffffff;
  --bordure:      #e2e8f0;

  --primaire:        #0d6efd;
  --primaire-sombre: #0b5ed7;
  --succes:          #15803d;
  --succes-fond:     #dcfce7;
  --alerte:          #b45309;
  --alerte-fond:     #fef3c7;
  --danger:          #b91c1c;
  --danger-fond:     #fee2e2;

  --rayon:       10px;
  --rayon-large: 16px;
  --ombre:       0 1px 2px rgb(15 23 42 / 6%), 0 4px 12px rgb(15 23 42 / 6%);

  --largeur-laterale: 248px;
  --hauteur-nav-basse: 64px;
  --cible-tactile: 48px;
}

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

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

body {
  margin: 0;
  background: var(--fond);
  color: var(--encre);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  font-size: 16px;          /* jamais moins : sous 16 px, iOS zoome sur les champs */
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; }

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

/* --- Marque ------------------------------------------------------- */

.marque { display: flex; align-items: center; gap: .7rem; color: inherit; text-decoration: none; }
.marque:hover { text-decoration: none; }

.marque__logo {
  display: grid; place-items: center;
  width: 40px; height: 40px;
  border-radius: var(--rayon);
  background: var(--primaire);
  color: #fff; font-weight: 700; font-size: 1.25rem;
  flex: 0 0 auto;
}

.marque__texte { font-weight: 650; letter-spacing: -.01em; }
.marque__texte small { display: block; font-weight: 400; font-size: .78rem; color: var(--encre-pale); }
.marque--grande { justify-content: center; margin-bottom: 1.75rem; font-size: 1.2rem; }

/* --- Structure ---------------------------------------------------- */

.lateral { display: none; }

.principal { min-height: 100vh; padding-bottom: calc(var(--hauteur-nav-basse) + env(safe-area-inset-bottom)); }

.entete-mobile {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .75rem 1rem;
  background: var(--encre); color: #fff;
  padding-top: calc(.75rem + env(safe-area-inset-top));
}

.entete-mobile__titre { font-weight: 650; font-size: 1.05rem; }

.entete-mobile__actions { display: flex; align-items: center; gap: .5rem; }

.contenu { padding: 1rem; max-width: 1180px; margin: 0 auto; }

/* --- Navigation basse (mobile) ------------------------------------ */

.nav-basse {
  position: fixed; inset: auto 0 0 0; z-index: 30;
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  background: var(--surface);
  border-top: 1px solid var(--bordure);
  padding-bottom: env(safe-area-inset-bottom);
}

.nav-basse__lien {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: var(--hauteur-nav-basse);
  color: var(--encre-douce);
  text-decoration: none;
}
.nav-basse__lien:hover { text-decoration: none; }
.nav-basse__lien.est-actif { color: var(--primaire); font-weight: 600; }

.nav-basse__icone { font-size: 1.35rem; line-height: 1; }
.nav-basse__libelle { font-size: .7rem; }

.nav-basse__lien--principal .nav-basse__icone {
  display: grid; place-items: center;
  width: 46px; height: 46px; margin-top: -18px;
  border-radius: 50%;
  background: var(--primaire); color: #fff;
  box-shadow: var(--ombre);
}

/* --- Cartes et actions -------------------------------------------- */

.titre-page { font-size: 1.5rem; margin-bottom: .25rem; }
.texte-secondaire { color: var(--encre-douce); margin: 0 0 1.5rem; }

.grille-cartes {
  display: grid; gap: .875rem;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

.carte-action {
  display: flex; flex-direction: column; gap: .2rem;
  padding: 1.1rem;
  background: var(--surface);
  border: 1px solid var(--bordure);
  border-radius: var(--rayon-large);
  box-shadow: var(--ombre);
  color: inherit; text-decoration: none;
  transition: transform .12s ease, border-color .12s ease;
}
.carte-action:hover { text-decoration: none; transform: translateY(-2px); border-color: var(--primaire); }
.carte-action__icone { font-size: 1.6rem; }
.carte-action__titre { font-weight: 650; }
.carte-action__soustitre { color: var(--encre-douce); font-size: .875rem; }

.carte-action--vedette { background: var(--encre); color: #fff; border-color: var(--encre); }
.carte-action--vedette .carte-action__soustitre { color: #cbd5e1; }

/* --- Page centrée (connexion) ------------------------------------- */

.corps--centre { display: grid; place-items: center; min-height: 100vh; padding: 1.25rem; }

.carte-centree {
  width: 100%; max-width: 400px;
  padding: 1.75rem;
  background: var(--surface);
  border: 1px solid var(--bordure);
  border-radius: var(--rayon-large);
  box-shadow: var(--ombre);
}

.carte-centree__titre { font-size: 1.25rem; text-align: center; margin-bottom: 1.25rem; }

/* --- Formulaires -------------------------------------------------- */

.formulaire { display: flex; flex-direction: column; gap: 1rem; }

.champ { display: flex; flex-direction: column; gap: .35rem; }
.champ__libelle { font-size: .875rem; font-weight: 600; color: var(--encre-douce); }
.champ__aide { font-size: .8rem; color: var(--encre-pale); }

input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="date"], input[type="search"], input[type="tel"], select, textarea {
  width: 100%;
  min-height: var(--cible-tactile);
  padding: .6rem .75rem;
  font: inherit;
  color: var(--encre);
  background: var(--surface);
  border: 1px solid var(--bordure);
  border-radius: var(--rayon);
}

input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--primaire);
  outline-offset: 2px;
}

textarea { min-height: 96px; resize: vertical; }

/* --- Boutons ------------------------------------------------------ */

.bouton {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  min-height: var(--cible-tactile);
  padding: .6rem 1.1rem;
  font: inherit; font-weight: 600;
  border: 1px solid transparent;
  border-radius: var(--rayon);
  background: var(--surface);
  color: var(--encre);
  cursor: pointer;
  text-decoration: none;
}
.bouton:hover { text-decoration: none; }
.bouton:disabled { opacity: .55; cursor: not-allowed; }

.bouton--principal { background: var(--primaire); border-color: var(--primaire); color: #fff; }
.bouton--principal:hover { background: var(--primaire-sombre); border-color: var(--primaire-sombre); }

.bouton--secondaire { border-color: var(--bordure); }
.bouton--secondaire:hover { border-color: var(--encre-pale); }

.bouton--danger { background: var(--danger); border-color: var(--danger); color: #fff; }

.bouton--discret { background: transparent; border-color: rgb(255 255 255 / 25%); color: inherit; }
.bouton--discret:hover { background: rgb(255 255 255 / 10%); }

.bouton--bloc { width: 100%; }
.bouton--petit { min-height: 36px; padding: .3rem .7rem; font-size: .85rem; }

/* --- Alertes ------------------------------------------------------ */

.flashs { display: flex; flex-direction: column; gap: .6rem; margin-bottom: 1rem; }

.alerte {
  padding: .75rem 1rem;
  border-radius: var(--rayon);
  border: 1px solid transparent;
  font-size: .925rem;
}
.alerte--succes { background: var(--succes-fond); border-color: #bbf7d0; color: var(--succes); }
.alerte--erreur { background: var(--danger-fond); border-color: #fecaca; color: var(--danger); }
.alerte--info   { background: #e0f2fe; border-color: #bae6fd; color: #075985; }
.alerte--attention { background: var(--alerte-fond); border-color: #fde68a; color: var(--alerte); }

/* --- Page d'erreur ------------------------------------------------ */

.erreur-page { text-align: center; padding: 3rem 1rem; }
.erreur-page__code { font-size: 3.5rem; font-weight: 700; color: var(--encre-pale); line-height: 1; }
.erreur-page__message { color: var(--encre-douce); margin: .75rem 0 1.5rem; white-space: pre-wrap; text-align: left; }

/* --- Tableaux ----------------------------------------------------- */

.tableau-conteneur { overflow-x: auto; border-radius: var(--rayon-large); border: 1px solid var(--bordure); background: var(--surface); }

table.tableau { width: 100%; border-collapse: collapse; font-size: .925rem; }
table.tableau th, table.tableau td { padding: .7rem .85rem; text-align: left; border-bottom: 1px solid var(--bordure); }
table.tableau th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--encre-douce); background: #f8fafc; }
table.tableau tr:last-child td { border-bottom: none; }
table.tableau td.nombre, table.tableau th.nombre { text-align: right; font-variant-numeric: tabular-nums; }

/* Un montant coupé en deux lignes se lit mal et se relit faux. */
table.tableau td.nombre { white-space: nowrap; }
.cellule-actions .bouton { white-space: nowrap; }

/* Tableau en cartes sur petit écran.
   Sept colonnes dans 390 px de large, c'est illisible : chaque ligne devient
   une carte et l'intitulé de colonne passe devant la valeur, via data-libelle. */
@media (max-width: 899px) {
  .tableau-conteneur--cartes { border: none; background: transparent; overflow: visible; }

  .tableau--cartes thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

  .tableau--cartes tr {
    display: block;
    margin-bottom: .75rem;
    padding: .85rem 1rem;
    background: var(--surface);
    border: 1px solid var(--bordure);
    border-radius: var(--rayon-large);
  }

  .tableau--cartes td {
    display: flex; align-items: baseline; justify-content: space-between; gap: 1rem;
    padding: .2rem 0;
    border: none;
    text-align: right;
  }

  .tableau--cartes td::before {
    content: attr(data-libelle);
    flex: 0 0 auto;
    font-size: .78rem; font-weight: 600; text-transform: uppercase; letter-spacing: .03em;
    color: var(--encre-douce);
    text-align: left;
  }

  /* La cellule mise en avant sert de titre de carte : pas d'intitulé, pleine largeur. */
  .tableau--cartes td.cellule-titre {
    display: block;
    margin-bottom: .4rem;
    font-size: 1.02rem; font-weight: 650;
    text-align: left;
  }
  .tableau--cartes td.cellule-titre::before { content: none; }

  .tableau--cartes td.cellule-actions { justify-content: flex-end; padding-top: .6rem; }
  .tableau--cartes td.cellule-actions::before { content: none; }
}

/* --- En-tête de page et filtres ----------------------------------- */

.barre-titre {
  display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between;
  gap: .75rem; margin-bottom: 1.25rem;
}
.barre-titre__actions { display: flex; gap: .5rem; flex-wrap: wrap; }

.texte-secondaire--serre { margin: 0; font-size: .9rem; }

.barre-filtres {
  display: flex; flex-wrap: wrap; gap: .6rem; align-items: center;
  margin-bottom: 1.25rem;
}
.barre-filtres__recherche { flex: 1 1 240px; }
/* Sur mobile, deux sélecteurs tiennent côte à côte : la barre de filtres ne doit
   pas repousser la liste sous la ligne de flottaison. */
.barre-filtres__champ { flex: 1 1 150px; max-width: 220px; }

.case-a-cocher {
  display: inline-flex; align-items: center; gap: .5rem;
  min-height: var(--cible-tactile);
  font-size: .925rem; cursor: pointer;
}
.case-a-cocher input { width: 20px; height: 20px; min-height: 0; margin: 0; accent-color: var(--primaire); }

/* --- Blocs de contenu --------------------------------------------- */

.bloc {
  padding: 1.25rem;
  margin-bottom: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--bordure);
  border-radius: var(--rayon-large);
}
.bloc__titre { font-size: 1.05rem; margin-bottom: .75rem; }
.bloc--danger { border-color: #fecaca; }
.bloc--vedette { border-color: var(--primaire); border-width: 2px; }

.case-a-cocher--bloc { display: flex; margin: .5rem 0 1rem; }

/* Formulaire d'une seule ligne : un champ et son bouton d'action. */
.ligne-actions { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .75rem; margin-bottom: .75rem; }
.ligne-actions .champ { flex: 0 1 260px; }

.bloc__entete { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .5rem; }
.bloc__total { font-size: 1.25rem; font-weight: 700; font-variant-numeric: tabular-nums; }

.encadre {
  padding: 1rem;
  margin-top: 1rem;
  background: #f8fafc;
  border: 1px solid var(--bordure);
  border-radius: var(--rayon);
}
.encadre__titre { font-size: .95rem; margin-bottom: .25rem; }

/* --- Onglets (emplacements de stock) ------------------------------- */

.onglets { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: 1rem; }

.onglets__lien {
  display: inline-flex; align-items: center;
  min-height: 40px;
  padding: .35rem .9rem;
  border: 1px solid var(--bordure);
  border-radius: 999px;
  background: var(--surface);
  color: var(--encre-douce);
  font-size: .9rem; font-weight: 600;
  text-decoration: none;
}
.onglets__lien:hover { text-decoration: none; border-color: var(--encre-pale); }
.onglets__lien.est-actif { background: var(--primaire); border-color: var(--primaire); color: #fff; }

/* Saisie d'inventaire directement dans la ligne du tableau. */
.ligne-inventaire { display: flex; gap: .35rem; align-items: center; }
.champ-compact { width: 6.5rem; min-height: 36px; padding: .25rem .5rem; font-size: .875rem; }

.colonnes { display: grid; gap: 1.25rem; grid-template-columns: 1fr; }
.colonnes--serrees { gap: 1rem; }

.liste-definitions { display: grid; grid-template-columns: auto 1fr; gap: .4rem 1rem; margin: 0; }
.liste-definitions dt { color: var(--encre-douce); font-size: .875rem; }
.liste-definitions dd { margin: 0; font-variant-numeric: tabular-nums; }
.liste-definitions + .texte-secondaire { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--bordure); }
.valeur-forte { font-weight: 650; font-size: 1.05rem; }

/* --- Formulaires étendus ------------------------------------------ */

.formulaire--large { gap: 0; }

.grille-champs {
  display: grid; gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  align-items: start;
}
.champ--large { grid-column: 1 / -1; }
.champ__erreur { font-size: .8rem; color: var(--danger); font-weight: 600; }

.actions-formulaire { display: flex; gap: .6rem; flex-wrap: wrap; margin-bottom: 2rem; }

/* --- Étiquettes ---------------------------------------------------- */

.etiquette {
  display: inline-block;
  padding: .1rem .45rem;
  margin-left: .3rem;
  font-size: .72rem; font-weight: 600;
  white-space: nowrap;
  border-radius: 999px;
  background: #e2e8f0; color: var(--encre-douce);
  vertical-align: middle;
}
.etiquette--principale { background: #dbeafe; color: #1d4ed8; }
.etiquette--attention  { background: var(--alerte-fond); color: var(--alerte); }
.etiquette--sourdine   { background: #f1f5f9; color: var(--encre-pale); }

/* Statuts de chantier : la couleur doit dire d'un coup d'œil ce qui est vivant. */
.etiquette--statut-en_cours { background: #dcfce7; color: var(--succes); }
.etiquette--statut-prospect { background: #e0f2fe; color: #075985; }
.etiquette--statut-termine  { background: #ede9fe; color: #5b21b6; }
.etiquette--statut-facture  { background: #f1f5f9; color: var(--encre-douce); }
.etiquette--statut-annule   { background: var(--danger-fond); color: var(--danger); }

.cellule-mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .875rem; }
/* Une référence ou un code-barres coupé en deux lignes se relit de travers. */
table.tableau td.cellule-mono { white-space: nowrap; }
.cellule-actions { display: flex; gap: .4rem; flex-wrap: wrap; justify-content: flex-end; }
.ligne--inactive { opacity: .6; }

/* --- Listes simples (tableau de bord) ------------------------------ */

.liste-simple { list-style: none; margin: 0; padding: 0; }
.liste-simple li { padding: .55rem 0; border-bottom: 1px solid var(--bordure); }
.liste-simple li:last-child { border-bottom: none; }
.liste-simple__detail { display: block; font-size: .85rem; color: var(--encre-douce); }

code {
  padding: .1rem .3rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .875em;
  background: #f1f5f9;
  border-radius: 4px;
}

/* --- État vide et pagination -------------------------------------- */

.etat-vide {
  padding: 2.5rem 1.5rem; text-align: center;
  background: var(--surface);
  border: 1px dashed var(--bordure);
  border-radius: var(--rayon-large);
}
.etat-vide__titre { font-size: 1.1rem; font-weight: 650; margin-bottom: .35rem; }
.etat-vide .texte-secondaire { max-width: 46ch; margin: 0 auto 1.25rem; }

.pagination { display: flex; align-items: center; justify-content: center; gap: 1rem; margin-top: 1.25rem; }
.pagination__position { color: var(--encre-douce); font-size: .9rem; }

/* --- Desktop ------------------------------------------------------ */

@media (min-width: 900px) {
  .nav-basse, .entete-mobile { display: none; }

  .lateral {
    position: fixed; inset: 0 auto 0 0;
    display: flex; flex-direction: column; gap: 1.5rem;
    width: var(--largeur-laterale);
    padding: 1.25rem 1rem;
    background: var(--encre);
    color: #e2e8f0;
  }

  .lateral__nav { display: flex; flex-direction: column; gap: .2rem; flex: 1; }

  .lateral__lien {
    display: flex; align-items: center; gap: .65rem;
    padding: .65rem .75rem;
    border-radius: var(--rayon);
    color: #cbd5e1; text-decoration: none;
  }
  .lateral__lien:hover { background: rgb(255 255 255 / 8%); text-decoration: none; }
  .lateral__lien.est-actif { background: var(--primaire); color: #fff; font-weight: 600; }

  .lateral__pied { border-top: 1px solid rgb(255 255 255 / 12%); padding-top: 1rem; }
  .lateral__utilisateur { font-size: .85rem; color: var(--encre-pale); margin-bottom: .6rem; }

  .principal { margin-left: var(--largeur-laterale); padding-bottom: 2rem; }
  .contenu { padding: 2rem; }
  .titre-page { font-size: 1.75rem; }

  .colonnes { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bloc { padding: 1.5rem; }
}

/* --- Préférences utilisateur -------------------------------------- */

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

/* Carte d'appel à l'action : du matériel sorti non facturé, c'est de l'argent
   qui dort. Elle doit se distinguer des compteurs neutres. */
.carte-action--attention {
  background: var(--alerte-fond);
  border-color: #fde68a;
}
.carte-action--attention .carte-action__soustitre { color: var(--alerte); }

/* =====================================================================
   Écran de scan
   Plein écran, gros boutons, contraste élevé : il s'utilise debout, d'une
   main, parfois avec des gants, dans une cave mal éclairée.
   ===================================================================== */

.corps--scan {
  display: flex; flex-direction: column;
  min-height: 100dvh;
  background: var(--fond);
}

.scan-entete {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: calc(.75rem + env(safe-area-inset-top)) 1rem .75rem;
  background: var(--encre); color: #fff;
}
.scan-entete__chantier { display: block; font-weight: 650; line-height: 1.3; }
.scan-entete__details { display: block; font-size: .78rem; color: var(--encre-pale); }

.scan-entete__reseau {
  flex: 0 0 auto;
  padding: .2rem .6rem;
  border-radius: 999px;
  background: var(--alerte-fond); color: var(--alerte);
  font-size: .75rem; font-weight: 700;
}

.scan-corps { flex: 1; padding: 1rem; max-width: 720px; width: 100%; margin: 0 auto; }

/* Le champ de la douchette doit rester focalisable, donc pas `display: none` :
   un élément masqué ne reçoit pas les frappes clavier. */
.entree-invisible {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  border: 0;
  opacity: 0;
  pointer-events: none;
}

.scan-actions { display: flex; flex-direction: column; gap: .6rem; margin-bottom: 1rem; }
.bouton--geant { min-height: 76px; font-size: 1.1rem; }

.scan-camera { position: relative; margin-bottom: 1rem; }
.scan-camera video {
  width: 100%; aspect-ratio: 4 / 3;
  object-fit: cover;
  background: #000;
  border-radius: var(--rayon-large);
}
.scan-camera__viseur {
  position: absolute; inset: 22% 12%;
  border: 3px solid rgb(255 255 255 / 85%);
  border-radius: var(--rayon);
  box-shadow: 0 0 0 100vmax rgb(0 0 0 / 25%);
}
.scan-camera__fermer { position: absolute; inset: auto 0 .75rem 0; width: max-content; margin: 0 auto; }

.scan-retour {
  padding: .85rem 1rem;
  margin-bottom: 1rem;
  border-radius: var(--rayon);
  font-weight: 600;
}
/* Confirmation d'ajout. Volontairement grande : elle se lit à bout de bras,
   dans une cave, sans lunettes. */
.panneau-ajout {
  padding: 1rem;
  margin-bottom: 1rem;
  border-radius: var(--rayon);
  background: var(--succes-fond);
  border: 2px solid var(--succes);
}
.panneau-ajout__titre { font-weight: 700; color: var(--succes); margin-bottom: .25rem; }
.panneau-ajout__designation { font-size: 1.1rem; font-weight: 600; margin-bottom: .85rem; }

.panneau-ajout__quantite {
  display: flex; align-items: center; justify-content: center; gap: 1rem;
  margin-bottom: .85rem;
}
/* 56 px : on vise ces boutons d'un pouce, parfois ganté. */
.panneau-ajout__pas {
  min-width: 56px; min-height: 56px;
  font-size: 1.6rem; line-height: 1; padding: 0;
}
.panneau-ajout__valeur { font-size: 1.5rem; min-width: 6rem; text-align: center; }

.panneau-ajout__actions { display: flex; flex-direction: column; gap: .5rem; }

/* Sépare le rattachement de la création : ce sont deux gestes différents, et
   les confondre crée des fiches en double. */
.dialogue__separateur {
  display: flex; align-items: center; gap: .75rem;
  margin: .25rem 0;
  color: var(--encre-pale); font-size: .85rem;
}
.dialogue__separateur::before,
.dialogue__separateur::after {
  content: ''; flex: 1; height: 1px; background: var(--bordure);
}

.scan-retour--succes  { background: var(--succes-fond); color: var(--succes); }
.scan-retour--erreur  { background: var(--danger-fond); color: var(--danger); }
.scan-retour--attente { background: var(--alerte-fond); color: var(--alerte); }

.scan-lignes__entete { display: flex; align-items: center; justify-content: space-between; }
.scan-lignes__compteur {
  min-width: 2.2rem; padding: .1rem .55rem;
  border-radius: 999px;
  background: var(--primaire); color: #fff;
  font-weight: 700; text-align: center;
}

.liste-scan { list-style: none; margin: 0 0 1rem; padding: 0; }
.liste-scan__ligne {
  display: flex; align-items: baseline; justify-content: space-between; gap: 1rem;
  padding: .7rem .9rem;
  margin-bottom: .4rem;
  background: var(--surface);
  border: 1px solid var(--bordure);
  border-radius: var(--rayon);
}
.liste-scan__designation { font-weight: 600; }
.liste-scan__quantite { font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; }

/* La dernière ligne s'éclaire une seconde : sur un chantier, on regarde
   l'écran une demi-seconde entre deux lectures. */
.liste-scan__ligne--nouvelle { animation: apparition-ligne 1s ease-out; }

@keyframes apparition-ligne {
  from { background: var(--succes-fond); border-color: var(--succes); }
  to   { background: var(--surface); border-color: var(--bordure); }
}

.scan-pied {
  position: sticky; bottom: 0;
  display: flex; gap: .6rem;
  padding: .75rem 1rem calc(.75rem + env(safe-area-inset-bottom));
  margin: 0 -1rem -1rem;
  background: var(--surface);
  border-top: 1px solid var(--bordure);
}
.scan-pied form { flex: 1; }
.scan-pied .bouton { width: 100%; }

/* --- Listes de choix (sélection du chantier) ----------------------- */

.liste-choix { display: flex; flex-direction: column; gap: .5rem; margin-bottom: 1.25rem; }

.choix {
  display: flex; flex-direction: column; gap: .15rem;
  width: 100%;
  min-height: 72px;
  padding: .9rem 1rem;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--bordure);
  border-radius: var(--rayon-large);
  font: inherit; color: inherit;
  cursor: pointer;
}
.choix:hover { border-color: var(--primaire); }
.choix:disabled { opacity: .5; cursor: not-allowed; }
.choix__titre { font-weight: 650; }
.choix__detail { color: var(--encre-douce); font-size: .9rem; }
.choix__meta { color: var(--encre-pale); font-size: .8rem; }

/* --- Boîtes de dialogue -------------------------------------------- */

.dialogue {
  width: min(28rem, calc(100vw - 2rem));
  padding: 1.5rem;
  border: none;
  border-radius: var(--rayon-large);
  background: var(--surface);
  color: var(--encre);
}
.dialogue::backdrop { background: rgb(15 23 42 / 55%); }
.dialogue__titre { font-size: 1.15rem; }
.dialogue__actions { display: flex; gap: .6rem; }
.dialogue__actions .bouton { flex: 1; }

/* --- Galerie de photos de chantier --------------------------------- */

.galerie {
  display: grid; gap: .75rem;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  margin-bottom: 1rem;
}

.galerie__element { margin: 0; }

.galerie__element img {
  display: block;
  width: 100%; height: 130px;
  object-fit: cover;
  background: var(--bordure);
  border-radius: var(--rayon);
}

.galerie__element figcaption {
  display: flex; flex-direction: column; gap: .25rem; align-items: flex-start;
  padding-top: .35rem;
  font-size: .8rem; color: var(--encre-douce);
}
.galerie__legende { font-weight: 600; color: var(--encre); }
.galerie__date { font-variant-numeric: tabular-nums; }

input[type="file"] {
  width: 100%;
  padding: .55rem;
  font: inherit;
  background: var(--surface);
  border: 1px dashed var(--bordure);
  border-radius: var(--rayon);
}

/* --- Choix radio détaillé (import) --------------------------------- */

.choix-radio { display: flex; flex-direction: column; gap: .6rem; }

.choix-radio__option {
  display: flex; align-items: flex-start; gap: .75rem;
  padding: .9rem 1rem;
  border: 1px solid var(--bordure);
  border-radius: var(--rayon);
  cursor: pointer;
}
.choix-radio__option:has(input:checked) { border-color: var(--primaire); background: #f5f9ff; }
.choix-radio__option input { width: 20px; height: 20px; margin: .2rem 0 0; accent-color: var(--primaire); }
.choix-radio__aide { display: block; margin-top: .15rem; font-size: .875rem; color: var(--encre-douce); }

/* --- Planches d'étiquettes à imprimer ------------------------------ */

/*
 * Ces pages n'existent que pour finir sur une feuille. Ce qui est à l'écran
 * doit donc être exactement ce qui sortira de l'imprimante, à la barre
 * d'outils près — d'où `sans-impression`, la seule chose que `@media print`
 * fait disparaître.
 */
.corps--impression { background: #fff; padding: 1rem; }

.barre-impression {
  display: flex; flex-wrap: wrap; align-items: center; gap: 1rem;
  padding: .75rem 0; margin-bottom: .5rem;
  border-bottom: 1px solid var(--bordure);
}
.barre-impression__champ { display: flex; align-items: center; gap: .5rem; }
.barre-impression__libelle { font-weight: 600; }
.barre-impression__champ input { width: 5rem; }
.barre-impression__aide { margin-bottom: 1rem; }

/* 45 mm : un format qui tient sur un bac de rangement et reste lisible à un
   mètre. Six colonnes par A4, soit vingt-quatre étiquettes par feuille. */
.planche-etiquettes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(45mm, 1fr));
  gap: 3mm;
}

.etiquette-qr {
  display: flex; align-items: center; gap: 2mm;
  padding: 2mm;
  border: 1px dashed #94a3b8;      /* trait de découpe */
  border-radius: 2mm;
  break-inside: avoid;             /* jamais coupée entre deux pages */
  background: #fff; color: #000;
}
.etiquette-qr__code { flex: 0 0 20mm; }
.etiquette-qr__code svg { display: block; width: 20mm; height: 20mm; }

.etiquette-qr__texte { display: flex; flex-direction: column; gap: .3mm; min-width: 0; }
.etiquette-qr__designation {
  font-weight: 700; font-size: 2.8mm; line-height: 1.15;
  /* Deux lignes au plus : au-delà, l'étiquette déborde du bac. */
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.etiquette-qr__reference { font-size: 2.4mm; color: #334155; }
.etiquette-qr__quantite  { font-size: 2.4mm; font-weight: 600; }
.etiquette-qr__uid       { font-size: 2mm; font-family: var(--police-mono, monospace); color: #64748b; }

@media print {
  @page { size: A4; margin: 8mm; }

  .sans-impression { display: none !important; }

  .corps--impression { padding: 0; }

  /* Le trait de découpe reste, mais discret : il guide les ciseaux sans
     manger de l'encre. */
  .etiquette-qr { border-color: #cbd5e1; }
}
