/* ===================================================================
   Winted VPN - Premium dark UI
   Inspired by: Linear, Mullvad, Tailscale, Notion, Telegram Premium
   =================================================================== */

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

:root {
  /* Surfaces - 4 levels of depth, matte */
  --bg-0: #0a0a0c;
  --bg-1: #131316;
  --bg-2: #1a1a1f;
  --bg-3: #25252b;

  /* Text */
  --fg-1: #ffffff;
  --fg-2: rgba(255, 255, 255, 0.66);
  --fg-3: rgba(255, 255, 255, 0.36);
  --fg-disabled: rgba(255, 255, 255, 0.16);

  /* Lines - приглушённые, depth-via-surface не border */
  --line: rgba(255, 255, 255, 0.05);
  --line-strong: rgba(255, 255, 255, 0.10);

  /* Accent - one brand color */
  --accent: #5b9eff;
  --accent-strong: #4d8ef0;
  --accent-soft: rgba(91, 158, 255, 0.12);
  --accent-border: rgba(91, 158, 255, 0.35);

  /* Semantic */
  --ok: #34d399;
  --warn: #f5a524;
  --danger: #f87171;
  --ok-soft: rgba(52, 211, 153, 0.12);
  --warn-soft: rgba(245, 165, 36, 0.13);
  --danger-soft: rgba(248, 113, 113, 0.12);

  /* Radius */
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-xl: 28px;

  /* Motion */
  --t-fast: 0.12s cubic-bezier(0.4, 0, 0.2, 1);
  --t-base: 0.2s  cubic-bezier(0.4, 0, 0.2, 1);
  --t-slow: 0.32s cubic-bezier(0.32, 0.72, 0, 1);
}

html, body {
  background: var(--bg-0);
  color: var(--fg-1);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 15px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
  min-height: 100vh;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
  padding: 0;
}

a { text-decoration: none; color: inherit; }

/* ─── Soft background accent - единственный декоративный элемент ─── */
body::before {
  content: '';
  position: fixed;
  top: -160px;
  right: -120px;
  width: 380px;
  height: 380px;
  background: radial-gradient(circle, rgba(91, 158, 255, 0.10) 0%, transparent 65%);
  pointer-events: none;
  z-index: 0;
}

body::after {
  content: '';
  position: fixed;
  bottom: -120px;
  left: -100px;
  width: 320px;
  height: 320px;
  background: radial-gradient(circle, rgba(91, 158, 255, 0.05) 0%, transparent 65%);
  pointer-events: none;
  z-index: 0;
}

/* ─── Layout ─── */
.screen {
  position: relative;
  z-index: 1;
  max-width: 480px;
  margin: 0 auto;
  padding:
    max(env(safe-area-inset-top), 8px) 16px
    max(env(safe-area-inset-bottom), 24px) 16px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  min-height: 100vh;
}

/* ─── Cinematic entrance - каждый элемент плавно появляется отдельно ─── */
/* Очень плавная iOS-кривая */
:root {
  --t-cine: cubic-bezier(0.22, 1, 0.36, 1);  /* smooth out-expo */
  --t-spring: cubic-bezier(0.34, 1.4, 0.64, 1);
}

/* === Base keyframes === */
@keyframes rise {
  0%   { opacity: 0; transform: translateY(24px); }
  100% { opacity: 1; transform: translateY(0); }
}

