/* Inventaire — couleurs de Groupe Surprenant (bleu marin #373373). Mise en page : une colonne étroite, pensée pour le téléphone. */
:root {
  --bg: #f4f4f7; --surface: #ffffff; --ink: #1c1e2e; --muted: #676a7a; --line: #dfe0e7;
  --brand: #373373; --brand-ink: #ffffff; --brand-soft: #ebebf5;
  --low: #b8342a; --low-soft: #fbe9e6; --ok: #2b7a49; --ok-soft: #e3f3e9; --warn: #9a6a00;
  --radius: 12px;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink); -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); font-size: 15px; line-height: 1.45; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
[hidden] { display: none !important; }
.wrap { max-width: 860px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }

/* ---------- barre du haut */
.topbar { position: sticky; top: 0; z-index: 20; background: var(--brand); color: var(--brand-ink); padding-top: env(safe-area-inset-top); }
.row1 { display: flex; align-items: center; gap: 10px; padding-block: 10px 6px; flex-wrap: wrap; }
.brand { color: #fff; text-decoration: none; font-weight: 700; font-size: 17px; margin-right: auto; }
.cos { display: flex; gap: 3px; background: rgba(255,255,255,.12); border-radius: 999px; padding: 3px; }
.cos button { border: 0; background: transparent; color: #fff; opacity: .8; padding: 5px 12px; border-radius: 999px; cursor: pointer; font-weight: 600; font-size: 13px; }
.cos button[aria-pressed="true"] { background: #fff; color: var(--brand); opacity: 1; }
.scan-btn { display: inline-flex; align-items: center; gap: 6px; border: 0; border-radius: 999px; padding: 7px 14px; background: #fff; color: var(--brand); font-weight: 700; cursor: pointer; }
.tabs { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.tabs a { color: #fff; opacity: .78; text-decoration: none; font-weight: 600; font-size: 14px; padding: 8px 10px 10px; border-bottom: 3px solid transparent; white-space: nowrap; }
.tabs a.on { opacity: 1; border-bottom-color: #fff; }
.tabs .badge { display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 4px; border-radius: 999px; background: #fff; color: var(--low); font-size: 12px; text-align: center; }

main { padding-block: 18px 80px; }
h1 { font-size: 1.45rem; margin: 0 0 4px; line-height: 1.2; text-wrap: balance; }
h2 { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 26px 0 8px; font-weight: 700; }
.sub { color: var(--muted); margin: 0 0 16px; }
.empty { padding: 36px 20px; text-align: center; color: var(--muted); }
.empty strong { display: block; color: var(--ink); font-size: 1.05rem; margin-bottom: 4px; }

/* ---------- contrôles */
.bar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.bar .grow { flex: 1 1 220px; min-width: 0; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); min-height: 42px; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 42px; padding: 8px 14px; border-radius: 9px;
  border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 600; text-decoration: none; color: var(--ink); white-space: nowrap; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.danger { color: var(--low); border-color: var(--low); }
.btn.ghost { border-color: transparent; background: transparent; padding-left: 0; }
.btn.small { min-height: 34px; padding: 5px 10px; font-size: 14px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.chip { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; vertical-align: 1px; }
.chip.low { background: var(--low-soft); color: var(--low); }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.grey { background: var(--bg); color: var(--muted); border: 1px solid var(--line); }
.toggle { display: inline-flex; align-items: center; gap: 6px; padding: 7px 11px; border: 1px solid var(--line); border-radius: 999px; font-size: 14px; font-weight: 600; cursor: pointer; background: var(--surface); }
.toggle input { margin: 0; accent-color: var(--brand); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.note { font-size: 14px; color: var(--muted); background: var(--brand-soft); border-radius: 9px; padding: 10px 12px; }
.note.warn { background: var(--low-soft); color: var(--low); }

/* ---------- liste des produits */
.list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.item { display: grid; grid-template-columns: 4px 1fr auto; gap: 12px; align-items: center; padding: 12px 14px 12px 0; border-top: 1px solid var(--line); text-decoration: none; color: inherit; }
.item:first-child { border-top: 0; }
.item:hover { background: #fafafc; }
.item .stripe { align-self: stretch; }
.item.is-low .stripe { background: var(--low); }
.item .name { font-weight: 600; overflow-wrap: anywhere; }
.item .meta { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.item .q { text-align: right; }
.item .q b { font-family: var(--mono); font-size: 20px; font-variant-numeric: tabular-nums; }
.item .q span { display: block; color: var(--muted); font-size: 12px; }
.item.is-low .q b { color: var(--low); }
.totals { display: flex; gap: 8px 20px; flex-wrap: wrap; color: var(--muted); font-size: 14px; margin: -8px 0 14px; }
.totals b { color: var(--ink); }

/* ---------- fiche produit */
.pd-head { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; }
.qty-big { display: flex; align-items: baseline; gap: 8px; margin: 14px 0 2px; flex-wrap: wrap; }
.qty-big b { font-family: var(--mono); font-size: 60px; line-height: 1; font-variant-numeric: tabular-nums; }
.qty-big.low b { color: var(--low); }
.steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 16px; }
.steps button { padding: 16px 0; font-size: 20px; font-family: var(--mono); border-radius: 10px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 700; }
.steps .minus { color: var(--low); } .steps .plus { color: var(--ok); }
.custom { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; margin-top: 8px; }
.custom input { font-family: var(--mono); font-size: 18px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.money { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.money div { background: var(--bg); border-radius: 9px; padding: 10px 12px; }
.money span { display: block; font-size: 12px; color: var(--muted); font-weight: 600; }
.money b { font-family: var(--mono); font-size: 17px; }
.hist .h { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); align-items: baseline; font-size: 14px; }
.hist .h:first-child { border-top: 0; }
.hist .d { font-family: var(--mono); font-weight: 700; min-width: 54px; }
.hist .d.neg { color: var(--low); } .hist .d.pos { color: var(--ok); }
.hist .w { color: var(--muted); font-size: 13px; min-width: 0; overflow-wrap: anywhere; }
.qrbox { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; margin-top: 16px; }
.qrbox .qr { width: 128px; height: 128px; padding: 8px; background: #fff; border: 1px solid var(--line); border-radius: 8px; }
.qrbox .qr svg { width: 100%; height: 100%; display: block; }

/* ---------- formulaires */
.form { display: grid; gap: 12px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 560px) { .grid2 { grid-template-columns: 1fr; } }
label.f { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; color: var(--muted); }
label.f .h { font-weight: 400; }
.pw { position: relative; }
.pw input { padding-right: 44px; }
.pw button { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); border: 0; background: transparent; cursor: pointer; padding: 8px; color: var(--muted); }
.login { max-width: 400px; margin: 6vh auto 0; }
.login img { display: block; width: 220px; max-width: 70%; margin: 0 auto 18px; }
.login h1 { text-align: center; margin-bottom: 16px; }

/* ---------- tableaux */
.tscroll { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 700; padding: 9px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.t td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.t tr:last-child td { border-bottom: 0; }
table.t .n { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
table.t td.c, table.t th.c { text-align: center; }
table.t input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--brand); }
.order-group { margin-bottom: 14px; }
.order-group h3 { font-size: 15px; margin: 0 0 6px; }

/* ---------- fenêtre */
.modal-bg { position: fixed; inset: 0; background: rgba(15,15,30,.5); z-index: 40; display: flex; align-items: flex-start; justify-content: center; padding: max(24px, env(safe-area-inset-top)) 12px 24px; overflow-y: auto; }
.modal { background: var(--surface); border-radius: 14px; width: 100%; max-width: 520px; padding: 18px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.modal-head h2 { margin: 0; font-size: 1.1rem; text-transform: none; letter-spacing: 0; color: var(--ink); }
.icon-btn { border: 0; background: transparent; font-size: 20px; cursor: pointer; padding: 4px 8px; color: var(--muted); }
.scan-view { position: relative; background: #000; border-radius: 10px; overflow: hidden; aspect-ratio: 3 / 4; max-height: 60vh; width: 100%; }
.scan-view video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scan-frame { position: absolute; inset: 18%; border: 3px solid rgba(255,255,255,.9); border-radius: 14px; }
.scan-msg { position: absolute; left: 0; right: 0; bottom: 10px; text-align: center; color: #fff; margin: 0; padding: 0 12px; font-weight: 600; text-shadow: 0 1px 3px #000; }
.scan-msg.err { background: rgba(0,0,0,.6); padding: 10px; bottom: 0; }

#toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(18px + env(safe-area-inset-bottom)); background: var(--ink); color: #fff; padding: 11px 16px; border-radius: 10px;
  font-weight: 600; max-width: calc(100% - 32px); z-index: 60; box-shadow: 0 6px 24px rgba(0,0,0,.25); }
#toast.warn { background: var(--low); }

/* ---------- étiquettes (impression) */
#print { display: none; }
.lbl-preview { display: flex; flex-wrap: wrap; gap: 10px; }
.label { display: flex; gap: 2mm; align-items: center; background: #fff; color: #000; overflow: hidden; border: 1px dashed #bbb; }
.label .qr svg { display: block; width: 100%; height: 100%; }
.label .tx { min-width: 0; display: flex; flex-direction: column; justify-content: space-between; height: 100%; }
.label .nm { font-weight: 700; line-height: 1.12; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.label .ft { font-family: var(--mono); color: #333; }
.label.off { opacity: .3; }
@media print {
  body > *:not(#print) { display: none !important; }
  #print { display: block; }
  #print .sheet { display: grid; break-after: page; }
  #print .sheet:last-child { break-after: auto; }
  #print .label { border: 0; }
}

/* ---------- graphiques de consommation */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .axis { fill: var(--muted); font-size: 11px; font-family: var(--mono); }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .bar { fill: var(--brand); }
.chart .bar.partial { fill: var(--brand); opacity: .35; }
.chart .bar.hot { fill: #5a56b0; }
.chart .trend { stroke: #c48a00; stroke-width: 2; stroke-dasharray: 6 4; fill: none; }
.chart .level { stroke: var(--brand); stroke-width: 2; fill: none; }
.chart .area { fill: var(--brand); opacity: .08; }
.chart .minline { stroke: var(--low); stroke-width: 1.5; stroke-dasharray: 4 3; }
.chart .minlabel { fill: var(--low); font-size: 11px; font-weight: 700; }
.chart .dot { fill: var(--brand); stroke: var(--surface); stroke-width: 2; }
.chart .hit { fill: transparent; cursor: crosshair; }
.chart .tip { position: absolute; pointer-events: none; background: var(--ink); color: #fff; font-size: 13px; padding: 6px 9px; border-radius: 7px;
  white-space: nowrap; transform: translate(-50%, -100%); margin-top: -8px; z-index: 2; }
.chart .tip b { font-family: var(--mono); }
.chart-key { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--muted); margin: 4px 0 10px; }
.chart-key i { display: inline-block; width: 18px; height: 0; border-top: 2px dashed #c48a00; vertical-align: middle; margin-right: 6px; }
.chart-key i.bar { height: 10px; border: 0; background: var(--brand); width: 10px; border-radius: 2px; }
.chart-key i.min { border-top-color: var(--low); }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 14px; }
.tiles div { background: var(--bg); border-radius: 9px; padding: 10px 12px; }
.tiles span { display: block; font-size: 12px; color: var(--muted); font-weight: 600; }
.tiles b { font-family: var(--mono); font-size: 18px; }
.tiles small { display: block; color: var(--muted); font-size: 12px; }
.trend-chip { display: inline-flex; align-items: center; gap: 3px; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.trend-chip.hausse { background: #fff3d6; color: #8a5a00; }
.trend-chip.baisse { background: var(--brand-soft); color: var(--brand); }
.trend-chip.stable, .trend-chip.aucune { background: var(--bg); color: var(--muted); border: 1px solid var(--line); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; background: var(--surface); }
.seg button { border: 0; background: transparent; padding: 6px 12px; cursor: pointer; font-weight: 600; font-size: 14px; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--brand); color: #fff; }
.spark { display: block; }
.spark rect { fill: var(--brand); }
.spark rect.partial { opacity: .35; }
table.t td.spk { width: 130px; }
