:root {
  --bg: #f4f5f8; --panel: #ffffff; --panel-2: #f8f9fb; --ink: #111827; --muted: #6b7280; --line: #e6e8ee; --line-strong: #d4d7df;
  --accent: #4f46e5; --accent-2: #7c3aed; --accent-ink: #ffffff; --accent-soft: #eef0ff;
  --ok: #059669; --ok-soft: #e7f8f1; --warn: #b45309; --warn-soft: #fdf3e2; --bad: #dc2626; --bad-soft: #fdecec;
  --side-bg: #0f1117; --side-ink: #c9cdd6; --side-muted: #6e7483; --side-hover: #1b1e27; --side-on: #ffffff;
  --radius: 14px; --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(17,24,39,.04), 0 2px 8px rgba(17,24,39,.04);
  --shadow-lg: 0 24px 60px -12px rgba(17,24,39,.28);
  --ring: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0c10; --panel: #13151b; --panel-2: #181a21; --ink: #e8eaf0; --muted: #959cab; --line: #242833; --line-strong: #323744;
    --accent: #8b8cf8; --accent-2: #b48cff; --accent-ink: #0b0c10; --accent-soft: #1f2140;
    --ok: #4ade9c; --ok-soft: #12291f; --warn: #f5b454; --warn-soft: #2e2413; --bad: #f87171; --bad-soft: #321819;
    --side-bg: #08090c; --side-hover: #15171e;
    --shadow: 0 1px 2px rgba(0,0,0,.4); --shadow-lg: 0 24px 60px -12px rgba(0,0,0,.7);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font: 14px/1.5 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-feature-settings: "cv11", "ss01"; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); }
