/* ------------------------------------------------------------------
   Identité : une carte de restaurant. Vert profond, safran, filets
   pointillés entre le nom du plat et son prix.
   Police : celle du système (Segoe UI, Roboto, San Francisco...).
   Aucune police à télécharger : lisible partout et rapide en réseau faible.
------------------------------------------------------------------- */
:root {
  --ink: #10241d;
  --leaf: #1f6b4f;
  --paper: #f3f5f0;
  --card: #ffffff;
  --line: #d6dcd3;
  --muted: #55655d;
  --saffron: #f2a900;
  --saffron-dark: #c98a00;
  --on-saffron: #2b2000;
  --chili: #b8321f;
  --ok: #1d7a4e;
  --radius: 10px;
  --font-display: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.5;
}
h1, h2, h3 { font-family: var(--font-display); line-height: 1.2; margin: 0; letter-spacing: -.01em; }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }
:focus-visible { outline: 3px solid var(--saffron); outline-offset: 2px; }
[hidden] { display: none !important; }

.wrap { max-width: 760px; margin: 0 auto; padding: 0 16px; }
.wrap-wide { max-width: 1280px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ----- Boutons ----- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px;
  border: 2px solid var(--ink); border-radius: var(--radius);
  background: transparent; font-weight: 700; cursor: pointer; text-decoration: none;
}
.btn:hover { background: rgba(16, 36, 29, .07); }
.btn-primary { background: var(--saffron); border-color: var(--saffron); color: var(--on-saffron); }
.btn-primary:hover { background: var(--saffron-dark); border-color: var(--saffron-dark); }
.btn-dark { background: var(--ink); color: var(--paper); }
.btn-dark:hover { background: #1b3a2f; }
.btn-danger { border-color: var(--chili); color: var(--chili); }
.btn-danger:hover { background: rgba(184, 50, 31, .08); }
.btn-small { min-height: 36px; padding: 0 12px; font-size: .9rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-block { width: 100%; }

/* ----- Formulaires ----- */
.field { display: grid; gap: 4px; margin-bottom: 14px; }
.field label { font-weight: 600; font-size: .92rem; }
.field input, .field select, .field textarea {
  width: 100%; min-height: 44px; padding: 8px 12px;
  background: #fff; border: 2px solid var(--line); border-radius: var(--radius);
}
.field textarea { min-height: 76px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--leaf); outline: none; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; font-weight: 600; }
.check input { width: 22px; height: 22px; accent-color: var(--leaf); }
.form-error { color: var(--chili); font-weight: 600; min-height: 1.4em; margin: 0 0 8px; }
.trap { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.banner { padding: 12px 16px; font-weight: 600; text-align: center; }
.banner-error { background: var(--chili); color: #fff; }
.banner-info { background: var(--saffron); color: var(--on-saffron); }
.banner a { color: inherit; }

/* ===================== Espace client ===================== */
.masthead { background: var(--ink); color: var(--paper); padding: 28px 0 22px; }
.masthead h1 { font-size: clamp(1.9rem, 7vw, 2.8rem); font-weight: 800; letter-spacing: -.02em; }
.masthead .wrap { position: relative; }
.masthead p { margin: 6px 0 0; color: #b9cbc2; max-width: 40ch; }
.table-pill {
  display: inline-block; margin-top: 14px; padding: 4px 12px;
  border: 2px solid var(--saffron); border-radius: 99px; color: var(--saffron); font-weight: 700;
}

.tabs {
  position: sticky; top: 0; z-index: 5; background: var(--paper);
  border-bottom: 2px solid var(--ink); overflow-x: auto; white-space: nowrap;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs a {
  display: inline-block; padding: 12px 14px; font-weight: 700; color: var(--ink);
  text-decoration: none; border-bottom: 4px solid transparent; margin-bottom: -2px;
}
.tabs a:hover, .tabs a.active { border-bottom-color: var(--saffron); }

.menu { padding-bottom: 120px; }
.menu section { padding-top: 28px; scroll-margin-top: 56px; }
.menu h2 { font-size: 1.6rem; margin-bottom: 6px; }
.dishes { list-style: none; margin: 0; padding: 0; }
.dish { display: flex; gap: 14px; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--line); }
.dish-photo { width: 72px; height: 72px; border-radius: var(--radius); object-fit: cover; flex: none; background: var(--line); }
.dish-main { flex: 1; min-width: 0; }
.dish-head { display: flex; align-items: baseline; gap: 8px; }
.dish-name { font-weight: 700; font-size: 1.05rem; }
.leader { flex: 1; min-width: 14px; border-bottom: 2px dotted #94a399; transform: translateY(-4px); }
.dish-price { font-weight: 800; white-space: nowrap; }
.dish-desc { margin: 2px 0 0; color: var(--muted); font-size: .92rem; max-width: 52ch; }
.dish.is-out .dish-name, .dish.is-out .dish-price { color: var(--muted); text-decoration: line-through; }
.tag-out { color: var(--chili); font-weight: 700; font-size: .9rem; }
.dish-ctl { flex: none; display: flex; align-items: center; }

.stepper { display: inline-flex; align-items: center; border: 2px solid var(--ink); border-radius: var(--radius); overflow: hidden; }
.stepper button { width: 40px; height: 40px; border: 0; background: transparent; font-size: 1.3rem; font-weight: 800; cursor: pointer; }
.stepper button:hover { background: rgba(16, 36, 29, .08); }
.stepper output { min-width: 32px; text-align: center; font-weight: 800; }
.add-btn {
  width: 44px; height: 44px; border-radius: var(--radius); border: 0; cursor: pointer;
  background: var(--saffron); color: var(--on-saffron); font-size: 1.6rem; font-weight: 800; line-height: 1;
}
.add-btn:hover { background: var(--saffron-dark); }

.cartbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: var(--ink);
}
.cartbar .btn { width: 100%; max-width: 728px; margin: 0 auto; display: flex; justify-content: space-between; }

dialog { border: 0; padding: 0; border-radius: 14px; width: min(560px, 94vw); max-height: 92vh; color: var(--ink); background: var(--card); }
dialog::backdrop { background: rgba(16, 36, 29, .6); }
.dlg-body { padding: 20px; }
.dlg-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.dlg-head h2 { font-size: 1.4rem; }
.icon-btn { width: 44px; height: 44px; border: 0; background: transparent; font-size: 1.6rem; cursor: pointer; border-radius: var(--radius); }
.icon-btn:hover { background: rgba(16, 36, 29, .08); }

.cart-lines { list-style: none; margin: 0 0 14px; padding: 0; }
.cart-line { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.cart-line .name { flex: 1; font-weight: 600; }
.cart-line .sum { min-width: 92px; text-align: right; font-weight: 700; }
.cart-total { display: flex; justify-content: space-between; font-size: 1.25rem; font-weight: 800; padding: 8px 0 16px; }
.pay-note { background: rgba(242, 169, 0, .18); border-left: 5px solid var(--saffron); padding: 10px 12px; margin: 0 0 16px; border-radius: 4px; }

/* ===================== Suivi de commande ===================== */
.ticket { background: var(--card); border: 2px solid var(--ink); border-radius: 14px; padding: 22px; margin: 24px 0; }
.ticket-number { font-family: var(--font-display); font-weight: 800; font-size: clamp(3rem, 16vw, 5rem); line-height: 1; }
.status-now { font-size: 1.3rem; font-weight: 800; margin: 12px 0 4px; }
.status-now.is-ready { color: var(--ok); }
.status-now.is-cancelled { color: var(--chili); }
.steps { list-style: none; display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 18px 0 0; padding: 0; }
.steps li { border-top: 6px solid var(--line); padding-top: 6px; font-size: .85rem; font-weight: 600; color: var(--muted); }
.steps li.done { border-top-color: var(--leaf); color: var(--ink); }
.steps li.current { border-top-color: var(--saffron); color: var(--ink); }
.order-lines { list-style: none; padding: 0; margin: 18px 0 0; }
.order-lines li { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px dotted var(--line); }

/* ===================== Connexion ===================== */
.login { max-width: 420px; margin: 12vh auto 0; padding: 24px; background: var(--card); border: 2px solid var(--ink); border-radius: 14px; }
.login h1 { font-size: 1.8rem; margin-bottom: 4px; }

/* ===================== Espace personnel ===================== */
.topbar { background: var(--ink); color: var(--paper); }
.topbar .wrap-wide { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding-top: 12px; padding-bottom: 12px; }
.topbar h1 { font-size: 1.3rem; margin-right: auto; }
.topbar .btn { border-color: #6c8479; color: var(--paper); }
.topbar .btn:hover { background: rgba(255, 255, 255, .1); }
.topbar .btn[aria-pressed="true"] { background: var(--saffron); border-color: var(--saffron); color: var(--on-saffron); }
.live { display: inline-flex; align-items: center; gap: 6px; font-size: .9rem; color: #b9cbc2; }
.live i { width: 10px; height: 10px; border-radius: 50%; background: #7a8c83; }
.live.on i { background: #38d27c; }

.board { display: grid; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); gap: 16px; padding: 18px 0 60px; align-items: start; }
.col h2 { font-size: 1.1rem; padding: 8px 12px; border-radius: var(--radius) var(--radius) 0 0; background: var(--ink); color: var(--paper); display: flex; justify-content: space-between; }
.col[data-status="en_attente"] h2 { background: var(--saffron); color: var(--on-saffron); }
.col[data-status="prete"] h2 { background: var(--leaf); }
.col-body { display: grid; gap: 12px; padding: 12px; background: rgba(16, 36, 29, .06); border-radius: 0 0 var(--radius) var(--radius); min-height: 90px; }
.col-empty { color: var(--muted); text-align: center; padding: 14px 0; margin: 0; }
.tk { background: var(--card); border: 2px solid var(--ink); border-radius: var(--radius); padding: 12px; }
.tk.is-new { animation: flash 1.6s ease-out 1; }
@keyframes flash { from { background: #ffe9a8; } to { background: var(--card); } }
@media (prefers-reduced-motion: reduce) { .tk.is-new { animation: none; } }
.tk-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.tk-num { font-family: var(--font-display); font-weight: 800; font-size: 1.7rem; }
.tk-meta { color: var(--muted); font-size: .9rem; margin: 0 0 8px; }
.tk-lines { list-style: none; margin: 0 0 8px; padding: 0; }
.tk-lines li { display: flex; gap: 8px; padding: 2px 0; }
.tk-lines b { min-width: 28px; }
.tk-note { background: #fff4d1; border-radius: 6px; padding: 6px 8px; margin: 0 0 8px; font-weight: 600; }
.tk-total { font-weight: 800; margin: 0 0 10px; }
.tk-actions { display: flex; gap: 8px; }
.tk-actions .btn:first-child { flex: 1; }

.done-box { margin: 0 0 60px; }
.done-box summary { cursor: pointer; font-weight: 700; padding: 10px 0; }
.done-list { list-style: none; margin: 0; padding: 0; }
.done-list li { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line); }

/* ===================== Administration ===================== */
.admin-grid { display: grid; gap: 28px; padding: 22px 0 80px; }
.panel { background: var(--card); border: 2px solid var(--ink); border-radius: 14px; padding: 18px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.panel-head h2 { font-size: 1.3rem; }
.rows { list-style: none; margin: 0; padding: 0; }
.row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.row .grow { flex: 1; min-width: 0; }
.row .title { font-weight: 700; }
.row-thumb { width: 52px; height: 52px; border-radius: 8px; object-fit: cover; background: var(--line); flex: none; }
.row-actions { display: flex; gap: 6px; }
.cat-title { margin: 18px 0 4px; font-size: 1.05rem; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 99px; background: var(--line); font-size: .8rem; font-weight: 700; }
.pill.out { background: rgba(184, 50, 31, .15); color: var(--chili); }
.preview { width: 120px; height: 120px; border-radius: var(--radius); object-fit: cover; background: var(--line); margin-bottom: 8px; }

.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); z-index: 30;
  background: var(--ink); color: var(--paper); padding: 10px 18px; border-radius: 99px; font-weight: 600;
  max-width: 92vw; text-align: center;
}
.toast.error { background: var(--chili); }

@media (max-width: 480px) {
  .field-row { grid-template-columns: 1fr; }
  .dish-photo { width: 60px; height: 60px; }
}

/* ===================== v2 : mode de commande, ventes, réseau faible ===================== */
.choice { border: 0; margin: 0 0 14px; padding: 0; display: flex; gap: 10px; flex-wrap: wrap; }
.choice legend { font-weight: 600; font-size: .92rem; padding: 0; margin-bottom: 6px; }
.radio {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 16px;
  border: 2px solid var(--line); border-radius: var(--radius); font-weight: 700; cursor: pointer; background: #fff;
}
.radio:has(input:checked) { border-color: var(--leaf); background: rgba(31, 107, 79, .08); }
.radio input { width: 20px; height: 20px; accent-color: var(--leaf); }
.stale { background: rgba(242, 169, 0, .2); border-left: 5px solid var(--saffron); padding: 10px 12px; margin: 16px 0 0; border-radius: 4px; font-weight: 600; }

.sales-filters { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.sales-filters .field { margin-bottom: 0; }
.sales-filters .btn { min-width: 120px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin: 14px 0 6px; }
.stat { border: 2px solid var(--ink); border-radius: var(--radius); padding: 12px 14px; background: var(--paper); }
.stat-value { font-family: var(--font-display); font-weight: 800; font-size: 1.45rem; line-height: 1.2; }
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; min-width: 320px; }
table.data th, table.data td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; }
table.data th { font-weight: 700; border-bottom: 2px solid var(--ink); }
table.data .r { text-align: right; }

/* ===================== v3 : options, Mobile Money, langue, impression ===================== */
.lang-btn {
  position: absolute; top: -14px; right: 16px; min-width: 44px; min-height: 36px; padding: 0 10px;
  border: 2px solid #6c8479; border-radius: var(--radius); background: transparent; color: var(--paper);
  font-weight: 700; cursor: pointer;
}
.lang-btn:hover { background: rgba(255, 255, 255, .1); }
.ctl-opts { display: flex; align-items: center; gap: 8px; }
.in-cart { font-size: .85rem; font-weight: 700; color: var(--leaf); white-space: nowrap; }
.opt-check { border-bottom: 1px solid var(--line); }
.opt-check .grow { flex: 1; }
.line-opts { display: block; font-weight: 400; }
.mm-box { background: rgba(31, 107, 79, .08); border-left: 5px solid var(--leaf); border-radius: 4px; padding: 10px 12px; margin: 0 0 14px; }
.mm-box p { margin: 0 0 10px; }
.mm-box .field { margin-bottom: 0; }
.notify-hint { margin: 12px 0 0; }
.ticket .btn-small { margin-top: 12px; }

.opt-add { display: grid; grid-template-columns: 1fr 110px auto; gap: 8px; margin-top: 8px; }
.opt-add input { min-height: 40px; padding: 6px 10px; border: 2px solid var(--line); border-radius: var(--radius); width: 100%; }

.tk-opts { display: block; color: var(--muted); font-size: .85rem; }
.tk-pay { background: rgba(31, 107, 79, .12); border-radius: 6px; padding: 6px 8px; margin: 0 0 8px; font-weight: 700; }
.tk-pay small { display: block; font-weight: 400; color: var(--muted); }
.tk-actions { flex-wrap: wrap; }

/* Ticket imprimé : visible uniquement à l'impression */
#print-area { display: none; }
@media print {
  @page { margin: 4mm; }
  body > *:not(#print-area) { display: none !important; }
  body { background: #fff; }
  #print-area { display: block; width: 72mm; margin: 0; color: #000; font-size: 12px; line-height: 1.35; }
  #print-area p { margin: 0 0 4px; }
  #print-area .pt-name { font-weight: 800; font-size: 15px; text-align: center; }
  #print-area .pt-num { font-weight: 800; font-size: 30px; text-align: center; line-height: 1.1; }
  #print-area .pt-bold { font-weight: 700; }
  #print-area .pt-line { display: flex; justify-content: space-between; gap: 8px; padding: 2px 0; }
  #print-area small { display: block; font-size: 11px; }
  #print-area hr { border: 0; border-top: 1px dashed #000; margin: 6px 0; }
}

@media (max-width: 480px) {
  .opt-add { grid-template-columns: 1fr 90px; }
  .opt-add .btn { grid-column: 1 / -1; }
}
