/* ═══════════════════════════════════════════════════════════════════
   VPN Web App — Main Stylesheet
   Dark purple theme, mobile-first, Telegram Mini App optimized
   ═══════════════════════════════════════════════════════════════════ */

/* ── CSS Variables ──────────────────────────────────────────────── */
:root {
  --bg-0:        #07080f;
  --bg-1:        #0d101a;
  --bg-card:     #12172a;
  --bg-elevated: #1a2038;
  --bg-input:    #14192c;

  --accent:      #7c3aed;
  --accent-2:    #a78bfa;
  --accent-glow: rgba(124, 58, 237, 0.3);
  --accent-dim:  rgba(124, 58, 237, 0.14);

  --green:       #22c55e;
  --green-dim:   rgba(34, 197, 94, 0.12);
  --red:         #ef4444;
  --red-dim:     rgba(239, 68, 68, 0.12);
  --yellow:      #f59e0b;
  --yellow-dim:  rgba(245, 158, 11, 0.12);
  --blue:        #3b82f6;
  --blue-dim:    rgba(59, 130, 246, 0.12);

  --text-1:  #f4f5fb;
  --text-2:  #94a0c2;
  --text-3:  #5c6488;

  /* Fallbacks for engines without `color-mix` */
  --border:       rgba(180, 190, 220, 0.18);
  --border-light: rgba(255, 255, 255, 0.06);

  --radius-sm:  8px;
  --radius-md:  12px;
  --radius-lg:  16px;
  --radius-xl:  20px;
  --radius-2xl: 24px;
  --radius-full: 9999px;

  --nav-h:    64px;
  --header-h: 56px;

  --shadow-card: 0 8px 32px rgba(0, 0, 0, 0.45), 0 1px 0 rgba(255, 255, 255, 0.04) inset;
  --shadow-glow: 0 0 32px var(--accent-glow);

  --font: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, Roboto, 'Helvetica Neue', Arial, sans-serif;

  /* Centered “phone” column on wide screens (no transform on sticky children) */
  --app-col-max: 440px;
  --app-surface: linear-gradient(165deg, #0f1120 0%, var(--bg-0) 45%, #06070d 100%);
  --app-frame-outer: none;

  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top:    env(safe-area-inset-top, 0px);

  --btn-text-on-primary: #fff;
}

@supports (color: color-mix(in srgb, #7c3aed, transparent)) {
  :root {
    --accent-dim:  color-mix(in srgb, var(--accent) 18%, transparent);
    --accent-glow: color-mix(in srgb, var(--accent) 32%, transparent);
    --border:      color-mix(in srgb, var(--text-1) 14%, transparent);
    --border-light: color-mix(in srgb, var(--text-1) 7%, transparent);
  }
}

/* ── Reset ──────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  height: 100%;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  color-scheme: dark;
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--text-1);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  letter-spacing: -0.01em;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  background-color: #03040a;
  background-image:
    radial-gradient(120% 80% at 50% -20%, rgba(124, 58, 237, 0.22), transparent 55%),
    radial-gradient(100% 60% at 100% 0%, rgba(34, 197, 94, 0.06), transparent 45%),
    radial-gradient(80% 50% at 0% 100%, rgba(59, 130, 246, 0.08), transparent 50%),
    linear-gradient(180deg, #0a0c16 0%, #05060d 100%);
  background-attachment: fixed;
}

#app { min-height: 100dvh; position: relative; isolation: isolate; }

::selection { background: rgba(124, 58, 237, 0.45); color: #fff; }

/* Telegram Mini App: native palette, no “purple on random gray” */
html[data-tg-theme] {
  color-scheme: light dark;
}
html[data-tg-theme] body {
  background: var(--bg-0) !important;
  background-image: none !important;
  background-attachment: scroll;
}
html[data-tg-theme] .main-app {
  background: var(--bg-0) !important;
  box-shadow: none;
  --app-frame-outer: none;
}
html[data-tg-theme] .main-app::before {
  display: none;
}
html[data-tg-theme] .app-header {
  background: var(--bg-0) !important;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  border-bottom: 1px solid var(--border);
}
html[data-tg-theme] .bottom-nav {
  background: var(--bg-0) !important;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  box-shadow: 0 -1px 0 var(--border);
  border-top: 1px solid var(--border);
}
html[data-tg-theme] .loading-screen {
  background: var(--bg-0) !important;
}
html[data-tg-theme] .app-backdrop::before,
html[data-tg-theme] .app-backdrop::after {
  display: none;
}

a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }

button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, textarea { font-family: inherit; }

img, svg { display: block; }

/* ── Utilities ──────────────────────────────────────────────────── */
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

.flex   { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2  { gap: 8px; }
.gap-3  { gap: 12px; }
.gap-4  { gap: 16px; }
.w-full { width: 100%; }
.text-center { text-align: center; }

.text-sm    { font-size: 13px; }
.text-base  { font-size: 15px; }
.text-lg    { font-size: 17px; }
.text-xl    { font-size: 20px; }
.text-2xl   { font-size: 24px; }
.text-3xl   { font-size: 30px; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold   { font-weight: 700; }

.text-muted   { color: var(--text-2); }
.text-faint   { color: var(--text-3); }
.text-accent  { color: var(--accent-2); }
.text-green   { color: var(--green); }
.text-red     { color: var(--red); }
.text-yellow  { color: var(--yellow); }

.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }

/* ── Ambient background (reusable) ─────────────────────────────── */
.app-backdrop {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background: inherit;
}
.app-backdrop::before,
.app-backdrop::after {
  content: '';
  position: absolute; border-radius: 50%;
  filter: blur(72px);
  opacity: 0.55;
}
.app-backdrop::before {
  width: min(120vw, 640px);
  height: min(120vw, 640px);
  top: -18%; left: 50%;
  transform: translateX(-50%);
  background: rgba(124, 58, 237, 0.35);
}
.app-backdrop::after {
  width: min(90vw, 420px);
  height: min(90vw, 420px);
  bottom: -5%; right: -15%;
  background: rgba(45, 212, 191, 0.08);
}
.app-backdrop--dim::before { opacity: 0.4; }
.app-backdrop--dim::after  { opacity: 0.35; }

/* ── Loading ─────────────────────────────────────────────────────── */
.loading-screen {
  position: fixed; inset: 0;
  z-index: 999;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.loading-inner {
  position: relative; z-index: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 20px;
}
.loading-logo {
  position: relative; display: flex; align-items: center; justify-content: center;
  width: 88px; height: 88px;
  animation: pulse 2.2s ease-in-out infinite;
}
.loading-text {
  font-size: 13px; font-weight: 500;
  color: var(--text-2); letter-spacing: 0.12em; text-transform: uppercase;
}
@keyframes pulse { 0%,100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.72; transform: scale(0.98); } }

.spinner {
  width: 28px; height: 28px;
  border: 2.5px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Auth Screen ─────────────────────────────────────────────────── */
.auth-screen {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  z-index: 100;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}
.auth-layout { position: relative; z-index: 1; width: 100%; max-width: 400px; }

.auth-card-frame {
  text-align: center;
  padding: 28px 24px 26px;
  border-radius: var(--radius-2xl);
  background: linear-gradient(150deg, rgba(26, 32, 56, 0.72) 0%, rgba(15, 17, 32, 0.65) 100%);
  border: 1px solid var(--border);
  box-shadow:
    var(--shadow-glow),
    0 24px 64px rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.auth-logo {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  width: 80px; height: 80px; margin: 0 auto 16px;
}
.auth-logo-ring {
  position: absolute; inset: 0; border-radius: 50%;
  background: conic-gradient(from 210deg, var(--accent), #c4b5fd, #22c55e33, var(--accent));
  opacity: 0.55; filter: blur(0.5px);
  animation: spin-slow 12s linear infinite;
}
.auth-logo .auth-logo-mark { position: relative; z-index: 1; }
@keyframes spin-slow { to { transform: rotate(360deg); } }

.auth-brand {
  font-size: 11px; font-weight: 800;
  letter-spacing: 0.32em; text-transform: uppercase;
  color: var(--accent-2);
  margin-bottom: 6px;
  opacity: 0.9;
}
.auth-title {
  font-size: 22px; font-weight: 700;
  line-height: 1.25; letter-spacing: -0.02em;
  margin-bottom: 10px;
  color: var(--text-1);
}
.auth-sub { color: var(--text-2); margin-bottom: 24px; font-size: 14.5px; line-height: 1.5; }
.auth-widget {
  min-height: 44px; display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.auth-hint { font-size: 12px; color: var(--text-3); margin-top: 18px; line-height: 1.45; }

/* Local dev + Telegram widget area refinements + TG iframe alignment */
#tg-login-widget iframe { border-radius: var(--radius-md) !important; }

/* ── App Layout ──────────────────────────────────────────────────── */
.main-app {
  position: relative;
  display: flex; flex-direction: column;
  width: 100%;
  max-width: min(var(--app-col-max), 100vw);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--app-surface);
  box-shadow: var(--app-frame-outer);
}
.main-app::before {
  content: '';
  position: absolute; inset: 0; pointer-events: none; z-index: 0;
  background: radial-gradient(80% 45% at 50% 0%, rgba(124, 58, 237, 0.1), transparent 60%);
}
.main-app > * { position: relative; z-index: 1; }

/* Header */
.app-header {
  position: sticky; top: 0; z-index: 50;
  height: var(--header-h);
  padding: 0 16px;
  display: flex; align-items: center; gap: 12px;
  background: rgba(13, 16, 32, 0.88);
  backdrop-filter: blur(12px) saturate(1.2);
  -webkit-backdrop-filter: blur(12px) saturate(1.2);
  border-bottom: 1px solid var(--border-light);
  padding-top: var(--safe-top);
}
.header-back {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-full);
  color: var(--text-2);
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}
.header-back:hover { background: var(--bg-elevated); color: var(--text-1); }
.header-title {
  font-size: 17px; font-weight: 600;
  flex: 1;
}
.header-actions {
  display: flex; align-items: center; gap: 8px;
}

/* Pages */
.pages-wrap {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding-bottom: calc(var(--nav-h) + var(--safe-bottom) + 8px);
  -webkit-overflow-scrolling: touch;
}
.page-content { min-height: 100%; }

/* Section padding */
.page-section { padding: 16px; }
.page-section + .page-section { padding-top: 0; }

/* ── Bottom Nav ──────────────────────────────────────────────────── */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: calc(var(--nav-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  display: flex; align-items: stretch;
  background: rgba(8, 10, 20, 0.94);
  backdrop-filter: blur(18px) saturate(1.2);
  -webkit-backdrop-filter: blur(18px) saturate(1.2);
  border-top: 1px solid var(--border-light);
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.4);
  z-index: 40;
}
.nav-item {
  flex: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 2px;
  color: var(--text-3);
  padding: 6px 2px 8px;
  transition: color 0.18s, transform 0.12s;
  position: relative;
  border: none; background: transparent;
  -webkit-tap-highlight-color: transparent;
}
.nav-item:active { transform: scale(0.96); }
.nav-item.active { color: var(--accent-2); }
.nav-item.active::before {
  content: '';
  position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 36px; height: 3px;
  background: linear-gradient(90deg, transparent, var(--accent-2), transparent);
  border-radius: 0 0 3px 3px;
  opacity: 0.9;
}
.nav-icon { width: 22px; height: 22px; }
.nav-label { font-size: 10px; font-weight: 600; letter-spacing: 0.02em; }

/* ── Cards ───────────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 12px 40px rgba(0, 0, 0, 0.2);
  overflow: hidden;
}
.card-body { padding: 16px; }
.card-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-light);
  display: flex; align-items: center; justify-content: space-between;
}
.card-header-title { font-size: 14px; font-weight: 600; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.05em; }
.card-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border-light);
}

/* ── Status Card (hero) ──────────────────────────────────────────── */
.status-card {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  padding: 24px 20px;
  text-align: center;
  position: relative;
  overflow: hidden;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 16px 48px rgba(0, 0, 0, 0.28);
}
.status-card::before {
  content: '';
  position: absolute; top: -40px; left: 50%; transform: translateX(-50%);
  width: 200px; height: 200px;
  border-radius: 50%;
  background: var(--accent-glow);
  filter: blur(40px);
  pointer-events: none;
}
.status-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 13px; font-weight: 500;
  margin-bottom: 16px;
}
.status-badge.active   { background: var(--green-dim);  color: var(--green); }
.status-badge.inactive { background: var(--red-dim);    color: var(--red); }
.status-badge.trial    { background: var(--yellow-dim); color: var(--yellow); }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

.status-title { font-size: 26px; font-weight: 700; margin-bottom: 4px; }
.status-sub   { font-size: 14px; color: var(--text-2); }

/* ── Buttons ─────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 0 20px;
  height: 48px;
  border-radius: var(--radius-full);
  font-size: 15px; font-weight: 600;
  transition: opacity 0.15s, transform 0.1s, box-shadow 0.15s;
  white-space: nowrap;
  cursor: pointer;
  border: none;
  outline: none;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; pointer-events: none; }

.btn-primary {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  color: var(--btn-text-on-primary, #fff);
  box-shadow: 0 4px 16px var(--accent-glow);
}
.btn-primary:hover { box-shadow: 0 6px 24px var(--accent-glow); }

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-1);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--border); }

.btn-outline {
  background: transparent;
  color: var(--accent-2);
  border: 1.5px solid var(--accent);
}
.btn-outline:hover { background: var(--accent-dim); }

.btn-danger {
  background: var(--red-dim);
  color: var(--red);
  border: 1px solid rgba(239,68,68,0.3);
}

.btn-sm { height: 36px; padding: 0 14px; font-size: 13px; }
.btn-lg { height: 54px; padding: 0 28px; font-size: 16px; }
.btn-block { width: 100%; }
.btn-icon { width: 40px; padding: 0; }

/* ── Inputs ──────────────────────────────────────────────────────── */
.input-group { display: flex; flex-direction: column; gap: 6px; }
.input-label { font-size: 13px; font-weight: 500; color: var(--text-2); }
.input {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-1);
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
.input::placeholder { color: var(--text-3); }

.textarea {
  width: 100%;
  padding: 12px 14px;
  min-height: 100px;
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-1);
  font-size: 15px;
  outline: none;
  resize: vertical;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

/* Input with suffix button */
.input-with-btn { display: flex; gap: 8px; }
.input-with-btn .input { flex: 1; }

/* ── List rows ───────────────────────────────────────────────────── */
.list-row {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border-light);
  transition: background 0.12s;
}
.list-row:last-child { border-bottom: none; }
.list-row:active, .list-row.clickable:hover { background: var(--bg-elevated); }
.list-row.clickable { cursor: pointer; }

.list-icon {
  width: 40px; height: 40px;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-size: 20px;
  line-height: 1;
}
.list-icon.purple { background: var(--accent-dim); color: var(--accent-2); }
.list-icon.green  { background: var(--green-dim);  color: var(--green); }
.list-icon.red    { background: var(--red-dim);    color: var(--red); }
.list-icon.yellow { background: var(--yellow-dim); color: var(--yellow); }
.list-icon.blue   { background: var(--blue-dim);   color: var(--blue); }

.list-body { flex: 1; min-width: 0; }
.list-title { font-size: 15px; font-weight: 500; }
.list-sub   { font-size: 13px; color: var(--text-2); margin-top: 1px; }
.list-end   { flex-shrink: 0; display: flex; align-items: center; gap: 8px; }

.chevron {
  width: 16px; height: 16px; color: var(--text-3);
}

/* ── Badges / Pills ──────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 12px; font-weight: 500;
}
.badge-purple { background: var(--accent-dim); color: var(--accent-2); }
.badge-green  { background: var(--green-dim);  color: var(--green); }
.badge-red    { background: var(--red-dim);    color: var(--red); }
.badge-yellow { background: var(--yellow-dim); color: var(--yellow); }
.badge-muted  { background: var(--bg-elevated); color: var(--text-2); }

/* ── Stats row ───────────────────────────────────────────────────── */
.stats-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px;
}
.stats-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px;
}
.stat-value { font-size: 22px; font-weight: 700; }
.stat-label { font-size: 12px; color: var(--text-2); margin-top: 2px; }

