:root {
  --tg-theme-bg: #0a0a0a;
  --tg-theme-text: #ffffff;
  --tg-theme-hint: #999999;
  --tg-theme-link: #2481cc;
  --tg-theme-button: #2481cc;
  --tg-theme-button-text: #ffffff;
  --tg-theme-secondary-bg: #1c1c1e;

  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --success: #10b981;
  --error: #ef4444;
  --warning: #f59e0b;
  --surface: #121212;
  --surface-light: #1e1e1e;
  --border: rgba(255, 255, 255, 0.1);
  --glass: rgba(255, 255, 255, 0.05);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--tg-theme-bg, #000);
  color: var(--tg-theme-text, #fff);
  line-height: 1.5;
  font-size: 16px;
  overflow-x: hidden;
}

.app {
  max-width: 600px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  padding-bottom: 80px;
  /* Space for bottom nav */
}

/* Header */
.header {
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 10;
}

.header-title {
  font-size: 20px;
  font-weight: 600;
  background: linear-gradient(90deg, #3b82f6, #ec4899);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Main Tabs */
.tabs {
  display: flex;
  background: var(--bg-secondary);
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 20px;
}

.tab {
  flex: 1;
  text-align: center;
  padding: 10px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.tab.active {
  background: var(--bg-card);
  color: var(--primary);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.tab-content {
  display: none;
  animation: fadeIn 0.3s ease;
}

.tab-content.active {
  display: block;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(5px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Service Cards */
.service-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  margin-bottom: 12px;
}

.service-icon {
  width: 40px;
  height: 40px;
  background: rgba(59, 130, 246, 0.1);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.service-details {
  flex: 1;
}

.service-name {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 4px;
}

.service-desc {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.3;
}

.section-title {
  font-size: 18px;
  font-weight: 700;
  margin: 24px 0 12px 0;
  color: var(--text-primary);
}

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


/* Cards */
.card {
  background: var(--surface-light);
  border-radius: 20px;
  padding: 20px;
  margin: 16px;
  border: 1px solid var(--border);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

/* Status Card */
.status-card {
  display: flex;
  align-items: center;
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.1), rgba(236, 72, 153, 0.05));
}

.status-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: var(--glass);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 16px;
  color: var(--primary);
}

.status-info {
  flex: 1;
}

.status-label {
  font-size: 14px;
  color: var(--tg-theme-hint);
  margin-bottom: 4px;
}

.status-value {
  font-size: 18px;
  font-weight: 600;
}

.status-value.active {
  color: var(--success);
}

.status-value.inactive {
  color: var(--tg-theme-hint);
}

.status-badge {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--tg-theme-hint);
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.2);
  transition: all 0.3s ease;
}

.status-badge.active {
  background: var(--success);
  box-shadow: 0 0 15px var(--success);
}

/* Stats Card */
.stats-card {
  margin-top: 0;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 12px;
  font-size: 14px;
}

.stat-value {
  font-weight: 600;
}

.progress-bar {
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 8px;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #ec4899);
  width: 0%;
  transition: width 0.5s ease;
}

/* Buttons */
.btn {
  border: none;
  outline: none;
  background: var(--surface-light);
  color: var(--tg-theme-text);
  border-radius: 12px;
  padding: 14px 20px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  position: relative;
  overflow: hidden;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--tg-theme-button, #3b82f6);
  color: var(--tg-theme-button-text, #fff);
  box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
}

.btn-large {
  margin: 0 16px 16px;
  width: calc(100% - 32px);
  padding: 20px;
  font-size: 18px;
  border-radius: 16px;
  background: linear-gradient(135deg, #3b82f6, #6366f1);
}

.btn-chrome {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(45deg, transparent 40%, rgba(255, 255, 255, 0.2) 50%, transparent 60%);
  transform: translateX(-100%);
  animation: shine 3s infinite;
}

@keyframes shine {
  0% {
    transform: translateX(-100%);
  }

  20% {
    transform: translateX(100%);
  }

  100% {
    transform: translateX(100%);
  }
}

.btn-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 0 16px;
  margin-bottom: 16px;
}

.btn-card {
  flex-direction: column;
  padding: 16px;
  height: 80px;
  background: var(--surface-light);
  border: 1px solid var(--border);
}

.btn-card svg {
  margin-bottom: 4px;
  color: var(--primary);
}

/* Referral Card */
.referral-card {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), rgba(59, 130, 246, 0.05));
  border-color: rgba(16, 185, 129, 0.2);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.referral-header {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--success);
  font-weight: 600;
}

.referral-info {
  font-size: 14px;
  opacity: 0.8;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--success);
  color: var(--success);
  padding: 10px;
  font-size: 14px;
}

/* Bottom Navigation */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(18, 18, 18, 0.95);
  backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  padding: 12px 16px 24px;
  /* Extra padding for iPhone home indicator */
  z-index: 100;
}

.nav-item {
  background: none;
  border: none;
  color: var(--tg-theme-hint);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  cursor: pointer;
  transition: color 0.2s;
  padding: 4px 12px;
}

.nav-item.active {
  color: var(--primary);
}

.nav-item svg {
  width: 24px;
  height: 24px;
}

