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

:root {
  --primary: #5B5EA6;
  --primary-dark: #4A4D8C;
  --primary-light: #7B7EC6;
  --accent: #FF6B35;
  --success: #28a745;
  --danger: #dc3545;
  --warning: #ffc107;
  --bg: #f5f6fa;
  --card-bg: #ffffff;
  --text: #2c3e50;
  --text-light: #7f8c8d;
  --border: #e0e0e0;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --radius: 12px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

/* === LANDING PAGE === */

.landing {
  min-height: 100vh;
}

.landing-header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
  padding: 20px 0;
  position: sticky;
  top: 0;
  z-index: 100;
}

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

.logo {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.logo span {
  color: var(--accent);
}

.hero {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
  padding: 80px 0 100px;
  text-align: center;
}

.hero h1 {
  font-size: 36px;
  margin-bottom: 16px;
  font-weight: 800;
}

.hero p {
  font-size: 18px;
  opacity: 0.9;
  max-width: 600px;
  margin: 0 auto 32px;
}

.hero-features {
  display: flex;
  gap: 24px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 40px;
}

.hero-feature {
  background: rgba(255,255,255,0.15);
  padding: 20px 24px;
  border-radius: var(--radius);
  min-width: 200px;
}

.hero-feature .icon {
  font-size: 32px;
  margin-bottom: 8px;
}

.hero-feature h3 {
  font-size: 16px;
  margin-bottom: 4px;
}

.hero-feature p {
  font-size: 13px;
  opacity: 0.8;
  margin: 0;
}

.pricing-section {
  padding: 60px 0;
  text-align: center;
}

.pricing-section h2 {
  font-size: 28px;
  margin-bottom: 32px;
}

.pricing-cards {
  display: flex;
  gap: 24px;
  justify-content: center;
  flex-wrap: wrap;
}

.pricing-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: var(--shadow);
  min-width: 260px;
  max-width: 320px;
  border: 2px solid var(--border);
}

.pricing-card.featured {
  border-color: var(--primary);
  position: relative;
}

.pricing-card .badge {
  background: var(--primary);
  color: white;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
}

.pricing-card h3 {
  font-size: 20px;
  margin-bottom: 8px;
}

.pricing-card .price {
  font-size: 36px;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 16px;
}

.pricing-card .price small {
  font-size: 16px;
  font-weight: 400;
  color: var(--text-light);
}

.pricing-card ul {
  list-style: none;
  text-align: left;
  margin-bottom: 24px;
}

.pricing-card ul li {
  padding: 6px 0;
  font-size: 14px;
}

.pricing-card ul li::before {
  content: "\2713";
  color: var(--success);
  margin-right: 8px;
  font-weight: bold;
}

.login-section {
  padding: 60px 0;
  text-align: center;
  background: var(--card-bg);
}

.login-section h2 {
  font-size: 28px;
  margin-bottom: 16px;
}

.login-section p {
  color: var(--text-light);
  margin-bottom: 24px;
}

#telegram-login-container {
  display: flex;
  justify-content: center;
  padding: 20px;
}

.landing-footer {
  padding: 24px 0;
  text-align: center;
  color: var(--text-light);
  font-size: 13px;
}

/* === APP LAYOUT === */

.app {
  display: none;
  min-height: 100vh;
}

.app.active {
  display: block;
}

.app-header {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  padding: 12px 0;
  position: sticky;
  top: 0;
  z-index: 100;
}

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

.app-header .logo {
  color: var(--primary);
  font-size: 18px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary-light);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
}

.user-avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.btn-logout {
  background: none;
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-light);
}

.btn-logout:hover {
  border-color: var(--danger);
  color: var(--danger);
}

/* Navigation */

.app-nav {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}

.nav-items {
  display: flex;
  list-style: none;
  max-width: 900px;
  margin: 0 auto;
}

.nav-items li {
  flex: 1;
}

.nav-items a {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 8px;
  text-decoration: none;
  color: var(--text-light);
  font-size: 12px;
  border-bottom: 3px solid transparent;
  transition: all 0.2s;
  white-space: nowrap;
}

.nav-items a .nav-icon {
  font-size: 20px;
  margin-bottom: 2px;
}

.nav-items a:hover,
.nav-items a.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* Main content */

