/* Placard — une colonne façon appli iPhone : en haut le titre, au milieu la page, en bas les trois onglets. */
:root {
  --bg: #eef2ee; --surface: #ffffff; --ink: #1b2420; --muted: #5d6b64; --line: #d5ded8;
  --accent: #23694a; --accent-ink: #ffffff; --accent-soft: #dcebe2;
  --out: #b4471f; --out-soft: #f6e2d8; --warn: #8a6100; --warn-soft: #f7ecc9;
  --f-display: "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --f-body: -apple-system, system-ui, "Segoe UI", Roboto, sans-serif;
  --f-mono: ui-monospace, "SF Mono", Menlo, monospace;
  --nav: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) { :root {
  --bg: #111714; --surface: #1a221e; --ink: #e6eee9; --muted: #98a8a0; --line: #2c3832;
  --accent: #5cc08f; --accent-ink: #0b1a12; --accent-soft: #1f3a2d;
  --out: #f08a62; --out-soft: #3b2219; --warn: #e2b649; --warn-soft: #362c12; color-scheme: dark; } }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 16px/1.45 var(--f-body); -webkit-tap-highlight-color: transparent;
  padding-top: env(safe-area-inset-top, 0px); }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
h1 { font: 800 1.9rem/1 var(--f-display); margin: 0; letter-spacing: -0.02em; }
h2.sous { font: 600 1rem var(--f-display); color: var(--muted); margin: 26px 0 4px; }
.msg { color: var(--muted); font-size: .92rem; margin: 0; }
.msg.erreur { color: var(--out); }
.mono { font-family: var(--f-mono); letter-spacing: .04em; }

input[type="text"], input[type="search"], input[type="password"], input[inputmode] {
  font: 500 16px var(--f-body); padding: 12px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); width: 100%; min-width: 0; }
.btn { border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-weight: 600; font-size: 1rem;
  padding: 12px 16px; border-radius: 12px; cursor: pointer; }
