/* app.css — TETRIS VPN Glass Edition v9 */
@import url('https://fonts.googleapis.com/css2?family=Inter:ital,wght@0,400;0,500;0,600;0,700;0,800;0,900;1,400&display=swap');

:root {
  --brand-orange: #ED6A0D;
  --brand-blue: #24448F;
  --brand-deep: #0F1F42;
  --glow-blue: rgba(36, 68, 143, 0.6);
  --glow-orange: rgba(237, 106, 13, 0.4);
  
  --bg-light: #1e2d55;
  --bg-dark: #050811;
  --glass-bg: rgba(30, 45, 85, 0.7);
  --glass-bg-solid: rgba(18, 28, 48, 0.9);
  --glass-border: rgba(255, 255, 255, 0.1);
  --glass-border-light: rgba(255, 255, 255, 0.06);
  
  --text-primary: #f0f3fa;
  --text-muted: #9aa6bf;
  --text-accent: #ED6A0D;
  --green-accent: #2ee5a0;
  --red-accent: #ff5a5f;
  
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 16px;
  --radius-sm: 12px;
  
  --shadow-card: 0 15px 35px -12px rgba(0, 0, 0, 0.5);
  --backdrop-blur: blur(14px);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

/* ===== ФОН ===== */
body {
  background: linear-gradient(145deg, #1e2d55 0%, #0f1628 50%, #050811 100%);
  background-attachment: fixed;
  color: var(--text-primary);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

/* Тетрис-кубики на фоне */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  background-image: 
    repeating-linear-gradient(90deg, 
      rgba(255,255,255,0.02) 0px, 
      rgba(255,255,255,0.02) 1px,
      transparent 1px,
      transparent 60px
    ),
    repeating-linear-gradient(0deg, 
      rgba(255,255,255,0.02) 0px, 
      rgba(255,255,255,0.02) 1px,
      transparent 1px,
      transparent 60px
    );
}

/* ===== ЕДИНЫЙ СТИЛЬ ДЛЯ ВСЕХ КАРТОЧЕК ===== */
.glass-card, .balance-card, .traffic-card, .servers-card, 
.ref-card, .stats-card, .device-card, .modal {
  background: var(--glass-bg);
  backdrop-filter: var(--backdrop-blur);
  -webkit-backdrop-filter: var(--backdrop-blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  transition: all 0.25s ease;
  position: relative;
  z-index: 2;
}

.glass-card:hover, .balance-card:hover, .traffic-card:hover, 
.servers-card:hover, .ref-card:hover, .device-card:hover {
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(35, 52, 95, 0.75);
}

/* ===== ОСНОВНОЙ КОНТЕЙНЕР ===== */
#app {
  display: flex;
  flex-direction: column;
  height: 100svh;
  max-width: 520px;
  margin: 0 auto;
  overflow: hidden;
  background: transparent;
  position: relative;
  z-index: 2;
}

/* ===== СТРАНИЦЫ ===== */
.page {
  flex: 1;
  overflow-y: auto;
  padding: 20px 18px 90px;
  display: none;
  scrollbar-width: thin;
  position: relative;
  z-index: 2;
}

.page.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px);}
  to { opacity: 1; transform: translateY(0);}
}

/* ===== TOP BAR ===== */
.top-bar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 18px;
  background: transparent;
}

.logo-block {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(30, 45, 85, 0.5);
  backdrop-filter: blur(10px);
  padding: 8px 16px;
  border-radius: 60px;
  border: 1px solid rgba(255,255,255,0.1);
}

.header-logo {
  width: 36px;
  height: 36px;
  filter: drop-shadow(0 0 6px rgba(36,68,143,0.6));
}

.logo-text {
  font-weight: 800;
  font-size: 15px;
  letter-spacing: -0.2px;
  background: linear-gradient(135deg, #fff, #8eaeff);
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
  white-space: nowrap;
}

.wallet-block {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(30, 45, 85, 0.5);
  backdrop-filter: blur(10px);
  padding: 6px 16px 6px 12px;
  border-radius: 60px;
  border: 1px solid rgba(255,255,255,0.1);
}

.wallet-icon {
  width: 24px;
  height: 24px;
  filter: drop-shadow(0 0 4px rgba(36,68,143,0.5));
}

.wallet-balance {
  font-weight: 900;
  font-size: 22px;
  letter-spacing: -0.5px;
  color: white;
  font-family: 'Inter', sans-serif;
}

.wallet-currency {
  font-weight: 900;
  font-size: 22px;
  color: var(--text-muted);
  margin-left: 2px;
}

.wallet-topup {
  background: var(--brand-orange);
  border: none;
  padding: 6px 14px;
  border-radius: 60px;
  font-size: 13px;
  font-weight: 800;
  color: white;
  cursor: pointer;
  transition: 0.1s;
}

.wallet-topup:active {
  transform: scale(0.96);
}

/* ===== BALANCE HERO CARD ===== */
.balance-card {
  background: rgba(30, 45, 85, 0.7);
  border-bottom: 2px solid rgba(255,255,255,0.15);
  padding: 28px 24px;
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
}

.balance-card::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -30%;
  width: 160%;
  height: 160%;
  background: radial-gradient(circle, rgba(255,255,255,0.05) 0%, transparent 70%);
  pointer-events: none;
}

