:root {
  --bg: #f6f7f8; --card: #ffffff; --ink: #14181f; --muted: #5d6673; --line: #e3e6ea;
  --accent: #0f766e; --wa: #1fa855; --wa-ink: #ffffff; --out: #9aa1ab; --shadow: 0 1px 2px rgba(0,0,0,.06), 0 2px 8px rgba(0,0,0,.04);
  --r: 14px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f1216; --card: #181c22; --ink: #eef1f4; --muted: #9aa3ae; --line: #262b33; --accent: #2dd4bf; --out: #6b7280; --shadow: none; }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--ink); }
img { display: block; max-width: 100%; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: var(--accent); }
[hidden] { display: none !important; }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; background: var(--card); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.logo { width: 48px; height: 48px; border-radius: 12px; object-fit: cover; flex: none; background: var(--bg); }
.logo.big { width: 88px; height: 88px; border-radius: 20px; margin: 0 auto 12px; }
.logo-initial { display: grid; place-items: center; font-weight: 700; font-size: 22px; color: #fff; background: var(--accent); }
.brand-text { min-width: 0; }
.brand-text h1 { margin: 0; font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-text p { margin: 2px 0 0; font-size: 13px; color: var(--muted); }
.wa-chip { flex: none; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; background: var(--wa); color: var(--wa-ink); }

.wrap { max-width: 1080px; margin: 0 auto; padding: 12px 16px 120px; }
.search input { width: 100%; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); color: var(--ink); font-size: 16px; }
.toggle { display: inline-flex; align-items: center; gap: 10px; margin: 12px 0 0; font-size: 15px; color: var(--ink); cursor: pointer; user-select: none; }
.toggle small { color: var(--muted); }
.toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.toggle .switch { position: relative; flex: none; width: 42px; height: 24px; border-radius: 999px; background: var(--line); transition: background .15s; }
.toggle .switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .15s; }
.toggle input:checked + .switch { background: var(--accent); }
.toggle input:checked + .switch::after { transform: translateX(18px); }
.toggle input:focus-visible + .switch { outline: 2px solid var(--accent); outline-offset: 2px; }
.notice { margin: 12px 0 0; padding: 10px 12px; border-radius: 10px; background: #fff7e6; color: #7a4b00; font-size: 14px; }
@media (prefers-color-scheme: dark) { .notice { background: #3a2c0d; color: #f7d58b; } }

.grid { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 640px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 900px) { .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.card { display: flex; flex-direction: column; background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); overflow: hidden; border: 1px solid var(--line); }
.card-open { display: block; padding: 0; border: 0; background: var(--bg); aspect-ratio: 1; width: 100%; }
.card-open img { width: 100%; height: 100%; object-fit: cover; }
.ph { display: grid; place-items: center; width: 100%; height: 100%; font-size: 40px; font-weight: 700; color: var(--muted); }
.card-body { display: flex; flex-direction: column; gap: 6px; padding: 10px 12px 12px; flex: 1; }
.card-body h2 { margin: 0; font-size: 14px; font-weight: 600; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.price { margin: 0; font-weight: 700; font-size: 16px; }
.price small { font-weight: 500; font-size: 12px; color: var(--muted); }
.add { margin-top: auto; padding: 9px; border: 0; border-radius: 10px; background: var(--accent); color: #fff; font-weight: 600; }
.card.out { opacity: .6; }
.lvl { margin: 0; font-size: 12px; font-weight: 600; }
.lvl-well_stocked, .lvl-available { color: #15803d; }
.lvl-running_out { color: #b45309; }
.lvl-last_units { color: #c2410c; }
@media (prefers-color-scheme: dark) { .lvl-well_stocked, .lvl-available { color: #4ade80; } .lvl-running_out { color: #fbbf24; } .lvl-last_units { color: #fb923c; } }
.sold { margin-top: auto; padding: 9px; text-align: center; border-radius: 10px; background: var(--bg); color: var(--out); font-weight: 600; font-size: 14px; }
.empty { text-align: center; color: var(--muted); margin: 32px 0; }
.foot { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin: 32px 0 0; font-size: 13px; color: var(--muted); }

.cartbar { position: fixed; z-index: 6; left: 12px; right: 12px; bottom: max(12px, env(safe-area-inset-bottom)); max-width: 560px; margin: 0 auto;
  display: flex; gap: 8px; border-radius: 14px; box-shadow: 0 6px 20px rgba(0,0,0,.18); }
.cartbar-view { flex: 1; min-width: 0; display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 14px 16px;
  border: 0; border-radius: 14px; background: var(--accent); color: #fff; font-size: 15px; font-weight: 600; }
.cartbar-view span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cartbar-send { flex: none; display: flex; align-items: center; gap: 6px; padding: 14px 16px; border: 0; border-radius: 14px;
  background: var(--wa); color: var(--wa-ink); font-size: 15px; font-weight: 700; }
.cartbar-send:disabled { opacity: .6; }

.sheet { position: fixed; inset: 0; z-index: 10; display: flex; align-items: flex-end; justify-content: center; }
.sheet-bg { position: absolute; inset: 0; background: rgba(0,0,0,.45); }
.sheet-card { position: relative; width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto; background: var(--card);
  border-radius: 18px 18px 0 0; padding: 20px 16px max(20px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 12px; }
@media (min-width: 640px) { .sheet { align-items: center; } .sheet-card { border-radius: 18px; } }
.x { position: absolute; top: 8px; right: 8px; width: 40px; height: 40px; border: 0; border-radius: 50%; background: var(--bg); font-size: 24px; line-height: 1; z-index: 1; }
.d-img img, .d-img .ph { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 12px; background: var(--bg); }
.d-img .ph { display: grid; }
.sheet-card h2 { margin: 0; font-size: 20px; padding-right: 40px; }
.qty { display: flex; align-items: center; justify-content: center; gap: 10px; }
.qty button { width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); font-size: 22px; }
.qty input { width: 90px; padding: 10px; text-align: center; border: 1px solid var(--line); border-radius: 12px; background: var(--card); color: var(--ink); font-size: 18px; }
.btn { display: block; width: 100%; padding: 14px; border: 0; border-radius: 12px; background: var(--accent); color: #fff; font-weight: 600; font-size: 16px; text-align: center; text-decoration: none; }
.btn-wa { background: var(--wa); color: var(--wa-ink); }
.btn-ghost { background: transparent; color: var(--accent); border: 1px solid var(--line); }
.btn-link { border: 0; background: none; color: var(--muted); text-decoration: underline; padding: 6px; }

.lines { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.line { display: grid; grid-template-columns: 52px 1fr auto; gap: 10px; align-items: center; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.line img, .line .ph { width: 52px; height: 52px; border-radius: 10px; object-fit: cover; background: var(--bg); font-size: 20px; }
.line .ph { display: grid; }
.line-name { margin: 0; font-size: 14px; font-weight: 600; }
.line-sub { margin: 2px 0 6px; font-size: 13px; color: var(--muted); }
.line .qty { justify-content: flex-start; gap: 6px; }
.line .qty button { width: 34px; height: 34px; font-size: 18px; border-radius: 10px; }
.line .qty input { width: 64px; padding: 6px; font-size: 15px; border-radius: 10px; }
.line-total { font-weight: 700; text-align: right; }
.line-rm { border: 0; background: none; color: var(--muted); font-size: 13px; text-decoration: underline; padding: 4px 0 0; }
.line.gone { opacity: .55; }
.total { display: flex; justify-content: space-between; font-size: 18px; padding-top: 4px; }
.hint { margin: 0; font-size: 13px; color: var(--muted); }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 14px; font-weight: 600; }
.field-label em { font-style: normal; font-weight: 400; color: var(--muted); }
.field input, .field textarea { padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--ink); font: inherit; font-weight: 400; }

body.center { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.msg { max-width: 420px; text-align: center; }
.msg h1 { margin: 0 0 8px; }
.msg p { color: var(--muted); }
.msg .btn { margin-top: 16px; }
.msg .btn-gap { margin-top: 10px; }

body.print { background: #fff; color: #111; }
.qr-sheet { max-width: 520px; margin: 0 auto; padding: 32px 16px; text-align: center; }
.qr-sheet h1 { margin: 0; font-size: 30px; }
.qr-lead { font-size: 18px; color: #333; }
.qr-img { width: min(360px, 100%); height: auto; margin: 16px auto; image-rendering: pixelated; }
.qr-url { font-size: 20px; font-weight: 700; letter-spacing: .3px; word-break: break-all; }
.qr-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 24px; }
@media print { .no-print { display: none !important; } .qr-sheet { padding-top: 0; } }
