:root {
  --bg-deep: #0a0920;
  --bg-deep-2: #0f0c2e;
  --bg-surface: #17143a;
  --bg-surface-2: #201c4a;
  --bg-surface-3: #2a2559;
  --line: rgba(255, 255, 255, 0.08);
  --line-soft: rgba(255, 255, 255, 0.05);

  --pink: #ff5da2;
  --orange: #ff9a56;
  --purple: #8b5cf6;
  --blue: #38bdf8;

  --text-primary: #f6f2ff;
  --text-muted: #9a92c2;
  --text-faint: #6c6493;

  --success: #34d399;
  --danger: #fb7185;

  --grad-brand: linear-gradient(90deg, var(--pink) 0%, var(--orange) 35%, var(--purple) 70%, var(--blue) 100%);
  --grad-brand-soft: linear-gradient(135deg, rgba(255,93,162,0.18), rgba(139,92,246,0.14) 55%, rgba(56,189,248,0.16));

  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;

  --font-display: 'Baloo 2', system-ui, sans-serif;
  --font-body: 'Manrope', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;

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

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-deep);
  color: var(--text-primary);
  font-family: var(--font-body);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

body {
  background:
    radial-gradient(120% 60% at 50% -10%, rgba(139,92,246,0.20), transparent 60%),
    radial-gradient(100% 50% at 100% 0%, rgba(255,93,162,0.10), transparent 55%),
    var(--bg-deep);
  min-height: 100vh;
}

button, input {
  font-family: inherit;
  color: inherit;
}

::selection { background: rgba(139,92,246,0.35); }

.app-shell {
  padding: calc(var(--safe-top) + 14px) 16px calc(74px + var(--safe-bottom) + 16px);
  max-width: 560px;
  margin: 0 auto;
}

.screen { animation: fadeIn .22s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  .screen { animation: none; }
  * { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}

/* ===================== TOPBAR ===================== */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}
.topbar-brand { display: flex; align-items: center; gap: 10px; }
.topbar-logo {
  width: 36px; height: 36px; border-radius: 10px; object-fit: cover;
  box-shadow: 0 0 0 1px var(--line), 0 4px 14px rgba(139,92,246,0.35);
}
.topbar-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 19px;
  letter-spacing: 0.2px;
}
.topbar-status {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; color: var(--text-muted);
  background: var(--bg-surface);
  border: 1px solid var(--line);
  padding: 6px 10px 6px 8px;
  border-radius: 999px;
}
.topbar-status .dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--text-faint);
  box-shadow: 0 0 0 0 rgba(52,211,153,0);
}
.topbar-status.is-active .dot { background: var(--success); box-shadow: 0 0 8px 1px rgba(52,211,153,0.7); }
.topbar-status.is-expired .dot { background: var(--danger); }

/* ===================== HERO: SUNSET CARD (signature element) ===================== */

