:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --ink: #1b2026;
  --muted: #69717c;
  --line: #e2e5e9;
  --long: #d9f2dd;
  --long-ink: #1d6b35;
  --short: #fbdede;
  --short-ink: #a12d2d;
  --mix: #dbe7fa;
  --mix-ink: #2a5598;
  --plus: #2f9e55;
  --minus: #d64545;
  --flat: #b7bec7;
  --up: #1d7a3e;
  --down: #b83232;
  --radius: 10px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
.num, .eq, .d24, td.n { font-variant-numeric: tabular-nums; }

/* ---------- Шапка ---------- */
.top {
  position: sticky; top: 0; z-index: 5;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.top-in {
  max-width: 1400px; margin: 0 auto; padding: 12px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
h1 { margin: 0; font-size: 20px; letter-spacing: -0.01em; }
.status { color: var(--muted); font-size: 13px; margin-top: 2px; }
.status b { color: var(--ink); font-weight: 600; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; vertical-align: 1px; background: var(--flat); }
.dot.on { background: var(--plus); }
.dot.err { background: var(--minus); }

.pause {
  flex: none;
  font: 600 15px/1 inherit;
  padding: 12px 18px;
  border-radius: 999px;
  border: 0;
  cursor: pointer;
  background: var(--ink);
  color: #fff;
  min-width: 150px;
}
.pause.paused { background: var(--plus); }
.pause:hover { filter: brightness(1.12); }
.pause:disabled { opacity: 0.5; cursor: default; }

.banner {
  background: #fff4d6; color: #6b4e00; border-top: 1px solid #f0dfa8;
  padding: 10px 16px; text-align: center; font-size: 14px;
}

/* ---------- Панель управления ---------- */
main { max-width: 1400px; margin: 0 auto; padding: 16px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px; }
.lg { font-size: 12px; padding: 3px 9px; border-radius: 6px; border: 2px solid transparent; }
.lg.long { background: var(--long); }
.lg.short { background: var(--short); }
.lg.mix { background: var(--mix); }
.lg.frame { background: var(--card); }
.lg.plus { border-color: var(--plus); }
.lg.minus { border-color: var(--minus); }
.controls { display: flex; flex-wrap: wrap; gap: 8px; }
.controls input, .controls select {
  font: inherit; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--ink);
}
.controls input { width: 150px; }

/* ---------- Секции ---------- */
.market { margin-top: 18px; }
.sec-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
h2 { margin: 0; font-size: 18px; }
h2 small { color: var(--muted); font-weight: 400; font-size: 13px; margin-left: 6px; }
.sec-stats { color: var(--muted); font-size: 13px; display: flex; flex-wrap: wrap; gap: 4px 14px; }
.sec-stats b { color: var(--ink); font-weight: 600; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }

/* ---------- Кнопка бота ---------- */
.bot {
  position: relative;
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
  padding: 8px 10px 9px;
  border: 2px solid var(--flat);
  border-radius: var(--radius);
  font: inherit; color: inherit; text-align: left;
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
  min-width: 0;
}
.bot:hover { transform: translateY(-1px); box-shadow: 0 3px 10px rgba(20, 30, 40, 0.1); }
.bot:focus-visible { outline: 3px solid #4a7fd6; outline-offset: 2px; }
.bot.long { background: var(--long); }
.bot.short { background: var(--short); }
.bot.mix { background: var(--mix); }
.bot.plus { border-color: var(--plus); }
.bot.minus { border-color: var(--minus); }
.bot .nm { font-weight: 650; font-size: 15px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-right: 22px; }
.bot .eq { font-size: 15px; }
.bot .d24 { font-size: 12px; color: var(--muted); }
.bot .d24.up { color: var(--up); }
.bot .d24.down { color: var(--down); }
.bot .op {
  position: absolute; top: 7px; right: 8px;
  font-size: 11px; font-weight: 600; line-height: 18px; min-width: 18px; text-align: center;
  border-radius: 9px; background: rgba(0, 0, 0, 0.08); padding: 0 5px;
}
.bot .ic { font-size: 12px; font-weight: 400; }
.empty { color: var(--muted); padding: 10px 0; }
.about details summary { cursor: pointer; }
.about .pool { margin-top: 6px; color: var(--muted); font-size: 12.5px; line-height: 1.6; }

.foot { color: var(--muted); font-size: 12px; margin: 28px 0 8px; max-width: 900px; }

/* ---------- Окно бота ---------- */
dialog {
  width: min(920px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  padding: 0; border: 0; border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
  background: var(--card); color: var(--ink);
}
dialog::backdrop { background: rgba(20, 25, 30, 0.45); }
.dlg-in { padding: 20px 22px 24px; }
.d-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.d-head h3 { margin: 0; font-size: 22px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chip { font-size: 12px; padding: 2px 8px; border-radius: 6px; background: #eef0f3; color: var(--muted); }
.chip.long { background: var(--long); color: var(--long-ink); }
.chip.short { background: var(--short); color: var(--short-ink); }
.chip.mix { background: var(--mix); color: var(--mix-ink); }
.x { border: 0; background: #eef0f3; border-radius: 50%; width: 34px; height: 34px; font-size: 18px; cursor: pointer; flex: none; color: var(--ink); }
.x:hover { background: #e2e5e9; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; margin: 16px 0 6px; }
.kpi { background: #f6f7f9; border-radius: 10px; padding: 10px 12px; }
.kpi .k { color: var(--muted); font-size: 12px; }
.kpi .v { font-size: 18px; font-weight: 650; margin-top: 2px; }
.up { color: var(--up); }
.down { color: var(--down); }

.spark { width: 100%; height: 70px; display: block; margin: 8px 0 2px; }
.spark-cap { color: var(--muted); font-size: 12px; display: flex; justify-content: space-between; }

.about { background: #f6f7f9; border-radius: 10px; padding: 12px 14px; margin-top: 14px; font-size: 13.5px; }
.about p { margin: 0 0 6px; }
.about p:last-child { margin: 0; }
.about b { font-weight: 600; }

h4 { margin: 22px 0 8px; font-size: 15px; }
h4 small { color: var(--muted); font-weight: 400; }

.trade { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; }
.trade.open { border-color: #c9d6ea; background: #fbfcfe; }
.t-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.t-sym { font-weight: 650; font-size: 15px; }
.side { font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 5px; margin-right: 6px; vertical-align: 1px; letter-spacing: 0.02em; }
.side.long { background: var(--long); color: var(--long-ink); }
.side.short { background: var(--short); color: var(--short-ink); }
.t-pnl { font-weight: 650; font-size: 15px; }
.t-pnl small { font-weight: 400; color: var(--muted); }
.t-ops { display: flex; flex-wrap: wrap; gap: 4px 18px; margin: 6px 0 4px; font-size: 13px; }
.t-ops span { white-space: nowrap; }
.t-ops .lbl { color: var(--muted); }
.why { font-size: 13px; color: #3a424c; margin-top: 4px; }
.why b { color: var(--muted); font-weight: 600; }
.cost { font-size: 12px; color: var(--muted); margin-top: 4px; }
.notes { font-size: 13px; color: #3a424c; padding-left: 18px; margin: 0; }
.notes li { margin-bottom: 4px; }
.notes time { color: var(--muted); font-size: 12px; margin-right: 6px; }
.costs-tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.costs-tbl td { padding: 4px 0; border-bottom: 1px solid var(--line); }
.costs-tbl td.n { text-align: right; }

@media (max-width: 600px) {
  .top-in { padding: 10px 16px; }
  h1 { font-size: 17px; }
  .pause { min-width: 0; padding: 10px 14px; font-size: 14px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 6px; }
  .controls input { width: 120px; }
  .dlg-in { padding: 16px; }
}