@keyframes riseSoft {
  0%   { opacity: 0; transform: translateY(16px); }
  100% { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  0%   { opacity: 0; }
  100% { opacity: 1; }
}

@keyframes pillPop {
  0%   { opacity: 0; transform: scale(0.72); }
  100% { opacity: 1; transform: scale(1); }
}

@keyframes heroTitleIn {
  0%   { opacity: 0; transform: translateY(18px); filter: blur(6px); }
  60%  { opacity: 1; filter: blur(0); }
  100% { opacity: 1; transform: translateY(0); filter: blur(0); }
}

/* === Balanced entrance - timeline ~1.3s === */

.topbar        { animation: riseSoft 0.5s  0.00s var(--t-cine) both; }
.hero          { animation: fadeIn   0.4s  0.08s var(--t-cine) both; }
.status-pill   { animation: pillPop  0.55s 0.18s var(--t-spring) both; }
.hero-title    { animation: heroTitleIn 0.65s 0.26s var(--t-cine) both; }
.hero-sub      { animation: riseSoft 0.5s  0.38s var(--t-cine) both; }
#daysProgress  { animation: riseSoft 0.45s 0.46s var(--t-cine) both; }
.cta-primary   { animation: riseSoft 0.5s  0.54s var(--t-cine) both; }
.hero-features { animation: riseSoft 0.5s  0.64s var(--t-cine) both; }
.inline-metric { animation: riseSoft 0.5s  0.72s var(--t-cine) both; }

.block:nth-of-type(1) { animation: fadeIn 0.4s 0.78s var(--t-cine) both; }
.block:nth-of-type(2) { animation: fadeIn 0.4s 0.96s var(--t-cine) both; }

.block:nth-of-type(1) > .block-label,
.block:nth-of-type(1) > .block-head { animation: riseSoft 0.45s 0.80s var(--t-cine) both; }
.block:nth-of-type(2) > .block-label,
.block:nth-of-type(2) > .block-head { animation: riseSoft 0.45s 0.98s var(--t-cine) both; }

.row-list .row {
  opacity: 0;
  animation: riseSoft 0.45s var(--t-cine) both;
}
.row-list .row:nth-child(1) { animation-delay: 0.84s; }
.row-list .row:nth-child(2) { animation-delay: 0.90s; }
.row-list .row:nth-child(3) { animation-delay: 0.96s; }
.row-list .row:nth-child(4) { animation-delay: 1.02s; }

.plan {
  animation: riseSoft 0.5s var(--t-cine) both;
  animation-delay: calc(1.04s + (var(--plan-i, 0) * 0.07s));
}

.footer { animation: riseSoft 0.45s 1.30s var(--t-cine) both; }

/* ─── Modal content - balanced entrance (~0.7s после slide) ─── */
/* Modal slide ~0.28s, контент стартует с 0.20s */

.modal .modal-title          { animation: heroTitleIn 0.5s  0.20s var(--t-cine) both; }
.modal .modal-subtitle       { animation: riseSoft   0.42s 0.30s var(--t-cine) both; }
.modal .modal-price          { animation: heroTitleIn 0.5s  0.36s var(--t-cine) both; }
.modal .modal-section > .modal-label { animation: riseSoft 0.4s 0.42s var(--t-cine) both; }

.modal .providers .provider-btn { animation: riseSoft 0.42s var(--t-cine) both; }
.modal .providers .provider-btn:nth-child(1) { animation-delay: 0.46s; }
.modal .providers .provider-btn:nth-child(2) { animation-delay: 0.54s; }
.modal .providers .provider-btn:nth-child(3) { animation-delay: 0.62s; }
.modal .providers .provider-btn:nth-child(4) { animation-delay: 0.70s; }
.modal .providers .provider-btn:nth-child(5) { animation-delay: 0.78s; }

.modal .amount-input-wrap { animation: riseSoft 0.42s 0.42s var(--t-cine) both; }
.modal .amount-quick      { animation: riseSoft 0.42s 0.52s var(--t-cine) both; }

.modal .platform-tabs         { animation: riseSoft 0.42s 0.46s var(--t-cine) both; }
.modal .platform-panel.active { animation: riseSoft 0.42s 0.56s var(--t-cine) both; }

.modal .ref-stats { animation: riseSoft 0.42s 0.36s var(--t-cine) both; }
.modal .ref-link  { animation: riseSoft 0.42s 0.54s var(--t-cine) both; }

.modal .btn-primary,
.modal .btn-outline {
  animation: riseSoft 0.45s 0.62s var(--t-cine) both;
}

/* ─── Status pill - attention wiggle когда подписка истекает ─── */
.status-pill--warn,
.status-pill--danger {
  animation:
    pillPop 0.8s 0.25s var(--t-spring) both,
    pillAttention 4.5s 2s ease-in-out infinite;
}

@keyframes pillAttention {
  0%, 28%, 100% { transform: translateX(0); }
  31%  { transform: translateX(-1.4px); }
  34%  { transform: translateX(1.4px); }
  37%  { transform: translateX(-1.4px); }
  40%  { transform: translateX(0.9px); }
  44%  { transform: translateX(0); }
}

/* ─── Plan card tap-pulse - quick feedback перед открытием модала ─── */
.plan--tap {
  animation: planTap 0.24s var(--t-cine);
}

@keyframes planTap {
  0%   { transform: scale(1); }
  45%  { transform: scale(0.955); }
  100% { transform: scale(1); }
}

/* === Accessibility - отключаем анимации если юзер выключил движение === */
@media (prefers-reduced-motion: reduce) {
  .topbar, .hero, .hero *, .inline-metric, .block, .block *,
  .row-list .row, .plan, .footer, .status-pill,
  .hero-title, .cta-primary, .hero-features, #daysProgress,
  .modal-title, .modal-subtitle, .modal-price, .modal-section .modal-label,
  .providers .provider-btn, .platform-tabs, .platform-panel, .amount-input-wrap,
  .amount-quick, .ref-stats, .ref-link, .status-pill--warn, .status-pill--danger,
  .plan--tap, .btn-primary, .btn-outline {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
    filter: none !important;
  }
}

/* ─── Topbar ─── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 44px;
  padding: 0 4px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: #fff;
  object-fit: cover;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.1) inset;
}

.brand-name {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--fg-1);
}

.user-id {
  font-size: 11px;
  font-weight: 500;
  color: var(--fg-3);
  font-feature-settings: "tnum";
  letter-spacing: 0.02em;
}

.topbar-action {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-1);
  border: 1px solid var(--line);
  color: var(--fg-2);
  font-size: 15px;
  display: grid;
  place-items: center;
  transition: background var(--t-base), border-color var(--t-base);
}

.topbar-action:active {
  background: var(--bg-2);
  border-color: var(--line-strong);
  transform: scale(0.94);
}

/* ─── Hero ─── */
.hero {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Status pill */
.status-pill {
  display: inline-flex;
  align-self: flex-start;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 10px;
  border-radius: 999px;
  background: var(--bg-1);
  border: 1px solid var(--line);
  color: var(--fg-2);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: background var(--t-base), color var(--t-base), border-color var(--t-base);
}

.status-pill--ok {
  background: var(--ok-soft);
  border-color: rgba(52, 211, 153, 0.25);
  color: var(--ok);
}

.status-pill--warn {
  background: var(--warn-soft);
  border-color: rgba(245, 165, 36, 0.28);
  color: var(--warn);
}

.status-pill--danger {
  background: var(--danger-soft);
  border-color: rgba(248, 113, 113, 0.28);
  color: var(--danger);
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.status-pill--ok .status-dot {
  animation: pulseOk 2.4s infinite;
}

@keyframes pulseOk {
  0%, 100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.6); }
  50%      { box-shadow: 0 0 0 5px rgba(52, 211, 153, 0); }
}

/* Hero title */
.hero-title {
  font-size: 32px;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--fg-1);
  font-feature-settings: "tnum";
  margin-top: 4px;
}

