/* Стиль «Хлеб и Эклер»: тёплая бумага, винно-бордовая стена с буквенной доской,
   Cormorant Garamond для заголовков, Manrope для текста, Oswald для плиток доски. */
:root {
  --paper: #f5f3f0;
  --surface: #fffdfb;
  --ink: #262422;
  --ink-soft: #6a625d;
  --line: #e2ddd8;
  --wine: #7a3a3f;
  --wine-deep: #5e2a2e;
  --wine-tint: rgba(122, 58, 63, 0.09);
  --leaf: #5c7633;
  --leaf-tint: rgba(92, 118, 51, 0.12);
  --warn: #a4532b;
  --warn-tint: rgba(164, 83, 43, 0.12);
  --board-tile: #1f1d1c;
  --board-text: #ece6da;
  --board-label: #e9d6d2;
  --on-wine: #f6efe9;
  --display: 'Cormorant Garamond', 'Times New Roman', Georgia, serif;
  --body: 'Manrope', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --board: 'Oswald', 'Arial Narrow', 'Segoe UI', sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    color-scheme: dark;
    --paper: #1b1a19;
    --surface: #242220;
    --ink: #efeae4;
    --ink-soft: #b0a8a1;
    --line: #393532;
    --wine: #c4696f;
    --wine-deep: #6a3034;
    --wine-tint: rgba(196, 105, 111, 0.14);
    --leaf: #9dbd64;
    --leaf-tint: rgba(157, 189, 100, 0.14);
    --warn: #e08a5f;
    --warn-tint: rgba(224, 138, 95, 0.14);
    --board-tile: #161514;
  }
}
:root[data-theme='dark'] {
  color-scheme: dark;
  --paper: #1b1a19;
  --surface: #242220;
  --ink: #efeae4;
  --ink-soft: #b0a8a1;
  --line: #393532;
  --wine: #c4696f;
  --wine-deep: #6a3034;
  --wine-tint: rgba(196, 105, 111, 0.14);
  --leaf: #9dbd64;
  --leaf-tint: rgba(157, 189, 100, 0.14);
  --warn: #e08a5f;
  --warn-tint: rgba(224, 138, 95, 0.14);
  --board-tile: #161514;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--paper); color: var(--ink); }
body {
  font: 15px/1.55 var(--body);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
button:focus-visible, .input:focus-visible { outline: 2px solid var(--wine); outline-offset: 2px; }
input, textarea, select { font: inherit; color: var(--ink); }
.ic { display: inline-flex; }

.screen { max-width: 480px; margin: 0 auto; padding: 0 16px 112px; }
.muted { color: var(--ink-soft); }
.small { font-size: 13px; }
.center { text-align: center; }
.row-gap { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- шапка ---------- */
.topbar {
  position: sticky; top: 0; z-index: 15;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin: 0 -16px 18px; padding: 12px 16px;
  background: color-mix(in srgb, var(--paper) 90%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { font-family: var(--display); font-size: 22px; font-weight: 600; line-height: 1.1; white-space: nowrap; }
.brand i, .wordmark i { color: var(--wine); font-weight: 500; }
.hello { color: var(--ink-soft); font-size: 13px; }
.eyebrow { font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-soft); font-weight: 500; }
.section-title { font-family: var(--display); font-size: 32px; font-weight: 500; line-height: 1.1; margin: 4px 0 16px; }
.section-title.sm { font-family: var(--body); font-size: 12px; margin: 26px 0 10px; color: var(--ink-soft); font-weight: 500; letter-spacing: 0.14em; text-transform: uppercase; }
.role-chip { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink); }
.role-chip::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--leaf); }

/* ---------- плитки буквенной доски ---------- */
.tile {
  display: inline-block; font-family: var(--board); text-transform: uppercase; letter-spacing: 0.06em;
  background: var(--board-tile); color: var(--board-text);
  padding: 1px 7px; border-radius: 2px; font-size: 14px; line-height: 1.55; font-weight: 400;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.35);
}
.tile.leaf { background: var(--leaf); color: #f4f7ec; }
.tiles { display: flex; flex-wrap: wrap; gap: 5px; }

/* ---------- карта гостя: бордовая стена ---------- */
.loyalty {
  position: relative;
  border-radius: 4px;
  padding: 22px 20px 20px;
  background: var(--wine-deep);
  color: var(--on-wine);
  overflow: hidden;
}
.loyalty .head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.loyalty .eyebrow { color: var(--board-label); }
.counter { font-family: var(--display); font-size: 68px; font-weight: 500; line-height: 0.9; font-variant-numeric: lining-nums tabular-nums; }
.counter .cur { color: var(--on-wine); transition: color 0.3s; }
.counter .of { color: rgba(246, 239, 233, 0.55); font-size: 0.55em; font-style: italic; margin-left: 2px; }
.counter.ready .cur { color: #c9dd9a; }
.stamps { display: grid; gap: 14px; margin: 22px 6px 18px; }
.cell {
  aspect-ratio: 1;
  border-radius: 50%;
  border: 1.5px dashed rgba(236, 230, 218, 0.38);
  display: grid; place-items: center;
  transition: background 0.3s, border-color 0.3s, transform 0.3s;
}
.cell svg { width: 46%; height: 46%; }
.cell.filled { background: var(--board-text); border: 1.5px solid var(--board-text); color: #5e2a2e; box-shadow: 0 2px 0 rgba(0, 0, 0, 0.25); }
.cell.pop { animation: pop 0.6s cubic-bezier(0.2, 1.6, 0.4, 1) both; }
.cell.gift { color: rgba(201, 221, 154, 0.6); border-color: rgba(201, 221, 154, 0.55); }
.cell.gift svg { fill: currentColor; stroke: none; }
.cell.gift.ready { animation: pulse 1.6s ease-in-out infinite; color: #c9dd9a; border-color: #c9dd9a; border-style: solid; }
.cell.gift.done { background: #5c7633; border: 1.5px solid #c9dd9a; color: #f4f7ec; animation: pop 0.7s cubic-bezier(0.2, 1.6, 0.4, 1); }
@keyframes pop { 0% { transform: scale(0.4); } 100% { transform: scale(1); } }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(201, 221, 154, 0.45); transform: scale(1); }
  50% { box-shadow: 0 0 0 9px rgba(201, 221, 154, 0); transform: scale(1.04); }
}
.hint { font-size: 14px; color: rgba(246, 239, 233, 0.78); }
.hint b { color: var(--on-wine); font-weight: 600; }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 99px; font-weight: 500; font-size: 13px; }
.pill.green { background: var(--leaf-tint); color: var(--leaf); }
.pill.soft { background: var(--line); color: var(--ink); }
.pill.orange { background: var(--wine-tint); color: var(--wine); }
.pill.red { background: var(--warn-tint); color: var(--warn); }

.coupon {
  margin-top: 14px; padding: 14px 16px; border-radius: 4px;
  background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--wine);
  display: flex; gap: 12px; align-items: center;
}
.coupon .em { font-size: 24px; }
.coupon b { font-family: var(--display); font-size: 21px; font-weight: 500; font-style: italic; color: var(--wine); }

/* ---------- QR ---------- */
.qr-card { margin-top: 14px; border-radius: 4px; background: var(--surface); border: 1px solid var(--line); padding: 20px 18px 14px; text-align: center; }
.qr-box { position: relative; width: 220px; height: 220px; margin: 0 auto; background: #fff; border-radius: 4px; border: 1px solid var(--line); display: grid; place-items: center; overflow: hidden; }
.qr-box canvas { width: 200px; height: 200px; image-rendering: pixelated; }
.qr-overlay { position: absolute; inset: 0; background: rgba(255, 253, 251, 0.95); display: grid; place-items: center; color: var(--leaf); font-family: var(--display); font-style: italic; font-weight: 600; font-size: 22px; padding: 16px; line-height: 1.2; }
.qr-code { margin-top: 14px; font-family: var(--board); font-size: 28px; letter-spacing: 0.14em; font-variant-numeric: tabular-nums; }
.ttl { height: 2px; background: var(--line); margin: 10px auto 10px; width: 180px; overflow: hidden; }
.ttl i { display: block; height: 100%; background: var(--wine); transition: width 0.5s linear; }
.qr-label { font-size: 12px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--wine); font-weight: 600; }

/* ---------- прайс-лист с отточием ---------- */
.leaders { list-style: none; margin: 0; padding: 0; }
.leaders li { display: flex; align-items: baseline; gap: 8px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.leaders li:last-child { border-bottom: 0; }
.leaders .name { font-family: var(--display); font-size: 19px; }
.leaders .dots-line { flex: 1; border-bottom: 1px dotted var(--ink-soft); opacity: 0.45; transform: translateY(-4px); }
.leaders .p { font-weight: 600; font-size: 14px; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ---------- кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  padding: 12px 22px; border-radius: 99px; background: var(--wine-deep); color: var(--on-wine);
  font-weight: 500; font-size: 15px; transition: transform 0.15s, background 0.2s, opacity 0.2s; min-height: 48px;
}
.btn:hover { background: var(--wine); }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.38; cursor: not-allowed; }
.btn.block { width: 100%; }
.btn.big { width: 100%; min-height: 60px; font-size: 17px; }
.btn.big svg { width: 24px; height: 24px; }
.btn svg { width: 20px; height: 20px; }
.btn.green { background: var(--leaf); color: #f7faf0; }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn.ghost:hover { border-color: var(--ink-soft); }
.btn.danger { background: transparent; color: var(--warn); border: 1px solid var(--warn-tint); }
.btn.sm { min-height: 34px; padding: 6px 14px; font-size: 13.5px; }
.link { color: var(--ink-soft); text-decoration: underline; text-underline-offset: 4px; padding: 6px; font-size: 14px; }
.link:hover { color: var(--wine); }

.input, .textarea {
  width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 12px 14px; outline: none;
}
.input:focus, .textarea:focus { border-color: var(--wine); }
.textarea { min-height: 110px; resize: vertical; }

/* ---------- нижняя навигация ---------- */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: center; gap: 4px; padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--paper) 92%, transparent); backdrop-filter: blur(10px); border-top: 1px solid var(--line);
}
.nav button { flex: 1; max-width: 150px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px; color: var(--ink-soft); font-size: 12px; font-weight: 500; letter-spacing: 0.02em; }
.nav button svg { width: 22px; height: 22px; }
.nav button.on { color: var(--wine); }
.nav button.on::after { content: ''; width: 18px; height: 2px; background: var(--wine); margin-top: 2px; }

