/*
 * Монитор повторяет макет шириной 1672 пикселя (окно от 1672px).
 * Все размеры и цвета сняты с макета. График — отдельной строкой во всю
 * ширину, поэтому страница выше экрана и прокручивается. Ниже 1672px —
 * адаптивная раскладка (блок @media в конце файла).
 */

:root {
  --bg: #06101a;
  --card: #09131e;
  --card-top: #0b1622;
  --card-border: #182533;
  --sub: #0b1824;
  --sub-border: #17232f;
  --stat: #0c1a29;
  --stat-border: #1a2833;
  --th: #111c29;
  --line: #141f2c;

  --text: #f6fbff;
  --text-2: #d8e0ee;
  --label: #aab9d0;
  --label-2: #c7d1eb;
  --muted: #96a4bd;
  --dim: #8792a9;

  --green: #3fe39a;
  --green-dot: #3eeb88;
  --green-bg: #0e3a2c;
  --red: #f2485f;
  --amber: #f59e0b;
  --blue: #3b82f6;
  --sky: #31b1f8;
  --violet: #a05efb;
  --violet-2: #8d83fb;

  --radius: 10px;

  /* Единая система отступов внутри карточек */
  --pad: 16px;        /* поле карточки слева, справа, снизу */
  --pad-top: 14px;    /* поле карточки сверху */
  --gap: 12px;        /* заголовок -> содержимое, между блоками */
  --sub-y: 12px;      /* подкарточки: сверху и снизу */
  --sub-x: 14px;      /* подкарточки: слева и справа */
  --sans: Inter, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }

/* Полосы прокрутки скрыты везде; прокрутка колесом, тачпадом и пальцем работает */
* { scrollbar-width: none; -ms-overflow-style: none; }
*::-webkit-scrollbar { display: none; width: 0; height: 0; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.4 var(--sans);
  -webkit-font-smoothing: antialiased;
}

h1, h2, p { margin: 0; }
.green { color: var(--green); }
.red { color: var(--red); }
.muted { color: var(--muted); }
.center { text-align: center; }
.strong { font-weight: 600; }
.violet-text { color: var(--violet); }

