:root {
  --bg: #000;
  --card: #1C1C1E;
  --card2: #2C2C2E;
  --line: rgba(84, 84, 88, .45);
  --text: #F5F5F7;
  --muted: #98989F;
  --faint: #6E6E73;
  --green: #30D158;
  --red: #FF453A;
  --orange: #FF9F0A;
  --blue: #0A84FF;
  --purple: #BF5AF2;
  --teal: #64D2FF;
  --gap: 12px;
  --pad: 16px;
  --r: 20px;
  color-scheme: dark;
}
* { box-sizing: border-box; margin: 0; }
html, body { background: var(--bg); color: var(--text); }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, sans-serif;
  font-size: 15px; line-height: 1.3;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; text-align: left; padding: 0; }
.num { font-variant-numeric: tabular-nums; letter-spacing: -.02em; }

main {
  max-width: 600px; margin: 0 auto;
  padding: 8px var(--pad) calc(100px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 24px;
}
section { display: flex; flex-direction: column; gap: 10px; }

/* ---------- заголовки ---------- */
.top { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; padding-top: 8px; }
.top .over { font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .02em; }
.top h1 { font-size: 32px; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; margin-top: 2px; }
.icon-btn { flex: none; width: 40px; height: 40px; border-radius: 20px; background: var(--card); display: grid; place-items: center; color: var(--muted); }
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn.spin svg { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.sec-head { display: flex; align-items: baseline; justify-content: space-between; padding: 0 4px; }
.sec-head h2 { font-size: 20px; font-weight: 700; letter-spacing: -.01em; }
.sec-head .link { color: var(--blue); font-size: 15px; }
.sec-head .hint { color: var(--muted); font-size: 13px; }

/* ---------- карточки ---------- */
.card { background: var(--card); border-radius: var(--r); padding: var(--pad); display: flex; flex-direction: column; gap: 12px; }
.card.tight { gap: 4px; }
.label { font-size: 13px; font-weight: 600; color: var(--muted); }
.big { font-size: 34px; font-weight: 700; line-height: 1.05; }
.mid { font-size: 22px; font-weight: 700; line-height: 1.1; }
.sub { font-size: 13px; color: var(--muted); }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.green { color: var(--green); } .red { color: var(--red); } .orange { color: var(--orange); } .muted { color: var(--muted); } .blue { color: var(--blue); }

.chip { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 999px; white-space: nowrap; }
.chip.up { color: var(--green); background: rgba(48,209,88,.15); }
.chip.down { color: var(--red); background: rgba(255,69,58,.15); }
.chip.flat { color: var(--muted); background: var(--card2); }

.split { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap); }
.split > div { display: flex; flex-direction: column; gap: 2px; }
.split .v { font-size: 17px; font-weight: 600; }
.divider { height: 1px; background: var(--line); margin: 2px 0; }

/* сетка показателей 2×N */
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap); }
.tile { background: var(--card); border-radius: var(--r); padding: 14px var(--pad); display: flex; flex-direction: column; gap: 6px; min-height: 108px; }
.tile .head { display: flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 600; color: var(--muted); }
.tile .head i { width: 8px; height: 8px; border-radius: 4px; flex: none; }
.tile .v { font-size: 26px; font-weight: 700; line-height: 1.1; margin-top: auto; }
.tile .s { font-size: 12px; color: var(--muted); min-height: 15px; }

