* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

:root {
  --tg-theme-bg-color: #f0f4f2;
  --tg-theme-text-color: #0c2522;
  --green: #0d5d56;
  --green-light: #5dcaa5;
  --green-bg: #e4f3ee;
  --green-border: #b8d9cf;
  --red: #c94040;
  --amber: #d99434;
  --gray: #8a9e98;
  --gray-light: #aab8b3;
  --border: #e0e8e4;
  --bg: #f0f4f2;
  --card-bg: white;
}

html, body { height: 100%; overflow: hidden; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: var(--bg); color: var(--tg-theme-text-color); }

#app { height: 100vh; overflow: hidden; }

/* ─── Загрузка / ошибка ─────────────────────────────────────────────────── */
.loading-screen, .error-screen, .empty-screen {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: 100vh; gap: 8px; padding: 32px;
}
.loading-logo { width: 56px; height: 56px; border-radius: 50%; border: 2px solid var(--green); display: flex; align-items: center; justify-content: center; font-size: 24px; font-weight: 500; color: var(--green); margin-bottom: 8px; }
.loading-text { font-size: 20px; font-weight: 500; color: var(--green); }
.loading-sub { font-size: 13px; color: var(--gray); }
.error-screen i, .empty-screen i { font-size: 48px; color: var(--gray-light); margin-bottom: 8px; }
.error-title, .empty-title { font-size: 17px; font-weight: 500; color: #0c2522; }
.error-sub, .empty-sub { font-size: 13px; color: var(--gray); text-align: center; line-height: 1.5; }
.error-screen button, .empty-screen button {
  margin-top: 12px; background: var(--green); color: white; border: none;
  border-radius: 10px; padding: 12px 24px; font-size: 14px; font-weight: 500; cursor: pointer;
}

/* ─── Экраны ────────────────────────────────────────────────────────────── */
#main { height: 100vh; position: relative; }
.screen { display: none; position: absolute; inset: 0; overflow-y: auto; padding-bottom: 72px; }
.screen.active { display: block; }

/* ─── Шапка главной ─────────────────────────────────────────────────────── */
.header { background: var(--green); color: white; padding: 18px 16px 20px; }
.header-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.brand { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 500; }
.brand-mark { width: 24px; height: 24px; border-radius: 50%; border: 1.5px solid rgba(255,255,255,0.5); display: flex; align-items: center; justify-content: center; font-size: 11px; }
.header-name { font-size: 13px; color: rgba(255,255,255,0.6); }
.hero-label { font-size: 11px; color: rgba(255,255,255,0.6); margin-bottom: 2px; }
.hero-amount { font-size: 34px; font-weight: 500; line-height: 1; color: var(--green-light); }
.hero-sub { font-size: 12px; color: rgba(255,255,255,0.55); margin-top: 3px; }
.progress-wrap { margin-top: 14px; }
.progress-row { display: flex; justify-content: space-between; font-size: 11px; color: rgba(255,255,255,0.55); margin-bottom: 5px; }
.progress-track { background: rgba(255,255,255,0.15); border-radius: 3px; height: 6px; }
.progress-fill { border-radius: 3px; height: 6px; background: var(--green-light); transition: width 0.6s ease; }
.freedom-chip { display: inline-flex; align-items: center; gap: 5px; background: rgba(255,255,255,0.1); border-radius: 20px; padding: 5px 11px; margin-top: 12px; font-size: 12px; color: rgba(255,255,255,0.8); }
.freedom-chip i { font-size: 12px; }

/* ─── Секции ────────────────────────────────────────────────────────────── */
.sec { padding: 12px 14px 0; }
.sec-title { font-size: 10px; font-weight: 500; color: var(--gray); text-transform: uppercase; letter-spacing: 0.6px; margin-bottom: 8px; }

/* ─── Совет дня ─────────────────────────────────────────────────────────── */
.advice-card { background: var(--green-bg); border-radius: 12px; border: 0.5px solid var(--green-border); padding: 12px 14px; }
.advice-eyebrow { font-size: 10px; font-weight: 500; color: var(--green); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 5px; }
.advice-text { font-size: 13px; color: #0c2522; line-height: 1.45; }
.advice-hl { font-weight: 500; color: var(--green); }

/* ─── Карточки ──────────────────────────────────────────────────────────── */
.card { background: white; border-radius: 12px; border: 0.5px solid var(--border); overflow: hidden; }
.chart-card { background: white; border-radius: 12px; border: 0.5px solid var(--border); padding: 14px; }
.chart-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.chart-title { font-size: 13px; font-weight: 500; color: #0c2522; }
.chart-legend { display: flex; gap: 12px; margin-top: 8px; flex-wrap: wrap; }
.leg { display: flex; align-items: center; gap: 4px; font-size: 11px; color: var(--gray); }
.leg-line { width: 18px; height: 2px; border-radius: 1px; }

/* ─── Кредит в списке ───────────────────────────────────────────────────── */
.cr { padding: 11px 14px; }
.cr + .cr { border-top: 0.5px solid var(--bg); }
.cr-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.cr-name { font-size: 14px; font-weight: 500; color: #0c2522; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.cr-bal { font-size: 14px; font-weight: 500; color: #0c2522; white-space: nowrap; }
.bar-track { height: 4px; background: #eef3ef; border-radius: 2px; margin-bottom: 7px; }
.bar-fill { height: 4px; border-radius: 2px; }
.cr-bot { display: flex; justify-content: space-between; align-items: flex-end; }
.cr-meta { display: flex; flex-direction: column; gap: 3px; }
.cr-rate { font-size: 11px; color: var(--gray); }
.cr-split { display: flex; gap: 4px; font-size: 11px; align-items: center; }
.s-body { color: var(--green); font-weight: 500; }
.s-int { color: var(--red); font-weight: 500; }
.s-lbl { color: var(--gray-light); }
.cr-right { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.cr-date { font-size: 11px; color: var(--gray-light); }
.early-tip { font-size: 11px; color: var(--green); font-weight: 500; display: flex; align-items: center; gap: 3px; }
.early-tip i { font-size: 12px; }
.no-tip { font-size: 11px; color: var(--gray-light); }

/* ─── Бейджи ────────────────────────────────────────────────────────────── */
.badge { font-size: 9px; font-weight: 500; padding: 2px 6px; border-radius: 20px; white-space: nowrap; }
.badge-hot { background: #fde8e8; color: var(--red); }
.badge-ok { background: var(--bg); color: var(--gray); }

/* ─── Страница заголовок ────────────────────────────────────────────────── */
.page-header { padding: 18px 14px 14px; background: var(--green); color: white; }
.page-title { font-size: 20px; font-weight: 500; color: white; }
.page-sub { font-size: 12px; color: rgba(255,255,255,0.6); margin-top: 3px; }

/* ─── Вкладки ───────────────────────────────────────────────────────────── */
.tabs { display: flex; background: rgba(255,255,255,0.1); border-radius: 8px; padding: 3px; gap: 3px; }
.tab { flex: 1; text-align: center; padding: 6px 4px; font-size: 12px; color: rgba(255,255,255,0.6); border-radius: 6px; cursor: pointer; }
.tab.active { background: white; color: var(--green); font-weight: 500; }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ─── Статы ─────────────────────────────────────────────────────────────── */
.stat-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stat-card { background: white; border-radius: 12px; border: 0.5px solid var(--border); padding: 12px 14px; }
.stat-lbl { font-size: 11px; color: var(--gray); margin-bottom: 3px; }
.stat-val { font-size: 19px; font-weight: 500; line-height: 1.1; }
.stat-val.neg { color: var(--red); }
.stat-val.pos { color: var(--green); }
.stat-val.neu { color: #0c2522; }

/* ─── История ───────────────────────────────────────────────────────────── */
.history-item { padding: 10px 14px; display: flex; justify-content: space-between; align-items: center; }
.history-item + .history-item { border-top: 0.5px solid var(--bg); }
.hi-bank { font-size: 13px; font-weight: 500; color: #0c2522; }
.hi-date { font-size: 11px; color: var(--gray); }
.hi-amount { font-size: 13px; font-weight: 500; }
.hi-extra { color: var(--green); }
.hi-min { color: #0c2522; }
.hi-type { font-size: 10px; color: var(--gray-light); }
.empty-list { padding: 24px; text-align: center; font-size: 13px; color: var(--gray); }

/* ─── Внести платёж ─────────────────────────────────────────────────────── */
.rate-card, .free-card { background: white; border-radius: 12px; border: 0.5px solid var(--border); padding: 14px; }
.rate-label { font-size: 11px; color: var(--gray); margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.5px; font-weight: 500; }
.free-input-row, .rate-input-row { display: flex; align-items: center; gap: 10px; }
.free-input, .rate-input { flex: 1; font-size: 28px; font-weight: 500; color: #0c2522; border: none; outline: none; background: transparent; font-family: inherit; width: 100%; }
.free-currency, .rate-suffix { font-size: 18px; color: var(--gray); }
.rate-divider { height: 0.5px; background: var(--bg); margin: 10px 0; }
.rate-hint { font-size: 12px; color: var(--gray); line-height: 1.4; }
.rate-hint b { color: var(--green); font-weight: 500; }
.distribute-btn { display: flex; align-items: center; justify-content: center; gap: 6px; background: var(--green); color: white; border-radius: 10px; padding: 11px; font-size: 13px; font-weight: 500; cursor: pointer; margin-top: 10px; }
.tip-banner { background: var(--green-bg); border-radius: 10px; border: 0.5px solid var(--green-border); padding: 10px 12px; display: flex; gap: 8px; align-items: flex-start; }
.tip-icon { color: var(--green); font-size: 15px; margin-top: 1px; flex-shrink: 0; }
.tip-text { font-size: 12px; color: #0c2522; line-height: 1.45; }
.tip-text b { font-weight: 500; color: var(--green); }

/* Кнопки в платежах */
.pay-actions { display: flex; gap: 8px; margin-top: 8px; }
.btn-min { flex: 1; border: 0.5px solid var(--border); border-radius: 8px; padding: 8px 10px; font-size: 12px; color: #0c2522; background: #f8faf9; text-align: center; cursor: pointer; font-family: inherit; }
.btn-extra { flex: 1; border: none; border-radius: 8px; padding: 8px 10px; font-size: 12px; color: white; background: var(--green); text-align: center; cursor: pointer; font-family: inherit; font-weight: 500; }
.btn-extra.dim { background: var(--gray); }
.btn-extra.done { background: #1b8c80; }
.pay-deadline-soon { color: var(--red); font-size: 11px; font-weight: 500; }
.pay-deadline-ok { color: var(--gray-light); font-size: 11px; }

/* ─── Рефинанс ──────────────────────────────────────────────────────────── */
.warn-banner { background: #fff8ed; border: 0.5px solid #f0d090; border-radius: 10px; padding: 10px 12px; display: flex; gap: 8px; }
.warn-icon { color: var(--amber); font-size: 15px; flex-shrink: 0; margin-top: 1px; }
.warn-text { font-size: 12px; color: #7a5a1a; line-height: 1.4; }
.warn-text b { font-weight: 500; }

.refi-card { background: white; border-radius: 12px; border: 0.5px solid var(--border); overflow: hidden; margin-bottom: 8px; }
.refi-head { padding: 12px 14px; display: flex; align-items: center; gap: 10px; cursor: pointer; }
.cb { width: 20px; height: 20px; border-radius: 6px; border: 1.5px solid #d0ddd8; background: white; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; color: white; transition: all 0.15s; }
.cb.on { background: var(--green); border-color: var(--green); }
.ri { flex: 1; }
.rname { font-size: 14px; font-weight: 500; color: #0c2522; display: flex; align-items: center; gap: 6px; margin-bottom: 2px; }
.rmeta { font-size: 12px; color: var(--gray); }
.rv { font-size: 11px; font-weight: 500; text-align: right; flex-shrink: 0; max-width: 90px; }
.v-yes { color: var(--green); }
.v-maybe { color: var(--amber); }
.v-no { color: var(--gray-light); }

.refi-body { border-top: 0.5px solid var(--bg); padding: 12px 14px; display: none; }
.refi-body.open { display: block; }
.cg { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.cc { background: #f8faf9; border-radius: 8px; padding: 10px 12px; }
.cc.win { background: var(--green-bg); }
.cl { font-size: 10px; color: var(--gray); text-transform: uppercase; letter-spacing: 0.3px; margin-bottom: 4px; }
.cl.g { color: var(--green); }
.cv { font-size: 17px; font-weight: 500; color: #0c2522; }
.cv.g { color: var(--green); }
.cs { font-size: 11px; color: var(--gray); margin-top: 2px; }
.cs.g { color: #5a8a7a; }
.sv { display: flex; justify-content: space-between; align-items: center; background: var(--green-bg); border-radius: 8px; padding: 10px 12px; }
.sl { font-size: 12px; color: var(--green); }
.sm { font-size: 16px; font-weight: 500; color: var(--green); }
.nob { background: #f8faf9; border-radius: 8px; padding: 10px 12px; }
.not { font-size: 12px; color: var(--gray); line-height: 1.4; }
.rw { background: #fff8ed; border-radius: 8px; padding: 9px 12px; margin-top: 8px; font-size: 12px; color: #7a5a1a; line-height: 1.4; }
.rw b { font-weight: 500; }

.badge-r { background: #fde8e8; color: var(--red); }
.badge-m { background: #fff5e0; color: var(--amber); }
.badge-g { background: var(--bg); color: var(--gray); }

/* ─── Навигация ─────────────────────────────────────────────────────────── */
.bottom-nav { position: fixed; bottom: 0; left: 0; right: 0; background: white; border-top: 0.5px solid var(--border); display: flex; padding: 8px 0 max(14px, env(safe-area-inset-bottom)); z-index: 10; }
.nav-item { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; cursor: pointer; }
.nav-item i { font-size: 20px; color: #b0bdb9; }
.nav-item span { font-size: 10px; color: #b0bdb9; }
.nav-item.active i, .nav-item.active span { color: var(--green); }

/* ─── По банкам ─────────────────────────────────────────────────────────── */
.bank-detail-card { background: white; border-radius: 12px; border: 0.5px solid var(--border); padding: 14px; margin-bottom: 8px; }
.bd-name { font-size: 14px; font-weight: 500; color: #0c2522; margin-bottom: 8px; display: flex; align-items: center; gap: 6px; }
.bd-row { display: flex; justify-content: space-between; font-size: 12px; padding: 4px 0; }
.bd-key { color: var(--gray); }
.bd-val { font-weight: 500; color: #0c2522; }
.bd-val.red { color: var(--red); }
.bd-val.green { color: var(--green); }
.bd-bar-wrap { margin: 8px 0 4px; }
.bd-bar-label { display: flex; justify-content: space-between; font-size: 11px; margin-bottom: 3px; }
.bd-bar-track { height: 6px; background: #eef3ef; border-radius: 3px; position: relative; overflow: hidden; }
.bd-bar-body { height: 6px; background: var(--green); border-radius: 3px; position: absolute; left: 0; }
.bd-bar-int { height: 6px; background: var(--red); border-radius: 3px; position: absolute; }
