:root {
  --bg: #f3f1ed;
  --surface: #ffffff;
  --ink: #17191d;
  --ink-2: #5b6068;
  --line: #e4e0d8;
  --accent: #f5a524;
  --accent-ink: #1b1406;
  --primary: #17191d;
  --primary-ink: #ffffff;
  --pos: #1f8a4c;
  --neg: #c2410c;
  --danger: #c0262d;
  --note: #fff4dc;
  --note-ink: #6b4a00;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(20, 20, 20, .06), 0 8px 24px rgba(20, 20, 20, .06);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1012;
    --surface: #1a1c20;
    --ink: #f2f0ec;
    --ink-2: #a2a6ad;
    --line: #2a2d33;
    --primary: #f5a524;
    --primary-ink: #1b1406;
    --pos: #4ade80;
    --neg: #fb923c;
    --danger: #f87171;
    --note: #2b2210;
    --note-ink: #f5d38a;
    --shadow: none;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}
h1 { font-size: 26px; line-height: 1.15; margin: 4px 0 6px; letter-spacing: -.02em; }
h2 { font-size: 15px; font-weight: 650; color: var(--ink-2); margin: 26px 2px 10px; text-transform: none; }
p { margin: 0 0 12px; }
a { color: inherit; }
b { font-weight: 700; }
.muted { color: var(--ink-2); }
.small { font-size: 13px; }
.center-text { text-align: center; }
.hidden { display: none !important; }

.screen { max-width: 520px; margin: 0 auto; padding: 18px 16px 40px; }
.screen.center { text-align: center; padding-top: 48px; }
.screen.center .btn { margin-top: 16px; }
.boot { display: grid; place-items: center; min-height: 70vh; }

.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid rgba(255,255,255,.25); border-top-color: var(--accent); animation: spin .8s linear infinite; margin: 8px auto; }
.spinner.dark { border-color: var(--line); border-top-color: var(--ink-2); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; min-height: 50px; padding: 12px 18px; border-radius: 14px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font: inherit; font-weight: 650; cursor: pointer; transition: transform .08s ease, opacity .15s;
}
.btn:active { transform: scale(.985); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--primary); color: var(--primary-ink); border-color: transparent; }
.btn.big { min-height: 56px; font-size: 17px; margin-top: 8px; }
.btn.huge { min-height: 92px; font-size: 19px; border-radius: 20px; margin: 6px 0 12px; }
.btn.huge svg { width: 30px; height: 30px; }
.link { background: none; border: 0; padding: 8px 0; font: inherit; color: var(--ink-2); cursor: pointer; font-weight: 600; }
.link.danger { color: var(--danger); }
.pill { font-size: 12px; font-weight: 650; padding: 4px 10px; border-radius: 999px; background: var(--line); color: var(--ink-2); }

.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.tile {
  display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 14px 6px;
  border-radius: 16px; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; box-shadow: var(--shadow);
}
.tile svg { width: 24px; height: 24px; color: var(--ink-2); }

/* ---------- панели и формы ---------- */
.panel { background: var(--surface); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); border: 1px solid var(--line); }
details.panel { margin-top: 18px; }
details summary { font-weight: 650; cursor: pointer; }
details[open] summary { margin-bottom: 10px; }
.form { display: grid; gap: 14px; }
.form label { display: grid; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.form input:not([type=checkbox]) {
  width: 100%; height: 50px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--bg); color: var(--ink); font: inherit; font-size: 18px; font-weight: 600;
  font-variant-numeric: tabular-nums; outline: none;
}
.form input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form small { font-weight: 500; }

