:root {
  --ink: #111;
  --muted: #6b6b6b;
  --line: #e4e4e4;
  --bg: #f5f5f3;
  --card: #fff;
  --indigo: #034363;
  --indigo-soft: #e6eef2;
  --cerulean: #0c7489;
  --gamboge: #ea9c0b;
  --gamboge-soft: #fdf3e0;
  --green: #8da329;
  --green-soft: #f1f5e3;
  --red: #bc4a4e;
  --red-soft: #f8e9ea;
  --radius: 10px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; font-family: Montserrat, system-ui, sans-serif; font-size: 14px; color: var(--ink); background: var(--bg); }
button, input, textarea, select { font: inherit; color: inherit; }
h2 { font-size: 15px; font-weight: 600; margin: 0 0 14px; display: flex; align-items: center; gap: 8px; }
h3 { font-size: 13px; font-weight: 600; margin: 18px 0 8px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }

.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 24px; padding: 0 20px; height: 56px; background: #000; color: #fff; }
.brand { display: flex; align-items: baseline; gap: 6px; }
.wordmark { font-weight: 300; letter-spacing: .32em; font-size: 18px; }
.go { font-weight: 700; font-size: 13px; background: #fff; color: #000; padding: 1px 6px; border-radius: 4px; letter-spacing: .08em; }
nav { display: flex; gap: 4px; flex: 1; }
.tab { white-space: nowrap; background: none; border: 0; color: #bbb; padding: 8px 14px; border-radius: 6px; cursor: pointer; font-weight: 500; }
.tab.active, .tab:hover { color: #fff; background: #222; }
.count { background: var(--gamboge); color: #000; border-radius: 10px; padding: 0 7px; font-size: 12px; font-weight: 700; margin-left: 4px; }
.count:empty { display: none; }
.agent { background: #222; border: 0; color: #fff; padding: 6px 12px; border-radius: 6px; cursor: pointer; }
.sim { background: var(--gamboge); color: #000; text-align: center; padding: 6px; font-weight: 600; font-size: 13px; }

.view { padding: 20px; max-width: 1280px; margin: 0 auto; }
.cols { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 20px; align-items: start; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.sticky { position: sticky; top: 76px; }
.step { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: #000; color: #fff; font-size: 12px; }
label { display: block; font-size: 12px; font-weight: 500; color: var(--muted); margin-bottom: 12px; }
input, textarea, select { display: block; width: 100%; margin-top: 4px; padding: 9px 11px; border: 1px solid #ccc; border-radius: 7px; background: #fff; font-size: 14px; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--indigo); outline-offset: -1px; border-color: transparent; }
textarea { resize: vertical; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.hint { color: var(--muted); font-size: 13px; margin: 0; }
.error { color: var(--red); font-weight: 500; margin: 10px 0 0; min-height: 1em; }

.customer-known { background: var(--indigo-soft); border-radius: 7px; padding: 10px 12px; color: var(--indigo); display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.link-btn { background: none; border: 0; color: var(--indigo); font-weight: 600; cursor: pointer; text-decoration: underline; padding: 0; }

.zone { margin: -4px 0 12px; }
.badge { display: inline-block; padding: 3px 9px; border-radius: 12px; font-size: 12px; font-weight: 600; }
.b-ville { background: var(--green-soft); color: #5c6b1a; }
.b-hors { background: var(--gamboge-soft); color: #8a5c06; }
.b-non { background: var(--red-soft); color: var(--red); }
.zone .badge + span { margin-left: 8px; color: var(--muted); font-size: 13px; }

.search { position: relative; margin-bottom: 10px; }
.results { position: absolute; left: 0; right: 0; top: 100%; z-index: 5; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.12); max-height: 340px; overflow: auto; }
.result { display: flex; justify-content: space-between; gap: 12px; padding: 9px 12px; cursor: pointer; }
.result:hover, .result.active { background: var(--indigo-soft); }
.result small { color: var(--muted); }
.result .r-meta { display: flex; gap: 12px; white-space: nowrap; }
.result.out > span:first-child { color: var(--muted); }
.basket { width: 100%; border-collapse: collapse; }
.basket td { padding: 8px 4px; border-bottom: 1px solid var(--line); }
.basket td.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.qty { display: inline-flex; align-items: center; gap: 6px; }
.qty button, .rm { width: 26px; height: 26px; border: 1px solid #ccc; background: #fff; border-radius: 6px; cursor: pointer; }
.rm { border: 0; color: var(--muted); }

.totals { display: grid; grid-template-columns: 1fr auto; gap: 6px; margin: 0; font-variant-numeric: tabular-nums; }
.totals dd { margin: 0; text-align: right; }
.totals .grand { font-weight: 700; font-size: 17px; padding-top: 8px; border-top: 1px solid var(--line); }
.warn { background: var(--gamboge-soft); color: #7a5205; border-radius: 7px; padding: 8px 10px; margin-top: 10px; font-size: 13px; }
.warn.bad { background: var(--red-soft); color: var(--red); }

.stores { display: grid; gap: 6px; margin-bottom: 12px; }
.store { display: grid; grid-template-columns: auto 1fr auto; gap: 4px 10px; align-items: center; border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; cursor: pointer; }
.store input { width: auto; margin: 0; grid-row: span 2; }
.store.sel { border-color: var(--indigo); background: var(--indigo-soft); }
.store .nm { font-weight: 600; }
.store .km { color: var(--muted); font-size: 12px; text-align: right; }
.store .st { grid-column: 2 / 4; font-size: 12px; color: var(--muted); }
.ok { color: #5c6b1a; font-weight: 600; }
.ko { color: var(--red); font-weight: 600; }
.late { color: #8a5c06; font-weight: 600; }

.primary, .btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; border-radius: 8px; padding: 11px 16px; font-weight: 600; cursor: pointer; text-decoration: none; }
.primary { width: 100%; background: var(--indigo); color: #fff; font-size: 15px; }
.primary:disabled { background: #b8c4cb; cursor: not-allowed; }
.btn { background: #fff; border: 1px solid #ccc; color: var(--ink); padding: 8px 12px; font-size: 13px; }
.btn:hover { border-color: #888; }
.btn.wa { background: #1f8f4e; border-color: #1f8f4e; color: #fff; }
.btn.wa.sent { background: #fff; color: #1f8f4e; }
.btn.danger { color: var(--red); border-color: #e2b8ba; }
.btn.green { background: var(--green); border-color: var(--green); color: #fff; }

.board { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; align-items: start; }
.board h2 { margin-bottom: 10px; }
.col { display: grid; gap: 10px; }
.order { background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--gamboge); border-radius: var(--radius); padding: 12px 14px; }
.order.en_livraison { border-left-color: var(--cerulean); }
.order.livree { border-left-color: var(--green); opacity: .85; }
.order.annulee { border-left-color: var(--red); opacity: .7; }
.order .head { display: flex; justify-content: space-between; gap: 8px; font-weight: 700; }
.order .meta { color: var(--muted); font-size: 12px; margin: 4px 0 8px; }
.order .actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.order select { width: auto; display: inline-block; margin: 0; padding: 7px 9px; font-size: 13px; }
.order .sim-tag { background: var(--gamboge-soft); color: #8a5c06; font-size: 11px; padding: 1px 6px; border-radius: 4px; font-weight: 600; }
.empty { color: var(--muted); font-size: 13px; padding: 12px; border: 1px dashed #ccc; border-radius: var(--radius); text-align: center; }

dialog { border: 0; border-radius: 14px; padding: 24px; width: min(520px, 92vw); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(0,0,0,.45); }
dialog h2 { font-size: 18px; }
.steps { display: grid; gap: 10px; margin: 16px 0; }
.steps .btn { justify-content: flex-start; width: 100%; padding: 12px 14px; font-size: 14px; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #000; color: #fff; padding: 10px 18px; border-radius: 8px; z-index: 50; }

@media (max-width: 960px) {
  .cols, .board { grid-template-columns: 1fr; }
  .sticky { position: static; }
  .grid2 { grid-template-columns: 1fr; }
  .top { gap: 10px; padding: 0 12px; }
  .view { padding: 16px; }
}
.result small.ok { color: #5c6b1a; font-weight: 600; }
.result small.ko { color: var(--red); font-weight: 600; }
.assist { width: min(620px, 94vw); }
.assist .primary small { font-weight: 400; opacity: .7; margin-left: 6px; }
.row-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.close-row { margin: 14px 0 0; text-align: right; }
#assist-out { background: var(--green-soft); }

/* ---------- Synthèse ---------- */
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin-bottom: 18px; }
.presets { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid #ccc; background: #fff; border-radius: 16px; padding: 6px 12px; cursor: pointer; font-size: 13px; }
.chip.on { background: #000; border-color: #000; color: #fff; }
label.inline { display: flex; align-items: center; gap: 6px; margin: 0; }
label.inline input { width: auto; margin: 0; padding: 6px 8px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.kpi .k-label { font-size: 12px; color: var(--muted); font-weight: 500; }
.kpi .k-value { font-size: 26px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.kpi .k-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.chart-card h2 { margin-bottom: 4px; }
.chart-card .sub { margin: 0 0 12px; }
.bars { position: relative; display: flex; align-items: flex-end; gap: 2px; height: 180px; padding-top: 18px; border-bottom: 1px solid #cfcfcf; }
.bars .col { flex: 1; height: 100%; display: flex; align-items: flex-end; cursor: default; }
.bars .bar { width: 100%; max-width: 44px; margin: 0 auto; background: var(--indigo); border-radius: 4px 4px 0 0; min-height: 0; }
.bars .col:hover .bar, .bars .col.hl .bar { background: var(--cerulean); }
.bars .max { position: absolute; top: 0; left: 0; font-size: 11px; color: var(--muted); }
.bars .gridline { position: absolute; left: 0; right: 0; border-top: 1px dashed #e6e6e6; pointer-events: none; }
.xlabels { display: flex; gap: 2px; margin-top: 6px; }
.xlabels span { flex: 1; text-align: center; font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; }
.hbars { display: grid; gap: 8px; }
.hrow { display: grid; grid-template-columns: 90px 1fr 44px; gap: 10px; align-items: center; font-size: 13px; }
.hrow .track { height: 14px; }
.hrow .fill { height: 100%; background: var(--indigo); border-radius: 0 4px 4px 0; min-width: 0; }
.hrow .v { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink); }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--line); }
table.data td { padding: 8px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
table.data .num { text-align: right; }
table.data .inbar { display: flex; align-items: center; gap: 8px; justify-content: flex-end; }
table.data .inbar i { display: block; height: 8px; background: var(--indigo); border-radius: 0 4px 4px 0; }
.tip { position: fixed; z-index: 60; pointer-events: none; background: #111; color: #fff; padding: 8px 10px; border-radius: 7px; font-size: 12px; line-height: 1.5; box-shadow: 0 6px 18px rgba(0,0,0,.25); }
.tip b { font-weight: 600; }
.empty-state { text-align: center; padding: 40px 16px; color: var(--muted); }
@media (max-width: 960px) { .grid-2 { grid-template-columns: 1fr; } .hrow { grid-template-columns: 80px 1fr 40px; } }

/* top bar: never wider than the window */
nav { min-width: 0; overflow-x: auto; scrollbar-width: none; }
nav::-webkit-scrollbar { display: none; }
.brand, .agent { flex-shrink: 0; white-space: nowrap; }
html, body { overflow-x: hidden; }
@media (max-width: 960px) { .wordmark { letter-spacing: .2em; font-size: 15px; } .tab { padding: 8px 10px; } }
.bars .col { position: relative; z-index: 1; }
.bars .gridline { z-index: 0; }

/* ---------- Paramètres ---------- */
.settings-table input, .settings-table select { margin: 0; padding: 7px 9px; font-size: 13px; }
.settings-table td { vertical-align: middle; }
.settings-table tr.off td:not(:last-child) { opacity: .5; }
.settings-table .add-row td { border-bottom: 0; padding-top: 12px; }
.switch { position: relative; display: inline-block; width: 38px; height: 22px; margin: 0; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; background: #ccc; border-radius: 22px; cursor: pointer; transition: background .15s; }
.switch span::before { content: ''; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: transform .15s; }
.switch input:checked + span { background: var(--green); }
.switch input:checked + span::before { transform: translateX(16px); }
.switch input:focus-visible + span { outline: 2px solid var(--indigo); outline-offset: 2px; }
.saved { color: #5c6b1a; font-size: 12px; font-weight: 600; }
table.data td.num { white-space: nowrap; }
.sub { margin: -6px 0 14px; }
.settings-table select { min-width: 130px; }
@media (max-width: 1100px) {
  .top { gap: 12px; padding: 0 12px; }
  .tab { padding: 8px 9px; font-size: 13px; }
  .wordmark { letter-spacing: .18em; font-size: 15px; }
  .agent { padding: 6px 9px; font-size: 13px; }
}
.switch input { opacity: 0; position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; z-index: 1; cursor: pointer; }
input.need { border-color: var(--gamboge); background: var(--gamboge-soft); }

/* ---------- shared: account menu, live dot, alert gate ---------- */
.menu { position: relative; flex-shrink: 0; }
.menu-pop { position: absolute; right: 0; top: calc(100% + 6px); background: #fff; color: var(--ink); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 30px rgba(0,0,0,.18); min-width: 230px; padding: 6px; z-index: 40; }
.menu-head { font-size: 12px; color: var(--muted); padding: 8px 10px 6px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.menu-item { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 9px 10px; border-radius: 6px; cursor: pointer; color: var(--ink); text-decoration: none; font-size: 14px; }
.menu-item:hover { background: var(--indigo-soft); }
.page-title { flex: 1; min-width: 0; font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; gap: 10px; align-items: center; }
.store-pick { width: auto; display: inline-block; margin: 0; padding: 5px 8px; font-size: 13px; background: #222; color: #fff; border-color: #444; }
.live { color: #6fce4b; font-size: 14px; flex-shrink: 0; }
.live.off { color: var(--red); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .2; } }
.alert-gate { display: flex; gap: 14px; align-items: center; justify-content: center; flex-wrap: wrap; background: var(--indigo-soft); color: var(--indigo); padding: 10px 16px; font-weight: 500; }
.alert-gate .primary { width: auto; padding: 9px 16px; }
.view.wide { max-width: 1600px; }
.view.narrow { max-width: 620px; }
.view.narrow section { margin-bottom: 20px; }
.board-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.primary.big { padding: 14px 16px; font-size: 16px; width: 100%; }
.green-btn { background: #5c7a10 !important; }
.muted-btn { background: #5b6f7a !important; }
.order.en_preparation { border-left-color: var(--indigo); }
.order.prete { border-left-color: var(--green); }
.order.pulse { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(234,156,11,.0); } 50% { box-shadow: 0 0 0 6px rgba(234,156,11,.35); } }
.items { width: 100%; border-collapse: collapse; margin: 8px 0; font-size: 15px; }
.items td { padding: 5px 0; border-bottom: 1px dashed var(--line); vertical-align: top; }
.items .q { width: 42px; font-weight: 700; font-size: 16px; }
.cust { font-size: 13px; line-height: 1.6; margin-top: 6px; }
.note { background: var(--gamboge-soft); border-radius: 6px; padding: 6px 9px; font-size: 13px; margin-top: 8px; }
.radio { display: flex; gap: 8px; align-items: center; color: var(--ink); font-size: 14px; margin: 0; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.radio input { width: auto; margin: 0; }
.issue-flag { color: var(--red); font-weight: 700; }

/* ---------- login ---------- */
.login-page { display: grid; place-items: center; min-height: 100vh; background: #000; }
.login-box { width: min(380px, 92vw); }
.login-brand { justify-content: center; color: #fff; margin-bottom: 22px; }
.login-brand .wordmark { font-size: 26px; }
.login-brand .go { font-size: 16px; }
.login-box .card { padding: 24px; }

/* ---------- courier (phone) ---------- */
.courier-page .top { padding: 0 12px; gap: 10px; }
.courier-page .wordmark { font-size: 14px; letter-spacing: .16em; }
.order.courier { padding: 14px; }
.order.courier .collect { font-size: 20px; }
.leg { border-top: 1px solid var(--line); margin-top: 10px; padding-top: 10px; }
.leg-title { font-weight: 700; font-size: 15px; margin-bottom: 4px; }
.addr { font-size: 14px; margin: 8px 0 4px; line-height: 1.4; }
.nav-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.btn.nav { justify-content: center; padding: 12px 8px; font-size: 14px; font-weight: 700; color: #fff; border: 0; }
.btn.nav.waze { background: #1aa3e8; }
.btn.nav.gmaps { background: #1f8f4e; }
.btn.call { display: flex; justify-content: center; font-size: 16px; padding: 11px; margin-top: 6px; }
.actions.stack { display: grid; gap: 8px; }
.pay-amount { font-size: 22px; font-weight: 700; text-align: center; margin: 6px 0; }
.admin-pick { padding: 10px 16px; background: #fff; border-bottom: 1px solid var(--line); }
.admin-pick label { margin: 0; display: flex; gap: 8px; align-items: center; }
.admin-pick select { width: auto; margin: 0; }
@media (max-width: 1200px) { .board-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 700px) { .board-4 { grid-template-columns: 1fr; } }
.user-dialog { width: min(640px, 94vw); }
fieldset.roles { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin: 0 0 12px; }
fieldset.roles legend { font-size: 12px; color: var(--muted); font-weight: 600; padding: 0 4px; }
#ud-roles, .store-checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 6px; }
.store-checks { max-height: 220px; overflow: auto; }
td.small { font-size: 12px; color: var(--muted); }
.inline-assign { display: flex; gap: 8px; margin-top: 4px; }
.inline-assign select { margin: 0; }
.order.has-issue { border-left-color: var(--red); background: #fffafa; }
@media (max-width: 560px) { .me-name { display: none; } }
.nowrap { white-space: nowrap; }
