:root {
  --bg: #f6f3ee;
  --surface: #ffffff;
  --text: #1d1a17;
  --muted: #7a726a;
  --line: #e6e0d7;
  --accent: #4b2e25;
  --accent-ink: #ffffff;
  --warn-bg: #fff3dc;
  --warn-line: #f0b44c;
  --warn-ink: #7a4a00;
  --error: #b3261e;
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161412;
    --surface: #211e1b;
    --text: #f2ede6;
    --muted: #a39a90;
    --line: #35302b;
    --accent: #b8734a;
    --warn-bg: #3a2c12;
    --warn-line: #a8792a;
    --warn-ink: #f6d08c;
    --error: #ff8a80;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  min-height: 100dvh;
  padding-bottom: env(safe-area-inset-bottom);
}
button, input { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 12px) 16px 12px;
  background: var(--bg);
}
.logos { display: flex; align-items: center; gap: 12px; }
.logo-oxbo { height: 28px; width: auto; display: block; }
.logo-ce { height: 22px; width: auto; display: block; }
.logo-sep { width: 1px; height: 24px; background: var(--line); }
/* Logos sur fond clair : en mode sombre on les pose sur une pastille claire */
@media (prefers-color-scheme: dark) {
  .logos { background: #f6f3ee; padding: 6px 12px; border-radius: 10px; }
  .logo-sep { background: #d9d1c6; }
}

.screen { max-width: 520px; margin: 0 auto; padding: 8px 16px 32px; }

/* Accueil */
#home { display: flex; flex-direction: column; gap: 12px; min-height: calc(100dvh - 70px); justify-content: center; }
.hero { text-align: center; margin-bottom: 20px; }
.hero-icon {
  width: 84px; height: 84px; margin: 0 auto 16px; border-radius: 50%;
  display: grid; place-items: center; background: var(--surface); color: var(--accent);
  border: 1px solid var(--line);
}
.hero h1 { font-size: 1.4rem; margin: 0 0 6px; }
.hero p { margin: 0; color: var(--muted); }

.btn {
  display: flex; align-items: center; justify-content: center;
  min-height: 52px; padding: 0 20px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--surface);
  font-weight: 600; cursor: pointer; text-align: center; width: 100%;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.big { min-height: 64px; font-size: 1.1rem; }
.btn:active { transform: scale(.98); }
.link { background: none; border: 0; color: var(--accent); font-weight: 600; padding: 8px 0; cursor: pointer; }
.error { color: var(--error); text-align: center; }
.muted { color: var(--muted); }
.center { text-align: center; }

/* Chargement */
#loading { display: flex; flex-direction: column; align-items: center; gap: 20px; padding-top: 40px; }
.loading-thumb { width: 60%; max-width: 240px; border-radius: 10px; opacity: .6; }
.spinner {
  width: 36px; height: 36px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Résultat */
.result { display: flex; flex-direction: column; gap: 14px; }
.summary {
  position: sticky; top: calc(env(safe-area-inset-top) + 58px); z-index: 4;
  background: var(--accent); color: var(--accent-ink);
  border-radius: var(--radius); padding: 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  box-shadow: 0 6px 20px rgb(0 0 0 / .15);
}
.vouchers { display: flex; align-items: baseline; gap: 8px; }
.voucher-count { font-size: 3rem; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.voucher-label { font-weight: 600; display: flex; flex-direction: column; line-height: 1.15; }
.voucher-label small { opacity: .8; font-weight: 400; }
.totals { display: flex; flex-direction: column; gap: 4px; text-align: right; }
.totals div { display: flex; flex-direction: column; }
.totals .muted { color: inherit; opacity: .75; font-size: .78rem; }
.totals strong { font-size: 1.15rem; font-variant-numeric: tabular-nums; }

.warning {
  background: var(--warn-bg); color: var(--warn-ink);
  border: 1px solid var(--warn-line); border-radius: var(--radius);
  padding: 10px 14px; font-size: .92rem;
}

.lines { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.line { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-top: 1px solid var(--line); }
.line:first-child { border-top: 0; }
.line.uncertain { background: var(--warn-bg); box-shadow: inset 4px 0 0 var(--warn-line); }
.line-main { flex: 1; min-width: 0; }
.line-name { font-weight: 600; }
.line-sub { font-size: .85rem; color: var(--muted); }
.line-note { font-size: .82rem; color: var(--warn-ink); margin-top: 2px; }
.line-price { font-weight: 600; font-variant-numeric: tabular-nums; min-width: 56px; text-align: right; }

.stepper { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 999px; }
.stepper button {
  width: 36px; height: 36px; border: 0; background: none; font-size: 1.2rem; cursor: pointer; color: var(--accent);
}
.stepper span { min-width: 22px; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }

.photo-check { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.photo-check summary { cursor: pointer; font-weight: 600; color: var(--accent); }
.photo-check img { width: 100%; margin-top: 12px; border-radius: 8px; }
.meta { font-size: .75rem; color: var(--muted); text-align: center; margin: 0; }

/* Feuille d'ajout */
.sheet { position: fixed; inset: 0; z-index: 20; }
.sheet-backdrop { position: absolute; inset: 0; background: rgb(0 0 0 / .4); }
.sheet-panel {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 85dvh;
  background: var(--bg); border-radius: 18px 18px 0 0;
  display: flex; flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom);
}
.sheet-head { display: flex; gap: 12px; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.sheet-head input {
  flex: 1; min-height: 44px; padding: 0 14px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface);
}
.menu-list { overflow-y: auto; padding: 4px 16px 16px; }
.menu-list h3 { font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 16px 0 6px; }
.menu-item {
  display: flex; justify-content: space-between; width: 100%;
  padding: 12px 4px; border: 0; border-bottom: 1px solid var(--line); background: none; text-align: left; cursor: pointer;
}
.menu-item span:last-child { color: var(--muted); font-variant-numeric: tabular-nums; }
