:root {
  --bg: #0f1f1b; --card: #16302a; --card2: #1d3b33; --line: #2a4a41;
  --text: #f3ead8; --muted: #9fb8ad; --accent: #ff7a2f; --ok: #7fd1a8; --warn: #ffb35c; --blue: #8cc7d6;
  --r: 14px;
  --display: 'Unbounded', 'Arial Black', sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 'DM Sans', system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { background: radial-gradient(120% 60% at 50% 0%, #1f4a3f 0%, var(--bg) 60%) fixed, var(--bg); }
body::after { content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 50; opacity: .07; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"); }
.brand { font-family: var(--display); font-weight: 800; letter-spacing: .02em; color: var(--text); }
.hidden { display: none !important; }
h1 { font-size: 18px; margin: 0; font-family: var(--display); font-weight: 700; letter-spacing: .01em; text-transform: uppercase; }
h2.sub { font-size: 15px; color: var(--muted); margin: 24px 0 8px; font-weight: 600; }
input, select, textarea {
  width: 100%; background: var(--card2); color: var(--text); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; font: inherit; outline: none;
}
input:focus, select:focus { border-color: var(--accent); }
label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: 8px; font-size: 13px; color: var(--text); }
label.check input { width: auto; }

.btn { border: 0; border-radius: 10px; padding: 10px 14px; font: inherit; font-weight: 600; cursor: pointer; background: var(--card2); color: var(--text); white-space: nowrap; }
.btn.primary { background: var(--accent); color: #1a120a; box-shadow: 0 0 18px rgba(255,122,47,.35); }
.btn.ok { background: var(--ok); color: #0c1f18; }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.small { padding: 6px 10px; font-size: 13px; }
.btn.wide { width: 100%; margin-top: 12px; padding: 13px; }
.btn:disabled { opacity: .5; cursor: default; }

.top { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px; padding-top: max(14px, env(safe-area-inset-top)); background: rgba(15,31,27,.88); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line); }
.top::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 3px; background: linear-gradient(90deg, #ff9a4d, #ffd9a8 50%, #ff9a4d);
  box-shadow: 0 0 14px 2px rgba(255,140,60,.65); }
.top .left { display: flex; align-items: baseline; gap: 12px; }
.top .brand { font-size: 20px; }
.top h1 { font-size: 11px; color: var(--muted); font-weight: 600; letter-spacing: .12em; }
main { padding: 14px 14px 100px; max-width: 720px; margin: 0 auto; }
.bottom { position: fixed; bottom: 0; left: 0; right: 0; display: flex; background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom); z-index: 5; }
.bottom button { flex: 1; background: none; border: 0; color: var(--muted); padding: 8px 0 10px; font-size: 20px; display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer; }
.bottom button span { font-size: 11px; }
.bottom button.active { color: var(--accent); }
.bottom button span { font-family: var(--display); font-weight: 600; letter-spacing: .04em; font-size: 9px !important; text-transform: uppercase; }

.row { display: flex; gap: 8px; margin-bottom: 12px; }
.row .qty { width: 70px; flex: none; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; }
.list { display: flex; flex-direction: column; gap: 8px; }
.empty { color: var(--muted); text-align: center; padding: 28px 10px; }

.item { display: flex; gap: 10px; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px; }
.item img, .item .ph { width: 42px; height: 42px; border-radius: 8px; object-fit: cover; background: var(--card2); flex: none; display: grid; place-items: center; font-size: 20px; }
.item .main { flex: 1; min-width: 0; cursor: pointer; }
.item .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .meta { font-size: 12px; color: var(--muted); }
.item.done { opacity: .55; }
.item.done .name { text-decoration: line-through; }
.item input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--ok); flex: none; }
.stepper { display: flex; align-items: center; gap: 4px; flex: none; }
.stepper button { width: 30px; height: 30px; border-radius: 8px; border: 0; background: var(--card2); color: var(--text); font-size: 16px; cursor: pointer; }
.stepper .v { min-width: 56px; text-align: center; font-size: 13px; cursor: pointer; }

.badge { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 99px; background: var(--card2); color: var(--muted); margin-left: 4px; }
.badge.manuel { background: rgba(62,207,142,.15); color: var(--ok); }
.badge.openprices { background: rgba(90,169,255,.15); color: var(--blue); }
.badge.none { background: rgba(245,185,66,.15); color: var(--warn); }
.price { font-weight: 700; flex: none; }

.summary { display: flex; justify-content: space-between; color: var(--muted); font-size: 13px; padding: 10px 2px; }
.summary b { color: var(--text); }

.recipe { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; }
.recipe h3 { margin: 2px 0 8px; font-size: 15px; font-family: var(--display); font-weight: 700; line-height: 1.25; }
.recipe .sum { color: var(--muted); font-size: 13px; margin: 0 0 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.chip { background: var(--card2); border-radius: 99px; padding: 4px 10px; font-size: 12px; }
.recipe ul, .recipe ol { margin: 6px 0 10px; padding-left: 20px; }
.recipe ul { list-style: none; padding-left: 0; }
.recipe li { margin: 3px 0; }
.recipe .buy { color: var(--warn); }
.recipe details summary { cursor: pointer; color: var(--blue); font-size: 13px; margin: 4px 0; }
.recipe .actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--card); width: 100%; max-width: 560px; max-height: 92vh; overflow: auto; border-radius: 18px 18px 0 0;
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 10px; }
@media (min-width: 700px) { .modal { align-items: center; } .sheet { border-radius: 18px; } }
.sheet h2 { margin: 0 0 4px; font-size: 16px; font-family: var(--display); font-weight: 700; text-transform: uppercase; }
.hint { font-size: 12px; color: var(--muted); background: var(--card2); border-radius: 10px; padding: 8px 10px; }
.hint.blue { border-left: 3px solid var(--blue); }
.hint.warn { border-left: 3px solid var(--warn); }
#reader { width: 100%; border-radius: 12px; overflow: hidden; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; position: relative; overflow: hidden;
  background: repeating-linear-gradient(0deg, transparent 0 46px, rgba(0,0,0,.18) 46px 48px), repeating-linear-gradient(90deg, transparent 0 94px, rgba(0,0,0,.14) 94px 96px),
    radial-gradient(90% 70% at 50% 30%, #3f7d6b 0%, #1d3f36 55%, #0f1f1b 100%); }
.login::before { content: ''; position: absolute; left: 8%; right: 8%; top: 7%; height: 6px; border-radius: 3px; background: #ffe2bd;
  box-shadow: 0 0 22px 6px rgba(255,130,50,.8), 0 0 60px 18px rgba(255,110,40,.35); }
.login form { background: rgba(15,31,27,.72); backdrop-filter: blur(6px); }
.login .logo { font-family: var(--display); font-weight: 900; font-size: 46px; text-align: center; margin: 4px 0 2px; letter-spacing: .01em; }
.login .tag { text-align: center; color: var(--muted); font-size: 12px; letter-spacing: .14em; text-transform: uppercase; margin: 0 0 8px; }
.login form { width: 100%; max-width: 340px; display: flex; flex-direction: column; gap: 12px; }
.err { color: var(--accent); font-size: 13px; margin: 0; min-height: 1em; }

.toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); background: var(--text); color: #0f1f1b;
  padding: 10px 16px; border-radius: 99px; font-weight: 600; font-size: 14px; z-index: 30; max-width: 90vw; text-align: center; }
