/* Betoil — панель управления торговым ботом.
   Холст серый, карточки белые: на чистом белом фоне карточки не читаются
   как отдельные объекты и интерфейс расплывается.

   Фирменный стиль держится на двух вещах и не трогает смысловые цвета.
   Первое — тёмная петролевая боковина: она даёт узнаваемость сразу, а вся
   рабочая область остаётся светлой, потому что цифры читают на светлом.
   Второе — петролевый акцент действий вместо нейтрального синего.
   Зелёный, красный, янтарный и фиолетовый не меняются: за ними закреплены
   прибыль, убыток, внимание и аналитика, и путать их с «фирменным» нельзя. */
:root {
  color-scheme: light;

  /* фирменные: петроль и латунь. Латунь только в знаке и тонких деталях —
     как смысловой цвет она заняла бы место янтарного */
  --brand-ink: #0a1a23;
  --brand-deep: #0f3c4d;
  --brand: #0d6e86;
  --brand-glow: #38b0c9;
  --brass: #d79f33;

  /* поверхности */
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-2: #eff2f7;
  --surface-3: #e5eaf2;
  --border: #e3e8f0;
  --border-strong: #ccd5e2;

  /* текст */
  --text: #16212e;
  --text-2: #44536a;
  --muted: #7a8799;

  /* петроль — действия и навигация. Сознательно уведён в синеву: рядом с
     зелёным «прибыль» теплее делать нельзя, их начнут путать в мелких метках */
  --accent: #0d6e86;
  --accent-hover: #0a5a6e;
  --accent-soft: #e4f2f6;
  --accent-line: #b6dde6;

  /* зелёный — прибыль. На белом нужен темнее, чем на тёмном фоне */
  --green: #0f8153;
  --green-soft: #e4f6ec;
  --green-line: #aee0c6;

  /* красный — убыток и опасные действия */
  --red: #cf3a3a;
  --red-soft: #fdeceb;
  --red-line: #f4c3c0;

  /* янтарный — внимание и время */
  --amber: #b06f02;
  --amber-soft: #fdf4e3;
  --amber-line: #f0dcae;

  /* фиолетовый — оценки и разбор: отделяет «аналитику» от «действий» */
  --violet: #6741c9;
  --violet-soft: #f1edfc;
  --violet-line: #d7ccf6;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 30, 54, .05), 0 4px 14px rgba(16, 30, 54, .05);
  --shadow-hover: 0 1px 2px rgba(10, 26, 35, .06), 0 8px 24px rgba(10, 26, 35, .09);
  --shadow-lg: 0 16px 48px rgba(16, 30, 54, .18);
  --mono: ui-monospace, SFMono-Regular, "JetBrains Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

/* label.field задаёт display:block и перебивал браузерное скрытие: поле «Код 2FA»
   на странице входа было видно всегда. Авторское правило должно быть сильнее. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }

/* ---------- каркас ---------- */
.layout { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }

.sidebar {
  /* Тёмная боковина — весь фирменный стиль в одном месте. Светлая панель с
     тёмным бортом читается как прибор: рабочая область не теряет контраста,
     а принадлежность видна с первого взгляда */
  background: linear-gradient(170deg, var(--brand-ink) 0%, var(--brand-deep) 100%);
  border-right: 1px solid rgba(255, 255, 255, .06);
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand {
  display: flex; align-items: center; gap: 9px;
  padding: 2px 6px 18px; font-weight: 650; font-size: 18px; letter-spacing: -.1px;
  color: #fff;
}
.brand .logo { width: 26px; height: 26px; flex: 0 0 26px; }
/* «oil» тёплым: имя делится на две части, и это единственное место,
   где латунь работает как текст */
.brand .mark-oil { color: var(--brass); }
.brand .dot {
  width: 8px; height: 8px; border-radius: 50%; background: #3ddc97;
  box-shadow: 0 0 0 3px rgba(61, 220, 151, .18);
  margin-left: auto;
}
.brand .dot.off { background: #ff6b6b; box-shadow: 0 0 0 3px rgba(255, 107, 107, .2); }

/* Боковина тёмная — её собственные цвета текста и состояний */
.sidebar .nav-group { color: rgba(255, 255, 255, .42); }
.sidebar .nav-item { color: rgba(255, 255, 255, .72); }
.sidebar .nav-item:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.sidebar .nav-item.active {
  background: rgba(56, 176, 201, .17); color: #fff; font-weight: 600;
  box-shadow: inset 2px 0 0 var(--brand-glow);
}
.sidebar .nav-item .badge { background: var(--brand-glow); color: var(--brand-ink); }
.sidebar .nav-item.active .badge { background: var(--brand-glow); color: var(--brand-ink); }
.sidebar-footer { color: rgba(255, 255, 255, .5) !important; }
.sidebar-footer { border-top-color: rgba(255, 255, 255, .1) !important; }
.sidebar-footer .mut { color: rgba(255, 255, 255, .58); }
.sidebar-footer .btn {
  background: rgba(255, 255, 255, .1); border-color: rgba(255, 255, 255, .16); color: #fff;
}
.sidebar-footer .btn:hover { background: rgba(255, 255, 255, .17); }

/* Подписи групп: 8 пунктов подряд читаются как свалка, тремя блоками — как меню */
.nav-group {
  padding: 14px 12px 5px; font-size: 10.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .8px; color: var(--muted);
}
.nav-group:first-child { padding-top: 2px; }

.nav-item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 12px; border-radius: var(--radius-sm); color: var(--text-2);
  cursor: pointer; user-select: none; transition: background .12s, color .12s;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 550; }
.nav-item .badge {
  font-size: 11px; background: var(--accent); color: #fff;
  border-radius: 20px; padding: 1px 7px; font-weight: 600;
}
.nav-item.active .badge { background: var(--accent); }

.sidebar-footer {
  margin-top: auto; padding: 12px 8px 0; border-top: 1px solid var(--border);
  color: var(--muted); font-size: 12px;
}

.main { padding: 22px 26px 60px; max-width: 1500px; }

.page-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 16px;
}
/* Петролевая засечка перед заголовком: взгляд цепляется за начало раздела,
   и страница перестаёт начинаться «ниоткуда». Стоит ровно столько, сколько
   нужно, чтобы отметить место, и ничего не заслоняет. */
.page-head h1 {
  margin: 0; font-size: 21px; font-weight: 650; letter-spacing: -.2px;
  padding-left: 11px; position: relative;
}
.page-head h1::before {
  content: ""; position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 3px; height: 18px; border-radius: 2px;
  background: linear-gradient(180deg, var(--brand-glow), var(--brand));
}
.page-head .sub { padding-left: 11px; }
.page-head .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.card .sub { color: var(--muted); font-size: 12.5px; line-height: 1.5; }

/* ---------- полоса состояния ---------- */
/* Главный вопрос при открытии панели — «бот сейчас торгует?». Раньше ответ был
   виден только как точка в углу, теперь строка стоит над каждым разделом. */
.status-strip {
  display: flex; align-items: center; gap: 10px 20px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border);
  border-left: 4px solid var(--green);
  border-radius: var(--radius); padding: 11px 16px; margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.status-strip.paused { border-left-color: var(--amber); }
.status-strip.stopped { border-left-color: var(--red); }
.status-strip .state { font-weight: 620; display: flex; align-items: center; gap: 8px; }
/* Верхний блик полосы состояния — та же петролевая нота, что в боковине */
.status-strip {
  background:
    linear-gradient(180deg, rgba(13, 110, 134, .035), transparent 42px),
    var(--surface);
}
.status-strip .sep { color: var(--border-strong); }
.status-strip .fact { color: var(--text-2); font-size: 13px; }
.status-strip .fact b { font-family: var(--mono); color: var(--text); font-weight: 600; }
.status-strip .spacer { flex: 1; }

/* ---------- карточки ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow);
  transition: box-shadow .16s, border-color .16s;
}
/* Подъём под курсором — только тень и рамка. Карточки не двигаются: в таблицах
   с числами сдвиг на пиксель мешает читать строку, за которую ведёшь глазом. */
.card:hover { box-shadow: var(--shadow-hover); border-color: var(--border-strong); }
.card h2 {
  margin: 0 0 12px; font-size: 12px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: .7px;
  display: flex; align-items: center; gap: 7px;
}
/* Точка перед названием карточки: заголовки в верхнем регистре сливаются с
   подписями внутри, а точка отделяет уровень, не добавляя линий */
.card h2::before {
  content: ""; width: 5px; height: 5px; border-radius: 50%;
  background: var(--accent-line); flex: 0 0 5px;
}
.card:hover h2::before { background: var(--brand); }
.card .card-link { float: right; font-size: 12px; text-transform: none; letter-spacing: 0; }

.grid { display: grid; gap: 14px; }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
/* Плиток может быть пять и больше: раскладка подстраивается сама, иначе пятая
   уезжает на свою строку и выглядит сбоем вёрстки */
.grid.auto { grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
/* главный блок и спутник: делить пополам их неправильно */
.grid.wide-left { grid-template-columns: 1.6fr 1fr; align-items: start; }

.stat .label { color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .5px; }
.stat .value { font-family: var(--mono); font-size: 24px; font-weight: 620; margin-top: 6px; letter-spacing: -.6px; }
.stat .hint { color: var(--muted); font-size: 12px; margin-top: 4px; }

/* Главная карточка дашборда: капитал должен читаться первым, а не наравне с R:R */
.stat.hero { background: linear-gradient(180deg, var(--accent-soft), var(--surface) 70%); border-color: var(--accent-line); }
.stat.hero .value { font-size: 34px; }

/* Компактный список метрик вместо четырёх одинаковых плиток */
.metric-row {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  padding: 9px 0; border-bottom: 1px solid var(--border);
}
.metric-row:last-child { border-bottom: 0; padding-bottom: 0; }
.metric-row .k { color: var(--muted); font-size: 13px; }
.metric-row .v { font-family: var(--mono); font-weight: 620; }
.metric-row .note { color: var(--muted); font-size: 11.5px; font-family: inherit; font-weight: 400; margin-left: 6px; }

.pos { color: var(--green); }
.neg { color: var(--red); }
.warn { color: var(--amber); }
.mut { color: var(--muted); }
.mono { font-family: var(--mono); }
.big { font-size: 15px; font-weight: 620; }

/* ---------- таблицы ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left; font-weight: 600; color: var(--muted); font-size: 11px;
  text-transform: uppercase; letter-spacing: .5px; padding: 8px 10px;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
td { padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; font-family: var(--mono); }
.table-wrap { overflow-x: auto; }

/* Лента последних сделок: 50 строк не должны выдавливать страницу, поэтому
   прокручиваются внутри карточки, а шапка таблицы остаётся на виду. */
.table-wrap.scroll { max-height: 430px; overflow-y: auto; }
.table-wrap.scroll thead th {
  position: sticky; top: 0; z-index: 1;
  background: var(--surface); box-shadow: inset 0 -1px 0 var(--border);
}
tbody tr.clickable { cursor: pointer; }

/* Полоска результата сделки: длина — к самой крупной сделке окна. Колонка
   чисел не даёт почувствовать разницу между 0.3 и 1.3, полоска даёт сразу. */
.pnl-bar { height: 7px; background: var(--surface-3); border-radius: 4px; min-width: 60px; }
.pnl-bar span { display: block; height: 100%; border-radius: 4px; }
.pnl-bar span.pos { background: var(--green); }
.pnl-bar span.neg { background: var(--red); }

/* Длинная причина отказа раздувала строку на шесть рядов и ломала сканирование
   таблицы. Показываем первую строку, полный текст — в подсказке и в разборе. */
.clip { display: block; max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px;
  border-radius: 20px; font-size: 11.5px; font-weight: 500; white-space: nowrap;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text-2);
}
.chip.green { color: var(--green); border-color: var(--green-line); background: var(--green-soft); }
.chip.red { color: var(--red); border-color: var(--red-line); background: var(--red-soft); }
.chip.amber { color: var(--amber); border-color: var(--amber-line); background: var(--amber-soft); }
.chip.blue { color: var(--accent); border-color: var(--accent-line); background: var(--accent-soft); }
.chip.violet { color: var(--violet); border-color: var(--violet-line); background: var(--violet-soft); }

/* ---------- кнопки ---------- */
.btn {
  padding: 7px 13px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text-2); cursor: pointer; font-size: 13px;
  transition: .12s; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); color: var(--text); border-color: var(--muted); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn:disabled:hover { background: var(--surface); border-color: var(--border-strong); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 550; }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
