/* Витрина приложений — тёмная «как App Store ночью», акцент берётся из карточки магазина. */
:root {
  --accent: #3d7bff;
  --accent-ink: #fff;
  --bg: #0b0c0f;
  --surface: #15171c;
  --surface-2: #1d2027;
  --line: rgb(255 255 255 / 0.07);
  --text: #f4f5f7;
  --muted: #8e939e;
  --good: #3ecf8e;
  --warn: #ffb547;
  --bad: #ff5d5d;
  --radius-lg: 22px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --icon: 60px;
  --gutter: 16px;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --fast: 140ms;
  --normal: 260ms;
  --font: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, sans-serif;
  color-scheme: dark;
}
:root[data-theme='light'] {
  --bg: #f2f3f6;
  --surface: #ffffff;
  --surface-2: #eceef2;
  --line: rgb(10 14 24 / 0.08);
  --text: #0f1115;
  --muted: #6b7080;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 15px/1.4 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  padding-bottom: calc(84px + env(safe-area-inset-bottom));
  overflow-x: hidden;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- загрузка ---------- */
.boot { display: flex; gap: 8px; justify-content: center; padding: 40vh 0; }
.boot-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); animation: pulse 900ms infinite var(--ease-out); }
.boot-dot:nth-child(2) { animation-delay: 150ms; }
.boot-dot:nth-child(3) { animation-delay: 300ms; }
@keyframes pulse { 0%, 100% { opacity: 0.25; transform: scale(0.8); } 50% { opacity: 1; transform: scale(1); } }

/* ---------- шапка ---------- */
.top { padding: 14px var(--gutter) 6px; position: sticky; top: 0; z-index: 5; background: linear-gradient(var(--bg) 78%, transparent); }
.top-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.shop-name { font: 700 24px/1.1 var(--font-display); letter-spacing: -0.02em; margin: 0; }
.shop-sub { color: var(--muted); font-size: 13px; }
.search {
  display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 12px;
  background: var(--surface-2); border-radius: var(--radius-sm); border: 1px solid var(--line);
}
.search svg { flex: none; opacity: 0.55; }
.search input { flex: 1; border: 0; background: none; outline: none; height: 100%; min-width: 0; }
.search input::placeholder { color: var(--muted); }