/* списки */
.list { background: var(--card); border-radius: var(--r); overflow: hidden; }
.li { display: flex; align-items: center; gap: 12px; padding: 12px var(--pad); min-height: 52px; width: 100%; position: relative; }
.li + .li::before { content: ""; position: absolute; top: 0; left: var(--pad); right: 0; height: 1px; background: var(--line); }
.li .body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.li .t { font-size: 15px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.li .d { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.li .end { font-size: 15px; font-weight: 600; white-space: nowrap; text-align: right; }
.li .end small { display: block; font-size: 12px; font-weight: 500; color: var(--muted); }
.li .chev { color: var(--faint); flex: none; }
.dot { flex: none; width: 9px; height: 9px; border-radius: 5px; }
.badge { flex: none; width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; font-size: 14px; font-weight: 700; color: #fff; }
.rank { flex: none; width: 22px; font-size: 14px; font-weight: 600; color: var(--faint); text-align: center; }
.alert-ic { flex: none; width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; }
.alert-ic svg { width: 18px; height: 18px; }
.alert-ic.bad { background: rgba(255,69,58,.18); color: var(--red); }
.alert-ic.warn { background: rgba(255,159,10,.18); color: var(--orange); }

/* полосы (топы, источники) */
.bar { height: 6px; border-radius: 3px; background: var(--card2); overflow: hidden; margin-top: 6px; }
.bar > div { height: 100%; border-radius: 3px; }

/* сегменты */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--card); border-radius: 10px; padding: 2px; }
.seg button { text-align: center; font-size: 13px; font-weight: 500; color: var(--muted); min-height: 32px; border-radius: 8px; }
.seg button.on { background: #3A3A3C; color: var(--text); font-weight: 600; }

/* графики */
.chart { width: 100%; display: block; overflow: visible; }
.axis { display: flex; justify-content: space-between; font-size: 11px; color: var(--faint); font-variant-numeric: tabular-nums; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 3px; border-radius: 2px; }

/* воронка */
.funnel { display: flex; flex-direction: column; gap: 10px; }
.fstep .row { font-size: 14px; }
.fstep .row b { font-weight: 600; }
.fstep .fbar { height: 26px; border-radius: 7px; background: var(--card2); overflow: hidden; margin-top: 5px; }
.fstep .fbar > div { height: 100%; border-radius: 7px; background: linear-gradient(90deg, #0A84FF, #64D2FF); min-width: 4px; }
.fstep .drop { font-size: 12px; color: var(--muted); margin-top: 3px; }

/* онлайн */
.pulse { flex: none; width: 44px; height: 44px; border-radius: 22px; background: rgba(48,209,88,.15); display: grid; place-items: center; }
.pulse span { width: 12px; height: 12px; border-radius: 6px; background: var(--green); animation: beat 2s ease-in-out infinite; }
@keyframes beat { 0%,100% { box-shadow: 0 0 0 0 rgba(48,209,88,.5); } 50% { box-shadow: 0 0 0 8px rgba(48,209,88,0); } }

/* кнопки */
.btn-primary { display: flex; align-items: center; justify-content: center; min-height: 48px; border-radius: 14px; background: var(--blue); color: #fff; font-size: 16px; font-weight: 600; text-decoration: none; margin-top: 4px; }
.mini-btn { align-self: flex-start; margin-top: 8px; min-height: 34px; padding: 0 14px; border-radius: 10px; font-size: 14px; font-weight: 600; }
.li .d { white-space: normal; }
.mini-btn.stop { background: rgba(255,69,58,.15); color: #FF6961; }
.mini-btn.go { background: rgba(48,209,88,.15); color: var(--green); }

/* назад, пустые состояния */
.back { display: inline-flex; align-items: center; gap: 2px; color: var(--blue); font-size: 17px; min-height: 40px; margin-bottom: -16px; align-self: flex-start; }
.back svg { width: 20px; height: 20px; }
.empty { text-align: center; padding: 28px 20px; color: var(--muted); line-height: 1.45; }
.empty b { display: block; color: var(--text); font-size: 17px; margin-bottom: 6px; }
.empty code { background: var(--card2); padding: 2px 6px; border-radius: 6px; color: var(--text); }
.note { font-size: 12px; color: var(--faint); text-align: center; padding: 0 12px; }

/* таббар */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  background: rgba(18,18,20,.88); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid var(--line);
}
.tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 48px; color: var(--faint); font-size: 10px; font-weight: 600; text-align: center; }
.tab svg { width: 24px; height: 24px; }
.tab.on { color: var(--blue); }

.toast { position: fixed; left: 50%; bottom: calc(80px + env(safe-area-inset-bottom)); transform: translate(-50%, 16px); opacity: 0;
  background: #3A3A3C; padding: 10px 16px; border-radius: 12px; font-size: 14px; transition: .25s; pointer-events: none; max-width: 90vw; text-align: center; z-index: 20; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.loader { display: grid; place-items: center; min-height: 60vh; }
.loader span { width: 26px; height: 26px; border-radius: 50%; border: 3px solid var(--card2); border-top-color: var(--blue); animation: spin .8s linear infinite; }
