:root {
  --primary-dark: #2c3e50;
  --primary-blue: #3498db;
  --primary-light-blue: #5dade2;
  --accent-blue: #85c1e9;
  --white: #ffffff;
  --gray-light: #ecf0f1;
  --gray-medium: #95a5a6;
  --success: #27ae60;
  --danger: #e74c3c;
  --warning: #f39c12;
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  --shadow-hover: 0 4px 20px rgba(0, 0, 0, 0.15);
  --border-radius: 12px;
  --border-radius-small: 8px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary-blue) 100%);
  min-height: 100vh;
  color: var(--primary-dark);
  overflow-x: hidden;
}

.container {
  max-width: 480px;
  margin: 0 auto;
  padding: 20px;
  min-height: 100vh;
}

/* Header */
.header {
  background: rgba(255, 255, 255, 0.98);
  border-radius: var(--border-radius);
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.logo-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--primary-blue), var(--primary-light-blue));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
}

.logo-text {
  font-size: 24px;
  font-weight: bold;
  color: var(--primary-dark);
}

/* Balance Card */
.balance-card {
  background: linear-gradient(135deg, var(--primary-blue), var(--primary-light-blue));
  color: white;
  border-radius: var(--border-radius);
  padding: 20px;
  margin-bottom: 15px;
  box-shadow: var(--shadow);
}

.balance-label {
  font-size: 14px;
  opacity: 0.9;
  margin-bottom: 5px;
}

.balance-amount {
  font-size: 32px;
  font-weight: bold;
  margin-bottom: 10px;
}

.balance-info {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  opacity: 0.95;
}

/* Section */
.section {
  background: white;
  border-radius: var(--border-radius);
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}

.section-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 15px;
  color: var(--primary-dark);
}

/* Devices Grid */
.devices-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 12px;
  margin-bottom: 15px;
}

.device-box {
  aspect-ratio: 1;
  border: 2px solid var(--gray-light);
  border-radius: var(--border-radius-small);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: var(--transition);
  cursor: pointer;
  background: white;
}

.device-box:hover {
  border-color: var(--primary-blue);
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}

.device-box.occupied {
  background: linear-gradient(135deg, #f8f9fa, #e9ecef);
  border-color: var(--primary-blue);
}

.device-box.add-device {
  background: var(--gray-light);
  border-style: dashed;
  border-color: var(--gray-medium);
}

.device-box.add-device:hover {
  background: #dfe6e9;
  border-color: var(--primary-blue);
}

.device-icon {
  font-size: 24px;
  margin-bottom: 5px;
}

.device-name {
  font-size: 11px;
  text-align: center;
  color: var(--primary-dark);
  max-width: 90%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.device-remove {
  position: absolute !important;
  top: 3px !important;
  right: 3px !important;
  width: 24px !important;
  height: 24px !important;
  background: var(--danger) !important;
  color: white !important;
  border-radius: 50% !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  font-size: 16px !important;
  font-weight: bold !important;
  cursor: pointer !important;
  opacity: 1 !important;
  transition: var(--transition) !important;
  z-index: 10 !important;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2) !important;
}

.device-box:hover .device-remove {
  opacity: 1;
  transform: scale(1.1);
}

.add-icon {
  font-size: 32px;
  color: var(--gray-medium);
}

/* Subscription Key */
.subscription-key {
  background: #f8f9fa;
  border-radius: var(--border-radius-small);
  padding: 15px;
  margin-bottom: 15px;
  position: relative;
}

.key-label {
  font-size: 12px;
  color: var(--gray-medium);
  margin-bottom: 8px;
}

.key-content {
  font-family: 'Courier New', monospace;
  font-size: 12px;
  word-break: break-all;
  color: var(--primary-dark);
  padding-right: 40px;
  line-height: 1.4;
}

.copy-button {
  position: absolute;
  top: 15px;
  right: 15px;
  background: var(--primary-blue);
  color: white;
  border: none;
  border-radius: var(--border-radius-small);
  padding: 8px 12px;
  cursor: pointer;
  font-size: 12px;
  transition: var(--transition);
}

.copy-button:hover {
  background: var(--primary-dark);
}

.copy-button.copied {
  background: var(--success);
}

/* Referral Earnings */
.referral-earnings {
  background: linear-gradient(135deg, var(--success), #2ecc71);
  color: white;
  border-radius: var(--border-radius);
  padding: 15px;
  margin-bottom: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow);
}

.referral-info {
  flex: 1;
}

.referral-label {
  font-size: 12px;
  opacity: 0.9;
  margin-bottom: 3px;
}

.referral-amount {
  font-size: 24px;
  font-weight: bold;
}

.referral-action {
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: white;
  padding: 10px 20px;
  border-radius: var(--border-radius-small);
  cursor: pointer;
  transition: var(--transition);
  font-size: 14px;
  font-weight: 500;
}

.referral-action:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Menu Grid */
.menu-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.menu-item {
  background: white;
  border-radius: var(--border-radius);
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: var(--shadow);
  border: 2px solid transparent;
}

.menu-item:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-hover);
  border-color: var(--primary-blue);
}

.menu-icon {
  font-size: 32px;
  margin-bottom: 10px;
  display: block;
}

.menu-text {
  font-size: 14px;
  color: var(--primary-dark);
  font-weight: 500;
}

/* Pages */
.page {
  display: none;
  animation: fadeIn 0.3s ease;
}

.page.active {
  display: block;
}

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