.app-content {
  max-width: 900px;
  margin: 0 auto;
  padding: 20px 16px;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 16px;
}

/* === COMPONENTS === */

.page {
  display: none;
}

.page.active {
  display: block;
}

.page-title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.card-title {
  font-size: 16px;
  font-weight: 600;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  text-align: center;
}

.stat-card .stat-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--primary);
}

.stat-card .stat-label {
  font-size: 12px;
  color: var(--text-light);
  margin-top: 4px;
}

/* Buttons */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

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

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

.btn-success:hover {
  background: #218838;
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-outline:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

.btn-lg {
  padding: 14px 28px;
  font-size: 16px;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Lists */

.list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
}

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

.list-item:hover {
  background: #f8f9fa;
}

.list-item-main {
  flex: 1;
}

.list-item-title {
  font-weight: 500;
  margin-bottom: 2px;
}

.list-item-subtitle {
  font-size: 13px;
  color: var(--text-light);
}

.list-item-right {
  text-align: right;
}

/* Status badges */

.badge-status {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}

.badge-processing { background: #fff3cd; color: #856404; }
.badge-delivery { background: #d1ecf1; color: #0c5460; }
.badge-delivered { background: #d4edda; color: #155724; }
.badge-cancelled { background: #f8d7da; color: #721c24; }
.badge-pickup { background: #e2e3e5; color: #383d41; }
.badge-unpaid { background: #fce4ec; color: #c62828; }
.badge-trial { background: #e8eaf6; color: #283593; }
.badge-active { background: #d4edda; color: #155724; }
.badge-expired { background: #f8d7da; color: #721c24; }

/* Forms */

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 6px;
}

.form-group input,
.form-group textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.2s;
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
}

.form-group textarea {
  min-height: 120px;
  resize: vertical;
}

.form-hint {
  font-size: 12px;
  color: var(--text-light);
  margin-top: 4px;
}

/* Modal */

.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

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

.modal {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
}

.modal-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 16px;
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 20px;
}

/* Loading */

.loading {
  text-align: center;
  padding: 40px;
  color: var(--text-light);
}

.spinner {
  display: inline-block;
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-light);
}

.empty-state .icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.empty-state p {
  font-size: 15px;
}

/* Toast */

.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 2000;
}

.toast {
  background: var(--text);
  color: white;
  padding: 12px 20px;
  border-radius: 8px;
  margin-top: 8px;
  font-size: 14px;
  animation: slideIn 0.3s ease;
  max-width: 350px;
}

.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Connect form */

.connect-form {
  max-width: 480px;
  margin: 40px auto;
}

.connect-form .step {
  display: none;
}

.connect-form .step.active {
  display: block;
}

.step-indicator {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
}

.step-dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--border);
  color: var(--text-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
}

.step-dot.active {
  background: var(--primary);
  color: white;
}

.step-dot.done {
  background: var(--success);
  color: white;
}

/* Key selection list */
.key-list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.15s;
  font-family: monospace;
  font-size: 13px;
}

.key-list-item:hover {
  border-color: var(--primary);
  background: #f0f0ff;
}

.key-list-item.selected {
  border-color: var(--primary);
  background: #e8e8ff;
}

/* Subscription banner */
.sub-banner {
  background: linear-gradient(135deg, #ff9800, #f44336);
  color: white;
  padding: 12px 20px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sub-banner.trial {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
}

.sub-banner p {
  font-size: 14px;
}

.sub-banner .btn {
  background: rgba(255,255,255,0.2);
  color: white;
  border: 1px solid rgba(255,255,255,0.4);
}

/* Pagination */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
}

.pagination button {
  padding: 6px 12px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}

.pagination button:hover {
  border-color: var(--primary);
}

.pagination button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.pagination .page-info {
  font-size: 13px;
  color: var(--text-light);
}

/* Responsive */

@media (max-width: 600px) {
  .hero h1 { font-size: 26px; }
  .hero p { font-size: 15px; }
  .hero-features { flex-direction: column; align-items: center; }
  .pricing-cards { flex-direction: column; align-items: center; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .nav-items a { font-size: 11px; padding: 10px 4px; }
  .nav-items a .nav-icon { font-size: 18px; }
  .app-content { padding: 12px 8px; }
  .sub-banner { flex-direction: column; gap: 8px; text-align: center; }
}