.balance-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
}

.days-block {
  flex: 2;
}

.days-number {
  font-size: 72px;
  font-weight: 900;
  letter-spacing: -2px;
  background: linear-gradient(135deg, #fff, #8eaeff);
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
  line-height: 1;
}

.days-label {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-muted);
  margin-top: 8px;
}

.daily-cost {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.topup-accent {
  background: var(--brand-orange);
  border: none;
  padding: 12px 20px;
  border-radius: 60px;
  font-weight: 800;
  font-size: 14px;
  color: white;
  cursor: pointer;
  white-space: nowrap;
  transition: 0.1s;
}

.topup-accent:active {
  transform: scale(0.96);
}

.action-buttons {
  display: flex;
  gap: 12px;
  margin-top: 20px;
}

.btn-outline {
  flex: 1;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.15);
  padding: 10px 12px;
  border-radius: 60px;
  font-size: 14px;
  font-weight: 700;
  color: white;
  cursor: pointer;
  transition: 0.1s;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-outline svg {
  width: 16px;
  height: 16px;
}

.btn-outline:active {
  transform: scale(0.97);
  background: rgba(255,255,255,0.1);
}

/* Traffic Card */
.traffic-card {
  padding: 22px 20px;
  margin-bottom: 20px;
  background: rgba(30, 45, 85, 0.7);
  border-left: none;
}

.traffic-header {
  display: flex;
  justify-content: space-between;
  font-size: 17px;
  font-weight: 800;
  margin-bottom: 16px;
}

.traffic-bar {
  height: 8px;
  background: rgba(255,255,255,0.1);
  border-radius: 12px;
  overflow: hidden;
  margin: 12px 0;
}

.traffic-bar__fill {
  height: 100%;
  background: linear-gradient(90deg, #3a6bc5, #5b8cff);
  border-radius: 12px;
  width: 0%;
  transition: width 0.4s;
}

.traffic-bar__fill--warn {
  background: linear-gradient(90deg, #ED6A0D, #ff8c3a);
}

.traffic-stats {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
}

.traffic-warning {
  background: rgba(255,90,95,0.12);
  border: 1px solid rgba(255,90,95,0.3);
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Buttons row */
.button-row {
  display: flex;
  gap: 12px;
  margin: 20px 0 14px;
}

.btn-primary {
  flex: 1;
  background: var(--brand-orange);
  border: none;
  padding: 10px 12px;
  border-radius: 60px;
  font-weight: 800;
  font-size: 14px;
  color: white;
  cursor: pointer;
}

.btn-secondary-outline {
  flex: 1;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.15);
  padding: 10px 12px;
  border-radius: 60px;
  font-weight: 700;
  font-size: 14px;
  color: white;
  cursor: pointer;
}

.description-text {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  line-height: 1.45;
  margin: 14px 0 6px;
  padding: 12px;
  background: rgba(0,0,0,0.2);
  border-radius: 16px;
}

/* Auto-renew checkbox */
.auto-renew {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0 8px;
  padding: 8px 0;
}

.auto-renew input {
  width: 20px;
  height: 20px;
  accent-color: var(--brand-orange);
  cursor: pointer;
}

.auto-renew label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}

/* Servers card */
.servers-card {
  padding: 20px;
  margin-bottom: 20px;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 10px;
}

.section-header h2 {
  font-size: 19px;
  font-weight: 800;
}

.badge-reality {
  font-size: 11px;
  background: rgba(255,255,255,0.08);
  padding: 4px 10px;
  border-radius: 30px;
  color: var(--text-muted);
}

.server-list {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.server-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.server-item:last-child {
  border-bottom: none;
}

.server-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.server-icon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
}

.server-name {
  font-size: 16px;
  font-weight: 600;
}

.server-badge {
  padding: 5px 12px;
  border-radius: 40px;
  font-size: 12px;
  font-weight: 700;
}

.server-badge.unlimited {
  background: rgba(46, 229, 160, 0.12);
  color: var(--green-accent);
}

.server-badge.traffic-limit {
  background: rgba(237, 106, 13, 0.12);
  color: var(--brand-orange);
}

/* Referral Banner */
.referral-banner-card {
  position: relative;
  border-radius: var(--radius-lg);
  margin-bottom: 20px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.2s;
}

.referral-banner-card:active {
  transform: scale(0.98);
}

.banner-bg-img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  z-index: 0;
}

.banner-content-overlay {
  position: relative;
  z-index: 1;
  padding: 24px 20px;
  background: linear-gradient(135deg, rgba(0,0,0,0.3), rgba(0,0,0,0.1));
}

.banner-title {
  font-size: 26px;
  font-weight: 900;
  color: white;
  margin-bottom: 8px;
  text-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

.banner-subtitle {
  font-size: 14px;
  font-weight: 600;
  color: rgba(255,255,255,0.9);
  margin-bottom: 12px;
}

.banner-small {
  font-size: 12px;
  font-weight: 500;
  color: rgba(255,255,255,0.7);
  margin-bottom: 16px;
}

.banner-btn {
  background: var(--brand-orange);
  border: none;
  padding: 10px 24px;
  border-radius: 60px;
  font-weight: 800;
  font-size: 14px;
  color: white;
  cursor: pointer;
  display: inline-block;
}

/* Bottom Nav */
.bottom-nav {
  display: flex;
  background: rgba(30, 45, 85, 0.5);
  backdrop-filter: blur(20px);
  border-top: 1px solid rgba(255,255,255,0.1);
  padding: 8px 16px 18px;
  flex-shrink: 0;
  position: relative;
  z-index: 10;
}

.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  padding: 8px;
  border-radius: 40px;
  cursor: pointer;
}

.nav-btn svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  stroke-width: 1.8;
  fill: none;
}

