:root {
  --fond: #f4f5f7;
  --carte: #ffffff;
  --texte: #1c2330;
  --sourd: #5d6778;
  --bord: #d9dde4;
  --prim: #1f4e79;
  --prim-texte: #ffffff;
  --ok: #1d7a46;
  --ok-fond: #e3f4ea;
  --alerte: #a15c00;
  --alerte-fond: #fff1db;
  --ko: #b3261e;
  --ko-fond: #fde8e6;
  --info-fond: #e7eff8;
  --rayon: 10px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--fond); color: var(--texte); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 18px; margin: 0 0 10px; }
h3 { font-size: 15px; margin: 0 0 8px; }
button, input, select, textarea { font: inherit; color: inherit; }
header { position: sticky; top: 0; z-index: 5; background: var(--prim); color: #fff; display: flex; align-items: center; gap: 16px; padding: 0 16px; min-height: 54px; flex-wrap: wrap; }
.marque { font-size: 16px; white-space: nowrap; }
nav { display: flex; gap: 2px; flex: 1; overflow-x: auto; scrollbar-width: none; }
nav button { background: none; border: 0; color: #cfe0f2; padding: 16px 10px; white-space: nowrap; cursor: pointer; border-bottom: 3px solid transparent; position: relative; }
nav button[aria-current="page"] { color: #fff; border-bottom-color: #fff; font-weight: 600; }
nav .pastille { position: absolute; top: 7px; right: 0; }
.qui { display: flex; gap: 10px; align-items: center; font-size: 13px; }
.qui .lien { color: #cfe0f2; }
main { max-width: 1200px; margin: 0 auto; padding: 18px 16px 60px; }
.pile { display: flex; flex-direction: column; gap: 14px; }
.ligne { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.pousse { margin-left: auto; }
.carte { background: var(--carte); border: 1px solid var(--bord); border-radius: var(--rayon); padding: 16px; overflow-x: auto; }
.sourd { color: var(--sourd); }
.petit { font-size: 13px; }
.btn, .btn-sec, .btn-danger { border-radius: 8px; padding: 9px 16px; cursor: pointer; border: 1px solid transparent; min-height: 40px; }
.btn { background: var(--prim); color: var(--prim-texte); }
.btn-sec { background: #fff; border-color: var(--bord); }
.btn-danger { background: #fff; border-color: #e3b3af; color: var(--ko); }
.btn:disabled, .btn-sec:disabled { opacity: .5; cursor: default; }
.btn.grand { font-size: 17px; padding: 14px 22px; }
.lien { background: none; border: 0; padding: 0; color: var(--prim); text-decoration: underline; cursor: pointer; }
.champ { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--sourd); }
.champ input, .champ select, .champ textarea, input.saisie, select.saisie { border: 1px solid var(--bord); border-radius: 8px; padding: 8px 10px; background: #fff; color: var(--texte); font-size: 15px; min-height: 40px; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible { outline: 3px solid #7fb0e0; outline-offset: 1px; }
.grille { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.grille > * { min-width: 0; }
.grille select { width: 100%; }
.grille-scan { grid-template-columns: 2fr 1fr 1.4fr; }
.grille-scan select { min-height: 60px; }
table.t { width: 100%; border-collapse: collapse; }
.t th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--sourd); font-weight: 600; padding: 6px 8px; border-bottom: 2px solid var(--bord); }
.t td { padding: 8px; border-bottom: 1px solid #eceef2; vertical-align: top; }
.t .n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.t tr.cliquable { cursor: pointer; }
.t tr.cliquable:hover td { background: #f7f9fc; }
.t tr.eteinte td { color: #9aa2ae; }
.defile { overflow-x: auto; }
.badge { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 99px; background: #eceff3; color: var(--texte); white-space: nowrap; }
.badge.ok { background: var(--ok-fond); color: var(--ok); }
.badge.alerte { background: var(--alerte-fond); color: var(--alerte); }
.badge.ko { background: var(--ko-fond); color: var(--ko); }
.badge.info { background: var(--info-fond); color: var(--prim); }
.pastille { display: inline-block; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: #e5484d; color: #fff; font-size: 11px; line-height: 18px; text-align: center; font-weight: 700; }
.barre { height: 6px; border-radius: 3px; background: #e6e9ee; overflow: hidden; min-width: 80px; }
.barre > i { display: block; height: 100%; background: var(--ok); }
.kpi { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.kpi button { text-align: left; background: var(--carte); border: 1px solid var(--bord); border-radius: var(--rayon); padding: 14px; cursor: pointer; }
.kpi b { display: block; font-size: 28px; line-height: 1.1; }
.kpi .alerte b { color: var(--alerte); }
.kpi .ko b { color: var(--ko); }
.bandeau { border-radius: var(--rayon); padding: 12px 14px; }
.bandeau.ok { background: var(--ok-fond); color: #11502d; }
.bandeau.alerte { background: var(--alerte-fond); color: #6b3d00; }
.bandeau.ko { background: var(--ko-fond); color: #7d1a15; }
.bandeau.info { background: var(--info-fond); color: #173b5c; }
.scan { font-size: 22px !important; padding: 14px !important; min-height: 60px !important; width: 100%; }
.retour-scan { font-size: 18px; min-height: 64px; }
.retour-scan b { font-size: 20px; }
.voile { position: fixed; inset: 0; background: rgba(15, 20, 30, .45); display: flex; align-items: flex-start; justify-content: center; padding: 5vh 12px; z-index: 20; overflow-y: auto; }
.voile .carte { width: min(720px, 100%); }
.fil { display: flex; flex-direction: column; gap: 8px; max-height: 320px; overflow-y: auto; }
.bulle { max-width: 85%; padding: 8px 12px; border-radius: 12px; background: #eef1f5; }
.bulle.moi { align-self: flex-end; background: var(--info-fond); }
.bulle small { display: block; color: var(--sourd); font-size: 11px; }
#toast { position: fixed; left: 50%; top: 70px; transform: translateX(-50%); background: #1c2330; color: #fff; padding: 14px 22px; border-radius: 10px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 30; max-width: 92vw; font-size: 17px; box-shadow: 0 6px 24px rgba(0,0,0,.25); }
#toast.erreur { background: var(--ko); }
#toast.vu { opacity: 1; }
.connexion { max-width: 380px; margin: 10vh auto; }
.vide { padding: 22px; text-align: center; color: var(--sourd); }
.groupe-cde { border-left: 4px solid var(--prim); padding-left: 12px; }
.groupe-cde.urgent { border-left-color: var(--ko); }
input.qte { width: 90px; text-align: right; }
input.emp { width: 110px; }
td input.saisie { min-height: 34px; padding: 5px 8px; }
.vignettes { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px; }
.vignettes figure { margin: 0; font-size: 12px; }
.vignettes img, .doc-pdf { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; border: 1px solid var(--bord); background: #eef1f5; }
.doc-pdf { display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 22px; color: var(--ko); text-decoration: none; }
.vignettes figcaption { margin-top: 4px; overflow-wrap: anywhere; }
/* cloche et avertissements */
.cloche { background: none; border: 0; color: #fff; font-size: 18px; cursor: pointer; position: relative; padding: 6px; }
.cloche .pastille { position: absolute; top: -2px; right: -6px; }
.qui #qui-nom { color: #fff; text-decoration: none; }
.notif { display: flex; flex-direction: column; gap: 2px; text-align: left; background: #fff; border: 0; border-bottom: 1px solid var(--bord); padding: 10px 6px; cursor: pointer; }
.notif:hover { background: #f7f9fc; }
.notif.nonlue { border-left: 4px solid var(--prim); padding-left: 10px; background: var(--info-fond); }
.texte-ko { color: var(--ko); }
.texte-alerte { color: var(--alerte); }
/* histogramme mensuel */
.barres { display: flex; gap: 10px; align-items: flex-end; overflow-x: auto; padding-bottom: 4px; }
.barres .mois { display: flex; flex-direction: column; align-items: center; min-width: 44px; font-size: 12px; }
.barres .colonnes { display: flex; gap: 3px; align-items: flex-end; height: 140px; }
.barres .colonnes i { display: block; width: 14px; border-radius: 3px 3px 0 0; min-height: 2px; }
.b-env { background: #9db8d6; }
.b-comp { background: var(--ok); }
.leg { display: inline-block; width: 12px; height: 12px; border-radius: 2px; vertical-align: middle; }
/* ---------- écrans atelier en arabe (droite à gauche) ---------- */
[dir="rtl"] .pousse { margin-left: 0; margin-right: auto; }
[dir="rtl"] .tuile .nombre { right: auto; left: 16px; }
[dir="rtl"] .qte-art { text-align: left; }
[dir="rtl"] .carte-cde, [dir="rtl"] .non-lu { border-left: 1px solid var(--bord); border-right: 6px solid var(--prim); }
[dir="rtl"] .carte-cde.urgent { border-right-color: var(--ko); }
[dir="rtl"] .non-lu { border-right-color: #1f6fd1; }
[lang="ar"] { font-family: "Segoe UI", Tahoma, "Noto Naskh Arabic", "Arial", sans-serif; }
[lang="ar"] .gros-texte, [lang="ar"] .consigne { line-height: 1.6; }

/* ---------- recherche dans l'en-tête ---------- */
.recherche { display: flex; align-items: center; gap: 4px; background: rgba(255,255,255,.14); border-radius: 8px; padding: 2px 6px; min-width: 240px; flex: 0 1 380px; }
.recherche input { flex: 1; min-width: 0; background: none; border: 0; color: #fff; font-size: 15px; padding: 8px 4px; }
.recherche input::placeholder { color: #cfe0f2; }
.recherche input:focus { outline: none; }
.recherche .loupe { background: none; border: 0; color: #fff; font-size: 16px; cursor: pointer; }
@media (max-width: 1100px) { .recherche { order: 3; flex-basis: 100%; margin-bottom: 6px; } }

/* ---------- scan au téléphone ---------- */
.scan-tel { width: 100%; min-height: 72px; font-size: 22px; }
.scan-plein { align-items: flex-start; }
.scan-plein .carte { max-height: 96vh; overflow-y: auto; }
.lecteur-tel { width: 100%; min-height: 200px; max-height: 50vh; overflow: hidden; border-radius: 12px; background: #000; }
.lecteur-tel video { width: 100% !important; height: auto !important; }
.choix-scan { flex-wrap: wrap; }

/* ---------- reprise des commandes en cours ---------- */
.depot { border: 2px dashed var(--bord); border-radius: 12px; padding: 22px; text-align: center; font-size: 17px; }
.depot.survol { border-color: var(--prim); background: var(--info-fond); }
.estompee { opacity: .55; }
tr.faite td { color: var(--sourd); }

/* ---------- mode atelier ---------- */
.titre-atelier { font-size: 28px; }
.consigne { font-size: 17px; margin: 0; color: var(--sourd); }
.gros-texte { font-size: 18px; }
.gros-chiffre { font-size: 28px; line-height: 1; }
.vert { color: var(--ok); }
.gros-bouton { font-size: 18px; min-height: 56px; padding: 12px 20px; border-radius: 12px; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.gros-bouton-retour { font-size: 18px; min-height: 52px; padding: 10px 18px; text-decoration: none; display: inline-flex; align-items: center; }
.gros-champ { font-size: 20px !important; min-height: 56px !important; }
.tuiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.tuile { position: relative; display: flex; flex-direction: column; gap: 6px; min-height: 170px; padding: 20px; border-radius: 16px; background: var(--carte); border: 2px solid var(--bord); text-decoration: none; color: var(--texte); box-shadow: 0 2px 6px rgba(0,0,0,.05); }
.tuile:active { transform: scale(.98); }
.tuile .icone { font-size: 44px; line-height: 1; }
.tuile .titre { font-size: 22px; font-weight: 700; }
.tuile .sous { color: var(--sourd); font-size: 15px; }
.tuile .nombre { position: absolute; top: 14px; right: 16px; min-width: 46px; height: 46px; padding: 0 10px; border-radius: 23px; background: var(--prim); color: #fff; font-size: 24px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.tuile.urgent { border-color: var(--ko); }
.tuile.urgent .nombre, .tuile.alerte .nombre { background: var(--ko); }
.bandeau-nouveau { display: block; padding: 18px; border-radius: 14px; background: #1f6fd1; color: #fff; font-size: 20px; font-weight: 600; text-decoration: none; }
.carte-cde { border-left: 6px solid var(--prim); }
.carte-cde.urgent { border-left-color: var(--ko); }
.carte-lien { display: block; text-decoration: none; color: var(--texte); }
.carte-choix { display: flex; align-items: center; gap: 14px; cursor: pointer; }
.carte-choix input { width: 30px; height: 30px; }
.entete-cde { margin-bottom: 8px; }
.note-cde { background: #fff8e1; border-radius: 8px; padding: 8px 12px; margin: 6px 0; font-size: 16px; }
.pastille-texte { display: inline-block; padding: 3px 10px; border-radius: 99px; font-size: 13px; font-weight: 700; background: #eceff3; }
.pastille-texte.rouge { background: var(--ko); color: #fff; }
.pastille-texte.bleu { background: #1f6fd1; color: #fff; }
.pastille-texte.orange { background: var(--alerte-fond); color: var(--alerte); }
.pastille-texte.vert { background: var(--ok-fond); color: var(--ok); }
.lignes-art { display: flex; flex-direction: column; }
.ligne-art { display: grid; grid-template-columns: auto 1fr auto auto; gap: 14px; align-items: center; padding: 12px 0; border-bottom: 1px solid #eceef2; }
.ligne-art:last-child { border-bottom: 0; }
.ligne-art.faite { opacity: .6; }
.nom-art { display: flex; flex-direction: column; gap: 3px; font-size: 17px; min-width: 0; }
.nom-art .pastille-texte { align-self: flex-start; }
.qte-art { text-align: right; font-size: 16px; white-space: nowrap; }
.actions-art { display: flex; flex-direction: column; gap: 6px; }
.photo-art { object-fit: contain; background: #fff; border: 1px solid var(--bord); border-radius: 10px; flex-shrink: 0; }
.photo-art.sans-photo { visibility: hidden; }
.vignettes-ligne { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0; }
.zone-scan { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.zone-scan .scan { flex: 1; min-width: 220px; }
.retour-geant { border-radius: 14px; padding: 18px 20px; font-size: 20px; line-height: 1.4; }
.retour-geant > button, .retour-geant > div.petit { display: block; margin-top: 10px; }
.retour-geant.ok { background: var(--ok-fond); color: #11502d; border: 2px solid var(--ok); }
.retour-geant.ko { background: var(--ko-fond); color: #7d1a15; border: 2px solid var(--ko); }
.grand-dialogue { width: min(640px, 100%) !important; }
.compteur { display: flex; gap: 14px; justify-content: center; align-items: center; }
.compteur .rond { width: 72px; height: 72px; border-radius: 36px; font-size: 38px; line-height: 1; }
.compteur .chiffre { width: 150px; font-size: 44px !important; text-align: center; min-height: 72px !important; }
.choix-pb { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.choisi { outline: 3px solid var(--prim); background: var(--info-fond) !important; }
.choix-radio { cursor: pointer; }
.choix-radio input { width: 22px; height: 22px; }
.progression { display: flex; gap: 14px; flex-wrap: wrap; font-size: 15px; }
.non-lu { border-left: 6px solid #1f6fd1; }
@media (max-width: 640px) {
  .ligne-art { grid-template-columns: auto 1fr; }
  .qte-art, .actions-art { grid-column: 2; text-align: left; }
  .tuiles { grid-template-columns: 1fr 1fr; gap: 10px; }
  .tuile { min-height: 140px; padding: 14px; }
  .tuile .titre { font-size: 18px; }
  .tuile .icone { font-size: 36px; }
}
@media (max-width: 640px) {
  header { gap: 6px; }
  nav button { padding: 12px 8px; }
  .qui span { display: none; }
  .grille-scan { grid-template-columns: 1fr 1fr; }
  .grille-scan > :first-child { grid-column: 1 / -1; }
  .grille { grid-template-columns: 1fr; }
  .t th, .t td { padding: 6px 4px; }
}
@media print {
  header, #toast, .pas-imprime { display: none !important; }
  body { background: #fff; }
  .carte { border: 0; padding: 0; }
}