.hero-sub {
  font-size: 15px;
  font-weight: 500;
  color: var(--fg-2);
}

/* Progress */
.progress {
  height: 4px;
  background: var(--line);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 4px;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.progress--warn .progress-fill { background: var(--warn); }
.progress--danger .progress-fill { background: var(--danger); }
.progress--sm { height: 3px; }

.progress-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--fg-3);
  font-feature-settings: "tnum";
}

/* ─── Hero feature strip - system status indicators ─── */
.hero-features {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 14px;
  margin-top: 6px;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}

.hero-feature {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  color: var(--fg-2);
  letter-spacing: 0.02em;
}

/* Код-стиль для названий протоколов - premium infra typography */
.hero-feature-code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.hero-feature-sep {
  color: var(--fg-disabled);
  font-size: 11px;
  user-select: none;
  font-weight: 400;
}

.hero-feature svg {
  width: 12px;
  height: 12px;
  stroke: var(--fg-3);
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

.hero-feature--ok     { color: var(--ok); }
.hero-feature--ok svg { stroke: var(--ok); }
.hero-feature--accent { color: var(--accent); }
.hero-feature--accent svg { stroke: var(--accent); }

/* Lucide-style icons - общий класс для всех outline-иконок */
.icon {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

.icon--sm { width: 16px; height: 16px; stroke-width: 2; }
.icon--lg { width: 24px; height: 24px; }

/* Row icon - иконка в left-side каждого list-row */
.row-icon-wrap {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  flex-shrink: 0;
  transition: background var(--t-fast), border-color var(--t-base);
}

.row-icon-wrap .icon { width: 18px; height: 18px; color: var(--fg-1); }

.row:active .row-icon-wrap {
  background: var(--bg-3);
  border-color: var(--line-strong);
}

/* Цветной акцент для отдельных action-rows */
.row[data-action="buy"]      .row-icon-wrap .icon { color: var(--accent); }
.row[data-action="topup"]    .row-icon-wrap .icon { color: var(--ok); }
.row[data-action="referral"] .row-icon-wrap .icon { color: #c4b5fd; }
.row[data-action="support"]  .row-icon-wrap .icon { color: var(--fg-2); }

/* Primary CTA - premium dark with subtle accent glow */
.cta-primary {
  height: 52px;
  width: 100%;
  margin-top: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.035) 0%, transparent 100%),
    var(--bg-2);
  color: var(--fg-1);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.005em;
  transition: transform var(--t-fast), background var(--t-base), border-color var(--t-base), box-shadow var(--t-base);
  position: relative;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.04) inset,
    0 1px 2px rgba(0, 0, 0, 0.3);
}

