/* ==========================================================================
   Принудительная тёмная тема.
   ВАЖНО: намеренно НЕ используем --tg-theme-* переменные для фона —
   именно из-за них приложение белело у пользователей со светлой темой Telegram.
   ========================================================================== */
:root {
  --bg: #0b0d14;
  --bg-soft: #12141f;
  --card: #161927;
  --card-hover: #1b1f30;
  --border: #262b40;
  --text: #f2f3f8;
  --hint: #8b91a8;
  --accent: #6d8bff;
  --accent-2: #9b6dff;
  --green: #35d07f;
  --yellow: #ffb020;
  --red: #ff5c6c;
  --gradient-main: linear-gradient(135deg, #6d8bff 0%, #9b6dff 60%, #c86dff 100%);
  --gradient-card: linear-gradient(160deg, rgba(109,139,255,0.12) 0%, rgba(155,109,255,0.06) 50%, transparent 100%);
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg) !important;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* --- Декоративные размытые пятна на фоне ("плавные линии/краски") --- */
.bg-decor { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.blob { position: absolute; border-radius: 50%; filter: blur(90px); opacity: 0.35; }
.blob-1 { width: 340px; height: 340px; background: #4a5fd9; top: -120px; left: -100px; }
.blob-2 { width: 300px; height: 300px; background: #7b3fd4; top: 30%; right: -140px; opacity: 0.25; }
.blob-3 { width: 280px; height: 280px; background: #2b8cff; bottom: -100px; left: 20%; opacity: 0.18; }

#app { position: relative; z-index: 1; padding: 14px 16px 40px; max-width: 560px; margin: 0 auto; }

/* --- Карточка баланса --- */
.balance-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--gradient-main);
  border-radius: 22px;
  padding: 20px 22px;
  margin-bottom: 16px;
  box-shadow: 0 10px 34px rgba(109,139,255,0.35);
  position: relative;
  overflow: hidden;
}
.balance-card::after {
  content: "";
  position: absolute;
  width: 180px; height: 180px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  top: -70px; right: -40px;
}
.balance-label { color: rgba(255,255,255,0.75); font-size: 13px; font-weight: 500; }
.balance-value { font-size: 30px; font-weight: 800; color: #fff; margin-top: 3px; letter-spacing: -0.5px; }

/* --- Кнопки --- */
.btn {
  border: none;
  border-radius: 14px;
  padding: 11px 18px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.12s ease, opacity 0.15s ease, box-shadow 0.15s ease;
}
.btn:active { transform: scale(0.96); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-glow {
  background: rgba(255,255,255,0.92);
  color: #3d2f8f;
  box-shadow: 0 4px 18px rgba(0,0,0,0.25);
  position: relative;
  z-index: 1;
}
.btn-primary {
  background: var(--gradient-main);
  color: #fff;
  box-shadow: 0 6px 20px rgba(109,139,255,0.35);
  width: 100%;
}
.btn-outline {
  background: transparent;
  color: var(--accent);
  border: 1.5px solid var(--accent);
  width: 100%;
}
.btn-secondary { background: var(--bg-soft); color: var(--text); border: 1px solid var(--border); }
.btn-timer {
  background: var(--bg-soft);
  color: var(--hint);
  border: 1px solid var(--border);
  width: 100%;
}

/* --- Вкладки --- */
.tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.tab-content { display: none; }
.tab-content.active { display: block; }
.tab {
  flex: 1;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--hint);
  border-radius: 14px;
  padding: 11px 6px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}
.tab.active {
  color: #fff;
  background: linear-gradient(135deg, rgba(109,139,255,0.25), rgba(155,109,255,0.18));
  border-color: var(--accent);
}

/* --- Категории --- */
.category-bar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 10px;
  margin-bottom: 6px;
  scrollbar-width: none;
}
.category-bar::-webkit-scrollbar { display: none; }
.cat-chip {
  flex-shrink: 0;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--hint);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}
.cat-chip.active {
  background: var(--gradient-main);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 4px 14px rgba(109,139,255,0.35);
}

/* --- Списки и карточки --- */
.list { display: flex; flex-direction: column; gap: 12px; }
#pinned-list { margin-bottom: 12px; }
#pinned-list:empty { margin-bottom: 0; }

.card {
  background: var(--card);
  background-image: var(--gradient-card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 16px;
  position: relative;
  overflow: hidden;
}
.card.pinned { border-color: rgba(109,139,255,0.55); }
.card.done-card { opacity: 0.55; filter: grayscale(0.6); }

.card-head { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 10px; }
.offer-icon {
  width: 52px; height: 52px;
  border-radius: 14px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--bg-soft);
  border: 1px solid var(--border);
}
.offer-icon-placeholder {
  width: 52px; height: 52px;
  border-radius: 14px;
  flex-shrink: 0;
  background: var(--gradient-main);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 800; color: #fff;
}
.card-head-text { flex: 1; min-width: 0; }
.card-title { font-weight: 700; font-size: 15.5px; line-height: 1.25; }
.card-reward {
  display: inline-block;
  margin-top: 5px;
  background: rgba(53,208,127,0.14);
  color: var(--green);
  font-weight: 800;
  font-size: 13.5px;
  padding: 3px 10px;
  border-radius: 999px;
}

.pin-badge {
  position: absolute;
  top: 0; right: 0;
  background: var(--gradient-main);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 0 16px 0 14px;
}

.card-desc { color: var(--hint); font-size: 13px; line-height: 1.45; margin-bottom: 6px; }
.card-conditions {
  background: var(--bg-soft);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 12.5px;
  color: var(--hint);
  line-height: 1.45;
  margin-bottom: 12px;
}
.card-conditions b { color: var(--text); }

.status-badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 11px;
  border-radius: 999px;
  margin-bottom: 10px;
}
.status-started { background: rgba(255,176,32,0.14); color: var(--yellow); }
.status-submitted { background: rgba(109,139,255,0.14); color: var(--accent); }
.status-confirmed { background: rgba(53,208,127,0.14); color: var(--green); }
.status-rejected { background: rgba(255,92,108,0.14); color: var(--red); }

.btn-row { display: flex; gap: 8px; }
.btn-row .btn { flex: 1; }

.empty { color: var(--hint); text-align: center; padding: 44px 10px; font-size: 14px; }

/* --- Способы вывода --- */
.pm-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.pm-item {
  background: var(--bg-soft);
  border: 1.5px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.pm-item.selected { border-color: var(--accent); background: rgba(109,139,255,0.1); }
.pm-item.disabled { opacity: 0.4; cursor: not-allowed; }
.pm-img { width: 34px; height: 34px; border-radius: 9px; object-fit: cover; }
.pm-img-placeholder {
  width: 34px; height: 34px; border-radius: 9px;
  background: var(--gradient-main);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 800; font-size: 15px;
}
.pm-name { font-size: 13px; font-weight: 600; line-height: 1.2; }
.pm-unavailable { font-size: 10.5px; color: var(--red); display: block; margin-top: 2px; }

/* --- Модалка --- */
.modal-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(4px);
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--card);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 24px 24px 0 0;
  padding: 14px 18px 26px;
  width: 100%;
  max-width: 560px;
  animation: slideUp 0.25s ease;
}
@keyframes slideUp { from { transform: translateY(60px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-handle { width: 44px; height: 4px; border-radius: 4px; background: var(--border); margin: 0 auto 14px; }
.modal h3 { margin: 0 0 14px; font-size: 17px; }
.modal input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1.5px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
  font-size: 14px;
  margin-bottom: 8px;
  outline: none;
}
.modal input:focus { border-color: var(--accent); }
.modal-hint { color: var(--hint); font-size: 12px; margin-bottom: 12px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 6px; }

/* --- Тост-уведомление --- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(80px);
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 18px;
  border-radius: 14px;
  font-size: 13.5px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.4);
  z-index: 100;
  opacity: 0;
  transition: all 0.25s ease;
  max-width: 88%;
  text-align: center;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }

/* --- Разворачиваемый длинный текст --- */
.read-more {
  color: var(--accent);
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  margin-left: 4px;
  white-space: nowrap;
}

/* --- Архив (истёкшие офферы) --- */
.archive-title {
  color: var(--hint);
  font-size: 12.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 18px 4px 10px;
}

/* --- Бейдж доработки --- */
.status-revision { background: rgba(255,140,50,0.16); color: #ff9a4d; }
.revision-note {
  background: rgba(255,140,50,0.1);
  border: 1px solid rgba(255,140,50,0.3);
  border-radius: 12px;
  padding: 9px 12px;
  font-size: 12.5px;
  color: #ffb98a;
  margin-bottom: 10px;
}

/* --- Счётчик выполнений --- */
.completions {
  display: inline-block;
  margin-top: 5px;
  margin-left: 6px;
  color: var(--hint);
  font-size: 12px;
  font-weight: 600;
}

/* --- Карточка ежедневного бонуса --- */
.bonus-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: linear-gradient(135deg, rgba(53,208,127,0.16), rgba(109,139,255,0.12));
  border: 1px solid rgba(53,208,127,0.35);
  border-radius: 18px;
  padding: 14px 16px;
  margin-bottom: 14px;
}
.bonus-card.waiting { border-color: var(--border); opacity: 0.85; }
.bonus-title { font-weight: 800; font-size: 14.5px; }
.bonus-sub { color: var(--hint); font-size: 12.5px; margin-top: 3px; }
.bonus-sub b { color: var(--text); font-variant-numeric: tabular-nums; }
.bonus-card .btn-glow { background: var(--green); color: #06331c; white-space: nowrap; }

/* --- Статистика --- */
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stat-card {
  background: var(--card);
  background-image: var(--gradient-card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px 16px;
  text-align: center;
}
.stat-card.wide { grid-column: 1 / -1; }
.stat-icon { font-size: 26px; margin-bottom: 8px; }
.stat-value { font-size: 24px; font-weight: 800; letter-spacing: -0.5px; }
.stat-label { color: var(--hint); font-size: 12.5px; margin-top: 4px; }

/* --- Бейдж срока действия оффера --- */
.expiry-badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  color: var(--yellow);
  background: rgba(255,176,32,0.12);
  padding: 4px 10px;
  border-radius: 999px;
  margin-bottom: 10px;
}
.expiry-badge.urgent {
  color: var(--red);
  background: rgba(255,92,108,0.14);
}

/* --- Уведомление о нехватке баланса в модалке вывода --- */
.modal-notice {
  background: rgba(255,176,32,0.1);
  border: 1px solid rgba(255,176,32,0.3);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 13px;
  color: var(--text);
  line-height: 1.5;
  margin-bottom: 14px;
}
.modal-notice b { color: var(--yellow); }

/* --- Бейдж эксклюзивного задания --- */
.exclusive-badge {
  display: inline-block;
  margin-top: 6px;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(155,109,255,0.14);
  color: var(--accent-2);
}
.exclusive-badge.unlocked {
  background: rgba(53,208,127,0.14);
  color: var(--green);
}

/* --- Карточка "Пригласи друзей" --- */
.referral-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: linear-gradient(135deg, rgba(155,109,255,0.16), rgba(109,139,255,0.1));
  border: 1px solid rgba(155,109,255,0.35);
  border-radius: 18px;
  padding: 14px 16px;
  margin-bottom: 14px;
}
.referral-title { font-weight: 800; font-size: 14.5px; }
.referral-sub { color: var(--hint); font-size: 12px; margin-top: 3px; }

/* --- Статистика внутри модалки рефералов --- */
.referral-stats-row { display: flex; gap: 10px; }
.referral-stat {
  flex: 1;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  text-align: center;
}
.referral-stat-value { font-size: 20px; font-weight: 800; }
.referral-stat-label { color: var(--hint); font-size: 11.5px; margin-top: 3px; }

/* --- Лента "последние выполнения / выводы" в статистике --- */
.feed-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 8px;
}
.feed-main { min-width: 0; }
.feed-name { font-weight: 700; font-size: 13.5px; margin-right: 6px; }
.feed-detail { color: var(--hint); font-size: 12.5px; }
.feed-side { text-align: right; flex-shrink: 0; }
.feed-reward { color: var(--green); font-weight: 800; font-size: 13.5px; }
.feed-time { color: var(--hint); font-size: 11px; margin-top: 2px; }