/* ---------- скан ---------- */
.code-entry { display: flex; gap: 8px; margin-top: 10px; }
.code-entry .input { text-align: center; font-family: var(--board); font-size: 22px; letter-spacing: 0.16em; }
.scan-card { margin-top: 16px; border-radius: 4px; background: var(--surface); border: 1px solid var(--line); padding: 16px; }
.who { display: flex; gap: 12px; align-items: center; }
.avatar { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-family: var(--display); font-weight: 600; font-size: 22px; flex: none; color: var(--wine-deep); }
.who b { font-family: var(--display); font-size: 22px; font-weight: 500; line-height: 1.1; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0; }
.stepper { display: flex; align-items: center; justify-content: space-between; border: 1px solid var(--line); border-radius: 99px; padding: 4px; margin: 10px 0; }
.stepper button { width: 44px; height: 44px; border-radius: 50%; background: var(--wine-tint); color: var(--wine); font-size: 22px; font-weight: 500; }
.stepper button:disabled { opacity: 0.3; }
.stepper .val { font-family: var(--display); font-weight: 500; font-size: 22px; }
.stack { display: grid; gap: 10px; }
.done-line { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 10px 10px 16px; border-radius: 99px; background: var(--leaf-tint); color: var(--leaf); font-weight: 600; }