.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.3); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -3px; }
@keyframes spin { to { transform: rotate(360deg); } }
label.inline { flex-direction: row; align-items: center; gap: 8px; white-space: nowrap; font-size: 13px; }
label.inline input { width: 80px; }
.row select { flex: 1; }
details summary.sub { cursor: pointer; list-style: revert; margin: 0 0 10px; }
.status { display: inline-block; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 99px; margin-bottom: 6px; }
.status.ok { background: rgba(62,207,142,.15); color: var(--ok); }
.status.almost { background: rgba(245,185,66,.15); color: var(--warn); }
.status.no { background: rgba(255,90,95,.13); color: var(--accent); }
.recipe li.low, .recipe li.missing { color: var(--warn); }
.recipe li.opt { color: var(--muted); }
.recipe li small { color: var(--muted); }
textarea { min-height: 110px; resize: vertical; }

/* ---------- Scanner plein écran ---------- */
.scanner { position: fixed; inset: 0; z-index: 40; background: #000; color: var(--text); overflow: hidden; }
.scanner video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.scan-shade { position: absolute; inset: 0; pointer-events: none;
  background: transparent; }
.scan-top { z-index: 2; position: absolute; top: 0; left: 0; right: 0; display: flex; justify-content: space-between; align-items: center;
  padding: max(14px, env(safe-area-inset-top)) 14px 14px; background: linear-gradient(rgba(10,20,17,.9), transparent); }
.scan-top .brand { font-size: 15px; letter-spacing: .12em; }
.scan-back { width: 44px; height: 44px; border-radius: 50%; border: 0; background: rgba(15,31,27,.75); color: var(--text); font-size: 26px; line-height: 1; cursor: pointer; }
#scanTorch { font-size: 18px; }
.scan-title { z-index: 2; position: absolute; top: 24%; left: 0; right: 0; text-align: center; font-family: var(--display); font-weight: 700; font-size: 16px; margin: 0; padding: 0 20px; text-shadow: 0 2px 10px #000; }
.scan-frame { position: absolute; left: 50%; top: 46%; transform: translate(-50%, -50%); width: 82vw; max-width: 420px; height: 30vw; max-height: 170px;
  border: 3px solid var(--text); border-radius: 18px; box-shadow: 0 0 0 100vmax rgba(10,20,17,.62), 0 0 24px rgba(255,122,47,.25); }
.scan-line { position: absolute; left: 6%; right: 6%; height: 2px; top: 50%; background: var(--accent); box-shadow: 0 0 12px 2px rgba(255,122,47,.8); animation: scanmove 1.6s ease-in-out infinite; }
@keyframes scanmove { 0%,100% { top: 18%; } 50% { top: 82%; } }
.scanner.found .scan-frame { border-color: var(--ok); box-shadow: 0 0 0 100vmax rgba(10,20,17,.62), 0 0 30px rgba(127,209,168,.6); }
.scan-status { z-index: 2; position: absolute; top: calc(46% + 110px); left: 0; right: 0; text-align: center; color: var(--muted); font-size: 14px; margin: 0; padding: 0 24px; text-shadow: 0 1px 6px #000; }
.scan-manual { z-index: 2; position: absolute; left: 50%; transform: translateX(-50%); bottom: max(28px, env(safe-area-inset-bottom)); background: rgba(15,31,27,.85); border: 1px solid var(--line); }
.field-alert { border-color: var(--warn) !important; box-shadow: 0 0 0 3px rgba(255,179,92,.2); }
.scan-cta { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; padding: 14px; margin-bottom: 12px; font-family: var(--display); font-size: 13px; letter-spacing: .04em; }

/* ---------- Photos des plats ---------- */
.recipe.has-media { padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.r-media { position: relative; aspect-ratio: 16 / 10; background: linear-gradient(135deg, #24463d, #16302a); overflow: hidden; }
.r-media img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: 1; }
.r-media .ph { position: absolute; inset: 0; display: grid; place-items: center; font-size: 44px; opacity: .5; }
.r-media::after { content: ''; position: absolute; inset: auto 0 0 0; height: 40%; z-index: 2; background: linear-gradient(transparent, rgba(22,48,42,.85)); }
.r-body { padding: 12px 14px 14px; display: flex; flex-direction: column; flex: 1; }
.r-body .actions { margin-top: auto; padding-top: 8px; }

/* ---------- PC : 3 recettes par ligne ---------- */
@media (min-width: 900px) {
  main { max-width: 1180px; }
  #tab-stock, #tab-courses, #tab-produits { max-width: 720px; margin: 0 auto; }
  #tab-recettes > .row, #tab-recettes > #bookSummary { max-width: 720px; }
  .list.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; align-items: stretch; }
  .list.grid .empty { grid-column: 1 / -1; }
}
@media (min-width: 640px) and (max-width: 899px) {
  .list.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .list.grid .empty { grid-column: 1 / -1; }
}
.r-media.ing img { object-fit: contain; padding: 8% 22% 14%; filter: drop-shadow(0 8px 18px rgba(0,0,0,.45)); }
.r-media.ing { background: radial-gradient(circle at 50% 45%, #3c6e60, #16302a 75%); }
