:root {
  color-scheme: dark;
  --bg: #0f1117;
  --bg-soft: #141820;
  --bg-card: #1a1f2a;
  --bg-elevated: #222836;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #f5f7fa;
  --text-secondary: #9aa3b5;
  --text-muted: #6b7385;
  --accent: #2aabee;
  --accent-hover: #1e9ad9;
  --accent-soft: rgba(42, 171, 238, 0.12);
  --success: #34c759;
  --success-bg: rgba(52, 199, 89, 0.12);
  --danger: #ff453a;
  --danger-bg: rgba(255, 69, 58, 0.12);
  --warn: #ff9f0a;
  --warn-bg: rgba(255, 159, 10, 0.12);
  --radius: 14px;
  --radius-lg: 18px;
  --nav-h: 64px;
  --header-h: 62px;
  --font: "Manrope", -apple-system, BlinkMacSystemFont, sans-serif;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { box-sizing: border-box; }

html {
  background: var(--bg);
}

html, body {
  margin: 0;
  padding: 0;
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100dvh;
  min-height: var(--tg-viewport-stable-height, 100dvh);
  background: var(--bg);
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-top: calc(var(--header-h) + var(--safe-top));
  padding-bottom: calc(var(--nav-h) + var(--safe-bottom) + 8px);
}

.bg-mesh,
.bg-grid,
.bg-orbs { display: none; }

/* ── Header ── */
.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  padding: 10px 16px;
  padding-top: calc(10px + var(--safe-top));
  background: rgba(15, 17, 23, 0.96);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}

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

.brand-logo {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  object-fit: cover;
  border: 1px solid var(--border-strong);
}

.brand-title {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.06em;
  line-height: 1.1;
  color: var(--text);
}

.brand-sub {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  margin-top: 2px;
}

.app-content {
  position: relative;
  z-index: 1;
}

#global-loader.loader {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg);
}

#global-loader.loader.hidden {
  display: none !important;
}

.screen {
  display: none;
  padding: 12px 16px 8px;
}

.screen.active { display: block; }

.screen.screen-enter {
  animation: fadeUp 0.32s ease both;
}

.screen.screen-enter .vpn-hero,
.screen.screen-enter .card,
.screen.screen-enter .connect-intro,
.screen.screen-enter .platform-card,
.screen.screen-enter .page-head {
  animation: fadeUp 0.38s ease both;
}

.screen.screen-enter .card:nth-of-type(1),
.screen.screen-enter .platform-card:nth-child(1) { animation-delay: 0.04s; }
.screen.screen-enter .card:nth-of-type(2),
.screen.screen-enter .platform-card:nth-child(2) { animation-delay: 0.08s; }
.screen.screen-enter .card:nth-of-type(3),
.screen.screen-enter .platform-card:nth-child(3) { animation-delay: 0.12s; }
.screen.screen-enter .card:nth-of-type(4),
.screen.screen-enter .platform-card:nth-child(4) { animation-delay: 0.16s; }

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

/* ── Hero / status card ── */
.vpn-hero,
.vpn-hero-premium {
  position: relative;
  border-radius: var(--radius-lg);
  padding: 20px 18px;
  margin-bottom: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  text-align: center;
}

.vpn-hero::before,
.hero-glow { display: none; }

.hero-logo,
.vpn-shield {
  width: 64px;
  height: 64px;
  margin: 0 auto 12px;
  border-radius: 16px;
  object-fit: cover;
  display: block;
}

.hero-logo--active {
  animation: logoPulse 2.4s ease-in-out infinite;
}

@keyframes logoPulse {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(42, 171, 238, 0.2);
  }
  50% {
    transform: scale(1.03);
    box-shadow: 0 0 18px 2px rgba(42, 171, 238, 0.28);
  }
}

.vpn-shield {
  filter: none;
}

.vpn-shield.pulse { animation: logoPulse 2.4s ease-in-out infinite; }

.vpn-shield svg { width: 100%; height: 100%; }

