/* ============================================================
   Festi Dibi — styles
   Braise, charbon, moutarde : l'univers du grill.
   Élément signature : le ticket de commande à bords crantés.
   ============================================================ */
:root {
  --braise: #5B1F0F;
  --braise-2: #7A2C14;
  --ember: #D9501A;
  --ember-fonce: #B23F10;
  --moutarde: #F0B429;
  --fumee: #F2F0ED;
  --blanc: #FFFFFF;
  --charbon: #26211E;
  --gris: #6E655F;
  --trait: #DEDAD4;
  --vert: #2F7A4B;
  --vert-clair: #E3F1E8;
  --rouge: #B42318;
  --rouge-clair: #FBE7E4;
  --jaune-clair: #FDF2D5;
  --r-petit: 6px;
  --r-moyen: 12px;
  --titre: "Bricolage Grotesque", "Trebuchet MS", system-ui, sans-serif;
  --texte: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--fumee); color: var(--charbon);
  font: 16px/1.5 var(--texte);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
h1, h2, h3 { font-family: var(--titre); line-height: 1.15; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: 1.75rem; font-weight: 800; }
h2 { font-size: 1.25rem; font-weight: 700; }
h3 { font-size: 1.05rem; font-weight: 700; }
p { margin: 0 0 1em; }
a { color: var(--ember-fonce); }
:focus-visible { outline: 3px solid var(--moutarde); outline-offset: 2px; }
.muted { color: var(--gris); }
.small { font-size: .875rem; }
.num { font-variant-numeric: tabular-nums; }
.wrap { max-width: 980px; margin: 0 auto; padding: 0 16px; }