/* ── Progress bar ────────────────────────────────────────────────── */
.progress-wrap { margin-top: 12px; }
.progress-label {
  display: flex; justify-content: space-between;
  font-size: 12px; color: var(--text-2); margin-bottom: 6px;
}
.progress-bar {
  height: 6px;
  background: var(--bg-elevated);
  border-radius: var(--radius-full);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: var(--radius-full);
  transition: width 0.6s ease;
}

/* ── Plan cards ──────────────────────────────────────────────────── */
.plan-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px;
}
.plan-card {
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s;
  position: relative;
  overflow: hidden;
}
.plan-card:active { transform: scale(0.98); }
.plan-card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
.plan-card.popular {
  border-color: var(--accent);
}
.plan-popular-tag {
  position: absolute; top: 0; right: 0;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  font-size: 10px; font-weight: 600;
  padding: 3px 8px 3px 10px;
  border-bottom-left-radius: var(--radius-md);
}
.plan-discount-tag {
  position: absolute; top: 0; left: 0;
  background: var(--green);
  color: #fff;
  font-size: 10px; font-weight: 700;
  padding: 3px 8px 3px 6px;
  border-bottom-right-radius: var(--radius-md);
}
.plan-title    { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
.plan-price    { font-size: 22px; font-weight: 800; color: var(--accent-2); }
.plan-currency { font-size: 14px; font-weight: 500; color: var(--text-2); }
.plan-desc     { font-size: 12px; color: var(--text-2); margin-top: 6px; }

/* ── Payment methods ─────────────────────────────────────────────── */
.pay-method {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  margin-bottom: 10px;
}
.pay-method:last-child { margin-bottom: 0; }
.pay-method.selected {
  border-color: var(--accent);
  background: var(--accent-dim);
}
.pay-method-icon {
  width: 40px; height: 40px;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
  background: var(--bg-elevated);
}
.pay-method-info { flex: 1; }
.pay-method-name { font-size: 15px; font-weight: 500; }
.pay-method-sub  { font-size: 12px; color: var(--text-2); margin-top: 2px; }
.pay-method-check {
  width: 20px; height: 20px;
  border-radius: 50%;
  border: 2px solid var(--border);
  flex-shrink: 0;
  transition: border-color 0.15s, background 0.15s;
  display: flex; align-items: center; justify-content: center;
}
.pay-method.selected .pay-method-check {
  border-color: var(--accent);
  background: var(--accent);
}
.pay-method.selected .pay-method-check::after {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #fff;
}

/* ── WL card header gradient ─────────────────────────────────────── */
.card-header.wl-header {
  background: linear-gradient(90deg, var(--accent-dim), transparent);
  border-bottom-color: rgba(124,90,247,.2);
}

/* ── VPN Key copy block ──────────────────────────────────────────── */
.key-block {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex; align-items: center; gap: 10px;
}
.key-value {
  flex: 1;
  font-family: 'Courier New', Courier, monospace;
  font-size: 12px;
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.key-copy-btn {
  flex-shrink: 0;
  width: 34px; height: 34px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-dim);
  color: var(--accent-2);
  transition: background 0.15s;
}
.key-copy-btn:hover { background: var(--bg-elevated); }

/* ── QR code placeholder ─────────────────────────────────────────── */
.qr-wrap {
  display: flex; justify-content: center;
  margin: 16px 0;
}
.qr-box {
  width: 180px; height: 180px;
  background: #fff;
  border-radius: var(--radius-lg);
  display: flex; align-items: center; justify-content: center;
}

/* ── Section headers ─────────────────────────────────────────────── */
.section-title {
  font-size: 13px; font-weight: 600;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 16px 16px 8px;
}

/* ── Empty state ─────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
}
.empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-title { font-size: 17px; font-weight: 600; margin-bottom: 6px; }
.empty-sub   { font-size: 14px; color: var(--text-2); }

/* ── Divider ─────────────────────────────────────────────────────── */
.divider {
  height: 1px;
  background: var(--border-light);
  margin: 8px 0;
}
.divider-label {
  display: flex; align-items: center; gap: 12px;
  margin: 16px 0;
  color: var(--text-3); font-size: 12px;
}
.divider-label::before, .divider-label::after {
  content: ''; flex: 1; height: 1px; background: var(--border-light);
}

/* ── Ticket ──────────────────────────────────────────────────────── */
.ticket-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  transition: background 0.12s;
}
.ticket-item:last-child { border-bottom: none; }
.ticket-item:active { background: var(--bg-elevated); }
.ticket-status-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; margin-top: 6px;
}
.ticket-status-dot.open   { background: var(--green); }
.ticket-status-dot.closed { background: var(--text-3); }

