/* ─── Portail client Nuances Mj — styles (téléphone d'abord ; mêmes standards que l'ERP) ─────────────────────
   Cibles ≥ 44 px, champs en 16 px (iOS ne zoome pas), aucun débordement à 360 px, zones sûres, zoom jamais bloqué.
   Couleurs des statuts (convention de l'ERP) : rouge = en retard · ambre = attend · bleu = en cours · vert = terminé · gris = inactif. */
:root {
  --encre: #141414; --papier: #f6f5f1; --blanc: #fff; --vert: #3c6e4a; --vert-fonce: #2c5338; --vert-pale: #e6efe7;
  --gris: #6b6a63; --gris-pale: #ecebe5; --ligne: #dedbd1; --rouge: #b4382f; --rouge-pale: #f8e4e1; --ambre: #9a6400; --ambre-pale: #fbefd6;
  --bleu: #2f5f8a; --bleu-pale: #e3edf6; --kraft: #c99a5b; --kraft-fonce: #8d6834; --ombre: 0 1px 2px rgba(20, 20, 20, .06), 0 6px 18px rgba(20, 20, 20, .05);
  --rayon: 14px; --barre: 60px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--papier); color: var(--encre); font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; overflow-x: hidden; }
a { color: var(--vert-fonce); }
h1, h2, h3 { line-height: 1.2; margin: 0; }
h1 { font-size: 26px; letter-spacing: -.01em; }
h2 { font-size: 19px; }
h3 { font-size: 16px; }
p { margin: 0; }
button, input, select { font: inherit; }
.evitement { position: absolute; left: -9999px; }
.evitement:focus { left: 12px; top: 12px; z-index: 50; background: var(--blanc); padding: 10px 14px; border-radius: 8px; }
.cache-lecteur { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid #7aa985; outline-offset: 2px; }
.chargement { padding: 48px 16px; text-align: center; color: var(--gris); }

/* ── Barre ── */
.barre { position: sticky; top: 0; z-index: 10; background: rgba(246, 245, 241, .94); backdrop-filter: saturate(1.4) blur(8px); border-bottom: 1px solid var(--ligne);
  padding: env(safe-area-inset-top) max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left)); }