.switch { display: flex !important; grid-template-columns: none; align-items: center; gap: 12px; font-size: 15px !important; color: var(--ink) !important; cursor: pointer; }
.switch input { position: absolute; opacity: 0; }
.switch span { width: 46px; height: 28px; border-radius: 999px; background: var(--line); position: relative; transition: background .15s; flex: none; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.switch input:checked + span { background: var(--pos); }
.switch input:checked + span::after { transform: translateX(18px); }
.wo { display: grid; gap: 12px; padding-top: 4px; border-top: 1px dashed var(--line); }
.wo-fields.off { opacity: .35; pointer-events: none; }

.summary { display: grid; gap: 8px; padding: 14px; border-radius: 14px; background: var(--bg); font-variant-numeric: tabular-nums; }
.summary div { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-size: 15px; }
.summary .big { font-size: 20px; padding: 6px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.summary .neg b { color: var(--neg); }
.summary .pos b { color: var(--pos); }
.summary.wide { text-align: left; margin: 20px 0 8px; background: var(--surface); }
.err-line { color: var(--danger); font-size: 14px; font-weight: 600; min-height: 1px; }
.note { background: var(--note); color: var(--note-ink); padding: 12px 14px; border-radius: 14px; font-size: 14px; margin-bottom: 14px; }

/* ---------- сегменты ---------- */
.seg { display: grid; grid-auto-flow: column; gap: 4px; padding: 4px; border-radius: 14px; background: var(--line); margin: 22px 0 12px; }
.seg.top { margin: 0 0 16px; }
.seg button { border: 0; background: none; padding: 10px; border-radius: 11px; font: inherit; font-weight: 650; color: var(--ink-2); cursor: pointer; }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

/* ---------- шапки ---------- */
.bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; min-height: 36px; }
.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-2); }
.client-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin: 6px 0 16px; }
.bal-chip { display: grid; justify-items: end; padding: 10px 14px; border-radius: 14px; background: var(--accent); color: var(--accent-ink); flex: none; }
.bal-chip b { font-size: 24px; line-height: 1; font-variant-numeric: tabular-nums; }
.bal-chip span { font-size: 12px; font-weight: 650; }

