:root {
  --bg: #f7f1e5;
  --card: #fffdf8;
  --ink: #221c14;
  --muted: #7a6f5f;
  --line: #e6dcc8;
  --olive: #55652b;
  --olive-soft: #e9edd9;
  --paprika: #c2452b;
  --paprika-dark: #a53520;
  --sand: #efe5d0;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(34, 28, 20, .06), 0 6px 18px rgba(34, 28, 20, .06);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; padding: 0; }
button:disabled { cursor: default; }
input, textarea { font: inherit; color: inherit; }
h1, h2, h3, p { margin: 0; }
.app { max-width: 560px; margin: 0 auto; min-height: 100vh; padding-bottom: 110px; }

.splash { display: grid; place-content: center; min-height: 100vh; text-align: center; gap: 8px; }
.splash-mark { font-size: 44px; font-weight: 800; letter-spacing: -.03em; color: var(--paprika); }
.splash-note { color: var(--muted); }

/* Шапка */
.top { padding: 18px 16px 10px; }
.brand-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { font-size: 26px; font-weight: 800; letter-spacing: -.03em; color: var(--paprika); }
.brand small { display: block; font-size: 12px; font-weight: 500; letter-spacing: 0; color: var(--muted); }
.table-chip {
  background: var(--ink); color: #fff; border-radius: 999px; padding: 8px 14px;
  font-weight: 700; font-size: 15px; white-space: nowrap;
}
.table-chip.plain { background: var(--sand); color: var(--ink); }
.mode { display: grid; grid-template-columns: 1fr 1fr; background: var(--sand); border-radius: 12px; padding: 4px; margin-top: 14px; }
.mode button { padding: 9px 8px; border-radius: 9px; font-weight: 600; font-size: 14px; color: var(--muted); }
.mode button.on { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.mode button:disabled { opacity: .45; }
.notice { margin: 10px 16px 0; padding: 10px 12px; border-radius: 12px; background: #fbe9d7; color: #7a3b12; font-size: 14px; }

/* Навигация по категориям */
.cats {
  position: sticky; top: 0; z-index: 5; display: flex; gap: 8px; overflow-x: auto; padding: 10px 16px;
  background: linear-gradient(var(--bg) 82%, rgba(247, 241, 229, 0)); scrollbar-width: none;
}
.cats::-webkit-scrollbar { display: none; }
.cats button {
  flex: none; padding: 8px 14px; border-radius: 999px; background: var(--card); border: 1px solid var(--line);
  font-size: 14px; font-weight: 600;
}
.section { padding: 6px 16px 10px; scroll-margin-top: 56px; }
.section h2 { font-size: 20px; letter-spacing: -.01em; margin: 12px 0 10px; }

.item {
  display: flex; gap: 12px; align-items: center; width: 100%; text-align: left;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 10px;
}
.item-body { flex: 1; min-width: 0; }
.item-name { font-weight: 700; }
.item-desc { color: var(--muted); font-size: 14px; margin-top: 2px; }
.item-price { margin-top: 8px; font-weight: 700; }
.add {
  flex: none; width: 40px; height: 40px; border-radius: 12px; background: var(--olive-soft); color: var(--olive);
  display: grid; place-content: center; font-size: 24px; font-weight: 500; line-height: 1;
}
.item.builder { background: var(--olive); border-color: var(--olive); color: #fff; padding: 18px 16px; }
.item.builder .item-desc { color: rgba(255, 255, 255, .8); }
.item.builder .add { background: rgba(255, 255, 255, .18); color: #fff; }
.badge { display: inline-block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; opacity: .85; margin-bottom: 4px; }

/* Нижняя панель */
.dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: linear-gradient(rgba(247, 241, 229, 0), var(--bg) 30%); pointer-events: none;
}
.dock-inner { max-width: 528px; margin: 0 auto; display: flex; gap: 8px; pointer-events: auto; }
.btn {
  display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%;
  background: var(--paprika); color: #fff; border-radius: 14px; padding: 15px 18px; font-weight: 700; font-size: 16px;
  box-shadow: 0 6px 16px rgba(194, 69, 43, .28);
}
.btn:active { background: var(--paprika-dark); }
.btn:disabled { background: #cfc4b0; box-shadow: none; }
.btn.secondary { background: var(--card); color: var(--ink); border: 1px solid var(--line); box-shadow: none; }
.btn.slim { width: auto; flex: none; padding: 15px 16px; }
.btn .count { background: rgba(255, 255, 255, .22); border-radius: 999px; padding: 1px 9px; font-size: 14px; }
.btn .sum { margin-left: auto; }

/* Экраны корзины, заказа, истории */
.page { padding: 16px; }
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-weight: 600; padding: 6px 0 12px; }
.page h1 { font-size: 26px; letter-spacing: -.02em; margin-bottom: 14px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.line { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.line:last-child { border-bottom: 0; padding-bottom: 0; }
.line:first-child { padding-top: 0; }
.line-body { flex: 1; min-width: 0; }
.line-name { font-weight: 600; }
.line-mods { color: var(--muted); font-size: 13px; margin-top: 2px; }
.line-sum { font-weight: 700; white-space: nowrap; }
.stepper { display: inline-flex; align-items: center; gap: 4px; margin-top: 8px; background: var(--sand); border-radius: 10px; }
.stepper button { width: 34px; height: 34px; font-size: 20px; font-weight: 600; }
.stepper span { min-width: 22px; text-align: center; font-weight: 700; }
.total-row { display: flex; justify-content: space-between; font-size: 18px; font-weight: 800; }
.field { display: block; width: 100%; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px; resize: vertical; }
.field:focus { outline: 2px solid var(--olive); outline-offset: 1px; }
.label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin: 0 0 6px 2px; }
.hint { color: var(--muted); font-size: 14px; }
.empty { text-align: center; color: var(--muted); padding: 48px 16px; }

.status-card { text-align: center; padding: 24px 16px; }
.order-no { font-size: 64px; font-weight: 800; letter-spacing: -.04em; line-height: 1; margin: 6px 0 12px; }
.status-pill { display: inline-block; padding: 8px 14px; border-radius: 999px; font-weight: 700; background: var(--sand); }
.status-pill.accepted, .status-pill.ready, .status-pill.completed { background: var(--olive-soft); color: var(--olive); }
.status-pill.payment_failed, .status-pill.cancelled { background: #f8ddd6; color: var(--paprika-dark); }
.status-pill.paid::before, .status-pill.awaiting_payment::before {
  content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: currentColor;
  margin-right: 8px; animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: .25; } }
.status-hint { color: var(--muted); margin-top: 10px; font-size: 14px; }
.stack { display: grid; gap: 8px; }
.history-item { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; }
.history-no { font-size: 22px; font-weight: 800; min-width: 54px; }

/* Шторка блюда / конструктора */
.sheet-backdrop { position: fixed; inset: 0; z-index: 20; background: rgba(34, 28, 20, .45); display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  width: 100%; max-width: 560px; max-height: 92vh; background: var(--bg); border-radius: 22px 22px 0 0;
  display: flex; flex-direction: column;
}
.sheet.enter { animation: rise .22s ease-out; }
@keyframes rise { from { transform: translateY(24px); opacity: 0; } }
.sheet-head { padding: 18px 16px 8px; display: flex; gap: 12px; align-items: flex-start; }
.sheet-head h2 { font-size: 22px; letter-spacing: -.02em; flex: 1; }
.close { width: 36px; height: 36px; border-radius: 50%; background: var(--sand); font-size: 20px; flex: none; }
.sheet-body { overflow-y: auto; padding: 4px 16px 16px; }
.sheet-foot { padding: 10px 16px calc(12px + env(safe-area-inset-bottom)); display: flex; gap: 10px; align-items: center; border-top: 1px solid var(--line); }
.sheet-foot .stepper { margin: 0; }
.group { margin-top: 14px; }
.group-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 8px; }
.group-head h3 { font-size: 16px; }
.group-rule { font-size: 12px; color: var(--muted); font-weight: 600; }
.group-rule.need { color: var(--paprika); }
.opt {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 6px;
}
.opt.on { border-color: var(--olive); background: var(--olive-soft); }
.opt:disabled { opacity: .45; }
.opt-mark { width: 20px; height: 20px; border-radius: 6px; border: 2px solid #c9bda6; flex: none; display: grid; place-content: center; font-size: 13px; color: #fff; }
.opt.single .opt-mark { border-radius: 50%; }
.opt.on .opt-mark { background: var(--olive); border-color: var(--olive); }
.opt-name { flex: 1; font-weight: 600; }
.opt-price { color: var(--muted); font-size: 14px; }

.dialog { margin: auto; max-width: 420px; width: calc(100% - 32px); background: var(--bg); border-radius: 20px; padding: 20px; align-self: center; }
.dialog p { margin-bottom: 16px; }
.dialog .stack { grid-template-columns: 1fr 1fr; }

.toast {
  position: fixed; left: 50%; bottom: 96px; transform: translate(-50%, 20px); z-index: 30; max-width: calc(100% - 32px);
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.fatal { min-height: 100vh; display: grid; place-content: center; text-align: center; padding: 24px; gap: 14px; }
.fatal h1 { font-size: 24px; }
.fatal p { color: var(--muted); max-width: 320px; margin: 0 auto; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