svg { fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
svg .fill { fill: currentColor; stroke: none; }
svg .cut { stroke: var(--card); stroke-width: 1.8; }

/* ================= страница шириной 1672 ================= */

.page { width: 1672px; margin: 0 auto; }

/* ---------- шапка: 0–93 ---------- */

.topbar {
  height: 93px;
  display: flex;
  align-items: flex-start;
  padding: 12px 13px 0 12px;
}

.brand { display: flex; align-items: flex-start; gap: 16px; padding: 5px 0 0 5px; }

/* логотип — тот же значок, что и фавикон (logo.png, 104px для Retina) */
.logo {
  display: block; width: 52px; height: 52px; flex: none;
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(251, 120, 9, 0.12), 0 0 20px rgba(251, 110, 9, 0.35);
}

h1 { font-size: 28px; line-height: 34px; font-weight: 700; letter-spacing: -0.2px; margin-top: -3px; }
.subtitle { font-size: 15px; line-height: 20px; color: #a2adc1; margin-top: 5px; display: flex; align-items: center; gap: 10px; }
.logout { display: inline; margin: 0; }
.logout button {
  background: none; border: 0; padding: 0;
  font: inherit; font-size: 13px; color: var(--dim);
  cursor: pointer; text-decoration: underline; text-underline-offset: 3px;
}
.logout button:hover { color: var(--text); }

.chips { display: flex; gap: 10px; margin-left: auto; }

.chip {
  height: 66px;
  display: flex; align-items: center; gap: 14px;
  padding: 0 14px;
  background: #0b1725;
  border: 1px solid #15202c;
  border-radius: var(--radius);
}
/* Ширина по длине пары (WLDUSDT, 1000PEPEUSDT …), не уже 150px */
.chip-symbol { width: auto; min-width: 150px; }
.chip-symbol b { overflow: visible; }
.chip-mode { width: 133px; }
.chip-phase { width: 179px; }
.chip-clock { width: 362px; }

.chip-label { display: block; font-size: 13px; line-height: 17px; color: var(--muted); }
.chip b { display: block; font-size: 16px; line-height: 22px; font-weight: 700; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip > div { min-width: 0; }

.coin {
  width: 26px; height: 26px; flex: none; border-radius: 50%;
  display: grid; place-items: center;
  background: #fb8c09; color: #fff;
}
.coin svg { width: 17px; height: 17px; stroke-width: 1.9; }

.chip-icon { width: 27px; height: 27px; flex: none; }
.flask { color: #2c8cf4; }
.doc { color: #56657e; }
.layers { color: #7c5cf7; }
.clock { color: #c3cde0; width: 26px; height: 26px; }

.grow { flex: 1; }
.countdown-row { display: flex; align-items: center; gap: 22px; }
.chip b.countdown { font-size: 24px; line-height: 28px; margin-top: 0; font-variant-numeric: tabular-nums; }
.progress { flex: 1; height: 7px; border-radius: 4px; background: #1c2b3f; overflow: hidden; }
.progress div {
  height: 100%; width: 0; border-radius: 4px;
  background: linear-gradient(90deg, #1d54f8, #483cf8 45%, #7473f9);
  transition: width 0.3s linear;
}

/* ---------- сетка рядов ---------- */

main { padding: 0 13px 5px 12px; position: relative; }

/* ---------- данные устарели ---------- */

body.stale main > .row, body.stale .chips { opacity: 0.35; filter: grayscale(0.7); transition: opacity 0.3s; }
body.stale .card-stats { pointer-events: none; }
.stale-banner {
  position: absolute; z-index: 20; top: 110px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 14px;
  padding: 14px 22px; border-radius: 12px;
  background: #2a1016; border: 1px solid #7f1d2d; color: #fecdd3;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
  white-space: nowrap;
}
.stale-banner.off { background: #2a1d0b; border-color: #7a4d0f; color: #fde6b8; }
.stale-banner svg { width: 26px; height: 26px; flex: none; stroke-width: 2; }
.stale-banner b { display: block; font-size: 16px; }
.stale-banner span { display: block; font-size: 13px; opacity: 0.85; margin-top: 2px; }
body:not(.stale) .stale-banner { display: none; }
.row { display: grid; }
.row-1 { height: 308px; grid-template-columns: 880px 390px 353px; column-gap: 12px; }
/* высота — по содержимому: график 330px + строки открытых сделок */
.row-chart { margin-top: 10px; grid-template-columns: 1fr; }
.row-2 { height: 284px; margin-top: 10px; grid-template-columns: 1220px 419px; column-gap: 8px; }
.row-3 { height: 229px; margin-top: 12px; grid-template-columns: 908px 732px; column-gap: 7px; }

.card {
  position: relative;
  display: flex; flex-direction: column;
  min-width: 0; overflow: hidden;
  background: linear-gradient(180deg, var(--card-top), var(--card) 40%);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: var(--pad-top) var(--pad) var(--pad);
  gap: var(--gap);
}

.card-head { height: 28px; flex: none; display: flex; align-items: center; gap: 10px; }
.card-head h2 { font-size: 19px; line-height: 24px; font-weight: 700; white-space: nowrap; margin: 0; }
.card-status h2 { font-size: 20px; }
.card-conn h2 { font-size: 18px; }

.h-ico {
  width: 28px; height: 28px; flex: none; border-radius: 7px;
  display: grid; place-items: center;
}
.h-ico svg { width: 19px; height: 19px; }
.h-ico.blue { background: #0e2c4f; color: var(--sky); }
.h-ico.green { background: #0a3327; color: var(--green); }
.h-ico.amber { background: #362721; color: var(--amber); }
.h-ico.violet { background: #16176a; color: #8b8cff; }
.h-ico.gear { background: #0b2440; color: #3b9cf6; }

.head-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.head-note { margin-left: auto; font-size: 14px; color: #aab5c5; }

.subcard {
  padding: var(--sub-y) var(--sub-x);
  background: var(--sub);
  border: 1px solid var(--sub-border);
  border-radius: 8px;
}
.subcard-title { font-size: 14px; line-height: 18px; color: #dfe7fe; }

/* ---------- ключ-значение ---------- */

.kv { display: grid; margin: 0; align-content: start; }
.kv dt { color: var(--label); white-space: nowrap; }
.kv dd { margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kv dd.green { color: var(--green); }
.kv dd.red { color: var(--red); }

.pill {
  display: inline-block;
  height: 24px; line-height: 24px;
  padding: 0 13px;
  border-radius: 6px;
  background: #271772;
  border: 1px solid #3a2a9a;
  color: #c7b8ff;
  font-size: 15px; font-weight: 600;
}

.badge {
  display: inline-block;
  height: 26px; line-height: 24px;
  padding: 0 10px;
  border-radius: 6px;
  font-size: 14px; font-weight: 600;
  background: #111c29; color: var(--muted);
  border: 1px solid var(--sub-border);
}
.badge.open { background: var(--green-bg); color: #91f3ba; border-color: #1f6b4c; }
.badge-lg { padding: 0 20px; }

.dot { width: 10px; height: 10px; border-radius: 50%; background: #3a475c; }
.dot.on { background: var(--green-dot); box-shadow: 0 0 8px rgba(62, 235, 136, 0.7); }

.status { display: inline-flex; align-items: center; gap: 9px; font-size: 14px; color: var(--muted); margin-left: 16px; }
.status i { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.status.ok { color: #7fe3a6; }
.status.ok i { background: var(--green-dot); box-shadow: 0 0 8px rgba(62, 235, 136, 0.7); }
.status.bad { color: var(--red); }
.status.bad i { background: var(--red); box-shadow: 0 0 8px var(--red); }
.status.off { color: var(--amber); }
.status.off i { background: var(--amber); }

/* ---------- текущий статус (719 × 308) ---------- */

.status-grid { display: grid; grid-template-columns: minmax(0, 1fr) 440px; column-gap: var(--gap); flex: 1; min-height: 0; }

/* Колонка подписей не уже макетной и не уже самой длинной подписи —
   значение никогда не наезжает на «До закрытия свечи:» */
.kv-status { grid-template-columns: minmax(140px, max-content) minmax(0, 1fr); column-gap: 12px; font-size: 15px; }
.kv-status dt, .kv-status dd { line-height: 26px; }
.kv-status dd { font-weight: 600; color: var(--text); }
.kv-status dt.lead { color: var(--label-2); font-size: 15.5px; }
.kv-status dt.lead, .kv-status dt.lead + dd, .kv-status dd.big, .kv-status dd.big + dt { line-height: 29px; }
.kv-status dd.big { font-size: 17px; font-weight: 700; }
#s-sell, #s-buy { font-size: 16.5px; }

.status-side { display: flex; flex-direction: column; gap: var(--gap); }

.phases-box { flex: none; }
.phases { list-style: none; margin: var(--gap) 0 0; padding: 0; display: grid; grid-template-columns: repeat(4, 1fr); position: relative; }
.phases::before {
  content: ""; position: absolute; left: 12.5%; right: 12.5%; top: 11px;
  height: 2px; background: #404d6f;
}
.phases li { position: relative; display: grid; justify-items: center; gap: 12px; }
.phases li span { font-size: 15px; line-height: 20px; color: #d9e3f6; }
.phases i {
  width: 22px; height: 22px; border-radius: 50%;
  background: radial-gradient(circle, #c3cde0 0 2px, #2c3a52 3px);
  border: 1px solid #3b4966;
}
.phases li.active span { color: #eae1ff; font-weight: 700; }
.phases li.active i {
  background: radial-gradient(circle at 40% 35%, #e9e6ff, #a9a3ff 45%, #6d5cf5);
  border-color: transparent;
  box-shadow: 0 0 0 5px rgba(109, 92, 245, 0.18), 0 0 18px 4px rgba(109, 92, 245, 0.55);
}

.deviation { padding: 0 var(--sub-x); }
.dev-track {
  position: relative; height: 4px; margin: 16px 3px 14px;
  border-radius: 2px;
  background: linear-gradient(90deg, #db455e, #bf404f 25%, #7b859b 42%, #7b859b 58%, #93374b 80%, #db455e);
}
.dev-track::before, .dev-track::after {
  content: ""; position: absolute; top: -5px; width: 4px; height: 14px; border-radius: 2px; background: #e5475f;
}
.dev-track::before { left: -2px; }
.dev-track::after { right: -2px; }
.dev-track i {
  position: absolute; top: -6px; left: 50%; width: 6px; height: 16px;
  margin-left: -3px; border-radius: 2px; background: #fff; transition: left 0.4s;
}
.dev-labels { display: grid; grid-template-columns: 1fr 1fr 1fr; }
.dev-labels div { display: grid; }
.dev-labels b { font-size: 14.5px; line-height: 19px; font-weight: 600; }
.dev-labels b:not(.red) { color: var(--text); }
.dev-labels small { font-size: 13px; line-height: 18px; color: #a8b3c6; }
.dev-labels small.red { color: var(--red); }
.dev-labels .center { text-align: center; }
.dev-labels .right { text-align: right; }

/* ---------- позиция (390 × 308) ---------- */

.kv-position { grid-template-columns: minmax(125px, max-content) minmax(0, 1fr); column-gap: var(--gap); font-size: 15px; }
.kv-position dt, .kv-position dd { line-height: 26px; }
/* значения прижаты вправо — по правому краю бейджа «нет» / «открыта» */
.kv-position dd { font-weight: 600; color: var(--text); font-size: 15.5px; text-align: right; }

/* Текст слева, мини-график — правая половина блока, без наложения */
.pnl {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 50%;
  grid-template-rows: auto auto 1fr;
  column-gap: var(--gap);
  /* размер и место как раньше (91px, прижат к низу карточки), хотя строк выше стало меньше */
  flex: none; height: 91px; margin-top: auto;
  background: linear-gradient(135deg, #15202e, #0e1f29);
  border-color: #1c2733;
}
.pnl .subcard-title, .pnl-value, .pnl-pct { grid-column: 1; min-width: 0; }
.pnl-value { font-size: 22px; line-height: 28px; font-weight: 700; margin-top: 0; min-height: 28px; white-space: nowrap; overflow: hidden; }
.pnl-pct { font-size: 15px; line-height: 18px; color: #7ee0b3; }
.pnl-pct.red { color: var(--red); }
/* Фиксированный CSS-размер canvas обязателен: пиксели считаются от
   clientWidth, без него размер растёт на экранах с devicePixelRatio > 1 */
.spark { display: block; }
/* во всю высоту блока: 91px минус рамка (2px) и поля subcard */
.spark-pnl { grid-column: 2; grid-row: 1 / -1; align-self: center; width: 100%; height: calc(89px - 2 * var(--sub-y)); }

/* ---------- состояние связи (248 × 308) ---------- */

.conn { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--gap); }
.conn li {
  display: grid; grid-template-columns: 26px minmax(0, 1fr) auto;
  grid-template-areas: "icon title flag" "icon note note";
  column-gap: 10px; align-items: start;
}
.conn-icon { grid-area: icon; }
.conn-title { grid-area: title; }
.ok-flag { grid-area: flag; }
.conn-note { grid-area: note; }
.conn-icon {
  width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center;
  background: #173d2c; color: #61c686; margin-top: 1px;
}
.conn-icon.grey { background: #1b2433; color: #909fb5; }
.conn-icon svg { width: 16px; height: 16px; }
.conn-title { font-size: 13.5px; line-height: 19px; font-weight: 500; color: #e3eafc; }
.conn-note { font-size: 12.5px; line-height: 16px; color: var(--dim); margin-top: 2px; }
.ok-flag { font-size: 15px; line-height: 20px; font-weight: 700; display: inline-flex; align-items: center; gap: 9px; white-space: nowrap; }
.ok-flag::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: #56627a; }
.ok-flag.ok { color: #6ff0a8; }
.ok-flag.ok::before { background: var(--green-dot); box-shadow: 0 0 8px rgba(62, 235, 136, 0.6); }
.ok-flag.bad { color: var(--red); }
.ok-flag.bad::before { background: var(--red); }
.ok-flag.none { color: #c5d1e9; font-weight: 500; }
.conn-foot {
  margin-top: auto; padding-top: var(--gap);
  border-top: 1px solid var(--line);
  display: flex; flex-wrap: wrap; align-items: center; gap: 2px 7px;
  font-size: 11px; letter-spacing: -0.1px; color: #abb4ca; white-space: nowrap;
}
.conn-foot span + span { padding-left: 7px; border-left: 1px solid #2a3647; }
.conn-foot b { font-weight: 500; color: #abb4ca; }
.conn-foot i { display: none; }

/* ---------- график (во всю ширину, 1647 × 420) ---------- */

.chart-ico { width: 22px; height: 22px; color: #c3cde0; }
.chart-card h2 { font-size: 16px; }
/* выбор монеты на графике (когда в SYMBOLS больше одной) */
.chart-card h2[hidden], .coin-btn[hidden], .coin-menu[hidden] { display: none; }
.coin-pick { position: relative; min-width: 0; }
.coin-btn {
  position: relative; display: flex; align-items: center; gap: 6px;
  height: 28px; padding: 0 8px 0 10px; max-width: 170px;
  background: #0b1725; color: var(--text);
  border: 1px solid #1c2b3d; border-radius: 7px;
  font: inherit; font-size: 16px; font-weight: 600; cursor: pointer;
}
.coin-btn:hover, .coin-btn[aria-expanded="true"] { border-color: #3a5474; background: #13243a; }
.coin-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.coin-btn svg { width: 16px; height: 16px; flex: none; fill: none; stroke: #abb4ca; stroke-width: 2; }
/* зелёная точка — по монете открыта позиция */
.coin-btn.open { padding-left: 22px; }
.coin-btn.open::before, .menu-item.open .menu-name::before {
  content: ""; position: absolute; left: 9px; top: 50%;
  width: 6px; height: 6px; margin-top: -3px; border-radius: 50%;
  background: var(--green);
}
.coin-menu {
  position: fixed; z-index: 50;
  width: 230px; padding: 8px;
  background: #0d1a2a; border: 1px solid #2a3c55; border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
}
#chart-search {
  width: 100%; height: 32px; padding: 0 10px;
  background: #0b1725; color: var(--text);
  border: 1px solid #1c2b3d; border-radius: 7px;
  font: inherit; font-size: 14px; outline: none;
}
#chart-search:focus { border-color: #3a5474; }
#chart-list {
  list-style: none; margin: 6px 0 0; padding: 0;
  max-height: 264px; overflow-y: auto; scrollbar-width: none;
}
#chart-list::-webkit-scrollbar { display: none; }
.menu-item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  height: 32px; padding: 0 10px; border-radius: 6px;
  font-size: 14px; color: #c5d1e9; cursor: pointer;
}
.menu-item:hover { background: #13243a; color: var(--text); }
.menu-item.active { background: #1a3150; color: var(--text); }
.menu-name { position: relative; font-weight: 600; }
.menu-item.open .menu-name { padding-left: 14px; }
.menu-item.open .menu-name::before { left: 0; }
.menu-item.auto { border-bottom: 1px solid var(--line); border-radius: 6px 6px 0 0; margin-bottom: 4px; }
.menu-note { font-size: 12px; color: #7f8aa3; white-space: nowrap; }
.menu-item.open .menu-note { color: var(--green); }
.menu-empty { padding: 10px; font-size: 13px; color: #7f8aa3; }
/* метка выбранной монеты в заголовках карточек */
.coin-tag {
  margin-left: 10px; padding: 2px 8px; vertical-align: 2px;
  border: 1px solid #2a3c55; border-radius: 6px; background: #13243a;
  font-size: 13px; font-weight: 600; color: #c5d1e9;
}
.coin-tag[hidden] { display: none; }
.menu-count { padding: 6px 10px 0; border-top: 1px solid var(--line); margin-top: 4px; font-size: 12px; color: #7f8aa3; }
select {
  margin-left: auto;
  width: 64px; height: 28px;
  background: #0b1725; color: var(--text);
  border: 1px solid #1c2b3d; border-radius: 7px;
  padding: 0 8px; font: inherit; font-size: 14px;
}
.price-line { display: flex; align-items: baseline; gap: var(--gap); }
.price-line b { font-size: 24px; line-height: 30px; font-weight: 700; }
#chart-change { font-size: 16px; color: #61deb7; }
#chart-change.red { color: var(--red); }
.chart-wrap { position: relative; flex: none; height: 330px; }

/* открытые сделки под графиком: клик — эта монета на всей странице */
.open-trades { margin-top: var(--gap); border-top: 1px solid var(--line); padding-top: 10px; }
.ot-head { display: flex; align-items: baseline; gap: 10px; font-size: 14px; color: var(--label); margin-bottom: 6px; }
.ot-head b { font-weight: 600; color: var(--text); }
#ot-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.ot-row {
  display: grid; align-items: center; column-gap: 16px;
  grid-template-columns: 150px 70px 150px 170px 150px minmax(0, 1fr) 20px;
  height: 36px; padding: 0 12px; border-radius: 8px;
  background: var(--sub); border: 1px solid var(--sub-border);
  font-size: 14px; font-variant-numeric: tabular-nums; cursor: pointer;
}
.ot-row:hover { border-color: #2a3c55; background: #0f1f30; }
.ot-row.active { border-color: #3a5474; background: #13243a; }
.ot-row:focus-visible { outline: 2px solid #3a5474; outline-offset: 1px; }
.ot-coin { position: relative; padding-left: 14px; font-weight: 700; }
.ot-coin::before {
  content: ""; position: absolute; left: 0; top: 50%;
  width: 6px; height: 6px; margin-top: -3px; border-radius: 50%; background: var(--green);
}
.ot-row span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ot-row .muted-label { font-style: normal; color: var(--muted); margin-right: 6px; }
.ot-side { font-weight: 600; }
.ot-pnl { text-align: right; font-weight: 700; }
.ot-go { color: var(--muted); text-align: right; }
.ot-empty { height: 36px; display: flex; align-items: center; padding: 0 12px; font-size: 14px; color: var(--muted); }
#chart { position: absolute; inset: 0; width: 100%; height: 100%; }

/* ---------- сделки (1220 × 284) ---------- */

.card-trades h2 { font-size: 18px; }
.table-wrap { flex: 1; min-height: 0; overflow: auto; }
.trades { width: 100%; border-collapse: separate; border-spacing: 0; table-layout: fixed; font-size: 14px; font-variant-numeric: tabular-nums; }
.trades th:nth-child(1) { width: 139px; }
.trades th:nth-child(2) { width: 100px; }
.trades th:nth-child(3) { width: 80px; }
.trades th:nth-child(4) { width: 96px; }
.trades th:nth-child(5) { width: 116px; }
.trades th:nth-child(6) { width: 96px; }
.trades th:nth-child(7) { width: 116px; }
.trades th:nth-child(8) { width: 96px; }
.trades th:nth-child(9) { width: 110px; }
.trades th:nth-child(10) { width: 96px; }
.trades td.pair { color: #d4dff6; font-weight: 600; }
/* таблица внутри дня: свои ширины колонок (ниже, есть «Порог входа») */
.trades th {
  position: sticky; top: 0; z-index: 1;
  height: 30px;
  background: var(--th);
  color: #d4dff6; font-weight: 400; text-align: center;
  border-left: 1px solid #1c2837;
  white-space: nowrap;
}
.trades th:first-child { border-left: 0; border-radius: 6px 0 0 6px; text-align: left; padding-left: var(--sub-x); }
.trades th:last-child { border-radius: 0 6px 6px 0; }
.trades td {
  height: 28px; text-align: center; white-space: nowrap;
  border-bottom: 1px solid var(--line);
  color: #c0c7dc;
}
.trades td:first-child { text-align: left; padding-left: var(--sub-x); color: #bfc8de; }
.trades td.side, .trades td.px, .trades td.same { font-weight: 700; }
.trades td.px { color: #f7fcff; }
.trades td.green { color: var(--green); }
.trades td.red { color: var(--red); }

/* ---------- статистика (419 × 284) ---------- */

.stats {
  display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr;
  gap: var(--gap); flex: 1; min-height: 0;
}
.stat {
  position: relative;
  background: var(--stat);
  border: 1px solid var(--stat-border);
  border-radius: 8px;
  padding: var(--sub-y) var(--sub-x);
}
.stat-label { display: block; font-size: 14px; line-height: 18px; color: #a7b3cd; }
.stat b { display: block; font-size: 24px; line-height: 30px; font-weight: 700; margin-top: 3px; white-space: nowrap; overflow: hidden; }
.stat-dot { display: block; width: 3px; height: 3px; border-radius: 50%; background: #56627a; margin: 6px 0 0 2px; }
.spark-stat { position: absolute; right: var(--sub-x); bottom: var(--sub-y); width: 76px; height: 34px; }
.spark-wide { position: absolute; left: var(--sub-x); bottom: var(--sub-y); width: calc(100% - 2 * var(--sub-x)); height: 26px; }

/* ---------- статистика по дням и месяцам ---------- */

.card-stats { cursor: pointer; transition: border-color 0.15s; }
.card-stats:hover, .card-stats:focus-visible { border-color: #2c3d55; outline: none; }
.expand-btn {
  margin-left: auto; width: 28px; height: 28px; border-radius: 7px;
  display: grid; place-items: center; color: var(--muted);
  background: #111c29; border: 1px solid var(--sub-border);
}
.card-stats:hover .expand-btn { color: var(--text); }
.expand-btn svg { width: 15px; height: 15px; }

main.history-open .row { display: none; }
.history { display: none; }
main.history-open .history { display: flex; height: 843px; }
.history .head-note { margin-left: 16px; }
.close-btn {
  margin-left: auto; width: 32px; height: 32px; border-radius: 8px;
  display: grid; place-items: center; cursor: pointer;
  background: #111c29; color: var(--muted); border: 1px solid var(--sub-border);
}
.close-btn:hover { color: var(--text); border-color: #2c3d55; }
.close-btn svg { width: 16px; height: 16px; }

.history-wrap { flex: 1; min-height: 0; overflow: auto; }
.htable { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; font-variant-numeric: tabular-nums; }
.htable > thead th {
  position: sticky; top: 0; z-index: 2;
  height: 32px; background: var(--th); color: #d4dff6; font-weight: 400;
  text-align: right; padding: 0 var(--sub-x); white-space: nowrap;
}
.htable > thead th:first-child { text-align: left; border-radius: 6px 0 0 6px; width: 40%; }
.htable > thead th:last-child { border-radius: 0 6px 6px 0; }
.htable > tbody > tr > td { padding: 0 var(--sub-x); height: 38px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
.htable > tbody > tr > td:first-child { text-align: left; }

.h-toggle {
  display: inline-flex; align-items: center; gap: 10px;
  background: none; border: 0; padding: 0; color: inherit; font: inherit; cursor: pointer;
}
.h-toggle i {
  width: 18px; height: 18px; border-radius: 5px; display: grid; place-items: center;
  background: #111c29; border: 1px solid var(--sub-border); font-style: normal; font-size: 10px; color: var(--muted);
  transition: transform 0.15s;
}
.h-toggle[aria-expanded="true"] i { transform: rotate(90deg); color: var(--text); }
/*
 * Лесенка дерева, шаг --tree (28px) = стрелка 18px + зазор 10px:
 *   стрелка месяца  -> текст месяца = стрелка дня -> текст дня
 *   текст дня = текст первой колонки во вложенной таблице сделок
 */
.htable { --tree: 28px; }
.h-month > td { background: #0c1826; font-weight: 700; font-size: 15px; height: 44px !important; }
.h-day > td:first-child { padding-left: calc(var(--sub-x) + var(--tree)) !important; }
.h-day > td { color: var(--text-2); }
.htable td.green { color: var(--green); }
.htable td.red { color: var(--red); }

/* баланс: «было → стало» и разница в своих колонках, чтобы цифры шли ровно */
.h-bal { font-variant-numeric: tabular-nums; }
.h-bal b { font-weight: 600; color: var(--text); }
.h-bal small { display: inline-block; min-width: 64px; margin-left: 10px; font-size: 13px; text-align: right; }

/* вложенная таблица начинается на 10px левее текста дня: как у основной таблицы,
   где фон заголовка начинается раньше текста */
.h-trades > td {
  --nested-inset: calc(var(--sub-x) + 2 * var(--tree) - 10px);
  /* справа тот же отступ, что слева; сверху и снизу — как везде внутри карточек */
  padding: var(--sub-y) var(--nested-inset) !important;
  height: auto !important; background: #081119;
}
.h-trades .trades { table-layout: fixed; }
.h-trades .trades th { background: #0e1824; height: 30px; }
.h-trades .trades th:first-child, .h-trades .trades td:first-child { padding-left: 10px; }
/* одинаковые колонки во всех днях */
.h-trades .trades th:nth-child(1) { width: 70px; }
.h-trades .trades th:nth-child(2) { width: 110px; }
.h-trades .trades th:nth-child(3) { width: 84px; }
.h-trades .trades th:nth-child(4) { width: 104px; }
.h-trades .trades th:nth-child(5) { width: 96px; }
.h-trades .trades th:nth-child(6) { width: 112px; }
.h-trades .trades th:nth-child(7) { width: 96px; }
.h-trades .trades th:nth-child(8) { width: 112px; }
.h-trades .trades th:nth-child(9) { width: 96px; }
.h-trades .trades th:nth-child(10) { width: 100px; }
.h-trades .trades th:nth-child(11) { width: 90px; }
.h-trades .trades td.threshold { color: #c7b8ff; font-weight: 600; }
.h-trades .trades tfoot td {
  height: 32px; text-align: center; font-weight: 700; color: var(--text);
  background: #0e1824; border-bottom: 0;
}
.h-trades .trades tfoot td:first-child { text-align: left; padding-left: 10px; border-radius: 6px 0 0 6px; }
.h-trades .trades tfoot td:last-child { border-radius: 0 6px 6px 0; }
.h-trades .trades tfoot td.green { color: var(--green); }
.h-trades .trades tfoot td.red { color: var(--red); }

/* ---------- лог (908 × 229) ---------- */

.log-box {
  flex: 1; min-height: 0;
  border: 1px solid #121e2b;
  border-radius: 8px;
  background: #07121c;
  padding: var(--sub-y) 6px var(--sub-y) 0;
  display: flex;
}
.events {
  flex: 1; list-style: none; margin: 0; padding: 0 8px 0 var(--sub-x);
  overflow-y: auto;
  font-family: var(--mono); font-size: 14px;
}
.events li { display: grid; grid-template-columns: 84px 20px 1fr; line-height: 21.5px; align-items: center; }
.events time { color: #9eb1d1; }
.events i { width: 10px; height: 10px; border-radius: 50%; background: var(--green-dot); }
.events span { color: #d8dfee; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.events span b { font-weight: 400; color: var(--green); }
.events span b.neg { color: var(--red); }
.events .l-info i { background: #c3cde0; }
.events .l-trade i { background: var(--green-dot); }
.events .l-warn i { background: var(--amber); }
.events .l-warn span { color: #f0a431; }
.events .l-error i { background: var(--red); }
.events .l-error span { color: var(--red); }

/* ---------- конфигурация (732 × 229) ---------- */

.config-box {
  flex: 1; min-height: 0;
  display: grid; grid-template-columns: 420px 1fr;
  background: #0a1823;
  border: 1px solid #121e2b;
  border-radius: 8px;
}
.kv-config { grid-template-columns: 257px 1fr; padding: 0 var(--sub-x); font-size: 14px; border-right: 1px solid #192c41; margin: var(--sub-y) 0; }
.kv-config dt { color: #b5c0db; text-transform: uppercase; line-height: 18px; }
.kv-config dd { color: #f6fdff; line-height: 18px; }
.note { display: flex; gap: var(--gap); padding: var(--sub-y) var(--sub-x) var(--sub-y) 24px; }
.note-icon {
  width: 30px; height: 30px; flex: none; border-radius: 50%;
  display: grid; place-items: center;
  background: #2b3a4f; color: #d9e3f6;
  font: 700 16px/1 Georgia, serif;
}
.note b { display: block; font-size: 14px; line-height: 21px; font-weight: 500; color: #e2ecfc; }
.note p { margin-top: 8px; font-size: 13px; line-height: 20px; color: #919fb4; }

/* ---------- вход ---------- */

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card {
  width: min(420px, 100%);
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 24px;
  display: grid;
  gap: 12px;
}
.login-card .brand { padding: 0; align-items: center; }
.login-card h1 { font-size: 19px; line-height: 24px; margin: 0; }
.login-card label { color: var(--muted); margin-top: 8px; }
.login-card input {
  background: var(--sub); color: var(--text);
  border: 1px solid var(--sub-border); border-radius: 8px;
  padding: 10px 12px; font: inherit;
}
.login-card input:focus { outline: 2px solid var(--violet); outline-offset: 1px; }
.login-card button {
  background: #6d5cf5; color: #fff; border: 0; border-radius: 8px;
  padding: 11px; font: inherit; font-weight: 600; cursor: pointer;
}
.login-card button:hover { filter: brightness(1.1); }
.login-error { color: var(--red); }

/* ================= окно уже 1672px: адаптивная раскладка ================= */

@media (max-width: 1671px) {
  .page { width: auto; }
  .topbar { height: auto; flex-wrap: wrap; gap: 12px; padding: 12px 16px; }
  .chips { flex-wrap: wrap; margin-left: 0; }
  .chip { width: auto !important; min-width: 130px; }
  .chip-clock { min-width: 300px; }

  main { padding: 0 16px 16px; display: grid; gap: 14px; }
  .row { height: auto !important; margin: 0 !important; gap: 14px; }
  .row-1 { grid-template-columns: 1fr 1fr; }
  .row-1 > .card-status { grid-column: 1 / -1; }
  .row-chart, .row-2, .row-3 { grid-template-columns: 1fr; }

  .status-grid { grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 16px; }
  .chart-wrap { height: 320px; }
  .ot-row { grid-template-columns: 1fr 1fr; height: auto; row-gap: 4px; padding: 8px 12px; }
  .ot-go { display: none; }
  .table-wrap { max-height: 330px; }
  .log-box { max-height: 240px; }
  .stats { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); grid-template-rows: none; margin-left: 0; }
  .stat { min-height: 98px; }
  .config-box { grid-template-columns: 1fr; }
  .kv-config { border-right: 0; }
  .note { padding: 0 var(--sub-x) var(--sub-y); }
  .conn-foot { flex-wrap: wrap; }
  .pnl { min-height: 94px; }
  main.history-open .history { height: auto; min-height: 70vh; }
  .h-trades > td { padding-left: var(--sub-x) !important; padding-right: var(--sub-x) !important; }
}

@media (max-width: 760px) {
  .history .card-head { flex-wrap: wrap; height: auto; row-gap: 6px; }
  .history .card-head h2 { white-space: normal; font-size: 17px; flex: 1; }
  .history .head-note { order: 3; flex-basis: 100%; margin-left: 0; }
  .htable { min-width: 620px; }
  .row-1 { grid-template-columns: 1fr; }
  .chip { flex: 1 1 140px; }
  .chip-clock { flex-basis: 100%; min-width: 0; }
  .subtitle { flex-wrap: wrap; }
  h1 { font-size: 21px; line-height: 28px; }
  .kv-status { grid-template-columns: 150px 1fr; }
  .kv-config { grid-template-columns: 1fr 1fr; }
}
