: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; }
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-mark { width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; background: var(--accent); flex: none; }
.brand-name { font-family: var(--display); font-weight: 700; font-size: 13px; letter-spacing: .06em; }
.brand-sub { font-size: 11px; color: var(--muted); }
.top-actions { display: flex; gap: 8px; }
.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 { border: 1px solid var(--border); border-radius: 18px; padding: 16px; background: var(--surface); display: flex; flex-direction: column; gap: 13px; }
.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: 20px; margin: 0; }
.calc { display: flex; flex-direction: column; gap: 6px; }
.calc-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-size: 14px; color: var(--muted); }
.calc-row b { font-family: var(--display); font-weight: 500; color: var(--text); font-variant-numeric: tabular-nums; }
.calc-row.old b { color: var(--muted); text-decoration: line-through; }
.calc-row.now b { font-size: 22px; font-weight: 700; }
.save { align-self: flex-start; 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; }
.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: center; gap: 8px; margin-top: 5px; }
.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-left: auto; width: 44px; height: 44px; border-radius: 13px; border: 0; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; flex: none; }
.add.in { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }

/* что внутри */
.section-title { font-family: var(--display); font-weight: 500; font-size: 15px; margin: 0 0 10px; }
.inside { border: 1px solid var(--border); border-radius: 16px; background: var(--surface); padding: 14px; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 12px; }
.stat b { display: block; font-family: var(--display); font-weight: 700; font-size: 17px; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: 11px; }
.chan-list { display: flex; flex-direction: column; gap: 9px; }
.chan { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.chan-dot { width: 26px; height: 26px; border-radius: 9px; background: var(--surface-2); display: grid; place-items: center; flex: none; color: var(--muted); }

/* нижняя панель */
.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; }

/* шторка */
.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; }