/* ---------- баннер набора ---------- */
.rail { display: flex; gap: 12px; overflow-x: auto; scroll-snap-type: x mandatory; padding: 8px var(--gutter) 4px; scrollbar-width: none; }
.rail::-webkit-scrollbar { display: none; }
.promo {
  position: relative; flex: 0 0 calc(100% - 28px); scroll-snap-align: center; min-height: 150px;
  border-radius: var(--radius-lg); padding: 18px; overflow: hidden; isolation: isolate; border: 1px solid var(--line);
  background:
    radial-gradient(120% 90% at 100% 0%, color-mix(in oklab, var(--accent) 55%, transparent), transparent 60%),
    radial-gradient(80% 80% at 0% 100%, color-mix(in oklab, var(--accent) 25%, #7a2cff 30%), transparent 70%),
    #12131a;
  color: #fff;
}
.promo-old { color: rgb(255 255 255 / 0.55); text-decoration: line-through; font-size: 14px; }
.promo-price { font: 800 40px/1 var(--font-display); letter-spacing: -0.03em; margin: 2px 0 6px; }
.promo-badge {
  position: absolute; top: 14px; right: 14px; background: #fff; color: #111; font: 800 13px/1 var(--font-display);
  padding: 6px 8px; border-radius: 999px;
}
.promo-title { font-weight: 650; font-size: 14px; text-transform: uppercase; letter-spacing: 0.02em; max-width: 60%; }
.promo-sub { font-size: 13px; color: rgb(255 255 255 / 0.7); max-width: 62%; margin-top: 2px; }
.promo-stack { position: absolute; right: 16px; top: 58px; display: flex; flex-direction: row-reverse; }
.promo-stack .icon:nth-child(n + 4) { display: none; }
.promo-stack .icon { --icon: 38px; margin-left: -10px; box-shadow: 0 6px 16px rgb(0 0 0 / 0.45); transform: rotate(var(--r, 0deg)); }
.promo-btn {
  margin-top: 12px; display: inline-flex; align-items: center; gap: 6px; border: 0; border-radius: 999px;
  padding: 8px 14px; font-weight: 650; background: #fff; color: #111;
  transition: transform var(--fast) var(--ease-out);
}
.promo-btn:active { transform: scale(0.96); }
.promo-btn[aria-pressed='true'] { background: var(--good); color: #062; }

/* ---------- категории ---------- */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 14px var(--gutter) 6px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; border: 1px solid var(--line); background: var(--surface); color: var(--text);
  padding: 7px 14px; border-radius: 999px; font-size: 14px; font-weight: 550;
  transition: background var(--fast) var(--ease-out), transform var(--fast) var(--ease-out);
}
.chip:active { transform: scale(0.96); }
.chip[aria-pressed='true'] { background: var(--accent); color: var(--accent-ink); border-color: transparent; }

/* ---------- сетка приложений ---------- */
.grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px 8px; padding: 12px var(--gutter) 24px; }
@media (min-width: 520px) { .grid { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
.app {
  display: flex; flex-direction: column; align-items: center; gap: 6px; border: 0; background: none; padding: 0;
  text-align: center; min-width: 0;
}
.app:active .icon { transform: scale(0.92); }
.app-name { font-size: 12px; line-height: 1.2; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-price { font-size: 11px; color: var(--muted); margin-top: -4px; }
.app[aria-pressed='true'] .app-price { color: var(--accent); font-weight: 650; }

.icon {
  --c: #555;
  position: relative; width: var(--icon); height: var(--icon); border-radius: calc(var(--icon) * 0.225);
  display: grid; place-items: center; color: #fff; font: 700 calc(var(--icon) * 0.44) / 1 var(--font-display);
  background:
    linear-gradient(160deg, rgb(255 255 255 / 0.28), transparent 45%),
    linear-gradient(200deg, color-mix(in oklab, var(--c) 82%, #fff), var(--c) 55%, color-mix(in oklab, var(--c) 75%, #000));
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.25), 0 1px 2px rgb(0 0 0 / 0.3);
  transition: transform var(--fast) var(--ease-out);
  text-shadow: 0 1px 2px rgb(0 0 0 / 0.25);
}
.icon.light-ink { color: #1a1a1a; text-shadow: none; }
.check {
  position: absolute; right: -5px; top: -5px; width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink); display: grid; place-items: center;
  border: 2px solid var(--bg); font-size: 12px; font-weight: 800;
  transform: scale(0); transition: transform var(--normal) var(--ease-out);
}
.app[aria-pressed='true'] .check { transform: scale(1); }

.empty { color: var(--muted); text-align: center; padding: 40px var(--gutter); }

/* ---------- корзина-полоса ---------- */
.cartbar {
  position: fixed; left: 12px; right: 12px; bottom: calc(74px + env(safe-area-inset-bottom)); z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 12px 12px 16px; border-radius: 18px; border: 0;
  background: var(--accent); color: var(--accent-ink); box-shadow: 0 12px 30px rgb(0 0 0 / 0.35);
  transform: translateY(calc(100% + 120px)); visibility: hidden;
  transition: transform var(--normal) var(--ease-out), visibility 0s linear var(--normal);
}
.cartbar.show { transform: translateY(0); visibility: visible; transition: transform var(--normal) var(--ease-out); }
.cartbar b { font-size: 16px; }
.cartbar span { opacity: 0.85; font-size: 13px; }
.cartbar-go { background: rgb(0 0 0 / 0.18); border-radius: 12px; padding: 8px 12px; font-weight: 650; }

/* ---------- нижние вкладки ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex; justify-content: space-around;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  background: color-mix(in oklab, var(--bg) 86%, transparent); backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
}
.tab {
  flex: 1; max-width: 120px; display: flex; flex-direction: column; align-items: center; gap: 3px;
  border: 0; background: none; color: var(--muted); font-size: 11px; padding: 6px 0; border-radius: 12px;
}
.tab svg { width: 22px; height: 22px; }
.tab[aria-current='page'] { color: var(--accent); background: color-mix(in oklab, var(--accent) 12%, transparent); }
.tab .badge { position: absolute; transform: translate(14px, -4px); background: var(--bad); color: #fff; font-size: 10px; border-radius: 999px; padding: 1px 5px; }
.tab { position: relative; }

/* ---------- листы и карточки ---------- */
.page { padding: 16px var(--gutter) 24px; }
.h1 { font: 700 24px/1.15 var(--font-display); letter-spacing: -0.02em; margin: 4px 0 16px; }
.h2 { font: 650 17px/1.2 var(--font-display); margin: 24px 0 10px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); padding: 14px; }
.card + .card { margin-top: 10px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.line { display: flex; align-items: center; gap: 10px; padding: 8px 0; }
.line + .line { border-top: 1px solid var(--line); }
.line .icon { --icon: 36px; }
.line-name { flex: 1; min-width: 0; }
.total { font: 750 22px/1.1 var(--font-display); }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 650; padding: 4px 10px; border-radius: 999px; background: var(--surface-2); }
.pill.awaiting_payment { color: var(--warn); background: color-mix(in oklab, var(--warn) 14%, transparent); }
.pill.check { color: var(--accent); background: color-mix(in oklab, var(--accent) 14%, transparent); }
.pill.paid { color: var(--good); background: color-mix(in oklab, var(--good) 14%, transparent); }
.pill.done { color: var(--good); background: color-mix(in oklab, var(--good) 22%, transparent); }
.pill.rejected { color: var(--bad); background: color-mix(in oklab, var(--bad) 14%, transparent); }
.pill.cancelled { color: var(--muted); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; width: 100%;
  border: 0; border-radius: var(--radius-md); background: var(--accent); color: var(--accent-ink);
  font-weight: 650; font-size: 16px; transition: transform var(--fast) var(--ease-out), opacity var(--fast);
}
.btn:active { transform: scale(0.98); }
.btn[disabled] { opacity: 0.5; }
.btn.ghost { background: var(--surface-2); color: var(--text); }
.btn.small { min-height: 36px; width: auto; padding: 0 14px; font-size: 14px; border-radius: var(--radius-sm); }
.btn.danger { background: color-mix(in oklab, var(--bad) 18%, transparent); color: var(--bad); }
.btn.good { background: color-mix(in oklab, var(--good) 20%, transparent); color: var(--good); }
.btns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

.field { display: block; margin-top: 12px; }
.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.input, textarea.input, select.input {
  width: 100%; min-height: 44px; padding: 10px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--surface-2); outline: none;
}
.input:focus { border-color: var(--accent); }
textarea.input { min-height: 88px; resize: vertical; }
.inline { display: flex; gap: 8px; }
.inline .input { flex: 1; }
.error { color: var(--bad); font-size: 13px; margin-top: 6px; }
.okline { color: var(--good); font-size: 13px; margin-top: 6px; }

.paybox { white-space: pre-wrap; background: var(--surface-2); border-radius: var(--radius-sm); padding: 12px; margin-top: 8px; font-size: 14px; }
.steps { counter-reset: s; list-style: none; padding: 0; margin: 12px 0 0; }
.steps li { counter-increment: s; position: relative; padding: 0 0 12px 36px; }
.steps li::before {
  content: counter(s); position: absolute; left: 0; top: -2px; width: 24px; height: 24px; border-radius: 50%;
  background: color-mix(in oklab, var(--accent) 18%, transparent); color: var(--accent);
  display: grid; place-items: center; font-weight: 750; font-size: 13px;
}
.hero-ok { width: 64px; height: 64px; border-radius: 20px; display: grid; place-items: center; background: color-mix(in oklab, var(--good) 18%, transparent); color: var(--good); font-size: 30px; margin-bottom: 12px; }

.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); padding: 12px; min-width: 0; }
.stat b { display: block; font: 750 18px/1.15 var(--font-display); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat span { font-size: 12px; color: var(--muted); }
.stat.accent { background: color-mix(in oklab, var(--accent) 16%, var(--surface)); }

.segment { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin: 6px 0 12px; }
.segment::-webkit-scrollbar { display: none; }

.toast {
  position: fixed; left: 50%; top: calc(12px + env(safe-area-inset-top)); z-index: 50; transform: translateX(-50%);
  background: var(--surface-2); color: var(--text); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 14px; font-size: 14px; box-shadow: 0 10px 30px rgb(0 0 0 / 0.35); max-width: calc(100% - 32px);
  animation: drop var(--normal) var(--ease-out);
}
.toast.bad { color: var(--bad); }
@keyframes drop { from { opacity: 0; transform: translate(-50%, -8px); } }

.fade-in { animation: fade var(--normal) var(--ease-out); }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } }

.price-row { display: grid; grid-template-columns: 1fr 96px; gap: 8px; align-items: center; padding: 6px 0; }
.price-row + .price-row { border-top: 1px solid var(--line); }
.price-row .input { min-height: 36px; padding: 6px 8px; text-align: right; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; transition-duration: 1ms !important; }
}

.qr-card { display: grid; grid-template-columns: 120px 1fr; gap: 14px; align-items: start; }
.qr-img { width: 120px; height: 120px; border-radius: 12px; background: #fff; padding: 6px; }
a.btn { text-decoration: none; }

/* Приложение уже в выбранном наборе */
.app.in-bundle .check { transform: scale(1); background: var(--good); }
.app.in-bundle .app-price { color: var(--good); font-weight: 650; }
