:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --ink: #0f1115;
  --ink-2: #4b5160;
  --ink-3: #8a90a0;
  --line: #e7e9ee;
  --soft: #eef0f4;
  --accent: #3b5bfd;
  --accent-ink: #ffffff;
  --accent-soft: #eaefff;
  --money: #0e9f6e;
  --money-soft: #e3f6ee;
  --warn: #c27803;
  --warn-soft: #fdf3dc;
  --danger: #d92d20;
  --danger-soft: #fde8e7;
  --hero: #12141a;
  --hero-ink: #ffffff;
  --hero-ink-2: rgba(255, 255, 255, 0.62);
  --radius: 18px;
  --radius-s: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06);
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
:root[data-theme='dark'] {
  --bg: #0d0f13;
  --card: #171a21;
  --ink: #f2f4f8;
  --ink-2: #b4b9c6;
  --ink-3: #7c8393;
  --line: #262a34;
  --soft: #1e222b;
  --accent: #6d86ff;
  --accent-ink: #0b0d12;
  --accent-soft: #1d2442;
  --money: #3ccf91;
  --money-soft: #12291f;
  --warn: #f2b84b;
  --warn-soft: #2c2412;
  --danger: #ff6b5e;
  --danger-soft: #2f1715;
  --hero: #1b1f29;
  --shadow: none;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.num { font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }

#app { max-width: 560px; margin: 0 auto; padding: 14px 16px calc(96px + var(--safe-b)); }
.boot { display: grid; place-items: center; height: 70vh; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ——— Шапка ——— */
.top { display: flex; align-items: center; gap: 12px; margin: 4px 2px 16px; }
.avatar { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; color: #fff; background: var(--accent); flex: none; }
.top .hello { flex: 1; min-width: 0; }
.top .hello b { display: block; font-size: 17px; line-height: 1.2; }
.top .hello span { color: var(--ink-3); font-size: 13px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); font-size: 13px; font-weight: 600; white-space: nowrap; }
.chip.code { font-family: ui-monospace, 'SF Mono', Menlo, monospace; letter-spacing: 0.06em; }

h1.page { font-size: 26px; line-height: 1.15; letter-spacing: -0.02em; margin: 6px 2px 4px; }
p.sub { color: var(--ink-2); margin: 0 2px 18px; }
h2.sec { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-3); margin: 22px 4px 8px; }
h2.sec .more { float: right; text-transform: none; letter-spacing: 0; color: var(--accent); font-weight: 600; }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--line); }
:root[data-theme='dark'] .card { border-color: transparent; }
.pad { padding: 16px; }