h1 { font-size: 24px; font-weight: 700; margin: 0; letter-spacing: -.025em; }
h2 { font-size: 15px; font-weight: 650; margin: 0 0 14px; letter-spacing: -.01em; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.boot { min-height: 100vh; display: grid; place-items: center; color: var(--muted); }
::selection { background: color-mix(in srgb, var(--accent) 25%, transparent); }

/* Layout */
.shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.side { background: var(--side-bg); color: var(--side-ink); padding: 18px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 2px; }
.brand { display: flex; align-items: center; gap: 11px; font-weight: 700; font-size: 15px; color: #fff; padding: 4px 8px 22px; letter-spacing: -.01em; }
.brand small { display: block; font-weight: 500; color: var(--side-muted); font-size: 11.5px; letter-spacing: 0; }
.logo { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0; color: #fff; font-size: 13px; font-weight: 800; letter-spacing: -.02em;
  background: linear-gradient(135deg, #6366f1, #a855f7); box-shadow: 0 6px 18px -6px rgba(124,58,237,.7), inset 0 1px 0 rgba(255,255,255,.25); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a, .nav-out { display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 9px; color: var(--side-ink); text-decoration: none; font-weight: 500; transition: background .15s, color .15s; }
.nav a svg, .nav-out svg { width: 18px; height: 18px; flex-shrink: 0; opacity: .75; }
.nav a:hover, .nav-out:hover { background: var(--side-hover); color: #fff; }
.nav a.on { background: var(--side-hover); color: var(--side-on); box-shadow: inset 2px 0 0 #8b8cf8; }
.nav a.on svg { opacity: 1; color: #a5a6ff; }
.side .spacer { flex: 1; }
.nav-out { color: var(--side-muted); border-top: 1px solid #1e212b; border-radius: 0 0 9px 9px; padding-top: 14px; }
.main { padding: 32px 40px 80px; min-width: 0; max-width: 1480px; width: 100%; animation: fade .25s ease; }
.top { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 22px; flex-wrap: wrap; }
.top .muted { font-size: 13px; font-weight: 500; margin-bottom: 2px; }
.demo { background: var(--warn-soft); color: var(--warn); padding: 10px 14px; border-radius: var(--radius-sm); margin-bottom: 18px; font-size: 13px; border: 1px solid color-mix(in srgb, currentColor 18%, transparent); }
.demo code { font-size: 12px; }

/* Panels */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px 22px; margin-bottom: 18px; }
.grid2 { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }
.grid2 > div:last-child { position: sticky; top: 20px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 10px; }

/* Form */
input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea { background: var(--panel); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); padding: 9px 12px; width: 100%; transition: border-color .15s, box-shadow .15s; }
input::placeholder, textarea::placeholder { color: color-mix(in srgb, var(--muted) 75%, transparent); }
input:hover, select:hover, textarea:hover { border-color: color-mix(in srgb, var(--muted) 55%, var(--line)); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
select { appearance: none; padding-right: 34px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%23888' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' viewBox='0 0 24 24'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; }
textarea { min-height: 80px; resize: vertical; }
label { display: block; font-size: 12.5px; font-weight: 550; color: var(--muted); margin-bottom: 6px; }
.field { min-width: 0; }
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line-strong); background: var(--panel); padding: 8px 15px; border-radius: var(--radius-sm); cursor: pointer; white-space: nowrap; text-decoration: none; color: var(--ink); font-weight: 550; box-shadow: 0 1px 2px rgba(17,24,39,.05); transition: background .15s, border-color .15s, transform .08s, box-shadow .15s; }
.btn:hover { background: var(--panel-2); border-color: color-mix(in srgb, var(--muted) 50%, var(--line)); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn.primary { background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 88%, #fff), var(--accent)); border-color: var(--accent); color: var(--accent-ink);
  box-shadow: 0 1px 2px rgba(17,24,39,.1), 0 4px 12px -4px color-mix(in srgb, var(--accent) 60%, transparent), inset 0 1px 0 rgba(255,255,255,.18); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--bad); }
.btn.danger:hover { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 35%, transparent); }
.btn.sm { padding: 6px 11px; font-size: 13px; }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: none; transform: none; }
.icon-btn { border: 0; background: none; cursor: pointer; color: var(--muted); padding: 5px 8px; border-radius: 8px; transition: background .15s, color .15s; }
.icon-btn:hover { background: var(--bad-soft); color: var(--bad); }
input.qty { width: 72px; text-align: center; padding: 7px; font-variant-numeric: tabular-nums; }
input.mini { width: 84px; text-align: right; padding: 7px 9px; font-variant-numeric: tabular-nums; }

/* Tables */
table { width: 100%; border-collapse: separate; border-spacing: 0; }
th { text-align: left; font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 10px 12px; background: var(--panel-2); border-bottom: 1px solid var(--line); white-space: nowrap; }
th:first-child { border-top-left-radius: var(--radius-sm); } th:last-child { border-top-right-radius: var(--radius-sm); }
td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; } tr.click td { transition: background .12s; } tr.click:hover td { background: color-mix(in srgb, var(--accent) 5%, transparent); }
.table-wrap { overflow-x: auto; margin: 0 -22px; padding: 0 22px; }
.group-row td { background: color-mix(in srgb, var(--accent) 6%, var(--panel)); font-weight: 650; font-size: 13px; color: var(--ink); padding-top: 9px; padding-bottom: 9px; }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); line-height: 1.6; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.badge.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.badge.info { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.st-demande { background: var(--panel-2); color: var(--muted); }
.st-devis { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.st-accepte, .st-commande, .st-atelier { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.st-pret, .st-livre { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.st-annule { background: var(--bad-soft); color: var(--bad); border-color: transparent; text-decoration: line-through; }

/* Catalogue */
.search { display: flex; gap: 10px; max-width: 620px; }
.search input { font-size: 16px; padding: 12px 16px 12px 44px; text-transform: uppercase; letter-spacing: .02em; border-radius: 12px;
  background: var(--panel) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' fill='none' stroke='%23888' stroke-width='2' stroke-linecap='round' viewBox='0 0 24 24'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") no-repeat 15px center; }
.search .btn { padding: 0 20px; border-radius: 12px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 14px; }
.chip { border: 1px solid var(--line); background: var(--panel-2); border-radius: 999px; padding: 5px 12px; cursor: pointer; font-size: 13px; font-weight: 600; transition: border-color .15s, background .15s; }
.chip .muted { font-weight: 450; }
.chip:hover { border-color: var(--accent); background: var(--accent-soft); }
.prod-head { display: flex; gap: 22px; align-items: flex-start; }
.prod-head h1 { font-size: 22px; }
.prod-img { width: 132px; height: 132px; border-radius: 12px; background: var(--panel-2); object-fit: contain; flex-shrink: 0; border: 1px solid var(--line); padding: 6px; }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; margin: 20px 0 16px; padding-top: 18px; border-top: 1px solid var(--line); }
.swatch { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 5px 12px 5px 6px; cursor: pointer; font-size: 13px; font-weight: 500; transition: border-color .15s, box-shadow .15s; }
.swatch:hover { border-color: var(--line-strong); }
.swatch.on { border-color: var(--accent); box-shadow: var(--ring); }
.swatch .dot { width: 20px; height: 20px; border-radius: 50%; border: 1px solid rgba(0,0,0,.12); box-shadow: inset 0 0 0 1px rgba(255,255,255,.3); background: #ccc; }
.swatch .cnt { background: var(--accent); color: var(--accent-ink); border-radius: 999px; font-size: 11px; padding: 0 7px; font-weight: 700; }
.addbar { position: sticky; bottom: 12px; background: color-mix(in srgb, var(--panel) 85%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--line); box-shadow: var(--shadow-lg); margin: 18px -8px -8px; padding: 12px 16px; border-radius: 14px; z-index: 3; }
.addbar #cartTotal { font-size: 18px; color: var(--accent); }
.wh { font-size: 12px; color: var(--muted); line-height: 1.6; }

/* Paliers de prix */
.tiers { display: flex; flex-wrap: wrap; gap: 5px; }
.tiers span { display: inline-flex; flex-direction: column; align-items: center; min-width: 62px; padding: 4px 8px; border: 1px solid var(--line); border-radius: 8px; font-size: 11px; color: var(--muted); line-height: 1.3; background: var(--panel); }
.tiers span b { color: var(--ink); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.tiers span.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.pinfo { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; font-size: 13px; }

/* Totaux */
.totals { background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 5%, var(--panel)), var(--panel) 45%); }
.totals div { display: flex; justify-content: space-between; padding: 6px 0; font-variant-numeric: tabular-nums; }
.totals .big { font-size: 22px; font-weight: 750; letter-spacing: -.02em; border-top: 1px solid var(--line); margin-top: 8px; padding-top: 14px; }
.totals .big span:last-child { color: var(--accent); }
.totals .sep { border-top: 1px dashed var(--line-strong); margin-top: 8px; padding-top: 12px; }
.totals .stack { display: flex; }
.hist { font-size: 12.5px; color: var(--muted); max-height: 240px; overflow: auto; }
.hist div { padding: 7px 0 7px 16px; position: relative; border-left: 1px solid var(--line); margin-left: 4px; }
.hist div::before { content: ""; position: absolute; left: -4px; top: 13px; width: 7px; height: 7px; border-radius: 50%; background: var(--line-strong); }
.hist div:first-child::before { background: var(--accent); }
.forced { color: var(--warn); font-weight: 600; }

/* Chargement */
.loading { display: flex; align-items: center; gap: 12px; color: var(--muted); }
.loading::before, .boot::before { content: ""; width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line-strong); border-top-color: var(--accent); animation: spin .7s linear infinite; flex-shrink: 0; }
.boot.err::before { display: none; }
.boot { display: flex; gap: 12px; align-items: center; justify-content: center; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(1000px 500px at 15% -10%, color-mix(in srgb, #6366f1 18%, transparent), transparent 60%),
              radial-gradient(800px 500px at 110% 110%, color-mix(in srgb, #a855f7 16%, transparent), transparent 60%), var(--bg); }
.login .panel { width: 100%; max-width: 380px; padding: 32px; gap: 16px; box-shadow: var(--shadow-lg); border-radius: 18px; }
.login .logo { align-self: flex-start; width: 44px; height: 44px; font-size: 15px; border-radius: 12px; margin-bottom: 4px; }
.login .btn { padding: 11px; margin-top: 4px; }

/* Modal / toast */
.modal { position: fixed; inset: 0; background: rgba(10,12,18,.45); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); display: grid; place-items: center; padding: 16px; z-index: 20; animation: fade .15s ease; }
.modal[hidden] { display: none; }
.modal-card { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 26px; width: 100%; max-width: 580px; max-height: 90vh; overflow: auto; box-shadow: var(--shadow-lg); animation: pop .2s cubic-bezier(.2,.9,.3,1.2); }
.modal-card h2 { font-size: 18px; letter-spacing: -.02em; }
.modal-card pre { background: var(--panel-2); border: 1px solid var(--line); padding: 12px; border-radius: var(--radius-sm); font-size: 12px; overflow: auto; max-height: 260px; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 11px 18px; border-radius: 12px; z-index: 30; font-weight: 550; box-shadow: var(--shadow-lg); animation: rise .25s cubic-bezier(.2,.9,.3,1.2); max-width: calc(100vw - 32px); }
.toast.err { background: var(--bad); color: #fff; }
.empty { text-align: center; padding: 48px 10px; color: var(--muted); border: 1px dashed var(--line-strong); border-radius: var(--radius-sm); background: var(--panel-2); }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.97); } }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 10px); } }
@media (prefers-reduced-motion: reduce) { *, *::before { animation: none !important; transition: none !important; } }

/* Mobile */
@media (max-width: 1100px) { .grid2 { grid-template-columns: 1fr; } .grid2 > div:last-child { position: static; } }
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: sticky; height: auto; flex-direction: row; align-items: center; overflow-x: auto; padding: 8px 10px; z-index: 5; gap: 4px; }
  .brand { padding: 0 6px 0 0; } .brand > div, .side .spacer { display: none; }
  .logo { width: 30px; height: 30px; font-size: 12px; }
  .nav { flex-direction: row; gap: 2px; }
  .nav a { white-space: nowrap; padding: 8px 10px; }
  .nav a.on { box-shadow: inset 0 -2px 0 #8b8cf8; }
  .nav-out { border: 0; padding: 8px 10px; } .nav-out span { display: none; }
  .main { padding: 20px 16px 60px; }
  h1 { font-size: 21px; }
  .prod-img { width: 84px; height: 84px; }
  .table-wrap { margin: 0 -22px; }
  .search .btn { padding: 0 14px; }
}
@media print { .side, .top .btn, .addbar { display: none !important; } .shell { display: block; } }

/* Réassort */
.restock { display: block; margin-top: 4px; font-size: 11.5px; font-weight: 550; color: var(--accent); white-space: nowrap; }
.restock::before { content: "↻ "; }
.restock-inline { color: var(--accent); font-weight: 550; }

/* Livraison client */
[hidden] { display: none !important; }
label.check { display: flex; align-items: center; gap: 9px; font-size: 14px; font-weight: 500; color: var(--ink); margin: 0; cursor: pointer; }
label.check input { width: 17px; height: 17px; margin: 0; accent-color: var(--accent); flex-shrink: 0; }
.addr { white-space: pre-line; font-size: 13px; padding: 10px 12px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--panel-2); }
.addr-st { margin-top: 6px; font-size: 12px; font-weight: 600; white-space: normal; }
.addr.ok { border-color: color-mix(in srgb, var(--ok) 35%, transparent); } .addr.ok .addr-st { color: var(--ok); }
.addr.todo { border-color: color-mix(in srgb, var(--warn) 45%, transparent); background: var(--warn-soft); } .addr.todo .addr-st { color: var(--warn); }
