/* Colours come from the Telegram theme (set on :root by telegram-web-app.js). */
:root {
  --bg: var(--tg-theme-secondary-bg-color, #f1f1f4);
  --card: var(--tg-theme-section-bg-color, var(--tg-theme-bg-color, #fff));
  --text: var(--tg-theme-text-color, #111);
  --hint: var(--tg-theme-hint-color, #8a8a8e);
  --sub: var(--tg-theme-subtitle-text-color, var(--hint));
  --link: var(--tg-theme-link-color, #2a7bd6);
  --accent: var(--tg-theme-accent-text-color, var(--link));
  --btn: var(--tg-theme-button-color, #2a7bd6);
  --btn-text: var(--tg-theme-button-text-color, #fff);
  --head: var(--tg-theme-section-header-text-color, var(--hint));
  --danger: var(--tg-theme-destructive-text-color, #e53935);
  --sep: color-mix(in srgb, var(--hint) 22%, transparent);
  --ok: #2e9e5b;
  --warn: #d48806;
  --radius: 14px;
  --tabs-h: 0px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
body.has-tabs { --tabs-h: 58px; }
main { padding: 12px 12px calc(24px + var(--tabs-h) + env(safe-area-inset-bottom)); max-width: 640px; margin: 0 auto; }
h1 { font-size: 22px; margin: 6px 4px 2px; }
h2 { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; color: var(--head); margin: 20px 16px 6px; }
p { margin: 0; }
a { color: var(--link); text-decoration: none; }
.sub { color: var(--hint); font-size: 13px; margin: 0 4px 12px; }
.muted { color: var(--hint); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }

.card { background: var(--card); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 10px; }
.card.flush { padding: 0; overflow: hidden; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.row + .row { margin-top: 8px; }
.stack > * + * { margin-top: 10px; }
.list > .item { padding: 12px 16px; display: flex; align-items: center; gap: 12px; }
.list > .item + .item { border-top: 1px solid var(--sep); }
.item .grow { flex: 1; min-width: 0; }
.item .title { font-weight: 500; }
.item .meta { color: var(--hint); font-size: 13px; }
.chev::after { content: "›"; color: var(--hint); font-size: 22px; line-height: 1; }
button.item { width: 100%; text-align: left; background: none; border: 0; color: inherit; font: inherit; cursor: pointer; }
button.item:active { background: var(--sep); }

label.field { display: block; }
label.field > span { display: block; font-size: 13px; color: var(--hint); margin: 0 2px 6px; }
input, select {
  width: 100%; font: inherit; font-size: 16px; color: var(--text);
  background: var(--bg); border: 1.5px solid transparent; border-radius: 10px;
  padding: 11px 12px; outline: none; -webkit-appearance: none; appearance: none;
}
input:focus, select:focus { border-color: var(--btn); }
input.bad { border-color: var(--danger); }
.err { color: var(--danger); font-size: 13px; margin: 6px 2px 0; }
.err:empty { display: none; }
.hint { color: var(--hint); font-size: 13px; margin: 6px 2px 0; }
.inline { display: flex; gap: 8px; }
.inline > * { flex: 1; }

.seg { display: flex; background: var(--bg); border-radius: 10px; padding: 3px; gap: 3px; }
.seg button { flex: 1; border: 0; border-radius: 8px; padding: 8px 6px; background: none; color: var(--text); font: inherit; font-weight: 500; cursor: pointer; }
.seg button.on { background: var(--card); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 0; border-radius: 18px; padding: 7px 13px; background: var(--bg); color: var(--text); font: inherit; font-size: 14px; cursor: pointer; }
.chip.on { background: var(--btn); color: var(--btn-text); }

.btn { display: block; width: 100%; border: 0; border-radius: 12px; padding: 13px; font: inherit; font-weight: 600; background: var(--btn); color: var(--btn-text); cursor: pointer; }
.btn:disabled { opacity: .5; }
.btn.ghost { background: var(--bg); color: var(--link); }
.btn.danger { background: none; color: var(--danger); font-weight: 500; }
.btn.small { display: inline-block; width: auto; padding: 8px 14px; font-size: 14px; }
.btns { display: flex; gap: 8px; margin-top: 12px; }
.btns > .btn { flex: 1; }
.linkbtn { border: 0; background: none; color: var(--link); font: inherit; padding: 0; cursor: pointer; }

.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 10px; background: var(--bg); color: var(--hint); white-space: nowrap; }
.badge.x2 { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.badge.maybe { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.badge.bad { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
.banner { border-radius: var(--radius); padding: 12px 14px; margin-bottom: 10px; background: color-mix(in srgb, var(--warn) 14%, var(--card)); }
.banner.info { background: color-mix(in srgb, var(--btn) 12%, var(--card)); }

.quote .total { font-size: 26px; font-weight: 700; }
.quote .credited { margin-top: 4px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; }
.kv > :nth-child(odd) { color: var(--hint); }
.kv > :nth-child(even) { text-align: right; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.kv .strong { font-weight: 700; color: var(--text); }

.copy { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--bg); border-radius: 10px; padding: 10px 12px; border: 0; width: 100%; font: inherit; color: var(--text); cursor: pointer; text-align: left; }
.copy b { font-size: 18px; font-variant-numeric: tabular-nums; }
.copy .act { color: var(--link); font-size: 13px; white-space: nowrap; }
.copy + .copy { margin-top: 8px; }

.steps { display: flex; gap: 4px; margin: 4px 0 12px; }
.steps > div { flex: 1; text-align: center; font-size: 11px; color: var(--hint); }
.steps > div::before { content: ""; display: block; height: 4px; border-radius: 2px; background: var(--sep); margin-bottom: 6px; }
.steps > div.done::before { background: var(--ok); }
.steps > div.now { color: var(--text); font-weight: 600; }
.steps > div.now::before { background: var(--btn); }
.status-big { font-size: 40px; line-height: 1; margin-bottom: 6px; }

.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile { background: var(--card); border-radius: var(--radius); padding: 12px 14px; }
.tile .v { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.tile .l { color: var(--hint); font-size: 13px; }
.tile.wide { grid-column: 1 / -1; }

.switch { position: relative; width: 46px; height: 28px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 14px; background: var(--sep); transition: background .15s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .15s; }
.switch input:checked + span { background: var(--ok); }
.switch input:checked + span::after { transform: translateX(18px); }

#tabs { position: fixed; left: 0; right: 0; bottom: 0; display: flex; background: var(--card); border-top: 1px solid var(--sep); padding-bottom: env(safe-area-inset-bottom); z-index: 5; }
#tabs button { flex: 1; border: 0; background: none; color: var(--hint); font: inherit; font-size: 11px; padding: 7px 0 8px; cursor: pointer; }
#tabs button .ic { display: block; font-size: 20px; line-height: 26px; }
#tabs button.on { color: var(--btn); }

#toast { position: fixed; left: 50%; bottom: calc(76px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: rgba(30,30,30,.92); color: #fff; padding: 9px 16px; border-radius: 18px; font-size: 14px; z-index: 10; max-width: 90vw; text-align: center; }

.loader { width: 28px; height: 28px; margin: 80px auto; border-radius: 50%; border: 3px solid var(--sep); border-top-color: var(--btn); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty { text-align: center; color: var(--hint); padding: 36px 16px; }
.empty .big { font-size: 40px; margin-bottom: 8px; }
.pager { display: flex; justify-content: space-between; margin-top: 4px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation-duration: 2s !important; } }
