/* SB Production — interface de terrain, mobile d'abord, lisible au soleil.
   Palette imposée par le cahier des charges, harmonisée ; aucun service externe (polices système). */

:root {
  --olive: #455C36;
  --olive-fonce: #34462A;
  --olive-clair: #5E7A4A;
  --sauge: #A8BA94;
  --sauge-pale: #E5ECDC;
  --creme: #F7F5EE;
  --creme-fonce: #ECE9DE;
  --blanc: #FFFFFF;
  --terracotta: #C8744F;
  --terracotta-fonce: #A85B3A;
  --rouge: #C64040;
  --ocre: #C99A2E;
  --encre: #26301F;
  --encre-douce: #5C6553;
  --trait: #DAD6C8;
  --rayon: 14px;
  --ombre: 0 1px 2px rgba(38, 48, 31, .08), 0 2px 8px rgba(38, 48, 31, .06);
  --police: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--creme); color: var(--encre);
  font: 18px/1.45 var(--police); min-height: 100vh;
  font-variant-numeric: tabular-nums;
}
a { color: var(--olive); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible,
label.choix:focus-within {
  outline: 3px solid var(--terracotta); outline-offset: 2px;
}
img, svg { max-width: 100%; }
.icone { width: 1.4em; height: 1.4em; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round; vertical-align: -0.3em; }
.visuellement-cache { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- en-tête ---------- */
.entete { background: var(--olive); color: var(--blanc); padding: 14px 18px 16px; }
.entete-ligne { display: flex; align-items: center; justify-content: space-between; gap: 12px; max-width: 760px; margin: 0 auto; }
.marque { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.marque .icone { width: 38px; height: 38px; color: var(--sauge); stroke-width: 1.6; }
.marque-nom { font-weight: 800; letter-spacing: .06em; font-size: 1.05rem; line-height: 1.1; display: block; }
.marque-sous { font-size: .85rem; opacity: .85; display: block; }
.compte { display: flex; align-items: center; gap: 8px; font-size: .85rem; }
.compte form { margin: 0; }
.bouton-discret { background: transparent; border: 1px solid rgba(255,255,255,.4); color: var(--blanc); border-radius: 10px;
  padding: 8px 12px; font: inherit; font-size: .85rem; cursor: pointer; min-height: 44px; }

main { max-width: 760px; margin: 0 auto; padding: 18px 16px 40px; }
h1 { font-size: 1.5rem; margin: 6px 0 14px; line-height: 1.2; }
h2 { font-size: 1.2rem; margin: 26px 0 10px; }
h3 { font-size: 1.05rem; margin: 18px 0 8px; }
p { margin: 0 0 12px; }
.aide { color: var(--encre-douce); font-size: .9rem; }
.date-jour { color: var(--encre-douce); margin: 0 0 14px; font-size: 1rem; }
.date-jour::first-letter { text-transform: uppercase; }
.retour { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; font-weight: 600; margin-bottom: 6px;
  min-height: 44px; }

/* ---------- messages ---------- */
.message { border-radius: var(--rayon); padding: 14px 16px; margin: 0 0 16px; font-weight: 600; display: flex; gap: 10px;
  align-items: flex-start; border: 2px solid; }
.message.ok { background: #EAF2E3; border-color: var(--olive-clair); color: var(--olive-fonce); }
.message.info { background: var(--blanc); border-color: var(--sauge); }
.message.erreur { background: #FBECEC; border-color: var(--rouge); color: #8E2424; }
.message.attention { background: #FBF3E3; border-color: var(--ocre); color: #6B4E0E; }
.message ul { margin: 6px 0 0; padding-left: 20px; font-weight: 500; }

/* ---------- jauges des trémies (haut de l'accueil) ---------- */
.jauges { display: grid; gap: 12px; margin: 4px 0 18px; }
.jauges-liste { display: grid; gap: 12px; }
.jauge { background: var(--blanc); border-radius: var(--rayon); padding: 14px 16px; box-shadow: var(--ombre);
  display: grid; gap: 4px; text-decoration: none; color: inherit; }
.jauge-nom { font-size: .82rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--encre-douce); }
.jauge-valeur { font-size: 2rem; font-weight: 800; line-height: 1.1; }
.jauge .barre-niveau { width: 100%; height: 26px; margin: 4px 0; }
.jauge-detail { font-size: .9rem; color: var(--encre-douce); display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.jauges-action { display: grid; gap: 10px; align-content: start; }
.jauges-action .bouton { width: 100%; }
.bouton.terracotta { background: var(--terracotta-fonce); border-color: var(--terracotta-fonce); }
.enlevement-rapide { display: grid; gap: 8px; padding: 12px 14px; margin: 0; }
.enlevement-rapide fieldset { border: 0; margin: 0; padding: 0; display: grid; gap: 6px; }
.enlevement-rapide legend { font-size: .82rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
  color: var(--encre-douce); margin-bottom: 4px; }
@media (min-width: 720px) {
  .jauges { grid-template-columns: 1fr minmax(220px, 30%); align-items: stretch; }
  .jauges-liste { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
}

/* ---------- indicateurs d'accueil ---------- */
.indicateurs { display: grid; gap: 12px; margin-bottom: 18px; }
.indicateur { background: var(--blanc); border-radius: var(--rayon); padding: 14px 16px; box-shadow: var(--ombre);
  display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; align-items: center; text-decoration: none; color: inherit; }
.indicateur .icone { grid-row: span 2; width: 34px; height: 34px; color: var(--olive); }
.indicateur-titre { font-size: .82rem; font-weight: 700; letter-spacing: .05em; color: var(--encre-douce); }
.indicateur-valeur { font-size: 2rem; font-weight: 800; line-height: 1.1; }
.indicateur-valeur small { font-size: .9rem; font-weight: 600; color: var(--encre-douce); }
.indicateur-detail { grid-column: 2; font-size: .9rem; color: var(--encre-douce); }
.indicateur .barre-niveau { grid-column: 1 / -1; width: 100%; height: 22px; margin-top: 8px; }
.niveau-libelle { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: 1rem; }
.pastille { width: 14px; height: 14px; border-radius: 50%; display: inline-block; flex: none; }
.n-normal { background: #4E7A3A; } .n-vigilance { background: var(--ocre); } .n-organiser { background: var(--terracotta); }
.n-urgence { background: var(--rouge); } .n-saturation { background: #8E2424; } .n-inconnu { background: #B9B6AA; }

/* ---------- grands boutons ---------- */
.actions-principales { display: grid; gap: 14px; margin: 6px 0 24px; }
.gros-bouton { display: flex; align-items: center; gap: 16px; width: 100%; min-height: 84px; padding: 16px 20px;
  border: 0; border-radius: 18px; font: inherit; font-size: 1.25rem; font-weight: 800; letter-spacing: .03em;
  color: var(--blanc); text-decoration: none; cursor: pointer; box-shadow: 0 3px 0 rgba(0,0,0,.18); text-align: left; }
.gros-bouton .icone { width: 40px; height: 40px; stroke-width: 1.7; }
.gros-bouton:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0,0,0,.18); }
.gros-bouton.olive { background: var(--olive); }
.gros-bouton.terracotta { background: var(--terracotta-fonce); }
.gros-bouton[disabled] { opacity: .65; cursor: wait; }
.gros-bouton.secondaire { background: var(--blanc); color: var(--olive); border: 2px solid var(--olive); box-shadow: none; }

.bouton { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 10px 18px;
  border-radius: 12px; border: 2px solid var(--olive); background: var(--olive); color: var(--blanc); font: inherit;
  font-weight: 700; font-size: 1rem; text-decoration: none; cursor: pointer; }
.bouton.clair { background: var(--blanc); color: var(--olive); }
.bouton.danger { background: var(--blanc); color: var(--rouge); border-color: var(--rouge); }
.bouton.petit { min-height: 40px; padding: 6px 12px; font-size: .9rem; }
.bouton[disabled] { opacity: .6; }
.rangee-boutons { display: flex; flex-wrap: wrap; gap: 10px; margin: 14px 0; }

/* ---------- listes ---------- */
.liste { list-style: none; margin: 0; padding: 0; background: var(--blanc); border-radius: var(--rayon); box-shadow: var(--ombre); }
.liste > li { padding: 12px 16px; border-bottom: 1px solid var(--creme-fonce); }
.liste > li:last-child { border-bottom: 0; }
.ligne-pesee { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; text-decoration: none; color: inherit; }
.ligne-pesee strong { font-size: 1.05rem; }
.ligne-pesee .poids { font-weight: 800; font-size: 1.1rem; text-align: right; white-space: nowrap; }
.ligne-pesee .meta { color: var(--encre-douce); font-size: .88rem; }
.ligne-pesee .droite { text-align: right; }
.annulee { opacity: .55; text-decoration: line-through; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .75rem; font-weight: 700;
  background: var(--sauge-pale); color: var(--olive-fonce); vertical-align: 1px; }
.badge.alerte { background: #FBF3E3; color: #6B4E0E; }
.badge.rouge { background: #FBECEC; color: #8E2424; }
.vide { color: var(--encre-douce); background: var(--blanc); border-radius: var(--rayon); padding: 16px; margin: 0; }

.raccourcis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 26px; }
.raccourci { display: flex; align-items: center; gap: 10px; padding: 14px; min-height: 60px; border-radius: var(--rayon);
  background: var(--blanc); color: var(--encre); text-decoration: none; font-weight: 600; font-size: .98rem;
  border: 1px solid var(--trait); }
.raccourci .icone { color: var(--olive); }

/* ---------- formulaires ---------- */
form { margin: 0; }
.champ { margin: 0 0 20px; border: 0; padding: 0; min-width: 0; }
.champ > legend, .champ > label.titre, .titre-champ { display: block; font-weight: 800; font-size: 1.05rem; margin-bottom: 8px; padding: 0; }
.numero { display: inline-flex; width: 28px; height: 28px; border-radius: 50%; background: var(--olive); color: var(--blanc);
  align-items: center; justify-content: center; font-size: .9rem; margin-right: 8px; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=datetime-local], input[type=email],
input[type=search], select, textarea {
  width: 100%; font: inherit; font-size: 1.1rem; padding: 12px 14px; min-height: 54px; border: 2px solid var(--trait);
  border-radius: 12px; background: var(--blanc); color: var(--encre);
}
textarea { min-height: 96px; }
input:focus, select:focus, textarea:focus { border-color: var(--olive); }
.saisie-poids { display: flex; gap: 10px; align-items: stretch; }
.saisie-poids input { font-size: 2rem; font-weight: 800; min-height: 72px; text-align: right; }
.unite { display: flex; border: 2px solid var(--olive); border-radius: 12px; overflow: hidden; flex: none; }
.unite label { display: flex; align-items: center; justify-content: center; min-width: 58px; font-weight: 800; cursor: pointer;
  font-size: 1.1rem; }
.unite input { position: absolute; opacity: 0; pointer-events: none; }
.unite label:has(input:checked) { background: var(--olive); color: var(--blanc); }
.interpretation { margin-top: 6px; font-weight: 600; color: var(--olive-fonce); min-height: 1.4em; }

.choix-grille { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
label.choix { position: relative; display: flex; align-items: center; min-height: 56px; padding: 10px 14px; border-radius: 12px;
  background: var(--blanc); border: 2px solid var(--trait); font-weight: 650; cursor: pointer; line-height: 1.2; }
label.choix input { position: absolute; opacity: 0; pointer-events: none; }
label.choix:has(input:checked) { border-color: var(--olive); background: var(--sauge-pale); box-shadow: inset 0 0 0 1px var(--olive); }
label.choix:has(input:checked)::after { content: ""; position: absolute; right: 10px; top: 50%; width: 10px; height: 18px;
  border: solid var(--olive); border-width: 0 3px 3px 0; transform: translateY(-65%) rotate(45deg); }
label.choix.discret { font-weight: 500; color: var(--encre-douce); }
.choix-grille[data-filtrable] label.choix[hidden] { display: none; }
.recherche-apporteur { margin-bottom: 10px; }
.nouvel-apporteur { margin-top: 10px; }

details.option { background: var(--blanc); border-radius: 12px; border: 1px solid var(--trait); margin: 0 0 16px; }
details.option > summary { cursor: pointer; padding: 14px 16px; font-weight: 650; color: var(--olive); min-height: 48px;
  list-style: none; display: flex; align-items: center; gap: 8px; }
details.option > summary::-webkit-details-marker { display: none; }
details.option > summary::before { content: "+"; font-weight: 800; width: 1em; }
details.option[open] > summary::before { content: "−"; }
details.option > .contenu { padding: 0 16px 16px; }
.grille-2 { display: grid; grid-template-columns: 1fr; gap: 12px; }
.case { display: flex; gap: 12px; align-items: flex-start; font-weight: 600; cursor: pointer; padding: 6px 0; }
.case input { width: 26px; height: 26px; flex: none; margin-top: 1px; accent-color: var(--olive); }
.ligne-variete { display: grid; grid-template-columns: 1fr 9rem; gap: 8px; margin-bottom: 8px; }
.ligne-variete input { text-align: right; font-weight: 700; }
.etiquette-champ { font-size: .9rem; font-weight: 700; display: block; margin-bottom: 4px; }

/* statut de lecture OCR */
.lu { display: inline-flex; align-items: center; gap: 4px; font-size: .78rem; font-weight: 700; padding: 2px 8px;
  border-radius: 999px; margin-left: 6px; vertical-align: 2px; letter-spacing: 0; }
.lu.sur { background: #EAF2E3; color: var(--olive-fonce); }
.lu.probable { background: #FBF3E3; color: #6B4E0E; }
.lu.conflit, .lu.absent { background: #FBECEC; color: #8E2424; }
.suggestion { font-size: .92rem; margin-top: 6px; }
.photo-ticket { display: block; width: 100%; max-height: 60vh; object-fit: contain; background: var(--creme-fonce); border-radius: 12px; }

/* ---------- confirmation ---------- */
.confirmation { background: var(--blanc); border-radius: 20px; padding: 26px 20px; text-align: center; box-shadow: var(--ombre);
  border-top: 8px solid var(--olive); }
.confirmation .coche { width: 72px; height: 72px; color: var(--olive); stroke-width: 2.2; }
.confirmation h1 { margin: 10px 0 6px; font-size: 1.7rem; }
.confirmation .poids-grand { font-size: 2.4rem; font-weight: 800; margin: 8px 0 2px; }
.confirmation dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; text-align: left; margin: 18px auto 0; max-width: 420px; }
.confirmation dt { color: var(--encre-douce); }
.confirmation dd { margin: 0; font-weight: 700; }

/* ---------- cuves ---------- */
.cuves { display: grid; gap: 14px; grid-template-columns: 1fr; }
.cuve { background: var(--blanc); border-radius: var(--rayon); padding: 16px; box-shadow: var(--ombre); display: grid;
  grid-template-columns: 120px 1fr; gap: 14px; align-items: start; }
.cuve h2 { margin: 0 0 6px; font-size: 1.15rem; }
.citerne { width: 120px; height: auto; overflow: visible; }
.citerne .repere { font-size: 13px; fill: var(--encre-douce); }
.citerne .citerne-inconnu { font-size: 40px; font-weight: 800; fill: #B9B6AA; }
.cuve-chiffres { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; font-size: .95rem; margin: 8px 0; }
.cuve-chiffres dt { color: var(--encre-douce); }
.cuve-chiffres dd { margin: 0; font-weight: 700; }
.taux { font-size: 2.2rem; font-weight: 800; line-height: 1; }
.prevision { font-size: .9rem; background: var(--creme); border-radius: 10px; padding: 8px 10px; margin-top: 6px; }

/* ---------- tableaux ---------- */
.tableau-conteneur { background: var(--blanc); border-radius: var(--rayon); box-shadow: var(--ombre); overflow: hidden; }
table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--creme-fonce); vertical-align: top; }
th { font-size: .8rem; color: var(--encre-douce); font-weight: 700; background: #FBFAF6; }
td.nombre, th.nombre { text-align: right; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tfoot td { font-weight: 800; background: #FBFAF6; }
.tableau-defilant { overflow-x: auto; }
.tableau-defilant table { min-width: 520px; }

/* ---------- statistiques ---------- */
.filtres { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.filtres a { padding: 8px 14px; border-radius: 999px; background: var(--blanc); border: 1px solid var(--trait); text-decoration: none;
  color: var(--encre); font-weight: 600; font-size: .92rem; min-height: 40px; display: inline-flex; align-items: center; }
.filtres a[aria-current] { background: var(--olive); color: var(--blanc); border-color: var(--olive); }
.chiffres-cles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 12px 0 8px; }
.chiffre { background: var(--blanc); border-radius: var(--rayon); padding: 12px 14px; box-shadow: var(--ombre); }
.chiffre span { display: block; font-size: .8rem; color: var(--encre-douce); font-weight: 700; }
.chiffre strong { display: block; font-size: 1.45rem; font-weight: 800; }
.carte { background: var(--blanc); border-radius: var(--rayon); padding: 14px 14px 10px; box-shadow: var(--ombre); margin-bottom: 14px; }
.carte h2 { margin-top: 0; font-size: 1.05rem; }
.graphique { width: 100%; height: auto; display: block; }
.graphique .axe { font-size: 12px; fill: var(--encre-douce); }
.graphique .etiquette { font-size: 14px; fill: var(--encre); font-weight: 600; }
.graphique .valeur { font-size: 14px; fill: var(--encre); font-weight: 700; }
details.tableau-detail summary { cursor: pointer; color: var(--olive); font-weight: 600; padding: 8px 0; font-size: .92rem; }
.barre-niveau { display: block; }

/* ---------- administration ---------- */
.tuiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.tuile { display: flex; flex-direction: column; gap: 4px; padding: 14px; min-height: 92px; border-radius: var(--rayon);
  background: var(--blanc); text-decoration: none; color: var(--encre); box-shadow: var(--ombre); font-weight: 700; }
.tuile .icone { color: var(--olive); }
.tuile small { font-weight: 500; color: var(--encre-douce); font-size: .85rem; }
.etat-systeme { list-style: none; padding: 0; margin: 0; }
.etat-systeme li { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--creme-fonce); align-items: center; }
.code-affiche { font: 800 2rem/1.2 ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; letter-spacing: .12em;
  background: var(--blanc); border: 3px dashed var(--olive); border-radius: 14px; padding: 16px; text-align: center; margin: 10px 0; }
.qr svg { width: 220px; height: 220px; background: var(--blanc); padding: 8px; border-radius: 12px; }
.secret { font-family: ui-monospace, Menlo, Consolas, monospace; word-break: break-all; background: var(--blanc); padding: 8px 10px;
  border-radius: 8px; display: inline-block; }
pre.json { white-space: pre-wrap; word-break: break-word; font-size: .78rem; background: var(--creme); padding: 8px; border-radius: 8px;
  max-height: 220px; overflow: auto; margin: 4px 0 0; }
.pagination { display: flex; gap: 10px; justify-content: space-between; margin: 14px 0; }
.pied { text-align: center; color: var(--encre-douce); font-size: .8rem; padding: 10px 0 24px; }

/* ---------- connexion ---------- */
.ecran-connexion { max-width: 440px; margin: 0 auto; }
.ecran-connexion .carte { padding: 20px; }
.code-pin { letter-spacing: .4em; font-size: 1.8rem !important; text-align: center; font-weight: 800; }

/* ---------- attente (lecture du ticket) ---------- */
.attente { display: none; text-align: center; padding: 30px 10px; }
.attente.visible { display: block; }
.roue { width: 54px; height: 54px; border-radius: 50%; border: 6px solid var(--sauge-pale); border-top-color: var(--olive);
  margin: 0 auto 14px; animation: tourne 1s linear infinite; }
@keyframes tourne { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .roue { animation-duration: 3s; } .gros-bouton:active { transform: none; } }

@media (min-width: 620px) {
  .indicateurs { grid-template-columns: 1fr 1fr; }
  .indicateurs .indicateur.large { grid-column: 1 / -1; }
  .actions-principales { grid-template-columns: 1fr 1fr; }
  .raccourcis, .tuiles { grid-template-columns: repeat(4, 1fr); }
  .grille-2 { grid-template-columns: 1fr 1fr; }
  .chiffres-cles { grid-template-columns: repeat(3, 1fr); }
  .cuves { grid-template-columns: 1fr 1fr; }
}
@media print {
  .entete .compte, .raccourcis, .actions-principales, .rangee-boutons, form { display: none !important; }
  body { background: #fff; }
}
.espace-haut { margin-top: 18px; }

.bandeau-alerte form.acquitter { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.bandeau-alerte form.acquitter input { flex: 1 1 220px; min-height: 44px; font-size: 1rem; }