.vpn-status-label,
.platform-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.platform-badge {
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.platform-badge .ico svg { width: 14px; height: 14px; vertical-align: -2px; }

.vpn-status-value {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
}

.vpn-status-value.off { color: var(--text-muted); }

.vpn-plan,
.hero-caption {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 6px;
  line-height: 1.45;
}

.vpn-hero .btn { margin-top: 16px; }

/* ── Cards ── */
.card,
.glass {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 10px;
  box-shadow: none;
  backdrop-filter: none;
}

.card-glow {
  border-color: var(--border-strong);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.card-head h2, .card-head h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
}

.card-icon {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: var(--accent-soft);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  box-shadow: none;
}

.card-icon .ico svg { width: 16px; height: 16px; }

.section-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  margin: 14px 0 8px 2px;
}

.muted { color: var(--text-secondary); }

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.stat {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
}

.stat-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.stat-value {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
  word-break: break-word;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.status-pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.status-active::before {
  animation: dotPulse 2s ease-in-out infinite;
}

@keyframes dotPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.55; transform: scale(0.85); }
}

.status-active { background: var(--success-bg); color: var(--success); }
.status-expired { background: var(--danger-bg); color: var(--danger); }
.status-limited { background: var(--warn-bg); color: var(--warn); }

/* ── Buttons ── */
.btn {
  appearance: none;
  border: none;
  border-radius: 12px;
  padding: 14px 16px;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: opacity 0.15s, transform 0.12s, background 0.2s, color 0.2s;
}

.btn:active { transform: scale(0.98); opacity: 0.92; }
.btn .ico svg { width: 17px; height: 17px; }

.btn-primary,
.btn-glow {
  background: var(--accent);
  color: #fff;
  box-shadow: none;
}

.btn-glow::after { display: none; }

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

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid rgba(255, 69, 58, 0.2);
}

.btn-inline {
  width: auto;
  padding: 8px 12px;
  font-size: 12px;
}

.btn-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}

.input, .select {
  width: 100%;
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  color: var(--text);
  border-radius: 11px;
  padding: 13px 14px;
  font-family: var(--font);
  font-size: 15px;
  margin-top: 8px;
  outline: none;
}

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

.field-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 12px;
}

/* ── Plans ── */
.plan-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 8px;
  background: var(--bg-card);
  cursor: pointer;
  transition: border-color 0.15s;
}

.plan-card.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.renew-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  background: var(--success-bg);
  color: var(--success);
  vertical-align: middle;
}

.plan-renew.selected {
  border-color: var(--success);
}

.plan-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.plan-card strong { font-size: 16px; font-weight: 800; }
.plan-desc { margin-top: 4px; font-size: 12px; line-height: 1.4; }

.plan-price {
  font-size: 17px;
  font-weight: 800;
  color: var(--accent);
  white-space: nowrap;
}

.plan-durations {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.duration-chip {
  padding: 8px 12px;
  border-radius: 9px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
}

.duration-chip.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.plans-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.plans-list .plan-card { margin-bottom: 0; }

.page-head { margin-bottom: 12px; }

.page-title {
  font-size: 22px;
  font-weight: 800;
  margin: 0 0 4px;
  color: var(--text);
}

.page-desc {
  margin: 0;
  font-size: 13px;
  color: var(--text-secondary);
}

/* ── Platform picker ── */
.connect-intro {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border-radius: var(--radius-lg);
  margin-bottom: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
}

.connect-intro-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  background: var(--accent-soft);
  flex-shrink: 0;
}

.connect-intro-icon .ico svg { width: 22px; height: 22px; }

.connect-intro-title {
  margin: 0 0 4px;
  font-size: 17px;
  font-weight: 800;
}

.connect-intro-desc {
  margin: 0;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.platform-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.platform-card {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--bg-card);
  cursor: pointer;
  text-align: center;
  padding: 18px 12px 14px;
  border-radius: var(--radius-lg);
  color: var(--text);
  font-family: var(--font);
  transition: border-color 0.2s, background 0.2s, transform 0.15s;
}

