/* «С нуля» — палитра «тёмный изумруд» */
:root {
  --bg: #061015;
  --bg2: #08161c;
  --card: #0d1f26;
  --card2: #122a33;
  --card3: #17343e;
  --line: rgba(130, 230, 190, 0.09);
  --line2: rgba(130, 230, 190, 0.16);
  --text: #e6f4ee;
  --muted: #8ba89f;
  --dim: #5b7870;
  --acc: #2fe3a0;
  --acc2: #17b97f;
  --acc-ink: #04261a;
  --acc-soft: rgba(47, 227, 160, 0.12);
  --teal: #3cc9c0;
  --warn: #efc56f;
  --warn-soft: rgba(239, 197, 111, 0.12);
  --bad: #ff7a72;
  --bad-soft: rgba(255, 122, 114, 0.12);
  --btc: #f0b35a;
  --r: 18px;
  --r-sm: 12px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --tab-h: 64px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 15px; line-height: 1.35; -webkit-font-smoothing: antialiased; overscroll-behavior: none; }
body { min-height: 100vh; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }
input { font: inherit; color: inherit; }
.num, .money { font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.pos { color: var(--acc); }
.neg { color: var(--bad); }
.warn { color: var(--warn); }
.btc { color: var(--btc); }
.small { font-size: 12.5px; }
.tiny { font-size: 11px; }
.bold { font-weight: 650; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.col { display: flex; flex-direction: column; gap: 4px; }
.grow { flex: 1; min-width: 0; }
.center { text-align: center; }
.hidden { display: none !important; }

/* ---------- Загрузка ---------- */
.boot { height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; }
.boot-logo { animation: pulse 1.6s ease-in-out infinite; }
.boot-title { font-size: 26px; font-weight: 750; letter-spacing: -0.02em; }
.boot-sub { color: var(--muted); }
@keyframes pulse { 50% { transform: scale(0.94); opacity: 0.8; } }

/* ---------- Каркас ---------- */
.shell { min-height: 100vh; padding-bottom: calc(var(--tab-h) + var(--safe-b) + 16px); }
.topbar {
  position: sticky; top: 0; z-index: 20; padding: 10px 14px 10px;
  background: linear-gradient(180deg, rgba(6, 16, 21, 0.97) 70%, rgba(6, 16, 21, 0.85));
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar .bal { font-size: 22px; font-weight: 760; letter-spacing: -0.02em; line-height: 1.1; }
.topbar .bal.negative { color: var(--bad); }
.topbar .sub { display: flex; gap: 10px; align-items: center; font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--card3); display: grid; place-items: center; font-weight: 700; color: var(--acc); overflow: hidden; flex: none; border: 1px solid var(--line2); }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 4px 9px; border-radius: 99px; background: var(--card2); border: 1px solid var(--line); font-size: 12px; color: var(--muted); white-space: nowrap; }
.chip.acc { background: var(--acc-soft); color: var(--acc); border-color: rgba(47, 227, 160, 0.25); }
.chip.warn { background: var(--warn-soft); color: var(--warn); border-color: rgba(239, 197, 111, 0.25); }
.chip.bad { background: var(--bad-soft); color: var(--bad); border-color: rgba(255, 122, 114, 0.25); }
.star-btn { height: 38px; padding: 0 12px; border-radius: 12px; background: linear-gradient(180deg, #1a3c35, #12302a); border: 1px solid rgba(47, 227, 160, 0.25); color: var(--acc); font-weight: 650; display: inline-flex; align-items: center; gap: 6px; }

.page { padding: 14px; display: flex; flex-direction: column; gap: 14px; }
.page-anim .page { animation: pageIn 0.28s ease; }
@keyframes pageIn { from { opacity: 0; transform: translateY(6px); } }
.page-title { font-size: 22px; font-weight: 760; letter-spacing: -0.02em; margin: 2px 2px 0; }
.section-title { display: flex; justify-content: space-between; align-items: baseline; margin: 6px 2px -4px; font-size: 13px; font-weight: 650; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 14px; padding: 4px 2px; }

/* ---------- Карточки ---------- */
.card { background: linear-gradient(180deg, var(--card2), var(--card)); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; }
.card.flat { background: var(--card); }
.card.tap { transition: transform 0.15s ease, border-color 0.2s; }
.card.tap:active { transform: scale(0.985); border-color: var(--line2); }
.card h3 { margin: 0 0 2px; font-size: 16px; font-weight: 680; letter-spacing: -0.01em; }
.card .kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.kpi { background: rgba(0, 0, 0, 0.18); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 9px 10px; min-width: 0; }
.kpi .v { font-size: 15.5px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .l { font-size: 11px; color: var(--muted); margin-top: 1px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }

.biz-card { display: flex; gap: 12px; align-items: stretch; }
.biz-thumb { width: 84px; height: 84px; border-radius: 14px; flex: none; overflow: hidden; background: #0a1a20; border: 1px solid var(--line); }
.biz-thumb svg { width: 100%; height: 100%; display: block; }
.biz-body { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: space-between; }
.biz-name { font-weight: 660; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.biz-sub { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.biz-stats { display: flex; gap: 12px; font-size: 12.5px; color: var(--muted); }
.biz-stats b { color: var(--text); font-weight: 650; font-variant-numeric: tabular-nums; }

.add-card { border: 1.5px dashed var(--line2); border-radius: var(--r); padding: 16px; display: flex; align-items: center; justify-content: center; gap: 8px; color: var(--acc); font-weight: 620; background: rgba(47, 227, 160, 0.03); }
.add-card:active { background: var(--acc-soft); }

.banner { border-radius: var(--r); padding: 12px 14px; display: flex; gap: 12px; align-items: center; border: 1px solid; }
.banner.acc { background: var(--acc-soft); border-color: rgba(47, 227, 160, 0.25); }
.banner.warn { background: var(--warn-soft); border-color: rgba(239, 197, 111, 0.25); }
.banner.bad { background: var(--bad-soft); border-color: rgba(255, 122, 114, 0.3); }
.banner .ico { font-size: 22px; flex: none; }
.banner .t { font-weight: 650; }
.banner .d { font-size: 12.5px; color: var(--muted); }

/* ---------- Кнопки ---------- */
.btn { height: 46px; border-radius: 14px; padding: 0 16px; font-weight: 660; display: inline-flex; align-items: center; justify-content: center; gap: 8px; background: var(--card3); border: 1px solid var(--line2); transition: transform 0.12s, opacity 0.2s, background 0.2s; white-space: nowrap; }
.btn:active { transform: scale(0.97); }
.btn.primary { background: linear-gradient(180deg, #3cf0ad, #1fc488); color: var(--acc-ink); border: 0; box-shadow: 0 6px 18px -8px rgba(47, 227, 160, 0.6); }
.btn.danger { background: var(--bad-soft); color: var(--bad); border-color: rgba(255, 122, 114, 0.3); }
.btn.ghost { background: transparent; }
.btn.sm { height: 36px; border-radius: 11px; padding: 0 12px; font-size: 13.5px; }
.btn.xs { height: 30px; border-radius: 9px; padding: 0 10px; font-size: 12.5px; }
.btn.block { width: 100%; }
.btn:disabled, .btn.disabled { opacity: 0.4; pointer-events: none; }
.btn-row { display: flex; gap: 8px; }
.btn-row > * { flex: 1; }

.seg { display: flex; background: var(--bg2); border: 1px solid var(--line); border-radius: 13px; padding: 3px; gap: 3px; }
.seg button { flex: 1; height: 34px; border-radius: 10px; font-size: 13.5px; font-weight: 600; color: var(--muted); transition: background 0.2s, color 0.2s; }
.seg button.on { background: var(--card3); color: var(--text); box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset; }

.stepper { display: inline-flex; align-items: center; background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.stepper button { width: 40px; height: 38px; font-size: 20px; color: var(--acc); }
.stepper button:disabled { color: var(--dim); }
.stepper .v { min-width: 34px; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12.5px; color: var(--muted); }
.input { height: 46px; border-radius: 13px; background: var(--bg2); border: 1px solid var(--line2); padding: 0 14px; outline: none; font-size: 16px; font-variant-numeric: tabular-nums; width: 100%; }
.input:focus { border-color: rgba(47, 227, 160, 0.5); }

input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 30px; background: transparent; }
input[type=range]::-webkit-slider-runnable-track { height: 6px; border-radius: 4px; background: linear-gradient(90deg, var(--acc2) var(--p, 50%), var(--card3) var(--p, 50%)); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 26px; height: 26px; border-radius: 50%; background: #eafff6; margin-top: -10px; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4), 0 0 0 4px rgba(47, 227, 160, 0.25); }
input[type=range]::-moz-range-track { height: 6px; border-radius: 4px; background: var(--card3); }
input[type=range]::-moz-range-thumb { width: 24px; height: 24px; border-radius: 50%; background: #eafff6; border: 0; }

.bar { height: 8px; border-radius: 6px; background: rgba(0, 0, 0, 0.3); overflow: hidden; border: 1px solid var(--line); }
.bar > i { display: block; height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--acc2), var(--acc)); transition: width 0.5s ease; }
.bar.warn > i { background: linear-gradient(90deg, #c99a3c, var(--warn)); }
.bar.bad > i { background: linear-gradient(90deg, #c94a43, var(--bad)); }

.pips { display: flex; gap: 4px; }
.pips i { width: 16px; height: 5px; border-radius: 3px; background: var(--card3); }
.pips i.on { background: var(--acc); box-shadow: 0 0 6px rgba(47, 227, 160, 0.5); }

.list { display: flex; flex-direction: column; }
.list .item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.list .item:last-child { border-bottom: 0; }
.item .ico { width: 38px; height: 38px; border-radius: 11px; background: var(--card3); display: grid; place-items: center; flex: none; font-size: 18px; }

.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table td { padding: 7px 0; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.table td:last-child { text-align: right; }
.table tr.total td { font-weight: 720; border-bottom: 0; padding-top: 10px; }

/* ---------- Сцены ---------- */
.scene { position: relative; border-radius: var(--r); overflow: hidden; border: 1px solid var(--line); background: #0a1a20; aspect-ratio: 400 / 250; box-shadow: 0 20px 40px -24px rgba(0, 0, 0, 0.8); }
.scene svg { display: block; width: 100%; height: 100%; }
.scene-hud { position: absolute; left: 10px; right: 10px; top: 10px; display: flex; justify-content: space-between; pointer-events: none; }
.scene-hud .chip { background: rgba(6, 16, 21, 0.72); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); color: var(--text); }
.scene-float { position: absolute; font-weight: 750; font-size: 13px; color: var(--acc); pointer-events: none; animation: floatUp 1.6s ease-out forwards; text-shadow: 0 1px 6px rgba(0, 0, 0, 0.8); }
@keyframes floatUp { from { opacity: 0; transform: translateY(4px); } 15% { opacity: 1; } to { opacity: 0; transform: translateY(-34px); } }

/* ---------- Таббар ---------- */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; padding: 6px 6px calc(6px + var(--safe-b)); background: rgba(8, 22, 28, 0.94); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-top: 1px solid var(--line); }
.tabbar button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 0 4px; color: var(--dim); font-size: 10.5px; font-weight: 600; border-radius: 12px; position: relative; transition: color 0.2s; }
.tabbar button svg { width: 24px; height: 24px; }
.tabbar button.on { color: var(--acc); }
.tabbar button.on::before { content: ""; position: absolute; top: -7px; width: 22px; height: 3px; border-radius: 0 0 3px 3px; background: var(--acc); box-shadow: 0 0 10px var(--acc); }
.tabbar .dot { position: absolute; top: 4px; right: calc(50% - 18px); width: 8px; height: 8px; border-radius: 50%; background: var(--bad); border: 2px solid var(--bg2); }

/* ---------- Шторка (bottom sheet) ---------- */
.sheet-wrap { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; background: rgba(2, 8, 10, 0.6); animation: fadeIn 0.2s ease; }
.sheet { width: 100%; max-height: 88vh; overflow-y: auto; background: linear-gradient(180deg, #102830, #0b1d23 120px); border-radius: 24px 24px 0 0; border-top: 1px solid var(--line2); padding: 8px 16px calc(18px + var(--safe-b)); animation: sheetIn 0.3s cubic-bezier(0.2, 0.9, 0.3, 1); }
.sheet .grip { width: 40px; height: 5px; border-radius: 3px; background: var(--card3); margin: 4px auto 12px; }
.sheet h2 { margin: 0 0 4px; font-size: 20px; letter-spacing: -0.02em; }
.sheet .lead { color: var(--muted); font-size: 13.5px; margin-bottom: 14px; }
.sheet-wrap.closing { animation: fadeOut 0.2s ease forwards; }
.sheet-wrap.closing .sheet { animation: sheetOut 0.2s ease forwards; }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes fadeOut { to { opacity: 0; } }
@keyframes sheetIn { from { transform: translateY(100%); } }
@keyframes sheetOut { to { transform: translateY(100%); } }

.opt { display: flex; gap: 12px; padding: 12px; border-radius: 16px; background: var(--card); border: 1px solid var(--line); margin-bottom: 10px; align-items: center; }
.opt.locked { opacity: 0.55; }
.opt .opt-art { width: 64px; height: 64px; border-radius: 12px; overflow: hidden; flex: none; background: #0a1a20; }
.opt .opt-art svg { width: 100%; height: 100%; }
.opt .meta { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 10px; font-size: 12px; color: var(--muted); margin-top: 4px; }
.opt .meta b { color: var(--text); font-weight: 620; }

/* ---------- Тосты ---------- */
.toasts { position: fixed; left: 12px; right: 12px; top: 12px; z-index: 80; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { padding: 12px 14px; border-radius: 14px; background: rgba(18, 42, 51, 0.97); border: 1px solid var(--line2); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5); font-size: 14px; animation: toastIn 0.3s ease; display: flex; gap: 10px; align-items: center; }
.toast.err { border-color: rgba(255, 122, 114, 0.4); }
.toast.ok { border-color: rgba(47, 227, 160, 0.4); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-10px); } }

/* ---------- Обучение ---------- */
.coach { position: fixed; left: 12px; right: 12px; bottom: calc(var(--tab-h) + var(--safe-b) + 12px); z-index: 40; background: linear-gradient(180deg, #164036, #0f2c27); border: 1px solid rgba(47, 227, 160, 0.35); border-radius: 18px; padding: 14px; box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55); animation: sheetIn 0.35s cubic-bezier(0.2, 0.9, 0.3, 1); }
.coach .t { font-weight: 700; margin-bottom: 4px; }
.coach .d { font-size: 13.5px; color: #b9d8cd; }
.coach .step { font-size: 11px; color: var(--acc); font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; margin-bottom: 4px; }
.pulse-target { position: relative; animation: targetPulse 1.6s ease-in-out infinite; }
@keyframes targetPulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(47, 227, 160, 0.0); } 50% { box-shadow: 0 0 0 6px rgba(47, 227, 160, 0.25); } }

/* ---------- Биржа ---------- */
.chart { width: 100%; height: 150px; display: block; }
.book { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.book .lvl { position: relative; display: flex; justify-content: space-between; padding: 4px 6px; border-radius: 6px; overflow: hidden; }
.book .lvl i { position: absolute; top: 0; bottom: 0; right: 0; opacity: 0.16; }
.book .bid i { background: var(--acc); }
.book .ask i { background: var(--bad); }
.book .lvl span { position: relative; }

.quest { display: flex; gap: 12px; align-items: center; }
.quest .q-ico { width: 42px; height: 42px; border-radius: 12px; background: var(--card3); display: grid; place-items: center; font-size: 20px; flex: none; }
.streak { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-top: 12px; }
.streak div { border-radius: 10px; padding: 7px 0; text-align: center; background: rgba(0, 0, 0, 0.2); border: 1px solid var(--line); font-size: 11px; color: var(--muted); }
.streak div.done { background: var(--acc-soft); border-color: rgba(47, 227, 160, 0.3); color: var(--acc); }
.streak div.today { border-color: var(--acc); }
.streak b { display: block; font-size: 12px; color: var(--text); }

.lb-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 14px; }
.lb-row.me { background: var(--acc-soft); border: 1px solid rgba(47, 227, 160, 0.25); }
.lb-row .rk { width: 28px; text-align: center; font-weight: 750; color: var(--muted); font-variant-numeric: tabular-nums; }
.lb-row .rk.top { color: var(--btc); }
.lb-row .avatar.gold { border: 2px solid #f0c060; box-shadow: 0 0 12px rgba(240, 192, 96, 0.5); }

.empty { text-align: center; color: var(--muted); padding: 22px 10px; font-size: 13.5px; }
.empty .big { font-size: 34px; margin-bottom: 6px; }

.spin { width: 18px; height: 18px; border: 2px solid rgba(255, 255, 255, 0.2); border-top-color: currentColor; border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (min-width: 560px) {
  .shell, .tabbar, .topbar { max-width: 520px; margin-left: auto; margin-right: auto; }
  .tabbar { border-radius: 18px 18px 0 0; }
}