.cta-primary:active {
  transform: scale(0.987);
  background: var(--bg-3);
  border-color: rgba(91, 158, 255, 0.25);
}

.cta-primary.copied {
  background: linear-gradient(180deg, rgba(52,211,153,0.18), rgba(52,211,153,0.08));
  border-color: rgba(52, 211, 153, 0.4);
  color: var(--ok);
  box-shadow: 0 0 0 4px rgba(52, 211, 153, 0.08);
}

.cta-icon {
  display: inline-flex;
  align-items: center;
  color: var(--accent);
}

.cta-primary.copied .cta-icon { color: var(--ok); }

/* Outline button - для secondary в модалах */
.btn-outline {
  width: 100%;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  color: var(--fg-2);
  font-size: 14px;
  font-weight: 500;
  transition: background var(--t-base), border-color var(--t-base), transform var(--t-fast);
}

.btn-outline:active {
  transform: scale(0.985);
  background: var(--bg-2);
  border-color: var(--line-strong);
}

/* Универсальный btn-primary alias (для модалов) */
.btn-primary {
  height: 52px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: linear-gradient(180deg, #ffffff 0%, #ededf0 100%);
  color: var(--bg-0);
  border-radius: var(--r-md);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  transition: transform var(--t-fast), background var(--t-base);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.6) inset,
    0 4px 14px rgba(0, 0, 0, 0.3);
}

.btn-primary:active { transform: scale(0.985); background: #e0e0e5; }

.btn-primary.copied {
  background: linear-gradient(180deg, #34d399 0%, #22c98a 100%);
  color: #042818;
}

.btn-icon { font-size: 16px; display: inline-flex; }

/* ─── Inline metric (traffic) ─── */
.inline-metric {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.inline-metric-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.inline-metric-head .label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-3);
}

.inline-metric-head .value {
  font-size: 14px;
  font-weight: 600;
  color: var(--fg-1);
  font-feature-settings: "tnum";
}

/* ─── Block + section labels ─── */
.block {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.block-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.block-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-3);
}

.block-link {
  font-size: 13px;
  font-weight: 500;
  color: var(--accent);
}

/* ─── List rows (Quick actions) ─── */
.row-list {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
}

.row {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 56px;
  padding: 0 16px;
  background: transparent;
  color: var(--fg-1);
  text-align: left;
  transition: background var(--t-fast);
}

.row + .row {
  border-top: 1px solid var(--line);
}

.row:active {
  background: var(--bg-2);
}

.row-title {
  flex: 1;
  font-size: 15px;
  font-weight: 500;
  color: var(--fg-1);
  letter-spacing: -0.005em;
}

.row-chevron {
  color: var(--fg-3);
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  flex-shrink: 0;
  transition: transform var(--t-fast), color var(--t-base);
}

.row:active .row-chevron {
  transform: translateX(2px);
  color: var(--fg-2);
}

/* ─── Plans grid ─── */
.plans-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.plan {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0;
  padding: 16px 14px 14px;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  text-align: left;
  transition: background var(--t-base), border-color var(--t-base), transform var(--t-fast);
  cursor: pointer;
  min-height: 124px;
}