.sunset-card {
  position: relative;
  border-radius: 26px;
  overflow: hidden;
  height: 236px;
  background: linear-gradient(180deg, #1a1547 0%, #120f38 55%, #0c0a28 100%);
  border: 1px solid var(--line);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sunset-ring {
  position: absolute;
  width: 200px; height: 200px;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%) rotate(-90deg);
}
.ring-track {
  fill: none;
  stroke: rgba(255,255,255,0.07);
  stroke-width: 10;
}
.ring-progress {
  fill: none;
  stroke: url(#sunsetGrad);
  stroke-width: 10;
  stroke-linecap: round;
  stroke-dasharray: 578;
  stroke-dashoffset: 578;
  transition: stroke-dashoffset 1s cubic-bezier(.22,.9,.34,1);
  filter: drop-shadow(0 0 6px rgba(255,93,162,0.35));
}

.sunset-sky {
  position: absolute;
  width: 152px; height: 152px;
  border-radius: 50%;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  overflow: hidden;
  background: linear-gradient(180deg, #2a1a4d 0%, #3a1f52 30%, #a1416b 60%, #d9714f 85%, #f2a35a 100%);
}
.sunset-sun {
  position: absolute;
  width: 62px; height: 62px;
  border-radius: 50%;
  left: 50%;
  top: var(--sun-top, 68%);
  transform: translate(-50%, -50%);
  background: radial-gradient(circle at 35% 30%, #fff6df, #ffd27a 45%, #ff9a56 100%);
  box-shadow: 0 0 26px 6px rgba(255,180,110,0.55);
  transition: top 1s cubic-bezier(.22,.9,.34,1);
}
.palm-skyline {
  position: absolute;
  bottom: -2px; left: 0;
  width: 100%; height: 34px;
  color: #0c0a28;
}

.sunset-content {
  position: relative;
  z-index: 2;
  text-align: center;
}
.days-number {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 46px;
  line-height: 1;
  text-shadow: 0 2px 18px rgba(0,0,0,0.45);
}
.days-label {
  font-size: 12.5px;
  color: rgba(255,255,255,0.75);
  margin-top: 4px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

/* ===================== QUICK ACTIONS ===================== */

.quick-actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}
.quick-btn {
  background: var(--bg-surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 12px 4px 10px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  font-size: 11.5px; font-weight: 600; color: var(--text-muted);
  cursor: pointer;
  transition: transform .15s ease, border-color .15s ease, background .15s ease;
}
.quick-btn:active { transform: scale(0.96); background: var(--bg-surface-2); }
.quick-icon { font-size: 19px; }

/* ===================== GENERIC CARDS / SECTIONS ===================== */

.section-card {
  background: var(--bg-surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px;
  margin-bottom: 12px;
}

.subheader { margin-bottom: 14px; }
.subheader-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 22px;
}
.hint-text {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 0 0 14px;
}

.empty-illustration { font-size: 34px; margin-bottom: 6px; }
.empty-title { font-family: var(--font-display); font-weight: 700; font-size: 17px; margin-bottom: 6px; }
.empty-text { font-size: 13px; color: var(--text-muted); line-height: 1.5; margin-bottom: 14px; }

/* ===================== BUTTONS ===================== */

.btn {
  width: 100%;
  border: none;
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 14.5px;
  cursor: pointer;
  transition: transform .12s ease, opacity .12s ease;
}
.btn:active { transform: scale(0.98); }
.btn-primary {
  background: var(--grad-brand);
  color: #140f2e;
}
.btn-secondary {
  background: var(--bg-surface-2);
  border: 1px solid var(--line);
  color: var(--text-primary);
}
.btn-ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text-muted);
}
.btn[disabled] { opacity: 0.5; pointer-events: none; }

.btn-icon {
  width: 44px; height: 44px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--bg-surface-2);
  font-size: 17px;
  cursor: pointer;
  flex-shrink: 0;
}

/* ===================== PLANS ===================== */

.mode-switch {
  display: flex;
  background: var(--bg-surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px;
  margin-bottom: 14px;
}
.mode-btn {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-weight: 700;
  font-size: 13px;
  padding: 9px 6px;
  border-radius: 999px;
  cursor: pointer;
}
.mode-btn.active {
  background: var(--bg-surface-3);
  color: var(--text-primary);
}

.plans-list { display: flex; flex-direction: column; gap: 10px; }

.plan-card {
  position: relative;
  background: var(--bg-surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  overflow: hidden;
}
.plan-card.popular { border-color: rgba(139,92,246,0.5); }
.plan-card.popular::before {
  content: '';
  position: absolute; inset: -1px;
  padding: 1px;
  border-radius: inherit;
  background: var(--grad-brand);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0.55;
  pointer-events: none;
}
.plan-badge {
  position: absolute;
  top: 10px; right: 14px;
  font-size: 10.5px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--grad-brand);
  color: #140f2e;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.plan-title { font-family: var(--font-display); font-weight: 700; font-size: 16px; margin-bottom: 2px; }
.plan-days { font-size: 12.5px; color: var(--text-muted); }
.plan-price { font-family: var(--font-mono); font-weight: 600; font-size: 19px; white-space: nowrap; }
.plan-price small { font-size: 12px; color: var(--text-muted); font-weight: 500; }

/* ===================== SERVERS ===================== */

.servers-list { display: flex; flex-direction: column; gap: 10px; }
.server-card {
  background: var(--bg-surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 15px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.server-flag {
  font-size: 26px;
  width: 46px; height: 46px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-surface-2);
  border-radius: 13px;
}
.server-info { flex: 1; min-width: 0; }
.server-name { font-weight: 700; font-size: 15px; margin-bottom: 2px; }
.server-status { font-size: 12px; color: var(--text-muted); }
.server-status.connected { color: var(--success); }
.server-copy {
  border: 1px solid var(--line);
  background: var(--bg-surface-2);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
}

/* ===================== TRAFFIC ===================== */

.traffic-list { display: flex; flex-direction: column; gap: 10px; }
.traffic-card {
  background: var(--bg-surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 16px;
}
.traffic-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.traffic-server { font-weight: 700; font-size: 14.5px; }
.traffic-total { font-family: var(--font-mono); font-size: 13px; color: var(--text-muted); }
.traffic-bar-track {
  height: 8px;
  border-radius: 999px;
  background: var(--bg-surface-2);
  overflow: hidden;
  display: flex;
}
.traffic-bar-up { height: 100%; background: linear-gradient(90deg, var(--pink), var(--orange)); }
.traffic-bar-down { height: 100%; background: linear-gradient(90deg, var(--purple), var(--blue)); }
.traffic-legend {
  display: flex; gap: 14px;
  margin-top: 9px;
  font-size: 11.5px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}
.traffic-legend span { display: flex; align-items: center; gap: 5px; }
.legend-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }

/* ===================== PROFILE ===================== */

.profile-card {
  display: flex; flex-direction: column; align-items: center;
  padding: 22px 16px;
  margin-bottom: 12px;
}
.profile-avatar {
  width: 66px; height: 66px;
  border-radius: 50%;
  background: var(--grad-brand);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 26px;
  color: #140f2e;
  margin-bottom: 10px;
}
.profile-name { font-family: var(--font-display); font-weight: 700; font-size: 18px; }
.profile-sub { font-size: 13px; color: var(--text-muted); margin-top: 3px; }

.referral-card { }
.referral-head { margin-bottom: 6px; }
.referral-title { font-family: var(--font-display); font-weight: 700; font-size: 16px; }

.referral-link-row {
  display: flex; gap: 8px;
  margin-bottom: 10px;
}
.referral-link-input {
  flex: 1;
  min-width: 0;
  background: var(--bg-surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0 12px;
  height: 44px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
}

.referral-stats-row {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}
.referral-stat {
  flex: 1;
  background: var(--bg-surface-2);
  border-radius: var(--radius-sm);
  padding: 12px;
  text-align: center;
}
.referral-stat-num {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 20px;
  background: var(--grad-brand);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.referral-stat-label { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.referral-pending {
  margin-top: 10px;
  font-size: 12px;
  color: var(--orange);
  background: rgba(255,154,86,0.1);
  border: 1px solid rgba(255,154,86,0.25);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
}

.link-row {
  display: flex; align-items: center; justify-content: space-between;
  text-decoration: none;
  color: var(--text-primary);
  font-weight: 600;
  font-size: 14px;
}
.link-row-arrow { color: var(--text-faint); font-size: 18px; }

/* ===================== BOTTOM NAV ===================== */

.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  display: flex;
  background: rgba(15, 12, 46, 0.86);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-top: 1px solid var(--line);
  padding: 8px 6px calc(8px + var(--safe-bottom));
  z-index: 40;
}
.nav-btn {
  flex: 1;
  background: none;
  border: none;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 6px 2px;
  color: var(--text-faint);
  font-size: 10.5px;
  font-weight: 600;
  cursor: pointer;
  border-radius: 12px;
  transition: color .15s ease;
}
.nav-icon { font-size: 19px; filter: grayscale(1); opacity: 0.6; transition: filter .15s ease, opacity .15s ease, transform .15s ease; }
.nav-btn.active { color: var(--text-primary); }
.nav-btn.active .nav-icon { filter: none; opacity: 1; transform: translateY(-1px); }

/* ===================== BOTTOM SHEET (оплата) ===================== */

.sheet-backdrop {
  position: fixed; inset: 0;
  background: rgba(5, 4, 18, 0.6);
  opacity: 0; pointer-events: none;
  transition: opacity .2s ease;
  z-index: 50;
}
.sheet-backdrop.open { opacity: 1; pointer-events: auto; }

.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: var(--bg-surface);
  border-top: 1px solid var(--line);
  border-radius: 22px 22px 0 0;
  padding: 10px 18px calc(22px + var(--safe-bottom));
  transform: translateY(100%);
  transition: transform .28s cubic-bezier(.22,.9,.34,1);
  z-index: 51;
  max-width: 560px;
  margin: 0 auto;
  box-shadow: 0 -10px 40px rgba(0,0,0,0.4);
}
.sheet.open { transform: translateY(0); }
.sheet-handle {
  width: 36px; height: 4px;
  background: var(--line);
  border-radius: 999px;
  margin: 6px auto 14px;
}

.sheet-plan-title { font-family: var(--font-display); font-weight: 700; font-size: 18px; margin-bottom: 2px; }
.sheet-plan-desc { font-size: 13px; color: var(--text-muted); margin-bottom: 18px; }
.sheet-price-row { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 18px; }
.sheet-price { font-family: var(--font-mono); font-weight: 600; font-size: 26px; }
.sheet-price-label { font-size: 12px; color: var(--text-muted); }

.promo-row {
  display: flex; gap: 8px;
  margin-bottom: 6px;
}
.promo-input {
  flex: 1;
  min-width: 0;
  background: var(--bg-surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0 12px;
  height: 44px;
  font-size: 13px;
  color: var(--text-primary);
  text-transform: uppercase;
}
.promo-success { font-size: 12px; color: var(--success); margin-bottom: 10px; }
.promo-error { font-size: 12px; color: var(--danger); margin-bottom: 10px; }

.sheet-status {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px;
  background: var(--bg-surface-2);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 10px;
}
.spinner {
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 2px solid var(--line);
  border-top-color: var(--purple);
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===================== TOAST ===================== */

.toast {
  position: fixed;
  top: calc(var(--safe-top) + 12px);
  left: 50%;
  transform: translateX(-50%) translateY(-140%);
  background: var(--bg-surface-3);
  border: 1px solid var(--line);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
  padding: 11px 18px;
  border-radius: 999px;
  z-index: 100;
  opacity: 0;
  transition: transform .25s ease, opacity .25s ease;
  box-shadow: 0 8px 30px rgba(0,0,0,0.35);
  white-space: nowrap;
}
.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* ===================== SKELETON ===================== */

.skel {
  background: linear-gradient(90deg, var(--bg-surface-2) 25%, var(--bg-surface-3) 37%, var(--bg-surface-2) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
  border-radius: 10px;
}
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }
