:root {
  --bg: #0d1117;
  --card: #161b22;
  --card2: #1c232d;
  --line: #2a323d;
  --text: #e6edf3;
  --muted: #8b949e;
  --green: #3fb950;
  --red: #f85149;
  --yellow: #d29922;
  --blue: #58a6ff;
  --violet: #bc8cff;
  --cyan: #39c5cf;
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 15px/1.4 -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  padding: 0 12px calc(24px + env(safe-area-inset-bottom));
  -webkit-text-size-adjust: 100%;
}
.num, td.r, .kv b { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.pos { color: var(--green); }
.neg { color: var(--red); }

/* --- шапка --- */
.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 2px 10px; background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.top-title { font-size: 12px; color: var(--muted); letter-spacing: .04em; }
.top-price { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.top-right { text-align: right; }
.live { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); display: inline-block; flex: none; }
.live.ok .dot { background: var(--green); box-shadow: 0 0 0 3px rgba(63,185,80,.18); }
.live.bad .dot, .dot.bad { background: var(--red); }
.dot.ok { background: var(--green); }
.dot.warn { background: var(--yellow); }

.notice {
  margin: 12px 0 0; padding: 10px 12px; border-radius: var(--radius);
  background: rgba(248,81,73,.12); border: 1px solid rgba(248,81,73,.4); color: #ffb3ad;
}

/* --- вкладки ботов --- */
.tabs { display: flex; gap: 6px; margin: 14px 0 12px; background: var(--card); padding: 4px; border-radius: 12px; }
.tab {
  flex: 1; border: 0; border-radius: 9px; padding: 10px 6px; font: inherit; font-weight: 600;
  color: var(--muted); background: transparent; cursor: pointer; min-height: 44px;
}
.tab.active { background: var(--card2); color: var(--text); box-shadow: inset 0 0 0 1px var(--line); }
.tab:focus-visible, .more:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

/* --- карточки --- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; }
.card-head h3 { margin: 0; font-size: 16px; }
.state { font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: var(--card2); color: var(--muted); }
.state.in { background: rgba(63,185,80,.15); color: var(--green); }
.state.ready { background: rgba(210,153,34,.15); color: var(--yellow); }
.state.down { background: rgba(248,81,73,.15); color: var(--red); }

.balance { font-size: 30px; font-weight: 800; font-variant-numeric: tabular-nums; }
.balance-sub { margin-top: 2px; }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.kv { background: var(--card2); border-radius: 10px; padding: 9px 10px; }
.kv span { display: block; font-size: 12px; color: var(--muted); }
.kv b { font-size: 16px; }

/* --- открытая позиция --- */
.position { border-color: rgba(88,166,255,.45); }
.position.none { border-style: dashed; color: var(--muted); text-align: center; padding: 16px; }
.dir { font-weight: 800; font-size: 12px; padding: 2px 7px; border-radius: 6px; }
.dir.LONG { background: rgba(63,185,80,.18); color: var(--green); }
.dir.SHORT { background: rgba(248,81,73,.18); color: var(--red); }
.pos-pnl { font-size: 28px; font-weight: 800; font-variant-numeric: tabular-nums; }

/* --- таблица сделок --- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -14px; padding: 0 14px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
caption { text-align: left; font-weight: 700; font-size: 15px; padding-bottom: 8px; }
th { text-align: left; color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase;
     letter-spacing: .03em; padding: 6px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
td.r, th.r { text-align: right; white-space: nowrap; }
td.t { white-space: nowrap; }
td.t .d { display: block; color: var(--muted); font-size: 11px; }
.reason { display: inline-block; font-size: 12px; padding: 2px 7px; border-radius: 6px; background: var(--card2); white-space: nowrap; }
.reason.flip { color: var(--blue); }
.reason.signal { color: var(--cyan); }
.reason.stop { color: var(--yellow); }
.reason.profit { color: var(--green); }
.reason.shutdown { color: var(--red); }
.reason.time { color: var(--violet); }
.empty { text-align: center; color: var(--muted); padding: 18px 0; }
.more { width: 100%; margin-top: 10px; min-height: 44px; border: 1px solid var(--line); border-radius: 10px;
        background: var(--card2); color: var(--text); font: inherit; cursor: pointer; }

/* --- техника --- */
.block h2 { font-size: 16px; margin: 20px 0 10px; display: flex; align-items: center; gap: 8px; }
.badge { font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.badge.ok { background: rgba(63,185,80,.15); color: var(--green); }
.badge.bad { background: rgba(248,81,73,.15); color: var(--red); }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.list li:last-child { border-bottom: 0; }
.list .name { flex: 1; min-width: 0; }
.list .val { color: var(--muted); font-size: 12px; text-align: right; font-variant-numeric: tabular-nums; }
.meter { height: 6px; background: var(--card2); border-radius: 4px; overflow: hidden; margin-top: 6px; }
.meter i { display: block; height: 100%; background: var(--green); width: 0; }
.meter i.warn { background: var(--yellow); }
.meter i.bad { background: var(--red); }
.foot { text-align: center; margin-top: 16px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@media (min-width: 560px) {
  .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  body { max-width: 760px; margin: 0 auto; }
}