/* ——— Баланс ——— */
.balance { background: var(--hero); color: var(--hero-ink); border-radius: 22px; padding: 18px 18px 16px; position: relative; overflow: hidden; }
.balance::after { content: ''; position: absolute; right: -60px; top: -60px; width: 200px; height: 200px; border-radius: 50%; background: radial-gradient(closest-side, rgba(109, 134, 255, 0.35), transparent); pointer-events: none; }
.balance .lbl { color: var(--hero-ink-2); font-size: 13px; }
.balance .big { font-size: 40px; font-weight: 700; letter-spacing: -0.03em; line-height: 1.1; margin: 4px 0 14px; }
.balance .row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.balance .mini { background: rgba(255, 255, 255, 0.07); border-radius: 12px; padding: 10px 12px; }
.balance .mini b { display: block; font-size: 17px; }
.balance .mini span { color: var(--hero-ink-2); font-size: 12px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 14px; padding: 13px 16px; font-weight: 600; background: var(--accent); color: var(--accent-ink); width: 100%; transition: transform 0.08s, opacity 0.15s; }
.btn:active { transform: scale(0.98); }
.btn[disabled] { opacity: 0.45; pointer-events: none; }
.btn.light { background: #fff; color: #0f1115; }
.btn.ghost { background: var(--soft); color: var(--ink); }
.btn.small { width: auto; padding: 8px 12px; font-size: 14px; border-radius: 10px; }
.btn.danger { background: var(--danger-soft); color: var(--danger); }
.btn.money { background: var(--money); color: #fff; }

/* ——— Сегменты ——— */
.seg { display: flex; background: var(--soft); border-radius: 11px; padding: 3px; gap: 2px; }
.seg button { flex: 1; border: 0; background: none; padding: 7px 10px; border-radius: 9px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }

/* ——— Плитки ——— */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile { padding: 14px; }
.tile .v { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }
.tile .k { color: var(--ink-3); font-size: 13px; display: flex; align-items: center; gap: 6px; }
.tile .k svg { width: 15px; height: 15px; }
.tile.money .v { color: var(--money); }

/* ——— График ——— */
.chart { padding: 14px 14px 10px; }
.chart .head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.chart .head b { font-size: 15px; }
.chart .head span { color: var(--ink-3); font-size: 13px; }
.bars { display: flex; align-items: flex-end; gap: 3px; height: 92px; }
.bars i { flex: 1; background: var(--accent-soft); border-radius: 4px 4px 2px 2px; min-height: 3px; position: relative; }
.bars i.has { background: var(--accent); }
.bars i.today { outline: 2px solid var(--accent); outline-offset: 1px; }
.chart .axis { display: flex; justify-content: space-between; color: var(--ink-3); font-size: 11px; margin-top: 6px; }

/* ——— Списки ——— */
.list { overflow: hidden; }
.item { display: flex; align-items: center; gap: 12px; padding: 13px 16px; border-top: 1px solid var(--line); }
.item:first-child { border-top: 0; }
.item .ic { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; font-size: 19px; flex: none; }
.item .t { flex: 1; min-width: 0; }
.item .t b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .t span { color: var(--ink-3); font-size: 13px; }
.item .r { text-align: right; flex: none; }
.item .r b { display: block; font-weight: 700; }
.item.tap { cursor: pointer; }
.item.tap:active { background: var(--soft); }

.st { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 2px 7px; border-radius: 6px; margin-top: 2px; }
.st.hold { background: var(--warn-soft); color: var(--warn); }
.st.available, .st.paid { background: var(--money-soft); color: var(--money); }
.st.reversed, .st.rejected { background: var(--danger-soft); color: var(--danger); }
.st.requested { background: var(--accent-soft); color: var(--accent); }

.empty { text-align: center; padding: 28px 20px; color: var(--ink-2); }
.empty .em { font-size: 36px; margin-bottom: 8px; }
.empty b { display: block; color: var(--ink); font-size: 16px; margin-bottom: 4px; }
.empty .btn { margin-top: 14px; width: auto; }

/* ——— Проекты ——— */
.proj { display: flex; gap: 14px; padding: 16px; align-items: flex-start; cursor: pointer; }
.proj + .proj { margin-top: 10px; }
.proj:active { transform: scale(0.99); }
.proj .logo { width: 52px; height: 52px; border-radius: 15px; display: grid; place-items: center; font-size: 27px; flex: none; }
.proj .body { flex: 1; min-width: 0; }
.proj .name { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; }
.proj .tag { color: var(--ink-2); font-size: 14px; margin: 2px 0 8px; }
.rate { background: var(--money-soft); color: var(--money); font-size: 12.5px; font-weight: 700; padding: 3px 8px; border-radius: 7px; }
.proj .stats { display: flex; gap: 14px; color: var(--ink-3); font-size: 13px; }
.proj .stats b { color: var(--ink); font-weight: 600; }
.chev { color: var(--ink-3); align-self: center; }

.phero { text-align: center; padding: 8px 0 18px; }
.phero .logo { width: 76px; height: 76px; border-radius: 22px; display: grid; place-items: center; font-size: 40px; margin: 0 auto 12px; }
.phero h1 { font-size: 24px; margin: 0 0 4px; letter-spacing: -0.02em; }
.phero p { color: var(--ink-2); margin: 0 auto 10px; max-width: 360px; }

.link { padding: 12px 14px; border-top: 1px solid var(--line); }
.link:first-child { border-top: 0; }
.link .l { font-size: 13px; color: var(--ink-3); margin-bottom: 6px; }
.link .u { display: flex; gap: 8px; align-items: center; }
.link code { flex: 1; min-width: 0; font: 13px ui-monospace, 'SF Mono', Menlo, monospace; background: var(--soft); padding: 9px 10px; border-radius: 9px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { width: 38px; height: 38px; flex: none; border: 0; border-radius: 10px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; }
.icon-btn svg { width: 18px; height: 18px; }

.prose { padding: 4px 16px 14px; }
.prose h3 { font-size: 14px; margin: 14px 0 4px; }
.prose p { margin: 0; color: var(--ink-2); }
.prose ul { margin: 6px 0 0; padding-left: 18px; color: var(--ink-2); }
.prose li + li { margin-top: 4px; }

/* ——— Онбординг ——— */
.onb-hero { padding: 26px 20px 22px; border-radius: 24px; background: var(--hero); color: var(--hero-ink); position: relative; overflow: hidden; margin-bottom: 14px; }
.onb-hero::before { content: ''; position: absolute; width: 240px; height: 240px; right: -80px; top: -90px; border-radius: 50%; background: radial-gradient(closest-side, rgba(60, 207, 145, 0.35), transparent); }
.onb-hero::after { content: ''; position: absolute; width: 220px; height: 220px; left: -90px; bottom: -120px; border-radius: 50%; background: radial-gradient(closest-side, rgba(109, 134, 255, 0.35), transparent); }
.onb-hero .pct { font-size: 64px; font-weight: 800; letter-spacing: -0.04em; line-height: 1; position: relative; }
.onb-hero .pct small { font-size: 20px; font-weight: 600; letter-spacing: 0; color: var(--hero-ink-2); margin-left: 6px; }
.onb-hero h1 { font-size: 24px; line-height: 1.2; letter-spacing: -0.02em; margin: 12px 0 6px; position: relative; }
.onb-hero p { color: var(--hero-ink-2); margin: 0; position: relative; }
.feat { display: flex; gap: 12px; padding: 13px 16px; border-top: 1px solid var(--line); }
.feat:first-child { border-top: 0; }
.feat .ic { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); flex: none; }
.feat .ic svg { width: 19px; height: 19px; }
.feat b { display: block; }
.feat span { color: var(--ink-2); font-size: 14px; }
details.terms { padding: 0; }
details.terms summary { list-style: none; padding: 14px 16px; font-weight: 600; display: flex; justify-content: space-between; cursor: pointer; }
details.terms summary::-webkit-details-marker { display: none; }
details.terms[open] summary .chev { transform: rotate(90deg); }
details.terms .prose { font-size: 14px; }
.check { display: flex; gap: 12px; align-items: flex-start; padding: 14px 4px; font-size: 14px; color: var(--ink-2); }
.check input { width: 22px; height: 22px; accent-color: var(--accent); flex: none; margin: 0; }

/* ——— Формы ——— */
.field { padding: 14px 16px; }
.field label { display: block; font-size: 13px; color: var(--ink-3); margin-bottom: 6px; }
.input { width: 100%; border: 1px solid var(--line); background: var(--bg); border-radius: 11px; padding: 11px 12px; font: 14px ui-monospace, 'SF Mono', Menlo, monospace; outline: none; }
.input:focus { border-color: var(--accent); }
.input.text { font-family: inherit; font-size: 15px; }
.hint { font-size: 13px; color: var(--ink-3); margin-top: 6px; }
.row2 { display: flex; gap: 8px; }

/* ——— Таббар ——— */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: center; gap: 4px; padding: 8px 10px calc(8px + var(--safe-b)); background: color-mix(in srgb, var(--card) 88%, transparent); backdrop-filter: saturate(180%) blur(18px); -webkit-backdrop-filter: saturate(180%) blur(18px); border-top: 1px solid var(--line); z-index: 10; }
.tabbar button { flex: 1; max-width: 130px; border: 0; background: none; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 4px 0; font-size: 11px; font-weight: 600; color: var(--ink-3); }
.tabbar button svg { width: 24px; height: 24px; }
.tabbar button.on { color: var(--accent); }

/* ——— Тост, шторка ——— */
.toast { position: fixed; left: 50%; bottom: calc(92px + var(--safe-b)); transform: translate(-50%, 20px); background: #12141a; color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; font-weight: 500; opacity: 0; pointer-events: none; transition: 0.2s; z-index: 30; max-width: calc(100% - 32px); text-align: center; }
.toast.on { opacity: 1; transform: translate(-50%, 0); }
.sheet-bg { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.42); z-index: 20; animation: fade 0.18s; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; max-width: 560px; margin: 0 auto; background: var(--card); border-radius: 22px 22px 0 0; padding: 10px 16px calc(18px + var(--safe-b)); z-index: 21; animation: up 0.22s cubic-bezier(0.2, 0.8, 0.2, 1); max-height: 88vh; overflow: auto; }
.sheet .grab { width: 38px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 12px; }
.sheet h3 { margin: 0 0 6px; font-size: 19px; }
.sheet p { color: var(--ink-2); margin: 0 0 14px; }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(40px); opacity: 0.5; } }

.kv { display: flex; justify-content: space-between; padding: 9px 0; border-top: 1px solid var(--line); font-size: 14px; }
.kv:first-child { border-top: 0; }
.kv span { color: var(--ink-3); }
.mt { margin-top: 10px; }
.mt2 { margin-top: 16px; }
.muted { color: var(--ink-3); }
.center { text-align: center; }
.small { font-size: 13px; }
.view { animation: fade 0.18s; }
.back { display: inline-flex; align-items: center; gap: 4px; border: 0; background: none; color: var(--accent); font-weight: 600; padding: 4px 0; margin-bottom: 6px; }
.tabbar[hidden]{display:none!important}