/* ── Chat messages ───────────────────────────────────────────────── */
.chat-wrap { padding: 12px 16px; display: flex; flex-direction: column; gap: 10px; }
.msg {
  max-width: 80%;
  padding: 10px 13px;
  border-radius: var(--radius-lg);
  font-size: 14px; line-height: 1.45;
}
.msg.user   { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.msg.admin  { align-self: flex-start; background: var(--bg-elevated); color: var(--text-1); border-bottom-left-radius: 4px; }
.msg-time   { font-size: 11px; opacity: 0.6; margin-top: 4px; }

/* ── Toast ───────────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: calc(var(--nav-h) + var(--safe-bottom) + 12px);
  left: 50%; transform: translateX(-50%);
  z-index: 200;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-1);
  padding: 10px 18px;
  border-radius: var(--radius-full);
  font-size: 14px; font-weight: 500;
  box-shadow: var(--shadow-card);
  animation: toast-in 0.25s ease, toast-out 0.25s ease 2.5s forwards;
  white-space: nowrap;
}
.toast.success { border-color: var(--green); color: var(--green); }
.toast.error   { border-color: var(--red);   color: var(--red); }
@keyframes toast-in  { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toast-out { from { opacity: 1; } to { opacity: 0; } }

/* ── Skeleton loading ────────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--bg-elevated) 25%, var(--border) 50%, var(--bg-elevated) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.skeleton-text { height: 14px; border-radius: 4px; }
.skeleton-title { height: 20px; border-radius: 4px; }
.skeleton-card { height: 120px; border-radius: var(--radius-lg); }

/* ── Admin grid ──────────────────────────────────────────────────── */
.admin-stat-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px;
}
.admin-stat {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px;
}
.admin-stat-val   { font-size: 24px; font-weight: 700; }
.admin-stat-label { font-size: 12px; color: var(--text-2); margin-top: 2px; }

