:root {
  --bleu: #1f3a5f; --bleu2: #2d5a8e; --fond: #f2f4f7; --carte: #fff; --texte: #1b1f24; --gris: #6b7280; --ligne: #dde1e7;
  --vert: #15803d; --vertf: #dcfce7; --rouge: #b91c1c; --rougef: #fee2e2; --orange: #b45309; --orangef: #fef3c7; --bleuf: #dbeafe;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; background: var(--fond); color: var(--texte);
  font: 16px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }

header#barre { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 6px;
  background: var(--bleu); color: #fff; padding: 6px 8px; min-height: 50px; }
#titre { flex: 1; font-weight: 600; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
header .ico { background: none; border: 0; color: #fff; font-size: 26px; width: 40px; height: 40px; border-radius: 8px; }
header .ico:active { background: rgba(255,255,255,.15); }
header .depot { background: rgba(255,255,255,.14); border: 0; color: #fff; padding: 6px 10px; border-radius: 16px;
  font-size: 13px; max-width: 46%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

main { padding: 10px; max-width: 900px; margin: 0 auto; padding-bottom: 90px; }
.cache { display: none !important; }

/* Scan */
.scan { display: flex; gap: 6px; margin-bottom: 10px; position: sticky; top: 56px; z-index: 5; }
.scan input { flex: 1; min-width: 0; font-size: 18px; padding: 11px 12px; border: 2px solid var(--bleu2); border-radius: 10px; background: #fff; }
.scan input:focus { outline: none; border-color: #f59e0b; box-shadow: 0 0 0 3px rgba(245,158,11,.25); }
.scan button { border: 0; background: var(--bleu2); color: #fff; border-radius: 10px; padding: 0 14px; font-size: 15px; font-weight: 600; }

/* Tuiles accueil */
.tuiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tuile { background: var(--carte); border: 0; border-radius: 14px; padding: 16px 12px; text-align: left; min-height: 104px;
  box-shadow: 0 1px 3px rgba(0,0,0,.08); display: flex; flex-direction: column; justify-content: space-between; }
.tuile:active { transform: scale(.98); background: #f8fafc; }
.tuile .t-ico { font-size: 26px; }
.tuile .t-nom { font-weight: 700; font-size: 16px; }
.tuile .t-info { font-size: 13px; color: var(--gris); }
.tuile .badge { float: right; }

.badge { display: inline-block; min-width: 22px; padding: 2px 8px; border-radius: 11px; font-size: 12px; font-weight: 700; text-align: center;
  background: var(--bleuf); color: var(--bleu2); }
.badge.vert { background: var(--vertf); color: var(--vert); }
.badge.rouge { background: var(--rougef); color: var(--rouge); }
.badge.orange { background: var(--orangef); color: var(--orange); }
.badge.gris { background: #eef0f3; color: var(--gris); }

/* Cartes et listes */
.carte { background: var(--carte); border-radius: 12px; padding: 12px; margin-bottom: 10px; box-shadow: 0 1px 3px rgba(0,0,0,.07); }
.carte h2 { margin: 0 0 6px; font-size: 17px; }
.carte h3 { margin: 10px 0 6px; font-size: 14px; color: var(--gris); text-transform: uppercase; letter-spacing: .03em; }
.liste { list-style: none; margin: 0; padding: 0; }
.liste > li { background: var(--carte); border-radius: 10px; padding: 10px 12px; margin-bottom: 6px; box-shadow: 0 1px 2px rgba(0,0,0,.06);
  display: flex; gap: 10px; align-items: center; }
.liste > li.clic:active { background: #eef2f7; }
.liste .grand { flex: 1; min-width: 0; }
.liste .l1 { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.liste .l2 { font-size: 13px; color: var(--gris); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.liste .droite { text-align: right; white-space: nowrap; }
.qte { font-size: 20px; font-weight: 700; }
.petit { font-size: 13px; color: var(--gris); }
.mono { font-family: ui-monospace, Consolas, monospace; }
.vide { text-align: center; color: var(--gris); padding: 30px 10px; }

.ok { background: var(--vertf) !important; }
.ko { background: var(--rougef) !important; }
.att { background: var(--orangef) !important; }
.fait { opacity: .55; }

/* Boutons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; border-radius: 10px; padding: 12px 16px;
  font-weight: 600; background: var(--bleu2); color: #fff; font-size: 15px; text-decoration: none; }
.btn:active { filter: brightness(.9); }
.btn.sec { background: #e5e9f0; color: var(--texte); }
.btn.vert { background: var(--vert); }
.btn.rouge { background: var(--rouge); }
.btn.bloc { width: 100%; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.btns .btn { flex: 1; }
.pm { width: 44px; height: 44px; border-radius: 10px; border: 0; background: #e5e9f0; font-size: 22px; font-weight: 700; }
.pm:active { background: #cfd6e0; }

/* Formulaires */
label.champ { display: block; margin: 10px 0; }
label.champ span { display: block; font-size: 13px; color: var(--gris); margin-bottom: 4px; }
label.champ input, label.champ select, label.champ textarea { width: 100%; padding: 11px; border: 1px solid var(--ligne); border-radius: 9px; font-size: 16px; background: #fff; }
label.coche { display: flex; gap: 10px; align-items: flex-start; margin: 10px 0; }
label.coche input { width: 22px; height: 22px; margin-top: 1px; flex: none; }

/* Retour de scan */
.retour { border-radius: 12px; padding: 12px; margin-bottom: 10px; border: 2px solid transparent; }
.retour.ok { border-color: #86efac; }
.retour.ko { border-color: #fca5a5; }
.retour .r-titre { font-weight: 700; font-size: 17px; }
.retour .r-gros { font-size: 30px; font-weight: 800; }

/* Emplacement courant */
.emp-courant { background: var(--bleu); color: #fff; border-radius: 12px; padding: 10px 12px; margin-bottom: 10px; display: flex; align-items: center; gap: 10px; }
.emp-courant .e-nom { font-size: 24px; font-weight: 800; letter-spacing: .03em; flex: 1; }
.emp-courant .e-lib { font-size: 12px; opacity: .8; }
.emp-courant button { background: rgba(255,255,255,.18); color: #fff; border: 0; border-radius: 8px; padding: 8px 10px; font-weight: 600; }

/* Picking */
.pick { display: flex; gap: 10px; align-items: center; }
.pick .emp { font-family: ui-monospace, Consolas, monospace; font-weight: 800; font-size: 16px; background: var(--bleuf); color: var(--bleu);
  border-radius: 8px; padding: 6px 8px; min-width: 88px; text-align: center; }
.pick .emp.sans { background: #eef0f3; color: var(--gris); font-weight: 600; font-size: 12px; }
.pick .compte { font-size: 22px; font-weight: 800; min-width: 64px; text-align: center; }
.pick .autres { font-size: 12px; color: var(--gris); }
.pick img { width: 48px; height: 48px; object-fit: contain; border-radius: 6px; background: #fff; flex: none; }

.segment { display: flex; background: #e5e9f0; border-radius: 10px; padding: 3px; margin-bottom: 10px; }
.segment button { flex: 1; border: 0; background: none; padding: 9px 6px; border-radius: 8px; font-weight: 600; font-size: 14px; }
.segment button.actif { background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.1); }

table.tab { width: 100%; border-collapse: collapse; font-size: 14px; background: #fff; }
table.tab th, table.tab td { padding: 7px 6px; border-bottom: 1px solid var(--ligne); text-align: left; vertical-align: top; }
table.tab th { position: sticky; top: 56px; background: #eef2f7; font-size: 12px; text-transform: uppercase; color: var(--gris); }
table.tab td.n, table.tab th.n { text-align: right; white-space: nowrap; }
.defile { overflow-x: auto; border-radius: 10px; }

.barre-bas { position: fixed; left: 0; right: 0; bottom: 0; background: rgba(255,255,255,.96); border-top: 1px solid var(--ligne);
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); display: flex; gap: 8px; z-index: 8; }
.barre-bas .btn { flex: 1; }
.progression { height: 8px; background: #e5e9f0; border-radius: 4px; overflow: hidden; margin: 6px 0; }
.progression div { height: 100%; background: var(--vert); transition: width .2s; }

#toast { position: fixed; left: 50%; top: 64px; transform: translateX(-50%); max-width: 92%; z-index: 30;
  padding: 12px 16px; border-radius: 10px; color: #fff; font-weight: 600; display: none; box-shadow: 0 4px 14px rgba(0,0,0,.25); text-align: center; }
#toast.ok { background: var(--vert); } #toast.ko { background: var(--rouge); } #toast.info { background: var(--bleu); }

#modal { position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
#modal .boite { background: #fff; width: 100%; max-width: 520px; border-radius: 16px 16px 0 0; padding: 16px; max-height: 90vh; overflow: auto; }
@media (min-width: 600px) { #modal { align-items: center; } #modal .boite { border-radius: 16px; } }
#modal h2 { margin: 0 0 8px; font-size: 18px; }

.photo { width: 100%; max-height: 220px; object-fit: contain; background: #fff; border-radius: 10px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 14px; }
.kv b { color: var(--gris); font-weight: 500; }
.flash-ok { animation: fok .5s; } .flash-ko { animation: fko .6s; }
@keyframes fok { 0% { background: #86efac; } 100% { background: inherit; } }
@keyframes fko { 0%, 50% { background: #fca5a5; } 100% { background: inherit; } }

header .depot:empty { display: none; }
