/* Mini App: цвета берутся из темы Telegram (--tg-theme-*), запасные — для обычного браузера. */
:root {
  --bg: var(--tg-theme-secondary-bg-color, #efeff4);
  --card: var(--tg-theme-section-bg-color, var(--tg-theme-bg-color, #ffffff));
  --text: var(--tg-theme-text-color, #000000);
  --hint: var(--tg-theme-hint-color, #8e8e93);
  --sub: var(--tg-theme-subtitle-text-color, var(--hint));
  --link: var(--tg-theme-link-color, #2481cc);
  --accent: var(--tg-theme-accent-text-color, var(--link));
  --btn: var(--tg-theme-button-color, #2481cc);
  --btn-text: var(--tg-theme-button-text-color, #ffffff);
  --sep: var(--tg-theme-section-separator-color, rgba(0, 0, 0, 0.08));
  --danger: var(--tg-theme-destructive-text-color, #ff3b30);
  --ok: #34c759;
  --warn: #ff9500;
  --ok-bg: rgba(52, 199, 89, 0.14);
  --warn-bg: rgba(255, 149, 0, 0.16);
  --danger-bg: rgba(255, 59, 48, 0.12);
  --radius: 16px;
  --safe-top: var(--tg-content-safe-area-inset-top, 0px);
  --safe-bottom: var(--tg-safe-area-inset-bottom, env(safe-area-inset-bottom, 0px));
  --tabbar: 58px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: var(--tg-theme-secondary-bg-color, #000000);
    --card: var(--tg-theme-section-bg-color, var(--tg-theme-bg-color, #1c1c1e));
    --text: var(--tg-theme-text-color, #ffffff);
    --hint: var(--tg-theme-hint-color, #98989e);
    --sep: var(--tg-theme-section-separator-color, rgba(255, 255, 255, 0.1));
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", Roboto, "Segoe UI", system-ui, sans-serif;
  overscroll-behavior: none; min-height: 100vh;
}
a { color: var(--link); text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input, textarea { font: inherit; color: inherit; }
h1 { font-size: 24px; line-height: 1.2; margin: 0 0 8px; font-weight: 700; letter-spacing: -0.02em; }
h2 { font-size: 17px; margin: 0; font-weight: 600; }
p { margin: 0 0 12px; }
.hint { color: var(--hint); }
.small { font-size: 13px; }
.center { text-align: center; padding: 64px 24px; }
.big-icon { font-size: 56px; margin-bottom: 12px; }

.app { padding: calc(var(--safe-top) + 8px) 16px calc(var(--tabbar) + var(--safe-bottom) + 16px); max-width: 640px; margin: 0 auto; }
.app.no-tabs { padding-bottom: calc(var(--safe-bottom) + 96px); }
.boot { display: flex; justify-content: center; padding: 40vh 0; }
.spinner {
  width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--sep); border-top-color: var(--btn);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── шапка ── */
.header { display: flex; align-items: center; gap: 12px; padding: 6px 0 14px; }
.header .title { flex: 1; min-width: 0; }
.header h1 { font-size: 22px; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header .sub { color: var(--hint); font-size: 13px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  background: var(--card); color: var(--accent); font-size: 18px; flex: none;
}
.icon-btn:active { opacity: 0.6; }

/* ── карточки и списки ── */
.card-block { background: var(--card); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.section-title {
  display: flex; align-items: baseline; justify-content: space-between; margin: 20px 4px 8px;
  font-size: 13px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--hint); font-weight: 600;
}
.section-title a { text-transform: none; letter-spacing: 0; font-weight: 500; }
.list { background: var(--card); border-radius: var(--radius); overflow: hidden; margin-bottom: 12px; }
.row {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px; min-height: 56px; width: 100%; text-align: left;
  position: relative;
}
.row + .row::before { content: ""; position: absolute; left: 16px; right: 0; top: 0; border-top: 1px solid var(--sep); }
.row.tappable:active { background: var(--sep); }
.row .body { flex: 1; min-width: 0; }
.row .name { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .meta { color: var(--hint); font-size: 13px; line-height: 1.35; }
.row .right { text-align: right; flex: none; }
.row .chev { color: var(--hint); font-size: 18px; flex: none; }
.avatar {
  width: 40px; height: 40px; border-radius: 50%; flex: none; display: flex; align-items: center; justify-content: center;
  background: var(--btn); color: var(--btn-text); font-weight: 600; font-size: 15px;
}
.avatar.muted { opacity: 0.45; }
.bank-badge {
  width: 44px; height: 30px; border-radius: 8px; flex: none; display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; letter-spacing: 0.02em; color: #fff; background: #6e6e73;
}
.bank-badge.humo { background: linear-gradient(135deg, #1f6feb, #0b3d91); }
.bank-badge.uzcard { background: linear-gradient(135deg, #1aa37a, #0a5c44); }
.bank-badge.paused { filter: grayscale(1); opacity: 0.6; }

.tx-icon {
  width: 40px; height: 40px; border-radius: 50%; flex: none; display: flex; align-items: center; justify-content: center;
  font-size: 18px; background: var(--ok-bg); color: var(--ok); font-weight: 700;
}
.tx-icon.out { background: var(--sep); color: var(--hint); }
.tx-icon.unknown { background: var(--warn-bg); color: var(--warn); }
.amount { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.amount.in { color: var(--ok); }
.amount .cur { font-size: 12px; font-weight: 500; color: var(--hint); margin-left: 3px; }

.chip {
  display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--sep); color: var(--text); margin: 2px 4px 2px 0; white-space: nowrap;
}
.chip.ok { background: var(--ok-bg); color: var(--ok); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.danger { background: var(--danger-bg); color: var(--danger); }
.chip.info { background: rgba(36, 129, 204, 0.14); color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.chip-btn { padding: 7px 14px; border-radius: 999px; background: var(--card); font-weight: 500; font-size: 14px; }
.chip-btn.active { background: var(--btn); color: var(--btn-text); }

/* ── главная ── */
.hero {
  background: linear-gradient(135deg, var(--btn), color-mix(in srgb, var(--btn) 70%, #000)); color: var(--btn-text);
  border-radius: 20px; padding: 18px 20px; margin-bottom: 12px; position: relative; overflow: hidden;
}
.hero::after {
  content: ""; position: absolute; right: -40px; top: -40px; width: 160px; height: 160px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
}
.hero .label { opacity: 0.85; font-size: 13px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.06em; }
.hero .sum { font-size: 36px; font-weight: 800; letter-spacing: -0.03em; margin: 4px 0 2px; font-variant-numeric: tabular-nums; }
.hero .sum .cur { font-size: 16px; font-weight: 600; opacity: 0.85; margin-left: 6px; }
.hero .sub { opacity: 0.9; font-size: 14px; }
.hero.small .sum { font-size: 26px; }
.banner {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 14px; margin-bottom: 12px;
  font-size: 14px; width: 100%; text-align: left; line-height: 1.35;
}
.banner.warn { background: var(--warn-bg); color: var(--text); }
.banner.ok { background: var(--ok-bg); color: var(--text); }
.banner.danger { background: var(--danger-bg); color: var(--text); }
.banner.info { background: var(--card); color: var(--text); }
.banner .ico { font-size: 20px; flex: none; }
.banner .act { color: var(--accent); font-weight: 600; flex: none; }
.empty { text-align: center; padding: 28px 16px; color: var(--hint); }
.empty .ico { font-size: 40px; margin-bottom: 8px; }

/* ── кнопки и формы ── */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; padding: 14px 16px;
  border-radius: 14px; font-weight: 600; font-size: 16px; background: var(--card); color: var(--accent);
  transition: transform 0.05s;
}
.btn:active { transform: scale(0.98); opacity: 0.85; }
.btn.primary { background: var(--btn); color: var(--btn-text); }
.btn.danger { color: var(--danger); }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: 0.5; }
.btn + .btn { margin-top: 10px; }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { width: auto; flex: 1; }
.main-fallback { position: fixed; left: 16px; right: 16px; bottom: calc(var(--safe-bottom) + 16px); z-index: 20; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18); }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--hint); margin: 0 4px 6px; font-weight: 500; }
.input {
  width: 100%; padding: 13px 14px; border-radius: 12px; border: 1px solid transparent; background: var(--card);
  outline: none; font-size: 17px;
}
.input:focus { border-color: var(--btn); }
.input.code { font-size: 30px; letter-spacing: 8px; text-align: center; font-weight: 600; padding: 14px 8px; }
textarea.input { min-height: 80px; resize: vertical; }
.form-error { color: var(--danger); font-size: 14px; margin: -6px 4px 12px; min-height: 0; }
.form-error:empty { margin: 0; }
.links { text-align: center; margin-top: 16px; }
.links a { font-weight: 500; }
.links a + a::before { content: "·"; color: var(--hint); margin: 0 10px; }
.switch { position: relative; width: 50px; height: 30px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span {
  position: absolute; inset: 0; border-radius: 30px; background: var(--sep); transition: background 0.2s;
}
.switch span::after {
  content: ""; position: absolute; width: 26px; height: 26px; left: 2px; top: 2px; border-radius: 50%; background: #fff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25); transition: transform 0.2s;
}
.switch input:checked + span { background: var(--ok); }
.switch input:checked + span::after { transform: translateX(20px); }
.check { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--hint); flex: none; display: flex; align-items: center; justify-content: center; color: transparent; font-size: 14px; }
.check.on { background: var(--btn); border-color: var(--btn); color: var(--btn-text); }
.segment { display: flex; background: var(--sep); border-radius: 12px; padding: 3px; }
.segment button { flex: 1; padding: 8px; border-radius: 10px; font-weight: 500; }
.segment button.active { background: var(--card); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); }
.copy-box {
  display: flex; align-items: center; gap: 10px; background: var(--bg); border-radius: 12px; padding: 12px 14px;
  font-size: 18px; font-weight: 600; letter-spacing: 0.03em; font-variant-numeric: tabular-nums; margin-bottom: 8px;
}
.copy-box span { flex: 1; word-break: break-all; }
.copy-box button { color: var(--accent); font-size: 14px; font-weight: 600; letter-spacing: 0; }
.file-pick { display: flex; align-items: center; gap: 12px; }
.file-pick input { display: none; }
.file-pick .preview { width: 56px; height: 56px; border-radius: 10px; object-fit: cover; background: var(--bg); flex: none; }

/* ── мастер (онбординг) ── */
.wiz { padding: 12px 0 40px; }
.wiz .logo { font-size: 52px; text-align: center; margin: 24px 0 12px; }
.wiz h1 { text-align: center; }
.wiz > p.hint { text-align: center; margin-bottom: 22px; }
.lang-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 24px; }
.lang-btn { background: var(--card); border-radius: var(--radius); padding: 26px 12px; font-size: 18px; font-weight: 600; }
.lang-btn:active { opacity: 0.7; }
.bank-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.bank-option {
  background: var(--card); border-radius: var(--radius); padding: 16px 12px; text-align: center; border: 2px solid transparent;
}
.bank-option b { display: block; font-size: 17px; margin-bottom: 4px; }
.bank-option small { color: var(--hint); font-size: 12px; }
.bank-option.selected { border-color: var(--btn); }
.qr-box { background: #fff; border-radius: var(--radius); padding: 12px; display: flex; justify-content: center; margin-bottom: 16px; }
.qr-box img { width: 240px; height: 240px; image-rendering: pixelated; }
.steps { padding-left: 20px; margin: 0 0 16px; }
.steps li { margin-bottom: 6px; }
.rich b { font-weight: 600; }
.progress-dots { display: flex; justify-content: center; gap: 6px; margin-bottom: 20px; }
.progress-dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--sep); }
.progress-dots i.on { background: var(--btn); }

/* ── таббар ── */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex; justify-content: space-around;
  background: var(--card); border-top: 1px solid var(--sep); padding: 6px 8px calc(var(--safe-bottom) + 6px);
}
.tabbar button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--hint); font-size: 11px; font-weight: 500; padding: 2px 0; }
.tabbar button.active { color: var(--accent); }
.tabbar svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ── шторка ── */
.sheet-overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.45); z-index: 30; animation: fade 0.15s; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 31; background: var(--bg); border-radius: 20px 20px 0 0;
  padding: 10px 16px calc(var(--safe-bottom) + 20px); max-height: 92vh; overflow-y: auto; animation: rise 0.2s ease-out;
  max-width: 640px; margin: 0 auto;
}
.sheet .grip { width: 36px; height: 4px; border-radius: 2px; background: var(--hint); opacity: 0.4; margin: 0 auto 14px; }
.sheet h2 { font-size: 20px; margin-bottom: 4px; }
.sheet .sub { color: var(--hint); margin-bottom: 14px; }
.sheet .card-block { background: var(--card); }
.sheet .list { background: var(--card); }
body.sheet-open { overflow: hidden; }
@keyframes rise { from { transform: translateY(40px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }

/* ── тост ── */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar) + var(--safe-bottom) + 20px); transform: translateX(-50%);
  background: rgba(30, 30, 30, 0.92); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; z-index: 40;
  max-width: calc(100% - 32px); text-align: center; animation: fade 0.15s;
}
.toast.error { background: var(--danger); }
.toast.success { background: var(--ok); }

.skeleton { background: linear-gradient(90deg, var(--sep) 25%, transparent 50%, var(--sep) 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 8px; height: 16px; }
@keyframes shimmer { to { background-position: -200% 0; } }
.fade-in { animation: fade 0.2s; }
