:root {
  --fond: #f4f6f5; --carte: #ffffff; --texte: #111; --doux: #555; --bord: #cfd6d2;
  --vert: #0f7a43; --vert-f: #0b5d33; --orange: #c25e00; --rouge: #b42318; --bleu: #1d4ed8;
  --sel: #0f7a43;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--fond); color: var(--texte);
  font: 17px/1.3 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
main { max-width: 560px; margin: 0 auto; padding: 8px 12px calc(12px + env(safe-area-inset-bottom)); }
[hidden] { display: none !important; }
h1 { font-size: 1.35rem; margin: 0 0 4px; }
h2 { font-size: 1rem; text-transform: uppercase; letter-spacing: .04em; color: var(--doux); margin: 14px 0 8px; }
button { font: inherit; color: inherit; border: 2px solid var(--bord); background: var(--carte);
  border-radius: 12px; cursor: pointer; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
button:active { transform: scale(.97); }
button:disabled { opacity: .45; }
.gros { width: 100%; min-height: 68px; font-size: 1.35rem; font-weight: 800; margin-top: 12px; }
.moyen { min-height: 54px; padding: 0 14px; font-weight: 700; }
.petit { min-height: 40px; padding: 0 12px; font-size: .95rem; }
.large { width: 100%; margin-top: 8px; }
.vert { background: var(--vert); border-color: var(--vert-f); color: #fff; }
.orange { background: var(--orange); border-color: var(--orange); color: #fff; }
.alerte { background: #fff4e5; border-left: 5px solid var(--orange); padding: 10px 12px; border-radius: 8px; margin: 10px 0; }
.aide { color: var(--doux); text-align: center; margin: 6px 0; }
.code { font-family: ui-monospace, Menlo, monospace; color: var(--doux); }
.haut { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.retour { min-height: 46px; padding: 0 14px; font-weight: 700; }
.resume { color: var(--doux); font-size: .95rem; text-align: right; }

/* Scanner */
.cam { position: relative; background: #000; border-radius: 14px; overflow: hidden; aspect-ratio: 4 / 3; }
.cam video { width: 100%; height: 100%; object-fit: cover; display: block; }
.viseur { position: absolute; inset: 22% 8%; border: 3px solid rgba(255,255,255,.85); border-radius: 10px; pointer-events: none; }
.viseur span { position: absolute; left: 4%; right: 4%; top: 50%; height: 2px; background: #ff3b30; }
.cam.lu .viseur { border-color: #34c759; }
.cam-voile { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; padding: 16px; background: rgba(0,0,0,.72); color: #fff; text-align: center; }
.cam-voile .gros { max-width: 320px; }
.barre { display: flex; gap: 10px; margin-top: 10px; }
.barre button { flex: 1; }
.badge { display: inline-block; min-width: 26px; padding: 2px 8px; border-radius: 13px; background: var(--rouge); color: #fff; font-size: .9rem; }
.bandeau { display: flex; align-items: center; justify-content: space-between; gap: 8px; background: #e7f6ec;
  border: 2px solid var(--vert); border-radius: 12px; padding: 8px 10px; margin-top: 8px; font-weight: 700; }
.f-code { display: flex; gap: 8px; margin-top: 10px; }
.f-code input { flex: 1; min-height: 54px; font-size: 1.3rem; padding: 0 12px; border: 2px solid var(--bord); border-radius: 12px; }

/* Produit */
.fiche { display: flex; gap: 12px; background: var(--carte); border-radius: 14px; padding: 10px; }
.photo { width: 120px; height: 120px; flex: none; display: flex; align-items: center; justify-content: center;
  background: #eef1ef; border-radius: 10px; overflow: hidden; color: var(--doux); font-size: .85rem; text-align: center; }
.photo img { max-width: 100%; max-height: 100%; object-fit: contain; }
.txt { min-width: 0; }
.txt h1 { overflow-wrap: anywhere; }
.marque { margin: 2px 0; font-weight: 600; }
.cond { margin: 2px 0; color: var(--doux); }
.inconnu h1 { color: var(--rouge); }
.lots { margin: 8px 0 0; color: var(--bleu); font-weight: 600; }
.src { font-size: .75rem; color: var(--doux); margin-top: 14px; }
.grille { display: grid; gap: 8px; }
.dates { grid-template-columns: repeat(4, 1fr); }
.dates button { min-height: 84px; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 4px 2px; }
.dates .j { font-size: .9rem; font-weight: 800; }
.dates .n { font-size: 1.7rem; font-weight: 800; line-height: 1.05; }
.dates .m { font-size: .8rem; color: var(--doux); }
.dates .m.nouveau { color: var(--bleu); font-weight: 800; }
.dates .auj { border-color: var(--orange); }
.dates button.choisi, .qtes button.choisi { background: var(--sel); border-color: var(--vert-f); color: #fff; }
.dates button.choisi .m { color: #fff; }

/* Quantité */
.mini { display: flex; align-items: center; gap: 10px; background: var(--carte); border-radius: 12px; padding: 8px; }
.mini img { width: 56px; height: 56px; object-fit: contain; border-radius: 8px; background: #eef1ef; }
.mini div { display: flex; flex-direction: column; min-width: 0; }
.q-date { font-size: 1.2rem; font-weight: 800; color: var(--vert-f); }
.qtes { grid-template-columns: repeat(5, 1fr); }
.qtes button { min-height: 66px; font-size: 1.6rem; font-weight: 800; }
.pm { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 10px; }
.pm button { width: 76px; font-size: 1.8rem; }
.pm output { min-width: 80px; text-align: center; font-size: 2.2rem; font-weight: 800; }
.doublon { background: #fff4e5; border: 2px solid var(--orange); border-radius: 12px; padding: 10px; margin-top: 10px; }
.doublon p { margin: 0 0 8px; font-weight: 700; }
.deux { display: flex; gap: 8px; } .deux button { flex: 1; }

/* Formulaires */
.formulaire label { display: block; font-weight: 700; margin: 12px 0 0; }
.formulaire input:not([type=file]) { display: block; width: 100%; min-height: 52px; font-size: 1.1rem; padding: 0 12px;
  border: 2px solid var(--bord); border-radius: 12px; margin-top: 4px; font-weight: 400; }
.formulaire input[type=file] { display: block; margin-top: 8px; font-size: 1rem; }
.connexion { padding-top: 12vh; }
.connexion h1 { font-size: 2rem; text-align: center; color: var(--vert-f); }

/* Listes */
.onglets { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.onglets button { min-height: 58px; font-weight: 700; font-size: .9rem; padding: 4px; }
.onglets button.actif { background: var(--texte); color: #fff; border-color: var(--texte); }
.onglets b { display: block; font-size: 1.2rem; }
.info { color: var(--doux); font-size: .95rem; }
.items { list-style: none; margin: 0; padding: 0; }
.items li { background: var(--carte); border-radius: 12px; padding: 10px; margin-bottom: 8px; display: grid;
  grid-template-columns: 56px 1fr; gap: 4px 10px; }
.items li.depassee { border-left: 6px solid var(--rouge); }
.items img, .items .vide { width: 56px; height: 56px; object-fit: contain; border-radius: 8px; background: #eef1ef; grid-row: span 2; }
.items .t { min-width: 0; }
.items .t strong { display: block; overflow-wrap: anywhere; }
.items .t span { color: var(--doux); font-size: .9rem; }
.items .d { font-weight: 800; }
.items .d.rouge { color: var(--rouge); }
.items .tag { display: inline-block; font-size: .8rem; font-weight: 700; padding: 1px 6px; border-radius: 6px; background: #e7f6ec; color: var(--vert-f); margin-left: 4px; }
.items .act { grid-column: 1 / -1; display: flex; gap: 8px; margin-top: 4px; }
.items .act .moyen { flex: 1; }
.items .act .confirmer { background: var(--orange); border-color: var(--orange); color: #fff; }
.pied { display: flex; justify-content: space-between; margin-top: 18px; }
.regle { background: var(--carte); border-radius: 12px; padding: 10px; margin-bottom: 8px; }
.regle p { margin: 0 0 8px; font-weight: 600; }
.regle .pm { justify-content: flex-start; margin: 0; }
.regle output { font-size: 1.6rem; min-width: 60px; }
.toast { position: fixed; left: 12px; right: 12px; bottom: calc(14px + env(safe-area-inset-bottom)); max-width: 536px; margin: 0 auto;
  background: #111; color: #fff; padding: 14px; border-radius: 12px; font-weight: 700; display: flex; gap: 10px;
  align-items: center; justify-content: space-between; z-index: 10; }
.toast button { background: #333; color: #fff; border-color: #555; }
.toast.erreur { background: var(--rouge); }