.nav-btn.active {
  color: var(--brand-orange);
  background: rgba(237,106,13,0.1);
}

/* ===== МОДАЛКИ ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.8);
  backdrop-filter: blur(8px);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: 0.2s;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: rgba(18, 28, 48, 0.98);
  backdrop-filter: blur(20px);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  width: 100%;
  max-width: 520px;
  padding: 24px 20px 32px;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.2, 0.9, 0.4, 1.1);
  border-top: 1px solid rgba(255,255,255,0.1);
}

/* ===== ЗАГОЛОВКИ МОДАЛОК — ЧИСТЫЙ ОРАНЖЕВЫЙ ===== */
.modal__title {
  font-size: 20px;
  font-weight: 800;
  margin-bottom: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--brand-orange) !important;
  background: none !important;
  -webkit-background-clip: unset !important;
  padding-left: 4px;
  margin-left: 0;
}

.modal__title svg {
  stroke: var(--brand-orange) !important;
  margin-right: 8px;
}

.modal__close {
  font-size: 26px;
  cursor: pointer;
  color: var(--text-muted) !important;
  background: none !important;
  border: none !important;
  padding: 0;
  line-height: 1;
}

.modal__close:hover {
  color: var(--brand-orange) !important;
}

/* ===== ЗАГОЛОВКИ СТРАНИЦ — ЧИСТЫЙ ОРАНЖЕВЫЙ ===== */
.page-title {
  font-size: 26px;
  font-weight: 800;
  color: var(--brand-orange) !important;
  background: none !important;
  -webkit-background-clip: unset !important;
  padding-left: 4px;
  margin-left: 0;
  margin-bottom: 8px;
}

.page-title span {
  color: var(--brand-orange);
}

/* Заголовки в модалках без градиента */
.modal .page-title,
.modal h2,
.modal h3 {
  background: none !important;
  -webkit-background-clip: unset !important;
  color: var(--brand-orange) !important;
}

/* Подзаголовки */
.muted.caption {
  margin-bottom: 20px;
  padding-left: 4px;
}

.muted {
  color: var(--text-muted);
}

.accent {
  color: var(--brand-orange);
  font-weight: 800;
}

/* Инструкция в модалке */
.instruction-text {
  font-size: 13px;
  font-weight: 500;
  line-height: 1.55;
  background: rgba(0,0,0,0.3);
  padding: 14px;
  border-radius: 14px;
  margin-top: 14px;
}