/* ── Connect guide ───────────────────────────────────────────────── */
.guide-step {
  display: flex; gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border-light);
}
.guide-step:last-child { border-bottom: none; }
.guide-num {
  width: 28px; height: 28px; flex-shrink: 0;
  border-radius: 50%;
  background: var(--accent-dim);
  color: var(--accent-2);
  font-size: 13px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  margin-top: 2px;
}
.guide-text { font-size: 14px; line-height: 1.5; }
.guide-text strong { color: var(--text-1); }

/* ── Platform tabs ───────────────────────────────────────────────── */
.tabs {
  display: flex; gap: 6px;
  padding: 4px;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex-shrink: 0;
  padding: 7px 14px;
  border-radius: var(--radius-md);
  font-size: 13px; font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.tab.active {
  background: var(--accent-dim);
  color: var(--accent-2);
}

/* ── Scroll snap (horizontal) ────────────────────────────────────── */
.snap-x {
  display: flex; gap: 12px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  padding-bottom: 4px;
}
.snap-x::-webkit-scrollbar { display: none; }
.snap-x > * { scroll-snap-align: start; flex-shrink: 0; }

/* ── Page transition ─────────────────────────────────────────────── */
.page-enter {
  animation: page-slide-in 0.2s ease;
}
@keyframes page-slide-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Referral link block ─────────────────────────────────────────── */
.ref-block {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
}
.ref-url {
  font-size: 13px; color: var(--accent-2);
  word-break: break-all; margin-bottom: 10px;
}

/* ── Toggle ──────────────────────────────────────────────────────── */
.toggle {
  position: relative;
  width: 44px; height: 26px; flex-shrink: 0;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0;
  background: var(--bg-elevated);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: background 0.2s;
  border: 1px solid var(--border);
}
.toggle-slider::before {
  content: '';
  position: absolute; left: 3px; top: 50%; transform: translateY(-50%);
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--text-3);
  transition: left 0.2s, background 0.2s;
}
.toggle input:checked + .toggle-slider { background: var(--accent-dim); border-color: var(--accent); }
.toggle input:checked + .toggle-slider::before { left: calc(100% - 21px); background: var(--accent-2); }

