:root {
    --bg: var(--tg-theme-secondary-bg-color, #f1f1f4);
    --card: var(--tg-theme-section-bg-color, var(--tg-theme-bg-color, #ffffff));
    --text: var(--tg-theme-text-color, #111111);
    --hint: var(--tg-theme-hint-color, #8a8a8e);
    --link: var(--tg-theme-link-color, #2481cc);
    --accent: var(--tg-theme-button-color, #2481cc);
    --accent-text: var(--tg-theme-button-text-color, #ffffff);
    --danger: var(--tg-theme-destructive-text-color, #e53935);
    --sep: color-mix(in srgb, var(--hint) 22%, transparent);
    --ok: #2fa84f;
    --radius: 14px;
}
@media (prefers-color-scheme: dark) {
    :root:not(.tg) {
        --bg: #0f0f10;
        --card: #1c1c1e;
        --text: #f2f2f2;
        --hint: #8e8e93;
    }
}
* { box-sizing: border-box; }
[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", "Segoe UI", Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}
#app { max-width: 560px; margin: 0 auto; padding: 12px 16px calc(28px + env(safe-area-inset-bottom)); }
h1 { font-size: 22px; margin: 6px 0 2px; letter-spacing: -0.2px; }
h2 { font-size: 13px; font-weight: 500; text-transform: uppercase; color: var(--hint); margin: 22px 4px 8px; letter-spacing: .3px; }
p { margin: 6px 0; }
.hint { color: var(--hint); font-size: 14px; }
.small { font-size: 13px; }
.center { text-align: center; }
.card { background: var(--card); border-radius: var(--radius); padding: 14px 16px; margin: 8px 0; }
.card.flush { padding: 0; overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--sep); cursor: pointer; }
.row:last-child { border-bottom: 0; }
.row .grow { flex: 1; min-width: 0; }
.row .title { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .sub { color: var(--hint); font-size: 13px; }
.row .chev { color: var(--hint); }
.big { font-size: 34px; font-weight: 700; letter-spacing: -0.5px; }
.money { font-variant-numeric: tabular-nums; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; background: var(--sep); color: var(--text); }
.pill.ok { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.pill.warn { background: color-mix(in srgb, #f5a623 20%, transparent); color: #c27c00; }
.pill.off { color: var(--hint); }
button, .btn {
    display: block; width: 100%; border: 0; border-radius: 12px; padding: 14px 16px; margin: 8px 0;
    font: inherit; font-weight: 600; cursor: pointer; text-align: center; text-decoration: none;
    background: var(--accent); color: var(--accent-text);
}
button.secondary, .btn.secondary { background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); }
button.danger { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }
button.link { background: none; color: var(--link); padding: 8px; font-weight: 500; }
button:disabled { opacity: .5; cursor: default; }
label { display: block; margin: 12px 0 6px; font-size: 14px; color: var(--hint); }
input, select, textarea {
    width: 100%; font: inherit; color: var(--text); background: var(--bg);
    border: 1px solid var(--sep); border-radius: 10px; padding: 11px 12px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.switch { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--sep); gap: 12px; }
.switch:last-child { border-bottom: 0; }
.switch input[type=checkbox] { width: 44px; height: 26px; appearance: none; background: var(--sep); border-radius: 999px; position: relative; border: 0; padding: 0; flex: none; cursor: pointer; transition: background .15s; }
.switch input[type=checkbox]::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: left .15s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch input[type=checkbox]:checked { background: var(--ok); }
.switch input[type=checkbox]:checked::after { left: 21px; }
details summary { cursor: pointer; color: var(--link); padding: 6px 0; list-style: none; }
details summary::-webkit-details-marker { display: none; }
.sum { display: flex; justify-content: space-between; padding: 4px 0; font-size: 15px; }
.sum.total { font-weight: 700; border-top: 1px solid var(--sep); margin-top: 6px; padding-top: 8px; }
.addr { font-family: ui-monospace, Menlo, monospace; font-size: 13px; word-break: break-all; }
.splash { display: flex; align-items: center; justify-content: center; min-height: 60vh; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--sep); border-top-color: var(--accent); animation: spin .8s linear infinite; }
.spinner.sm { width: 18px; height: 18px; border-width: 2px; display: inline-block; vertical-align: -3px; }
@keyframes spin { to { transform: rotate(360deg); } }
.hero { text-align: center; padding: 18px 8px 8px; }
.hero .emoji { font-size: 56px; line-height: 1; }
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: rgba(30,30,30,.92); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; max-width: 90vw; z-index: 1000; }
.error { color: var(--danger); font-size: 14px; margin: 8px 0; }
.steps { counter-reset: s; padding: 0; margin: 8px 0; list-style: none; }
.steps li { counter-increment: s; padding: 6px 0 6px 34px; position: relative; font-size: 15px; }
.steps li::before { content: counter(s); position: absolute; left: 0; top: 5px; width: 24px; height: 24px; border-radius: 50%; background: var(--sep); text-align: center; line-height: 24px; font-size: 13px; font-weight: 600; }
.tabs { display: flex; gap: 6px; margin: 4px 0 8px; }
.tabs button { margin: 0; padding: 8px; font-size: 14px; }