.mini { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.dots { display: flex; gap: 5px; flex: none; }
.dots i { width: 10px; height: 10px; border-radius: 50%; border: 1px dashed var(--ink-soft); opacity: 0.8; }
.dots i.f { background: var(--wine); border: 1px solid var(--wine); opacity: 1; }
.dots i.g { border-color: var(--leaf); }
.dots i.g.r { background: var(--leaf); border-style: solid; }
.mini .num { font-family: var(--display); font-size: 20px; font-weight: 600; font-variant-numeric: lining-nums tabular-nums; }

.list { display: grid; gap: 0; border-top: 1px solid var(--line); }
.op { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 2px; border-bottom: 1px solid var(--line); }
.op b { font-family: var(--display); font-size: 19px; font-weight: 500; }
.op.reverted { opacity: 0.5; text-decoration: line-through; }

/* ---------- владелец ---------- */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { border-radius: 4px; background: var(--surface); border: 1px solid var(--line); padding: 14px; min-width: 0; text-align: left; }
.stat .v { font-family: var(--display); font-size: 34px; font-weight: 500; line-height: 1.05; font-variant-numeric: lining-nums tabular-nums; }
.stat .l { font-size: 12.5px; color: var(--ink-soft); line-height: 1.35; margin-top: 2px; }
.stat.wide { grid-column: span 2; }
.subtabs { display: flex; gap: 18px; overflow-x: auto; margin: 22px -16px 14px; padding: 0 16px; border-bottom: 1px solid var(--line); scrollbar-width: none; }
.subtabs::-webkit-scrollbar { display: none; }
.subtabs .chip { border-radius: 0; background: none; padding: 8px 0 10px; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.subtabs .chip.on { background: none; color: var(--ink); border-bottom-color: var(--wine); }
.chip { flex: none; padding: 6px 14px; border-radius: 99px; background: transparent; color: var(--ink-soft); font-weight: 500; font-size: 14px; border: 1px solid var(--line); }
.chip.on { background: var(--wine-tint); color: var(--wine); border-color: transparent; }
.guest-row { display: flex; align-items: center; gap: 12px; padding: 10px 8px; border-bottom: 1px solid var(--line); text-align: left; width: 100%; cursor: pointer; transition: background 0.2s; }
.guest-row.sel { background: var(--wine-tint); box-shadow: inset 3px 0 0 var(--wine); }
.guest-row .meta { flex: 1; min-width: 0; }
.guest-row .meta b { display: block; font-family: var(--display); font-size: 19px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.guest-row .meta small { color: var(--ink-soft); font-size: 12.5px; }
.guest-row .open { color: var(--ink-soft); padding: 6px 4px; font-size: 22px; font-family: var(--display); }
.selbar { position: fixed; left: 0; right: 0; bottom: 70px; z-index: 19; display: flex; justify-content: center; padding: 0 16px; }
.selbar .inner { max-width: 448px; width: 100%; display: flex; gap: 8px; align-items: center; justify-content: space-between; background: var(--wine-deep); color: var(--on-wine); padding: 8px 8px 8px 18px; border-radius: 99px; font-weight: 500; box-shadow: 0 10px 30px rgba(38, 36, 34, 0.25); }
.selbar .btn { background: var(--on-wine); color: var(--wine-deep); }
.field { display: grid; gap: 6px; margin-bottom: 12px; }
.field label { font-size: 13px; color: var(--ink-soft); }
.box { border-radius: 4px; background: var(--surface); border: 1px solid var(--line); padding: 16px; }
.invite { word-break: break-all; font: 13px var(--mono); background: var(--paper); border: 1px dashed var(--line); border-radius: 4px; padding: 10px; margin: 8px 0; user-select: all; }

/* ---------- модалка ---------- */
.sheet-bg { position: fixed; inset: 0; background: rgba(38, 36, 34, 0.45); z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 480px; max-height: 88vh; overflow: auto; background: var(--paper); border-radius: 14px 14px 0 0; padding: 18px 16px 28px; }
.sheet .grab { width: 40px; height: 3px; border-radius: 3px; background: var(--line); margin: -4px auto 14px; }
.ev { display: flex; justify-content: space-between; gap: 8px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.ev.rev { opacity: 0.45; text-decoration: line-through; }

/* ---------- тост и конфетти ---------- */
#toast { position: fixed; top: 12px; left: 50%; transform: translateX(-50%) translateY(calc(-100% - 24px)); z-index: 60; padding: 11px 20px; border-radius: 99px; font-weight: 500; background: var(--ink); color: var(--paper); box-shadow: 0 10px 30px rgba(38, 36, 34, 0.25); transition: transform 0.3s; max-width: calc(100vw - 32px); }
#toast.show { transform: translateX(-50%) translateY(0); }
#toast.err { background: var(--warn); color: #fff; }
#toast.warn { background: var(--wine-deep); color: var(--on-wine); }
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 50; width: 100vw; height: 100vh; }

.empty { padding: 26px 12px; text-align: center; color: var(--ink-soft); font-family: var(--display); font-size: 19px; font-style: italic; }
.consent { text-align: center; padding-top: 26px; }
.consent .loyalty { text-align: left; }
.consent h1 { font-family: var(--display); font-size: 40px; font-weight: 400; line-height: 1.05; margin: 22px 0 10px; }
.consent p { color: var(--ink-soft); }
.legal { font-size: 12.5px; color: var(--ink-soft); margin-top: 14px; line-height: 1.5; }
.spinner { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--wine); animation: spin 0.8s linear infinite; margin: 60px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