.device-select-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 12px;
  padding-left: 4px;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%) translateY(120px);
  background: rgba(0,0,0,0.95);
  backdrop-filter: blur(16px);
  padding: 12px 24px;
  border-radius: 60px;
  color: var(--brand-orange);
  font-weight: 700;
  font-size: 14px;
  z-index: 1000;
  transition: 0.2s;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}

/* Loading screen */
.loading-screen {
  position: fixed;
  inset: 0;
  background: linear-gradient(145deg, #1e2d55, #050811);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  z-index: 1000;
}

.loading-logo {
  width: 80px;
  height: 80px;
  filter: drop-shadow(0 0 20px rgba(36,68,143,0.5));
}

.spinner {
  width: 32px;
  height: 32px;
  border: 2px solid rgba(255,255,255,0.1);
  border-top: 2px solid var(--brand-orange);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Tiers grid */
.tiers-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 18px 0;
}

.tier-card {
  background: rgba(0,0,0,0.3);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px;
  padding: 14px 6px;
  text-align: center;
  cursor: pointer;
  transition: 0.1s;
}

.tier-card.selected {
  border-color: var(--brand-orange);
  background: rgba(237,106,13,0.15);
}

.tier-card__price {
  font-size: 20px;
  font-weight: 800;
  color: var(--brand-orange);
}

.tier-card__gb {
  font-size: 14px;
  font-weight: 700;
  margin: 4px 0;
}

.tier-card__per {
  font-size: 11px;
  color: var(--text-muted);
}

/* Device list in modal */
.device-list-modal {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
  max-height: 250px;
  overflow-y: auto;
}

.device-option {
  background: rgba(255,255,255,0.05);
  padding: 12px;
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  font-weight: 600;
}

.device-type-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 10px 0;
}

.type-btn {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  padding: 12px;
  border-radius: 60px;
  color: white;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.empty-state {
  text-align: center;
  padding: 48px 20px;
}

/* Page header */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-left: 4px;
}

.btn-add {
  background: var(--brand-orange);
  border: none;
  padding: 8px 18px;
  border-radius: 40px;
  font-weight: 700;
  color: white;
  font-size: 13px;
  cursor: pointer;
}

/* Packages grid */
.packages-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 16px 0;
}

.pkg-btn {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  padding: 10px;
  text-align: center;
  font-weight: 700;
  cursor: pointer;
  color: white;
  font-size: 14px;
}

.pkg-btn.selected {
  background: var(--brand-orange);
  color: white;
  border-color: var(--brand-orange);
}

.input-wrap {
  margin: 12px 0;
}

.input-wrap label {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 5px;
  display: block;
}

.input-wrap input {
  width: 100%;
  background: rgba(0,0,0,0.3);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px;
  padding: 12px;
  color: white;
  font-size: 15px;
}

/* Ref card */
.ref-card {
  padding: 18px;
  margin-top: 8px;
}

.ref-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.ref-code-box {
  background: rgba(0,0,0,0.3);
  padding: 12px;
  border-radius: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 6px 0;
  cursor: pointer;
  font-family: monospace;
  font-size: 13px;
}

.stat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
}

/* Device card */
.device-card {
  margin-bottom: 12px;
  padding: 16px;
  cursor: pointer;
}

.device-card__top {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.device-card__icon {
  font-size: 28px;
}

.device-card__name {
  font-weight: 700;
  font-size: 16px;
}

.device-card__type {
  font-size: 12px;
  color: var(--text-muted);
}

.device-card__status {
  margin-left: auto;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 20px;
}

.status--active {
  background: rgba(46, 229, 160, 0.15);
  color: var(--green-accent);
}

.status--inactive {
  background: rgba(255, 90, 95, 0.15);
  color: var(--red-accent);
}

.traffic-wrap {
  margin-top: 8px;
}

.traffic-label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  margin-bottom: 6px;
}

.traffic-none {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.url-box {
  background: rgba(0,0,0,0.4);
  padding: 10px;
  border-radius: 10px;
  font-size: 11px;
  word-break: break-all;
  cursor: pointer;
  margin-top: 8px;
}

.divider {
  height: 1px;
  background: rgba(255,255,255,0.08);
  margin: 12px 0;
}

.btn-row {
  display: flex;
  gap: 10px;
}

.btn-danger {
  background: rgba(255, 90, 95, 0.15);
  border: 1px solid rgba(255, 90, 95, 0.3);
  padding: 10px 12px;
  border-radius: 60px;
  font-weight: 700;
  font-size: 14px;
  color: var(--red-accent);
  cursor: pointer;
}