/* RajBot Mini App — стили (изумрудный стиль) */
:root {
  --bg: #0a0f14;
  --card: #111827;
  --card-hover: #1a2332;
  --border: #1f2937;
  --text: #e5e7eb;
  --muted: #6b7280;
  --primary: #10b981;
  --primary-dark: #059669;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { overflow-x: hidden; width: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* Полноэкранный контейнер приложения (Telegram Mini App) */
.app {
  position: relative;
  width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  overflow-x: hidden;
}

/* Background effects */
.bg-glow {
  position: absolute;
  top: -120px;
  left: 0;
  right: 0;
  height: 400px;
  background: radial-gradient(circle at 50% 0%, #10b98115 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}
.bg-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(#10b98108 1px, transparent 1px),
    linear-gradient(90deg, #10b98108 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
  z-index: 0;
}

.content {
  position: relative;
  z-index: 1;
  flex: 1;
  padding: 16px;
  overflow-y: auto;
}

.tab-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 8px;
  position: relative;
  z-index: 1;
}
.tab-header h2 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.tab-header .header-action {
  font-size: 12px;
  color: var(--muted);
  background: transparent;
  border: none;
  cursor: pointer;
}

/* Status / balance card */
.balance-card {
  background: linear-gradient(135deg, var(--card), #0d1520);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 24px;
  margin-bottom: 12px;
  position: relative;
  overflow: hidden;
}
.balance-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 100% 0%, #10b98115 0%, transparent 50%);
  pointer-events: none;
}
.balance-label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}
.balance-amount {
  font-size: 38px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #fff;
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.balance-currency {
  font-size: 16px;
  color: var(--muted);
  font-weight: 500;
}

/* Buttons */
.btn-primary-new {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 14px 16px;
  border-radius: 14px;
  border: none;
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  margin-bottom: 8px;
}
.btn-primary-new:active { opacity: 0.8; }

.btn-outline-new {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 16px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: transparent;
  color: #d1d5db;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  margin-bottom: 8px;
}
.btn-outline-new:active { opacity: 0.8; }

.btn-icon { font-size: 16px; }
.btn-price { margin-left: auto; font-size: 14px; opacity: 0.9; font-weight: 600; }

.btn-row {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}
.btn-small {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: transparent;
  color: #d1d5db;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}
.btn-small:active { opacity: 0.8; }
.btn-small.primary {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  color: #fff;
  border-color: transparent;
}

/* Card */
.card {
  background: var(--card);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 12px;
  border: 1px solid transparent;
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.card-title { font-size: 14px; font-weight: 600; color: #d1d5db; }
.card-link {
  font-size: 12px;
  color: var(--primary);
  text-decoration: none;
  background: none;
  border: none;
  cursor: pointer;
  font-weight: 500;
}

/* History rows */
.tx-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.tx-row:last-child { border-bottom: none; }
.tx-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.tx-icon.income { background: #10b98120; color: var(--primary); }
.tx-icon.outcome { background: #ef444420; color: var(--danger); }
.tx-icon.sub { background: #3b82f620; color: #60a5fa; }
.tx-main { flex: 1; min-width: 0; }
.tx-title { font-size: 14px; font-weight: 500; color: #d1d5db; }
.tx-date { font-size: 11px; color: var(--muted); margin-top: 2px; }
.tx-amount {
  font-size: 14px;
  font-weight: 600;
  flex-shrink: 0;
}
.tx-amount.income { color: var(--primary); }
.tx-amount.outcome { color: #d1d5db; }

/* Tariff cards */
.tariff-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 6px;
}
.tariff-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  transition: all 0.2s;
}
.tariff-item:active { background: var(--card-hover); }
.tariff-item.has-balance {
  border-color: #10b98140;
  background: linear-gradient(135deg, var(--card), #10b9810a);
}
.tariff-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: #10b98115;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}
.tariff-icon.team { background: #3b82f620; }
.tariff-info { flex: 1; min-width: 0; }
.tariff-name { font-size: 16px; font-weight: 700; color: #fff; letter-spacing: -0.01em; }
.tariff-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 6px;
  gap: 10px;
}
.tariff-price { font-size: 13px; color: var(--muted); }
.tariff-status {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.tariff-status.ok {
  background: #10b98115;
  color: var(--primary);
  border: 1px solid #10b98140;
}
.tariff-status.lack {
  background: #f59e0b15;
  color: var(--warning);
  border: 1px solid #f59e0b40;
}

/* Top balance pill on payment screen */
.balance-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  margin-bottom: 16px;
}
.balance-pill-icon {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: #10b98115;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}
.balance-pill-info { flex: 1; }
.balance-pill-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.balance-pill-value { font-size: 16px; font-weight: 700; color: #fff; }

/* Tab bar */
.tab-bar {
  display: flex;
  background: var(--card);
  border-top: 1px solid var(--border);
  padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
  position: relative;
  z-index: 2;
}
.tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px 4px;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 10px;
  font-weight: 500;
}
.tab-item.active { color: var(--primary); }
.tab-item-icon { font-size: 20px; }

/* Deposit screen specifics */
.deposit-address {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  font-family: 'SF Mono', Menlo, monospace;
  font-size: 13px;
  word-break: break-all;
  color: #d1d5db;
  text-align: center;
  margin-bottom: 10px;
  line-height: 1.5;
}
.qr-wrap {
  background: #fff;
  border-radius: 16px;
  padding: 16px;
  margin: 16px auto;
  width: fit-content;
}
.timer-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: #f59e0b15;
  color: var(--warning);
  border: 1px solid #f59e0b40;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
}
.info-list {
  list-style: none;
  padding: 0;
  margin: 16px 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.info-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: #d1d5db;
}
.info-list li .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--primary);
  flex-shrink: 0;
}

.section-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 18px 4px 10px;
  font-weight: 600;
}

/* Payment confirmation modal-like card */
.confirm-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
  margin-bottom: 12px;
}
.confirm-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  font-size: 14px;
}
.confirm-row .label { color: var(--muted); }
.confirm-row .value { font-weight: 600; color: #fff; }
.confirm-row.total {
  border-top: 1px solid var(--border);
  margin-top: 6px;
  padding-top: 14px;
  font-size: 16px;
}
.confirm-row.total .value { color: var(--primary); font-size: 20px; }

/* Status hero — щит с кольцами (как в реальном приложении) */
.status-hero {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 200px;
  margin: 6px 0 4px;
  overflow: hidden;
}
.status-hero .rings {
  position: absolute;
  width: 100%;
  height: 100%;
  max-width: 280px;
  max-height: 280px;
}
.status-hero .ring {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border-radius: 50%;
  border: 1px solid var(--primary);
  opacity: 0;
  animation: ripple 8s linear infinite;
}
.status-hero .ring:nth-child(1) { animation-delay: 0s; }
.status-hero .ring:nth-child(2) { animation-delay: 2s; }
.status-hero .ring:nth-child(3) { animation-delay: 4s; }
.status-hero .ring:nth-child(4) { animation-delay: 6s; }
@keyframes ripple {
  0% { width: 20px; height: 20px; margin: -10px 0 0 -10px; opacity: 0; }
  25% { width: 80px; height: 80px; margin: -40px 0 0 -40px; opacity: 0; }
  30% { opacity: 0.5; }
  100% { width: 240px; height: 240px; margin: -120px 0 0 -120px; opacity: 0; }
}
.status-hero .logo-icon {
  position: relative;
  z-index: 2;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: #10b98110;
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: 0 0 40px #10b98120;
}

/* Status user-card (тип, дата, прогресс) */
.user-status-card {
  background: linear-gradient(135deg, var(--card), #0d1520);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 12px;
}
.user-status-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}
.user-name {
  font-size: 22px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.02em;
  margin-bottom: 2px;
}
.status-badge-text {
  font-size: 13px;
  font-weight: 500;
}
.status-badge-text.active { color: var(--primary); }
.status-badge-text.inactive { color: var(--warning); }
.status-right { text-align: right; }
.date-label {
  font-size: 14px;
  color: #d1d5db;
  font-weight: 500;
  margin-bottom: 4px;
}
.type-badge-pill {
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 20px;
  border: 1px solid;
  display: inline-block;
  font-weight: 500;
}
.type-badge-pill.individual {
  color: var(--primary);
  border-color: #10b98140;
}
.type-badge-pill.team {
  color: #60a5fa;
  border-color: #3b82f640;
}
.progress-container { margin-top: 16px; }
.progress-bg {
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 2px;
  background: linear-gradient(90deg, #10b981, #059669);
  transition: width 0.8s ease;
}
.progress-label {
  font-size: 11px;
  color: var(--muted);
  margin-top: 6px;
  text-align: right;
}

/* Большой блок статуса подписки (как balance-card, с кнопкой внутри) */
.sub-status-card {
  background: linear-gradient(135deg, var(--card), #0d1520);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 22px;
  margin-bottom: 12px;
  position: relative;
  overflow: hidden;
}
.sub-status-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 100% 0%, #10b98115 0%, transparent 50%);
  pointer-events: none;
}
.sub-status-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  position: relative;
  z-index: 1;
}
.sub-status-label {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.01em;
}
.sub-status-label.active { color: var(--primary); }
.sub-status-label.inactive { color: var(--warning); }
.sub-status-date {
  font-size: 13px;
  color: var(--muted);
  margin-top: 4px;
}
.sub-status-card .progress-bg { margin-top: 18px; position: relative; z-index: 1; }
.sub-status-card .btn-primary-new { margin-top: 18px; margin-bottom: 0; position: relative; z-index: 1; }

/* Компактные строки тарифов (стиль как история операций) */
.tariff-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.tariff-row:active { opacity: 0.7; }
.tariff-row:last-child { border-bottom: none; }
.tariff-row-left { display: flex; flex-direction: column; gap: 2px; }
.tariff-row-name { font-size: 14px; color: #d1d5db; font-weight: 500; }
.tariff-row-note { font-size: 11px; color: var(--muted); }
.tariff-row-right { display: flex; align-items: center; gap: 8px; }
.tariff-row-price {
  font-size: 16px;
  font-weight: 700;
  color: var(--primary);
}
.tariff-row-arrow { color: var(--muted); font-size: 16px; }

/* Подсказка под тарифами (смена типа через поддержку) */
.tariffs-hint {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
  text-align: center;
  padding: 14px 12px 4px;
}
.tariffs-hint b { color: #d1d5db; font-weight: 600; }
.tariffs-hint a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}
.tariffs-hint a:active { opacity: 0.7; }

/* FAQ */
.faq-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 10px;
}
.faq-q {
  font-size: 14px;
  font-weight: 600;
  color: #d1d5db;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.faq-q .chevron {
  color: var(--muted);
  font-size: 18px;
  flex-shrink: 0;
}
.faq-a {
  font-size: 13px;
  color: var(--muted);
  margin-top: 8px;
  line-height: 1.55;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
}
.empty-state-icon { font-size: 48px; margin-bottom: 10px; }
.empty-state-text { font-size: 14px; }

/* Input */
.input-block {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 12px;
}
.input-label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.input-field {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 15px;
  margin-bottom: 12px;
  outline: none;
}
.input-field:focus { border-color: var(--primary); }
.input-field::placeholder { color: var(--muted); }

/* Result row (для проверки) */
.result-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
}
.result-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.result-row:last-child { border-bottom: none; }
.result-label { color: var(--muted); }
.result-value { font-weight: 500; color: #fff; }

/* Контейнер активной вьюхи (app.js рендерит сюда tab-header + content) */
/* padding-top — фоллбэк под вырез устройства; точный отступ под хедер Telegram
   ставит telegram.js через contentSafeAreaInset (см. applySafeArea) */
#view-root {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding-top: env(safe-area-inset-top, 0px);
}
#view-root .content { overflow-y: auto; }

/* Состояния загрузки/ошибки (полноэкранные) */
.fullscreen-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 24px;
  gap: 12px;
}
.fullscreen-state .ic { font-size: 48px; }
.fullscreen-state .title { font-size: 18px; font-weight: 600; }
.fullscreen-state .desc { font-size: 14px; color: var(--muted); }

/* Спиннер */
.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Toast */
.toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 24px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  z-index: 1000;
  max-width: 80%;
  text-align: center;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  animation: toastIn 0.2s;
}
.toast.success { background: var(--primary); color: #fff; border-color: transparent; }
.toast.error { background: var(--danger); color: #fff; border-color: transparent; }
@keyframes toastIn { from { opacity: 0; transform: translateX(-50%) translateY(10px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }

/* ============ Команда ============ */
/* Карточка-шапка (корона + лидер + счётчик + прогресс) */
.team-summary {
  background: linear-gradient(135deg, var(--card), #0d1520);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 12px;
}
.team-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.team-crown {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #3b82f620;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}
.team-head-info { flex: 1; min-width: 0; }
.team-leader-name { font-size: 16px; font-weight: 600; color: #fff; }
.team-leader-role { font-size: 13px; color: var(--muted); }
.team-count { text-align: right; flex-shrink: 0; }
.team-count-num { font-size: 20px; font-weight: 700; color: var(--primary); }
.team-count-num span { font-size: 14px; color: var(--muted); font-weight: 500; }
.team-count-label { font-size: 11px; color: var(--muted); }
.team-summary .progress-fill { background: linear-gradient(90deg, #3b82f6, #10b981); }
.team-foot {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  font-size: 12px;
}
.team-foot .left { color: var(--success); }
.team-foot .right { color: var(--muted); }

/* Заголовок секции внутри карточки (Активные / Ожидают) */
.team-card-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.team-card-title.active span.ic { color: var(--success); }
.team-card-title.pending { color: var(--warning); }
.card.pending { border: 1px solid #f59e0b40; }

/* Строка участника */
.member-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.member-row:last-child { border-bottom: none; }
.member-num {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: var(--muted);
  flex-shrink: 0;
}
.member-num.pending { background: #f59e0b20; color: var(--warning); }
.member-name-row { flex: 1; font-size: 14px; }
.member-name-row.pending { color: var(--warning); }
.member-remove {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: none;
  background: #ef444415;
  color: var(--danger);
  font-size: 14px;
  cursor: pointer;
  flex-shrink: 0;
}
.member-remove:active { opacity: 0.7; }