.plan:active {
  background: var(--bg-2);
  transform: scale(0.985);
}

.plan--featured {
  background:
    linear-gradient(180deg, rgba(91,158,255,0.06), rgba(91,158,255,0.01)),
    var(--bg-1);
  border-color: rgba(91, 158, 255, 0.22);
}

.plan--featured:active {
  background:
    linear-gradient(180deg, rgba(91,158,255,0.10), rgba(91,158,255,0.02)),
    var(--bg-2);
}

.plan-badge {
  position: absolute;
  top: 11px;
  right: 11px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  background: rgba(91, 158, 255, 0.10);
  border: 1px solid rgba(91, 158, 255, 0.22);
  padding: 3px 7px;
  border-radius: 6px;
}

.plan-period {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--fg-3);
  margin-bottom: 8px;
}

.plan-price {
  font-size: 26px;
  font-weight: 800;
  color: var(--fg-1);
  font-feature-settings: "tnum";
  letter-spacing: -0.02em;
  line-height: 1;
}

.plan-currency {
  font-size: 16px;
  font-weight: 600;
  color: var(--fg-3);
  margin-left: 2px;
}

.plan-meta {
  margin-top: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--fg-3);
  font-feature-settings: "tnum";
  display: flex;
  align-items: center;
  gap: 6px;
}

.plan-save {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--ok);
  font-feature-settings: "tnum";
  letter-spacing: 0.02em;
}

.plan-save::before {
  content: '·';
  margin-right: 6px;
  color: var(--fg-3);
  font-weight: 400;
}

/* ─── Footer ─── */
.footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 6px 12px;
  font-size: 11px;
  color: var(--fg-3);
  padding-top: 8px;
  margin-top: auto;
}

.footer-id { font-feature-settings: "tnum"; }

.footer-legal {
  flex-basis: 100%;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  margin-top: 6px;
  padding-top: 8px;
  border-top: 1px solid rgba(255,255,255,0.06);
}
.footer-legal a {
  color: var(--fg-3);
  text-decoration: none;
  transition: color 0.15s;
}
.footer-legal a:hover { color: var(--accent); }

/* ===================================================================
   MODALS
   =================================================================== */

body.modal-open { overflow: hidden; }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: overlayIn 0.2s ease both;
}

@keyframes overlayIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--bg-1);
  border-top: 1px solid var(--line-strong);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  width: 100%;
  max-width: 480px;
  padding:
    24px 20px
    max(env(safe-area-inset-bottom), 28px) 20px;
  position: relative;
  animation: modalIn 0.32s var(--t-slow) both;
  max-height: 92vh;
  overflow-y: auto;
}

@keyframes modalIn {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

.modal::before {
  content: '';
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  width: 36px;
  height: 4px;
  background: var(--line-strong);
  border-radius: 2px;
}

.modal-close {
  position: absolute;
  top: 18px;
  right: 16px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--bg-2);
  border: 1px solid var(--line);
  color: var(--fg-2);
  font-size: 13px;
  display: grid;
  place-items: center;
  transition: background var(--t-fast), transform var(--t-fast);
}

.modal-close:active {
  background: var(--bg-3);
  transform: scale(0.9);
}

.modal-header {
  margin-bottom: 22px;
  padding-right: 40px;
  margin-top: 12px;
}

.modal-title {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--fg-1);
  margin-bottom: 4px;
}

.modal-subtitle {
  font-size: 14px;
  color: var(--fg-2);
  margin-bottom: 8px;
  line-height: 1.45;
}

.modal-price {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--fg-1);
  font-feature-settings: "tnum";
}

.modal-price::after {
  content: ' ₽';
  font-size: 18px;
  font-weight: 500;
  color: var(--fg-3);
}

.modal-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.modal-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-3);
  margin-bottom: 2px;
}