.btn.plein { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.plein.out { background: var(--out); border-color: var(--out); color: #fff; }
.btn.discret { border: 0; background: none; color: var(--muted); text-decoration: underline; padding: 8px 0; }
.btn:disabled { opacity: .5; }

/* Porte */
.porte { min-height: 100vh; display: grid; place-items: center; padding: 24px max(16px, env(safe-area-inset-left)); }
.porte-in { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 14px; align-items: center; text-align: center; }
.porte-in img { border-radius: 18px; }
.porte form { display: flex; gap: 8px; width: 100%; }
.porte input { text-align: center; font-size: 1.3rem; letter-spacing: .3em; }

/* Appli */
#appli { max-width: 560px; margin: 0 auto;
  padding: 14px max(16px, env(safe-area-inset-right, 0px)) calc(var(--nav) + 24px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); }
.haut { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.compteurs { color: var(--muted); font-size: .88rem; font-variant-numeric: tabular-nums; }
.vue { display: flex; flex-direction: column; gap: 12px; }

.mode { display: grid; grid-template-columns: 1fr 1fr; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 4px; gap: 4px; }
.mode button { border: 0; background: transparent; color: var(--muted); font-weight: 600; padding: 12px 8px; border-radius: 10px; cursor: pointer; }
.mode button[aria-pressed="true"].in { background: var(--accent); color: var(--accent-ink); }
.mode button[aria-pressed="true"].out { background: var(--out); color: #fff; }

.camera { position: relative; aspect-ratio: 4 / 3; max-width: 100%; background: #000; border-radius: 18px; overflow: hidden; }
.camera video { width: 100%; height: 100%; object-fit: cover; display: block; }
.viseur { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.viseur span { width: 78%; height: 38%; border: 3px solid rgba(255,255,255,.9); border-radius: 14px; box-shadow: 0 0 0 9999px rgba(0,0,0,.28); }
.camera.out .viseur span { border-color: #ffb08f; }
.camera.lu .viseur span { border-color: #6be3a4; }
.camera-msg { position: absolute; inset: 0; display: grid; place-items: center; padding: 20px; text-align: center; color: #fff; background: rgba(0,0,0,.55); }
.aide { color: var(--muted); font-size: .9rem; margin: -2px 2px 0; }
.ligne-code { display: flex; gap: 8px; }

/* Listes */
.liste { list-style: none; margin: 0; padding: 0; }
.liste li { display: flex; align-items: center; gap: 12px; padding: 10px 2px; border-bottom: 1px solid var(--line); }
.liste .vignette { width: 44px; height: 44px; border-radius: 10px; object-fit: contain; background: #fff; flex: none; border: 1px solid var(--line); }
.liste .vignette.vide { display: grid; place-items: center; color: var(--muted); font-weight: 700; background: var(--surface); }
.liste .txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.liste .nom { font-weight: 500; overflow-wrap: anywhere; }
.liste .det { font-size: .8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.liste li.zero .nom { color: var(--muted); }
.liste li.fait .nom { color: var(--muted); text-decoration: line-through; }
.qte { font: 600 1.05rem var(--f-mono); min-width: 2ch; text-align: center; font-variant-numeric: tabular-nums; }
.mini { border: 1px solid var(--line); background: var(--surface); width: 38px; height: 38px; border-radius: 10px; font-size: 1.2rem; flex: none; cursor: pointer; }
.case { width: 30px; height: 30px; border-radius: 9px; border: 2px solid var(--line); background: var(--surface); flex: none; display: grid; place-items: center; color: var(--accent-ink); cursor: pointer; }
.case[aria-checked="true"] { background: var(--accent); border-color: var(--accent); }
.case svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; }
.prix { font: 600 .95rem var(--f-mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.prix.public { color: var(--muted); font-weight: 500; }
.vide-etat { color: var(--muted); padding: 18px 2px !important; border: 0 !important; }
.sens { font: 600 .85rem var(--f-mono); width: 2.4ch; flex: none; text-align: center; }
.sens.in { color: var(--accent); } .sens.out { color: var(--out); }
.ajout { display: flex; gap: 8px; margin-top: 4px; }
.total { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.total strong { font: 700 1.4rem var(--f-mono); font-variant-numeric: tabular-nums; }
.total span { color: var(--muted); font-size: .85rem; }

/* Onglets du bas */
.onglets { position: fixed; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(3, 1fr);
  background: var(--surface); border-top: 1px solid var(--line); z-index: 5;
  padding: 6px max(8px, env(safe-area-inset-right)) calc(6px + env(safe-area-inset-bottom, 0px)) max(8px, env(safe-area-inset-left)); }
.onglets button { border: 0; background: none; color: var(--muted); font-size: .78rem; font-weight: 600; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px; cursor: pointer; }
.onglets svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.onglets button[aria-current="page"] { color: var(--accent); }
.onglets .nb:not(:empty) { position: absolute; margin-left: 30px; margin-top: -2px; background: var(--out); color: #fff; font-size: .68rem; border-radius: 99px; padding: 0 6px; min-width: 18px; }

/* Fiche produit */
.fiche { position: fixed; inset: 0; background: rgba(10,15,12,.45); z-index: 10; display: flex; align-items: flex-end; justify-content: center; }
.fiche-in { background: var(--surface); width: 100%; max-width: 560px; border-radius: 22px 22px 0 0; max-height: 92vh; overflow-y: auto;
  padding: 18px max(16px, env(safe-area-inset-right)) calc(18px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left));
  display: flex; flex-direction: column; gap: 12px; }
.f-tete { display: flex; gap: 14px; align-items: flex-start; }
.f-tete img { width: 84px; height: 84px; object-fit: contain; background: #fff; border-radius: 12px; border: 1px solid var(--line); flex: none; }
.f-tete .txt { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.f-tete h2 { font: 700 1.2rem/1.2 var(--f-display); margin: 0; overflow-wrap: anywhere; }
.code { font: 500 .8rem var(--f-mono); color: var(--muted); }
.pastille { align-self: flex-start; font-size: .72rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; padding: 3px 8px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); }
.pastille.warn { background: var(--warn-soft); color: var(--warn); }
.champs { display: grid; gap: 8px; }
.champs label { display: grid; gap: 4px; font-size: .82rem; color: var(--muted); }
.infos { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.infos div { background: var(--bg); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.infos .l { font-size: .75rem; color: var(--muted); }
.infos .v { font: 600 1.05rem var(--f-mono); font-variant-numeric: tabular-nums; }
.infos .s { font-size: .75rem; color: var(--muted); overflow-wrap: anywhere; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.actions .btn.plein { flex: 1; min-width: 150px; padding: 15px; font-size: 1.05rem; }
.pas { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.pas button { border: 0; background: transparent; width: 44px; height: 48px; font-size: 1.3rem; cursor: pointer; }
.pas span { min-width: 30px; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }
.prix-paye { display: flex; align-items: center; gap: 8px; font-size: .9rem; color: var(--muted); }
.prix-paye input { width: 110px; text-align: right; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav) + 16px + env(safe-area-inset-bottom, 0px));
  background: var(--ink); color: var(--bg); padding: 12px 16px; border-radius: 14px; font-weight: 500; z-index: 20; width: max-content; max-width: calc(100% - 32px); }

.liste li.groupe { border-bottom: 0; padding: 16px 2px 2px; justify-content: space-between; }
.liste li.groupe .nom { font: 700 .82rem var(--f-body); text-transform: uppercase; letter-spacing: .06em; color: var(--accent); }
.liste li.groupe .qte { font-size: .9rem; color: var(--accent); }
.liste li.groupe.zero .nom, .liste li.groupe.zero .qte { color: var(--muted); }
.liste li.membre { padding-left: 14px; }
.type-liste { display: grid; gap: 4px; font-size: .82rem; color: var(--muted); }
.pas.petit button { width: 34px; height: 36px; font-size: 1.1rem; }
.pas.petit span { min-width: 22px; }
.interrupteur { display: flex; align-items: center; gap: 12px; font-weight: 600; cursor: pointer; }
.interrupteur small { display: block; font-weight: 400; color: var(--muted); font-size: .82rem; }
.interrupteur input { appearance: none; -webkit-appearance: none; width: 50px; height: 30px; border-radius: 99px; background: var(--line); position: relative; flex: none; cursor: pointer; transition: background .15s; margin: 0; }
.interrupteur input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .15s; }
.interrupteur input:checked { background: var(--accent); }
.interrupteur input:checked::after { transform: translateX(20px); }
@media (prefers-reduced-motion: reduce) { .interrupteur input, .interrupteur input::after { transition: none; } }
.combien { flex-basis: 100%; font-weight: 600; font-size: .92rem; }
.camera.bas { aspect-ratio: 16 / 9; }