/* ---------- гостевой экран ---------- */
.hero { padding: 26px 22px; border-radius: 24px; color: #f5f3ef; margin-bottom: 14px;
  background: radial-gradient(120% 140% at 100% 0%, #3a3f48 0%, #17191d 55%);
  position: relative; overflow: hidden; }
.hero::after { content: ""; position: absolute; right: -70px; bottom: -90px; width: 170px; height: 170px; border-radius: 50%; border: 20px solid var(--accent); opacity: .9; }
.hero h1 { font-size: 30px; margin: 10px 0 8px; position: relative; z-index: 1; }
.hero p { color: #c9ccd2; max-width: 64%; position: relative; z-index: 1; }
.brand { font-weight: 800; letter-spacing: .14em; font-size: 13px; color: var(--accent); }
.perks { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.perk { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 14px 10px; text-align: center; box-shadow: var(--shadow); }
.perk b { display: block; font-size: 22px; letter-spacing: -.02em; }
.perk span { font-size: 12px; color: var(--ink-2); }
.rules { margin: 0 0 12px; padding-left: 18px; display: grid; gap: 8px; font-size: 15px; }

/* ---------- карта клиента ---------- */
.loyalty-card {
  aspect-ratio: 1.586; border-radius: 22px; padding: 20px 22px; color: #f5f3ef;
  display: flex; flex-direction: column; justify-content: space-between;
  background:
    linear-gradient(115deg, transparent 66%, rgba(245,165,36,.95) 66.2%, rgba(245,165,36,.95) 71%, transparent 71.2%),
    linear-gradient(115deg, transparent 74%, rgba(245,165,36,.35) 74.2%, rgba(245,165,36,.35) 76%, transparent 76.2%),
    radial-gradient(120% 120% at 0% 0%, #3a3f48 0%, #17191d 60%);
  box-shadow: 0 14px 30px rgba(0,0,0,.22);
}
.lc-top { display: flex; justify-content: space-between; align-items: center; }
.lc-kind { font-size: 12px; color: #b7bbc2; position: relative; z-index: 1; }
.lc-balance { display: grid; }
.lc-label { font-size: 13px; color: #b7bbc2; }
.lc-num { font-size: 46px; font-weight: 800; line-height: 1.05; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.lc-unit { font-size: 14px; color: #d7d9dd; }
.lc-bottom { display: flex; justify-content: space-between; font-size: 15px; font-weight: 650; letter-spacing: .06em; font-variant-numeric: tabular-nums; }
.lc-rate { color: #1b1406; background: var(--accent); padding: 2px 8px; border-radius: 8px; font-size: 12px; letter-spacing: 0; }

.qr-panel { margin-top: -18px; padding: 34px 20px 16px; background: #fff; color: #111; border-radius: 0 0 22px 22px; box-shadow: var(--shadow); cursor: pointer; border: 1px solid #ece8e0; border-top: 0; }
.qr-panel .muted { color: #6b6f76; }
.qr-box { width: min(78vw, 300px); background: #fff; aspect-ratio: 1; margin: 0 auto 14px; display: grid; place-items: center; }
.qr-box svg { width: 100%; height: 100%; display: block; shape-rendering: crispEdges; }
.qr-code-row { display: flex; justify-content: center; align-items: baseline; gap: 10px; }
.qr-code { font-size: 30px; font-weight: 800; letter-spacing: .25em; font-variant-numeric: tabular-nums; margin-right: -.25em; }
.qr-bar { height: 4px; border-radius: 4px; background: #eee9df; overflow: hidden; margin: 10px 0 12px; }
.qr-bar i { display: block; height: 100%; background: var(--accent); transform-origin: left; transition: transform .25s linear; }

/* ---------- операции ---------- */
.ops { list-style: none; margin: 0; padding: 4px 16px; }
.op { padding: 12px 0; border-bottom: 1px solid var(--line); }
.op:last-child { border-bottom: 0; }
.op-main { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.op-title { font-weight: 600; }
.op-delta { font-weight: 750; font-variant-numeric: tabular-nums; }
.op.plus .op-delta { color: var(--pos); }
.op.minus .op-delta { color: var(--neg); }
.op.undone { opacity: .5; }
.op.undone .op-delta { text-decoration: line-through; }
.op-sub { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; color: var(--ink-2); margin-top: 2px; flex-wrap: wrap; }
.op .link { padding: 6px 0 0; font-size: 14px; }

/* ---------- итоги ---------- */
.done-ico { width: 84px; height: 84px; border-radius: 50%; background: var(--pos); color: #fff; display: grid; place-items: center; margin: 0 auto 14px; animation: pop .35s cubic-bezier(.2,1.6,.4,1); }
.done-ico svg { width: 44px; height: 44px; }
@keyframes pop { from { transform: scale(.4); opacity: 0; } }
.empty-ico { width: 64px; height: 64px; margin: 0 auto 12px; color: var(--ink-2); }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 14px; box-shadow: var(--shadow); }
.stat.wide { grid-column: 1 / -1; }
.stat b { display: block; font-size: 22px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat span { font-size: 12px; color: var(--ink-2); }

#toast {
  position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); transform: translate(-50%, 140%);
  max-width: calc(100% - 32px); padding: 12px 16px; border-radius: 14px; background: #17191d; color: #fff;
  font-size: 14px; font-weight: 600; box-shadow: 0 10px 30px rgba(0,0,0,.25); transition: transform .25s ease, opacity .25s; z-index: 10;
  opacity: 0; visibility: hidden;
}
#toast.show { transform: translate(-50%, 0); opacity: 1; visibility: visible; }
#toast.ok { background: var(--pos); }
#toast.err { background: var(--danger); }

@media (max-width: 360px) {
  .tiles { grid-template-columns: 1fr; }
  .tile { flex-direction: row; justify-content: center; }
  .lc-num { font-size: 38px; }
}

/* ---------- согласия, данные, рассылки ---------- */
.check { display: grid !important; grid-template-columns: 22px 1fr; gap: 10px; align-items: start; font-size: 14px !important; font-weight: 500 !important; color: var(--ink) !important; line-height: 1.4; cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--pos); }
.check a, .links a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.consent { margin-bottom: 10px; }
.switch i { font-style: normal; }
.form textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; background: var(--surface);
  color: var(--ink); font-size: 16px; line-height: 1.45; font-family: inherit; resize: vertical; min-height: 120px;
}
.form textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; }
.form .chips { margin: -4px 0 0; }
.chip { border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 999px; padding: 8px 12px; font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }
.chip.on { background: var(--primary); color: var(--primary-ink); border-color: transparent; }
.seg-res { margin-top: 12px; }
.seg-count { display: flex; align-items: baseline; gap: 8px; }
.seg-count b { font-size: 34px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.seg-count span { color: var(--ink-2); font-weight: 600; }
.seg-res details summary { cursor: pointer; font-weight: 600; margin-top: 4px; }
.seg-res .ops { padding: 0; }
.bc-text { font-size: 14px; margin: 6px 0 2px; white-space: pre-wrap; overflow-wrap: anywhere; }
.pill.live { background: var(--note); color: var(--note-ink); }
.data h3 { margin: 0 0 8px; font-size: 16px; }
.kv { list-style: none; margin: 0 0 14px; padding: 0; }
.kv li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.kv li span { color: var(--ink-2); }
.kv li b { text-align: right; overflow-wrap: anywhere; }
.data .switch { margin: 4px 0 10px; }
