:root {
    --bg: #f5f6f8; --panel: #fff; --ink: #1c2330; --muted: #6b7380; --line: #e3e6eb;
    --accent: #0b6fb8; --accent-soft: #e6f1fa; --alert: #c0392b; --ok: #1e8e5a;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 14px; color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
a { color: var(--accent); text-decoration: none; }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 0 0 10px; }
.muted { color: var(--muted); } .small { font-size: 12px; }
.mono, code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px; }
code { background: var(--bg); padding: 2px 6px; border-radius: 4px; }

.layout { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.sidebar { background: #14202e; color: #c9d1dc; display: flex; flex-direction: column; padding: 20px 14px; }
.brand { color: #fff; font-weight: 700; font-size: 17px; margin: 0 8px 24px; }
.brand span { font-weight: 400; color: #8fa3b8; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a, .sidebar nav .soon { padding: 8px 10px; border-radius: 6px; color: #c9d1dc; }
.sidebar nav a.active, .sidebar nav a:hover { background: #22344a; color: #fff; }
.sidebar nav .soon { opacity: .45; cursor: default; }
.sidebar-foot { margin-top: auto; padding: 0 8px; font-size: 12.5px; display: grid; gap: 6px; }
.sidebar-foot a { color: #8fa3b8; }
.env { background: #b8860b; color: #fff; border-radius: 4px; padding: 3px 8px; justify-self: start; font-weight: 600; }
.content { padding: 28px 32px; max-width: 1400px; }

.page-head { margin-bottom: 18px; }
.page-head.row { display: flex; justify-content: space-between; align-items: flex-start; }
.back { display: inline-block; margin-bottom: 10px; }

.state-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px; color: var(--ink); font-size: 13px; }
.chip i { width: 8px; height: 8px; border-radius: 50%; }
.chip b { color: var(--muted); font-weight: 600; }
.chip.on { border-color: var(--accent); background: var(--accent-soft); }

.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px; margin-bottom: 14px; }
.filters input, .filters select { border: 1px solid var(--line); border-radius: 6px; padding: 7px 9px; font: inherit; }
.filters input[type=search] { min-width: 280px; }
.filters label { color: var(--muted); display: flex; gap: 6px; align-items: center; }
button { background: var(--accent); color: #fff; border: 0; border-radius: 6px; padding: 8px 14px; font: inherit; cursor: pointer; }
button:disabled { background: #c5ccd6; cursor: not-allowed; }
.reset { color: var(--muted); }

.grid { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.grid th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12.5px; padding: 10px 12px; border-bottom: 1px solid var(--line); background: #fafbfc; }
.grid td { padding: 10px 12px; border-bottom: 1px solid var(--line); }
.grid tbody tr { cursor: pointer; } .grid tbody tr:hover { background: #f7fafd; }
.grid.lines tbody tr { cursor: default; }
.grid tfoot td { border-bottom: 0; padding: 6px 12px; }
.num { text-align: right; white-space: nowrap; }
.sort { color: var(--muted); } .sort.on { color: var(--ink); }
.empty { text-align: center; color: var(--muted); padding: 30px; }
.tag { background: #eef0f4; color: #4a5361; border-radius: 4px; padding: 1px 6px; font-size: 11.5px; font-weight: 600; }
.state { display: inline-block; border-radius: 4px; padding: 3px 8px; font-size: 12.5px; font-weight: 600;
    color: var(--c); background: color-mix(in srgb, var(--c) 12%, white); border: 1px solid color-mix(in srgb, var(--c) 35%, white); }
.state.big { font-size: 14px; padding: 6px 12px; }
.alert { color: var(--alert); font-weight: 600; } .ok { color: var(--ok); }

.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; margin-bottom: 12px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 16px; }
.card p { margin: 0 0 8px; line-height: 1.45; }
.card.wide .grid { border: 0; }
.flash { padding: 10px 14px; border-radius: 6px; margin-bottom: 12px; background: var(--accent-soft); }
.flash-error { background: #fbeaea; color: var(--alert); }

.auth { min-height: 100vh; display: grid; place-items: center; }
.auth-box { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 28px; width: 360px; }
.auth-box h1 { margin-bottom: 18px; }
.auth-box label { display: block; color: var(--muted); margin: 12px 0 4px; }
.auth-box input { width: 100%; border: 1px solid var(--line); border-radius: 6px; padding: 9px; font: inherit; }
.auth-box button { width: 100%; margin-top: 18px; }
.auth-box .error { color: var(--alert); margin-bottom: 8px; }
.qr { text-align: center; margin: 14px 0; }
.auth-box code { display: block; margin-top: 4px; word-break: break-all; }

.button { display: inline-block; background: var(--accent); color: #fff; border-radius: 6px; padding: 8px 14px; }
button.secondary { background: #fff; color: var(--ink); border: 1px solid var(--line); }
button.secondary:hover { border-color: var(--accent); }
.small-btn { padding: 5px 10px; font-size: 12.5px; }
.link-danger { background: none; color: var(--muted); padding: 4px 8px; }
.link-danger:hover { color: var(--alert); }
.actions form { display: inline; margin: 0; }
.row-actions { white-space: nowrap; } .row-actions form { display: inline; }
.card.narrow { max-width: 460px; }
.field { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 12.5px; }
.field input, .field select, .add-line select, .add-line input, .grid input { border: 1px solid var(--line); border-radius: 6px; padding: 7px 9px; font: inherit; color: var(--ink); background: #fff; }
.field.grow { flex: 1; }
.card.narrow .field { margin-bottom: 12px; }
.header-form { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 12px; }
.grid input:disabled { background: #f3f4f6; color: var(--muted); }
.qty { width: 70px; text-align: right; } .price { width: 90px; text-align: right; } .price-wide { width: 200px; }
.add-line { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; } .add-line select { min-width: 380px; flex: 1; }
.restock td { vertical-align: top; }
.restock tbody.group { border-top: 2px solid var(--line); }
.order-cell { background: #fafbfc; border-right: 1px solid var(--line); min-width: 220px; }
.badge-alert { display: inline-block; background: #fbeaea; color: var(--alert); font-weight: 600; border-radius: 4px; padding: 3px 8px; font-size: 12.5px; }
tr.uncovered td { background: #fffafa; }
.to-order { border-color: #f0c9c4; }
.supplier-blocks { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.supplier-block { border: 1px solid var(--line); border-radius: 8px; padding: 12px; }
.supplier-block h3 { margin: 0 0 8px; font-size: 14px; }
.supplier-block ul { margin: 0 0 12px; padding-left: 18px; line-height: 1.6; }
.card + .card { margin-top: 12px; }

a.button.secondary-link { background: #fff; color: var(--ink); border: 1px solid var(--line); }
a.button.secondary-link:hover { border-color: var(--accent); }
button.danger { background: var(--alert); }
.blocked { margin: -8px 0 14px; }
.card.narrow-wide { max-width: 640px; }
.card.narrow-wide .field { margin-bottom: 12px; }
.steps { line-height: 1.7; padding-left: 20px; margin: 0 0 16px; }
.check { display: flex; gap: 8px; align-items: flex-start; }
.check.confirm { background: #fff8e6; border: 1px solid #f1d58a; border-radius: 6px; padding: 10px; margin: 12px 0; }
.notice { background: var(--accent-soft); border-radius: 6px; padding: 10px 12px; margin: 16px 0; font-size: 13px; }
h2.spaced { margin-top: 22px; }
.recap { border-collapse: collapse; margin-bottom: 12px; }
.recap th { text-align: left; color: var(--muted); font-weight: 500; padding: 6px 16px 6px 0; vertical-align: top; }
.recap td { padding: 6px 0; }
.big-amount { font-size: 20px; }
.mode-fictif { background: #fdf0d5; color: #8a5a00; } .mode-test { background: var(--accent-soft); color: var(--accent); } .mode-live { background: #fbeaea; color: var(--alert); }
.log { padding: 8px 0; border-bottom: 1px solid var(--line); line-height: 1.5; }
.log:last-child { border-bottom: 0; }
.log-failed { color: var(--alert); }

@media (max-width: 800px) {
    .layout { grid-template-columns: 1fr; } .sidebar { flex-direction: row; flex-wrap: wrap; gap: 8px; padding: 12px; }
    .sidebar nav { flex-direction: row; flex-wrap: wrap; } .sidebar-foot { margin: 0; }
    .content { padding: 16px; } .filters input[type=search] { min-width: 0; width: 100%; }
}
.cards > .card + .card { margin-top: 0; }

/* Produits */
.quick-search { position: relative; margin: 0 4px 18px; }
.quick-search input { width: 100%; border: 1px solid #2b3d52; background: #1b2a3b; color: #fff; border-radius: 6px; padding: 8px 10px; font: inherit; }
.quick-search input::placeholder { color: #8fa3b8; }
.qs-results { position: absolute; left: 0; top: 40px; width: 340px; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.18); z-index: 20; overflow: hidden; }
.qs-results a { display: block; padding: 8px 12px; color: var(--ink); border-bottom: 1px solid var(--line); }
.qs-results a:hover { background: var(--accent-soft); }
.qs-results a span { display: block; color: var(--muted); font-size: 12px; }
.qs-empty { padding: 10px 12px; color: var(--muted); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; flex-wrap: wrap; }
.tabs a { padding: 9px 14px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.on { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
.cards.two { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.gaps { background: #fff8e6; border: 1px solid #f1d58a; border-radius: 8px; padding: 14px 16px; margin-bottom: 14px; }
.gaps h2 { color: #8a5a00; }
.gap { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 8px 0; border-top: 1px solid #f1d58a; }
.gap form { display: flex; gap: 6px; }
.wide-recap th { min-width: 200px; }
tr.muted td { color: var(--muted); }