.btn.danger { background: var(--surface); border-color: var(--red-line); color: var(--red); }
.btn.danger:hover { background: var(--red-soft); border-color: var(--red); color: var(--red); }
.btn.good { background: var(--green); border-color: var(--green); color: #fff; font-weight: 550; }
.btn.good:hover { filter: brightness(1.08); color: #fff; }
.btn.sm { padding: 4px 9px; font-size: 12px; }

input[type=text], input[type=password], input[type=number], select, textarea {
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: 8px 10px; width: 100%; outline: none; transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
input::placeholder { color: var(--muted); }
label.field { display: block; margin-bottom: 12px; }
label.field span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; }

.switch { position: relative; display: inline-block; width: 40px; height: 22px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; inset: 0; background: var(--border-strong); border-radius: 22px;
  cursor: pointer; transition: .2s;
}
.switch .slider::before {
  content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 3px rgba(16,30,54,.25);
}
.switch input:checked + .slider { background: var(--green); }
.switch input:checked + .slider::before { transform: translateX(18px); }

.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .spacer { flex: 1; }

/* ---------- всплывающее ---------- */
.toast-host { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 50; }
.toast {
  background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--accent);
  padding: 11px 14px; border-radius: var(--radius-sm); max-width: 380px;
  box-shadow: var(--shadow-lg); animation: slide .2s ease-out;
}
.toast.ok { border-left-color: var(--green); }
.toast.err { border-left-color: var(--red); }
@keyframes slide { from { opacity: 0; transform: translateY(8px); } }

.modal-host {
  position: fixed; inset: 0; background: rgba(22, 33, 46, .45); backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center; z-index: 60; padding: 20px;
}
.modal {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; width: min(680px, 100%); max-height: 86vh; overflow: auto; box-shadow: var(--shadow-lg);
}
.modal h3 { margin: 0 0 14px; font-size: 16px; }

pre.raw {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px; overflow: auto; font-family: var(--mono); font-size: 12px; margin: 0;
  white-space: pre-wrap; word-break: break-word; color: var(--text-2);
}

/* ---------- индикаторы ---------- */
.progress { height: 5px; background: var(--surface-3); border-radius: 4px; overflow: hidden; min-width: 54px; }
.progress span { display: block; height: 100%; background: var(--accent); border-radius: 4px; }

/* Воронка дня. Полоса показывает, сколько сигналов ДОЖИЛО до этого шага, и
   потому сужается сверху вниз; колонка слева отвечает «где теряем», колонка
   справа — «сколько осталось». Без этих правил блок разваливался в простыню
   из подписей и чисел подряд: разметка была, стилей не было. */
.funnel { display: grid; gap: 2px; }
.funnel-head,
.funnel-row {
  display: grid;
  grid-template-columns: minmax(110px, 1fr) 76px minmax(80px, 1.6fr) 44px;
  align-items: center; gap: 10px;
}
.funnel-head {
  font-size: 10px; letter-spacing: .6px; text-transform: uppercase;
  color: var(--muted); padding-bottom: 4px; border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}
.funnel-head div:nth-child(2), .funnel-head div:last-child { text-align: right; }
.funnel-row { font-size: 13px; padding: 4px 0; color: var(--text-2); }
.funnel-row .f-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.funnel-row .f-drop,
.funnel-row .f-left { text-align: right; font-variant-numeric: tabular-nums; }
.funnel-row .f-drop { color: var(--red); }
.funnel-row .f-drop span { color: var(--muted); font-size: 11px; }
.funnel-row.quiet .f-drop { color: var(--muted); }
.funnel-row .f-left { font-weight: 600; color: var(--text); }
.f-track { height: 8px; background: var(--surface-3); border-radius: 4px; overflow: hidden; }
.f-fill { height: 100%; background: var(--accent); border-radius: 4px; }
/* Последняя строка — не ещё один этап, а итог: отделяем чертой, иначе она
   читается как повтор предыдущей (остаток там тот же) */
.funnel-row.final {
  color: var(--text); font-weight: 600;
  border-top: 1px solid var(--border); margin-top: 4px; padding-top: 7px;
}
.funnel-row.final .f-fill { background: var(--green); }
.funnel-row.final .f-left { color: var(--green); }
/* На узком экране полоса уходит первой: числа важнее картинки */
@media (max-width: 620px) {
  .funnel-head, .funnel-row { grid-template-columns: 1fr 70px 44px; }
  .f-track { display: none; }
  .funnel-head div:nth-child(3) { display: none; }
}

/* Разбор отказов — детализация тех этапов воронки, где теряется поток.
   Ритм сетки тот же, что у воронки: подпись, полоса, число. Полоса меряется
   от самой частой причины, иначе при десятке причин все выродятся в засечки.

   Цвет полосы НЕ акцентный сознательно: выше акцентом залито «сколько дожило
   до этапа», и тот же цвет под «сколько отсеяли» означал бы противоположное
   теми же чернилами. Мягкий красный из палитры отказов говорит «здесь
   потеряли», но не кричит: отсев — штатная работа фильтра, а не авария. */
.rejects { display: grid; gap: 1px; }
.reject-row {
  display: grid;
  grid-template-columns: minmax(120px, 1.4fr) minmax(70px, 1fr) 34px 40px;
  align-items: center; gap: 10px;
  font-size: 13px; padding: 4px 0; color: var(--text-2);
}
.reject-row .r-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.r-track { height: 6px; background: var(--surface-3); border-radius: 3px; overflow: hidden; }
.r-fill { height: 100%; background: var(--red-line); border-radius: 3px; }
.reject-row .r-count,
.reject-row .r-share { text-align: right; font-variant-numeric: tabular-nums; }
.reject-row .r-count { font-weight: 600; color: var(--text); }
.reject-row .r-share { color: var(--muted); font-size: 11px; }
/* Подзаголовок группы: тонкая черта сверху вместо второго крупного заголовка.
   Два h3 подряд читались как сбой вёрстки — это один блок, а не два. */
.reject-group {
  display: flex; align-items: baseline; gap: 8px;
  font-size: 10px; letter-spacing: .6px; text-transform: uppercase;
  color: var(--muted); margin-top: 10px; padding-bottom: 3px;
  border-bottom: 1px solid var(--border);
}
.reject-group:first-child { margin-top: 0; }
.reject-group .g-count {
  margin-left: auto; font-size: 11px; letter-spacing: 0;
  font-variant-numeric: tabular-nums;
}
/* На узком экране первой уходит полоса: числа важнее картинки */
@media (max-width: 620px) {
  .reject-row { grid-template-columns: 1fr 34px 40px; }
  .r-track { display: none; }
}

/* Плашка идущей проверки на дашборде. Фиолетовый — цвет разбора и аналитики:
   это не действие, которое надо совершить, и не тревога, а сообщение «сейчас
   измеряем». Зелёный и красный заняты прибылью и убытком, янтарный — вниманием
   и временем; любой из них соврал бы о смысле. */
.band-note {
  background: var(--violet-soft); border: 1px solid var(--violet-line);
  border-radius: var(--radius); padding: 12px 14px; margin-bottom: 14px;
}
.band-head {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-size: 13px; color: var(--text-2); margin-bottom: 8px;
}
.band-tag {
  font-size: 10px; letter-spacing: .6px; text-transform: uppercase;
  background: var(--violet); color: #fff; border-radius: 999px; padding: 2px 8px;
}
.band-count {
  margin-left: auto; font-weight: 600; color: var(--text);
  font-variant-numeric: tabular-nums;
}
.band-note .progress { background: #fff; }
.band-note .progress span { background: var(--violet); }
.band-foot { font-size: 12px; color: var(--muted); margin-top: 8px; }
@media (max-width: 620px) {
  .band-count { margin-left: 0; width: 100%; }
}

/* Шапка графика: переключатель окна слева, подпись «было → стало» справа.
   Кнопки сделаны сегментами, а не обычными .btn: три варианта одного и того
   же выбора — это один орган управления, и тремя отдельными кнопками он
   читался бы как три разных действия. */
.chart-head {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin: -2px 0 10px;
}
.seg {
  display: inline-flex; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 999px; padding: 2px;
}
.seg-btn {
  appearance: none; border: 0; background: none; cursor: pointer;
  font: inherit; font-size: 12px; color: var(--text-2);
  padding: 4px 12px; border-radius: 999px; line-height: 1.3;
  transition: background .15s, color .15s;
}
.seg-btn:hover { color: var(--text); }
.seg-btn.on {
  background: var(--surface); color: var(--text); font-weight: 600;
  box-shadow: 0 1px 2px rgba(16, 30, 54, .08);
}
.chart-head .mut { margin-left: auto; }
@media (max-width: 620px) {
  .chart-head .mut { margin-left: 0; width: 100%; }
}

/* Вторая строка в числовой ячейке: процент сверху, деньги под ним. Нужна там,
   где одно число отвечает на вопрос «много ли это» (доля оборота), а второе —
   «сколько именно» (USDT), и прятать любое из них в подсказку неправильно. */
td .cell-note {
  display: block; color: var(--muted); font-weight: 400;
  font-size: 11px; margin-top: 2px;
}

/* Обратный отсчёт до дедлайна — главная механика сделки, её видно полоской */
.timebar { height: 4px; background: var(--surface-3); border-radius: 3px; overflow: hidden; min-width: 56px; margin-top: 4px; }
.timebar span { display: block; height: 100%; background: var(--accent); border-radius: 3px; transition: width .4s linear; }
.timebar.warn span { background: var(--amber); }
.timebar.urgent span { background: var(--red); }

.empty { padding: 34px; text-align: center; color: var(--muted); }

.kill-banner {
  background: var(--red-soft); border: 1px solid var(--red-line);
  color: var(--red); padding: 10px 14px; border-radius: var(--radius-sm); margin-bottom: 14px;
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
}
.err-box {
  background: var(--red-soft); border: 1px solid var(--red-line); color: var(--red);
  padding: 9px 12px; border-radius: var(--radius-sm); margin-bottom: 12px; font-size: 13px;
}
.hint-box {
  background: var(--accent-soft); border: 1px solid var(--accent-line); color: var(--text-2);
  padding: 9px 12px; border-radius: var(--radius-sm); font-size: 12.5px;
}

/* ---------- логин ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { width: min(380px, 100%); }
.login-card .brand { justify-content: center; font-size: 26px; padding: 2px 0 10px; color: var(--text); }
.login-card .brand .logo { width: 34px; height: 34px; flex: 0 0 34px; }
/* Страница входа — первое, что видят: тонкая петролевая линия сверху карточки
   связывает её с боковиной панели, не утяжеляя форму */
.login-card {
  border-top: 3px solid var(--brand);
  position: relative;
}
.login-wrap {
  background:
    radial-gradient(1100px 520px at 50% -12%, rgba(13, 110, 134, .14), transparent 70%),
    var(--bg);
}
.login-card .sub { text-align: center; color: var(--muted); margin-bottom: 20px; font-size: 13px; }

@media (max-width: 1100px) { .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: static; height: auto; flex-direction: row; flex-wrap: wrap;
    align-items: center; border-right: 0;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
    /* На узком экране боковина становится шапкой: градиент разворачивается
       вдоль, иначе тёмный край оказывался бы снизу, а светлый сверху */
    background: linear-gradient(100deg, var(--brand-ink) 0%, var(--brand-deep) 100%);
  }
  .brand { padding: 2px 6px; }
  .nav-group { display: none; }
  .sidebar-footer { width: 100%; margin-top: 8px; }
  .main { padding: 16px; }
  .grid.cols-3, .grid.cols-2, .grid.wide-left { grid-template-columns: 1fr; }
}

/* ---------- разбор стратегии ---------- */
/* Вывод — это утверждение о системе, а не карточка данных: цвет слева задаёт,
   насколько срочно на него смотреть, и больше ничем вывод не украшен. */
.findings { display: grid; gap: 8px; }
.finding {
  background: var(--surface); border: 1px solid var(--border);
  border-left: 3px solid var(--border-strong);
  border-radius: var(--radius-sm); padding: 10px 14px;
}
.finding.bad  { border-left-color: var(--red);    background: var(--red-soft); }
.finding.warn { border-left-color: var(--amber);  background: var(--amber-soft); }
.finding.ok   { border-left-color: var(--green);  background: var(--green-soft); }
.finding.info { border-left-color: var(--violet); background: var(--violet-soft); }
.finding .ttl { font-weight: 620; font-size: 13.5px; }
.finding .txt { color: var(--text-2); font-size: 12.5px; line-height: 1.5; margin-top: 3px; }

/* Полоса R:R: ширина — это само отношение, поэтому подпись живёт внутри полосы */
.rr-bar { position: relative; height: 18px; min-width: 120px; background: var(--bg); border-radius: 3px; }
.rr-bar .fill { height: 100%; border-radius: 3px; }
.rr-bar .fill.ok  { background: var(--green); }
.rr-bar .fill.bad { background: var(--red); opacity: .55; }
.rr-bar .cap {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: flex-end;
  padding-right: 6px; font-family: var(--mono); font-size: 11.5px; font-weight: 600;
}
tbody tr.dim td { opacity: .62; }

.split { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.split-half {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 14px;
}
.split-half .cap { color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .5px; }
.split-half .big { font-family: var(--mono); font-size: 22px; font-weight: 620; margin: 6px 0 2px; }

.rule { height: 1px; background: var(--border); margin: 10px 0; }

@media (max-width: 820px) {
  .split { grid-template-columns: 1fr; }
}

/* Сколько уровней сетки успело залиться — три-четыре значения, не таблица */
.levels-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.levels-row .lv {
  flex: 1 1 120px; background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 9px 12px;
}
.levels-row .cap { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.levels-row .v { font-family: var(--mono); font-size: 17px; font-weight: 620; margin: 2px 0; }
.levels-row .mut { font-size: 11.5px; }

/* --------------------------------------------------------------------------- */
/*  Телефон: 430px и уже                                                        */
/* --------------------------------------------------------------------------- */
/* Правило в 860px превращает боковину в шапку — этого хватает планшету, но на
   телефоне остаётся четыре беды: меню из десяти пунктов переносится в высокий
   блок на полэкрана, строка состояния рассыпается, таблицы на 7-10 колонок
   уезжают в горизонтальную прокрутку, а числа в 24px не помещаются по двое в
   ряд. Ниже чинится каждая.

   Подход к таблицам: НЕ превращать строки в карточки. Карточки читаются по
   одной, а здесь смысл в сравнении соседних строк — какая сделка крупнее,
   какая дольше. Поэтому второстепенные колонки убираются, а оставшиеся
   четыре помещаются в ширину без прокрутки. Всё убранное доступно по тапу на
   строку: открывается карточка сделки со всеми полями. */
@media (max-width: 430px) {
  /* --- шапка и меню --- */
  /* Меню в одну строку с горизонтальной прокруткой: на телефоне это привычный
     жест, а переносом десять пунктов занимали четыре ряда. */
  .sidebar { padding: 8px 0 8px 12px; gap: 0; }
  .sidebar nav {
    display: flex; gap: 6px; width: 100%; margin-top: 8px;
    overflow-x: auto; scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch; scrollbar-width: none;
    padding-bottom: 2px;
  }
  .sidebar nav::-webkit-scrollbar { display: none; }
  .sidebar .nav-item {
    flex: 0 0 auto; scroll-snap-align: start; white-space: nowrap;
    padding: 9px 13px; border-radius: 999px; margin: 0;
    /* 38px по высоте — у пальца должно быть во что попасть */
    min-height: 38px; display: flex; align-items: center;
  }
  .brand { padding: 0 12px 0 0; }
  /* Служебные строки режима и связи на телефоне только занимают место:
     состояние и так видно в строке статуса ниже. */
  .sidebar-footer #mode-line, .sidebar-footer #ws-line { display: none; }
  .sidebar-footer {
    margin-top: 6px; padding-right: 12px;
    display: flex; align-items: center; justify-content: space-between;
  }

  /* --- строка состояния --- */
  .status-strip { gap: 6px 12px; padding: 10px 12px; font-size: 12px; }
  .status-strip .sep { display: none; }
  .status-strip .spacer { display: none; }
  /* Кнопка действия во всю ширину: это единственное действие на экране, и
     попадать в неё пальцем надо без прицеливания. */
  .status-strip .btn { width: 100%; margin-top: 4px; min-height: 40px; }

  /* --- плитки --- */
  .main { padding: 12px; }
  .grid { gap: 10px; }
  .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat .value { font-size: 19px; }
  .stat.hero { grid-column: 1 / -1; }
  .stat.hero .value { font-size: 27px; }
  .card { padding: 12px; }
  h1 { font-size: 20px; }
  h2 { font-size: 14px; }

  /* --- таблицы --- */
  table { font-size: 12px; }
  th, td { padding: 7px 5px; }
  .table-wrap { overflow-x: visible; }

  /* Лента на дашборде: # | Пара | Результат | полоса | Комиссия | Как вышли | Закрыта
     Остаются пара, результат и причина выхода — то, ради чего в ленту и смотрят. */
  .tbl-ribbon th:nth-child(1), .tbl-ribbon td:nth-child(1),
  .tbl-ribbon th:nth-child(4), .tbl-ribbon td:nth-child(4),
  .tbl-ribbon th:nth-child(5), .tbl-ribbon td:nth-child(5),
  .tbl-ribbon th:nth-child(7), .tbl-ribbon td:nth-child(7) { display: none; }

  /* Раздел «Сделки»: 10 колонок. Остаются пара, результат, как вышли, когда. */
  .tbl-trades th:nth-child(1), .tbl-trades td:nth-child(1),
  .tbl-trades th:nth-child(4), .tbl-trades td:nth-child(4),
  .tbl-trades th:nth-child(5), .tbl-trades td:nth-child(5),
  .tbl-trades th:nth-child(6), .tbl-trades td:nth-child(6),
  .tbl-trades th:nth-child(7), .tbl-trades td:nth-child(7),
  .tbl-trades th:nth-child(8), .tbl-trades td:nth-child(8) { display: none; }

  /* Позиции: # | Пара | Статус | Цены | Вложено | Уровни | Цели | Результат | Время | действия
     Остаются пара, цены, результат и кнопки — закрыть позицию с телефона надо мочь. */
  .tbl-positions th:nth-child(1), .tbl-positions td:nth-child(1),
  .tbl-positions th:nth-child(3), .tbl-positions td:nth-child(3),
  .tbl-positions th:nth-child(5), .tbl-positions td:nth-child(5),
  .tbl-positions th:nth-child(6), .tbl-positions td:nth-child(6),
  .tbl-positions th:nth-child(7), .tbl-positions td:nth-child(7),
  .tbl-positions th:nth-child(9), .tbl-positions td:nth-child(9) { display: none; }

  /* --- мелочь --- */
  .chip { font-size: 10.5px; padding: 1px 6px; }
  .seg-btn { min-height: 34px; padding: 0 11px; }
  .toolbar { gap: 6px; }
  .toolbar .btn { flex: 1 1 auto; min-height: 40px; }
  .modal { width: calc(100vw - 20px); max-height: calc(100vh - 40px); padding: 14px; }
  .toast-host { left: 10px; right: 10px; bottom: 10px; }
  .page-head { flex-direction: column; align-items: flex-start; gap: 10px; }
  .page-head .toolbar { width: 100%; }
}

/* Очень узкие экраны (320-360px): плитки в один столбец, иначе числа ломаются
   переносом посреди разряда. */
@media (max-width: 360px) {
  .grid.cols-4 { grid-template-columns: 1fr; }
  .stat .value { font-size: 22px; }
}

/* Вырезы и скруглённые углы: содержимое не должно заползать под чёлку и
   системную полосу жестов. */
@supports (padding: max(0px)) {
  @media (max-width: 430px) {
    .sidebar { padding-left: max(12px, env(safe-area-inset-left)); }
    .main {
      padding-left: max(12px, env(safe-area-inset-left));
      padding-right: max(12px, env(safe-area-inset-right));
      padding-bottom: max(12px, env(safe-area-inset-bottom));
    }
  }
}
