[hidden] { display: none !important; }
:root {
  --bg: #f6f4f0; --card: #fff; --ink: #1f2a33; --muted: #6b7680; --line: #e4e0d8;
  --brand: #1d3d5c; --brand-2: #2f6690; --accent: #c8102e;
  --ok: #1f8a4c; --ok-bg: #e3f4e9; --ko: #c62828; --ko-bg: #fde7e7;
  --wait: #b26a00; --wait-bg: #fff1d6; --off: #5f6368; --off-bg: #eceff1; --blue-bg: #e3eefa;
  --radius: 12px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body { font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; background: var(--bg); color: var(--ink); }
a { color: var(--brand-2); text-decoration: none; }
h1 { font-size: 24px; margin: 4px 0 12px; }
h2 { font-size: 17px; margin: 0 0 10px; }
h3 { margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.r { text-align: right; white-space: nowrap; }
.pad { padding: 14px; }
.flake { color: #9cc9ee; }
.ok-txt { color: var(--ok); } .ko-txt { color: var(--ko); } .warn-txt, .wait-txt { color: var(--wait); }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row form { margin: 0; }

.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: calc(8px + env(safe-area-inset-top)) 16px 8px; background: var(--brand); color: #fff; }
.top .brand { color: #fff; font-weight: 700; font-size: 18px; letter-spacing: .5px; }
.top .brand small { font-weight: 400; opacity: .7; font-size: 13px; margin-left: 4px; }
.top nav { display: flex; gap: 8px; align-items: center; margin-left: auto; flex-wrap: wrap; }
.top nav.links { gap: 16px; }
.top nav.links a { color: #dbe8f3; }
.top nav.links a.on { color: #fff; font-weight: 600; border-bottom: 2px solid #9cc9ee; }
.top .who { color: #fff; font-size: 14px; }
.muted-light { color: #9fb3c6 !important; }
.sync { font-size: 12.5px; color: #cfe0ef; display: flex; align-items: center; gap: 4px; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 3px; }
.dot.on { background: #4cd38a; } .dot.off { background: #f0a43a; } .dot.busy { background: #9cc9ee; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .3; } }
.tab { background: transparent; border: 0; color: #cfe0ef; font: inherit; font-weight: 600; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.tab.on { background: rgba(255,255,255,.14); color: #fff; }
.badge { background: var(--accent); color: #fff; border-radius: 999px; padding: 0 7px; font-size: 12px; margin-left: 4px; }
.menu { position: relative; }
.menu-pop { position: absolute; right: 0; top: 40px; background: #fff; color: var(--ink); border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.2); padding: 10px; min-width: 220px; display: flex; flex-direction: column; gap: 8px; }
.menu-pop a { padding: 6px 4px; }
.banner { background: var(--wait-bg); color: #6b4300; padding: 10px 16px; border-bottom: 1px solid #f1dcb0; }

.btn { display: inline-block; background: var(--brand-2); color: #fff; border: 0; border-radius: 9px; padding: 10px 16px; font: inherit; font-weight: 600; cursor: pointer; text-align: center; }
.btn:disabled { opacity: .4; cursor: default; }
.btn.small { padding: 6px 11px; font-size: 14px; }
.btn.big { padding: 14px 18px; font-size: 17px; width: 100%; }
.btn.light { background: #fff; color: var(--brand); }
.btn.ghost { background: #fff; color: var(--brand-2); border: 1px solid #c9d6e2; }
.btn.ghost-light { background: transparent; color: #fff; border: 1px solid rgba(255,255,255,.35); }
.btn.danger { background: var(--ko); }
.x { border: 0; background: none; color: var(--ko); font-size: 17px; cursor: pointer; padding: 4px 6px; }

.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600; white-space: nowrap; background: var(--off-bg); color: var(--off); }
.pill.ok { background: var(--ok-bg); color: var(--ok); } .pill.ko { background: var(--ko-bg); color: var(--ko); }
.pill.wait { background: var(--wait-bg); color: var(--wait); } .pill.off { background: #dfe2e5; color: #444; } .pill.blue { background: var(--blue-bg); color: var(--brand-2); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 14px; }
.card.narrow { max-width: 520px; margin: 40px auto; }
.card.empty { text-align: center; padding: 30px; }

/* ---- appli : écran partagé ---- */
.split { display: grid; grid-template-columns: 1fr 360px; gap: 14px; padding: 14px; align-items: start; }
.split .right { position: sticky; top: 74px; max-height: calc(100vh - 90px); overflow: auto; margin: 0; }
#view-bons { padding: 14px; }
details.client summary { cursor: pointer; font-size: 16px; list-style: none; }
details.client summary::before { content: '▸ '; color: var(--muted); }
details.client[open] summary::before { content: '▾ '; }
.grid-form { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px 12px; margin-top: 12px; }
.grid-form label { display: flex; flex-direction: column; gap: 3px; font-size: 12.5px; color: var(--muted); }
.grid-form .w2 { grid-column: span 2; }
input, select, textarea { font: inherit; font-size: 16px; padding: 9px 10px; border: 1px solid #d5d0c6; border-radius: 9px; background: #fff; color: var(--ink); width: 100%; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid #9cc9ee; border-color: var(--brand-2); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.filters .grow { flex: 1 1 240px; width: auto; }
.filters select { width: auto; }
.chk { display: flex; gap: 6px; align-items: center; white-space: nowrap; }
.chk input { width: auto; }

.catalogue { display: flex; flex-direction: column; gap: 10px; }
.prod { display: grid; grid-template-columns: 96px 1fr; gap: 12px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; }
.thumb { position: relative; width: 96px; height: 96px; border-radius: 9px; background: #eef1f4; overflow: hidden; display: grid; place-items: center; }
.thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.thumb .flake { font-size: 34px; color: #b8cde0; }
.phead { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.pname { font-weight: 650; line-height: 1.25; }
.colsel { display: inline-flex; align-items: center; gap: 6px; margin: 6px 0 2px; font-size: 13px; color: var(--muted); }
.colsel select { width: auto; padding: 5px 8px; font-size: 15px; }
.conds { margin-top: 6px; display: flex; flex-direction: column; }
.cond-row { display: grid; grid-template-columns: 1fr 130px 86px 136px; gap: 8px; align-items: center; padding: 7px 0; border-top: 1px solid #f0ede7; }
.cond-price { text-align: right; }
.cond-stock { font-size: 13px; text-align: center; font-weight: 600; }
.stepper { display: flex; align-items: center; border: 1px solid #c9d6e2; border-radius: 10px; overflow: hidden; background: #fff; }
.stepper button { width: 42px; height: 42px; border: 0; background: #eef4fa; color: var(--brand); font-size: 22px; font-weight: 700; cursor: pointer; }
.stepper button:active { background: #d7e6f4; }
.stepper input { border: 0; border-radius: 0; text-align: center; width: 52px; padding: 8px 2px; font-weight: 700; -moz-appearance: textfield; }
.stepper input::-webkit-inner-spin-button, .stepper input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

.lignes { display: flex; flex-direction: column; gap: 2px; margin-bottom: 10px; }
.ligne { display: grid; grid-template-columns: 1fr auto auto auto; gap: 8px; align-items: center; padding: 7px 0; border-bottom: 1px solid #f0ede7; font-size: 14px; }
.ligne.warn { background: #fffaf0; }
.ligne .lq { color: var(--muted); font-size: 13px; white-space: nowrap; }
.totaux { display: flex; flex-direction: column; gap: 4px; border-top: 2px solid var(--line); padding-top: 8px; margin-bottom: 6px; }
.totaux > div { display: flex; justify-content: space-between; gap: 10px; }
.totaux .big { font-size: 17px; }
.page-tot { max-width: 380px; margin-left: auto; margin-top: 12px; }
#panier .btn.ghost { margin-top: 8px; width: 100%; }

.modal { position: fixed; inset: 0; background: rgba(15, 30, 45, .45); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal-box { background: #fff; border-radius: 16px; padding: 22px; width: min(520px, 100%); box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal-box .row { justify-content: flex-end; margin-top: 16px; }

/* ---- pages navigateur ---- */
.page { max-width: 1200px; margin: 0 auto; padding: 18px; }
.flash { max-width: 1200px; margin: 12px auto 0; padding: 0 18px; }
.flash div { background: #e8f1fa; border: 1px solid #c3dbf0; padding: 10px 14px; border-radius: 8px; }
.bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.crumbs { margin-bottom: 6px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.table-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
table.list { width: 100%; border-collapse: collapse; }
table.list th { text-align: left; font-size: 12.5px; color: var(--muted); font-weight: 600; padding: 10px; border-bottom: 1px solid var(--line); background: #faf9f6; }
table.list th.r, table.list td.r { text-align: right; }
table.list td { padding: 9px 10px; border-bottom: 1px solid #f0ede7; vertical-align: middle; }
table.list tbody tr[onclick] { cursor: pointer; }
table.list tbody tr:hover { background: #f8fafc; }
td.actions { white-space: nowrap; }
td.actions .btn { margin-right: 4px; }
dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 0; }
dl.facts dt { color: var(--muted); } dl.facts dd { margin: 0; }
form.inline { display: flex; gap: 6px; align-items: center; margin: 0; }
form.inline select { width: auto; }
.note { background: #fffaf0; border: 1px solid #f1dcb0; padding: 8px 10px; border-radius: 8px; white-space: pre-line; }
.settings h2 { margin-top: 18px; }
.settings .row { margin-top: 16px; }
.foot { text-align: center; color: var(--muted); font-size: 12px; padding: 10px 0 24px; }

.login-page { display: grid; place-items: center; min-height: 100vh; background: linear-gradient(160deg, #1d3d5c, #2f6690); }
.login { background: #fff; padding: 34px 30px; border-radius: 16px; width: min(380px, 92vw); text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.25); display: flex; flex-direction: column; gap: 10px; }
.login h1 { margin: 0; letter-spacing: 2px; }
.login p { margin: 0 0 4px; }
.login .flake.big { font-size: 46px; color: var(--brand-2); }
.login .err { background: var(--ko-bg); color: var(--ko); padding: 8px; border-radius: 8px; }

@media (max-width: 980px) {
  .split { grid-template-columns: 1fr; }
  .split .right { position: static; max-height: none; }
  .grid-form { grid-template-columns: 1fr 1fr; }
  .grid2 { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .cond-row { grid-template-columns: 1fr auto; }
  .cond-stock { text-align: left; }
  .prod { grid-template-columns: 64px 1fr; }
  .thumb { width: 64px; height: 64px; }
  .grid-form { grid-template-columns: 1fr; }
  .grid-form .w2 { grid-column: span 1; }
  .sync { order: 3; width: 100%; }
}
