/*
 * Дизайн-система мини-аппов Cashbird и BirdPay.
 * Принципы (см. packages/webapp/DESIGN.md):
 *  — цвета берём из темы Telegram (--tg-theme-*): светлая и тёмная тема пользователя;
 *  — бренд-цвет (--brand) один и только для акцентов: знак, график, активная вкладка, главная кнопка;
 *  — сгруппированные списки как в настройках Telegram, линейные иконки Lucide, без эмодзи;
 *  — деньги крупно и моноширинными цифрами; заголовки в обычном регистре; без градиентов и свечений.
 */
:root {
  --bg: var(--tg-theme-secondary-bg-color, #efeff4);
  --surface: 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);
  --subtle: var(--tg-theme-subtitle-text-color, var(--hint));
  --section-title: var(--tg-theme-section-header-text-color, var(--hint));
  --sep: var(--tg-theme-section-separator-color, color-mix(in srgb, var(--hint) 30%, transparent));
  --danger: var(--tg-theme-destructive-text-color, #ff3b30);
  --fill: color-mix(in srgb, var(--text) 6%, transparent);
  --fill-2: color-mix(in srgb, var(--text) 10%, transparent);
  --up: #248a3d;
  --down: #d70015;
  --r-lg: 14px;
  --r-md: 10px;
  --gutter: 16px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
:root[data-scheme="dark"] {
  --bg: var(--tg-theme-secondary-bg-color, #000000);
  --surface: 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, #8d8e93);
  --up: #30d158;
  --down: #ff453a;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.38 var(--font);
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
button, input { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; }
.num { font-variant-numeric: tabular-nums; }
.i { display: block; flex: none; }

#app { max-width: 560px; margin: 0 auto; padding: 8px 0 calc(92px + env(safe-area-inset-bottom)); min-height: 100vh; }
.pad { padding: 0 var(--gutter); }

/* ------------------------------------------------------------- шапка */
.bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px var(--gutter) 14px; }
.wordmark { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 19px; letter-spacing: -0.03em; }
.mark { width: 30px; height: 30px; border-radius: 9px; background: var(--brand); color: var(--on-brand); display: grid; place-items: center; }
.mark svg { width: 20px; height: 20px; }
.pill-btn { display: inline-flex; align-items: center; gap: 4px; border: 0; background: var(--surface); color: var(--text); border-radius: 999px; padding: 7px 10px 7px 11px; font-size: 15px; font-weight: 500; }
.pill-btn .i { color: var(--hint); }
.screen-title { font-size: 28px; font-weight: 700; letter-spacing: -0.035em; margin: 2px var(--gutter) 14px; }

/* ------------------------------------------------------------- секции */
.section { margin: 0 0 22px; }
.section-title { display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; color: var(--section-title); margin: 0 calc(var(--gutter) + 4px) 7px; }
.section-title a, .section-title button { color: var(--brand-text); background: none; border: 0; padding: 0; font-size: 13px; text-decoration: none; }
.section-foot { font-size: 13px; color: var(--hint); margin: 7px calc(var(--gutter) + 4px) 0; line-height: 1.35; }
.group { background: var(--surface); border-radius: var(--r-lg); margin: 0 var(--gutter); overflow: hidden; }
.cell { position: relative; display: flex; align-items: center; gap: 12px; width: 100%; min-height: 48px; padding: 10px 16px; border: 0; background: none; text-align: left; color: var(--text); }
button.cell:active, a.cell:active { background: var(--fill); }
a.cell { text-decoration: none; }
.cell + .cell::before { content: ""; position: absolute; top: 0; right: 0; left: 16px; height: 0.5px; background: var(--sep); }
.cell.has-icon + .cell::before, .cell + .cell.has-icon::before { left: 56px; }
.cell-icon { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: var(--fill-2); color: var(--text); flex: none; }
.cell-icon .i { width: 18px; height: 18px; }
.cell-body { flex: 1; min-width: 0; }
.cell-title { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cell-sub { font-size: 13px; color: var(--hint); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cell-value { font-size: 16px; color: var(--hint); white-space: nowrap; display: flex; align-items: center; gap: 4px; }
.cell-value.strong { color: var(--text); font-weight: 500; }
.chev { color: var(--hint); opacity: 0.6; }
.cell-check { color: var(--brand-text); }

/* ------------------------------------------------------------- цена и график */
.quote-hero { padding: 2px var(--gutter) 6px; }
.quote-label { font-size: 15px; color: var(--hint); display: flex; align-items: center; gap: 6px; }
.quote-value { font-size: 42px; font-weight: 700; letter-spacing: -0.045em; line-height: 1.1; margin-top: 2px; font-variant-numeric: tabular-nums; }
.quote-value small { font-size: 24px; font-weight: 600; color: var(--hint); letter-spacing: -0.02em; margin-left: 4px; }
.quote-delta { font-size: 15px; font-weight: 500; margin-top: 3px; font-variant-numeric: tabular-nums; min-height: 21px; }
.up { color: var(--up); }
.down { color: var(--down); }
.flat { color: var(--hint); }
.chart { height: 220px; margin: 8px 0 4px; position: relative; }
.chart-empty { height: 220px; display: grid; place-items: center; color: var(--hint); font-size: 14px; text-align: center; padding: 0 32px; }
.periods { display: flex; justify-content: space-between; gap: 4px; padding: 4px var(--gutter) 0; }
.period { flex: 1; border: 0; background: none; color: var(--hint); font-size: 14px; font-weight: 600; padding: 7px 0; border-radius: 9px; }
.period.active { background: var(--fill-2); color: var(--text); }
.period:disabled { opacity: 0.35; }
.range { display: flex; justify-content: space-between; font-size: 13px; color: var(--hint); padding: 10px calc(var(--gutter) + 4px) 0; font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------- кнопки */
.btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 50px; border: 0; border-radius: 12px; padding: 0 18px; background: var(--brand); color: var(--on-brand); font-size: 17px; font-weight: 600; text-decoration: none; }
.btn:active { opacity: 0.85; }
.btn.tonal { background: var(--brand-tint); color: var(--brand-text); }
.btn.plain { background: var(--surface); color: var(--text); }
.btn:disabled { opacity: 0.45; }
.btn-row { display: flex; gap: 10px; padding: 0 var(--gutter); }
.link-btn { border: 0; background: none; color: var(--brand-text); font-size: 15px; padding: 6px 0; }

/* ------------------------------------------------------------- сегменты */
.seg { display: flex; background: var(--fill-2); border-radius: 10px; padding: 2px; margin: 0 var(--gutter) 16px; }
.seg-item { flex: 1; border: 0; background: none; padding: 7px 6px; border-radius: 8px; font-size: 14px; font-weight: 600; color: var(--text); opacity: 0.7; }
.seg-item.active { background: var(--surface); opacity: 1; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12); }

/* ------------------------------------------------------------- конвертер */
.converter { position: relative; margin: 0 var(--gutter); }
.conv-field { background: var(--surface); border-radius: var(--r-lg); padding: 12px 16px 14px; }
.conv-field + .conv-field { margin-top: 6px; }
.conv-label { font-size: 13px; color: var(--hint); }
.conv-row { display: flex; align-items: center; gap: 10px; margin-top: 4px; }
.conv-input { flex: 1; min-width: 0; border: 0; background: none; outline: none; padding: 0; font-size: 30px; font-weight: 600; letter-spacing: -0.035em; font-variant-numeric: tabular-nums; color: var(--text); }
.conv-input::placeholder { color: var(--hint); opacity: 0.6; }
.ccy { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 16px; padding: 6px 10px 6px 6px; border-radius: 999px; background: var(--fill); }
.ccy-dot { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; color: #fff; }
.ccy-dot.rub { background: #1f4fbf; }
.ccy-dot.usdt { background: #26a17b; }
.swap { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 38px; height: 38px; border-radius: 50%; border: 4px solid var(--bg); background: var(--surface); color: var(--text); display: grid; place-items: center; padding: 0; z-index: 1; }
.swap .i { width: 18px; height: 18px; }
.rate-line { display: flex; justify-content: space-between; align-items: center; font-size: 14px; color: var(--hint); padding: 10px calc(var(--gutter) + 4px) 0; font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------- поля */
.field { display: block; padding: 0; }
.input { width: 100%; border: 0; outline: none; background: none; padding: 13px 16px; font-size: 16px; color: var(--text); }
.input::placeholder { color: var(--hint); opacity: 0.8; }
.search { display: flex; align-items: center; gap: 8px; margin: 0 var(--gutter) 18px; padding: 0 12px; height: 38px; border-radius: 10px; background: var(--fill-2); color: var(--hint); }
.search input { flex: 1; min-width: 0; border: 0; background: none; outline: none; font-size: 16px; color: var(--text); padding: 0; }
.search .i { width: 18px; height: 18px; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 0 var(--gutter); margin-bottom: 18px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 0; border-radius: 999px; padding: 7px 14px; background: var(--surface); color: var(--text); font-size: 15px; font-weight: 500; }
.chip.active { background: var(--text); color: var(--bg); }

/* ------------------------------------------------------------- статусы и лента */
.badge { display: inline-flex; align-items: center; font-size: 13px; font-weight: 500; padding: 2px 8px; border-radius: 6px; background: var(--fill-2); color: var(--hint); white-space: nowrap; }
.badge.ok { background: color-mix(in srgb, var(--up) 14%, transparent); color: var(--up); }
.badge.bad { background: color-mix(in srgb, var(--down) 12%, transparent); color: var(--down); }
.badge.wait { background: var(--brand-tint); color: var(--brand-text); }
.steps { padding: 4px 16px 6px; }
.step { display: flex; gap: 12px; position: relative; padding: 8px 0; font-size: 15px; }
.step-dot { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--fill-2); flex: none; display: grid; place-items: center; background: var(--surface); z-index: 1; }
.step.done .step-dot { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.step-dot .i { width: 12px; height: 12px; stroke-width: 3; }
.step:not(:last-child)::after { content: ""; position: absolute; left: 9px; top: 28px; bottom: -8px; width: 2px; background: var(--fill-2); }
.step.done:not(:last-child)::after { background: var(--brand); }
.step:not(.done) .step-label { color: var(--hint); }
.code-box { display: flex; align-items: center; gap: 10px; margin: 0 var(--gutter); padding: 14px 16px; border-radius: var(--r-lg); background: var(--surface); }
.code-box code { flex: 1; min-width: 0; font: 600 15px/1.35 ui-monospace, "SF Mono", Menlo, Consolas, monospace; word-break: break-all; user-select: all; }
.icon-btn { border: 0; background: var(--fill); color: var(--text); width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; padding: 0; flex: none; }
.icon-btn .i { width: 18px; height: 18px; }

/* ------------------------------------------------------------- состояния */
.state { text-align: center; padding: 56px 32px; color: var(--hint); }
.state-icon { width: 56px; height: 56px; margin: 0 auto 14px; border-radius: 16px; background: var(--fill); display: grid; place-items: center; color: var(--hint); }
.state-icon .i { width: 28px; height: 28px; }
.state-title { color: var(--text); font-size: 17px; font-weight: 600; margin-bottom: 4px; }
.state .btn { margin-top: 18px; }
.result { text-align: center; padding: 28px var(--gutter) 22px; }
.result-icon { width: 64px; height: 64px; margin: 0 auto 14px; border-radius: 50%; display: grid; place-items: center; background: var(--brand-tint); color: var(--brand-text); }
.result-icon.ok { background: color-mix(in srgb, var(--up) 14%, transparent); color: var(--up); }
.result-icon.bad { background: color-mix(in srgb, var(--down) 12%, transparent); color: var(--down); }
.result-icon .i { width: 30px; height: 30px; }
.result h2 { font-size: 22px; letter-spacing: -0.03em; margin: 0 0 6px; }
.result p { color: var(--hint); margin: 0 auto; max-width: 340px; font-size: 15px; }
.sk { background: var(--fill-2); border-radius: 8px; position: relative; overflow: hidden; }
.sk::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--surface) 55%, transparent), transparent); animation: sk 1.3s infinite; }
@keyframes sk { to { transform: translateX(100%); } }

/* ------------------------------------------------------------- нижняя навигация */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; justify-content: center; background: var(--tg-theme-bottom-bar-bg-color, var(--surface)); border-top: 0.5px solid var(--sep); padding: 6px 8px calc(4px + env(safe-area-inset-bottom)); }
.tabbar-inner { display: flex; width: 100%; max-width: 560px; }
.tab { flex: 1; border: 0; background: none; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 4px 0; color: var(--hint); font-size: 10.5px; font-weight: 500; letter-spacing: 0; }
.tab .i { width: 25px; height: 25px; stroke-width: 1.6; }
.tab.active { color: var(--brand-text); }

/* ------------------------------------------------------------- витрина (BirdPay) */
.rail { display: flex; gap: 10px; overflow-x: auto; scroll-snap-type: x mandatory; padding: 0 var(--gutter); margin-bottom: 22px; scrollbar-width: none; }
.rail::-webkit-scrollbar { display: none; }
.feature { flex: none; width: 78%; max-width: 360px; scroll-snap-align: start; border: 0; text-align: left; border-radius: 16px; padding: 16px; min-height: 132px; display: flex; flex-direction: column; justify-content: space-between; color: #fff; }
.feature-logo { width: 36px; height: 36px; }
.feature-title { font-size: 20px; font-weight: 700; letter-spacing: -0.03em; margin-top: 18px; }
.feature-sub { font-size: 14px; opacity: 0.78; margin-top: 2px; }
.logos { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px 8px; padding: 0 var(--gutter); }
.logo-item { border: 0; background: none; padding: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; }
.logo-tile { width: 58px; height: 58px; border-radius: 15px; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 22px; }
.logo-tile svg { width: 30px; height: 30px; fill: currentColor; }
:root[data-scheme="dark"] .logo-tile.dark { box-shadow: inset 0 0 0 0.5px rgba(255, 255, 255, 0.18); }
.logo-name { font-size: 12px; text-align: center; color: var(--text); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell .logo-tile { width: 32px; height: 32px; border-radius: 9px; font-size: 14px; }
.cell .logo-tile svg { width: 17px; height: 17px; }
.product-head { display: flex; align-items: center; gap: 14px; padding: 4px var(--gutter) 18px; }
.product-head .logo-tile { width: 56px; height: 56px; }
.product-title { font-size: 22px; font-weight: 700; letter-spacing: -0.03em; line-height: 1.2; }
.product-sub { color: var(--hint); font-size: 14px; margin-top: 2px; }
.radio { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--fill-2); flex: none; display: grid; place-items: center; }
.radio.on { border-color: var(--brand); }
.radio.on::after { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--brand); }
.amounts { display: flex; gap: 8px; padding: 10px var(--gutter) 0; }
.amounts .chip { flex: 1; background: var(--surface); text-align: center; padding: 8px 0; font-variant-numeric: tabular-nums; }
.clamp { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.landing { min-height: 92vh; display: grid; place-content: center; text-align: center; padding: 24px; }
.landing .mark { width: 72px; height: 72px; border-radius: 20px; margin: 0 auto 18px; }
.landing .mark svg { width: 44px; height: 44px; }
.landing h1 { margin: 0; font-size: 32px; letter-spacing: -0.04em; }
.landing p { color: var(--hint); max-width: 360px; margin: 8px auto 22px; }
.landing .btn { max-width: 300px; margin: 0 auto; }
.group > .input + .input { border-top: 0.5px solid var(--sep); }
.conv-field { display: block; }
.cell-title { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.3; }
