:root {
  --bg-primary: #07090e;
  --bg-card: rgba(17, 24, 39, 0.75);
  --bg-card-hover: rgba(30, 41, 59, 0.85);
  --border-card: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(56, 189, 248, 0.4);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --accent-cyan: #38bdf8;
  --accent-indigo: #6366f1;
  --accent-purple: #a855f7;
  --accent-green: #10b981;
  --accent-red: #ef4444;
  --accent-amber: #f59e0b;
  --fog-glow: radial-gradient(circle at 50% 0%, rgba(56, 189, 248, 0.15), transparent 70%);
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* Telegram Theme Overrides if present */
body.tg-theme {
  --bg-primary: var(--tg-theme-bg-color, #07090e);
  --text-main: var(--tg-theme-text-color, #f8fafc);
  --text-muted: var(--tg-theme-hint-color, #94a3b8);
  --bg-card: var(--tg-theme-secondary-bg-color, rgba(17, 24, 39, 0.75));
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-x: hidden;
  position: relative;
  background-image: 
    radial-gradient(circle at 10% 20%, rgba(99, 102, 241, 0.08) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(56, 189, 248, 0.08) 0%, transparent 40%);
}

/* Fog background ambiance */
.fog-ambient {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  background: var(--fog-glow);
  z-index: 0;
}

/* App Container */
.app-container {
  width: 100%;
  max-width: 480px;
  padding: 16px 16px 90px 16px;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* Header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 4px;
}

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

.brand-logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #38bdf8, #6366f1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  box-shadow: 0 4px 14px rgba(56, 189, 248, 0.3);
}

.brand-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.5px;
  background: linear-gradient(90deg, #f8fafc, #cbd5e1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-tag {
  font-size: 11px;
  color: var(--accent-cyan);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-card);
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
}

/* Subscription Hero Card */
.hero-card {
  background: linear-gradient(145deg, rgba(30, 41, 59, 0.7), rgba(15, 23, 42, 0.8));
  border: 1px solid rgba(56, 189, 248, 0.2);
  border-radius: var(--radius-lg);
  padding: 20px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(12px);
}

.hero-card::after {
  content: '';
  position: absolute;
  top: -50%;
  right: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle at 75% 25%, rgba(56, 189, 248, 0.12), transparent 45%);
  pointer-events: none;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}

.status-badge.active {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.status-badge.expired {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.status-pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: currentColor;
  box-shadow: 0 0 8px currentColor;
  animation: pulse-dot 2s infinite ease-in-out;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

.hero-title {
  font-size: 24px;
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 4px;
}

.hero-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

/* Quick Action Buttons */
.hero-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn-primary {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, #38bdf8, #2563eb);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.35);
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.btn-primary:active {
  transform: scale(0.98);
  opacity: 0.9;
}

.btn-secondary {
  width: 100%;
  padding: 12px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-main);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
}

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

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

/* Section Titles */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 4px;
}

.section-title {
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-counter {
  font-size: 12px;
  color: var(--accent-cyan);
  background: rgba(56, 189, 248, 0.12);
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 600;
}

/* Server Cards Grid */
.servers-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.server-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  transition: border-color 0.2s, transform 0.15s;
  backdrop-filter: blur(8px);
}

.server-card:hover {
  border-color: var(--border-focus);
}

.server-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.server-flag {
  font-size: 24px;
}

.server-ping {
  font-size: 11px;
  font-weight: 600;
  color: #34d399;
  display: flex;
  align-items: center;
  gap: 4px;
}

.server-ping-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: #34d399;
}

.server-name {
  font-size: 14px;
  font-weight: 700;
}

.server-protocols {
  font-size: 11px;
  color: var(--text-muted);
}

/* Tab Navigation (Bottom Bar) */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  background: rgba(11, 15, 23, 0.88);
  backdrop-filter: blur(20px);
  border-top: 1px solid var(--border-card);
  display: flex;
  justify-content: space-around;
  padding: 8px 12px 16px 12px;
  z-index: 100;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.15s, transform 0.1s;
  padding: 4px 8px;
  border-radius: 8px;
}

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

.nav-item.active .nav-icon {
  transform: translateY(-2px);
}

.nav-icon {
  font-size: 20px;
  transition: transform 0.15s;
}

/* Tabs View Container */
.tab-content {
  display: none;
  flex-direction: column;
  gap: 16px;
}

.tab-content.active {
  display: flex;
  animation: fadeIn 0.25s ease-out;
}

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

/* Pricing Plans Cards */
.plans-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.plan-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
  transition: all 0.2s;
  cursor: pointer;
}

.plan-card.popular {
  border-color: rgba(56, 189, 248, 0.4);
  background: linear-gradient(145deg, rgba(30, 41, 59, 0.6), rgba(15, 23, 42, 0.7));
}

.plan-card:hover {
  border-color: var(--accent-cyan);
}

.plan-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.plan-badge {
  position: absolute;
  top: -10px;
  right: 14px;
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 8px;
  text-transform: uppercase;
}

.plan-name {
  font-size: 16px;
  font-weight: 700;
}

.plan-desc {
  font-size: 12px;
  color: var(--text-muted);
}

.plan-price-block {
  text-align: right;
}

.plan-price {
  font-size: 20px;
  font-weight: 800;
  color: #38bdf8;
}

.plan-period {
  font-size: 11px;
  color: var(--text-muted);
}

/* Instruction Step Accordions */
.guide-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.guide-step {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.step-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(56, 189, 248, 0.15);
  color: var(--accent-cyan);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 2px;
}

.step-text {
  font-size: 13px;
  line-height: 1.4;
  color: #cbd5e1;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 90%;
  max-width: 360px;
  pointer-events: none;
}

.toast {
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(56, 189, 248, 0.3);
  color: #f8fafc;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(10px);
  animation: slideDown 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-16px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Modal Popup */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-overlay.active {
  display: flex;
}

.modal-card {
  width: 100%;
  max-width: 400px;
  background: #0f172a;
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 17px;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
}

.code-box {
  background: #020617;
  border: 1px solid var(--border-card);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-family: monospace;
  font-size: 11px;
  color: #38bdf8;
  max-height: 140px;
  overflow-y: auto;
  word-break: break-all;
  user-select: all;
}
