/* ── Переменные ── */
:root {
  --bg: var(--tg-theme-bg-color, #f4f6fb);
  --bg-card: var(--tg-theme-secondary-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #1a1a2e);
  --hint: var(--tg-theme-hint-color, #8a8a9a);
  --link: var(--tg-theme-link-color, #4361ee);
  --btn: var(--tg-theme-button-color, #4361ee);
  --btn-text: var(--tg-theme-button-text-color, #ffffff);
  --accent: #4361ee;
  --accent2: #7209b7;
  --green: #2dc653;
  --red: #ef233c;
  --shadow: 0 4px 24px rgba(67, 97, 238, 0.10);
  --radius: 16px;
  --radius-sm: 10px;
}

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

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

/* ── Шапка ── */
.header {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent2) 100%);
  padding: 20px 16px 16px;
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-inner { max-width: 600px; margin: 0 auto; }
.logo { display: flex; align-items: center; gap: 10px; margin-bottom: 2px; }
.logo-icon { font-size: 26px; }
.logo-text { font-size: 20px; font-weight: 700; letter-spacing: -0.3px; }
.header-sub { font-size: 12px; opacity: 0.85; margin-left: 36px; }

/* ── Вкладки ── */
.tabs {
  display: flex;
  gap: 8px;
  padding: 12px 16px 0;
  overflow-x: auto;
  scrollbar-width: none;
  background: var(--bg);
  position: sticky;
  top: 73px;
  z-index: 90;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  white-space: nowrap;
  padding: 7px 16px;
  border-radius: 20px;
  border: 2px solid transparent;
  background: var(--bg-card);
  color: var(--hint);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}
.tab:hover { border-color: var(--accent); color: var(--accent); }
.tab.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* ── Поиск ── */
.search-wrap {
  padding: 10px 16px 4px;
  background: var(--bg);
  position: sticky;
  top: 117px;
  z-index: 89;
}
.search {
  width: 100%;
  padding: 10px 16px;
  border-radius: 12px;
  border: 1.5px solid transparent;
  background: var(--bg-card);
  color: var(--text);
  font-size: 14px;
  outline: none;
  box-shadow: var(--shadow);
  transition: border-color 0.2s;
}
.search:focus { border-color: var(--accent); }
.search::placeholder { color: var(--hint); }

/* ── Main ── */
.main { padding: 12px 16px 100px; max-width: 600px; margin: 0 auto; }

/* ── Группа банка ── */
.bank-group { margin-bottom: 24px; }
.bank-group-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 10px;
  padding: 0 4px;
}
.bank-badge {
  display: inline-block;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  border-radius: 8px;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

/* ── Карточка предложения ── */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  border: 1.5px solid transparent;
  position: relative;
  overflow: hidden;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 8px 32px rgba(67,97,238,0.15); }
.card:active { transform: translateY(0); }
.card.credit { border-left: 4px solid var(--accent); }
.card.debit  { border-left: 4px solid var(--green); }

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.card-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}
.card-type-badge {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 20px;
}
.card-type-badge.credit { background: #edf0ff; color: var(--accent); }
.card-type-badge.debit  { background: #e8faf0; color: var(--green); }

.card-bank-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 4px;
  letter-spacing: 0.2px;
}

.card-desc {
  font-size: 13px;
  color: var(--hint);
  margin-bottom: 10px;
  line-height: 1.4;
}

.card-benefits {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}
.benefit-chip {
  font-size: 12px;
  padding: 4px 10px;
  background: var(--bg);
  border-radius: 20px;
  color: var(--text);
  white-space: nowrap;
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.card-commission {
  font-size: 12px;
  color: var(--hint);
}
.card-btn {
  padding: 8px 18px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: opacity 0.2s;
}
.card-btn:hover { opacity: 0.9; }

/* ── Модалка ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }

.modal {
  background: var(--bg-card);
  border-radius: 24px 24px 0 0;
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  padding: 24px 20px 40px;
  position: relative;
  transform: translateY(40px);
  transition: transform 0.25s;
  max-height: 85vh;
  overflow-y: auto;
}
.modal-overlay.open .modal { transform: translateY(0); }

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: var(--bg);
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  font-size: 16px;
  cursor: pointer;
  color: var(--hint);
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-bank-name { font-size: 13px; color: var(--hint); margin-bottom: 4px; }
.modal-card-name { font-size: 22px; font-weight: 800; color: var(--text); margin-bottom: 6px; line-height: 1.2; }
.modal-type-row { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; }
.modal-desc { font-size: 14px; color: var(--hint); margin-bottom: 16px; line-height: 1.5; }

.modal-benefits-title { font-size: 14px; font-weight: 700; color: var(--text); margin-bottom: 8px; }
.modal-benefit {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 14px;
  color: var(--text);
  padding: 6px 0;
  border-bottom: 1px solid var(--bg);
}
.modal-benefit:last-child { border-bottom: none; }
.modal-benefit-icon { color: var(--green); font-size: 16px; flex-shrink: 0; margin-top: 1px; }

.modal-commission {
  margin-top: 16px;
  padding: 10px 14px;
  background: #fff8e1;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: #9a6e00;
}

.modal-apply-btn {
  display: block;
  width: 100%;
  margin-top: 20px;
  padding: 15px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  text-align: center;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 700;
  text-decoration: none;
  border: none;
  cursor: pointer;
}

/* ── Баннер подписки ── */
.subscribe-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  z-index: 150;
  box-shadow: 0 -4px 20px rgba(67,97,238,0.25);
}
.subscribe-text {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
}
.subscribe-icon { font-size: 22px; }
.subscribe-text b { font-size: 14px; display: block; }
.subscribe-sub { font-size: 12px; opacity: 0.85; }
.subscribe-btn {
  flex-shrink: 0;
  padding: 8px 16px;
  background: rgba(255,255,255,0.25);
  border: 2px solid rgba(255,255,255,0.7);
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

/* ── Loader ── */
.loader { text-align: center; padding: 60px 20px; color: var(--hint); }
.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--bg-card);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Пустой поиск ── */
.empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--hint);
}
.empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-title { font-size: 17px; font-weight: 600; margin-bottom: 6px; color: var(--text); }

/* ── Тёмная тема ── */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1a2e;
    --bg-card: #16213e;
    --text: #eaeaea;
    --hint: #7a7a9a;
  }
  .card-type-badge.credit { background: #1e2860; }
  .card-type-badge.debit  { background: #0d3320; }
  .benefit-chip { background: #0f0f1e; }
  .modal-commission { background: #2a2000; color: #d4aa00; }
}