.barre-haut { display: flex; align-items: center; gap: 12px; min-height: var(--barre); max-width: 1180px; margin: 0 auto; }
.logo { height: 34px; width: auto; display: block; }
.barre-client { flex: 1; min-width: 0; border-left: 1px solid var(--ligne); padding-left: 12px; }
.barre-client .sur { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--gris); }
.barre-client .nom { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.barre-actions { display: flex; gap: 6px; align-items: center; }
.nav { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; max-width: 1180px; margin: 0 auto; -webkit-overflow-scrolling: touch; }
.nav::-webkit-scrollbar { display: none; }
.nav a { flex: none; display: inline-flex; align-items: center; min-height: 44px; padding: 0 14px; color: var(--gris); text-decoration: none; font-weight: 600; border-bottom: 3px solid transparent; white-space: nowrap; }
.nav a[aria-current="page"] { color: var(--vert-fonce); border-bottom-color: var(--vert); }

/* ── Mise en page ── */
main { max-width: 1180px; margin: 0 auto; padding: 20px max(16px, env(safe-area-inset-right)) calc(40px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); display: grid; gap: 18px; }
.entete { display: grid; gap: 4px; }
.entete .sur { font-size: 13px; color: var(--gris); }
.grille { display: grid; gap: 18px; grid-template-columns: 1fr; }
@media (min-width: 900px) { .grille.deux { grid-template-columns: 1fr 1fr; } }
.carte { background: var(--blanc); border: 1px solid var(--ligne); border-radius: var(--rayon); box-shadow: var(--ombre); padding: 16px; min-width: 0; }
.carte > h2 { margin-bottom: 12px; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.carte > h2 a { font-size: 14px; font-weight: 600; }
.liste { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.item { display: block; border: 1px solid var(--ligne); border-radius: 12px; padding: 12px; color: inherit; text-decoration: none; background: var(--blanc); min-width: 0; }
a.item:hover { border-color: #b9c9bd; background: #fbfcfa; }
.item-haut { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; flex-wrap: wrap; }
.item-titre { font-weight: 650; min-width: 0; overflow-wrap: anywhere; }
.item-sous { font-size: 14px; color: var(--gris); overflow-wrap: anywhere; }
.faits { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px 16px; margin: 10px 0 0; }
.faits div { min-width: 0; }
.faits dt { font-size: 12px; color: var(--gris); text-transform: uppercase; letter-spacing: .04em; }
.faits dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.vide { color: var(--gris); padding: 8px 0; }
.note { font-size: 13px; color: var(--gris); }
.groupe-commande { display: grid; gap: 10px; }
.groupe-commande + .groupe-commande { margin-top: 18px; padding-top: 16px; border-top: 1px dashed var(--ligne); }

/* ── Pastilles d'état ── */
.pastilles { display: flex; gap: 6px; flex-wrap: wrap; }
.ton { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 3px 10px; font-size: 13px; font-weight: 650; white-space: normal; line-height: 1.3; }
.ton::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.ton.vert { background: var(--vert-pale); color: var(--vert-fonce); }
.ton.bleu { background: var(--bleu-pale); color: var(--bleu); }
.ton.ambre { background: var(--ambre-pale); color: var(--ambre); }
.ton.rouge { background: var(--rouge-pale); color: var(--rouge); }
.ton.gris { background: var(--gris-pale); color: var(--gris); }

/* ── Boutons et champs ── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; min-width: 44px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--ligne);
  background: var(--blanc); color: var(--encre); font-weight: 650; cursor: pointer; text-decoration: none; }
.btn:hover { border-color: #b8b4a6; }
.btn-primaire { background: var(--vert); border-color: var(--vert); color: #fff; }
.btn-primaire:hover { background: var(--vert-fonce); border-color: var(--vert-fonce); }
.btn-discret { border-color: transparent; background: transparent; color: var(--gris); }
.btn[disabled] { opacity: .6; cursor: progress; }
.filtres { display: flex; gap: 6px; flex-wrap: wrap; }
.filtres .btn[aria-pressed="true"] { background: var(--vert-pale); border-color: #b9d0bd; color: var(--vert-fonce); }
form.pile, .pile { display: grid; gap: 14px; }
label.champ { display: grid; gap: 6px; font-weight: 600; font-size: 15px; }
.champ input { width: 100%; min-height: 48px; border: 1px solid #cfcabd; border-radius: 10px; padding: 10px 12px; font-size: 16px; background: var(--blanc); color: var(--encre); }
.champ input:focus { border-color: var(--vert); outline: 3px solid #cfe1d3; outline-offset: 0; }
.champ-code input { font-size: 24px; letter-spacing: .3em; text-align: center; font-variant-numeric: tabular-nums; }
.erreur { background: var(--rouge-pale); color: var(--rouge); border-radius: 10px; padding: 10px 12px; font-weight: 600; }
.succes { background: var(--vert-pale); color: var(--vert-fonce); border-radius: 10px; padding: 10px 12px; font-weight: 600; }

/* ── Écrans d'entrée (connexion, invitation) ── */
.porte { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: max(24px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom)); }
.porte-carte { width: 100%; max-width: 420px; background: var(--blanc); border: 1px solid var(--ligne); border-radius: 18px; box-shadow: var(--ombre); padding: 26px 22px; display: grid; gap: 18px; }
.porte-tete { display: grid; gap: 10px; justify-items: start; }
.porte-tete .logo { height: 44px; }
.porte-tete p { color: var(--gris); }
.porte-pied { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.qr { width: 196px; height: 196px; image-rendering: pixelated; border: 1px solid var(--ligne); border-radius: 10px; justify-self: center; background: #fff; }
.cle { font-family: ui-monospace, Consolas, monospace; font-size: 15px; background: var(--gris-pale); border-radius: 8px; padding: 8px 10px; overflow-wrap: anywhere; user-select: all; }
.codes { font-family: ui-monospace, Consolas, monospace; font-size: 17px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 14px; background: var(--gris-pale); padding: 12px; border-radius: 10px; }
.choix { display: grid; gap: 8px; }
.choix label { display: flex; gap: 10px; align-items: center; min-height: 48px; border: 1px solid var(--ligne); border-radius: 10px; padding: 8px 12px; cursor: pointer; }
.choix input { width: 22px; height: 22px; accent-color: var(--vert); }

/* ── Mon cannabis ── */
.total { font-size: 34px; font-weight: 750; letter-spacing: -.02em; color: var(--vert-fonce); }
.barres { display: grid; gap: 8px; }
.barre-cat { display: grid; grid-template-columns: minmax(0, 9em) 1fr auto; gap: 10px; align-items: center; font-size: 14px; }
.barre-cat .piste { height: 10px; border-radius: 99px; background: var(--gris-pale); overflow: hidden; }
.barre-cat .rempli { display: block; height: 100%; width: var(--part, 0%); background: var(--vert); border-radius: 99px; transition: width .8s ease; }
.zones { display: flex; height: 12px; border-radius: 99px; overflow: hidden; background: var(--gris-pale); margin: 10px 0 6px; }
.zones span { display: block; width: var(--part, 0%); }
.zone-voute { background: var(--vert); } .zone-production { background: var(--bleu); } .zone-quarantaine { background: #d9a43a; }
.zone-entrepot { background: #8a9a8e; } .zone-autre { background: #b9b4a6; } .zone-non_precisee { background: #dcd8cc; }
.legende { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px; color: var(--gris); }
.legende i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

/* ── Tableau léger (connexions) → cartes au téléphone ── */
.tableau { width: 100%; border-collapse: collapse; font-size: 14px; }
.tableau th { text-align: left; color: var(--gris); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; padding: 8px 6px; border-bottom: 1px solid var(--ligne); }
.tableau td { padding: 9px 6px; border-bottom: 1px solid var(--gris-pale); overflow-wrap: anywhere; }
@media (max-width: 600px) {
  .tableau thead { display: none; }
  .tableau tr { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 8px 0; border-bottom: 1px solid var(--gris-pale); }
  .tableau td { border: 0; padding: 0; }
  .tableau td:last-child { grid-column: 1 / -1; color: var(--gris); font-size: 13px; }
  h1 { font-size: 22px; }
  .barre-client .sur { display: none; }
  .logo { height: 28px; }
  .carte { padding: 14px; }
}

/* ── Ligne de production animée ── */
.ligne { margin: 10px 0 0; }
.ligne-svg { display: block; width: 100%; height: auto; overflow: visible; }
.ligne-texte { font-size: 14px; font-weight: 600; color: var(--vert-fonce); margin-top: 2px; }
.ligne.attente .ligne-texte { color: var(--ambre); }
.ligne-titre { display: grid; gap: 2px; margin-bottom: 12px; }
.ligne-sur { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--gris); }
.ligne-titre strong { font-size: 18px; }
.ligne-grande .horizontale { display: block; max-width: 980px; }
.ligne-grande .verticale { display: none; max-width: 380px; }
@media (max-width: 640px) { .ligne-grande .horizontale { display: none; } .ligne-grande .verticale { display: block; } }
.rail { stroke: var(--ligne); stroke-width: 3; stroke-linecap: round; }
.rail-fait { stroke: var(--vert); stroke-width: 3; stroke-linecap: round; transition: stroke-dashoffset var(--duree, 1.4s) cubic-bezier(.45, .05, .25, 1); }
.rail-fait.epais { stroke-width: 5; }
.convoyeur { fill: #e7e3d8; stroke: #d5d0c2; }
.rouleau circle { fill: #f6f4ee; stroke: #cbc5b5; }
.rouleau line { stroke: #b8b1a0; stroke-width: 1.4; }
.rouleau { transform-box: fill-box; transform-origin: center; }
.ligne.en-route:not(.arrivee) .rouleau { animation: tourne .5s linear infinite; }
@keyframes tourne { to { transform: rotate(360deg); } }
.station .pastille { fill: var(--blanc); stroke: #cbc5b5; stroke-width: 2; }
.station.franchie .pastille { fill: var(--vert); stroke: var(--vert); }
.station.actuelle .pastille { fill: var(--blanc); stroke: var(--vert); stroke-width: 3; }
.ligne.attente .station.actuelle .pastille { stroke: var(--ambre); }
.ligne-mini .station.actuelle .pastille { fill: var(--vert); }
.ligne-mini.attente .station.actuelle .pastille { fill: var(--ambre); }
.station .numero { font-size: 14px; font-weight: 700; fill: #a7a192; text-anchor: middle; }
.station.actuelle .numero { fill: var(--vert-fonce); }
.station .coche { fill: none; stroke: #fff; stroke-width: 3.2; stroke-linecap: round; stroke-linejoin: round; }
.station .etiquette { font-size: 14px; font-weight: 600; fill: var(--gris); text-anchor: middle; }
.station.actuelle .etiquette { fill: var(--encre); font-weight: 750; }
.station.franchie .etiquette { fill: var(--vert-fonce); }
.station .date { font-size: 12.5px; fill: var(--gris); text-anchor: middle; }
.station .sous { font-size: 13px; font-style: italic; fill: var(--vert-fonce); text-anchor: middle; font-weight: 600; }
.ligne.attente .station .sous { fill: var(--ambre); }
.station .gauche { text-anchor: start; }
.verticale .station .etiquette { font-size: 16px; }
.verticale .station .date { font-size: 13.5px; }
.pulse { fill: none; stroke: var(--vert); stroke-width: 2; opacity: 0; transform-box: fill-box; transform-origin: center; }
.ligne.attente .pulse { stroke: var(--ambre); }
.ligne.arrivee .pulse { animation: pulse 2.4s ease-out infinite; }
@keyframes pulse { 0% { opacity: .55; transform: scale(1); } 80%, 100% { opacity: 0; transform: scale(1.7); } }
/* Les étapes franchies s'allument au passage de la caisse. */
.ligne.en-route .station.franchie .pastille, .ligne.en-route .station.franchie .coche { animation: allume .35s ease-out both; animation-delay: calc(var(--i) * var(--pas, 200ms) + var(--pas, 200ms) * .6); }
@keyframes allume { from { fill: var(--blanc); stroke: #cbc5b5; stroke-opacity: .2; } }
.chariot { transition: none; }
.ligne.en-route .chariot { transition: transform var(--duree, 1.4s) cubic-bezier(.45, .05, .25, 1); }
.caisse-corps { fill: var(--kraft); stroke: var(--kraft-fonce); stroke-width: 1.2; }
.caisse-pli { stroke: var(--kraft-fonce); stroke-width: 1; opacity: .6; }
.caisse-ruban { fill: #e8d3a8; opacity: .9; }
.caisse-etiquette { fill: #fff; opacity: .9; }
.ligne.arrivee .caisse { animation: pose .45s ease-out 1; transform-box: fill-box; transform-origin: center bottom; }
@keyframes pose { 0% { transform: scaleY(.92); } 60% { transform: scaleY(1.04); } 100% { transform: scaleY(1); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
@media print {
  .barre, .nav, .btn { display: none !important; }
  body { background: #fff; }
  .carte { box-shadow: none; }
}
.retour { justify-self: start; padding-left: 4px; }
.ligne-mini .ligne-svg { max-width: 440px; }
/* Cibles tactiles ≥ 44 px sans changer la mise en page (logo, « Tout voir »). */
.barre-haut > a { display: inline-flex; align-items: center; min-height: 44px; }
.carte > h2 a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 6px; margin: -13px -6px; }
/* Téléphone : le nom du client passe sous le logo (jamais réduit à « D. »). */
@media (max-width: 600px) {
  .barre-haut { flex-wrap: wrap; row-gap: 0; }
  .barre-haut > a { flex: 1; }
  .barre-client { order: 3; flex-basis: 100%; border-left: 0; padding: 0 0 4px; }
  .barre-client .nom { font-size: 14px; }
}

/* ── Jalons de livraison (bientôt prête / prête / retardée) ── */
.jalon { border-radius: 12px; padding: 12px 14px; display: grid; gap: 4px; border: 1px solid transparent; min-width: 0; overflow-wrap: anywhere; }
.jalon + .jalon { margin-top: 10px; }
.item .jalon { margin-top: 10px; }
.jalon-titre { font-weight: 700; font-size: 16px; }
.jalon-detail { font-size: 14px; }
.jalon-bientot_prete { background: var(--bleu-pale); color: var(--bleu); border-color: #c9d9ee; }
.jalon-prete { background: var(--vert-pale); color: var(--vert-fonce); border-color: #b9d0bd; }
.jalon-retardee { background: var(--rouge-pale); color: var(--rouge); border-color: #efc2bd; }
.carte-jalons { border-left: 4px solid var(--vert); }

/* ── Section B2B : demandes et leur suivi animé (suivi.js) ── */
.champ textarea { width: 100%; min-height: 160px; border: 1px solid #cfcabd; border-radius: 10px; padding: 10px 12px; font: inherit; font-size: 16px; background: var(--blanc); color: var(--encre); resize: vertical; }
.champ textarea:focus { border-color: var(--vert); outline: 3px solid #cfe1d3; outline-offset: 0; }
.intro { margin: 4px 0 12px; max-width: 70ch; }
.texte-libre { white-space: pre-wrap; overflow-wrap: anywhere; }
.reponse { border-left: 4px solid var(--bleu); }
.reponse.acceptee { border-left-color: var(--vert); }
.reponse.refusee { border-left-color: var(--rouge); }
.suivi { margin: 10px 0 0; }
.suivi-rail { position: relative; height: 22px; margin: 0 11px; }
.suivi-grande .suivi-rail { height: 56px; margin: 6px 40px 0; }
.suivi-piste, .suivi-rempli { position: absolute; top: 9px; left: 0; height: 4px; border-radius: 2px; }
.suivi-piste { right: 0; background: var(--gris-pale); }
.suivi-rempli { width: var(--fin, 0%); background: var(--vert); transition: width 1.1s cubic-bezier(.3, .7, .2, 1); }
.suivi-station { position: absolute; top: 0; left: var(--x); transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 4px; }
.suivi-pastille { width: 22px; height: 22px; border-radius: 50%; background: var(--blanc); border: 3px solid #cbc5b5; box-sizing: border-box; transition: background .3s .8s, border-color .3s .8s; }
.suivi-station.faite .suivi-pastille { background: var(--vert); border-color: var(--vert); }
.suivi-station.actuelle .suivi-pastille { border-color: var(--vert); background: var(--vert-pale); position: relative; }
.suivi-station.actuelle .suivi-pastille::after { content: ""; position: absolute; inset: -3px; border-radius: 50%; border: 3px solid var(--vert); animation: pulse 2s ease-out 1.2s infinite; }
.suivi-station.actuelle.acceptee .suivi-pastille { background: var(--vert); }
.suivi-station.actuelle.refusee .suivi-pastille { background: var(--rouge-pale); border-color: var(--rouge); }
.suivi-station.actuelle.acceptee .suivi-pastille::after, .suivi-station.actuelle.refusee .suivi-pastille::after { animation: none; border-color: transparent; }
.suivi-nom { font-size: 12px; color: var(--gris); white-space: nowrap; }
.suivi-station.actuelle .suivi-nom { color: var(--encre); font-weight: 650; }
.suivi-enveloppe { position: absolute; top: -9px; left: var(--fin, 0%); width: 18px; height: 13px; margin-left: -9px; border-radius: 2px; background: var(--kraft); box-shadow: inset 0 -5px 0 var(--kraft-fonce); transition: left 1.1s cubic-bezier(.3, .7, .2, 1); }
.suivi-texte { font-size: 13px; color: var(--gris); margin-top: 6px; }
.suivi-grande .suivi-texte { margin-top: 2px; font-size: 15px; color: var(--encre); }
@media (max-width: 560px) { .suivi-grande .suivi-rail { margin: 6px 26px 0; } .suivi-nom { font-size: 11px; white-space: normal; text-align: center; max-width: 74px; } }
@media (prefers-reduced-motion: reduce) { .suivi-rempli, .suivi-enveloppe, .suivi-pastille { transition: none; } .suivi-station.actuelle .suivi-pastille::after { animation: none; } }
.faits + h2 { margin-top: 14px; }
.suivi-long.suivi-grande .suivi-station:not(.actuelle) .suivi-nom { display: none; }
@media (min-width: 900px) { .suivi-long.suivi-grande .suivi-station:not(.actuelle) .suivi-nom { display: block; max-width: 90px; white-space: normal; text-align: center; } }

/* ── Section B2B (B2B-1b) : formulaires publiés, commentaires, documents, soumission ── */
.fiche { display: grid; gap: 18px; min-width: 0; }
.groupe-champ { display: grid; gap: 6px; min-width: 0; }
.champ select { width: 100%; min-height: 48px; border: 1px solid #cfcabd; border-radius: 10px; padding: 10px 12px; font-size: 16px; background: var(--blanc); color: var(--encre); }
.champ select:focus { border-color: var(--vert); outline: 3px solid #cfe1d3; outline-offset: 0; }
.champ input[type="file"] { padding: 9px 10px; font-size: 15px; }
.champ textarea.court { min-height: 96px; }
.champ-case { display: flex; gap: 10px; align-items: flex-start; min-height: 44px; padding: 8px 0; font-weight: 600; font-size: 15px; cursor: pointer; }
.champ-case input { width: 24px; height: 24px; flex: none; margin: 0; accent-color: var(--vert); }
.etoile { color: var(--rouge); }
.erreur-champ { color: var(--rouge); font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
.erreur-champ:empty { display: none; }
.champ [aria-invalid="true"], .champ-case [aria-invalid="true"] { border-color: var(--rouge); }
.champ [aria-invalid="true"]:focus { outline-color: var(--rouge-pale); }
.attendu { background: var(--ambre-pale); color: var(--ambre); border-radius: 10px; padding: 10px 12px; font-weight: 600; margin-bottom: 12px; }
.carte > .liste + * { margin-top: 14px; }
.carte > .vide + * { margin-top: 6px; }
.carte > .succes { margin-top: 14px; }
.soumission { margin-top: 18px; padding-top: 16px; border-top: 1px dashed var(--ligne); }
.btn.inactif[disabled] { cursor: not-allowed; }
.carte > .succes + * { margin-top: 14px; }
