:root {
  --bg: var(--tg-theme-secondary-bg-color, #0f1216);
  --surface: var(--tg-theme-bg-color, #171c22);
  --surface-2: color-mix(in srgb, var(--surface) 88%, var(--text) 12%);
  --text: var(--tg-theme-text-color, #eef2f6);
  --muted: var(--tg-theme-hint-color, #93a1b1);
  --accent: var(--tg-theme-button-color, #35a2ff);
  --accent-ink: var(--tg-theme-button-text-color, #ffffff);
  --border: color-mix(in srgb, var(--text) 14%, transparent);
  --hot: #ff5a3c;
  --ok: #3fb96f;
  --display: "Unbounded", "Trebuchet MS", sans-serif;
  --body: "Golos Text", -apple-system, "Helvetica Neue", sans-serif;
  --bar: 84px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
/* Обязательно !important: у .overlay, .loader и .state свой display, а он сильнее
   браузерного [hidden]. Без этого закрытая шторка висит поверх магазина и съедает все клики. */
[hidden] { display: none !important; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--body); font-size: 15px; line-height: 1.45;
  padding-bottom: calc(var(--bar) + env(safe-area-inset-bottom));
}
button { font-family: inherit; cursor: pointer; }
.app { display: flex; flex-direction: column; gap: 18px; padding: 12px 14px 20px; }

.loader { display: grid; place-items: center; min-height: 70vh; }
.spinner {
  width: 26px; height: 26px; border-radius: 50%;
  border: 2px solid var(--border); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } }
.state { display: flex; flex-direction: column; gap: 14px; align-items: center; padding: 60px 24px; text-align: center; color: var(--muted); }
.state .btn { width: auto; padding: 0 22px; }

/* шапка */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.brand { display: flex; align-items: center; gap: 9px; min-width: 0; }
.brand-name { font-family: var(--display); font-weight: 700; font-size: 13px; letter-spacing: .06em; }
/* Логотип магазина: крупное дисплейное начертание, название задаётся в админке */
.logo {
  font-family: var(--display); font-weight: 700; font-size: 25px; line-height: 1.05;
  letter-spacing: -.02em; white-space: nowrap;
}
.top-actions { display: flex; gap: 8px; align-items: flex-start; }
.lang-wrap { position: relative; }
.lang-menu {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 25; min-width: 176px;
  padding: 6px; border-radius: 15px; border: 1px solid var(--border); background: var(--surface);
  box-shadow: 0 20px 44px -22px rgba(0, 0, 0, .85);
  display: flex; flex-direction: column; gap: 2px;
}
.lang-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px;
  border: 0; border-radius: 11px; background: transparent; color: var(--text);
  font: 500 14px/1 var(--body); text-align: left;
}
.lang-item.on { background: var(--surface-2); font-weight: 600; }
.lang-item .flag { font-size: 17px; line-height: 1; }
.icon-btn {
  height: 38px; min-width: 38px; padding: 0 11px; border-radius: 12px; position: relative;
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  display: inline-flex; align-items: center; gap: 6px; justify-content: center; font: 500 13px/1 var(--body);
}
.cart-badge {
  position: absolute; top: -5px; right: -5px; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: var(--hot); color: #fff; font: 700 11px/18px var(--body);
  text-align: center; border: 2px solid var(--bg);
}

/* «хит» — баннер над каталогом: рамка акцентом и своя вёрстка, чтобы не путать с карточками */
.deal {
  position: relative; overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--border));
  border-radius: 20px; padding: 16px; display: flex; flex-direction: column; gap: 11px;
  background:
    linear-gradient(160deg, color-mix(in srgb, var(--accent) 16%, transparent), transparent 62%),
    var(--surface);
  box-shadow: 0 10px 28px -18px color-mix(in srgb, var(--accent) 80%, transparent);
  text-align: left; color: inherit; width: 100%;
}
.deal-cover { width: 100%; height: 132px; object-fit: cover; border-radius: 14px; }
.deal-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.eyebrow { font: 600 11px/1 var(--body); letter-spacing: .14em; text-transform: uppercase; color: var(--accent); }
.deal h2 { font-family: var(--display); font-weight: 700; font-size: 22px; line-height: 1.15; margin: 0; text-wrap: balance; }
.deal-price { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.deal-price b { font-family: var(--display); font-weight: 700; font-size: 28px; font-variant-numeric: tabular-nums; }
.deal-sep { color: var(--muted); font-size: 12px; text-decoration: line-through; font-variant-numeric: tabular-nums; }
.save { margin-left: auto; padding: 5px 10px; border-radius: 9px; background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); font: 600 12px/1 var(--body); }

.btn {
  height: 48px; border: 0; border-radius: 13px; width: 100%;
  background: var(--accent); color: var(--accent-ink);
  font: 600 15px/1 var(--body); display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn:disabled { opacity: .5; }
.btn.ghost { background: transparent; border: 1px solid var(--border); color: var(--text); }

/* фильтры */
.filters { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.chip { height: 36px; padding: 0 14px; border-radius: 11px; border: 1px solid var(--border); background: var(--surface); color: var(--muted); font: 500 13px/1 var(--body); display: inline-flex; align-items: center; white-space: nowrap; }
.chip.on { background: var(--text); color: var(--bg); border-color: var(--text); font-weight: 600; }

/* плитка тарифов */
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.card { border: 1px solid var(--border); border-radius: 16px; overflow: hidden; background: var(--surface); display: flex; flex-direction: column; text-align: left; padding: 0; color: inherit; }
.cover { position: relative; aspect-ratio: 4 / 5; display: grid; place-items: center; padding: 10px; background: var(--surface-2); overflow: hidden; }
.cover img { width: 100%; height: 100%; object-fit: cover; position: absolute; inset: 0; }
.cover-title { position: relative; font-family: var(--display); font-weight: 700; font-size: 14px; text-align: center; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.off { position: absolute; top: 8px; left: 8px; padding: 4px 8px; border-radius: 8px; background: var(--hot); color: #fff; font: 700 11px/1 var(--body); z-index: 1; }
.card-body { padding: 11px 12px 12px; display: flex; flex-direction: column; gap: 3px; flex: 1; }
.card-name { font-weight: 600; font-size: 14px; line-height: 1.25; }
.card-term { color: var(--muted); font-size: 12px; }
.price-row { display: flex; align-items: baseline; gap: 8px; margin: 5px 0 9px; flex-wrap: wrap; }
.price-now { font-family: var(--display); font-weight: 700; font-size: 16px; font-variant-numeric: tabular-nums; }
.price-old { color: var(--muted); font-size: 12px; text-decoration: line-through; font-variant-numeric: tabular-nums; }
/* «Добавить в корзину» — во всю ширину карточки: в неё легче попасть, чем в кружок «+» */
.add {
  margin-top: auto; width: 100%; min-height: 40px; padding: 8px 10px; border: 0; border-radius: 12px;
  background: var(--accent); color: var(--accent-ink);
  display: flex; align-items: center; justify-content: center; gap: 6px; text-align: center;
  font: 600 12.5px/1.25 var(--body);
}
.add.in { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.add svg { width: 15px; height: 15px; flex: none; }

.section-title { font-family: var(--display); font-weight: 500; font-size: 15px; margin: 0 0 10px; }

/* нижняя панель */
.cartbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  border-top: 1px solid var(--border); background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(14px);
  padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 12px;
}
.cartbar-sum { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cartbar-sum b { font-family: var(--display); font-weight: 700; font-size: 18px; font-variant-numeric: tabular-nums; }
.cartbar-sum span { color: var(--muted); font-size: 12px; }
.cartbar .btn { width: auto; flex: 1; height: auto; min-height: 48px; padding: 8px 12px; font-size: 14px; line-height: 1.25; text-align: center; }

/* шторка */
.overlay { position: fixed; inset: 0; z-index: 40; display: flex; align-items: flex-end; }
.backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .6); }
.sheet {
  position: relative; width: 100%; max-height: 92vh; overflow-y: auto;
  background: var(--surface); border-radius: 22px 22px 0 0; border-top: 1px solid var(--border);
  padding: 10px 16px calc(18px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 13px;
  animation: rise .22s ease-out;
}
@keyframes rise { from { transform: translateY(18px); } }
@media (prefers-reduced-motion: reduce) { .sheet { animation: none; } }
.handle { width: 38px; height: 4px; border-radius: 2px; background: var(--border); margin: 0 auto 2px; flex: none; }
.sheet-cover { aspect-ratio: 16 / 9; border-radius: 14px; position: relative; overflow: hidden; background: var(--surface-2); display: grid; place-items: center; }
.sheet-cover img { width: 100%; height: 100%; object-fit: cover; }
.close { position: absolute; top: 10px; right: 10px; width: 34px; height: 34px; border-radius: 50%; background: rgba(0, 0, 0, .55); border: 0; color: #fff; display: grid; place-items: center; z-index: 1; }
.sheet h3 { font-family: var(--display); font-weight: 700; font-size: 19px; margin: 0; }
.meta-row { display: flex; gap: 8px; flex-wrap: wrap; }
.tag { padding: 5px 9px; border-radius: 9px; background: var(--surface-2); font-size: 12px; color: var(--muted); }
.tag.on { background: var(--text); color: var(--bg); font-weight: 600; }
.terms { display: flex; gap: 8px; flex-wrap: wrap; }
.term-btn { border: 1px solid var(--border); background: var(--surface-2); color: var(--text); border-radius: 12px; padding: 9px 12px; display: flex; flex-direction: column; gap: 2px; align-items: flex-start; min-height: 44px; }
.term-btn.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.term-btn b { font-size: 13px; }
.term-btn span { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.sheet-price { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.sheet-price b { font-family: var(--display); font-weight: 700; font-size: 26px; font-variant-numeric: tabular-nums; }
.desc { color: var(--muted); font-size: 13px; line-height: 1.55; margin: 0; white-space: pre-line; }
.includes { display: flex; flex-direction: column; gap: 8px; }
.inc { display: flex; gap: 9px; font-size: 13px; line-height: 1.4; }
.inc svg { flex: none; margin-top: 1px; color: var(--ok); }

/* корзина */
.line { display: flex; gap: 11px; align-items: center; padding: 11px 0; border-bottom: 1px solid var(--border); }
.line:last-child { border-bottom: 0; }
.line-cover { width: 48px; height: 56px; border-radius: 10px; flex: none; object-fit: cover; background: var(--surface-2); }
.line-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.line-body b { font-size: 13px; font-weight: 600; }
.line-body span { color: var(--muted); font-size: 12px; }
.line-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.line-price { font-family: var(--display); font-weight: 500; font-size: 14px; font-variant-numeric: tabular-nums; }
.line-remove { width: 36px; height: 36px; border-radius: 10px; border: 0; background: transparent; color: var(--muted); display: grid; place-items: center; }
.promo { display: flex; gap: 8px; }
.promo input { flex: 1; min-width: 0; height: 46px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); color: var(--text); padding: 0 13px; font: 400 15px/1 var(--body); }
.promo button { height: 46px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font: 600 13px/1 var(--body); }
.promo-on { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 12px; background: color-mix(in srgb, var(--ok) 14%, transparent); font-size: 13px; color: var(--ok); }
.promo-on button { margin-left: auto; background: none; border: 0; color: var(--muted); display: grid; place-items: center; }
.promo-error { color: var(--hot); font-size: 12px; margin: 0; }
.pay-list { display: flex; flex-direction: column; gap: 9px; }
.pay { display: flex; align-items: center; gap: 11px; padding: 12px; border-radius: 13px; border: 1px solid var(--border); background: var(--surface); width: 100%; color: inherit; text-align: left; }
.pay.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); }
.pay b { font-size: 13px; font-weight: 600; }
.radio { margin-left: auto; width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--border); flex: none; display: grid; place-items: center; }
.pay.on .radio { border-color: var(--accent); }
.pay.on .radio::after { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.totals { display: flex; flex-direction: column; gap: 8px; }
.total-row { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.total-row.grand { color: var(--text); align-items: baseline; }
.total-row.grand b { font-family: var(--display); font-weight: 700; font-size: 22px; }
.note { color: var(--muted); font-size: 12px; line-height: 1.5; margin: 0; }
.empty { text-align: center; color: var(--muted); padding: 40px 10px; }
.pay-error { color: var(--hot); font-size: 13px; line-height: 1.45; margin: 0; }

/* экран после оплаты */
.done { display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; padding: 56px 18px 24px; }
.done-mark { width: 66px; height: 66px; border-radius: 50%; display: grid; place-items: center; background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.done-mark svg { width: 30px; height: 30px; }
.done h2 { font-family: var(--display); font-weight: 700; font-size: 21px; margin: 0; }
.done p { color: var(--muted); font-size: 14px; line-height: 1.5; margin: 0; max-width: 34ch; }
.done .btn { width: auto; padding: 0 22px; margin-top: 4px; }

/* выбор монеты и счёт на перевод */
.coins { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 10px; }
.coin {
  position: relative; display: flex; flex-direction: column; gap: 2px;
  align-items: flex-start; text-align: left; padding: 10px 32px 10px 11px;
  border-radius: 12px; border: 2px solid var(--border);
  background: var(--surface); color: inherit;
}
/* Выбранная сеть — самое важное решение на экране: ошибка в сети стоит клиенту денег. */
.coin.on {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 26%, var(--surface));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}
.coin-tick {
  position: absolute; top: 9px; right: 9px; width: 19px; height: 19px; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink); display: grid; place-items: center;
}
.coin-tick svg { width: 12px; height: 12px; }
.coin b { font-size: 13px; font-weight: 600; }
.coin span { font-size: 11px; color: var(--muted); }
.coin.on span { color: color-mix(in srgb, var(--text) 75%, transparent); }
.pay-box { display: flex; flex-direction: column; gap: 14px; }
.pay-field { display: flex; flex-direction: column; gap: 6px; }
.pay-label { font: 600 11px/1 var(--body); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.pay-value {
  display: flex; align-items: center; gap: 10px; padding: 12px 13px;
  border: 1px solid var(--border); border-radius: 13px; background: var(--surface);
}
.pay-value b { font-family: var(--display); font-weight: 700; font-size: 19px; font-variant-numeric: tabular-nums; }
.pay-value code { font-size: 12px; line-height: 1.4; word-break: break-all; min-width: 0; flex: 1; }
.copy-btn {
  margin-left: auto; flex: none; height: 34px; padding: 0 12px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  font: 600 12px/1 var(--body);
}
.pay-sub { font-size: 12px; color: var(--muted); line-height: 1.45; }
.pay-warn {
  padding: 12px 13px; border-radius: 13px; font-size: 12.5px; line-height: 1.5;
  background: color-mix(in srgb, var(--hot) 13%, transparent);
  border: 1px solid color-mix(in srgb, var(--hot) 35%, transparent);
}