.platform-card:active {
  transform: scale(0.97);
  border-color: var(--accent);
  background: var(--accent-soft);
}

.platform-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  margin: 0 auto 10px;
  border-radius: 14px;
  background: var(--bg-elevated);
  color: var(--accent);
  box-shadow: none;
  border: 1px solid var(--border);
}

.platform-icon .ico svg { width: 24px; height: 24px; }

.platform-name {
  display: block;
  font-size: 15px;
  font-weight: 800;
}

.platform-hint {
  display: block;
  margin-top: 3px;
  font-size: 11px;
  color: var(--text-muted);
}

.back-link {
  appearance: none;
  border: none;
  background: none;
  color: var(--accent);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0 0 10px;
  cursor: pointer;
}

.back-link .ico svg { width: 16px; height: 16px; }

/* ── Devices ── */
.device-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.device-item:last-child { border-bottom: none; }

.device-info {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.device-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  flex-shrink: 0;
}

.device-icon .ico svg { width: 15px; height: 15px; }

.device-name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Bottom nav ── */
.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  height: calc(var(--nav-h) + var(--safe-bottom));
  padding: 6px 8px var(--safe-bottom);
  background: rgba(15, 17, 23, 0.98);
  border-top: 1px solid var(--border);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.nav-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 10px;
  font-weight: 600;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 6px 4px;
  cursor: pointer;
  border-radius: 10px;
  transition: color 0.2s, background 0.2s, transform 0.15s;
}

.nav-btn:active { transform: scale(0.94); }

.nav-btn.active {
  color: var(--accent);
  background: var(--accent-soft);
}

.nav-icon {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-icon svg { width: 20px; height: 20px; }
.nav-btn.active .nav-icon { filter: none; }

/* ── Loader ── */
.loader {
  text-align: center;
  color: var(--text-secondary);
  gap: 14px;
}

.loader-text { font-size: 13px; font-weight: 600; }

.loader-ring {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  animation: spin 0.7s linear infinite;
  box-shadow: none;
}

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

.toast {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(var(--nav-h) + 12px + env(safe-area-inset-bottom, 0px));
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border-strong);
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  transform: translateY(6px);
  z-index: 40;
  box-shadow: var(--shadow);
}

.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { border-color: rgba(255, 69, 58, 0.35); color: #ffb4ae; }

.key-box {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  word-break: break-all;
  font-family: ui-monospace, monospace;
  font-size: 10px;
  line-height: 1.5;
  color: var(--text-secondary);
  margin: 10px 0;
}

.steps {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: s;
}

.steps li {
  counter-increment: s;
  position: relative;
  padding-left: 32px;
  margin-bottom: 12px;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.5;
}

.steps li::before {
  content: counter(s);
  position: absolute;
  left: 0;
  top: 0;
  width: 22px;
  height: 22px;
  border-radius: 7px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 11px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
}

.steps li b { color: var(--text); }

.store-links { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }

.store-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 11px;
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
}

.store-link > span:nth-child(2) { flex: 1; }

.store-link-icon {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--accent-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  flex-shrink: 0;
}

.store-link-icon .ico svg { width: 15px; height: 15px; }

.ico { display: inline-flex; line-height: 0; }
.ico svg { display: block; }

.hidden { display: none !important; }

.empty-state {
  text-align: center;
  padding: 32px 16px;
  color: var(--text-muted);
  font-size: 14px;
}

.balance-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.balance-value {
  font-size: 22px;
  font-weight: 800;
  color: var(--accent);
}

.quick-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 10px;
}

.quick-btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 14px 10px;
  color: var(--text);
  font-family: var(--font);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.quick-btn .ico { color: var(--accent); }
.quick-btn .ico svg { width: 20px; height: 20px; }

.app-version {
  margin: 20px 0 8px;
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  opacity: 0.6;
}