/* ── Local dev (демо) panel ─────────────────────────────────────── */
.standalone-dev-block {
  margin: 18px 0 0;
  padding: 16px;
  border-radius: var(--radius-lg);
  text-align: left;
  background: var(--bg-card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card);
}
.standalone-dev-block .text-sm code { font-size: 12px; padding: 1px 5px; border-radius: 4px; background: var(--bg-elevated); }

/* ── Small phones: type scale, spacing, 48px+ targets ───────────── */
@media (max-width: 520px) {
  :root { --header-h: 52px; --nav-h: 60px; }

  body {
    font-size: 16px;
    line-height: 1.5;
    letter-spacing: 0;
  }
  .text-sm { font-size: 0.83rem; }

  .app-header { padding-left: 14px; padding-right: 14px; }
  .header-title { font-size: 1.0625rem; }

  .page-section { padding: 20px 18px; }
  .page-section + .page-section { padding-top: 0; }

  .section-title { padding: 20px 18px 8px; font-size: 12px; }

  .status-title { font-size: clamp(1.35rem, 5.4vw, 1.6rem); }
  .status-sub  { font-size: 0.9rem; }

  .list-row     { padding: 15px 16px; align-items: flex-start; }
  .list-icon    { width: 44px; height: 44px; font-size: 21px; border-radius: 14px; }
  .list-title   { font-size: 1rem; }
  .list-sub     { font-size: 0.86rem; }

  .card-body   { padding: 18px; }
  .card-header { padding: 14px 16px; }

  .nav-icon  { width: 25px; height: 25px; }
  .nav-item  { min-height: 50px; padding: 4px 0 8px; }
  .nav-label { font-size: 10.5px; line-height: 1.1; }

  .btn     { min-height: 50px; height: 50px; font-size: 16px; }
  .btn-sm  { min-height: 40px; height: 40px; }

  .input, .textarea { font-size: 16px; }

  /* Standalone browser: less noisy background */
  html:not([data-tg-theme]) body {
    background-color: #07080f;
    background-image: linear-gradient(180deg, #0d101c 0%, #07080f 55%, #04050c 100%);
  }
  html:not([data-tg-theme]) .main-app::before { opacity: 0.4; }
}

/* ── Responsive ─────────────────────────────────────────────────── */
@media (min-width: 480px) {
  :root { --app-frame-outer: 0 0 0 1px var(--border), 0 40px 120px -32px rgba(0, 0, 0, 0.65); }
  .bottom-nav,
  .app-header {
    left: 50%;
    right: auto;
    width: min(var(--app-col-max), 100vw);
    transform: translateX(-50%);
  }
  .bottom-nav { border-radius: 18px 18px 0 0; }
  .toast-container { max-width: 360px; }
}

/* ── Scrollbar (desktop) ─────────────────────────────────────────── */
@media (pointer: fine) {
  ::-webkit-scrollbar { width: 4px; height: 4px; }
  ::-webkit-scrollbar-track { background: transparent; }
  ::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
}
