:root {
  --bg: #0f1720;
  --panel: #182431;
  --panel-2: #1f2f3e;
  --line: #2c3e50;
  --txt: #eef4f8;
  --muted: #93a7b8;
  --accent: #ff8c1a;
  --accent-2: #ffb35c;
  --ok: #2ecc71;
  --warn: #f1c40f;
  --danger: #e74c3c;
  --info: #3498db;
  --radius: 14px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--txt);
  min-height: 100vh;
}

/* ---------- Barre supérieure ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.topbar a.home { color: var(--accent-2); text-decoration: none; font-weight: 700; font-size: 18px; }
.topbar h1 { font-size: 18px; margin: 0; flex: 1; }
.cx-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.cx-dot.ok { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.cx-dot.ko { background: var(--danger); }

/* ---------- Layout ---------- */
.wrap { max-width: 1100px; margin: 0 auto; padding: 16px; }
.cols { display: grid; grid-template-columns: 1fr 360px; gap: 16px; align-items: start; }
@media (max-width: 820px) { .cols { grid-template-columns: 1fr; } }

.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px;
}
.panel h2 { margin: 0 0 12px; font-size: 16px; color: var(--accent-2); }

/* ---------- Boutons ---------- */
button, .btn {
  font: inherit; cursor: pointer; border: none; border-radius: 12px;
  padding: 14px 16px; font-weight: 700; color: #fff; background: var(--panel-2);
  border: 1px solid var(--line); transition: transform .05s ease, filter .15s ease;
}
button:active, .btn:active { transform: scale(.97); }
button:disabled { opacity: .4; cursor: not-allowed; }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #1a1109; }
.btn-ok { background: var(--ok); border-color: var(--ok); color: #06301a; }
.btn-danger { background: var(--danger); border-color: var(--danger); }
.btn-info { background: var(--info); border-color: var(--info); }
.btn-ghost { background: transparent; }
.btn-lg { font-size: 18px; padding: 16px 20px; width: 100%; }
.btn-sm { padding: 8px 12px; font-size: 13px; border-radius: 10px; }

/* ---------- Prise de commande ---------- */
.produits { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.produit {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; text-align: center; cursor: pointer; position: relative;
}
.produit .nom { font-size: 18px; font-weight: 700; }
.produit .prix { color: var(--accent-2); margin-top: 6px; font-size: 15px; }
.produit.rupture { opacity: .45; cursor: not-allowed; }
.produit .badge-rupture {
  position: absolute; top: 8px; right: 8px; background: var(--danger);
  font-size: 11px; padding: 3px 7px; border-radius: 8px; font-weight: 700;
}

.options { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 10px 14px;
  border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line);
  cursor: pointer; user-select: none; font-weight: 600;
}
.chip.on { background: var(--accent); color: #1a1109; border-color: var(--accent); }
.chip.off-rupture { opacity: .4; cursor: not-allowed; }

.qte { display: inline-flex; align-items: center; gap: 10px; }
.qte button { width: 44px; height: 44px; padding: 0; font-size: 22px; }
.qte .val { min-width: 34px; text-align: center; font-size: 20px; font-weight: 800; }

/* ---------- Panier ---------- */
.panier-ligne {
  display: flex; justify-content: space-between; gap: 8px;
  padding: 10px 0; border-bottom: 1px dashed var(--line);
}
.panier-ligne .desc { font-size: 14px; }
.panier-ligne .desc small { color: var(--muted); display: block; }
.panier-ligne .montant { font-weight: 800; white-space: nowrap; }
.total-line { display: flex; justify-content: space-between; align-items: baseline; margin-top: 14px; }
.total-line .grand { font-size: 30px; font-weight: 900; color: var(--accent-2); }

/* ---------- Cartes commande (paiement / prépa) ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.cmd {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; display: flex; flex-direction: column; gap: 10px;
}
.cmd.flash { animation: flash 1s ease; }
@keyframes flash { from { box-shadow: 0 0 0 3px var(--accent); } to { box-shadow: none; } }
.cmd .num { font-size: 22px; font-weight: 900; }
.cmd .items { font-size: 14px; color: var(--txt); }
.cmd .items li { margin: 2px 0; }
.cmd .meta { display: flex; justify-content: space-between; align-items: center; }
.cmd .montant-pay { font-size: 24px; font-weight: 900; color: var(--accent-2); }
.client-nom { font-weight: 800; font-size: 16px; color: var(--accent-2); }

.statut { font-size: 12px; font-weight: 800; padding: 4px 10px; border-radius: 999px; }
.s-a_payer { background: #5a4a12; color: var(--warn); }
.s-paye { background: #14402a; color: var(--ok); }
.s-pret { background: #123a52; color: var(--info); }
.s-remis { background: #2a2f37; color: var(--muted); }
.s-annule { background: #4a1f1a; color: var(--danger); }

.tag { font-size: 12px; padding: 3px 8px; border-radius: 8px; background: var(--panel-2); color: var(--muted); }
.tag.paye { background: #14402a; color: var(--ok); }
.tag.nonpaye { background: #5a4a12; color: var(--warn); }

/* ---------- Modale QR / scan ---------- */
.modal-bg {
  position: fixed; inset: 0; background: rgba(0,0,0,.7); display: none;
  align-items: center; justify-content: center; z-index: 50; padding: 16px;
}
.modal-bg.show { display: flex; }
.modal {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px; max-width: 380px; width: 100%; text-align: center;
}
.modal img.qr { width: 240px; height: 240px; background: #fff; border-radius: 12px; }
.modal .num-big { font-size: 40px; font-weight: 900; color: var(--accent-2); }

#reader { width: 100%; border-radius: 12px; overflow: hidden; }

.empty { color: var(--muted); text-align: center; padding: 40px 10px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--panel-2); border: 1px solid var(--line); color: var(--txt);
  padding: 12px 18px; border-radius: 12px; z-index: 60; opacity: 0; transition: opacity .2s;
  font-weight: 700;
}
.toast.show { opacity: 1; }
.toast.ok { border-color: var(--ok); }
.toast.err { border-color: var(--danger); }

/* ---------- Filtres ---------- */
.filtres { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.filtres .chip { padding: 8px 14px; }
.count { background: var(--accent); color: #1a1109; border-radius: 999px; padding: 1px 8px; font-size: 12px; font-weight: 800; }

/* ---------- Admin ---------- */
.adm-row { display: grid; grid-template-columns: 1fr auto auto; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.adm-row .pname { font-weight: 700; font-size: 16px; }
.adm-row input[type=number] { width: 90px; padding: 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--txt); font: inherit; text-align: right; }
.switch { position: relative; width: 58px; height: 32px; }
.switch input { display: none; }
.switch .slider { position: absolute; inset: 0; background: var(--danger); border-radius: 999px; transition: .2s; }
.switch .slider::before { content: ""; position: absolute; width: 26px; height: 26px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + .slider { background: var(--ok); }
.switch input:checked + .slider::before { transform: translateX(26px); }
.switch-label { font-size: 12px; color: var(--muted); text-align: center; display: block; margin-top: 2px; }

textarea.note { width: 100%; background: var(--bg); color: var(--txt); border: 1px solid var(--line); border-radius: 10px; padding: 10px; font: inherit; resize: vertical; min-height: 44px; }

/* ---------- Hub d'accueil ---------- */
body.hub { display: flex; align-items: center; justify-content: center; padding: 20px; }
.hub-wrap { text-align: center; max-width: 760px; width: 100%; }
.hub-wrap h1 { font-size: 40px; margin: 0 0 6px; }
.hub-sub { color: var(--muted); margin: 0 0 26px; }
.hub-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 560px) { .hub-grid { grid-template-columns: 1fr; } }
.hub-card {
  display: flex; flex-direction: column; gap: 6px; text-decoration: none; color: var(--txt);
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px; text-align: left;
}
.hub-card:active { transform: scale(.98); }
.hub-emoji { font-size: 34px; }
.hub-titre { font-size: 20px; font-weight: 800; }
.hub-desc { color: var(--muted); font-size: 13px; }
.c-commande { border-left: 5px solid var(--accent); }
.c-paiement { border-left: 5px solid var(--ok); }
.c-prepa { border-left: 5px solid var(--info); }
.c-admin { border-left: 5px solid var(--muted); }
.c-client { border-left: 5px solid var(--accent-2); }
.hub-foot { margin-top: 24px; color: var(--muted); font-size: 13px; }
.hub-foot.ok { color: var(--ok); }
.hub-foot.ko { color: var(--danger); }