/* Pricing Page */
.page {
  animation: fadeIn 0.3s ease;
  padding-bottom: 100px;
}

.page-header {
  display: flex;
  align-items: center;
  padding: 16px;
  gap: 16px;
}

.back-btn {
  background: none;
  border: none;
  color: var(--tg-theme-text);
  font-size: 24px;
  cursor: pointer;
  padding: 4px;
}

.pricing-list {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.pricing-card {
  background: var(--surface-light);
  border-radius: 20px;
  padding: 24px;
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
  transition: transform 0.2s;
}

.pricing-card.featured {
  border-color: var(--primary);
  background: linear-gradient(135deg, var(--surface-light), rgba(59, 130, 246, 0.1));
}

.pricing-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  background: var(--primary);
  color: white;
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.pricing-name {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
}

.pricing-price {
  font-size: 32px;
  font-weight: 700;
  margin-bottom: 16px;
}

.pricing-price span {
  font-size: 14px;
  font-weight: normal;
  color: var(--tg-theme-hint);
}

.pricing-features {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
  font-size: 14px;
  color: var(--tg-theme-hint);
}

/* Profile Page */
.profile-content {
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

.profile-avatar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.avatar-circle {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6, #ec4899);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  font-weight: 600;
  color: #fff;
  box-shadow: 0 8px 20px rgba(59, 130, 246, 0.3);
}

.profile-name {
  font-size: 20px;
  font-weight: 600;
}

.profile-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  width: 100%;
}

.profile-stat {
  background: var(--surface-light);
  border-radius: 16px;
  padding: 16px;
  text-align: center;
  border: 1px solid var(--border);
}

.stat-number {
  font-size: 24px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 4px;
}

.profile-menu {
  width: 100%;
  border-radius: 16px;
  background: var(--surface-light);
  overflow: hidden;
  border: 1px solid var(--border);
}

.menu-item {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  background: none;
  border: none;
  color: var(--tg-theme-text);
  font-size: 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}

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

/* Toast */
.toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.9);
  background: rgba(0, 0, 0, 0.9);
  color: white;
  padding: 12px 24px;
  border-radius: 24px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s ease;
  z-index: 1000;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.toast.success {
  border: 1px solid var(--success);
}

.toast.error {
  border: 1px solid var(--error);
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ============================================================
   KEY MODAL - Красивое окно с VPN ключами
   ============================================================ */

.key-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: modalFadeIn 0.3s ease;
}

@keyframes modalFadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.key-modal-content {
  background: linear-gradient(145deg, #1a1a2e, #16213e);
  border-radius: 24px;
  width: 100%;
  max-width: 400px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 24px;
  position: relative;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  animation: modalSlideUp 0.3s ease;
}

@keyframes modalSlideUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.key-modal-content h2 {
  text-align: center;
  margin-bottom: 24px;
  font-size: 22px;
  background: linear-gradient(90deg, #3b82f6, #ec4899);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.key-modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 16px;
  transition: all 0.2s;
}

.key-modal-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

.key-section {
  margin-bottom: 16px;
}

.key-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 8px;
}

.key-icon {
  font-size: 18px;
}

.key-desc {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.6);
  margin-bottom: 12px;
}

.key-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 16px;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.3s;
  border: none;
  cursor: pointer;
}

.key-btn-quick {
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
  box-shadow: 0 4px 20px rgba(16, 185, 129, 0.3);
}

.key-btn-quick:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 25px rgba(16, 185, 129, 0.4);
}

.key-btn-quick:active {
  transform: scale(0.98);
}

.key-divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
  margin: 20px 0;
}

.key-link-box {
  display: flex;
  gap: 8px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 12px;
  padding: 4px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.key-link-box input {
  flex: 1;
  background: transparent;
  border: none;
  color: #fff;
  padding: 12px;
  font-size: 12px;
  outline: none;
  min-width: 0;
}

.key-copy-btn {
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  border: none;
  color: white;
  padding: 12px 16px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 16px;
  transition: all 0.2s;
}

.key-copy-btn:hover {
  transform: scale(1.05);
}

.key-copy-btn:active {
  transform: scale(0.95);
}

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

.server-item {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 12px;
  color: #fff;
  text-decoration: none;
  text-align: center;
  transition: all 0.2s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.server-item:hover {
  background: rgba(59, 130, 246, 0.2);
  border-color: rgba(59, 130, 246, 0.5);
}

.server-item:active {
  transform: scale(0.95);
}

.key-instructions {
  background: rgba(255, 255, 255, 0.03);
  border-radius: 16px;
  padding: 16px;
  margin-top: 8px;
}

.key-instructions ol {
  padding-left: 20px;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.8);
}

.key-instructions li {
  margin-bottom: 12px;
  line-height: 1.5;
}

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

.app-link {
  display: inline-block;
  background: rgba(59, 130, 246, 0.15);
  border: 1px solid rgba(59, 130, 246, 0.3);
  color: #3b82f6;
  padding: 10px 14px;
  border-radius: 10px;
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  text-align: center;
  transition: all 0.2s;
}

.app-link:hover {
  background: rgba(59, 130, 246, 0.25);
}