:root {
  /* Identité : bleu roi sombre, or, orange réservé aux alertes */
  --primaire: #1e3a8a;
  --primaire-fonce: #172554;
  --primaire-clair: #e8edfb;
  --or: #c8962e;
  --or-vif: #e5b73b;
  --or-clair: #fbf4e2;
  --fond: #f4f6fa;
  --carte: #ffffff;
  --texte: #1a2033;
  --doux: #5b6478;
  --bord: #dde2ec;
  --rouge: #b42318;
  --rouge-clair: #fdecea;
  --orange: #c2410c;
  --orange-clair: #ffedd5;
  --wa: #25d366;
  --rayon: 12px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--fond);
  color: var(--texte);
  font-size: 16px;
  line-height: 1.4;
  padding-bottom: calc(68px + env(safe-area-inset-bottom));
}
a { color: var(--primaire); }
.entete {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: var(--primaire); color: #fff; padding: 12px 16px;
}
.entete-titre { font-weight: 700; font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entete-etat { font-size: 12px; background: rgba(255,255,255,.18); padding: 3px 8px; border-radius: 99px; white-space: nowrap; }
.vue { max-width: 760px; margin: 0 auto; padding: 16px; }
.chargement { text-align: center; color: var(--doux); padding: 40px 0; }
h1 { font-size: 22px; margin: 4px 0 12px; }
h2 { font-size: 17px; margin: 22px 0 10px; }
h3 { font-size: 15px; margin: 0 0 6px; }
.doux { color: var(--doux); font-size: 14px; }
.petit { font-size: 13px; }
.nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 5;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: #fff; border-top: 1px solid var(--bord);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav[hidden], [hidden] { display: none !important; }
.nav a {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 0 10px; font-size: 12px; color: var(--doux); text-decoration: none;
}
.ico { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.btn .ico { width: 18px; height: 18px; }
.entete-etat::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #6ee7a8; margin-right: 6px; vertical-align: 1px; }
.entete-etat.horsligne::before { background: var(--or-vif); }
.pastille { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: var(--primaire-clair); color: var(--primaire); flex: none; }
.pastille.p1 { background: var(--rouge-clair); color: var(--rouge); }
.pastille.p2 { background: var(--orange-clair); color: var(--orange); }
.tache-tete { display: flex; gap: 12px; align-items: flex-start; }
.tache-tete h3 { margin: 2px 0 2px; }
.menu .g { display: flex; align-items: center; gap: 12px; }
.menu .g > div { min-width: 0; }
.chevron { color: var(--doux); }
.sep { color: var(--bord); margin: 0 4px; }
.nav a.actif { color: var(--primaire); font-weight: 700; }
.carte { background: var(--carte); border: 1px solid var(--bord); border-radius: var(--rayon); padding: 14px; margin-bottom: 10px; }
.grille { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.kpi { background: var(--carte); border: 1px solid var(--bord); border-radius: var(--rayon); padding: 12px; min-width: 0; }
.kpi .lib { font-size: 13px; color: var(--doux); }
.kpi .val { font-size: 21px; font-weight: 700; overflow-wrap: anywhere; }
.kpi.fort { background: var(--primaire); color: #fff; border-color: var(--primaire); }
.kpi.fort .lib { color: rgba(255,255,255,.85); }
.neg { color: var(--rouge) !important; }
.liste { list-style: none; margin: 0; padding: 0; }
.ligne {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--carte); border: 1px solid var(--bord); border-radius: var(--rayon);
  padding: 12px; margin-bottom: 8px; text-decoration: none; color: inherit;
}
.ligne .g { min-width: 0; flex: 1; }
.ligne .g b, .ligne .g .doux { display: block; overflow: hidden; text-overflow: ellipsis; }
.ligne .d { text-align: right; white-space: nowrap; }
.badge { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: var(--primaire-clair); color: var(--primaire-fonce); }
.badge.rouge { background: var(--rouge-clair); color: var(--rouge); }
.badge.orange { background: var(--orange-clair); color: var(--orange); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--primaire); background: var(--primaire); color: #fff;
  font: inherit; font-weight: 600; padding: 11px 16px; border-radius: 10px; cursor: pointer;
  text-decoration: none; min-height: 44px;
}
.btn.sec { background: #fff; color: var(--primaire); }
.btn.wa { background: var(--wa); border-color: var(--wa); color: #073b1c; }
.btn.danger { background: #fff; color: var(--rouge); border-color: var(--rouge); }
.btn.mini { padding: 6px 10px; min-height: 34px; font-size: 14px; }
.btn.plein { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
form .champ { margin-bottom: 12px; }
label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 4px; }
input, select, textarea {
  width: 100%; font: inherit; padding: 10px 12px; min-height: 44px;
  border: 1px solid var(--bord); border-radius: 10px; background: #fff; color: var(--texte);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primaire); outline-offset: 1px; }
.deux { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.case { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.case input { width: 22px; min-height: 22px; }
.recherche { margin-bottom: 10px; }
.filtres { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 10px; padding-bottom: 2px; }
.filtres button { flex: none; border: 1px solid var(--bord); background: #fff; border-radius: 99px; padding: 6px 12px; font: inherit; font-size: 14px; cursor: pointer; }
.filtres button.actif { background: var(--primaire); color: #fff; border-color: var(--primaire); }
.produits { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; max-height: 42vh; overflow-y: auto; }
.produit-btn {
  text-align: left; background: #fff; border: 1px solid var(--bord); border-radius: 10px; padding: 10px;
  font: inherit; cursor: pointer; min-height: 72px;
}
.produit-btn b { display: block; font-size: 14px; line-height: 1.25; }
.produit-btn .prix { color: var(--primaire); font-weight: 700; font-size: 14px; }
.produit-btn .stk { font-size: 12px; color: var(--doux); }
.produit-btn.vide { opacity: .55; }
.panier-ligne { display: grid; grid-template-columns: 1fr auto; gap: 6px; border-bottom: 1px dashed var(--bord); padding: 8px 0; }
.qte { display: flex; align-items: center; gap: 6px; }
.qte button { width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--bord); background: #fff; font-size: 18px; cursor: pointer; }
.qte input { width: 62px; min-height: 34px; padding: 4px; text-align: center; }
.prix-input { width: 110px !important; min-height: 34px !important; padding: 4px 8px !important; }
.total { display: flex; justify-content: space-between; font-size: 20px; font-weight: 800; margin: 10px 0; }
.tache { border-left: 4px solid var(--primaire); }
.tache.p1 { border-left-color: var(--rouge); }
.tache.p2 { border-left-color: var(--orange); }
.tache .actions { margin: 8px 0 0; }
.banniere { background: var(--orange-clair); color: #7c2d12; border: 1px solid #fed7aa; border-radius: var(--rayon); padding: 12px; margin-bottom: 12px; font-size: 14px; }
.banniere.maj { max-width: 728px; margin: 12px auto 0; display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--primaire-clair); color: var(--primaire-fonce); border-color: #c7d2f0; }
.banniere.rouge { background: var(--rouge-clair); color: var(--rouge); border-color: #f5c6c0; }
.toast {
  position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); z-index: 10;
  background: #1d2622; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; max-width: calc(100% - 32px);
}
.tableau { width: 100%; border-collapse: collapse; font-size: 14px; }
.tableau td, .tableau th { padding: 7px 4px; border-bottom: 1px solid var(--bord); text-align: left; }
.tableau td.n, .tableau th.n { text-align: right; white-space: nowrap; }
.graph { width: 100%; height: auto; display: block; }
.menu a { font-weight: 600; }
.vide-etat { text-align: center; color: var(--doux); padding: 24px 8px; }
pre.msg { white-space: pre-wrap; font: inherit; margin: 6px 0; background: var(--fond); padding: 10px; border-radius: 8px; font-size: 14px; }
.etapes { display: flex; gap: 6px; flex-wrap: wrap; }
/* Bouton retour de l'en-tête */
.entete { justify-content: flex-start; }
.entete-etat { margin-left: auto; }
.retour { background: rgba(255,255,255,.15); border: 0; color: #fff; width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; cursor: pointer; flex: none; }
.retour .ico { transform: rotate(180deg); }

/* Actions rapides de l'accueil */
.raccourcis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 12px 0; }
.raccourci { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 4px; border-radius: 12px; background: var(--carte); border: 1px solid var(--bord); color: var(--texte); text-decoration: none; font-size: 12px; font-weight: 700; text-align: center; line-height: 1.2; }
.raccourci .ico { width: 24px; height: 24px; color: var(--primaire); }
.raccourci.principal { background: var(--primaire); border-color: var(--primaire); color: #fff; }
.raccourci.principal .ico { color: #fff; }

/* Objectif du mois */
.objectif { margin: 10px 0; }
.barre { height: 10px; border-radius: 99px; background: var(--primaire-clair); overflow: hidden; margin-top: 6px; }
.barre > span { display: block; height: 100%; background: var(--primaire); border-radius: 99px; }

/* Panier toujours visible pendant la vente */
.barre-panier { position: fixed; left: 0; right: 0; bottom: calc(60px + env(safe-area-inset-bottom)); z-index: 4; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  max-width: 760px; margin: 0 auto; padding: 10px 16px; background: var(--primaire-fonce); color: #fff; box-shadow: 0 -4px 14px rgba(0,0,0,.12); }
.barre-panier b { font-size: 17px; }
.barre-panier .btn { background: #fff; color: var(--primaire-fonce); border-color: #fff; }
body.avec-panier { padding-bottom: calc(130px + env(safe-area-inset-bottom)); }

/* Aide courte repliable */
.aide { margin: 8px 0 0; font-size: 14px; }
.aide summary { cursor: pointer; color: var(--primaire); font-weight: 600; list-style: none; }
.aide summary::-webkit-details-marker { display: none; }
.aide summary::before { content: "?"; display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: var(--primaire-clair); color: var(--primaire); font-size: 12px; margin-right: 6px; }
.aide p { margin: 6px 0 0; color: var(--doux); }
.groupe-jour { margin: 16px 0 6px; font-size: 14px; color: var(--doux); text-transform: uppercase; letter-spacing: .03em; }
.groupe-jour.urgent { color: var(--rouge); }

/* Fenêtre de saisie du mot de passe */
.dialogue { border: 0; border-radius: 14px; padding: 18px; width: min(92vw, 380px); box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.dialogue::backdrop { background: rgba(0,0,0,.45); }
.dialogue h3 { margin: 0 0 12px; font-size: 16px; }
.dialogue .actions { margin-bottom: 0; }

/* Menu Plus en grille */
.titre-compact { margin: 0 0 10px; }
.menu-grille { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.tuile {
  display: flex; align-items: center; gap: 10px; min-height: 56px; padding: 8px 10px;
  background: var(--carte); border: 1px solid var(--bord); border-radius: 12px;
  color: var(--texte); text-decoration: none; font-weight: 700; font-size: 14px; line-height: 1.2;
}
.tuile:active { background: var(--primaire-clair); }
.tuile-ico { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; background: var(--primaire-clair); color: var(--primaire); flex: none; }
.tuile-ico .ico { width: 20px; height: 20px; }
.tuile-txt { min-width: 0; overflow-wrap: anywhere; hyphens: auto; }
.tuile.alerte .tuile-ico { background: var(--orange-clair); color: var(--orange); }
.pied-menu { margin: 10px 0 0; text-align: center; }
@media (min-width: 600px) { .menu-grille { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 900px) { .menu-grille { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

@media (min-width: 640px) {
  .grille { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* ---- Touches dorées de l'identité bleu roi et or ---- */
.entete { background: var(--primaire-fonce); border-bottom: 3px solid var(--or-vif); }
.nav a.actif { color: var(--primaire); position: relative; }
.nav a.actif::before { content: ""; position: absolute; top: 0; left: 30%; right: 30%; height: 3px; border-radius: 0 0 3px 3px; background: var(--or-vif); }
.kpi.fort { background: var(--primaire); border-color: var(--primaire); box-shadow: inset 0 -3px 0 var(--or-vif); }
.barre > span { background: linear-gradient(90deg, var(--or), var(--or-vif)); }
.raccourci.principal { background: var(--primaire); border-color: var(--primaire); box-shadow: inset 0 -3px 0 var(--or-vif); }
.badge { background: var(--primaire-clair); color: var(--primaire); }
.tuile-ico { background: var(--primaire-clair); color: var(--primaire); }
.tuile.alerte .tuile-ico { background: var(--orange-clair); color: var(--orange); }
.barre-panier { background: var(--primaire-fonce); border-top: 3px solid var(--or-vif); }
.barre-panier .btn { background: var(--or-vif); border-color: var(--or-vif); color: var(--primaire-fonce); }
.retour { background: rgba(255,255,255,.12); }
.filtres button.actif { background: var(--primaire); border-color: var(--primaire); }
body.avec-panier .toast { bottom: calc(140px + env(safe-area-inset-bottom)); }
.toast { background: var(--primaire-fonce); border-left: 4px solid var(--or-vif); }

/* Icônes sans fond lumineux : le pictogramme seul, dans la couleur de la marque */
.tuile-ico, .pastille, .pastille.p1, .pastille.p2, .tuile.alerte .tuile-ico { background: none !important; width: auto; height: auto; border-radius: 0; }
.tuile-ico { color: var(--primaire); }
.tuile-ico .ico { width: 24px; height: 24px; }
.tuile.alerte .tuile-ico { color: var(--orange); }
.pastille { color: var(--primaire); padding-top: 2px; }
.pastille.p1 { color: var(--rouge); }
.pastille.p2 { color: var(--orange); }

/* Tableau de bord analytique */
.kpis-tb { grid-template-columns: 1fr 1fr; }
.kpi .evol { font-size: 12px; font-weight: 700; margin-top: 2px; }
.kpi .evol.hausse { color: #15803d; }
.kpi .evol.baisse { color: var(--orange); }
.carte-graph h3 { margin: 0 0 8px; font-size: 15px; }
.carte-graph .graph { margin: 0 -4px; width: calc(100% + 8px); }
.legende { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; color: var(--doux); margin: 6px 0 2px; }
.legende span { display: inline-flex; align-items: center; gap: 5px; }
.legende i { display: inline-block; width: 14px; height: 3px; border-radius: 2px; }
.bloc-anneau { display: flex; align-items: center; gap: 12px; }
.bloc-anneau .graph.anneau { width: 132px; flex: none; margin: 0; }
.parts { list-style: none; margin: 0; padding: 0; flex: 1; min-width: 0; font-size: 13px; }
.parts li { display: flex; align-items: center; gap: 6px; padding: 3px 0; }
.parts li span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.parts li i { width: 10px; height: 10px; border-radius: 2px; flex: none; }
.barres-h { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.barres-h li { display: grid; grid-template-columns: 82px 1fr 52px; align-items: center; gap: 8px; padding: 4px 0; }
.barres-h .lib { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.barres-h .piste { background: var(--primaire-clair); border-radius: 3px; height: 12px; overflow: hidden; }
.barres-h .piste span { display: block; height: 100%; border-radius: 3px; }
.barres-h b { text-align: right; font-size: 12px; }
.points-cles { list-style: none; margin: 0; padding: 0; }
.points-cles li { padding: 8px 10px; margin: 6px 0; border-left: 4px solid var(--primaire); background: var(--primaire-clair); border-radius: 6px; font-size: 14px; }
.points-cles li.positif { border-color: #15803d; background: #ecf7ef; }
.points-cles li.alerte { border-color: var(--orange); background: #fff1e8; }
.points-cles li.conseil { border-color: var(--or); background: #fbf4e2; }
.liste-matrice { margin: 8px 0 0; padding-left: 22px; font-size: 14px; }
.liste-matrice li { padding: 4px 0; }
.liste-matrice .badge { margin-left: 4px; }
