:root {
  --vert: #0f7a5a;
  --vert-fonce: #0a5a42;
  --vert-clair: #e3f4ee;
  --fond: #f4f6f5;
  --carte: #ffffff;
  --texte: #1c2624;
  --gris: #64706d;
  --bord: #dde3e1;
  --rouge: #c0392b;
  --rouge-clair: #fbeceb;
  --orange: #b9770e;
  --orange-clair: #fdf3e1;
  --rayon: 8px;
}
* { box-sizing: border-box; }
/* Un élément masqué reste masqué, même si une classe lui donne un display (grille, flex…). */
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--fond); color: var(--texte); font-size: 15px; line-height: 1.4;
}
button, input, select, textarea { font: inherit; }
h1, h2, h3 { margin: 0 0 .6em; line-height: 1.2; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; }

/* En-tête */
.entete {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  background: var(--vert); color: #fff; padding: 10px 20px;
}
.entete .marque { font-weight: 700; font-size: 1.1rem; letter-spacing: .5px; }
.entete .marque small { font-weight: 400; opacity: .85; margin-left: 6px; }
.entete .pharmacie select { background: rgba(255,255,255,.15); color: #fff; border: 1px solid rgba(255,255,255,.35); padding: 6px 8px; font-weight: 600; max-width: 260px; }
.entete .pharmacie select option { color: var(--texte); }
.entete .pastille { background: rgba(255,255,255,.15); padding: 6px 10px; border-radius: 6px; font-weight: 600; font-size: .9rem; }
.entete nav { display: flex; gap: 4px; flex-wrap: wrap; }
.entete nav button {
  background: transparent; color: #fff; border: 0; padding: 7px 12px; border-radius: 6px; cursor: pointer; opacity: .85;
}
.entete nav button:hover { background: rgba(255,255,255,.12); opacity: 1; }
.entete nav button.actif { background: #fff; color: var(--vert-fonce); opacity: 1; font-weight: 600; }
.entete .droite { margin-left: auto; display: flex; align-items: center; gap: 12px; font-size: .9rem; }
.entete .droite a { color: #fff; }
.entete .droite button { background: rgba(255,255,255,.15); color: #fff; border: 0; padding: 6px 10px; border-radius: 6px; cursor: pointer; }

main { padding: 20px; max-width: 1400px; margin: 0 auto; }

/* Composants */
.carte { background: var(--carte); border: 1px solid var(--bord); border-radius: var(--rayon); padding: 16px; }
.grille { display: grid; gap: 16px; }
.ligne { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }
.ligne > * { min-width: 0; }
label { display: flex; flex-direction: column; gap: 4px; font-size: .85rem; color: var(--gris); }
input, select, textarea {
  border: 1px solid var(--bord); border-radius: 6px; padding: 8px 10px; background: #fff; color: var(--texte);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--vert); outline-offset: -1px; border-color: var(--vert); }

.btn {
  border: 1px solid var(--bord); background: #fff; color: var(--texte); padding: 8px 14px; border-radius: 6px;
  cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--vert); }
.btn.principal { background: var(--vert); border-color: var(--vert); color: #fff; font-weight: 600; }
.btn.principal:hover { background: var(--vert-fonce); }
.btn.danger { color: var(--rouge); border-color: #e8b4ae; }
.btn.danger:hover { background: var(--rouge-clair); }
.btn.petit { padding: 4px 9px; font-size: .85rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--bord); vertical-align: middle; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .4px; color: var(--gris); font-weight: 600; background: #fafbfb; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.cliquable { cursor: pointer; }
tr.cliquable:hover td { background: var(--vert-clair); }
.table-defile { overflow-x: auto; }

.badge { display: inline-block; white-space: nowrap; padding: 2px 8px; border-radius: 999px; font-size: .78rem; font-weight: 600; background: var(--vert-clair); color: var(--vert-fonce); }
.badge.rouge { background: var(--rouge-clair); color: var(--rouge); }
.badge.orange { background: var(--orange-clair); color: var(--orange); }
.badge.gris { background: #eef0ef; color: var(--gris); }
.muet { color: var(--gris); font-size: .88rem; }
.vide { color: var(--gris); text-align: center; padding: 24px; }

.chiffres { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.chiffre { background: var(--carte); border: 1px solid var(--bord); border-radius: var(--rayon); padding: 14px; }
.chiffre .val { font-size: 1.45rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.chiffre .lib { color: var(--gris); font-size: .85rem; }
.chiffre.alerte .val { color: var(--rouge); }

/* Fenêtres */
.voile {
  position: fixed; inset: 0; background: rgba(20, 30, 28, .45); display: flex; align-items: center; justify-content: center;
  padding: 16px; z-index: 50;
}
.fenetre { background: #fff; border-radius: 10px; padding: 20px; width: 100%; max-width: 560px; max-height: 92vh; overflow: auto; box-shadow: 0 10px 40px rgba(0,0,0,.2); }
.fenetre.large { max-width: 820px; }
.fenetre .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }

#notif { position: fixed; bottom: 20px; right: 20px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.notif { background: var(--texte); color: #fff; padding: 10px 16px; border-radius: 8px; box-shadow: 0 4px 16px rgba(0,0,0,.2); max-width: 380px; }
.notif.erreur { background: var(--rouge); }
.notif.ok { background: var(--vert); }

/* Connexion */
.connexion { max-width: 360px; margin: 10vh auto; }
.connexion .carte { padding: 28px; }
.connexion h1 { color: var(--vert); text-align: center; font-size: 1.5rem; }
.connexion form { display: grid; gap: 14px; }

/* Impression */
#zone-impression { display: none; }
@media print {
  body > *:not(#zone-impression) { display: none !important; }
  #zone-impression { display: block; }
  body { background: #fff; }
}
.ticket { width: 72mm; font-family: "Courier New", monospace; font-size: 11px; color: #000; }
.ticket .centre { text-align: center; }
.ticket hr { border: 0; border-top: 1px dashed #000; margin: 6px 0; }
.ticket table td { border: 0; padding: 1px 0; }
.ticket .total { font-size: 14px; font-weight: 700; }
.facture { font-size: 12px; color: #000; padding: 10mm; }
.facture .haut { display: flex; justify-content: space-between; margin-bottom: 20px; }
.facture h1 { font-size: 20px; color: #000; }
.facture table th { background: #eee; color: #000; }
.facture td, .facture th { border: 1px solid #999; }
.facture .totaux { margin-left: auto; width: 45%; margin-top: 10px; }

@media (max-width: 700px) {
  main { padding: 12px; }
  .entete { padding: 10px 12px; }
}

.ecart-positif { color: var(--vert); font-weight: 700; }
.ecart-negatif { color: var(--rouge); font-weight: 700; }

/* Scan */
.zone-scan { display: flex; gap: 8px; align-items: center; border: 2px dashed var(--vert); border-radius: var(--rayon); padding: 8px 10px; background: var(--vert-clair); }
.zone-scan .icone-scan { font-size: 1.5rem; color: var(--vert); }
.zone-scan .champ-scan { flex: 1; min-width: 0; font-size: 1.05rem; padding: 10px 12px; }
.petit-texte { font-size: .8rem; margin-top: 4px; }
.video-scan { position: relative; background: #000; border-radius: 8px; overflow: hidden; }
.video-scan video { width: 100%; display: block; max-height: 60vh; object-fit: cover; }
.video-scan .viseur { position: absolute; inset: 18%; border: 3px solid rgba(255,255,255,.85); border-radius: 12px; box-shadow: 0 0 0 9999px rgba(0,0,0,.25); }
.code-2fa { font-size: 1.6rem; letter-spacing: .4em; text-align: center; font-variant-numeric: tabular-nums; }
.qr-2fa { width: 220px; margin: 8px auto; }
.qr-2fa svg { width: 100%; height: auto; display: block; }
.secret { font-family: "Courier New", monospace; background: #f1f3f2; padding: 6px 10px; border-radius: 6px; word-break: break-all; user-select: all; }
.etapes { margin: 0; padding-left: 20px; display: grid; gap: 6px; }

/* Mode manager (panneau ouvert par-dessus la caisse) */
.mode-manager { position: fixed; inset: 0; z-index: 40; background: var(--fond); overflow: auto; }
.mode-manager .barre { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; background: #7a4b00; color: #fff; padding: 10px 20px; }
.mode-manager .barre b { font-size: 1.05rem; }
.mode-manager .barre nav { display: flex; gap: 4px; flex-wrap: wrap; }
.mode-manager .barre nav button { background: transparent; color: #fff; border: 0; padding: 7px 12px; border-radius: 6px; cursor: pointer; opacity: .85; }
.mode-manager .barre nav button.actif { background: #fff; color: #7a4b00; opacity: 1; font-weight: 600; }
.mode-manager .barre .droite { margin-left: auto; display: flex; gap: 10px; align-items: center; font-size: .9rem; }
.mode-manager .barre .droite button { background: rgba(255,255,255,.18); color: #fff; border: 0; padding: 7px 12px; border-radius: 6px; cursor: pointer; font-weight: 600; }
.mode-manager main { padding: 20px; max-width: 1400px; margin: 0 auto; }
.btn-manager { background: #ffd58a !important; color: #5a3700 !important; font-weight: 700; }


tr.flash td { animation: flash 1.2s ease-out; }
@keyframes flash { from { background: #c9eedd; } to { background: transparent; } }

.code-poste { font-size: 2.2rem; font-weight: 800; letter-spacing: .18em; font-variant-numeric: tabular-nums; color: var(--vert-fonce); background: var(--vert-clair); border-radius: 10px; padding: 10px 16px; margin: 0 auto 14px; display: inline-block; }
