:root {
  --brand: #c2410c;
  --brand-dark: #9a3412;
  --brand-soft: #fff7ed;
  --bg: #f6f5f3;
  --card: #ffffff;
  --text: #1c1917;
  --muted: #78716c;
  --line: #e7e5e4;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 4px 14px rgba(0, 0, 0, .05);

  --new: #2563eb;
  --prep: #d97706;
  --ready: #16a34a;
  --pack: #0891b2;
  --out: #7c3aed;
  --done: #78716c;
  --cancel: #dc2626;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3 { margin: 0 0 .6em; line-height: 1.2; }
h2 { font-size: 1.1rem; }
h3 { font-size: .95rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
a { color: var(--brand); }
.muted { color: var(--muted); }
.hidden { display: none !important; }
.loading { display: grid; place-items: center; min-height: 100vh; color: var(--muted); }

/* Boutons et champs */
.btn {
  appearance: none; touch-action: manipulation; user-select: none; -webkit-user-select: none; border: 1px solid var(--line); background: #fff; color: var(--text);
  border-radius: 10px; padding: .6em 1em; font: inherit; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: .4em;
  text-decoration: none; min-height: 42px; white-space: nowrap;
}
@media (hover: hover) { .btn:hover { border-color: #d6d3d1; background: #fafaf9; } }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
@media (hover: hover) { .btn.primary:hover { background: var(--brand-dark); } }
.btn.success { background: var(--ready); border-color: var(--ready); color: #fff; }
.btn.warn { background: var(--prep); border-color: var(--prep); color: #fff; }
.btn.purple { background: var(--out); border-color: var(--out); color: #fff; }
.btn.danger { color: var(--cancel); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.small { min-height: 32px; padding: .3em .7em; font-size: .9em; }
.btn.big { min-height: 56px; font-size: 1.1rem; width: 100%; }

label { display: block; font-weight: 600; font-size: .85rem; color: #44403c; margin-bottom: .75rem; }
input, select, textarea {
  display: block; width: 100%; margin-top: .3rem; font: inherit; font-weight: 400;
  padding: .6em .75em; border: 1px solid #d6d3d1; border-radius: 10px; background: #fff; color: var(--text);
  min-height: 44px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #fdba74; border-color: var(--brand); }
textarea { min-height: 64px; resize: vertical; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.row { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.spacer { flex: 1; }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem; }

/* Barre du haut */
.topbar {
  position: -webkit-sticky; position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 1rem;
  background: #fff; border-bottom: 1px solid var(--line); padding: .5rem 1rem;
  padding-top: max(.5rem, env(safe-area-inset-top));
}
.brand { display: flex; align-items: center; gap: .5rem; font-weight: 800; font-size: 1.1rem; }
.brand img { width: 30px; height: 30px; }
.post { font-weight: 600; color: var(--muted); }
.tabs { display: flex; gap: .25rem; overflow-x: auto; scrollbar-width: none; }
.tabs button {
  border: 0; touch-action: manipulation; background: transparent; font: inherit; font-weight: 600; color: var(--muted);
  padding: .5em .8em; border-radius: 8px; cursor: pointer; white-space: nowrap;
}
.tabs button.active { background: var(--brand-soft); color: var(--brand); }
.me { margin-left: auto; display: flex; align-items: center; gap: .5rem; font-weight: 600; white-space: nowrap; }
.conn { width: 10px; height: 10px; border-radius: 50%; background: var(--cancel); }
.conn.on { background: var(--ready); }

main { padding: 1rem; padding-bottom: max(1rem, env(safe-area-inset-bottom)); max-width: 1500px; margin: 0 auto; }

/* Connexion */
.login { min-height: 100vh; display: grid; place-items: center; padding: 1rem; background: var(--brand-soft); }
.login-card { width: 100%; max-width: 440px; text-align: center; }
.login-card .brand { justify-content: center; font-size: 1.6rem; margin-bottom: .25rem; }
.login-card .brand img { width: 44px; height: 44px; }
.staff-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: .6rem; margin-top: 1rem; }
.staff-btn {
  border: 1px solid var(--line); background: #fff; border-radius: 12px; padding: .9rem .5rem; cursor: pointer;
  font: inherit; display: flex; flex-direction: column; align-items: center; gap: .2rem;
}
@media (hover: hover) { .staff-btn:hover { border-color: var(--brand); } }
.staff-btn small { color: var(--muted); }
.role-dot { width: 12px; height: 12px; border-radius: 50%; }
.r-admin { background: var(--text); }
.r-telephone { background: var(--new); }
.r-cuisine { background: var(--prep); }
.r-emballage { background: var(--pack); }
.r-livreur { background: var(--out); }
.pin-dots { display: flex; justify-content: center; gap: .8rem; margin: 1rem 0; }
.pin-dots span { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--brand); }
.pin-dots span.full { background: var(--brand); }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; max-width: 300px; margin: 0 auto; }
.keypad button {
  touch-action: manipulation; user-select: none; -webkit-user-select: none;
  font: inherit; font-size: 1.5rem; font-weight: 600; min-height: 64px; border-radius: 14px;
  border: 1px solid var(--line); background: #fff; cursor: pointer;
}
.keypad button:active { background: var(--brand-soft); }
.error { color: var(--cancel); font-weight: 600; min-height: 1.4em; margin-top: .5rem; }

/* Commandes */
.order {
  background: #fff; border-radius: 12px; border: 1px solid var(--line); border-left: 5px solid var(--muted);
  padding: .75rem .85rem; margin-bottom: .65rem;
}
.order.s-new { border-left-color: var(--new); }
.order.s-prep { border-left-color: var(--prep); }
.order.s-ready { border-left-color: var(--ready); }
.order.s-pack { border-left-color: var(--pack); }
.order.s-out { border-left-color: var(--out); }
.order.s-cancel { opacity: .6; border-left-color: var(--cancel); }
.order.flash { animation: flash 1.2s ease-out 2; }
@keyframes flash { 0% { box-shadow: 0 0 0 4px #fdba74; } 100% { box-shadow: none; } }
.order header { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin-bottom: .35rem; }
.order .num { font-weight: 800; font-size: 1.15rem; }
.order .who, .order .addr { margin: .15rem 0; }
.order .addr small { display: block; color: var(--muted); }
.order .addr .warn { color: var(--prep); }   /* ne doit pas toucher le bouton .btn.warn « Commencer » */
.order .items { list-style: none; margin: .4rem 0; padding: 0; }
.order .items li { padding: .1rem 0; }
.order .notes { background: #fef3c7; border-radius: 8px; padding: .35rem .5rem; margin: .35rem 0; font-size: .92em; }
.order .meta { display: flex; justify-content: space-between; gap: .5rem; flex-wrap: wrap; color: var(--muted); font-size: .9em; }
.order footer { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .6rem; }
.order footer .btn { flex: 1; }
.order footer select { flex: 2; margin: 0; min-height: 42px; }
.order.big .items { font-size: 1.25rem; }
.order.big .num { font-size: 1.5rem; }
.badge { font-size: .75rem; font-weight: 700; padding: .15em .55em; border-radius: 99px; color: #fff; background: var(--muted); }
.badge.s-new { background: var(--new); }
.badge.s-prep { background: var(--prep); }
.badge.s-ready { background: var(--ready); }
.badge.s-pack { background: var(--pack); }
.badge.s-out { background: var(--out); }
.badge.s-cancel { background: var(--cancel); }
.wanted { font-weight: 700; color: var(--brand); }
.age { font-size: .85em; font-weight: 700; color: var(--muted); }
.age.late { color: var(--cancel); }
.empty { color: var(--muted); text-align: center; padding: 1.2rem .5rem; border: 1px dashed var(--line); border-radius: 12px; margin-bottom: .65rem; }

/* Téléphone */
.tel-layout { display: grid; grid-template-columns: minmax(340px, 520px) minmax(340px, 1fr); gap: 1rem; align-items: start; }
.side { display: grid; gap: 1rem; }
.ac { position: relative; }
.ac-list {
  position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 4px); margin: 0; padding: .3rem; list-style: none;
  background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); font-weight: 400;
}
.ac-list li { padding: .6rem .6rem; border-radius: 8px; cursor: pointer; }
.ac-list li small { color: var(--muted); display: block; }
.ac-list li.active { background: var(--brand-soft); }
@media (hover: hover) { .ac-list li:hover { background: var(--brand-soft); } }
.geo-status { font-size: .85rem; font-weight: 600; }
.geo-status.ok { color: var(--ready); }
.geo-status.ko { color: var(--prep); }
.hint { background: #eff6ff; color: #1e40af; border-radius: 10px; padding: .5rem .7rem; font-size: .9rem; margin: -.25rem 0 .75rem; }
.pick-map { height: 180px; border-radius: 10px; overflow: hidden; margin-bottom: .75rem; background: #eee; }
.menu-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: .45rem; margin-bottom: .75rem; }
.menu-grid .cat { grid-column: 1 / -1; font-size: .8rem; font-weight: 700; color: var(--muted); text-transform: uppercase; margin-top: .3rem; }
.menu-btn {
  touch-action: manipulation; user-select: none; -webkit-user-select: none;
  border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: .55rem; text-align: left; cursor: pointer;
  font: inherit; min-height: 56px;
}
@media (hover: hover) { .menu-btn:hover { border-color: var(--brand); background: var(--brand-soft); } }
.menu-btn b { display: block; font-size: .9rem; }
.menu-btn span { color: var(--muted); font-size: .85rem; }
.cart { border: 1px solid var(--line); border-radius: 10px; margin-bottom: .75rem; }
.cart-line { display: flex; align-items: center; gap: .5rem; padding: .45rem .6rem; border-bottom: 1px solid var(--line); }
.cart-line:last-child { border-bottom: 0; }
.cart-line .name { flex: 1; }
.qty { display: flex; align-items: center; gap: .3rem; }
.qty button { touch-action: manipulation; width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--line); background: #fff; font-size: 1.1rem; cursor: pointer; }
.qty b { min-width: 1.5em; text-align: center; }
.free-item { display: grid; grid-template-columns: 1fr 100px auto; gap: .4rem; margin-bottom: .75rem; align-items: end; }
.free-item input { margin: 0; }
.total-row { display: flex; justify-content: space-between; font-size: 1.25rem; margin: .5rem 0 1rem; }

/* Cartes */
.map { height: 420px; border-radius: 12px; overflow: hidden; background: #eee; }
/* Leaflet place le coin haut-gauche du repère sur le point : on le recentre. */
.pin-icon { width: auto !important; height: auto !important; }
.pin-icon .pin { display: inline-block; transform: translate(-50%, -50%); }
/* Sans contexte d'empilement, les couches Leaflet passeraient par-dessus la barre du haut. */
.map, .pick-map { position: relative; z-index: 0; }
.leaflet-container { font: inherit; background: #e8e6e1; }
.leaflet-control-attribution { font-size: 10px; }

.map-empty { height: 100%; display: grid; place-items: center; text-align: center; color: var(--muted); padding: 1rem; }
.pin {
  background: var(--muted); color: #fff; font-weight: 800; font-size: 13px; padding: 4px 8px; border-radius: 99px;
  border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .3); white-space: nowrap;
}
.pin.s-new { background: var(--new); }
.pin.s-prep { background: var(--prep); }
.pin.s-ready { background: var(--ready); }
.pin.s-pack { background: var(--pack); }
.pin.s-out { background: var(--out); }
.pin.resto { background: var(--brand); font-size: 15px; }
.pin.driver { background: #111827; }
.pin.here { background: var(--brand); }

/* Cuisine */
.kanban { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; align-items: start; }
.kanban.four { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.col-title { display: flex; align-items: center; gap: .5rem; margin-bottom: .6rem; }
.col-title .count { background: var(--line); border-radius: 99px; padding: 0 .55em; font-size: .85rem; }

/* Mains libres (cuisine) */
.voice-bar { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin-bottom: 1rem; }
.voice-bar .conn.on { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .25; transform: scale(.8); } }
.voice-help { font-size: .9rem; color: var(--muted); }
.voice-help summary { cursor: pointer; }
.voice-help ul { margin: .5rem 0 0; padding-left: 1.1rem; }
.voice-help b { color: var(--text); }

/* Livreur */
.livreur-layout { display: grid; grid-template-columns: minmax(320px, 480px) 1fr; gap: 1rem; align-items: start; }
.gps-bar { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; margin-bottom: 1rem; }
.switch { display: flex; align-items: center; gap: .5rem; margin: 0; font-size: 1rem; cursor: pointer; }
.switch input { width: 22px; height: 22px; min-height: 0; margin: 0; accent-color: var(--brand); }

/* Suivi */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1rem; }
.stat { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: .9rem 1rem; }
.stat small { color: var(--muted); font-weight: 600; }
.stat b { display: block; font-size: 1.6rem; font-variant-numeric: tabular-nums; }
.suivi-layout { display: grid; gap: 1rem; }

/* Admin tables */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: .8rem; color: var(--muted); text-transform: uppercase; padding: .4rem; }
.table td { padding: .35rem .4rem; border-top: 1px solid var(--line); vertical-align: middle; }
.table input, .table select { margin: 0; min-height: 38px; }
.table input[type=checkbox] { width: 20px; height: 20px; min-height: 0; accent-color: var(--brand); }
.admin-wrap { max-width: 900px; margin: 0 auto; display: grid; gap: 1rem; }
.add-form { display: grid; grid-template-columns: 2fr 1.5fr 1fr auto; gap: .5rem; align-items: end; }
.add-form label { margin: 0; }

.attente { align-self: center; color: var(--ready); font-weight: 600; font-size: .9em; }
.reste { align-self: center; color: var(--prep); font-weight: 600; font-size: .9em; }

.plats-preferes { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: 1rem; }
.plats-preferes .plat { background: var(--brand-soft); border-radius: 10px; padding: .35rem .6rem; }
.plats-preferes .plat small { display: block; color: var(--muted); }
.sans-gap .plats-preferes .plat { margin: 0 .4rem .4rem 0; }

/* Stock marchandise. */
.stock-liste { display: grid; gap: .4rem; margin-bottom: 1rem; }
.stock-ligne { display: grid; grid-template-columns: 1fr auto auto auto; gap: .6rem; align-items: center;
  background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--ready); border-radius: 10px; padding: .5rem .7rem; }
.stock-ligne.manque { border-left-color: var(--cancel); background: #fef7f7; }
.stock-ligne.inactif { opacity: .5; }
.stock-nom small { display: block; }
.stock-qte { font-size: 1.15rem; white-space: nowrap; }
.stock-ligne .qty input.pas { width: 62px; margin: 0; min-height: 34px; padding: .2em .3em; text-align: center; }
.stock-actions { display: flex; gap: .3rem; }
.stock-edition { background: var(--brand-soft); border-radius: 0 0 10px 10px; padding: .7rem; margin: -.4rem 0 .5rem; display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .5rem; align-items: end; }
.stock-edition label { margin: 0; }
.sans-gap .stock-actions > * + * { margin-left: .3rem; }

.ok-bandeau { background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534; border-radius: 10px; padding: .5rem .8rem; margin-bottom: .8rem; font-weight: 600; }
.stat b.rouge { color: var(--cancel); }
@media (max-width: 640px) {
  .stock-ligne { grid-template-columns: 1fr auto; }
  .stock-ligne .qty, .stock-ligne [data-histo] { grid-column: 1 / -1; justify-self: start; }
}

/* Graphiques : une grandeur, une seule couleur ; la longueur porte l'information. */
.barres { display: grid; gap: .3rem; }
.barre-ligne { display: grid; grid-template-columns: 5.5rem 1fr auto; align-items: center; gap: .6rem; padding: .15rem 0; }
.barre-nom { font-weight: 600; font-size: .9rem; }
.barre-piste { background: #f1efec; border-radius: 4px; height: 20px; overflow: hidden; }
.barre-remplie { display: block; height: 100%; background: #fdba74; border-radius: 4px; }
.barre-ligne.meilleur .barre-remplie { background: var(--brand); }
.barre-valeur { font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; font-size: .9rem; }
.barre-valeur small { font-weight: 400; color: var(--muted); }
.lecture { list-style: none; padding: 0; margin: .5rem 0 0; display: grid; gap: .5rem; }
.lecture li { background: var(--brand-soft); border-radius: 10px; padding: .6rem .8rem; }
.sans-gap .barre-ligne > * + * { margin-left: .6rem; }
@media (max-width: 640px) {
  .barre-ligne { grid-template-columns: 4.2rem 1fr; }
  .barre-valeur { grid-column: 2; text-align: right; }
}

/* Fidélité et fiches clients. */
.fidelite { background: #f0fdf4; border: 1px solid #bbf7d0; border-radius: 10px; padding: .6rem .75rem; margin-bottom: .75rem; display: grid; gap: .5rem; }
.fidelite.pale { background: #fafaf9; border-color: var(--line); color: var(--muted); }
.fidelite .qty span { font-weight: 600; margin-left: .3rem; }
.total-row.petite { font-size: 1rem; margin: .15rem 0; color: var(--muted); }
.remise { color: var(--ready); font-weight: 700; }
.table .nombre { text-align: right; white-space: nowrap; }
.table.clients tr[data-client] { cursor: pointer; }
.table.clients tr.ouvert, .table.clients tr[data-client]:hover { background: var(--brand-soft); }
.mouvements { list-style: none; padding: 0; margin: 0; }
.mouvements li { padding: .3rem 0; border-top: 1px solid var(--line); }
.mouvements .plus { color: var(--ready); }
.mouvements .moins { color: var(--cancel); }
.admin-wrap.large { max-width: 1200px; }

/* Récapitulatif de la soirée du livreur. */
.recap { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: .6rem; margin-bottom: 1rem; }
.recap .stat { padding: .6rem .7rem; }
.recap .stat b { font-size: 1.25rem; }
.livree-a { align-self: center; color: var(--muted); font-weight: 600; font-size: .9em; margin-right: auto; }

/* Cuisine : chaque plat se coche au fur et à mesure. */
.coche { display: flex; align-items: center; gap: .6rem; margin: 0; padding: .25rem 0; font-weight: 400; cursor: pointer; }
.coche input { width: 26px; height: 26px; min-height: 0; margin: 0; flex: none; accent-color: var(--ready); }
.coche.faite span { text-decoration: line-through; color: var(--muted); }
.order .items .deja { color: var(--ready); font-weight: 700; }
.avancement { font-weight: 800; font-size: .95rem; color: var(--prep); background: #fff7ed; border-radius: 99px; padding: .05em .55em; }
.avancement.complet { color: #fff; background: var(--ready); }
.btn.tout-pret { animation: respire 1.4s ease-in-out infinite; }
@keyframes respire { 50% { box-shadow: 0 0 0 5px rgba(22, 163, 74, .25); } }
@media (prefers-reduced-motion: reduce) { .btn.tout-pret { animation: none; outline: 3px solid rgba(22, 163, 74, .35); } }

.alerte { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; border-radius: 10px; padding: .6rem .8rem; margin-bottom: .8rem; font-weight: 600; }
.table .badge { margin-left: .4rem; vertical-align: middle; }

details summary { cursor: pointer; font-weight: 600; color: var(--muted); margin: .5rem 0; }

/* Notifications */
#toasts { position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); z-index: 100; display: grid; gap: .5rem; width: min(92vw, 420px); }
.toast { background: #1c1917; color: #fff; padding: .75rem 1rem; border-radius: 12px; box-shadow: var(--shadow); font-weight: 600; animation: up .2s ease-out; }
.toast.error { background: var(--cancel); }
.toast.success { background: var(--ready); }
@keyframes up { from { transform: translateY(10px); opacity: 0; } }

/* ---------------------------------------------------------------------------
   Deux cibles bien distinctes :
   • Cuisine  → tablette (768 à 1366 px) : les 3 colonnes restent visibles le
     plus longtemps possible, le cuisto voit tout le service d'un coup d'œil.
   • Prise de commande et livreur → smartphone, souvent d'une seule main et
     en extérieur : une colonne, gros boutons, rien de coupé.
   --------------------------------------------------------------------------- */

/* Cibles tactiles : tout ce qui se touche fait au moins ~44 px */
@media (pointer: coarse) {
  .btn.small { min-height: 40px; padding: .45em .8em; }
  .qty button { width: 44px; height: 44px; font-size: 1.25rem; }
  .table input[type=checkbox], .switch input { width: 26px; height: 26px; }
  .table input, .table select { min-height: 44px; }
  .ac-list li { padding: .8rem .6rem; }
  details summary { padding: .35rem 0; }
}

/* Tablette paysage */
@media (max-width: 1100px) {
  .kanban.four { grid-template-columns: repeat(2, 1fr); }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .livreur-layout { grid-template-columns: minmax(300px, 400px) 1fr; }
}

/* Tablette portrait : cuisine toujours en 3 colonnes, cartes resserrées */
@media (max-width: 900px) {
  main { padding: .75rem; }
  .kanban { gap: .55rem; }
  .kanban.four { grid-template-columns: repeat(2, 1fr); }
  .order { padding: .6rem .65rem; margin-bottom: .55rem; }
  .order.big .items { font-size: 1.1rem; }
  .order.big .num { font-size: 1.35rem; }
  .order footer { gap: .35rem; }
  .order footer .btn { padding: .6em .5em; }
  .livreur-layout { grid-template-columns: 1fr; }
  .map { height: 340px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .table .hide-sm { display: none; }
  .add-form { grid-template-columns: 1fr 1fr; }
}

/* Cuisine : chaque colonne défile de son côté, le titre reste visible.
   Les 3 colonnes tiennent ainsi dans la hauteur de la tablette. */
@media (min-width: 700px) and (min-height: 600px) {
  .kanban > section {
    max-height: calc(100dvh - 12rem);
    overflow-y: auto;
    overscroll-behavior: contain;
    padding-right: .2rem;
  }
  .kanban .col-title {
    position: -webkit-sticky; position: sticky; top: 0; z-index: 1;
    background: var(--bg); padding: .2rem 0 .35rem; margin-bottom: .3rem;
  }
}

/* Petites tablettes portrait : 2 colonnes plutôt qu'une longue liste */
@media (max-width: 700px) {
  .kanban { grid-template-columns: repeat(2, 1fr); }
  .kanban.four { grid-template-columns: repeat(2, 1fr); }
  .tel-layout { grid-template-columns: 1fr; }
  .order.big .items { font-size: 1rem; }
}

/* Smartphone : écran de travail de la prise de commande et du livreur */
@media (max-width: 560px) {
  main { padding: .6rem; }
  .kanban, .kanban.four { grid-template-columns: 1fr; }
  .topbar { flex-wrap: wrap; gap: .5rem; padding: .5rem .75rem; }
  .tabs { order: 3; width: 100%; }
  .me span:not(.conn) { max-width: 90px; overflow: hidden; text-overflow: ellipsis; }
  .grid2 { grid-template-columns: 1fr; gap: 0; }
  .add-form { grid-template-columns: 1fr 1fr; }
  .free-item { grid-template-columns: 1fr 80px auto; }
  .stats { grid-template-columns: repeat(2, 1fr); }

  /* Boutons d'action pleine largeur : on vise juste, même en roulant */
  .order footer { flex-direction: column; }
  .order footer .btn, .order footer select { width: 100%; flex: none; min-height: 48px; }
  .order .num { font-size: 1.25rem; }
  .order .who a { font-weight: 700; }

  /* Livreur : la liste d'abord, la carte ensuite et plus courte */
  .map { height: 260px; }

  /* Prise de commande : articles plus gros, panier lisible */
  .menu-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .menu-btn { min-height: 62px; }
  .total-row { font-size: 1.35rem; }
  .pick-map { height: 150px; }
}

/* iOS zoome sur un champ dont le texte fait moins de 16 px : on l'en empêche */
@media (max-width: 900px) {
  input, select, textarea { font-size: 16px; }
}

/* ---- Tablettes anciennes (iOS 12) ----------------------------------------
   Safari 12 n'applique « gap » qu'aux grilles. Sur les rangées flex, on rétablit
   l'espacement avec des marges, uniquement quand le test JS a échoué. */
.sans-gap .row > * + *,
.sans-gap .order header > * + *,
.sans-gap .order footer > * + *,
.sans-gap .order .meta > * + *,
.sans-gap .me > * + *,
.sans-gap .brand > * + *,
.sans-gap .topbar > * + *,
.sans-gap .tabs > * + *,
.sans-gap .col-title > * + *,
.sans-gap .qty > * + *,
.sans-gap .gps-bar > * + * { margin-left: .5rem; }
.sans-gap .coche > * + * { margin-left: .6rem; }
.sans-gap .switch > * + * { margin-left: .5rem; }
.sans-gap .order footer .btn { margin-bottom: .35rem; }
.sans-gap .fidelite > * + * { margin-top: .5rem; }
.sans-gap .pin-dots span + span { margin-left: .8rem; }