/* ─── Providers (in payment modal) ─── */
.providers {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.provider-btn {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 14px 16px;
  font-size: 15px;
  font-weight: 500;
  color: var(--fg-1);
  text-align: left;
  transition: background var(--t-fast), border-color var(--t-base), transform var(--t-fast);
  width: 100%;
}

.provider-btn::after {
  content: '›';
  color: var(--fg-3);
  font-size: 20px;
  font-weight: 300;
  flex-shrink: 0;
}

.provider-btn:active {
  background: var(--bg-3);
  transform: scale(0.985);
}

/* ─── Checking state ─── */
.modal-checking {
  align-items: center;
  padding: 24px 0 8px;
  gap: 14px;
}

.checking-spinner {
  width: 32px;
  height: 32px;
  border: 2px solid var(--line);
  border-top-color: var(--fg-1);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.checking-text {
  font-size: 15px;
  font-weight: 500;
  color: var(--fg-2);
}

/* ─── Success state ─── */
.modal-success {
  align-items: center;
  padding: 24px 0 8px;
  gap: 10px;
}

.success-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(52,211,153,0.14);
  border: 1px solid rgba(52,211,153,0.30);
  color: #34d399;
  margin: 0 auto 8px;
  animation: popIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  box-shadow: 0 8px 28px -10px rgba(52,211,153,0.45);
}
.success-icon svg { display: block; }

.modal-hero-icon {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(91,158,255,0.12);
  border: 1px solid rgba(91,158,255,0.28);
  color: #7cb8ff;
  margin: 0 auto 10px;
  box-shadow: 0 10px 30px -12px rgba(91,158,255,0.50);
}
.modal-hero-icon svg { display: block; }

.brand-icon {
  flex-shrink: 0;
  margin-right: 2px;
  opacity: 0.92;
}

@keyframes popIn {
  from { opacity: 0; transform: scale(0.5); }
  to   { opacity: 1; transform: scale(1); }
}

.success-text {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--fg-1);
}

.success-sub {
  font-size: 14px;
  color: var(--fg-2);
  margin-bottom: 6px;
}

/* ─── Referral stats ─── */
.ref-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}

.ref-stat {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 14px;
  text-align: center;
}

.ref-stat-value {
  font-size: 22px;
  font-weight: 800;
  color: var(--fg-1);
  font-feature-settings: "tnum";
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}

.ref-stat-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-3);
}

.ref-link {
  background: var(--bg-0);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 12px 14px;
  font-size: 12px;
  color: var(--fg-2);
  word-break: break-all;
  font-family: ui-monospace, SFMono-Regular, monospace;
  line-height: 1.5;
}

/* ─── Topup amount input ─── */
.amount-input-wrap {
  position: relative;
}

.amount-input {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  padding: 18px 50px 18px 18px;
  font-size: 26px;
  font-weight: 800;
  color: var(--fg-1);
  font-family: inherit;
  font-feature-settings: "tnum";
  letter-spacing: -0.01em;
  outline: none;
  transition: border-color var(--t-base);
  appearance: textfield;
  -moz-appearance: textfield;
}

.amount-input::-webkit-outer-spin-button,
.amount-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
}

.amount-input:focus {
  border-color: var(--accent);
}

.amount-currency {
  position: absolute;
  right: 18px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 20px;
  font-weight: 600;
  color: var(--fg-3);
  pointer-events: none;
}

.amount-quick {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.amount-chip {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 10px 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--fg-2);
  transition: background var(--t-fast), color var(--t-base), transform var(--t-fast);
}

.amount-chip:active {
  background: var(--bg-3);
  color: var(--fg-1);
  transform: scale(0.96);
}

/* ─── Platform tabs (Happ modal) ─── */
.platform-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 4px;
  margin-bottom: 10px;
}

.platform-tab {
  background: none;
  color: var(--fg-3);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 9px 4px;
  border-radius: 8px;
  transition: background var(--t-base), color var(--t-base);
  text-align: center;
}

.platform-tab.active {
  background: var(--bg-3);
  color: var(--fg-1);
}

.platform-panel {
  display: none;
  animation: panelIn 0.2s ease both;
}

.platform-panel.active { display: block; }

@keyframes panelIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.how-to {
  font-size: 13px;
  color: var(--fg-2);
  line-height: 1.55;
  padding: 14px 14px 14px 32px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  margin-top: 8px;
}

.how-to li { margin-bottom: 6px; }
.how-to li:last-child { margin-bottom: 0; }
.how-to b { color: var(--fg-1); font-weight: 700; }

/* ─── Scrollbar ─── */
::-webkit-scrollbar { width: 0; }