/* Back Button */
.back-button {
  background: white;
  border: 2px solid var(--gray-light);
  color: var(--primary-dark);
  padding: 12px 24px;
  border-radius: var(--border-radius-small);
  cursor: pointer;
  font-size: 16px;
  font-weight: 500;
  transition: var(--transition);
  margin-bottom: 20px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.back-button:hover {
  background: var(--primary-blue);
  color: white;
  border-color: var(--primary-blue);
}

/* Action Buttons */
.action-button {
  background: var(--primary-blue);
  color: white;
  border: none;
  padding: 15px 30px;
  border-radius: var(--border-radius-small);
  cursor: pointer;
  font-size: 16px;
  font-weight: 500;
  transition: var(--transition);
  width: 100%;
  margin-bottom: 12px;
}

.action-button:hover {
  background: var(--primary-dark);
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}

.action-button.secondary {
  background: white;
  color: var(--primary-dark);
  border: 2px solid var(--gray-light);
}

.action-button.secondary:hover {
  background: var(--gray-light);
}

/* Payment Methods */
.payment-methods {
  display: grid;
  gap: 12px;
}

.payment-method {
  background: white;
  border: 2px solid var(--gray-light);
  border-radius: var(--border-radius);
  padding: 20px;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 15px;
}

.payment-method:hover {
  border-color: var(--primary-blue);
  box-shadow: var(--shadow);
}

.payment-icon {
  font-size: 32px;
}

.payment-info h3 {
  font-size: 16px;
  margin-bottom: 5px;
}

.payment-info p {
  font-size: 14px;
  color: var(--gray-medium);
}

/* Platform Selection */
.platform-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.platform-item {
  background: white;
  border: 2px solid var(--gray-light);
  border-radius: var(--border-radius);
  padding: 25px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
}

.platform-item:hover {
  border-color: var(--primary-blue);
  transform: translateY(-3px);
  box-shadow: var(--shadow-hover);
}

.platform-icon {
  font-size: 40px;
  margin-bottom: 10px;
}

.platform-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--primary-dark);
}

/* Info Cards */
.info-card {
  background: white;
  border-radius: var(--border-radius);
  padding: 20px;
  margin-bottom: 15px;
  box-shadow: var(--shadow);
}

.info-card h3 {
  color: var(--primary-dark);
  margin-bottom: 10px;
  font-size: 16px;
}

.info-card p {
  color: var(--gray-medium);
  line-height: 1.6;
  font-size: 14px;
}

.feature-list {
  list-style: none;
  padding: 0;
}

.feature-list li {
  padding: 12px 0;
  border-bottom: 1px solid var(--gray-light);
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
}

.feature-list li:last-child {
  border-bottom: none;
}

.feature-icon {
  color: var(--primary-blue);
  font-size: 20px;
}

/* Referral Stats */
.referral-stats {
  background: white;
  border-radius: var(--border-radius);
  padding: 20px;
  margin-bottom: 20px;
}

.stat-item {
  display: flex;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--gray-light);
}

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

.stat-label {
  color: var(--gray-medium);
  font-size: 14px;
}

.stat-value {
  font-weight: 600;
  color: var(--primary-dark);
  font-size: 14px;
}

.referral-link-box {
  background: #f8f9fa;
  border-radius: var(--border-radius-small);
  padding: 15px;
  margin-bottom: 20px;
  position: relative;
}

.referral-link {
  font-size: 12px;
  word-break: break-all;
  color: var(--primary-dark);
  padding-right: 80px;
  line-height: 1.4;
}

/* Responsive */
@media (max-width: 400px) {
  .container {
    padding: 15px;
  }
  .devices-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  .balance-amount {
    font-size: 28px;
  }
  .device-remove {
    width: 28px !important;
    height: 28px !important;
    font-size: 18px !important;
    top: 2px !important;
    right: 2px !important;
  }
}

/* Loading Spinner */
.spinner {
  border: 3px solid var(--gray-light);
  border-top: 3px solid var(--primary-blue);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
  margin: 20px auto;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* Toast Notification */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--primary-dark);
  color: white;
  padding: 15px 25px;
  border-radius: var(--border-radius-small);
  box-shadow: var(--shadow-hover);
  opacity: 0;
  transition: var(--transition);
  z-index: 1000;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* Toast types */
.toast.error {
  background: var(--danger);
  color: white;
}

.toast.success {
  background: var(--success);
  color: white;
}

.toast.warning {
  background: var(--warning);
  color: white;
}

.toast.info {
  background: var(--primary-dark);
  color: white;
}

/* Modal (generic) */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 20px;
}

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

.modal {
  background: white;
  border-radius: var(--border-radius);
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-hover);
  padding: 20px;
}

.modal h3 {
  margin-bottom: 10px;
}

.modal .modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

/* Referral transactions list */
.referral-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--gray-light);
  cursor: pointer;
}

.referral-item:last-child {
  border-bottom: none;
}
.referral-user {
  font-weight: 500;
  color: var(--primary-dark);
}
.referral-amount {
  color: var(--primary-dark);
}

/* Loading states */
.loading-skeleton {
  background: linear-gradient(90deg, #e0e0e0 25%, #f0f0f0 50%, #e0e0e0 75%);
  background-size: 200% 100%;
  animation: loading-shimmer 1.5s infinite;
  border-radius: 4px;
  color: transparent;
  display: inline-block;
  min-width: 80px;
  height: 1em;
}

@keyframes loading-shimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

/* Hide loading skeleton when content is loaded */
.content-loaded .loading-skeleton {
  display: none;
}

/* Withdraw modal button hover effects */
#cancelWithdraw:hover {
  background: #f8f9fa !important;
  border-color: #adb5bd !important;
}

#confirmWithdraw:hover:not(:disabled) {
  background: #218838 !important;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(40, 167, 69, 0.3);
}

#confirmWithdraw:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

/* Loading Overlay */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.loading-overlay.show {
  display: flex;
}