/* ---------- En-tête espace associés ---------- */
.topbar {
  background: var(--braise); color: #fff; position: sticky; top: 0; z-index: 20;
  padding-top: env(safe-area-inset-top, 0px);
}
.topbar .wrap { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 10px; padding-bottom: 6px; }
.brand { font-family: var(--titre); font-weight: 800; font-size: 1.2rem; color: #fff; text-decoration: none; }
.brand span { color: var(--moutarde); }
.who { font-size: .85rem; opacity: .85; }
.who a { color: #fff; }
.nav { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; padding: 0 16px 8px; max-width: 980px; margin: 0 auto; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
  flex: none; color: #F6D9CC; text-decoration: none; font-size: .9rem; font-weight: 600;
  padding: 6px 12px; border-radius: 999px;
}
.nav a.on { background: var(--moutarde); color: var(--braise); }
.nav a:hover:not(.on) { background: var(--braise-2); }

main { padding: 20px 0 48px; }

/* ---------- Blocs ---------- */
.panel { background: var(--blanc); border: 1px solid var(--trait); border-radius: var(--r-moyen); padding: 16px; margin-bottom: 16px; }
.panel > h2:first-child, .panel > h3:first-child { margin-top: 0; }
.grid { display: grid; gap: 12px; }
.g4 { grid-template-columns: 1fr 1fr; }
@media (min-width: 640px) { .g2 { grid-template-columns: 1fr 1fr; } .g3 { grid-template-columns: repeat(3, 1fr); } .g4 { grid-template-columns: repeat(4, 1fr); } }

/* Chiffres clés : sobres, alignés à gauche */
.kpi { padding: 12px 14px; border-left: 4px solid var(--trait); background: var(--blanc); border-radius: 0 var(--r-petit) var(--r-petit) 0; }
.kpi .v { font-family: var(--titre); font-size: 1.35rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.kpi .l { font-size: .85rem; color: var(--gris); }
.kpi.ok { border-color: var(--vert); } .kpi.ko { border-color: var(--rouge); } .kpi.hot { border-color: var(--ember); } .kpi.gold { border-color: var(--moutarde); }

/* Jauge de rentabilité */
.jauge { height: 14px; background: var(--fumee); border-radius: 999px; overflow: hidden; border: 1px solid var(--trait); }
.jauge > i { display: block; height: 100%; background: linear-gradient(90deg, var(--ember), var(--moutarde)); }
.jauge.ok > i { background: var(--vert); }

/* ---------- Formulaires ---------- */
label { display: block; font-size: .9rem; font-weight: 600; margin: 0 0 4px; }
input[type=text], input[type=tel], input[type=number], input[type=password], input[type=date], input[type=file], select, textarea {
  width: 100%; font: inherit; padding: 10px 12px; border: 1px solid #CFC9C1; border-radius: var(--r-petit); background: #fff; color: var(--charbon);
}
textarea { min-height: 80px; }
.field { margin-bottom: 12px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row > .grow { flex: 1 1 160px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: 600 .95rem var(--texte); padding: 10px 16px; border-radius: var(--r-petit);
  border: 1px solid transparent; background: var(--ember); color: #fff; cursor: pointer; text-decoration: none; min-height: 44px;
}
.btn:hover { background: var(--ember-fonce); }
.btn.sec { background: #fff; color: var(--charbon); border-color: #CFC9C1; }
.btn.sec:hover { background: var(--fumee); }
.btn.vert { background: var(--vert); } .btn.vert:hover { background: #256340; }
.btn.danger { background: #fff; color: var(--rouge); border-color: #E8B4AD; }
.btn.small { padding: 6px 10px; min-height: 34px; font-size: .85rem; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.flash { padding: 10px 14px; border-radius: var(--r-petit); margin-bottom: 16px; font-weight: 600; }
.flash.ok { background: var(--vert-clair); color: #1D5233; }
.flash.ko { background: var(--rouge-clair); color: var(--rouge); }

/* ---------- Tableaux ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--trait); vertical-align: top; }
th { font-size: .82rem; color: var(--gris); font-weight: 600; }
td.r, th.r { text-align: right; font-variant-numeric: tabular-nums; }
tfoot td { font-weight: 700; border-bottom: none; }

.tag { display: inline-block; font-size: .78rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--fumee); color: var(--gris); white-space: nowrap; }
.tag.nouvelle { background: var(--jaune-clair); color: #7A5600; }
.tag.preparation { background: #FCE3D6; color: var(--ember-fonce); }
.tag.prete { background: var(--vert-clair); color: var(--vert); }
.tag.recuperee { background: var(--fumee); color: var(--gris); }
.tag.annulee { background: var(--rouge-clair); color: var(--rouge); }
.tag.paye { background: var(--vert); color: #fff; }
.tag.impaye { background: #fff; color: var(--rouge); border: 1px solid #E8B4AD; }
.tag.retard { background: var(--rouge); color: #fff; }

/* ---------- Ticket : élément signature ---------- */
.ticket {
  --cran: 10px;
  position: relative; background: #fff; border-radius: 4px;
  padding: 14px 16px 14px 92px; min-height: 84px;
  -webkit-mask: radial-gradient(circle var(--cran) at 76px 0, #0000 98%, #000) top/100% 51% no-repeat,
                radial-gradient(circle var(--cran) at 76px 100%, #0000 98%, #000) bottom/100% 51% no-repeat;
          mask: radial-gradient(circle var(--cran) at 76px 0, #0000 98%, #000) top/100% 51% no-repeat,
                radial-gradient(circle var(--cran) at 76px 100%, #0000 98%, #000) bottom/100% 51% no-repeat;
  filter: drop-shadow(0 1px 0 var(--trait));
}
.ticket::before { /* perforation */
  content: ""; position: absolute; left: 75px; top: 14px; bottom: 14px;
  border-left: 2px dashed var(--trait);
}
.ticket .no {
  position: absolute; left: 0; top: 0; bottom: 0; width: 76px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-family: var(--titre); font-weight: 800; font-size: 1.9rem; line-height: 1; color: var(--braise);
  font-variant-numeric: tabular-nums;
}
.ticket .no small { font: 600 .7rem var(--texte); color: var(--gris); margin-top: 4px; }
.ticket.etat-prete .no { background: var(--vert-clair); color: var(--vert); }
.ticket.etat-nouvelle .no { background: var(--jaune-clair); }
.ticket.etat-preparation .no { background: #FCE3D6; color: var(--ember-fonce); }
.ticket.etat-recuperee { opacity: .62; }
.ticket.etat-annulee { opacity: .45; }
.ticket.en-retard .no { background: var(--rouge); color: #fff; }
.ticket.en-retard .no small { color: #fff; }
.ticket.attente-sync { outline: 2px dashed var(--moutarde); outline-offset: -2px; }
.ticket .t-head { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.ticket .t-nom { font-weight: 700; }
.ticket .t-items { margin: 4px 0 8px; font-size: .92rem; }
.ticket .t-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.tickets { display: grid; gap: 10px; }
@media (min-width: 760px) { .tickets { grid-template-columns: 1fr 1fr; } }

/* Grand ticket client */
.ticket.grand { padding-left: 128px; min-height: 140px; }
.ticket.grand::before { left: 111px; }
.ticket.grand { -webkit-mask: radial-gradient(circle var(--cran) at 112px 0, #0000 98%, #000) top/100% 51% no-repeat, radial-gradient(circle var(--cran) at 112px 100%, #0000 98%, #000) bottom/100% 51% no-repeat;
                        mask: radial-gradient(circle var(--cran) at 112px 0, #0000 98%, #000) top/100% 51% no-repeat, radial-gradient(circle var(--cran) at 112px 100%, #0000 98%, #000) bottom/100% 51% no-repeat; }
.ticket.grand .no { width: 112px; font-size: 3rem; }

/* ---------- Barre de filtres / onglets ---------- */
.filtres { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin-bottom: 12px; }
.filtres button { flex: none; font: 600 .88rem var(--texte); padding: 6px 12px; border-radius: 999px; border: 1px solid #CFC9C1; background: #fff; cursor: pointer; color: var(--charbon); }
.filtres button.on { background: var(--charbon); color: #fff; border-color: var(--charbon); }
.filtres button b { font-variant-numeric: tabular-nums; }

.etat-reseau { font-size: .85rem; font-weight: 600; padding: 6px 12px; border-radius: var(--r-petit); margin-bottom: 12px; display: none; }
.etat-reseau.off { display: block; background: var(--jaune-clair); color: #7A5600; }
.etat-reseau.sync { display: block; background: var(--fumee); color: var(--gris); }

/* ---------- Page client ---------- */
.client-hero { background: var(--braise); color: #fff; padding: calc(28px + env(safe-area-inset-top, 0px)) 0 28px; }
.client-hero h1 { font-size: 2.4rem; margin: 0; color: #fff; }
.client-hero h1 span { color: var(--moutarde); }
.client-hero p { margin: 6px 0 0; color: #F6D9CC; max-width: 52ch; }
.plat { display: flex; gap: 12px; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--trait); }
.plat:last-child { border-bottom: none; }
.plat .info { flex: 1; min-width: 0; }
.plat .nom { font-weight: 700; }
.plat .desc { font-size: .88rem; color: var(--gris); }
.plat .prix { font-family: var(--titre); font-weight: 800; color: var(--braise); font-variant-numeric: tabular-nums; }
.plat.epuise { opacity: .5; }
.qte { display: flex; align-items: center; gap: 4px; }
.qte button { width: 40px; height: 40px; border-radius: 50%; border: 1px solid #CFC9C1; background: #fff; font: 700 1.2rem var(--texte); cursor: pointer; color: var(--charbon); }
.qte button.plus { background: var(--ember); border-color: var(--ember); color: #fff; }
.qte output { min-width: 26px; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }
.panier-barre {
  position: fixed; left: 0; right: 0; bottom: 0; background: var(--charbon); color: #fff; z-index: 10;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
}
.panier-barre .wrap { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 0; }
.panier-barre .total { font-family: var(--titre); font-weight: 800; font-size: 1.2rem; }
.choix-paiement label { display: flex; gap: 10px; align-items: flex-start; font-weight: 500; padding: 10px 12px; border: 1px solid #CFC9C1; border-radius: var(--r-petit); margin-bottom: 8px; background: #fff; cursor: pointer; }
.choix-paiement input { margin-top: 4px; }
.etapes { display: flex; gap: 4px; margin: 12px 0; }
.etapes span { flex: 1; height: 6px; border-radius: 3px; background: var(--trait); }
.etapes span.on { background: var(--ember); }
.hp { position: absolute; left: -9999px; }

/* Barres de stats */
.barre { display: grid; grid-template-columns: 54px 1fr 44px; gap: 8px; align-items: center; font-size: .88rem; margin-bottom: 4px; }
.barre .b { height: 16px; background: var(--fumee); border-radius: 3px; overflow: hidden; }
.barre .b i { display: block; height: 100%; background: var(--ember); }

@media (prefers-reduced-motion: no-preference) {
  .ticket.nouveau { animation: arrive .6s ease-out; }
  @keyframes arrive { from { transform: translateY(-6px); background: var(--jaune-clair); } to { transform: none; } }
}
@media print { .topbar, .nav, .no-print { display: none !important; } body { background: #fff; } }
