/* Grind back-office — optimisé iPad paysage (1024→1366 px de large) */
:root {
  --bg: #f3f1ec; --card: #ffffff; --ink: #1d1a16; --muted: #7a736a; --line: #e5e0d7;
  --side: #16130f; --side-ink: #cfc8bc; --accent: #ff5a1f; --accent-ink: #fff;
  --ok: #1f9d55; --ok-bg: #e5f5ec; --warn: #c27c0e; --warn-bg: #fdf2de; --bad: #d0342c; --bad-bg: #fde7e5;
  --r: 16px; --tap: 56px;
  --safe-l: env(safe-area-inset-left); --safe-t: env(safe-area-inset-top);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink);
  font: 17px/1.35 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-user-select: none; user-select: none; overscroll-behavior: none; }
input, textarea, select { -webkit-user-select: text; user-select: text; font: inherit; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; touch-action: manipulation; }

#app { display: grid; grid-template-columns: 96px 1fr; height: 100dvh; }
@media (min-width: 1200px) { #app { grid-template-columns: 220px 1fr; } }

/* Barre latérale */
#sidebar { background: var(--side); color: var(--side-ink); display: flex; flex-direction: column;
  padding: calc(16px + var(--safe-t)) 10px 16px calc(10px + var(--safe-l)); gap: 6px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.logo { width: 44px; height: 44px; border-radius: 12px; background: var(--accent); color: #fff;
  display: grid; place-items: center; font-weight: 900; font-size: 24px; flex: none; }
.brand-name { font-weight: 900; letter-spacing: .12em; color: #fff; font-size: 20px; }
#nav { display: flex; flex-direction: column; gap: 4px; flex: 1; overflow-y: auto; }
.nav-item { display: flex; align-items: center; gap: 12px; min-height: var(--tap); padding: 0 14px; border-radius: 14px;
  color: var(--side-ink); font-weight: 600; position: relative; text-align: left; width: 100%; }
.nav-item .ico { font-size: 24px; width: 32px; text-align: center; flex: none; }
.nav-item.active { background: #2b251e; color: #fff; }
.nav-item.active::before { content: ""; position: absolute; left: -10px; top: 12px; bottom: 12px; width: 4px; border-radius: 4px; background: var(--accent); }
.nav-item .badge { margin-left: auto; }
@media (max-width: 1199px) {
  .brand-name, .nav-item .lbl { display: none; }
  .nav-item { justify-content: center; padding: 0; }
  .nav-item .badge { position: absolute; top: 6px; right: 6px; margin: 0; }
  .brand { justify-content: center; padding: 4px 0 18px; }
}

main { display: flex; flex-direction: column; min-width: 0; height: 100dvh; }
#topbar { display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: calc(14px + var(--safe-t)) 28px 10px; }
#topbar h1 { margin: 0; font-size: 28px; letter-spacing: -.01em; }
.top-right { display: flex; align-items: center; gap: 14px; }
#view { flex: 1; overflow-y: auto; padding: 8px 28px 28px; -webkit-overflow-scrolling: touch; }

.muted { color: var(--muted); }
.chip { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 16px; border-radius: 999px;
  background: var(--card); border: 1px solid var(--line); font-weight: 600; }
.badge { background: var(--accent); color: #fff; border-radius: 999px; min-width: 24px; height: 24px; padding: 0 7px;
  font-size: 13px; font-weight: 700; display: inline-grid; place-items: center; }

/* Cartes et grilles */
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, 1fr); } .g3 { grid-template-columns: repeat(3, 1fr); } .g4 { grid-template-columns: repeat(4, 1fr); }
.card { background: var(--card); border-radius: var(--r); padding: 20px; border: 1px solid var(--line); }
.card h2 { margin: 0 0 12px; font-size: 19px; }
.card h3 { margin: 0 0 8px; font-size: 15px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.tile { display: flex; flex-direction: column; gap: 10px; text-align: left; min-height: 150px; transition: transform .08s; }
.tile:active { transform: scale(.98); }
.tile .ico { font-size: 34px; }
.tile .t { font-size: 20px; font-weight: 700; }
.kpi .v { font-size: 34px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi .l { color: var(--muted); font-weight: 600; font-size: 14px; }
.kpi .d { font-size: 14px; font-weight: 600; margin-top: 4px; }
.up { color: var(--ok); } .down { color: var(--bad); }

/* Boutons */
.btn { min-height: var(--tap); padding: 0 22px; border-radius: 14px; font-weight: 700; display: inline-flex;
  align-items: center; justify-content: center; gap: 8px; background: var(--card); border: 1px solid var(--line); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.dark { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn.ok { background: var(--ok); color: #fff; border-color: var(--ok); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.danger { color: var(--bad); }
.btn.sm { min-height: 44px; padding: 0 14px; border-radius: 12px; font-size: 15px; }
.btn:disabled { opacity: .4; }
.btn:active:not(:disabled) { filter: brightness(.94); }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* Onglets segmentés */
.seg { display: inline-flex; background: #e8e4dc; padding: 4px; border-radius: 14px; gap: 4px; }
.seg button { min-height: 46px; padding: 0 18px; border-radius: 11px; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.08); }

/* Checklists */
.progress { height: 10px; background: #ece8e0; border-radius: 10px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--accent); border-radius: 10px; transition: width .25s; }
.progress.full > i { background: var(--ok); }
.check { display: flex; align-items: center; gap: 16px; min-height: 68px; padding: 10px 18px; border-radius: 14px;
  background: var(--card); border: 1px solid var(--line); text-align: left; width: 100%; }
.check .box { width: 36px; height: 36px; border-radius: 10px; border: 2.5px solid #cfc8bc; flex: none; display: grid; place-items: center;
  font-size: 22px; color: #fff; font-weight: 900; }
.check.done { background: var(--ok-bg); border-color: #bfe6cf; }
.check.done .box { background: var(--ok); border-color: var(--ok); }
.check.done .lbl { color: #3c6a4f; }
.check .meta { margin-left: auto; font-size: 13px; color: var(--muted); text-align: right; white-space: nowrap; }
.section-title { margin: 22px 4px 10px; font-size: 14px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.checks { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }

/* Commandes : split catalogue / panier */
.split { display: grid; grid-template-columns: 1fr 360px; gap: 20px; align-items: start; min-height: 100%; }
.sticky { position: sticky; top: 0; }
.prod { display: flex; align-items: center; gap: 12px; padding: 10px 10px 10px 16px; min-height: 68px;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; }
.prod.has { border-color: var(--accent); box-shadow: inset 4px 0 0 var(--accent); }
.prod .n { font-weight: 650; } .prod .u { font-size: 14px; color: var(--muted); }
.stepper { margin-left: auto; display: flex; align-items: center; gap: 4px; background: #f1ede6; border-radius: 14px; padding: 4px; }
.stepper button { width: 48px; height: 48px; border-radius: 11px; font-size: 26px; font-weight: 700; background: var(--card); }
.stepper .q { min-width: 46px; text-align: center; font-weight: 800; font-size: 20px; font-variant-numeric: tabular-nums; }
.stepper.zero .q { color: #b5ada1; }
.prods { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (max-width: 1199px) { .prods { grid-template-columns: 1fr; } .split { grid-template-columns: 1fr 330px; } }
.cart-line { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.supplier-tabs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 14px; }
.supplier-tabs .chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }

/* Listes / tableaux */
.list { display: flex; flex-direction: column; }
.list > .li { display: flex; align-items: center; gap: 14px; min-height: 64px; padding: 10px 4px; border-bottom: 1px solid var(--line); text-align: left; width: 100%; }
.list > .li:last-child { border-bottom: 0; }
.status { padding: 4px 10px; border-radius: 999px; font-size: 13px; font-weight: 700; white-space: nowrap; }
.st-sent { background: var(--warn-bg); color: var(--warn); }
.st-prepared { background: #e5eefc; color: #2c5fb8; }
.st-received { background: var(--ok-bg); color: var(--ok); }
.st-cancelled { background: #eee; color: #888; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); }
th { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Barres (dashboard) */
.bars { display: flex; align-items: flex-end; gap: 8px; height: 180px; padding-top: 10px; }
.bars .b { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 6px; height: 100%; }
.bars .b i { display: block; width: 100%; max-width: 42px; background: var(--accent); border-radius: 6px 6px 2px 2px; min-height: 2px; }
.bars .b span { font-size: 12px; color: var(--muted); }
.hbar { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center; margin-bottom: 10px; }
.hbar .track { grid-column: 1 / -1; height: 8px; border-radius: 8px; background: #efebe4; overflow: hidden; }
.hbar .track i { display: block; height: 100%; background: var(--accent); border-radius: 8px; }

/* Formulaires */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 14px; font-weight: 700; color: var(--muted); }
.input { min-height: var(--tap); padding: 0 16px; border-radius: 12px; border: 1px solid var(--line); background: #fff; width: 100%; }
textarea.input { padding: 12px 16px; min-height: 96px; resize: vertical; }

/* Modale et toast */
.overlay { position: fixed; inset: 0; background: rgba(22,19,15,.45); display: grid; place-items: center; z-index: 50; animation: fade .15s; }
.modal { background: var(--card); border-radius: 22px; padding: 26px; width: min(640px, 92vw); max-height: 88vh; overflow-y: auto; }
.modal h2 { margin: 0 0 16px; }
.modal pre { white-space: pre-wrap; background: #f6f3ee; padding: 16px; border-radius: 12px; font: 15px/1.45 ui-monospace, Menlo, monospace; -webkit-user-select: text; user-select: text; }
.people { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.people button { min-height: 72px; border-radius: 14px; background: #f3f0ea; font-weight: 700; font-size: 18px; }
.people button.on { background: var(--ink); color: #fff; }
.pin { display: flex; gap: 12px; justify-content: center; margin: 10px 0 20px; }
.pin i { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--ink); }
.pin i.f { background: var(--ink); }
.keypad { display: grid; grid-template-columns: repeat(3, 88px); gap: 12px; justify-content: center; }
.keypad button { height: 72px; border-radius: 18px; background: #f3f0ea; font-size: 28px; font-weight: 600; }
#toast { position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%) translateY(120px); background: var(--ink); color: #fff;
  padding: 14px 24px; border-radius: 14px; font-weight: 600; transition: transform .25s; z-index: 60; }
#toast.show { transform: translateX(-50%) translateY(0); }
.empty { text-align: center; padding: 50px 20px; color: var(--muted); }
.empty .ico { font-size: 46px; margin-bottom: 8px; }
.demo-banner { background: var(--warn-bg); color: var(--warn); padding: 10px 16px; border-radius: 12px; font-weight: 600; margin-bottom: 16px; }
@keyframes fade { from { opacity: 0; } }

/* Message en mode portrait */
#rotate { display: none; }
@media (orientation: portrait) and (max-width: 1100px) {
  #rotate { display: grid; place-items: center; position: fixed; inset: 0; background: var(--side); color: #fff; font-size: 24px; font-weight: 700; z-index: 100; }
}
