:root {
  --fond: #f6f7f9;
  --carte: #ffffff;
  --texte: #111827;
  --texte-2: #4b5563;
  --texte-3: #6b7280;
  --bord: #e5e7eb;
  --bord-2: #d1d5db;
  --accent: #1d4ed8;
  --accent-fonce: #1e40af;
  --ok-fond: #ecfdf5; --ok-bord: #a7f3d0; --ok-texte: #065f46;
  --att-fond: #fef3c7; --att-texte: #92400e;
  --err-fond: #fee2e2; --err-texte: #991b1b;
  --info-fond: #eff6ff; --info-bord: #bfdbfe; --info-texte: #1e3a8a;
  --rayon: 12px;
  --haut: env(safe-area-inset-top, 0px);
  --bas: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Arial, sans-serif;
  background: var(--fond); color: var(--texte); font-size: 16px; line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.ecran { position: fixed; inset: 0; display: flex; flex-direction: column; overflow: hidden; }
.entete {
  padding: calc(var(--haut) + 12px) 12px 12px; background: var(--carte); border-bottom: 1px solid var(--bord);
  display: flex; align-items: center; gap: 4px; min-height: 60px;
}
.entete h1 { margin: 0; font-size: 17px; font-weight: 600; flex: 1; }
.entete .gros { font-size: 26px; font-weight: 700; padding-left: 8px; }
.icone-btn {
  width: 44px; height: 44px; border: none; background: transparent; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center; color: inherit; flex-shrink: 0;
}
.icone-btn:hover { background: rgba(0,0,0,.05); }
.corps { flex: 1; overflow-y: auto; padding: 16px 20px 24px; display: flex; flex-direction: column; gap: 16px; -webkit-overflow-scrolling: touch; }
.pied { padding: 12px 20px calc(var(--bas) + 16px); background: var(--carte); border-top: 1px solid var(--bord); display: flex; flex-direction: column; gap: 8px; }

.btn {
  height: 52px; border-radius: var(--rayon); border: none; background: var(--accent); color: #fff;
  font-size: 16px; font-weight: 600; display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  text-decoration: none;
}
.btn:hover { background: var(--accent-fonce); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-second { background: var(--carte); color: var(--texte); border: 1.5px solid var(--bord-2); height: 48px; }
.btn-second:hover { background: #f9fafb; }
.btn-lien { border: none; background: none; color: var(--accent); font-weight: 600; font-size: 14px; padding: 8px 0; text-align: left; }

.champ { display: flex; flex-direction: column; gap: 8px; }
.champ label { font-size: 14px; font-weight: 600; }
.input {
  height: 52px; border: 1px solid var(--bord-2); border-radius: var(--rayon); padding: 0 16px; font-size: 16px;
  background: var(--carte); width: 100%;
}
.input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
textarea.input { height: 84px; padding: 12px 14px; resize: none; font-size: 15px; }
.aide { font-size: 13px; color: var(--texte-2); }

.carte { background: var(--carte); border: 1px solid var(--bord); border-radius: 14px; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.bandeau { border-radius: var(--rayon); padding: 12px 14px; display: flex; gap: 10px; align-items: flex-start; font-size: 14px; }
.bandeau strong { display: block; font-size: 14px; }
.bandeau.ok { background: var(--ok-fond); border: 1px solid var(--ok-bord); color: var(--ok-texte); }
.bandeau.att { background: var(--att-fond); border: 1px solid #fcd34d; color: var(--att-texte); }
.bandeau.err { background: var(--err-fond); border: 1px solid #fca5a5; color: var(--err-texte); }
.bandeau.info { background: var(--info-fond); border: 1px solid var(--info-bord); color: var(--info-texte); }
.bandeau svg { flex-shrink: 0; margin-top: 1px; }

.titre-section { margin: 0; font-size: 15px; font-weight: 600; }
.surtitre { margin: 0; font-size: 13px; font-weight: 600; color: var(--texte-2); text-transform: uppercase; letter-spacing: .06em; }

/* Connexion */
#ecran-connexion .corps { padding-top: calc(var(--haut) + 56px); justify-content: flex-start; max-width: 460px; margin: 0 auto; width: 100%; }
.logo { width: 72px; height: 72px; border-radius: 18px; background: var(--accent); display: flex; align-items: center; justify-content: center; margin: 0 auto; }
.marque { font-size: 13px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--texte-2); text-align: center; }
.titre-accueil { margin: 0; font-size: 28px; font-weight: 700; text-align: center; line-height: 1.2; }
.sous-titre { margin: 0; font-size: 15px; color: var(--texte-2); text-align: center; }
.code-input { letter-spacing: .5em; font-size: 24px; font-weight: 700; text-align: center; }

/* Scan */
#ecran-scan { background: #0b0f19; color: #fff; }
#ecran-scan .entete { background: transparent; border: none; justify-content: space-between; }
#ecran-scan .entete h1 { text-align: center; }
.onglets { margin: 4px 20px 0; display: flex; background: #1f2937; border-radius: 12px; padding: 4px; }
.onglets button { flex: 1; height: 40px; border: none; border-radius: 9px; font-size: 14px; font-weight: 600; background: transparent; color: #d1d5db; }
.onglets button[aria-selected="true"] { background: #fff; color: var(--texte); }
.consigne { margin: 14px 28px 0; font-size: 15px; text-align: center; color: #e5e7eb; min-height: 44px; }
.zone-video { flex: 1; position: relative; margin: 12px 20px; border-radius: 18px; overflow: hidden; background: #111827; min-height: 200px; }
.zone-video video { width: 100%; height: 100%; object-fit: cover; display: block; }
.cadre { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 78%; height: 46%; pointer-events: none; transition: height .2s; }
.cadre.texte { height: 30%; }
.cadre span { position: absolute; width: 34px; height: 34px; border: 4px solid #60a5fa; }
.cadre span:nth-child(1) { top: 0; left: 0; border-right: none; border-bottom: none; border-top-left-radius: 14px; }
.cadre span:nth-child(2) { top: 0; right: 0; border-left: none; border-bottom: none; border-top-right-radius: 14px; }
.cadre span:nth-child(3) { bottom: 0; left: 0; border-right: none; border-top: none; border-bottom-left-radius: 14px; }
.cadre span:nth-child(4) { bottom: 0; right: 0; border-left: none; border-top: none; border-bottom-right-radius: 14px; }
.camera-msg { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; padding: 24px; font-size: 15px; color: #d1d5db; }
.puce {
  align-self: center; display: inline-flex; align-items: center; gap: 8px; border-radius: 20px; padding: 8px 14px;
  font-size: 14px; font-weight: 600; background: rgba(16,185,129,.18); border: 1px solid #10b981; color: #a7f3d0; min-height: 38px;
}
.puce.attente { background: rgba(96,165,250,.15); border-color: #60a5fa; color: #dbeafe; }
.puce.erreur { background: rgba(248,113,113,.15); border-color: #f87171; color: #fecaca; }
.commandes { padding: 12px 32px 12px; display: flex; align-items: center; justify-content: space-between; }
.declencheur { width: 80px; height: 80px; border-radius: 40px; border: 4px solid #fff; background: transparent; display: flex; align-items: center; justify-content: center; padding: 0; }
.declencheur span { width: 62px; height: 62px; border-radius: 31px; background: #fff; }
.declencheur:disabled { opacity: .5; }
.btn-sombre { width: 52px; height: 52px; border-radius: 12px; border: 1.5px solid #4b5563; background: #111827; color: #fff; display: flex; align-items: center; justify-content: center; }
.btn-panier { margin: 0 20px 10px; height: 48px; border-radius: 12px; border: none; background: #fff; color: var(--accent); font-size: 15px; font-weight: 700; display: flex; align-items: center; justify-content: center; gap: 10px; }
.btn-saisie { margin: 0 20px calc(var(--bas) + 20px); height: 48px; border-radius: 12px; border: 1.5px solid #4b5563; background: transparent; color: #fff; font-size: 15px; font-weight: 600; display: flex; align-items: center; justify-content: center; gap: 10px; }

/* Listes d'articles */
.article-choix {
  min-height: 64px; padding: 12px 14px; border-radius: var(--rayon); background: var(--carte); border: 1px solid var(--bord);
  display: flex; align-items: center; justify-content: space-between; gap: 12px; text-align: left; width: 100%;
}
.article-choix:hover { border-color: var(--accent); }
.article-choix .ref { font-size: 15px; font-weight: 600; display: block; }
.article-choix .lib { font-size: 13px; color: var(--texte-2); display: block; }
.badge-achete { font-size: 11px; font-weight: 600; color: var(--ok-texte); background: var(--ok-fond); border-radius: 10px; padding: 2px 8px; margin-left: 6px; }

/* Demande */
.article-entete { display: flex; gap: 14px; align-items: center; }
.vignette { width: 72px; height: 72px; flex-shrink: 0; border-radius: 10px; background: var(--bord); object-fit: cover; display: flex; align-items: center; justify-content: center; font-size: 11px; color: var(--texte-2); text-align: center; }
.article-entete .nom { font-size: 16px; font-weight: 600; }
.article-entete .ref { font-size: 14px; color: var(--texte-2); }
.quantite { display: flex; align-items: center; gap: 12px; }
.quantite button { width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--bord-2); background: var(--carte); font-size: 22px; }
.quantite button:disabled { opacity: .4; }
.quantite output { min-width: 32px; text-align: center; font-size: 20px; font-weight: 600; }
.pastilles { display: flex; flex-wrap: wrap; gap: 8px; }
.pastilles button { min-height: 40px; padding: 8px 14px; border-radius: 20px; font-size: 14px; font-weight: 500; background: var(--carte); color: #374151; border: 1px solid var(--bord-2); }
.pastilles button[aria-pressed="true"] { background: var(--accent); color: #fff; border-color: var(--accent); }
.photos { display: flex; gap: 10px; flex-wrap: wrap; }
.photos img { width: 76px; height: 76px; border-radius: 12px; object-fit: cover; }
.ajout-photo { width: 76px; height: 76px; border-radius: 12px; border: 1.5px dashed #9ca3af; background: var(--carte); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: var(--accent); font-size: 12px; font-weight: 600; }

/* Ma demande */
.ligne-panier { display: flex; gap: 12px; align-items: flex-start; }
.ligne-panier .vignette { width: 56px; height: 56px; }
.ligne-panier .infos { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ligne-panier .nom { font-size: 15px; font-weight: 600; }
.ligne-panier .det { font-size: 13px; color: var(--texte-2); }
.ligne-panier .actions { display: flex; gap: 16px; margin-top: 4px; }
.ligne-panier .actions button { border: none; background: none; padding: 6px 0; font-size: 14px; font-weight: 600; color: var(--accent); }
.ligne-panier .actions button.retirer { color: #b91c1c; }
.pastille-hd { display: inline-block; font-size: 11px; font-weight: 600; background: var(--att-fond); color: var(--att-texte); border-radius: 10px; padding: 2px 8px; margin-left: 6px; }
.articles-suivi { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--texte-2); }
.articles-suivi b { color: var(--texte); font-weight: 600; }

/* Refus */
.refus { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 24px 8px 8px; text-align: center; }
.refus .rond { width: 64px; height: 64px; border-radius: 32px; background: var(--att-fond); display: flex; align-items: center; justify-content: center; }
.refus h2 { margin: 0; font-size: 22px; }
.refus p { margin: 0; font-size: 15px; color: var(--texte-2); }

/* Suivi */
.retour-ligne { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.retour-ligne .num { font-size: 15px; font-weight: 600; }
.retour-ligne .det { font-size: 13px; color: var(--texte-2); }
.statut { font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 12px; white-space: nowrap; }
.retour-ligne > div { flex: 1; min-width: 0; }
.retour-ligne .statut { white-space: normal; text-align: center; max-width: 48%; flex-shrink: 0; }
.statut.e1 { background: var(--att-fond); color: var(--att-texte); }
.statut.e2 { background: #dbeafe; color: var(--accent-fonce); }
.statut.e3 { background: #e0e7ff; color: #3730a3; }
.statut.e4 { background: #d1fae5; color: var(--ok-texte); }
.statut.e-1 { background: var(--err-fond); color: var(--err-texte); }
.etapes { display: flex; gap: 6px; }
.etapes span { flex: 1; height: 4px; border-radius: 2px; background: var(--bord); }
.etapes span.fait { background: var(--accent); }
.vide { text-align: center; color: var(--texte-2); font-size: 15px; padding: 32px 12px; }

.nav { height: calc(68px + var(--bas)); padding-bottom: var(--bas); background: var(--carte); border-top: 1px solid var(--bord); display: flex; }
.nav button { flex: 1; border: none; background: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 12px; font-weight: 500; color: var(--texte-2); }
.nav button[aria-current="page"] { color: var(--accent); font-weight: 600; }

.chargement { position: fixed; inset: 0; background: rgba(17,24,39,.45); display: flex; align-items: center; justify-content: center; z-index: 50; }
.chargement div { background: #fff; border-radius: 14px; padding: 20px 24px; font-weight: 600; display: flex; align-items: center; gap: 12px; max-width: 80%; }
.roue { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--bord); border-top-color: var(--accent); animation: tourne .8s linear infinite; flex-shrink: 0; }
@keyframes tourne { to { transform: rotate(360deg); } }
.toast { position: fixed; left: 16px; right: 16px; bottom: calc(var(--bas) + 90px); background: #111827; color: #fff; padding: 12px 16px; border-radius: 12px; font-size: 14px; z-index: 60; text-align: center; }

@media (min-width: 640px) {
  .ecran:not(#ecran-scan) .corps, .ecran:not(#ecran-scan) .pied { width: 100%; max-width: 560px; margin-left: auto; margin-right: auto; }
}
