:root {
  --bg: #0f1419;
  --panel: #171e26;
  --panel-2: #1d2630;
  --line: #2a3542;
  --text: #e8eef5;
  --muted: #93a1b3;
  --accent: #3dd6c6;
  --accent-2: #2bb3a5;
  --danger: #ff6b6b;
  --ok: #63d471;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  --radius: 16px;
  --font: "IBM Plex Sans", "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
  --sidebar: 240px;
  --sidebar-collapsed: 52px;
  --mobile-header-h: 3rem;
  --mobile-header-counts-h: 2.25rem;
  --mobile-nav-h: 3.5rem;
  --mobile-nav-total-h: calc(var(--mobile-nav-h) + var(--safe-bottom));
  --mobile-actions-pad: 0.55rem;
  --mobile-actions-h: calc(var(--mobile-actions-pad) + 2.75rem);
  --mobile-layout-max: 768px;
  --mobile-gutter: 1rem;
  --mobile-sticky-top: calc(var(--mobile-header-h) + var(--safe-top));
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

body:has(#offline-banner:not([hidden])) {
  --mobile-sticky-top: calc(var(--mobile-header-h) + var(--safe-top) + 2rem);
}

/* Переопределяем и header-h, и sticky-top: иначе :root уже «запекает» 3rem в --mobile-sticky-top. */
body.has-mobile-fleet-counts {
  --mobile-header-h: calc(3rem + var(--mobile-header-counts-h));
  --mobile-sticky-top: calc(var(--mobile-header-h) + var(--safe-top));
}

body.has-mobile-fleet-counts:has(#offline-banner:not([hidden])) {
  --mobile-sticky-top: calc(var(--mobile-header-h) + var(--safe-top) + 2rem);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

/* Canvas под Android gesture-bar / overscroll — не белый default. */
html {
  background-color: #0c1117;
  color-scheme: dark;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(61, 214, 198, 0.16), transparent 55%),
    radial-gradient(900px 500px at 100% 0%, rgba(84, 120, 255, 0.12), transparent 45%),
    linear-gradient(180deg, #0c1117 0%, #121821 100%);
}

.shell {
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  min-height: 100vh;
  min-width: 0;
  max-width: 100%;
  overflow-x: hidden;
  transition: grid-template-columns 0.2s ease;
}

.shell.is-sidebar-collapsed {
  grid-template-columns: var(--sidebar-collapsed) minmax(0, 1fr);
}

.sidebar {
  position: relative;
  padding: 1.5rem 1.1rem;
  border-right: 1px solid var(--line);
  background: rgba(12, 17, 23, 0.72);
  backdrop-filter: blur(10px);
  min-width: 0;
}

.sidebar-collapse-btn {
  position: absolute;
  top: 1rem;
  right: -14px;
  z-index: 6;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
}

.sidebar-collapse-btn:hover,
.sidebar-collapse-btn:focus-visible {
  border-color: var(--accent);
  color: var(--accent);
  outline: none;
}

.brand {
  display: grid;
  gap: 0.55rem;
}

.brand-link {
  display: block;
  text-decoration: none;
  border-radius: 14px;
  outline-offset: 3px;
}

.brand-logo {
  display: block;
  width: min(100%, 220px);
  height: auto;
  border-radius: 12px;
}

.brand-mark {
  display: none;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 8px;
  object-fit: contain;
  margin: 0 auto;
}

.brand-tagline {
  margin: 0;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.72rem;
  font-weight: 600;
}

.brand-version {
  margin: -0.15rem 0 0;
  color: var(--muted);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  opacity: 0.85;
}

.brand h1 {
  margin: 0;
  font-size: 1.35rem;
  letter-spacing: -0.03em;
}

.eyebrow {
  margin: 0 0 0.35rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.72rem;
  font-weight: 600;
}

.nav {
  display: grid;
  gap: 0.45rem;
  margin: 1.5rem 0 1.2rem;
  /* Иначе при высокой колонке (флот / скролл сайдбара) ряды растягивают пункты */
  align-content: start;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  text-decoration: none;
  color: var(--muted);
  padding: 0.7rem 0.85rem;
  border-radius: 12px;
  border: 1px solid transparent;
  transition: 0.15s ease;
  font-weight: 600;
}

.nav-ico {
  flex: 0 0 1.25rem;
  width: 1.25rem;
  height: 1.25rem;
  display: block;
  opacity: 0.92;
}

.nav-link.active .nav-ico {
  opacity: 1;
}

.nav-label {
  flex: 1 1 auto;
  min-width: 0;
}

.nav-link:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.03);
}

.nav-link.active {
  color: #06201d;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

.shell.is-sidebar-collapsed .sidebar {
  /* Выше .content — иначе выезд «Ещё» оказывается под таблицей флота */
  z-index: 40;
  padding: 0.85rem 0.25rem 0.75rem;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  overflow: visible;
}

.shell.is-sidebar-collapsed .brand {
  align-items: center;
  justify-items: center;
}

.shell.is-sidebar-collapsed .brand-logo {
  display: none;
}

.shell.is-sidebar-collapsed .brand-mark {
  display: block;
}

.shell.is-sidebar-collapsed .brand-tagline,
.shell.is-sidebar-collapsed .brand-version,
.shell.is-sidebar-collapsed .nav-label,
.shell.is-sidebar-collapsed .fleet-sidebar-title,
.shell.is-sidebar-collapsed .fleet-sidebar-counts {
  display: none;
}

/* В узком rail — только цветная точка статуса флота */
.shell.is-sidebar-collapsed .fleet-sidebar-summary {
  display: flex;
  justify-content: center;
  padding: 0.15rem 0;
}

.shell.is-sidebar-collapsed .fleet-sidebar-summary[hidden] {
  display: none;
}

.shell.is-sidebar-collapsed .fleet-sidebar-link {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 1.85rem;
  height: 1.85rem;
  padding: 0;
  border-radius: 8px;
}

.shell.is-sidebar-collapsed .fleet-sidebar-dot {
  display: block;
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: var(--muted);
  box-shadow: 0 0 0 2px rgba(147, 161, 179, 0.18);
}

.shell.is-sidebar-collapsed .fleet-sidebar-summary.has-live .fleet-sidebar-dot {
  background: var(--ok);
  box-shadow: 0 0 0 3px rgba(99, 212, 113, 0.22);
}

.shell.is-sidebar-collapsed .fleet-sidebar-summary.has-danger .fleet-sidebar-dot {
  background: var(--danger);
  box-shadow: 0 0 0 3px rgba(255, 107, 107, 0.22);
}

.shell.is-sidebar-collapsed .nav {
  margin-top: 0.75rem;
}

.shell.is-sidebar-collapsed .nav-ico {
  width: 1.05rem;
  height: 1.05rem;
  flex-basis: 1.05rem;
}

.shell.is-sidebar-collapsed .nav-link,
.shell.is-sidebar-collapsed .nav-more-summary,
.shell.is-sidebar-collapsed .nav-link-tokens {
  justify-content: center;
  padding: 0.45rem 0.2rem;
  min-height: 2rem;
  border-radius: 9px;
}

.shell.is-sidebar-collapsed .nav-link.active .nav-ico {
  opacity: 1;
}

.shell.is-sidebar-collapsed .nav-badge {
  position: absolute;
  top: 0.2rem;
  right: 0.15rem;
}

.shell.is-sidebar-collapsed .nav-link,
.shell.is-sidebar-collapsed .nav-more-summary {
  position: relative;
}

.shell.is-sidebar-collapsed .nav-more {
  position: relative;
}

.shell.is-sidebar-collapsed .nav-more-summary-label {
  display: none;
}

.shell.is-sidebar-collapsed .nav-more > .nav-more-summary::after {
  display: none;
}

.shell.is-sidebar-collapsed .nav-more-body {
  position: absolute;
  left: calc(100% + 0.45rem);
  top: 0;
  z-index: 50;
  min-width: 12.5rem;
  padding: 0.4rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(12, 17, 23, 0.98);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45);
}

.shell.is-sidebar-collapsed .nav-more:not([open]) > .nav-more-body {
  display: none !important;
}

.shell.is-sidebar-collapsed .nav-more-body .nav-link {
  justify-content: flex-start;
  padding: 0.55rem 0.7rem;
}

.shell.is-sidebar-collapsed .nav-more-body .nav-label {
  display: inline;
}

.shell.is-sidebar-collapsed .sidebar-collapse-btn {
  right: -12px;
}

.sidebar-note {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.4;
  margin: 0;
}

.content {
  padding: 1.5rem 1.5rem 2.5rem;
  width: min(980px, 100%);
  min-width: 0;
  max-width: 100%;
}

.page { display: none; }
.page.active { display: block; }

.page-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 1.1rem;
}

.page-header h2 {
  margin: 0;
  font-size: clamp(1.4rem, 2.5vw, 1.85rem);
  letter-spacing: -0.03em;
}

.sub {
  margin: 0.4rem 0 0;
  color: var(--muted);
}

code {
  font-family: var(--mono);
  font-size: 0.9em;
  color: #c9d7e7;
}

.header-actions,
.actions-inline {
  display: flex;
  gap: 0.6rem;
  flex-shrink: 0;
  align-items: end;
}

.btn {
  border: 0;
  border-radius: 999px;
  padding: 0.7rem 1.15rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease, opacity 0.15s ease;
}

@media (hover: hover) {
  .btn:hover { transform: translateY(-1px); }
}

.btn:active:not(:disabled) { transform: scale(0.98); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn.is-loading { opacity: 0.7; cursor: wait; pointer-events: none; }
#calculator-refresh-btn:disabled {
  cursor: not-allowed;
  pointer-events: auto;
}

.btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #06201d;
}

.btn.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
}

.btn.small {
  padding: 0.55rem 0.9rem;
  font-size: 0.9rem;
}

.btn.danger {
  background: linear-gradient(135deg, #ff6b6b, #d94848);
  color: #1a0808;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.modal[hidden] {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(6, 10, 14, 0.72);
  backdrop-filter: blur(4px);
}

.modal-dialog {
  position: relative;
  width: min(420px, 100%);
  padding: 1.35rem 1.4rem 1.2rem;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.modal-dialog.settings-dialog {
  width: min(920px, 100%);
  max-height: min(92vh, 980px);
  padding: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.settings-dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 1.1rem 1.25rem;
  border-bottom: 1px solid var(--line);
  background: rgba(12, 17, 23, 0.55);
}

.settings-dialog-header h3 {
  margin: 0;
  font-size: 1.2rem;
  letter-spacing: -0.02em;
}

.settings-dialog-sub {
  margin: 0.3rem 0 0;
  font-size: 0.88rem;
}

.settings-dialog-body {
  overflow: auto;
  padding: 1rem 1.25rem 1.35rem;
}

.settings-dialog-body .section {
  margin-bottom: 0.85rem;
  box-shadow: none;
}

.settings-dialog-body .section:last-child {
  margin-bottom: 0;
}

.settings-dialog-body .form {
  gap: 0.85rem;
}

.modal-dialog h3 {
  margin: 0 0 0.55rem;
  font-size: 1.1rem;
}

.modal-text {
  margin: 0 0 1.2rem;
  color: var(--muted);
  line-height: 1.45;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  flex-wrap: wrap;
}

/* Сеткыч: Обе стороны → Лонг/Шорт → Отмена (без ввода all/buy/sell). */
.modal-actions--side-choices {
  justify-content: stretch;
}

.modal-actions--side-choices .btn {
  text-align: center;
}

.modal-actions--side-choices #confirm-modal-ok {
  order: 1;
  flex: 1 1 100%;
}

.modal-actions--side-choices #confirm-modal-alt,
.modal-actions--side-choices #confirm-modal-alt2 {
  order: 2;
  flex: 1 1 calc(50% - 0.4rem);
  min-width: 6.5rem;
}

.modal-actions--side-choices #confirm-modal-cancel {
  order: 3;
  flex: 1 1 100%;
}

/* Одна сторона (long или short): одна CTA на всю ширину + Отмена. */
.modal-actions--side-choices-single #confirm-modal-ok,
.modal-actions--side-choices-single #confirm-modal-alt,
.modal-actions--side-choices-single #confirm-modal-alt2 {
  order: 1;
  flex: 1 1 100%;
}

.modal-dialog.roll-dialog {
  width: min(960px, 100%);
  max-height: min(90vh, 900px);
  overflow: auto;
}

.roll-form {
  gap: 0.85rem;
}

/* label { display:grid } перебивает UA [hidden] — явно прячем поля цен. */
#roll_p_entry_wrap[hidden],
#roll_p_exit_wrap[hidden] {
  display: none;
}

.roll-preview-panel {
  display: grid;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.roll-preview-panel[hidden] {
  display: none;
}

.roll-preview-panel.is-loading .roll-preview-meta {
  opacity: 0.75;
}

.roll-preview-meta {
  font-size: 0.86rem;
  color: var(--muted);
  line-height: 1.4;
}

.roll-preview-table-wrap,
.roll-preview-levels-wrap {
  max-height: min(48vh, 420px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.roll-preview-slash-hint {
  margin: 0;
  font-size: 0.82rem;
}

/* Превью ролла: цены «сейчас / после» шире обычной сетки — иначе TP наезжают */
.roll-compare-levels.levels-grid-table {
  table-layout: auto;
  width: max-content;
  min-width: 100%;
}

.roll-compare-levels.levels-grid-table th,
.roll-compare-levels.levels-grid-table td {
  white-space: nowrap;
  vertical-align: middle;
}

.roll-compare-levels.levels-grid-table td.levels-row-label,
.roll-compare-levels.levels-grid-table th.levels-row-label,
.roll-compare-levels.levels-grid-table thead tr.levels-cols-head th:first-child {
  white-space: normal;
  min-width: 9rem;
  max-width: 14rem;
}

.roll-compare-levels.levels-grid-table tbody tr.levels-row td,
.roll-compare-levels.levels-grid-table tbody tr.levels-row-pending td,
.roll-compare-levels.levels-grid-table tbody tr.levels-row-reload td {
  /* непрозрачный фон — длинный TP не просвечивает на соседнюю колонку */
  background: #0f141b;
}

.roll-compare-levels.levels-grid-table td.levels-tp,
.roll-compare-levels.levels-grid-table thead tr.levels-cols-head th:nth-child(3),
.roll-compare-levels.levels-grid-table thead tr.levels-cols-head th:nth-child(4),
.roll-compare-levels.levels-grid-table thead tr.levels-cols-head th:nth-child(5) {
  min-width: 10.5rem;
  padding-left: 0.55rem;
  padding-right: 0.55rem;
}

.roll-compare-levels.levels-grid-table tbody tr.levels-row td:nth-child(2),
.roll-compare-levels.levels-grid-table thead tr.levels-cols-head th:nth-child(2) {
  min-width: 8.5rem;
}

.roll-preview-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}

.roll-preview-table th,
.roll-preview-table td {
  padding: 0.4rem 0.55rem;
  text-align: left;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.roll-preview-table th {
  position: sticky;
  top: 0;
  background: var(--panel, #fff);
  color: var(--muted);
  font-weight: 600;
  z-index: 1;
}

.roll-preview-table td:nth-child(2),
.roll-preview-table td:nth-child(3),
.roll-preview-table td:nth-child(4),
.roll-preview-table td:nth-child(5),
.roll-preview-table th:nth-child(2),
.roll-preview-table th:nth-child(3),
.roll-preview-table th:nth-child(4),
.roll-preview-table th:nth-child(5) {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.roll-preview-table tbody tr:last-child td {
  border-bottom: none;
}

.roll-form label > span {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--muted);
  font-size: 0.86rem;
}

.roll-mode-fieldset {
  margin: 0;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  display: grid;
  gap: 0.65rem;
}

.roll-mode-fieldset legend {
  padding: 0 0.25rem;
  color: var(--muted);
  font-size: 0.86rem;
}

.roll-mode-option {
  /* По центру блока текста (не к верхнему краю). */
  align-items: center;
}

.roll-mode-option span {
  line-height: 1.35;
}

.roll-market-option {
  align-items: center;
  gap: 0.5rem;
  margin: 0;
}

.roll-market-option span {
  color: var(--text);
  font-size: 0.92rem;
}

/* У checkbox/radio в ролле нет «подписи сверху» — сбрасываем margin от .roll-form label > span. */
.roll-form .roll-mode-option > span,
.roll-form .roll-market-option > span {
  margin-bottom: 0;
}

.roll-form-note {
  margin: 0;
}

.flash {
  position: fixed;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1100;
  box-sizing: border-box;
  width: min(640px, calc(100% - 2rem));
  max-width: calc(100vw - 2rem);
  max-height: min(40vh, 12rem);
  margin: 0;
  padding: 0.85rem 1rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow-x: hidden;
  overflow-y: auto;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.flash.ok {
  border-color: rgba(99, 212, 113, 0.45);
  color: var(--ok);
}

.flash.warn {
  border-color: rgba(230, 168, 60, 0.55);
  color: #c48a1a;
}

.flash.err {
  border-color: rgba(255, 107, 107, 0.45);
  color: var(--danger);
}

.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-wrap {
  width: min(420px, 100%);
  padding: 24px 18px;
}

.login-wrap .brand-link {
  width: 100%;
}

.login-wrap .brand-logo {
  width: 100%;
  max-width: none;
  height: auto;
}

.login-head {
  margin: 0;
}

.login-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login-card .btn.primary {
  width: 100%;
}

.login-card .flash.err {
  margin: 0;
}

.form {
  display: grid;
  gap: 1rem;
}

/* При market поле цены входа отключено — курсор «запрещено». */
#entry_limit_price:disabled,
label:has(#entry_limit_price:disabled) {
  cursor: not-allowed;
}

/* Тип стратегии после создания нельзя сменить — как у .btn:disabled. */
#strategy_type:disabled,
label:has(#strategy_type:disabled) {
  cursor: not-allowed;
}

.section {
  background: linear-gradient(180deg, var(--panel) 0%, var(--panel-2) 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.15rem 1.2rem 1.3rem;
  margin-bottom: 1rem;
}

.modal-dialog.settings-dialog.token-dialog {
  width: min(640px, 100%);
  max-height: min(90vh, 720px);
}

#token_form_client_wrap[hidden],
#token_form_status_wrap[hidden] {
  display: none !important;
}

.section h3 {
  margin: 0 0 0.9rem;
  font-size: 1.02rem;
}

.console-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.9rem;
}

.console-head h3 {
  margin: 0;
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem 1rem;
}

/* Иначе длинный placeholder/spinner number-input раздувает колонку и наезжает на соседнюю */
.grid > * {
  min-width: 0;
}

.account-pick-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.account-pick-row select {
  flex: 1;
  min-width: 0;
}

.account-create-panel {
  margin-top: 0.85rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border, #d8dde6);
  border-radius: 8px;
  background: var(--surface-2, rgba(0, 0, 0, 0.03));
}

.account-create-panel .actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.api-tokens-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.api-token-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border, #d8dde6);
  border-radius: 6px;
  font-size: 0.92rem;
}

.api-token-row .meta {
  flex: 1 1 auto;
  min-width: 12rem;
}

.api-token-row .actions {
  display: flex;
  gap: 0.35rem;
}

.create-grid {
  grid-template-columns: 1fr 1fr auto;
  align-items: end;
}

label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.9rem;
  color: var(--muted);
}

label.full { grid-column: 1 / -1; }

label.checkbox {
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 0.55rem;
  margin-top: 0.4rem;
}

/* Не растягивать чекбокс на ширину ячейки (иначе «белый квадрат» поверх текста). */
label.checkbox input[type='checkbox'] {
  width: auto;
  max-width: none;
  min-width: 1.05rem;
  height: 1.05rem;
  margin: 0;
  padding: 0;
  accent-color: var(--accent, #3dd6c6);
}

input, select {
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #0f151c;
  color: var(--text);
  padding: 0.65rem 0.75rem;
  font: inherit;
}

input:focus, select:focus {
  outline: 2px solid rgba(61, 214, 198, 0.35);
  border-color: var(--accent);
}

.tp-table {
  display: grid;
  gap: 0.55rem;
}

.tp-head, .tp-row {
  display: grid;
  grid-template-columns: 2.2rem 1fr 1fr;
  gap: 0.7rem;
  align-items: center;
}

.tp-head {
  color: var(--muted);
  font-size: 0.85rem;
  padding: 0 0.1rem;
}

.accounts {
  display: grid;
  gap: 0.85rem;
}

.account-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1rem;
  align-items: center;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #121920;
}

.account-meta {
  display: grid;
  gap: 0.25rem;
}

.account-id {
  font-family: var(--mono);
  font-size: 0.92rem;
  word-break: break-all;
}

.account-name {
  color: var(--text);
  font-weight: 600;
}

.muted, .account-status {
  color: var(--muted);
  font-size: 0.9rem;
}

.payin-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.payin-row input {
  width: 140px;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
}

.stat {
  display: grid;
  gap: 0.3rem;
  padding: 0.85rem 0.95rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #121920;
}

.stat-label {
  color: var(--muted);
  font-size: 0.82rem;
}

.stat strong {
  font-size: 1.05rem;
  word-break: break-word;
}

.stat .price {
  font-size: 1.5rem;
  color: var(--accent);
}

.stat strong.has-error {
  color: var(--danger);
  font-size: 0.95rem;
  font-weight: 600;
  white-space: normal;
  line-height: 1.35;
  max-width: 100%;
}

.mono {
  font-family: var(--mono);
  font-size: 0.92rem !important;
}

.orders {
  display: grid;
  gap: 0.7rem;
}

/* Поле тикера: визуально заглавные (значение нормализует JS). */
input.ticker-uppercase {
  text-transform: uppercase;
}

.ticker-group {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #121920;
  overflow: hidden;
}

.ticker-group-toggle {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 0.75rem;
  align-items: center;
  padding: 0.85rem 1rem;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  cursor: pointer;
  text-align: left;
}

.ticker-group-toggle:hover {
  background: rgba(255, 255, 255, 0.03);
}

.ticker-group-title {
  font-weight: 700;
  letter-spacing: 0.02em;
}

.ticker-group-meta {
  color: var(--muted);
  font-size: 0.9rem;
}

.ticker-group-chevron {
  width: 0.55rem;
  height: 0.55rem;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  transition: transform 0.15s ease;
}

.ticker-group.collapsed .ticker-group-chevron {
  transform: rotate(-45deg);
}

.ticker-group-body {
  display: grid;
  gap: 0.65rem;
  padding: 0 0.85rem 0.85rem;
}

.ticker-group.collapsed .ticker-group-body {
  display: none;
}

.order-card {
  display: grid;
  gap: 0.35rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #0f151c;
}

.order-top {
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  flex-wrap: wrap;
}

.order-dir {
  font-weight: 700;
}

.order-dir.buy { color: var(--ok); }
.order-dir.sell { color: #ffb347; }

.docs h3 {
  margin-top: 0;
}

.docs h4 {
  margin: 1.1rem 0 0.4rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.docs p, .docs li, .docs dd {
  color: #c5d0dc;
  line-height: 1.55;
}

.docs ol, .docs ul {
  padding-left: 1.2rem;
  margin: 0.6rem 0 0.2rem;
}

.docs li + li {
  margin-top: 0.35rem;
}

.docs-pre {
  margin: 0.75rem 0;
  padding: 0.75rem 0.9rem;
  overflow-x: auto;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  background: rgba(15, 20, 25, 0.55);
  color: #d7e2ee;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85rem;
  line-height: 1.45;
  white-space: pre;
}

.docs-dl {
  display: grid;
  gap: 0.85rem;
  margin: 0;
}

.docs-dl dt {
  color: var(--text);
  font-weight: 600;
}

.docs-dl dd {
  margin: 0.25rem 0 0;
}

.docs .note {
  margin-top: 0.9rem;
  padding: 0.75rem 0.9rem;
  border-radius: 10px;
  border: 1px solid rgba(61, 214, 198, 0.25);
  background: rgba(61, 214, 198, 0.08);
  color: #d7f6f1;
}

.terminal {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #0a0e13;
  max-height: min(70vh, 720px);
  overflow: auto;
  flex: 1;
}

.terminal-log,
.terminal-state {
  margin: 0;
  padding: 1rem 1.1rem;
  font-family: var(--mono);
  font-size: 0.82rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  color: #c8d6e5;
}

.terminal-state {
  max-height: 360px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #0a0e13;
  color: #9fb0c3;
}

.terminal-input-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.65rem;
  align-items: center;
  margin-top: 0.85rem;
}

.terminal-prompt {
  font-family: var(--mono);
  color: var(--accent);
  font-size: 0.9rem;
}

.terminal-input-row input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #0a0e13;
  color: var(--text);
  padding: 0.7rem 0.85rem;
  font-family: var(--mono);
}

.terminal-input-row input:disabled {
  opacity: 0.5;
}

.quick-cmds {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
  margin: 0;
}

.btn.small {
  padding: 0.35rem 0.7rem;
  font-size: 0.8rem;
}

.test-layout,
.lab-layout {
  display: grid;
  gap: 1rem;
}

.test-session-bar,
.lab-session-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem 1.25rem;
  align-items: end;
}

.lab-session-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-left: auto;
}

.test-session-bar > h3,
.test-session-title h3,
.lab-session-title h3 {
  margin: 0;
}

.test-session-title,
.lab-session-title {
  display: grid;
  gap: 0.2rem;
  min-width: 12rem;
  flex: 1 1 14rem;
}

.test-session-title .muted,
.lab-session-title .muted {
  margin: 0;
  font-size: 0.85rem;
}

.test-entry-field {
  display: grid;
  gap: 0.35rem;
  min-width: 8rem;
  width: 9.5rem;
}

.test-entry-field input {
  width: 100%;
}

.test-meta-inline,
.lab-meta-inline {
  display: grid;
  grid-template-columns: repeat(4, minmax(6.5rem, 1fr));
  gap: 0.65rem;
  flex: 2 1 28rem;
}

.test-meta-inline {
  grid-template-columns: repeat(3, minmax(7rem, 1fr));
  flex: 2 1 22rem;
}

.test-meta-inline .stat,
.lab-meta-inline .stat {
  min-width: 0;
}

.bot-lab-tabs {
  display: inline-flex;
  gap: 0.35rem;
  margin: 0 0 0.85rem;
  padding: 0.25rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #0a0e13;
}

.bot-lab-tab {
  appearance: none;
  border: 0;
  border-radius: 9px;
  padding: 0.45rem 0.9rem;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
}

.bot-lab-tab:hover {
  color: var(--text);
}

.bot-orders-seg {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0 0 0.65rem;
}

.bot-orders-seg-btn {
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.3rem 0.7rem;
  background: var(--panel-2);
  color: var(--muted);
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
}

.bot-orders-seg-btn:hover {
  color: var(--text);
}

.bot-orders-seg-btn.is-active {
  color: var(--text);
  border-color: rgba(61, 214, 198, 0.45);
  background: rgba(61, 214, 198, 0.12);
  font-weight: 600;
}

/*
 * «Ожидают» / «Лимиты» с заявками:
 * внимание = жёлтая заливка; выбор = то же + тёмная обводка и бирюзовое кольцо.
 */
.bot-orders-seg-btn.has-attention:not(.is-active) {
  background: #ffd166;
  border-color: #ffd166;
  color: #1a1208;
  font-weight: 700;
}

.bot-orders-seg-btn.has-attention.is-active {
  background: #ffd166;
  border-color: #1a1208;
  color: #1a1208;
  font-weight: 700;
  box-shadow: 0 0 0 2px #ffd166, 0 0 0 4px var(--accent);
}

.bot-lab-tab.active {
  background: #1a222c;
  color: var(--text);
  box-shadow: inset 0 0 0 1px rgba(61, 139, 253, 0.35);
}

.bot-lab-panel[hidden] {
  display: none !important;
}

.test-page-tabs {
  margin-bottom: 1rem;
}

.test-page-panel[hidden] {
  display: none !important;
}

.roll-test-manual-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin-top: 0.65rem;
  color: var(--text);
  font-size: 0.92rem;
  cursor: pointer;
  user-select: none;
}

.roll-test-manual-toggle input {
  width: 1rem;
  height: 1rem;
}

/* Источник теста Семёныч: галка «вручную» и выбор бота в одной строке. */
.test-dca-source-row {
  align-items: flex-end;
}

.test-dca-source-row .roll-test-manual-toggle {
  margin-top: 0;
  margin-bottom: 0.55rem;
  flex: 0 0 auto;
  min-height: 2.5rem;
}

.test-dca-source-row #test-dca-bot-fields {
  flex: 1 1 14rem;
  min-width: 12rem;
}

.test-dca-source-row #test-dca-bot-fields[hidden] {
  display: none !important;
}

.roll-test-fields {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem 1rem;
  margin-top: 0.75rem;
}

.roll-test-fields[hidden] {
  display: none !important;
}

.roll-test-fields .test-entry-field {
  width: auto;
  min-width: 9rem;
  flex: 1 1 11rem;
}

/* .test-entry-field { display:grid } перебивает UA [hidden]. */
.roll-test-fields .test-entry-field[hidden],
.dca-settings-group[hidden],
.dca-settings-group .test-entry-field[hidden],
.dca-settings-groups .test-entry-field[hidden],
.grid > [hidden],
.grid label[hidden] {
  display: none !important;
}

.dca-settings-groups {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  width: 100%;
  margin-top: 0.75rem;
}

.dca-settings-group {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
}

.dca-settings-group > legend,
.dca-settings-group-title {
  margin: 0;
  padding: 0;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted, #9aa4b2);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.dca-settings-group .roll-test-fields {
  margin-top: 0;
}

.settings-dca-groups {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.settings-dca-groups .dca-settings-group .grid {
  margin-top: 0.35rem;
}

.roll-test-fields .test-entry-field:first-child {
  flex: 1.4 1 14rem;
}

.roll-test-fields .test-entry-field select {
  width: 100%;
  min-height: 2.5rem;
  padding: 0.45rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0a0e13;
  color: var(--text);
  font: inherit;
}

.roll-test-actions {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  padding-bottom: 0.1rem;
}

.roll-test-form .test-dca-session-meta {
  margin-top: 0.85rem;
  flex: none;
  width: 100%;
  max-width: 36rem;
  grid-template-columns: repeat(3, minmax(6.5rem, 1fr));
}

#test-roll-preview-panel {
  margin-top: 1rem;
}

.levels-section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.35rem 1rem;
  margin-bottom: 0.75rem;
  /* Выше sticky-шапки таблицы — заголовок не перекрывается «шторкой» */
  position: relative;
  z-index: 5;
}

.levels-section-head h3 {
  margin: 0;
}

.levels-section-head .muted {
  margin: 0;
}

.levels-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  align-items: center;
  margin: 0 0 0.75rem;
  /* Выше sticky-шапки — кнопка «Сформировать» всегда кликабельна */
  position: relative;
  z-index: 5;
}

.calculator-section .calculator-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  align-items: flex-end;
  margin: 0 0 0.5rem;
}

.calculator-controls .field {
  margin: 0;
  min-width: 10rem;
}

.calculator-controls .field span {
  display: block;
  font-size: 0.8rem;
  margin-bottom: 0.25rem;
  opacity: 0.8;
}

.calculator-params-empty {
  text-align: center;
}

.calculator-loading-cell {
  padding: 0.85rem 0.75rem !important;
}

.calculator-skeleton-row {
  display: block;
  height: 0.85rem;
  border-radius: 6px;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.04) 25%,
    rgba(255, 255, 255, 0.1) 50%,
    rgba(255, 255, 255, 0.04) 75%
  );
  background-size: 200% 100%;
  animation: calculator-skeleton-shimmer 1.2s ease-in-out infinite;
}

.calculator-skeleton-row--short {
  width: 42%;
  margin: 0 auto;
}

.calculator-skeleton-row--mid {
  width: 68%;
}

.calculator-skeleton-row--wide {
  width: 88%;
}

.calculator-summary.is-loading .calculator-card strong,
.calculator-summary.is-loading .calculator-card .muted {
  opacity: 0.35;
}

@keyframes calculator-skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.calculator-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  margin-top: 0.75rem;
  margin-bottom: 0.75rem;
}

.calculator-card {
  border: 1px solid var(--border, #2a3140);
  border-radius: 8px;
  padding: 0.85rem 1rem;
  background: var(--panel-2, rgba(255, 255, 255, 0.03));
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.calculator-card strong {
  font-size: 1.35rem;
  line-height: 1.2;
}

.calculator-card.is-over-cap strong {
  color: var(--danger, #e85d5d);
}

.calculator-warnings {
  margin: 0 0 0.75rem;
  padding-left: 1.2rem;
}

.calculator-table-wrap {
  margin-top: 0.75rem;
  padding: 0.65rem 0.75rem 0.55rem;
}

.calculator-breakdown-block {
  margin-top: 0.75rem;
}

.calculator-breakdown-block .calculator-table-title {
  margin: 0 0 0.55rem;
  padding: 0 0.75rem;
}

.calculator-grid-side-block {
  margin-top: 0.65rem;
}

.calculator-grid-side-block + .calculator-grid-side-block {
  margin-top: 1rem;
}

.calculator-table-subtitle {
  margin: 0 0 0.4rem;
  padding: 0 0.75rem;
  font-size: 0.88rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.calculator-grid-side-block.is-max-side .calculator-table-subtitle::after {
  content: ' · MAX';
  font-weight: 500;
  color: var(--muted, #8b93a7);
}

.calculator-max-detail-hint {
  margin: 0 0 0.55rem;
  padding: 0 0.75rem;
  font-size: 0.85rem;
  line-height: 1.45;
}

.calculator-breakdown-table tr.calculator-step-tp1 td {
  color: var(--muted, #8b93a7);
}

.calculator-breakdown-wrap {
  overflow: auto;
  max-height: min(55vh, 520px);
  padding: 0;
  /* Отдельный слой — меньше артефактов при sticky в overflow */
  transform: translateZ(0);
}

.calculator-breakdown-wrap .calculator-breakdown-table {
  margin: 0;
}

.calculator-table-title {
  margin: 0 0 0.55rem;
  font-size: 0.95rem;
  font-weight: 600;
}

.calculator-table-wrap .data-table thead th {
  padding: 0.7rem 0.75rem;
}

.calculator-breakdown-table {
  font-size: 0.85rem;
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.calculator-breakdown-table th,
.calculator-breakdown-table td {
  padding: 0.55rem 0.65rem;
  vertical-align: middle;
}

.calculator-breakdown-table tbody {
  position: relative;
  z-index: 0;
}

.calculator-breakdown-table thead {
  position: relative;
  z-index: 30;
}

.calculator-breakdown-table thead tr {
  /* Сплошная «шторка» над шапкой — без неё просвечивают символы tbody */
  box-shadow: 0 -24px 0 24px #121820;
}

.calculator-breakdown-table thead th {
  position: sticky;
  top: 0;
  z-index: 31;
  padding: 0.7rem 0.75rem;
  background-color: #121820;
  background-image: none;
  background-clip: border-box;
  color: var(--muted);
  border-top: 0;
  border-bottom: 1px solid #121820;
  box-shadow:
    0 1px 0 #121820,
    0 10px 14px -6px rgba(0, 0, 0, 0.55);
  transform: translateZ(0);
  backface-visibility: hidden;
}

.calculator-breakdown-table thead th::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: -4px;
  height: 4px;
  background: #121820;
  pointer-events: none;
}

.calculator-breakdown-table th.num,
.calculator-breakdown-table td.num,
.calculator-breakdown-table tfoot th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.calculator-breakdown-table td.calculator-formula {
  white-space: nowrap;
  text-align: left;
  font-size: 0.8rem;
  opacity: 0.92;
}

#bot-table-calculator-method td:nth-child(3),
#bot-table-calculator-method td:nth-child(4),
#bot-table-calculator-method th:nth-child(3),
#bot-table-calculator-method th:nth-child(4) {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.calculator-breakdown-table tfoot th,
.calculator-breakdown-table tfoot td {
  font-weight: 600;
  border-top: 1px solid var(--border, #2a3140);
  padding-top: 0.55rem;
}

.calculator-mobile-breakdown {
  display: none;
}

.calculator-mobile-card {
  border: 1px solid var(--border, #2a3140);
  border-radius: 8px;
  margin-bottom: 0.5rem;
  padding: 0.35rem 0.65rem;
}

.calculator-mobile-card summary {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  cursor: pointer;
  list-style: none;
}

.calculator-mobile-card summary::-webkit-details-marker {
  display: none;
}

.calculator-mobile-card dl {
  margin: 0.5rem 0 0.25rem;
  display: grid;
  gap: 0.25rem;
}

.calculator-mobile-card dl > div {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
}

.calculator-mobile-card dt {
  opacity: 0.75;
}

.calculator-mobile-card dd {
  margin: 0;
  text-align: right;
}

.calculator-mobile-total {
  display: grid;
  gap: 0.35rem;
  margin-top: 0.75rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border, #2a3140);
  border-radius: 8px;
}

.calculator-mobile-total > div {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
}

@media (max-width: 768px) {
  .calculator-summary {
    grid-template-columns: 1fr;
  }

  .calculator-breakdown-block {
    display: none;
  }

  .calculator-mobile-breakdown {
    display: block;
    margin-top: 0.75rem;
  }
}

/*
 * Три слоя угла: frame (фон+radius, без overflow) → wrap (clip) → scroll.
 * AA края overflow:hidden+radius иначе композитится со страницей / #121820
 * («Позиция» в левом верхнем углу). Frame того же цвета гасит щель.
 */
.levels-table-frame {
  position: relative;
  z-index: 0;
  isolation: isolate;
  background: #2a3340;
  box-shadow: 0 0 0 1px #2a3340;
  border-radius: 10px;
  /* Клип квадратной крышки в радиус; scrollport sticky — .levels-table-scroll */
  overflow: hidden;
}

/*
 * Крышка только дуги радиуса (10px): без box-shadow — иначе квадратный
 * «выступ» вниз/вправо поверх строки «Позиция».
 */
.levels-table-corner-cap {
  position: absolute;
  top: 0;
  left: 0;
  width: 10px;
  height: 10px;
  background: #2a3340;
  border-radius: 0;
  box-shadow: none;
  z-index: 80;
  pointer-events: none;
}

.levels-table-wrap {
  max-height: none;
  overflow: hidden;
  display: block;
  background: #2a3340;
  /* Скругление только у frame — иначе двойной AA */
  border-radius: 0;
  border: 0;
  position: relative;
  z-index: 0;
}

.table-wrap.levels-table-wrap {
  max-height: none;
  overflow: hidden;
  background: #2a3340;
  border-radius: 0;
  border: 0;
  position: relative;
  z-index: 0;
}

.levels-table-scroll {
  max-height: min(70vh, 720px);
  overflow: auto;
  background: #2a3340;
}

/*
 * Угол скругления: сплошная заливка шапки влево/вверх от первой ячейки.
 * Иначе в радиусе виден фон строки «Позиция» (#121820).
 */
.levels-grid-table thead tr.levels-summary-head th:first-child,
.levels-grid-table thead tr.levels-cols-head:first-child th:first-child {
  background-color: #2a3340;
  border-top-left-radius: 0;
  z-index: 34;
  box-shadow:
    -14px 0 0 0 #2a3340,
    0 -14px 0 0 #2a3340,
    -14px -14px 0 0 #2a3340;
}

/* Ниже первой строки шапки — чтобы #121820 не перекрывал угол */
.levels-grid-table thead tr.levels-summary-values th:first-child {
  z-index: 31;
}

.levels-grid-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
}

.levels-grid-table thead {
  position: relative;
  z-index: 30;
}

.levels-grid-table tbody {
  position: relative;
  z-index: 0;
}

/*
 * Ширину колонки при table-layout:fixed задаёт первая строка thead
 * (levels-summary-head) — пустой th:first-child сжимал «Позиция»/«Уровень».
 */
.levels-grid-table col.levels-col-label,
.levels-grid-table thead th:first-child,
.levels-grid-table th.levels-row-label,
.levels-grid-table td.levels-row-label {
  width: 9rem;
  min-width: 9rem;
  max-width: 11rem;
}

.levels-grid-table th,
.levels-grid-table td {
  text-align: center;
}

.levels-grid-table thead tr.levels-cols-head th:first-child,
.levels-grid-table th.levels-row-label,
.levels-grid-table td.levels-row-label {
  text-align: left;
  font-weight: 600;
  color: var(--text);
  /* Не ломать «Уровень»/«Позиция» посередине слова */
  white-space: nowrap;
  overflow-wrap: normal;
  word-break: normal;
  line-height: 1.3;
  vertical-align: middle;
}

/* overflow:hidden только у тела — на sticky th ломает отрисовку угла шапки */
.levels-grid-table tbody td.levels-row-label,
.levels-grid-table tbody th.levels-row-label {
  overflow: hidden;
  text-overflow: ellipsis;
}

.levels-grid-table tbody tr.levels-row td {
  background-color: #121820;
  border-bottom-color: #1a222c;
}

.levels-grid-table tbody tr.levels-row-pending td {
  background-color: #121820;
  color: var(--muted);
  border-bottom-color: #1a222c;
}

.levels-grid-table tbody tr.levels-row-filled td {
  background-color: #121820;
  border-bottom-color: #1a222c;
}

.levels-grid-table tbody tr.levels-branch-head th {
  background: rgba(61, 214, 198, 0.16);
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-align: left;
  padding: 0.45rem 0.65rem;
  border-bottom-color: rgba(61, 214, 198, 0.28);
  box-shadow: inset 3px 0 0 var(--accent);
  /* Ниже sticky-шапки — иначе teal пролезает в левый верхний угол */
  position: relative;
  z-index: 0;
}

.levels-grid-table tbody tr.levels-row-child td.levels-row-label {
  padding-left: 0.35rem;
}

.levels-grid-table .levels-indent {
  display: inline-block;
  margin-right: 0.35rem;
  color: var(--muted);
  font-weight: 500;
}

.levels-grid-table .levels-label-text {
  display: inline;
}

.levels-grid-table tbody tr.levels-row-reload td {
  background-color: #121820;
}

.levels-grid-table thead th.levels-summary-loading {
  opacity: 0.35;
}

.levels-grid-table td.levels-tp {
  font-variant-numeric: tabular-nums;
}

.levels-grid-table td.levels-tp-filled {
  color: var(--muted);
  text-decoration: line-through;
  text-decoration-thickness: 1px;
}

.levels-grid-table .pnl-pos {
  color: #7ddea0;
}

.levels-grid-table .pnl-neg {
  color: #f0a0a0;
}

.test-body,
.lab-body {
  display: grid;
  /* Консоль уже — таблицы справа шире и на одном уровне с консолью. */
  grid-template-columns: minmax(0, 0.75fr) minmax(300px, 1.35fr);
  gap: 1rem;
  align-items: start;
}

.test-console,
.lab-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.test-side,
.lab-side {
  display: grid;
  gap: 1rem;
  min-width: 0;
}

.bot-console-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.65rem;
  margin-bottom: 0.85rem;
  min-width: 0;
}

.bot-console-meta .stat {
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #0a0e13;
  min-width: 0;
  box-sizing: border-box;
  max-width: 100%;
}

.bot-console-meta .stat strong {
  word-break: break-word;
  overflow-wrap: anywhere;
}

.section.compact {
  padding: 0.9rem 1rem 1rem;
}

.section.compact h3 {
  margin-bottom: 0.65rem;
  font-size: 0.95rem;
}

.table-wrap {
  overflow: auto;
  max-height: 280px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #0a0e13;
}

.tokens-table-wrap {
  max-height: min(60vh, 520px);
}

/* Таблица на ширину контейнера; длинные ячейки — с переносом / ellipsis */
.tokens-table-wrap .data-table {
  width: 100%;
  table-layout: auto;
}

.tokens-table-wrap .data-table th,
.tokens-table-wrap .data-table td {
  white-space: normal;
  word-break: break-word;
}

.tokens-table-wrap .data-table td.mono,
.tokens-table-wrap .data-table .token-expiry-cell {
  white-space: nowrap;
}

.license-overview {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  align-items: stretch;
  margin-bottom: 1rem;
}

.license-overview > .section {
  margin: 0;
  min-width: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}

.license-status-head,
.license-features-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem 1rem;
  margin-bottom: 0.85rem;
  min-height: 1.85rem;
}

.license-status-head h3,
.license-features-head h3 {
  margin: 0;
}

.license-state-pill {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  padding: 0.28rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.3;
}

.license-state-pill.license-state-ok {
  color: var(--ok);
  border-color: rgba(99, 212, 113, 0.35);
  background: rgba(99, 212, 113, 0.1);
}

.license-state-pill.license-state-bad {
  color: var(--danger);
  border-color: rgba(255, 107, 107, 0.4);
  background: rgba(255, 107, 107, 0.1);
}

.license-meta-dl {
  display: grid;
  gap: 0;
  margin: 0;
}

.license-meta-row {
  display: grid;
  grid-template-columns: minmax(9rem, 12rem) minmax(0, 1fr);
  gap: 0.5rem 1rem;
  align-items: start;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--line);
}

.license-meta-row:last-child {
  border-bottom: none;
}

.license-meta-row dt {
  margin: 0;
  color: var(--muted);
  font-weight: 500;
  font-size: 0.9rem;
}

.license-meta-row dd {
  margin: 0;
  color: var(--text);
  min-width: 0;
  overflow-wrap: anywhere;
}

.license-meta-row dd.mono,
.license-meta-row code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.86rem;
}

.license-hwid {
  display: inline-block;
  word-break: break-all;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.86rem;
}

.license-reason:empty {
  display: none;
}

.license-reason:not(:empty) {
  margin: 0.75rem 0 0;
}

.license-status-actions.bots-toolbar {
  display: flex;
  flex-wrap: nowrap;
  align-items: stretch;
  justify-content: stretch;
  gap: 0.4rem;
  margin-top: auto;
  padding-top: 1rem;
  overflow: visible;
  width: 100%;
}

.license-status-actions.bots-toolbar .btn {
  flex: 1 1 0;
  min-width: 0;
  max-width: none;
  margin: 0;
  padding: 0.35rem 0.45rem;
  font-size: 0.78rem;
  line-height: 1.25;
  white-space: normal;
  text-align: center;
  hyphens: auto;
}

.license-status-actions.bots-toolbar .license-deactivate-btn {
  margin-left: 0;
}

.license-features-hint {
  margin: 0 0 0.75rem;
  padding: 0.65rem 0.8rem;
  border-radius: 10px;
  border: 1px solid rgba(255, 193, 7, 0.28);
  background: rgba(255, 193, 7, 0.08);
  color: #f0e6c8;
}

/* Без вложенной «коробки» .table-wrap — та же плашка, что у статуса */
.license-features-table {
  width: 100%;
  border-collapse: collapse;
  flex: 1;
  font-family: inherit;
  font-size: 0.95rem;
  background: transparent;
}

.license-features-table th,
.license-features-table td {
  border-left: none;
  border-right: none;
  border-top: none;
  border-bottom: 1px solid var(--line);
  padding: 0.55rem 0;
  vertical-align: middle;
  white-space: normal;
  background: transparent;
}

.license-features-table th[scope='row'] {
  position: static;
  text-align: left;
  color: var(--muted);
  font-weight: 500;
  font-size: 0.9rem;
  background: transparent;
}

.license-features-table tbody tr:last-child th,
.license-features-table tbody tr:last-child td {
  border-bottom: none;
}

.license-features-table .license-features-section-row th {
  padding: 0.55rem 0.65rem;
  border-bottom: 1px solid rgba(61, 214, 198, 0.22);
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-align: left;
  background: rgba(61, 214, 198, 0.08);
  border-radius: 6px;
}

.license-features-table .license-features-section-row.license-features-brokers-start th,
.license-features-table .license-features-section-row.license-features-limits-start th {
  /* Воздушный отступ от предыдущей секции */
  border-top: 0.85rem solid transparent;
  background-clip: padding-box;
}

.license-features-table tr.license-features-section-row + tr th,
.license-features-table tr.license-features-section-row + tr td {
  padding-top: 0.55rem;
  border-top: none;
}

.license-features-table .license-features-section-title {
  width: auto;
}

/* У строки перед секцией убрать нижнюю линию — секция сама отделяет */
.license-features-table tr:has(+ .license-features-section-row) th,
.license-features-table tr:has(+ .license-features-section-row) td {
  border-bottom: none;
  padding-bottom: 0.75rem;
}

.license-features-table .license-features-value {
  text-align: right;
  width: 42%;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.license-features-table .license-mark-yes {
  color: var(--ok);
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1;
}

.license-features-table .license-mark-no {
  color: var(--muted);
  font-weight: 500;
}

.license-features-table .license-mark-text {
  color: var(--text);
}

#license-features-section.is-license-inactive {
  opacity: 0.72;
}

@media (max-width: 960px) {
  .license-overview {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .license-meta-row {
    grid-template-columns: 1fr;
    gap: 0.2rem;
    padding: 0.7rem 0;
  }

  .license-features-table .license-features-value {
    width: 38%;
  }
}

.empty-row td {
  position: relative;
}

.empty-row.is-loading td::before {
  content: '';
  display: inline-block;
  width: 0.75rem;
  height: 0.75rem;
  margin-right: 0.45rem;
  border: 2px solid var(--line);
  border-top-color: var(--accent, #3dd6c6);
  border-radius: 50%;
  vertical-align: -0.1em;
  animation: shurik-spin 0.7s linear infinite;
}

@keyframes shurik-spin {
  to { transform: rotate(360deg); }
}

.tokens-table-wrap .data-table td.actions-cell {
  min-width: 12.5rem;
}

.tokens-table-wrap .data-table td.actions-cell .row-actions {
  display: inline-flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.25rem;
}

.tokens-table-wrap .data-table td.actions-cell .row-actions .btn {
  margin-left: 0;
}

.tokens-table-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  margin-bottom: 0.65rem;
}

.tokens-table-head h3 {
  margin: 0;
}

.tokens-table-head-main {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--mono);
  font-size: 0.75rem;
}

.data-table th,
.data-table td {
  padding: 0.45rem 0.55rem;
  border-bottom: 1px solid rgba(42, 53, 66, 0.85);
  text-align: left;
  white-space: nowrap;
}

/* Длинные причины в «Ожидает выставления» — перенос, без растягивания таблицы. */
.data-table td.cell-reason {
  white-space: normal;
  max-width: 11rem;
  min-width: 7.5rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.data-table.calculator-params-table th,
.data-table.calculator-params-table td {
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.data-table.levels-grid-table th,
.data-table.levels-grid-table td {
  text-align: center;
}

.data-table.levels-grid-table th.levels-row-label,
.data-table.levels-grid-table td.levels-row-label,
.data-table.levels-grid-table thead tr.levels-cols-head th:first-child,
.data-table.levels-grid-table thead th:first-child {
  text-align: left;
  white-space: nowrap;
}

/* DCA / Сеткыч MM: не наследовать ширину 14rem у th:first-child лестницы
   и fixed-раскладку — иначе «Сумма ₽» и «Шаг %» слипаются. */
.data-table.levels-grid-table.levels-dca-table,
.data-table.levels-grid-table.levels-grid-mm-table {
  table-layout: auto;
}

.data-table.levels-grid-table.levels-grid-mm-table thead tr.levels-cols-head th:first-child,
.data-table.levels-grid-table.levels-grid-mm-table tbody td:first-child,
.data-table.levels-grid-table.levels-grid-mm-table thead tr.levels-grid-summary-values th:first-child {
  width: auto;
  min-width: 3.25rem;
  max-width: 5rem;
  text-align: left;
  white-space: nowrap;
  font-weight: 600;
}

.data-table.levels-grid-table.levels-grid-mm-table thead tr.levels-cols-head th.num,
.data-table.levels-grid-table.levels-grid-mm-table th.num,
.data-table.levels-grid-table.levels-grid-mm-table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  padding-left: 0.65rem;
  padding-right: 0.65rem;
}

/* Денежная колонка — запас под «24 436,23», чтобы не наезжала на «Шаг %». */
.data-table.levels-grid-table.levels-grid-mm-table thead tr.levels-cols-head th.num:nth-child(6),
.data-table.levels-grid-table.levels-grid-mm-table td.num:nth-child(6),
.data-table.levels-grid-table.levels-grid-mm-table thead tr.levels-grid-summary-values th.num:nth-child(6) {
  min-width: 7.5rem;
  padding-left: 0.85rem;
  padding-right: 0.85rem;
}

.data-table.levels-grid-table.levels-grid-mm-table thead tr.levels-cols-head th.num:nth-child(7),
.data-table.levels-grid-table.levels-grid-mm-table td.num:nth-child(7),
.data-table.levels-grid-table.levels-grid-mm-table thead tr.levels-grid-summary-values th.num:nth-child(7) {
  min-width: 4.25rem;
  padding-left: 0.75rem;
}

#levels-grid-wrap .levels-table-wrap {
  overflow: hidden;
}

#levels-grid-wrap .levels-table-scroll {
  overflow: auto;
}

.data-table.levels-grid-table.levels-dca-table thead tr.levels-cols-head th:first-child,
.data-table.levels-grid-table.levels-dca-table tbody td:first-child {
  width: 2.75rem;
  min-width: 2.75rem;
  max-width: 3rem;
  text-align: left;
  font-weight: 400;
  white-space: nowrap;
  color: var(--muted);
}

.data-table.levels-grid-table.levels-dca-table thead tr.levels-cols-head th.levels-dca-label,
.data-table.levels-grid-table.levels-dca-table th.levels-dca-label,
.data-table.levels-grid-table.levels-dca-table td.levels-dca-label {
  text-align: left;
  font-weight: 600;
  white-space: nowrap;
  width: 4.5rem;
  min-width: 4rem;
  max-width: 6rem;
  color: var(--text);
}

.data-table.levels-grid-table.levels-dca-table thead tr.levels-cols-head th.num,
.data-table.levels-grid-table.levels-dca-table th.num,
.data-table.levels-grid-table.levels-dca-table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 400;
  white-space: nowrap;
}

.data-table th {
  position: sticky;
  top: 0;
  background: #121820;
  color: var(--muted);
  font-weight: 600;
  z-index: 1;
}

/* Многострочная шапка сетки уровней: top выставляет syncLevelsStickyOffsets() */
.levels-grid-table thead th {
  position: sticky;
  z-index: 31;
  background-color: #2a3340;
  background-image: none;
  background-clip: border-box;
  color: #d7dee8;
  /* Сплошная граница = фон: без rgba-щелей и без box-shadow (рваный текст / палочки) */
  border-top: 0;
  border-left: 0;
  border-right: 0;
  border-bottom: 1px solid #2a3340;
  box-shadow: none;
}

.levels-grid-table thead th:first-child {
  z-index: 32;
}

.levels-grid-table thead tr.levels-summary-values th {
  background-color: #121820;
  background-image: none;
  background-clip: border-box;
  color: var(--text);
  border-bottom: 1px solid #121820;
  box-shadow: none;
}

.levels-grid-table thead tr.levels-cols-head th {
  box-shadow: none;
  border-bottom: 1px solid #2a3340;
}

/* DCA / Сеткыч: итоги под шапкой колонок. */
.data-table.levels-grid-table.levels-dca-table thead tr.levels-dca-summary-values th,
.data-table.levels-grid-table.levels-grid-mm-table thead tr.levels-grid-summary-values th {
  font-weight: 600;
  white-space: nowrap;
}

.levels-dca-meta-compact {
  margin: 0 0 0.5rem;
  font-size: 0.85rem;
}

@media (min-width: 901px) {
  /* На десктопе итоги в строке таблицы — краткий meta не дублируем. */
  #levels-dca-meta.levels-dca-meta-compact {
    display: none;
  }
}

.data-table thead tr.filter-row th {
  top: 2rem;
  z-index: 2;
  padding: 0.35rem 0.45rem;
  background: #0f141b;
  font-weight: 400;
}

.data-table .table-filter {
  width: 100%;
  min-width: 5.5rem;
  box-sizing: border-box;
  padding: 0.3rem 0.4rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0a0e13;
  color: var(--text);
  font: inherit;
}

.data-table .table-filter:focus {
  outline: 1px solid var(--accent, #3d8bfd);
  border-color: var(--accent, #3d8bfd);
}

.data-table td.actions-cell {
  text-align: right;
  white-space: nowrap;
}

.data-table td.actions-cell .btn {
  margin-left: 0.25rem;
}

.data-table tr:last-child td {
  border-bottom: 0;
}

.data-table .empty-row td {
  color: var(--muted);
  text-align: center;
  padding: 0.85rem;
}

.data-table .side-buy {
  color: var(--ok);
  font-weight: 600;
}

.data-table .side-sell {
  color: #ff8f8f;
  font-weight: 600;
}

.bot-cancel-btn {
  padding: 0.2rem 0.55rem;
  font-size: 0.72rem;
  color: #ffb4b4;
  border-color: rgba(255, 143, 143, 0.35);
}

.bot-cancel-btn:hover {
  border-color: rgba(255, 143, 143, 0.7);
  color: #ffe0e0;
}

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .shell.is-sidebar-collapsed { grid-template-columns: 1fr; }
  .sidebar-collapse-btn { display: none; }
  /* Свернутое меню — только десктоп; на узком экране показываем подписи */
  .shell.is-sidebar-collapsed .brand-logo {
    display: block;
    width: min(100%, 220px);
    height: auto;
    object-fit: contain;
    border-radius: 12px;
  }
  .shell.is-sidebar-collapsed .brand-mark {
    display: none;
  }
  .shell.is-sidebar-collapsed .fleet-sidebar-counts {
    display: revert;
  }
  .shell.is-sidebar-collapsed .fleet-sidebar-dot {
    display: none;
  }
  .shell.is-sidebar-collapsed .fleet-sidebar-summary,
  .shell.is-sidebar-collapsed .fleet-sidebar-link {
    display: revert;
    width: auto;
    height: auto;
    padding: revert;
  }
  .shell.is-sidebar-collapsed .brand-tagline,
  .shell.is-sidebar-collapsed .brand-version,
  .shell.is-sidebar-collapsed .nav-label,
  .shell.is-sidebar-collapsed .fleet-sidebar-title,
  .shell.is-sidebar-collapsed .nav-more-summary-label {
    display: revert;
  }
  .shell.is-sidebar-collapsed .nav-more-body {
    position: static;
    min-width: 0;
    padding: 0.15rem 0 0.35rem;
    border: 0;
    background: transparent;
    box-shadow: none;
  }
  .shell.is-sidebar-collapsed .nav-more:not([open]) > .nav-more-body {
    display: none;
  }
  .shell.is-sidebar-collapsed .nav-more-summary > .nav-ico {
    display: none;
  }
  .shell.is-sidebar-collapsed .nav-more > .nav-more-summary::after {
    display: block;
  }
  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .nav { grid-template-columns: 1fr 1fr; }
  .create-grid { grid-template-columns: 1fr; }
  .account-card { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; }
  .grid { grid-template-columns: 1fr; }
  .status-grid { grid-template-columns: 1fr; }
  .terminal-input-row { grid-template-columns: 1fr; }
  .test-body,
  .lab-body {
    grid-template-columns: 1fr;
    align-items: stretch;
  }
  .test-meta-inline,
  .lab-meta-inline { grid-template-columns: 1fr; }
  .test-session-bar,
  .lab-session-bar { align-items: stretch; }
  .bot-console-meta { grid-template-columns: 1fr; }
}

/* Позиции: таблица на странице «Робот» */
.positions-section {
  display: grid;
  gap: 0.75rem;
}

.positions-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 1rem;
}

.positions-header h3 {
  margin: 0;
}

.positions-header .muted {
  margin: 0.25rem 0 0;
}

.positions-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.5rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.positions-summary strong {
  color: var(--text);
}

/* Карточки позиций — компактно: шапка + метрики в ряд + подвал */
.position-card {
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.18);
}

.position-card-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.3rem;
}

.position-card-title {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  min-width: 0;
}

.position-card-ticker {
  font-family: var(--mono);
  font-size: 0.95rem;
  font-weight: 700;
  text-transform: uppercase;
}

.position-card-kind {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 500;
  text-transform: lowercase;
}

.position-card-pnl {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 0.88rem;
  flex-shrink: 0;
}

.position-card-metrics {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.15rem 0.85rem;
  margin-bottom: 0.3rem;
}

.position-card-metric {
  display: inline-flex;
  align-items: baseline;
  gap: 0.3rem;
  min-width: 0;
}

.position-card-metric .lbl {
  color: var(--muted);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.position-card-metric .val {
  font-size: 0.82rem;
  font-weight: 600;
  word-break: break-word;
}

.position-card-metric .val.mono {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

.position-card-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.position-card-foot .positions-close-btn {
  flex-shrink: 0;
  padding: 0.2rem 0.55rem;
  font-size: 0.75rem;
}

.positions-cards-empty {
  padding: 0.75rem;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 10px;
}

.pnl-pos {
  color: var(--ok);
}

.pnl-neg {
  color: var(--danger);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.bot-select-label {
  display: flex;
  align-items: center;
}

.bot-select {
  min-width: 12rem;
  max-width: 18rem;
  padding: 0.55rem 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
}

.content:has(.page-bots.active) {
  width: 100%;
  max-width: none;
}

.content:has(#page-tokens.active),
.content:has(.page-tokens.active),
.content:has(#page-accounts.active),
.content:has(.page-accounts.active) {
  width: max-content;
  max-width: 100%;
}

/* Заголовок не растягивает страницу шире таблицы */
.page-tokens > .page-header,
.page-accounts > .page-header {
  max-width: 42rem;
}

.page-eyebrow {
  margin: 0 0 0.25rem;
}

.bots-page-header {
  margin-bottom: 1.25rem;
}

.bots-page-header .sub {
  max-width: 36rem;
}

.bots-fleet {
  padding-bottom: 1.15rem;
}

.bots-fleet-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem 1.5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.bots-list-header h3 {
  margin: 0;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
}

.bots-list-header .muted {
  margin: 0.3rem 0 0;
  max-width: 28rem;
  line-height: 1.45;
}

.bots-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem 0.75rem;
  align-items: center;
  justify-content: flex-end;
}

.bots-toolbar-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
}

/* Общая сетка колонок флота — одна на шапку/фильтры/строки, иначе при resize/collapse разъезжается.
   width: max-content — скрытый столбец реально укорачивает таблицу (не раздувает fr-соседей). */
.bots-fleet-table {
  --fleet-cols:
    0.55rem
    10rem
    8.5rem
    5.25rem
    3.75rem
    6.5rem
    4.5rem
    5.75rem
    5rem
    5rem
    6.25rem;
  --fleet-col-gap: 0.4rem;
  --fleet-row-pad-x: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-height: 0;
  width: max-content;
  max-width: 100%;
}

.bots-fleet-table-chrome {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  flex-shrink: 0;
  z-index: 3;
}

.bots-fleet-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.55rem 0.75rem;
  min-width: 0;
}

.bots-columns-menu {
  position: relative;
}

.bots-columns-menu > summary {
  list-style: none;
  cursor: pointer;
}

.bots-columns-menu > summary::-webkit-details-marker {
  display: none;
}

.bots-columns-menu-body {
  position: absolute;
  top: calc(100% + 0.35rem);
  right: 0;
  z-index: 20;
  display: grid;
  gap: 0.35rem;
  min-width: 11rem;
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(15, 20, 27, 0.98);
  box-shadow: var(--shadow);
}

.bots-columns-menu:not([open]) > .bots-columns-menu-body {
  display: none;
}

.bots-columns-option {
  display: grid;
  grid-template-columns: 1rem 1fr;
  align-items: center;
  column-gap: 0.5rem;
  margin: 0;
  padding: 0.15rem 0;
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 600;
  line-height: 1.25;
  cursor: pointer;
  user-select: none;
}

.bots-columns-option input {
  box-sizing: border-box;
  width: 1rem;
  height: 1rem;
  margin: 0;
  padding: 0;
  justify-self: center;
  accent-color: var(--accent);
  flex-shrink: 0;
}

.bots-columns-option span {
  min-width: 0;
  text-align: left;
}

/* Скрытые столбцы флота: ячейка уходит из grid, трек убран из --fleet-cols */
.bots-fleet-table.is-hide-col-account [data-fleet-col="account"],
.bots-fleet-table.is-hide-col-account .bot-row-account,
.bots-fleet-table.is-hide-col-strategy [data-fleet-col="strategy"],
.bots-fleet-table.is-hide-col-strategy .bot-row-strategy-cell,
.bots-fleet-table.is-hide-col-ticker [data-fleet-col="ticker"],
.bots-fleet-table.is-hide-col-ticker .bot-row-ticker,
.bots-fleet-table.is-hide-col-lots [data-fleet-col="lots"],
.bots-fleet-table.is-hide-col-lots .bot-row-lots,
.bots-fleet-table.is-hide-col-price [data-fleet-col="price"],
.bots-fleet-table.is-hide-col-price .bot-row-price,
.bots-fleet-table.is-hide-col-mode [data-fleet-col="mode"],
.bots-fleet-table.is-hide-col-mode .bot-row-mode,
.bots-fleet-table.is-hide-col-status [data-fleet-col="status"],
.bots-fleet-table.is-hide-col-status .bot-row-status,
.bots-fleet-table.is-hide-col-started [data-fleet-col="started"],
.bots-fleet-table.is-hide-col-started .bot-row-started {
  display: none !important;
}

.bot-row-filters {
  min-height: 0;
  align-items: center;
  /* Тот же горизонтальный padding/бордер, что у .bot-row — иначе колонки шапки и фильтров расходятся. */
  padding: 0.3rem var(--fleet-row-pad-x, 0.5rem) 0.4rem;
  border: 1px solid rgba(125, 139, 156, 0.14);
  border-left-width: 3px;
  border-left-color: transparent;
  border-radius: 8px;
  background: rgba(10, 14, 20, 0.92);
  cursor: default;
  box-shadow: none;
  pointer-events: auto;
  margin-bottom: 0;
}

.bot-row-filters .bot-row-lots,
.bot-row-filters .bot-row-price,
.bot-row-filters .bot-row-mode,
.bot-row-filters .bot-row-started,
.bot-row-filters .bot-row-quick {
  /* Пустые ячейки фильтров на всю ширину трека — иначе «схлопываются» в центр и кажется, что колонки поехали. */
  justify-self: stretch;
  width: 100%;
  min-height: 1px;
}

.bot-row-filters .bot-col-filter {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: 1.7rem;
  box-sizing: border-box;
  justify-self: stretch;
  align-self: center;
  margin: 0;
  border: 1px solid rgba(125, 139, 156, 0.32);
  border-radius: 6px;
  background: #0c1016;
  color: var(--text);
  font: inherit;
  font-size: 0.74rem;
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: normal;
  text-transform: none;
  padding: 0 0.45rem;
  box-shadow: none;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.bot-row-filters select.bot-col-filter {
  cursor: pointer;
  /* Место под кастомную стрелку — как у input по высоте/бордеру. */
  padding-right: 1.35rem;
  background-color: #0c1016;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'%3E%3Cpath stroke='%238793a3' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round' d='M1.5 1.8 6 6.2l4.5-4.4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.4rem center;
  background-size: 0.65rem auto;
  text-overflow: ellipsis;
}

.bot-row-filters .bot-col-filter::placeholder {
  color: #7d8b9c;
  opacity: 1;
  font-weight: 500;
}

.bot-row-filters .bot-col-filter:hover {
  border-color: rgba(125, 139, 156, 0.5);
}

/* Перебиваем глобальные input:focus / select:focus — иначе «Статус» светится акцентом. */
.bot-row-filters .bot-col-filter:focus,
.bot-row-filters .bot-col-filter:focus-visible {
  outline: none;
  border-color: rgba(61, 214, 198, 0.55);
  box-shadow: 0 0 0 1px rgba(61, 214, 198, 0.22);
}

.bot-row-filters input.bot-col-filter::-webkit-search-cancel-button {
  cursor: pointer;
  filter: grayscale(1) opacity(0.65);
}

.bots-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-height: 0;
  /* На десктопе прокрутка — только строки; шапка/футер sticky внутри .bots-fleet-table. */
}

.bots-list-pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem 1rem;
  margin-top: 0.15rem;
  padding: 0.45rem 0.35rem 0.25rem;
  flex-shrink: 0;
  z-index: 3;
  background: linear-gradient(180deg, rgba(15, 20, 27, 0.92), rgba(15, 20, 27, 0.98));
  border-top: 1px solid rgba(125, 139, 156, 0.14);
}

.bots-list-pagination[hidden] {
  display: none !important;
}

.bots-page-size-label {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
}

.bots-page-size-label select {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(18, 24, 33, 0.95);
  color: var(--text);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.3rem 0.65rem;
  cursor: pointer;
}

.bots-page-size-label select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.bots-page-numbers {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem;
}

.bots-page-btn {
  min-width: 2rem;
  height: 2rem;
  padding: 0 0.55rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

.bots-page-btn:hover {
  color: var(--text);
  border-color: rgba(61, 214, 198, 0.35);
}

.bots-page-btn.is-active {
  color: #06201d;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
  cursor: default;
}

.bots-page-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.bots-page-ellipsis {
  min-width: 1.25rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  user-select: none;
}

.bots-fleet-picker {
  display: none;
}

.bots-empty {
  padding: 1.4rem 1rem;
  border: 1px dashed var(--line);
  border-radius: 14px;
  text-align: center;
  background: rgba(0, 0, 0, 0.15);
}

.bots-empty strong {
  display: block;
  margin-bottom: 0.35rem;
}

.bots-empty .muted {
  margin: 0;
}

.bot-row {
  display: grid;
  grid-template-columns: var(--fleet-cols);
  align-items: center;
  column-gap: var(--fleet-col-gap, 0.4rem);
  row-gap: 0.25rem;
  /* min-content: высота по контенту (border-box + фиксированный min-height
     иначе обрезает перенос имени и ломает вертикальный центр). */
  height: auto;
  min-height: min-content;
  padding: 0.3rem var(--fleet-row-pad-x, 0.5rem);
  border-radius: 10px;
  border: 1px solid var(--line);
  border-left-width: 3px;
  border-left-color: var(--line);
  background: linear-gradient(165deg, rgba(29, 38, 48, 0.95), rgba(18, 24, 33, 0.98));
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
  box-sizing: border-box;
}

.bot-row > * {
  min-width: 0;
}

/* Классический вид (как в master): узкая колонка контента + однострочные имя/счёт.
   Двухколоночный десктоп-layout отключается ниже в @media (min-width: 769px). */
body.is-fleet-ui-classic .content:has(.page-bots.active) {
  width: min(1100px, 100%);
  max-width: 100%;
}

body.is-fleet-ui-classic .bots-list .bot-row:not(.bot-row-head):not(.bot-row-filters) {
  min-height: 2.65rem;
  padding: 0.35rem 0.7rem;
  column-gap: 0.65rem;
}

body.is-fleet-ui-classic .bots-list .bot-row:not(.bot-row-head) .bot-row-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  overflow-wrap: normal;
  line-height: 1.25;
}

body.is-fleet-ui-classic .bots-list .bot-row:not(.bot-row-head) .bot-row-account-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  overflow-wrap: normal;
}

.bot-row-head {
  min-height: 0;
  align-items: center;
  /* Те же border/padding, что у строк — иначе треки шапки и тела расходятся. */
  padding: 0.25rem var(--fleet-row-pad-x, 0.5rem);
  border: 1px solid transparent;
  border-left-width: 3px;
  border-left-color: transparent;
  background: rgba(15, 20, 27, 0.96);
  cursor: default;
  pointer-events: none;
  /* Как раньше: читаемый caps, без «сжатого» bold и переносов по буквам */
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #7d8b9c;
  box-shadow: none;
}

.bot-row-head .bot-row-sort {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  margin: 0;
  padding: 0.15rem 0.1rem;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  min-width: 0;
  max-width: 100%;
}

.bot-row-head .bot-row-sort:hover,
.bot-row-head .bot-row-sort:focus-visible {
  color: #c5d0dc;
  outline: none;
}

.bot-row-head .bot-row-sort:focus-visible {
  box-shadow: 0 0 0 1px rgba(61, 214, 198, 0.45);
}

.bot-row-head .bot-row-sort[aria-sort="ascending"],
.bot-row-head .bot-row-sort[aria-sort="descending"] {
  color: #9eb0c2;
}

.bot-row-sort-ind {
  display: inline-block;
  width: 0.55rem;
  flex: 0 0 auto;
  font-size: 0.58rem;
  line-height: 1;
  opacity: 0.35;
}

.bot-row-sort-ind::before {
  content: '↕';
}

.bot-row-head .bot-row-sort[aria-sort="ascending"] .bot-row-sort-ind {
  opacity: 1;
  color: var(--accent);
}

.bot-row-head .bot-row-sort[aria-sort="ascending"] .bot-row-sort-ind::before {
  content: '▲';
}

.bot-row-head .bot-row-sort[aria-sort="descending"] .bot-row-sort-ind {
  opacity: 1;
  color: var(--accent);
}

.bot-row-head .bot-row-sort[aria-sort="descending"] .bot-row-sort-ind::before {
  content: '▼';
}

.bot-row-head .bot-row-name,
.bot-row-head .bot-row-strategy-cell,
.bot-row-head .bot-row-ticker,
.bot-row-head .bot-row-account,
.bot-row-head .bot-row-mode,
.bot-row-head .bot-row-status,
.bot-row-head .bot-row-started,
.bot-row-head .bot-row-quick {
  font-size: inherit;
  font-weight: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  color: inherit;
  font-family: inherit;
}

.bot-row-head .bot-row-strategy-cell {
  text-align: left;
  justify-content: flex-start;
}

.bot-row-head .bot-row-ticker,
.bot-row-head .bot-row-account,
.bot-row-head .bot-row-mode,
.bot-row-head .bot-row-status,
.bot-row-head .bot-row-started,
.bot-row-head .bot-row-quick {
  text-align: center;
  justify-content: center;
}

.bot-row-head .bot-row-price,
.bot-row-head .bot-row-lots {
  text-align: center;
  justify-content: center;
  color: inherit;
  font-family: inherit;
  font-size: inherit;
  font-weight: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
}

.bot-row-head .bot-row-quick {
  justify-content: center;
  text-align: center;
  min-height: 0;
  white-space: nowrap;
}

.bot-row.status-running {
  border-left-color: var(--accent);
}

.bot-row.status-crashed {
  border-left-color: var(--danger);
}

@media (hover: hover) {
  .bot-row:hover:not(.bot-row-head) {
    border-color: rgba(61, 214, 198, 0.4);
  }
}

.bot-row:active:not(.bot-row-head) {
  background: linear-gradient(165deg, rgba(32, 42, 52, 0.98), rgba(18, 24, 33, 0.98));
}

.bot-row.is-selected {
  border-color: rgba(61, 214, 198, 0.75);
  box-shadow: 0 0 0 1px rgba(61, 214, 198, 0.2);
  background:
    radial-gradient(120px 70px at 100% 0%, rgba(61, 214, 198, 0.12), transparent 70%),
    linear-gradient(165deg, rgba(32, 48, 52, 0.98), rgba(18, 24, 33, 0.98));
  cursor: default;
}

.bot-row-dot-slot {
  width: 0.5rem;
  height: 0.5rem;
  align-self: center;
  justify-self: center;
}

.bot-row-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: #5a6878;
  box-shadow: 0 0 0 3px rgba(90, 104, 120, 0.18);
  align-self: center;
  justify-self: center;
}

.bot-row.status-running .bot-row-dot {
  background: var(--ok);
  box-shadow: 0 0 0 3px rgba(99, 212, 113, 0.22);
  animation: bot-pulse 1.8s ease-in-out infinite;
}

.bot-row.status-crashed .bot-row-dot {
  background: var(--danger);
  box-shadow: 0 0 0 3px rgba(255, 107, 107, 0.22);
}

@keyframes bot-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.65; transform: scale(0.92); }
}

.bot-row-name {
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: -0.01em;
  min-width: 0;
  overflow: visible;
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.35;
  text-align: left;
  justify-self: stretch;
  align-self: center;
}

.bot-row-head .bot-row-name {
  text-align: left;
}

.bot-row-broker {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  justify-self: center;
}

.bot-row-strategy-cell {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  justify-self: stretch;
  align-self: center;
  min-width: 0;
}

.bot-row-strategy-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.28rem;
  max-width: 100%;
  min-width: 0;
}

.bot-row-strategy {
  display: inline-block;
  flex: 0 0 auto;
  padding: 0.12rem 0.35rem;
  border-radius: 4px;
  border: 1px solid rgba(125, 139, 156, 0.35);
  background: rgba(125, 139, 156, 0.12);
  color: #c5d0dc;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.2;
  white-space: nowrap;
  overflow: visible;
}

.bot-row-strategy.strategy-tp_ladder {
  border-color: rgba(61, 214, 198, 0.4);
  background: rgba(61, 214, 198, 0.12);
  color: #9eefe4;
}

.bot-row-strategy.strategy-dca {
  border-color: rgba(120, 170, 255, 0.4);
  background: rgba(120, 170, 255, 0.12);
  color: #b8d0ff;
}

.bot-row-strategy.strategy-grid {
  border-color: rgba(232, 176, 88, 0.45);
  background: rgba(232, 176, 88, 0.14);
  color: #f0d09a;
}

.bot-row-grid-dir {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 1.15rem;
  height: 1.15rem;
  border-radius: 4px;
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1;
  border: 1px solid transparent;
}

.bot-row-grid-dir.is-long {
  color: #6ddea0;
  border-color: rgba(109, 222, 160, 0.45);
  background: rgba(109, 222, 160, 0.12);
}

.bot-row-grid-dir.is-short {
  color: #f0a0a0;
  border-color: rgba(240, 160, 160, 0.45);
  background: rgba(240, 160, 160, 0.12);
}

.bot-row-grid-dir.is-both {
  color: #e8b058;
  border-color: rgba(232, 176, 88, 0.45);
  background: rgba(232, 176, 88, 0.12);
}

.bot-row-head .bot-row-strategy-cell {
  font-size: inherit;
  font-weight: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  color: inherit;
  justify-content: flex-start;
}

.bot-row-ticker {
  font-family: var(--mono);
  font-size: 0.88rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  white-space: nowrap;
  text-align: center;
  justify-self: stretch;
  align-self: center;
}

.bot-row-account {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.4rem;
  min-width: 0;
  max-width: 100%;
  justify-self: stretch;
  align-self: center;
}

.bot-row-account-broker {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
}

.bot-row-account-broker .bot-card-broker {
  width: 1.15rem;
  height: 1.15rem;
}

.bot-row-account-broker .bot-card-broker img {
  width: 1.15rem;
  height: 1.15rem;
}

.bot-row-account-label {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text);
  white-space: normal;
  overflow: visible;
  overflow-wrap: anywhere;
  line-height: 1.3;
  min-width: 0;
}

.bot-row-account-label.muted {
  color: var(--muted);
}

.bot-row-head .bot-row-account {
  justify-content: center;
}

.bot-row-lots {
  font-family: var(--mono);
  font-size: 0.88rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  text-align: center;
  color: var(--text);
  justify-self: stretch;
  align-self: center;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bot-row-lots-short {
  color: var(--danger, #e85d5d);
}

.bot-row-price {
  font-family: var(--mono);
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  text-align: center;
  justify-self: stretch;
  align-self: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 1.1rem;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bot-row-price.is-price-loading {
  color: transparent;
}

.bot-row-price-skeleton {
  display: inline-block;
  width: 3.25rem;
  height: 0.7rem;
  border-radius: 999px;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.06) 25%,
    rgba(61, 214, 198, 0.22) 50%,
    rgba(255, 255, 255, 0.06) 75%
  );
  background-size: 200% 100%;
  animation: bot-price-skeleton-shimmer 1.1s ease-in-out infinite;
}

@keyframes bot-price-skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

@media (prefers-reduced-motion: reduce) {
  .bot-row-price-skeleton {
    animation: none;
    background: rgba(255, 255, 255, 0.1);
  }
}

.bot-row-mode {
  justify-self: stretch;
  align-self: center;
  min-width: 0;
  width: 100%;
  text-align: center;
}

.bot-row-mode .mode-badge {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bot-row-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  justify-self: stretch;
  align-self: center;
  gap: 0.4rem;
  min-width: 0;
  flex-wrap: wrap;
  text-align: center;
}

.bot-status-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  border: 1px solid var(--line);
  color: var(--muted);
  background: rgba(0, 0, 0, 0.2);
  white-space: nowrap;
}

.bot-status-chip.is-running {
  color: #9be7a5;
  border-color: rgba(99, 212, 113, 0.4);
  background: rgba(99, 212, 113, 0.12);
}

.bot-status-chip.is-paused {
  /* Отдельно от mode-live (оранжевый «Боевой»), чтобы чипы не сливались. */
  color: #d7c2ff;
  border-color: rgba(167, 139, 250, 0.5);
  background: rgba(124, 92, 220, 0.16);
}

.bot-status-chip.is-crashed {
  color: #ffb4b4;
  border-color: rgba(255, 107, 107, 0.45);
  background: rgba(255, 107, 107, 0.12);
}

.bot-status-chip.is-pending {
  color: #92400e;
  background: #fef3c7;
  border-color: #fcd34d;
}

.bot-status-chip.is-stopped {
  color: #9aa8b8;
  border-color: rgba(147, 161, 179, 0.35);
  background: rgba(0, 0, 0, 0.18);
}

.bot-row-started {
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  white-space: nowrap;
  text-align: center;
  justify-self: stretch;
  align-self: center;
  line-height: 1.2;
}

.bot-row-share {
  font-size: 0.7rem;
  color: #ffb86b;
  font-weight: 600;
  white-space: nowrap;
}

.bot-row-overlap {
  font-size: 0.7rem;
  color: #ff9f6b;
  font-weight: 600;
  white-space: nowrap;
}

.bot-row-quick {
  display: flex;
  justify-content: center;
  align-items: center;
  align-self: center;
  gap: 0.3rem;
  min-height: 1.75rem;
}

.bot-row-head .bot-row-quick {
  justify-content: center;
  text-align: center;
}

.bot-row-quick .btn {
  min-width: 4rem;
  justify-content: center;
}

.bot-row-menu-btn {
  min-width: 2rem !important;
  padding-left: 0.35rem;
  padding-right: 0.35rem;
  font-size: 1.05rem;
  line-height: 1;
  letter-spacing: 0;
}

.bot-row-menu {
  position: fixed;
  z-index: 80;
  min-width: 11rem;
  padding: 0.3rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(18, 24, 33, 0.98);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.4);
  display: grid;
  gap: 0.15rem;
}

.bot-row-menu[hidden] {
  display: none !important;
}

.bot-row-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.45rem 0.65rem;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
}

.bot-row-menu-item:hover:not(:disabled) {
  background: rgba(61, 214, 198, 0.12);
}

.bot-row-menu-item:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.bot-row-menu-item.danger-text {
  color: #ffb4b4;
}

.bot-detail-toolbar-meta {
  display: flex;
  align-items: baseline;
  gap: 0.35rem;
  font-size: 0.88rem;
}

.bot-detail-toolbar-meta strong {
  font-size: 0.95rem;
  letter-spacing: -0.01em;
}

@media (max-width: 960px) {
  .bots-fleet-table {
    --fleet-cols:
      0.7rem
      9rem
      7.5rem
      5.25rem
      3.5rem
      6.25rem
      4.25rem
      5.25rem
      4.75rem
      4.75rem
      6.5rem;
    --fleet-col-gap: 0.45rem;
  }
}

.bot-card-broker {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
  background: transparent;
}

.bot-card-broker img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.bot-card-broker-text {
  width: auto;
  min-width: 1.4rem;
  padding: 0 0.35rem;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text);
  background: rgba(42, 53, 66, 0.9);
}

.broker-cell {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  vertical-align: middle;
}

.broker-cell .bot-card-broker {
  width: 1.35rem;
  height: 1.35rem;
}

.broker-cell-label {
  line-height: 1.2;
}

.accounts-card-broker {
  display: inline-flex;
  vertical-align: middle;
}

.btn:focus-visible,
.nav-link:focus-visible,
.fleet-filter:focus-visible,
.bot-row:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.nav {
  display: grid;
  gap: 0.85rem;
  margin: 1.25rem 0 1.2rem;
  align-content: start;
}

.nav-group {
  display: grid;
  gap: 0.35rem;
  align-content: start;
}

.nav-group-label {
  padding: 0 0.85rem;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #6d7c8f;
}

.nav-more {
  border-radius: 12px;
  border: 1px solid transparent;
}

.nav-more.has-active {
  border-color: rgba(61, 214, 198, 0.18);
  background: rgba(0, 0, 0, 0.12);
}

.nav-more-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  list-style: none;
  cursor: pointer;
  user-select: none;
  padding: 0.65rem 0.85rem;
  border-radius: 12px;
  color: var(--muted);
  font-weight: 600;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-more-summary::-webkit-details-marker {
  display: none;
}

.nav-more-summary::after {
  content: '';
  width: 0.45rem;
  height: 0.45rem;
  margin-left: auto;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  opacity: 0.7;
  transition: transform 0.18s ease;
  flex-shrink: 0;
}

.nav-more[open] > .nav-more-summary::after {
  transform: rotate(-135deg);
  margin-top: 0.2rem;
}

.nav-more-summary:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

.nav-more-summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.nav-more-summary-label {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.nav-more-summary > .nav-ico {
  display: none;
}

.shell.is-sidebar-collapsed .nav-more-summary > .nav-ico {
  display: inline-block;
}

.nav-more-body {
  display: grid;
  gap: 0.25rem;
  padding: 0.15rem 0 0.35rem;
}

.nav-more-body .nav-link {
  padding-left: 1.05rem;
}

.nav-more-body .nav-action {
  display: block;
  width: 100%;
  box-sizing: border-box;
  text-align: left;
  background: transparent;
  cursor: pointer;
  font: inherit;
  color: var(--muted);
}

.nav-more-body .nav-action:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.03);
}

.nav-more-body .nav-action:disabled {
  opacity: 0.55;
  cursor: wait;
}

.nav-dev-archive-progress {
  display: grid;
  gap: 0.2rem;
  padding: 0.15rem 1.05rem 0.45rem;
}

/* display:grid перебивает UA [hidden] — иначе полоска видна без клика. */
.nav-dev-archive-progress[hidden] {
  display: none !important;
}

.nav-dev-archive-progress-bar {
  width: 100%;
  height: 0.45rem;
  border: 0;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.08);
  accent-color: var(--accent, #5b8def);
}

.nav-dev-archive-progress-bar::-webkit-progress-bar {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
}

.nav-dev-archive-progress-bar::-webkit-progress-value {
  background: var(--accent, #5b8def);
  border-radius: 999px;
}

.nav-dev-archive-progress-label {
  font-size: 0.72rem;
  line-height: 1.25;
  color: var(--muted);
}

.mobile-dev-archive-progress {
  padding: 0.15rem 1rem 0.55rem;
}

/* Бейдж у токенов/лицензии — вправо, иконки с подписью в одной колонке с «Роботы» */
.nav-link .nav-badge {
  margin-left: auto;
  flex: 0 0 auto;
}

.nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.15rem;
  height: 1.15rem;
  padding: 0 0.3rem;
  border-radius: 999px;
  background: var(--danger);
  color: #1a0808;
  font-size: 0.72rem;
  font-weight: 800;
}

.nav-badge[hidden] {
  display: none !important;
}

.fleet-sidebar-summary {
  margin: 1rem 0 0;
  padding: 0.7rem 0.85rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.22);
}

.fleet-sidebar-summary.has-live {
  border-color: rgba(99, 212, 113, 0.35);
}

.fleet-sidebar-summary.has-danger {
  border-color: rgba(255, 107, 107, 0.45);
}

.fleet-sidebar-link {
  display: grid;
  gap: 0.2rem;
  text-decoration: none;
  color: inherit;
}

.fleet-sidebar-dot {
  display: none;
}

.fleet-sidebar-title {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.fleet-sidebar-counts {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
}

.bots-fleet-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  margin-bottom: 1rem;
  padding: 0.75rem 0.9rem;
  border-radius: 12px;
  border: 1px solid rgba(42, 53, 66, 0.9);
  background: rgba(0, 0, 0, 0.18);
}

.bots-fleet-counts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem 1rem;
  font-size: 0.88rem;
  color: var(--muted);
}

.fleet-count strong {
  color: var(--text);
  font-weight: 700;
}

.fleet-count.is-ok strong { color: var(--ok); }
.fleet-count.is-danger strong { color: var(--danger); }

.bots-fleet-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

/* Meta/карточка флота — только телефон; на десктопе колонки таблицы. */
.bot-row-mobile-meta {
  display: none;
}

.bots-mobile-back-row {
  display: none;
}

.bot-console-hero {
  display: none;
}

.mobile-sheet-group-label {
  margin: 0.55rem 0 0.15rem 0.35rem;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.mobile-sheet-group-label:first-child {
  margin-top: 0;
}

.fleet-filter {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 0.35rem 0.7rem;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

.fleet-filter:hover {
  color: var(--text);
  border-color: rgba(61, 214, 198, 0.35);
}

.fleet-filter.is-active {
  color: #06201d;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
}

.bot-detail-host {
  margin-top: 0.65rem;
}

.bot-detail-host[hidden] {
  display: none !important;
}

.bot-detail-panel {
  display: grid;
  gap: 0.45rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.18);
}

.bot-detail-panel[hidden] {
  display: none !important;
}

.bot-detail-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  align-items: flex-start;
}

.bot-detail-hint {
  margin: 0;
  max-width: 28rem;
  font-size: 0.82rem;
  line-height: 1.4;
}

.bot-detail-title {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
}

.bot-detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  width: 100%;
}

.bot-detail-actions .btn {
  flex: 1 1 auto;
  min-width: 4.5rem;
  justify-content: center;
}

.mode-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  border: 1px solid var(--line);
  color: var(--muted);
  background: rgba(0, 0, 0, 0.2);
  text-transform: none;
}

.mode-badge.mode-live {
  color: #ffd0a8;
  border-color: rgba(255, 160, 90, 0.45);
  background: rgba(255, 140, 60, 0.12);
}

.mode-badge.mode-sandbox {
  color: #9fd4ff;
  border-color: rgba(100, 170, 255, 0.4);
  background: rgba(80, 140, 255, 0.12);
}

.mode-badge.mode-dry_run {
  color: #c9d7e7;
  border-color: rgba(147, 161, 179, 0.45);
}

/* В строке флота режим — outline, статус — filled: два соседних чипа читаются раздельно. */
.bot-row-mode .mode-badge.mode-live {
  background: transparent;
  border-color: rgba(255, 160, 90, 0.55);
  color: #ffc48a;
}

.bot-row-mode .mode-badge.mode-sandbox {
  background: transparent;
}

.bot-row-mode .mode-badge.mode-dry_run {
  background: transparent;
}

.bot-row-status .bot-status-chip.is-paused {
  border-style: solid;
  box-shadow: inset 0 0 0 1px rgba(167, 139, 250, 0.12);
}

.positions-share-warn {
  margin: 0 0 0.75rem;
}

.tokens-expiry-warn {
  margin: 0 0 0.85rem;
}

.tokens-expiry-warn.is-danger {
  border-color: rgba(255, 107, 107, 0.45);
  color: #ffc9c9;
}

.broker-api-stats {
  margin: 0 0 0.85rem;
}

.broker-api-stats-hint {
  margin: 0.35rem 0 0.65rem;
  font-size: 0.9em;
}

.broker-api-stats-table-wrap {
  margin-top: 0.25rem;
}

.broker-api-stats-table th,
.broker-api-stats-table td {
  vertical-align: middle;
}

.broker-api-stats-row-label {
  text-align: left;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.82);
  white-space: normal;
  min-width: 12rem;
}

.broker-api-stats-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.broker-api-stats-status-cell {
  text-align: center;
}

.broker-api-stats-status {
  font-size: 0.92em;
  white-space: nowrap;
}

.broker-api-stats-status.is-ok {
  color: #9ddeb0;
}

.broker-api-stats-status.is-info {
  color: #ffd0a8;
}

.broker-api-stats-status.is-warn {
  color: #ffc9c9;
}

.broker-api-stats-status.is-muted {
  color: rgba(255, 255, 255, 0.45);
}

.broker-api-stats-num.is-empty {
  color: rgba(255, 255, 255, 0.35);
  font-weight: 500;
}

.broker-api-stats-footnote {
  margin: 0.75rem 0 0;
  font-size: 0.9em;
}

.page-api-stats .page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.tokens-alert-banner {
  margin: 0 0 1rem;
  border-color: rgba(255, 140, 60, 0.45);
  color: #ffd0a8;
}

.tokens-alert-banner.is-danger {
  border-color: rgba(255, 107, 107, 0.45);
  color: #ffc9c9;
}

.tokens-alert-banner a {
  color: inherit;
  font-weight: 700;
  text-decoration: underline;
}

tr.token-row-soon td,
tr.token-row-expired td,
tr.token-row-missing-expires td {
  background: rgba(255, 140, 60, 0.08);
}

tr.token-row-expired td {
  background: rgba(255, 107, 107, 0.1);
}

.token-expiry-cell {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.token-expiry-cell.is-soon,
.token-expiry-cell.is-missing {
  color: #ffd0a8;
  font-weight: 600;
}

.token-expiry-cell.is-expired {
  color: var(--danger);
  font-weight: 700;
}

.settings-advanced {
  margin-top: 0.85rem;
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 0.55rem 0.75rem 0.75rem;
  background: rgba(0, 0, 0, 0.12);
}

.settings-advanced summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 600;
  font-size: 0.9rem;
}

.docs-toc-list {
  margin: 0;
  padding-left: 1.2rem;
  display: grid;
  gap: 0.35rem;
}

.docs-toc-list a {
  color: var(--accent);
  text-decoration: none;
}

.docs-toc-list a:hover {
  text-decoration: underline;
}

.bots-empty .btn {
  margin-top: 0.85rem;
}

@media (max-width: 900px) {
  .nav {
    gap: 0.75rem;
  }
}

.bot-session {
  align-items: stretch;
}

.bot-session #bot-running {
  letter-spacing: -0.02em;
}

.bot-session #bot-running.is-live {
  color: var(--ok);
}

.bot-session .lab-meta-inline .stat {
  padding: 0.65rem 0.8rem;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid rgba(42, 53, 66, 0.7);
}

.bot-session .lab-meta-inline .stat .price {
  color: var(--accent);
}

.btn.danger-text {
  color: var(--danger);
  border-color: rgba(255, 107, 107, 0.35);
}

.btn.danger-text:hover {
  background: rgba(255, 107, 107, 0.1);
}

/* Состояние лицензии — см. .license-state-pill */

@media (max-width: 768px) {
  .bots-fleet-top {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .bots-list {
    /* Без вложенного scrollport — скролл страницы, sticky-вкладки остаются. */
    max-height: none;
    overflow: visible;
  }

  .bots-list-pagination {
    display: none !important;
  }

  .bot-row-filters {
    display: none !important;
  }

  .bots-toolbar {
    justify-content: stretch;
    width: 100%;
  }

  .bots-toolbar-group {
    display: flex;
    width: 100%;
    gap: 0.5rem;
  }

  .bots-toolbar-group .btn {
    flex: 1;
    min-width: 0;
  }
}

/* --- Мобильный UX (<=768px, sync with MOBILE_LAYOUT_MAX in app.js) --- */

.mobile-header,
.mobile-bottom-nav,
.mobile-bot-actions,
.mobile-sheet,
.offline-banner,
.pull-refresh-indicator,
.settings-dialog-footer,
.bot-page-tabs,
.bots-mobile-context,
.positions-cards,
.tokens-cards,
.levels-mobile-list,
.tokens-mobile-filters,
.bot-orders-mobile,
.docs-toc-mobile-btn,
.settings-mobile-subtitle {
  display: none;
}

.mobile-hint-summary {
  display: none;
}

@media (max-width: 768px) {
  .mobile-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem 0.5rem;
    /* fixed: иначе sticky-фильтры внутри .shell с top:header-h дают двойной отступ и наезд на карточки */
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 900;
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    min-height: var(--mobile-header-h);
    padding: calc(0.45rem + var(--safe-top)) var(--mobile-gutter) 0.45rem;
    border-bottom: 1px solid var(--line);
    background: rgba(12, 17, 23, 0.92);
    backdrop-filter: blur(10px);
  }

  .mobile-brand {
    flex-shrink: 0;
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--text);
    text-decoration: none;
    letter-spacing: -0.02em;
  }

  .mobile-header-title {
    flex: 1;
    min-width: 0;
    font-size: 0.88rem;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .mobile-fleet-badge {
    flex-shrink: 0;
    font: inherit;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--muted);
    padding: 0.25rem 0.55rem;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: rgba(0, 0, 0, 0.22);
    cursor: pointer;
  }

  .mobile-fleet-counts {
    display: flex;
    flex-wrap: nowrap;
    align-items: baseline;
    gap: 0.55rem 0.85rem;
    flex: 1 0 100%;
    order: 10;
    min-width: 0;
    max-width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    padding: 0.1rem 0 0.05rem;
    font-size: 0.78rem;
    color: var(--muted);
  }

  .mobile-fleet-counts::-webkit-scrollbar {
    display: none;
  }

  .mobile-fleet-counts[hidden] {
    display: none !important;
  }

  .mobile-fleet-counts .fleet-count strong {
    font-size: 0.88rem;
  }

  .mobile-fleet-badge.has-live {
    color: var(--ok);
    border-color: rgba(99, 212, 113, 0.35);
  }

  .mobile-fleet-badge.has-danger {
    color: var(--danger);
    border-color: rgba(255, 107, 107, 0.45);
  }

  .mobile-create-btn {
    flex-shrink: 0;
    box-sizing: border-box;
    min-width: 2.75rem;
    min-height: 2.75rem;
    padding: 0.5rem 0.75rem;
  }

  .bots-mobile-context {
    /* flex+gap — BFC, иначе margin схлопывается и hero уезжает под пикер */
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    position: sticky;
    /*
     * Шапка fixed + padding-top у .shell уже держат контент ниже шапки.
     * top: header-h здесь давал двойной сдвиг (shell padding + sticky top).
     */
    top: 0;
    z-index: 850;
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    margin: 0 0 0.45rem;
    /* Без своего gutter: ширина как у hero/карточек (.content уже даёт --mobile-gutter) */
    padding: 0.55rem 0 0.5rem;
    border-bottom: 1px solid var(--line);
    background: rgba(12, 17, 23, 0.96);
    backdrop-filter: blur(10px);
    flex-shrink: 0;
  }

  .bots-mobile-back-row {
    display: block;
    margin-bottom: 0;
  }

  .bots-mobile-back-row[hidden] {
    display: none !important;
  }

  .bots-mobile-back-btn {
    min-height: 2.5rem;
  }

  .bot-console-hero {
    display: block;
    margin-bottom: 0.65rem;
    padding: 0.85rem 0.95rem;
    border: 1px solid rgba(61, 214, 198, 0.28);
    border-radius: 14px;
    background: rgba(61, 214, 198, 0.06);
  }

  .bot-console-hero[hidden] {
    display: none !important;
  }

  .bot-console-hero-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
  }

  .bot-console-hero-ticker {
    font-family: var(--mono);
    font-weight: 700;
    font-size: 1.05rem;
    text-transform: uppercase;
  }

  .bot-console-hero-chip {
    font-size: 0.72rem;
    font-weight: 700;
    color: #c4a0ff;
    border: 1px solid rgba(196, 160, 255, 0.4);
    border-radius: 999px;
    padding: 0.15rem 0.5rem;
  }

  .bot-console-hero-lots {
    margin: 0.35rem 0 0.2rem;
    font-size: 1.35rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
  }

  .bot-console-hero-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 0.85rem;
    color: var(--muted);
    font-size: 0.88rem;
    font-variant-numeric: tabular-nums;
  }

  .bot-console-hero-row em {
    font-style: normal;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-right: 0.25rem;
  }

  .bots-mobile-context .bot-page-tabs {
    margin-bottom: 0;
  }

  /* На списке «Роботы» — только фильтры; вкладки робота после тапа по карточке. */
  .bots-mobile-context .bot-page-tabs[hidden] {
    display: none !important;
  }

  .bots-mobile-context .bot-page-tab[data-bot-page-tab="fleet"][hidden] {
    display: none !important;
  }

  .page-bots.bot-mobile-tab-fleet .bots-mobile-context {
    padding-top: 0.45rem;
    padding-bottom: 0.5rem;
  }

  .bots-mobile-context .bots-fleet-picker {
    margin-bottom: 0;
    width: 100%;
  }

  /* Текст пикера в одну колонку с MNTUSDT в hero (тот же горизонтальный pad). */
  .bots-mobile-context .bots-mobile-picker-btn {
    padding-left: 0.95rem;
    padding-right: 0.95rem;
  }

  /*
   * Sticky-контекст наезжает на контент: padding (не margin) — иначе отступ
   * схлопывается и первая плашка / hero уезжают под фильтры.
   */
  .page-bots:not(.bot-mobile-tab-fleet) > .lab-layout {
    margin-top: 0;
    /* Раньше 1.35rem — после fixed-шапки хватает меньшего зазора (чипы заявок ближе к пикеру). */
    padding-top: 0.45rem;
    position: relative;
    z-index: 0;
  }

  .page-bots.bot-mobile-tab-fleet > .lab-layout {
    margin-top: 0;
    padding-top: 0.35rem;
    position: relative;
    z-index: 0;
  }

  .shell {
    display: block;
    width: 100%;
    min-width: 0;
    /* Шапка fixed — резервируем её высоту (--mobile-header-h уже с safe-top в min-height) */
    padding-top: var(--mobile-header-h);
  }

  /*
   * Сайдбар прячем всегда на ≤768: иначе .shell.is-sidebar-collapsed .sidebar
   * (display:flex без media) и desktop-правила page-bots перебивают display:none
   * и на телефоне снова торчат логотип / «состояние» / Роботы·Ещё.
   */
  .sidebar,
  .shell.is-sidebar-collapsed .sidebar,
  .shell:has(.page-bots.active) .sidebar,
  body.is-fleet-ui-classic .shell:has(.page-bots.active) .sidebar {
    display: none !important;
  }

  .sidebar-collapse-btn {
    display: none !important;
  }

  .content {
    box-sizing: border-box;
    padding: 1rem var(--mobile-gutter) calc(var(--mobile-nav-total-h) + 1rem);
    width: 100%;
    max-width: 100%;
    margin: 0;
    /*
     * Не overflow-x: clip — иначе content становится scrollport и sticky-фильтры
     * считают top от его края (уже под шапкой), «съедая» первую карточку флота.
     */
    overflow-x: visible;
  }

  .content:has(.page-bots.active),
  .content:has(#page-tokens.active),
  .content:has(.page-tokens.active),
  .content:has(#page-accounts.active),
  .content:has(.page-accounts.active) {
    width: 100%;
    max-width: 100%;
  }

  .page-bots,
  .page-bots .lab-layout,
  .page-bots .section,
  .page-bots .bot-lab-panel,
  .page-bots .lab-body,
  .page-bots .lab-main,
  .page-bots .lab-side,
  .page-bots .bot-orders-mobile {
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }

  /* Макет флота: без «Парк стратегий» / «Состояние» / Обновить — только вкладки + chips + карточки. */
  .page-bots .bots-page-header {
    display: none;
  }

  .page-bots .bots-fleet-top {
    display: none !important;
  }

  .page-bots .bots-fleet-strip {
    display: none !important;
  }

  /* Без общей панели-обёртки: только отдельные плашки на ширину контента. */
  .page-bots .lab-layout > .bots-fleet {
    padding: 0;
    margin-bottom: 0;
    border: none;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }

  .page-bots .bots-fleet .bots-fleet-table,
  .page-bots .bots-fleet .bots-list {
    width: 100%;
    max-width: 100%;
  }

  .page-bots .bots-list {
    gap: 0.55rem;
  }

  .page-bots .bots-list .bot-row {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  .bots-fleet-filters-mobile {
    display: none;
    margin-top: 0;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    mask-image: linear-gradient(to right, #000 88%, transparent);
  }

  .bots-fleet-filters-mobile::-webkit-scrollbar {
    display: none;
  }

  .page-bots.bot-mobile-tab-fleet .bots-fleet-filters-mobile {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.35rem;
  }

  .page-bots:not(.bot-mobile-tab-fleet) .bots-fleet-filters-mobile {
    display: none !important;
  }

  .bot-page-tabs {
    width: 100%;
    max-width: 100%;
  }

  body.has-mobile-bot-actions .content {
    padding-bottom: calc(
      var(--mobile-nav-total-h) + var(--mobile-actions-h) + var(--mobile-actions-pad) + 1rem
    );
  }

  .flash {
    top: auto;
    bottom: calc(var(--mobile-nav-total-h) + 0.65rem);
    transform: translateX(-50%);
  }

  body.has-mobile-bot-actions .flash {
    bottom: calc(
      var(--mobile-nav-total-h) + var(--mobile-actions-h) + var(--mobile-actions-pad) + 0.65rem
    );
  }

  body.mobile-hide-bottom-nav .flash {
    bottom: calc(var(--mobile-actions-h) + var(--safe-bottom) + 0.65rem);
  }

  body.mobile-hide-bottom-nav:not(.has-mobile-bot-actions) .flash {
    bottom: calc(var(--safe-bottom) + 0.65rem);
  }

  body.has-flash .content {
    /* toast не сдвигает контент */
  }

  .modal {
    padding: calc(0.75rem + var(--safe-top)) 0.75rem calc(0.75rem + var(--safe-bottom));
  }

  .mobile-bottom-nav {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 950;
    box-sizing: border-box;
    padding-bottom: var(--safe-bottom);
    border-top: 1px solid var(--line);
    background: rgba(12, 17, 23, 0.96);
    backdrop-filter: blur(12px);
  }

  .mobile-nav-link {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.15rem;
    box-sizing: border-box;
    height: var(--mobile-nav-h);
    padding: 0.35rem 0.5rem;
    border: 0;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: 0.72rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    position: relative;
  }

  .mobile-nav-icon {
    width: 1.25rem;
    height: 1.25rem;
    flex-shrink: 0;
  }

  .mobile-nav-link.is-active .mobile-nav-icon {
    color: var(--accent);
  }

  .mobile-nav-link.is-active {
    color: var(--accent);
  }

  .mobile-nav-link .nav-badge {
    position: absolute;
    top: 0.35rem;
    right: calc(50% - 1.75rem);
  }

  body.mobile-hide-bottom-nav .mobile-bottom-nav {
    display: none;
  }

  body.mobile-hide-bottom-nav .content {
    padding-bottom: calc(var(--mobile-actions-h) + var(--safe-bottom) + 1rem);
  }

  body.mobile-hide-bottom-nav:not(.has-mobile-bot-actions) .content {
    padding-bottom: calc(var(--safe-bottom) + 1rem);
  }

  .mobile-bot-actions {
    display: flex;
    align-items: stretch;
    gap: 0.55rem;
    position: fixed;
    left: 0;
    right: 0;
    bottom: calc(var(--mobile-nav-total-h) + var(--mobile-actions-pad));
    z-index: 960;
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    padding-top: var(--mobile-actions-pad);
    padding-bottom: 0;
    padding-inline: var(--mobile-gutter);
    border-top: 1px solid rgba(61, 214, 198, 0.22);
    background: rgba(15, 20, 25, 0.96);
    backdrop-filter: blur(10px);
  }

  /* Иначе author display:flex перебивает HTML [hidden] — sticky виден на «Флот». */
  .mobile-bot-actions[hidden] {
    display: none !important;
  }

  body.mobile-hide-bottom-nav .mobile-bot-actions {
    bottom: 0;
    padding-bottom: calc(var(--mobile-actions-pad) + var(--safe-bottom));
  }

  .mobile-bot-actions .btn.primary,
  .mobile-bot-actions .btn.danger {
    flex: 1;
    min-width: 0;
    min-height: 2.75rem;
    box-sizing: border-box;
  }

  .mobile-bot-actions #mobile-bot-more {
    flex: 0 0 2.75rem;
    min-width: 2.75rem;
    min-height: 2.75rem;
    padding: 0;
    box-sizing: border-box;
    font-size: 1.25rem;
    line-height: 1;
  }

  .mobile-sheet {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 1200;
  }

  .mobile-sheet[hidden] {
    display: none !important;
  }

  .mobile-sheet-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(6, 10, 14, 0.72);
    backdrop-filter: blur(4px);
  }

  .mobile-sheet-panel {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    /* Длинный список ботов не уезжает за верх экрана — скролл внутри links. */
    max-height: min(92dvh, 100%);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 1rem 1rem calc(1rem + var(--safe-bottom));
    border-radius: var(--radius) var(--radius) 0 0;
    border: 1px solid var(--line);
    border-bottom: 0;
    background: var(--panel);
    box-shadow: var(--shadow);
  }

  .mobile-sheet-title {
    flex-shrink: 0;
    margin: 0 0 0.75rem;
    font-size: 1.05rem;
  }

  .mobile-sheet-links {
    display: grid;
    gap: 0.25rem;
    margin-bottom: 0.75rem;
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }

  .mobile-sheet-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    min-height: 2.75rem;
    padding: 0.65rem 0.85rem;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--text);
    font: inherit;
    font-weight: 600;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
  }

  .mobile-sheet-link:active {
    background: rgba(255, 255, 255, 0.05);
  }

  .mobile-sheet-cancel {
    flex-shrink: 0;
    width: 100%;
    min-height: 2.75rem;
  }

  .bot-page-tabs {
    display: flex;
    gap: 0.35rem;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    margin-bottom: 0.55rem;
    padding-bottom: 0.15rem;
    /* Намекает, что вкладок больше (Калькулятор и т.п.) */
    mask-image: linear-gradient(to right, #000 88%, transparent);
  }

  .bot-page-tabs::-webkit-scrollbar {
    display: none;
  }

  .bot-page-tab {
    flex: 0 0 auto;
    scroll-snap-align: start;
    min-height: 2.75rem;
    padding: 0.45rem 0.85rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
  }

  .bot-page-tab.is-active {
    color: #06201d;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    border-color: transparent;
  }

  .lab-layout [data-bot-page-section] {
    display: none;
  }

  .lab-layout [data-bot-page-section].is-mobile-tab-active {
    display: block;
  }

  /* Не сбрасывать grid у позиций — иначе пропадает gap между кнопками и карточками */
  .lab-layout .positions-section[data-bot-page-section].is-mobile-tab-active {
    display: grid;
  }

  .bot-lab-tabs {
    display: none;
  }

  /* Вкладки страницы Тест — не прятать вместе с bot-lab на телефоне */
  .test-page-tabs.bot-lab-tabs {
    display: inline-flex;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
  }

  .bot-lab-panel[hidden] {
    display: none !important;
  }

  .bot-lab-panel.is-mobile-tab-active {
    display: block !important;
  }

  .bot-detail-actions {
    display: none !important;
  }

  .bots-fleet-filters {
    flex-wrap: nowrap;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    max-width: 100%;
    mask-image: linear-gradient(to right, #000 85%, transparent);
  }

  .bots-fleet #bot-create-btn {
    display: none;
  }

  .bots-fleet .bots-columns-menu,
  .bots-fleet #bots-fleet-ui-theme-btn {
    display: none;
  }

  .bots-fleet-filters::-webkit-scrollbar {
    display: none;
  }

  .fleet-filter {
    flex-shrink: 0;
    scroll-snap-align: start;
    min-height: 2.75rem;
    padding: 0.45rem 0.85rem;
  }

  .btn,
  .btn.small,
  .nav-link,
  .bot-lab-tab,
  .bot-row-quick .btn,
  .positions-close-btn,
  .bot-cancel-btn {
    min-height: 2.75rem;
  }

  .btn.small {
    padding: 0.55rem 0.95rem;
    font-size: 0.92rem;
  }

  .mobile-hint {
    margin-top: 0.35rem;
  }

  .mobile-hint-summary {
    display: list-item;
    cursor: pointer;
    color: var(--accent);
    font-size: 0.85rem;
    font-weight: 600;
  }

  .mobile-hint:not([open]) .sub,
  .mobile-hint:not([open]) .muted {
    display: none;
  }

  .mobile-hint[open] .mobile-hint-summary {
    margin-bottom: 0.35rem;
  }

  .positions-table-wrap {
    display: none;
  }

  .positions-header {
    flex-direction: column;
    align-items: stretch;
    gap: 0.65rem;
  }

  .positions-header .actions-inline {
    display: flex;
    flex-wrap: wrap;
    width: 100%;
    gap: 0.5rem;
  }

  .positions-header .actions-inline .btn {
    flex: 1 1 auto;
    min-width: 0;
  }

  .positions-summary {
    display: grid;
    gap: 0.35rem;
  }

  .positions-cards {
    display: grid;
    gap: 0.45rem;
  }

  .tokens-table-wrap {
    display: none;
  }

  .tokens-mobile-filters {
    display: block;
    margin-bottom: 0.85rem;
    border: 1px dashed var(--line);
    border-radius: 12px;
    padding: 0.55rem 0.75rem;
    background: rgba(0, 0, 0, 0.12);
  }

  .tokens-mobile-filters summary {
    cursor: pointer;
    color: var(--accent);
    font-weight: 600;
  }

  .tokens-mobile-filters-body {
    display: grid;
    gap: 0.65rem;
    margin-top: 0.65rem;
  }

  .tokens-cards {
    display: grid;
    gap: 0.65rem;
  }

  .token-card {
    padding: 0.85rem 0.95rem;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.18);
  }

  .token-card.is-soon,
  .token-card.is-missing {
    border-color: rgba(255, 140, 60, 0.45);
  }

  .token-card.is-expired {
    border-color: rgba(255, 107, 107, 0.45);
  }

  .token-card-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.35rem;
  }

  .token-card-label {
    font-weight: 700;
  }

  .token-card-meta {
    color: var(--muted);
    font-size: 0.85rem;
    line-height: 1.45;
    margin-bottom: 0.65rem;
  }

  .token-card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
  }

  .tokens-cards-empty {
    padding: 1rem;
    text-align: center;
    color: var(--muted);
    border: 1px dashed var(--line);
    border-radius: 12px;
  }

  .levels-table-frame,
  .levels-table-wrap {
    display: none;
  }

  .levels-section-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.35rem 0.75rem;
    margin-bottom: 0.75rem;
  }

  .levels-mobile-list {
    display: grid;
    gap: 0.55rem;
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }

  .levels-mobile-summary {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, max-content);
    column-gap: 1rem;
    row-gap: 0.45rem;
    align-items: baseline;
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    padding: 0.85rem 0.95rem;
    margin-bottom: 0.65rem;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.18);
    font-size: 0.88rem;
  }

  .levels-mobile-summary dt {
    color: var(--muted);
    margin: 0;
    min-width: 0;
  }

  .levels-mobile-summary dd {
    margin: 0;
    min-width: 0;
    text-align: right;
    font-family: var(--mono);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere;
  }

  .levels-mobile-branch {
    border: 1px solid var(--line);
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.2);
    overflow: hidden;
  }

  .levels-mobile-branch > summary {
    cursor: pointer;
    padding: 0.7rem 0.85rem;
    font-weight: 600;
    font-size: 0.86rem;
    list-style: none;
    color: var(--muted);
  }

  .levels-mobile-branch > summary::-webkit-details-marker {
    display: none;
  }

  .levels-mobile-branch-body {
    display: grid;
    gap: 0.5rem;
    padding: 0 0.55rem 0.65rem;
  }

  .levels-mobile-card {
    border: 1px solid var(--line);
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.15);
    overflow: hidden;
  }

  .levels-mobile-card summary {
    cursor: pointer;
    padding: 0.65rem 0.85rem;
    font-weight: 600;
    list-style: none;
  }

  .levels-mobile-card summary::-webkit-details-marker {
    display: none;
  }

  .levels-mobile-card-body {
    padding: 0 0.85rem 0.75rem;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.35rem 0.75rem;
    font-size: 0.82rem;
    color: var(--muted);
  }

  .levels-mobile-card-body strong {
    color: var(--text);
    font-family: var(--mono);
  }

  .levels-mobile-empty {
    padding: 1rem;
    text-align: center;
    color: var(--muted);
    border: 1px dashed var(--line);
    border-radius: 12px;
  }

  .bot-lab-panel.is-mobile-tab-active .lab-body {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    min-height: calc(100dvh - var(--mobile-sticky-top) - var(--mobile-nav-h) - var(--safe-bottom) - 5rem);
  }

  body.mobile-hide-bottom-nav .bot-lab-panel.is-mobile-tab-active .lab-body {
    min-height: calc(100dvh - var(--mobile-sticky-top) - var(--mobile-actions-h) - var(--safe-bottom) - 4rem);
  }

  .bot-lab-panel.is-mobile-tab-active .lab-main,
  .bot-lab-panel.is-mobile-tab-active .lab-side,
  .bot-lab-panel.is-mobile-tab-active .bot-orders-mobile,
  .bot-lab-panel.is-mobile-tab-active .section {
    width: 100%;
    max-width: 100%;
    align-self: stretch;
  }

  .bot-lab-panel.is-mobile-tab-active .terminal {
    max-height: none;
    flex: 1;
    min-height: 12rem;
    width: 100%;
  }

  .settings-dialog {
    width: 100%;
    max-width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
  }

  .settings-dialog-header .header-actions {
    flex-wrap: wrap;
  }

  .settings-dialog-header #save-btn,
  .settings-dialog-header #reload-btn {
    display: none;
  }

  .settings-dialog-header #settings-modal-close::before {
    content: '← ';
  }

  .settings-dialog-footer {
    display: flex;
    padding: 0.75rem 1rem calc(0.75rem + var(--safe-bottom));
    border-top: 1px solid var(--line);
    background: rgba(12, 17, 23, 0.92);
  }

  .settings-dialog-footer .btn {
    flex: 1;
    min-height: 2.75rem;
  }

  .settings-dialog-body .section > h3 {
    cursor: pointer;
  }

  .bot-console-meta {
    grid-template-columns: 1fr;
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }

  .bot-console-meta .stat {
    width: 100%;
    max-width: 100%;
  }

  .bot-console-meta .stat strong {
    word-break: break-all;
  }

  .section.lab-main.test-console,
  .section.levels-section,
  .section.positions-section {
    width: 100%;
    box-sizing: border-box;
  }

  .offline-banner {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1300;
    padding: calc(0.45rem + var(--safe-top)) 0.85rem 0.45rem;
    text-align: center;
    font-size: 0.85rem;
    font-weight: 600;
    color: #ffd0a8;
    background: rgba(80, 40, 10, 0.95);
    border-bottom: 1px solid rgba(255, 140, 60, 0.45);
  }

  .offline-banner[hidden] {
    display: none !important;
  }

  .pull-refresh-indicator {
    display: block;
    position: fixed;
    top: calc(var(--mobile-header-h) + var(--safe-top));
    left: 50%;
    transform: translateX(-50%);
    z-index: 880;
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    font-size: 0.82rem;
    color: var(--muted);
    background: var(--panel);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
  }

  .pull-refresh-indicator[hidden] {
    display: none !important;
  }

  .bots-fleet-picker {
    display: grid;
    gap: 0.35rem;
    margin-bottom: 0.75rem;
  }

  .bots-fleet-picker[hidden] {
    display: none !important;
  }

  .bots-mobile-select-label {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
  }

  .bots-mobile-picker-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    min-height: 2.75rem;
    padding: 0.55rem 2rem 0.55rem 0.95rem;
    border-radius: 12px;
    border: 1px solid rgba(61, 214, 198, 0.28);
    background: rgba(61, 214, 198, 0.06);
    color: var(--text);
    font: inherit;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
    overflow: hidden;
    overflow-wrap: anywhere;
    word-break: break-word;
    position: relative;
  }

  .bots-mobile-picker-btn::after {
    content: '▾';
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
    flex-shrink: 0;
  }

  .bots-mobile-picker-card {
    display: grid;
    gap: 0.28rem;
    min-width: 0;
    flex: 1 1 auto;
  }

  .bots-mobile-picker-top {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem 0.45rem;
    min-width: 0;
  }

  .bots-mobile-picker-name {
    font-weight: 700;
    font-size: 0.95rem;
    overflow-wrap: anywhere;
  }

  .bots-mobile-picker-chip {
    font-size: 0.72rem;
    font-weight: 700;
    color: #c4a0ff;
    border: 1px solid rgba(196, 160, 255, 0.4);
    border-radius: 999px;
    padding: 0.12rem 0.45rem;
  }

  .bots-mobile-picker-metrics {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem 0.55rem;
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
  }

  .bots-mobile-picker-broker {
    display: inline-flex;
    flex-shrink: 0;
  }

  .bots-mobile-picker-broker .bot-card-broker {
    width: 1.1rem;
    height: 1.1rem;
    border-radius: 5px;
  }

  .bots-mobile-picker-metrics strong {
    color: var(--text);
    font-family: var(--mono);
    font-weight: 700;
    text-transform: uppercase;
  }

  .bots-mobile-picker-metrics em {
    font-style: normal;
    font-size: 0.68rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    margin-right: 0.2rem;
  }

  .bots-mobile-picker-btn .bot-row-strategy {
    font-size: 0.72rem;
    padding: 0.12rem 0.4rem;
  }

  .bots-picker-search {
    flex-shrink: 0;
    width: 100%;
    min-height: 2.75rem;
    margin-bottom: 0.65rem;
    padding: 0.55rem 0.75rem;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: var(--panel-2);
    color: var(--text);
    font: inherit;
  }

  .bot-picker-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    width: 100%;
    min-height: 2.75rem;
    padding: 0.65rem 0.85rem;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--text);
    font: inherit;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
  }

  .bot-picker-item.is-selected {
    background: rgba(61, 214, 198, 0.12);
    border: 1px solid rgba(61, 214, 198, 0.35);
  }

  .bot-picker-item:active {
    background: rgba(255, 255, 255, 0.05);
  }

  .bot-picker-item-main {
    display: grid;
    gap: 0.2rem;
    min-width: 0;
    flex: 1 1 auto;
  }

  .bot-picker-item-title {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem 0.45rem;
    min-width: 0;
  }

  .bot-picker-item-title .bot-row-strategy {
    font-size: 0.72rem;
    padding: 0.12rem 0.4rem;
  }

  .bot-picker-item-meta {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 500;
    min-width: 0;
  }

  .bot-picker-item-meta .bot-row-mobile-meta-broker {
    display: inline-flex;
    flex-shrink: 0;
  }

  .bot-picker-item-meta .bot-card-broker {
    width: 1.1rem;
    height: 1.1rem;
    border-radius: 5px;
  }

  .bot-picker-item-meta .bot-row-mobile-meta-text {
    min-width: 0;
  }

  .bot-picker-status {
    flex-shrink: 0;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 0.15rem 0.45rem;
    border-radius: 999px;
    border: 1px solid var(--line);
  }

  .bot-picker-status.is-running {
    color: var(--ok);
    border-color: rgba(99, 212, 113, 0.35);
  }

  .bot-picker-status.is-crashed {
    color: var(--danger);
    border-color: rgba(255, 107, 107, 0.45);
  }

  .bots-list .bot-row {
    display: grid;
    /* Логотип/лоты под точкой; колонка статуса (стоп / тип / цена) — единая ширина. */
    grid-template-columns: auto minmax(0, 1fr) minmax(4.5rem, max-content) auto;
    grid-template-areas:
      "dot name status more"
      "meta meta type more"
      "lots lots price more";
    column-gap: 0.45rem;
    row-gap: 0.28rem;
    cursor: pointer;
    transform: none;
    min-height: min-content;
    padding: 0.7rem 0.8rem;
    border-radius: 12px;
    align-items: center;
  }

  .bots-list .bot-row > * {
    min-width: 0;
  }

  .bots-list .bot-row-dot {
    grid-area: dot;
    align-self: center;
    margin-top: 0;
  }

  .bots-list .bot-row-name {
    grid-area: name;
    font-size: 1.05rem;
    font-weight: 700;
    overflow-wrap: anywhere;
  }

  .bots-list .bot-row-status {
    grid-area: status;
    justify-self: stretch;
    align-self: center;
    width: 100%;
    min-width: 0;
  }

  /* Чип «стоп/бой» — на всю ширину колонки статуса. */
  .bots-list .bot-row-status .bot-status-chip {
    flex: 1 1 auto;
    width: 100%;
    justify-content: center;
    box-sizing: border-box;
    border-radius: 8px;
    padding: 0.2rem 0.45rem;
  }

  .bots-list .bot-row-quick {
    grid-area: more;
    display: flex;
    justify-content: flex-end;
    align-items: center;
  }

  .bots-list .bot-row-quick .bot-card-quick-start,
  .bots-list .bot-row-quick .bot-card-quick-stop {
    display: none;
  }

  .bots-list .bot-row-mobile-meta {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    grid-area: meta;
    justify-self: start;
    color: var(--muted);
    font-size: 0.82rem;
    line-height: 1.35;
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .bots-list .bot-row-mobile-meta-broker {
    display: inline-flex;
    flex-shrink: 0;
  }

  .bots-list .bot-row-mobile-meta-broker .bot-card-broker {
    width: 1.1rem;
    height: 1.1rem;
    border-radius: 5px;
  }

  .bots-list .bot-row-mobile-meta-text {
    min-width: 0;
  }

  /* Тип — в той же колонке, что статус; растягиваем на её ширину. */
  .bots-list .bot-row-strategy-cell {
    display: inline-flex !important;
    grid-area: type;
    align-self: center;
    justify-self: stretch;
    width: 100%;
  }

  .bots-list .bot-row-strategy-cell .bot-row-strategy-wrap {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.2rem;
    width: 100%;
  }

  .bots-list .bot-row-strategy {
    display: inline-flex;
    flex: 1 1 auto;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-size: 0.72rem;
    padding: 0.18rem 0.45rem;
    box-sizing: border-box;
    min-width: 0;
  }

  /* Лоты под meta (слева), цена под типом — общая левая кромка колонок. */
  .bots-list .bot-row-lots,
  .bots-list .bot-row-price {
    display: inline-flex;
    align-items: baseline;
    gap: 0.28rem;
    line-height: 1.15;
    align-self: baseline;
    min-height: 0;
    font-size: 0.88rem;
    font-variant-numeric: tabular-nums;
  }

  .bots-list .bot-row-lots {
    grid-area: lots;
    justify-self: start;
    justify-content: flex-start;
    text-align: left;
  }

  .bots-list .bot-row-lots::before {
    content: 'лоты';
    color: var(--muted);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: none;
  }

  .bots-list .bot-row-price {
    grid-area: price;
    justify-self: start;
    justify-content: flex-start;
    text-align: left;
  }

  .bots-list .bot-row-price::before {
    content: 'ЦЕНА';
    color: var(--muted);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
  }

  .bots-list .bot-row-account,
  .bots-list .bot-row-ticker,
  .bots-list .bot-row-mode,
  .bots-list .bot-row-started,
  .bots-list .bot-row-broker {
    display: none !important;
  }

  .bot-row-head {
    display: none !important;
  }

  .bot-orders-mobile {
    display: grid;
    gap: 0.55rem;
    width: 100%;
  }

  .orders-mobile-tabs {
    display: flex;
    gap: 0.35rem;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    /* proximity — иначе после скролла snap «отбрасывает» к началу */
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    mask-image: linear-gradient(to right, #000 88%, transparent);
    padding-bottom: 0.1rem;
  }

  .orders-mobile-tabs::-webkit-scrollbar {
    display: none;
  }

  .orders-mobile-tab {
    flex: 0 0 auto;
    scroll-snap-align: start;
    min-height: 2.5rem;
    padding: 0.4rem 0.75rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
  }

  .orders-mobile-tab.is-active {
    color: #06201d;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    border-color: transparent;
  }

  /* Как desktop «Ожидают» / «Лимиты»: жёлтый чип при ненулевом счётчике. */
  .orders-mobile-tab.has-attention:not(.is-active) {
    border-color: #ffd166;
    color: #ffd166;
  }

  .orders-mobile-tab.has-attention.is-active {
    background: #ffd166;
    color: #1a1208;
    border-color: transparent;
  }

  .orders-mobile-panel {
    display: grid;
    gap: 0.55rem;
    width: 100%;
  }

  .order-card {
    padding: 0.75rem 0.85rem;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.18);
    font-size: 0.85rem;
    line-height: 1.45;
  }

  .order-card.side-buy {
    border-left: 3px solid var(--ok);
  }

  .order-card.side-sell {
    border-left: 3px solid var(--danger);
  }

  .orders-mobile-empty {
    padding: 0.65rem 0.85rem;
    color: var(--muted);
    font-size: 0.85rem;
  }

  /*
   * На телефоне заявки — в #bot-orders-mobile (чипы + одна панель).
   * Сегменты и desktop-таблицы прячем: иначе клик по «Лимиты» и т.п.
   * переключает скрытые panel'ы и оставляет пустое место под вкладками.
   */
  .bot-orders-seg,
  .lab-side-table-section {
    display: none;
  }

  .docs-toc-mobile-btn {
    display: inline-flex;
    flex-shrink: 0;
  }

  .docs-page-header {
    flex-direction: row;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
  }

  .settings-mobile-subtitle {
    display: block;
    margin: 0.15rem 0 0;
    font-size: 0.88rem;
  }

  .settings-dialog-body .settings-section {
    padding: 0;
    margin-bottom: 0.65rem;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.12);
    overflow: hidden;
  }

  .settings-dialog-body .settings-section > summary {
    cursor: pointer;
    padding: 0.85rem 1rem;
    font-weight: 700;
    font-size: 0.95rem;
    list-style: none;
  }

  .settings-dialog-body .settings-section > summary::-webkit-details-marker {
    display: none;
  }

  .settings-dialog-body .settings-section > .settings-section-inner {
    padding: 0 1rem 1rem;
  }

  .mobile-confirm-text {
    margin: 0 0 1rem;
    line-height: 1.5;
    color: var(--muted);
  }

  .mobile-confirm-text strong {
    color: var(--text);
  }

  .mobile-confirm-actions {
    display: flex;
    gap: 0.55rem;
  }

  .mobile-confirm-actions .btn {
    flex: 1;
    min-height: 2.75rem;
  }

  .pull-refresh-indicator.is-pulling {
    color: var(--accent);
  }

  .pull-refresh-indicator.is-refreshing::before {
    content: '';
    display: inline-block;
    width: 0.85rem;
    height: 0.85rem;
    margin-right: 0.35rem;
    border: 2px solid var(--line);
    border-top-color: var(--accent);
    border-radius: 50%;
    vertical-align: -0.1rem;
    animation: pull-refresh-spin 0.7s linear infinite;
  }

  @keyframes pull-refresh-spin {
    to { transform: rotate(360deg); }
  }

  .bots-list .bot-row.is-selected {
    border-width: 1.5px;
    border-color: rgba(61, 214, 198, 0.82);
    box-shadow: none;
  }

  .bots-list .bot-row-name {
    font-size: 1.05rem;
  }

  .bots-list .bot-row-ticker,
  .bots-list .bot-row-price {
    font-size: 0.95rem;
  }

  .bots-list-skeleton {
    display: block;
  }

  .bot-row-skeleton,
  .bot-card-skeleton {
    width: 100%;
    height: 3rem;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: linear-gradient(90deg, rgba(255,255,255,0.04) 25%, rgba(255,255,255,0.08) 50%, rgba(255,255,255,0.04) 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.2s ease-in-out infinite;
  }

  @keyframes skeleton-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
  }

  .page-bots > .page-header {
    margin-bottom: 0.65rem;
  }

  .page-bots > .page-header h2 {
    font-size: 1.35rem;
  }
}

@media (min-width: 769px) {
  /* Chip-фильтры — только mobile sticky; на десктопе колоночный select. */
  .page-bots #bots-fleet-filters,
  .bots-fleet-filters-mobile {
    display: none !important;
  }

  .settings-dialog-body .settings-section > summary {
    display: none;
  }

  .settings-dialog-body .settings-section > .settings-section-inner {
    padding: 0;
  }

  .settings-dialog-body .settings-section {
    padding: 1.15rem 1.2rem 1.3rem;
    margin-bottom: 1rem;
    border-radius: var(--radius);
    background: linear-gradient(180deg, var(--panel) 0%, var(--panel-2) 100%);
    box-shadow: var(--shadow);
    overflow: visible;
  }

  .mobile-hint[open] .mobile-hint-summary {
    display: none;
  }

  .mobile-hint .sub,
  .mobile-hint .muted {
    display: block;
  }

  /* Десктоп «Роботы»: обе колонки одной высоты — иначе sticky-флот держит
     «Состояние», а «Позиции» уезжают при скролле/collapse и шапки расходятся. */
  .shell:has(.page-bots.active) {
    height: 100vh;
    min-height: 100vh;
    overflow: hidden;
    /* auto-ряд растёт с «Ещё» в сайдбаре → контент выше 100vh → футер флота клипится */
    grid-template-rows: minmax(0, 1fr);
    align-items: stretch;
  }

  .shell:has(.page-bots.active) .sidebar {
    /* overflow на сайдбаре клипит кнопку сворачивания (right: -14px) */
    display: flex;
    flex-direction: column;
    min-height: 0;
    height: auto;
    max-height: 100%;
    overflow: visible;
  }

  .shell:has(.page-bots.active) .sidebar > .brand,
  .shell:has(.page-bots.active) .sidebar > .fleet-sidebar-summary {
    flex-shrink: 0;
  }

  .shell:has(.page-bots.active) .sidebar > .nav {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    align-content: start;
  }

  /*
   * Свёрнутый rail + «Роботы»: выезд «Ещё» absolute вправо от .nav-more.
   * overflow у .nav клипит панель — пункты «не появляются», хотя open=true.
   * В rail иконки короткие, вертикальный скролл .nav не нужен.
   */
  .shell.is-sidebar-collapsed:has(.page-bots.active) .sidebar > .nav {
    overflow: visible;
  }

  .shell:has(.page-bots.active) .sidebar-collapse-btn {
    z-index: 50;
  }

  .content:has(.page-bots.active) {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    overflow: hidden;
    /* Нижний padding съедал место у пагинации флота (футер уезжал под clip). */
    padding-bottom: 0.5rem;
  }

  /* Специфичность выше .page.active { display:block }, иначе страница не flex
     и lab-layout растёт по контенту → список ботов без скролла, пагинация за экраном. */
  .page.page-bots.active {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
  }

  .page-bots > .page-header {
    flex-shrink: 0;
  }

  .page-bots .lab-layout {
    display: grid;
    /* Флот по ширине таблицы (скрытый столбец сжимает панель); справа — остаток */
    grid-template-columns: minmax(0, max-content) minmax(0, 1fr);
    /* auto-ряд тянется по max-content детей и ломает 100vh-оболочку */
    grid-template-rows: minmax(0, 1fr);
    gap: 0.85rem;
    align-items: stretch;
    justify-content: start;
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    width: 100%;
    overflow: hidden;
  }

  .page-bots .lab-layout > .bots-fleet {
    position: static;
    max-height: none;
    height: auto;
    margin-bottom: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    width: max-content;
    max-width: 100%;
    min-width: 0;
    min-height: 0;
    justify-self: start;
    /* .section padding-bottom оставлял пустую полосу под футером и клипил его */
    padding-bottom: 0.55rem;
  }

  .page-bots .bots-fleet-top,
  .page-bots .bots-fleet-strip {
    flex-shrink: 0;
  }

  .page-bots .bots-fleet-top {
    /* Одна линия с «Позиции счёта»: заголовок и кнопки по верху, без вертикального съезда */
    align-items: flex-start;
  }

  .page-bots .bots-fleet-top .bots-list-header h3,
  .page-bots .positions-header h3 {
    margin: 0;
    line-height: 1.25;
    min-height: 1.75rem;
    display: flex;
    align-items: center;
  }

  .page-bots .bots-fleet-top .bots-toolbar,
  .page-bots .positions-header .actions-inline {
    min-height: 1.75rem;
    align-items: center;
  }

  /* Скролл только строк: шапка/фильтры и пагинация вне scroll-контейнера */
  .page-bots .bots-fleet-table {
    /* basis 0 — иначе auto по контенту строк выталкивает пагинацию за clip */
    flex: 1 1 0;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }

  .page-bots .bots-fleet-table-chrome {
    /* Тот же scrollbar-gutter, что у списка — иначе колонки шапки шире строк. */
    flex: 0 0 auto;
    overflow-x: hidden;
    overflow-y: auto;
    scrollbar-gutter: stable;
    background: rgba(15, 20, 27, 0.97);
    padding-bottom: 0.15rem;
  }

  .page-bots .bots-list {
    flex: 1 1 0;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    scrollbar-gutter: stable;
  }

  .page-bots .bots-list-pagination {
    flex: 0 0 auto;
    margin-top: 0.15rem;
    /* Не overflow/gutter как у строк — иначе «Строк»/номера страниц клипятся */
    overflow: visible;
    scrollbar-gutter: auto;
    padding-bottom: 0.35rem;
  }

  .page-bots .lab-layout > .bots-detail {
    display: grid;
    /* Иначе колонка auto раздувается вкладками/таблицами шире 24% и клипится —
       «Логи»/«Калькулятор» уезжают за край, клики по вкладкам «мёртвые». */
    grid-template-columns: minmax(0, 1fr);
    gap: 0.85rem;
    align-content: start;
    min-width: 0;
    max-width: 100%;
    height: auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    scrollbar-gutter: stable;
  }

  .page-bots .lab-layout > .bots-detail > .section {
    margin-bottom: 0;
  }

  .page-bots .positions-header {
    /* Колонка: заголовок на одной линии с «Состояние», кнопки ниже — без wrap в узкой панели */
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 0.45rem;
  }

  .page-bots .positions-header .actions-inline {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
  }

  .page-bots .positions-header .actions-inline .btn {
    flex: 1 1 auto;
    min-width: 0;
    justify-content: center;
  }

  .page-bots .positions-header,
  .page-bots .positions-header .actions-inline,
  .page-bots .bot-lab-tabs {
    display: flex;
    flex-wrap: wrap;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
  }

  .page-bots .bot-lab-tabs {
    /* Не inline-flex: иначе max-content раздувает колонку деталки */
    gap: 0.25rem;
  }

  .page-bots .bot-lab-tab {
    flex: 1 1 auto;
    min-width: 0;
    padding: 0.4rem 0.45rem;
    text-align: center;
  }

  .page-bots .bots-detail .table-wrap,
  .page-bots .bots-detail .section {
    max-width: 100%;
    min-width: 0;
  }

  /* Перенос даты запуска — только в строках, не в шапке («ЗАПУСК» не по буквам) */
  .page-bots .bots-list .bot-row .bot-row-started {
    overflow-wrap: anywhere;
    white-space: normal;
  }

  .page-bots .bot-row-head .bot-row-started,
  .page-bots .bot-row-head .bot-row-sort {
    overflow-wrap: normal;
    white-space: nowrap;
  }

  .page-bots .bots-fleet-table .bot-row,
  .page-bots .bots-fleet-table .bot-row-head,
  .page-bots .bots-fleet-table .bot-row-filters {
    min-width: 0;
    /* Не width:100% — иначе таблица не сжимается при скрытии столбца */
    width: max-content;
    max-width: 100%;
    grid-template-columns: var(--fleet-cols);
    column-gap: var(--fleet-col-gap);
    padding-left: var(--fleet-row-pad-x);
    padding-right: var(--fleet-row-pad-x);
  }

  /* Только строки данных — иначе шапка (ИМЯ/ТИКЕР/…) наследует 0.88/0.8 и «плывёт» */
  .page-bots .bots-list .bot-row:not(.bot-row-head) .bot-row-name {
    font-size: 0.88rem;
  }

  .page-bots .bots-list .bot-row:not(.bot-row-head) .bot-row-ticker,
  .page-bots .bots-list .bot-row:not(.bot-row-head) .bot-row-lots,
  .page-bots .bots-list .bot-row:not(.bot-row-head) .bot-row-price,
  .page-bots .bots-list .bot-row:not(.bot-row-head) .bot-row-started {
    font-size: 0.8rem;
  }

  .page-bots .bot-row-head,
  .page-bots .bot-row-head .bot-row-sort,
  .page-bots .bot-row-head .bot-row-quick {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.04em;
  }

  .page-bots .bot-row-quick .btn {
    min-width: 3.5rem;
    padding-left: 0.4rem;
    padding-right: 0.4rem;
    font-size: 0.78rem;
  }

  /* Узкая правая колонка: позиции — карточки, без горизонтального скролла таблицы */
  .page-bots .positions-table-wrap {
    display: none;
  }

  .page-bots .positions-cards {
    display: grid;
    gap: 0.45rem;
  }

  /* Позиция: только таблицы; логи — отдельная вкладка на всю ширину */
  .page-bots #bot-lab-panel-console .lab-body,
  .page-bots #bot-lab-panel-console .lab-body-position {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .page-bots #bot-lab-panel-logs .lab-body,
  .page-bots #bot-lab-panel-logs .lab-body-logs {
    grid-template-columns: 1fr;
  }

  .page-bots #bot-lab-panel-logs .lab-main .terminal {
    min-height: 14rem;
    max-height: min(55vh, 28rem);
  }

  /* --- classic: стек как в master (флот → позиции → вкладки), без side-by-side --- */
  body.is-fleet-ui-classic .shell:has(.page-bots.active) {
    height: auto;
    min-height: 100vh;
    overflow: visible;
    grid-template-rows: auto;
    align-items: start;
  }

  body.is-fleet-ui-classic .shell:has(.page-bots.active) .sidebar {
    display: block;
    height: auto;
    max-height: none;
    overflow: visible;
  }

  body.is-fleet-ui-classic .shell:has(.page-bots.active) .sidebar > .nav {
    flex: none;
    overflow: visible;
  }

  body.is-fleet-ui-classic .content:has(.page-bots.active) {
    display: block;
    width: min(1100px, 100%);
    max-width: 100%;
    height: auto;
    min-height: 0;
    overflow: visible;
    padding-bottom: 1.5rem;
  }

  body.is-fleet-ui-classic .page.page-bots.active {
    display: block;
    flex: none;
    height: auto;
    min-height: 0;
    overflow: visible;
  }

  body.is-fleet-ui-classic .page-bots .lab-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto;
    gap: 1rem;
    align-items: start;
    justify-content: stretch;
    flex: none;
    width: 100%;
    min-height: 0;
    overflow: visible;
  }

  body.is-fleet-ui-classic .page-bots .lab-layout > .bots-fleet {
    display: block;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    min-height: 0;
    height: auto;
    overflow: visible;
    justify-self: stretch;
    padding-bottom: 1.15rem;
  }

  body.is-fleet-ui-classic .page-bots .bots-fleet-table {
    flex: none;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 100%;
    min-height: 0;
    overflow: visible;
  }

  body.is-fleet-ui-classic .page-bots .bots-fleet-table-chrome {
    flex: none;
    overflow: visible;
    scrollbar-gutter: auto;
  }

  body.is-fleet-ui-classic .page-bots .bots-list {
    flex: none;
    overflow: visible;
    scrollbar-gutter: auto;
    max-height: none;
  }

  body.is-fleet-ui-classic .page-bots .bots-list-pagination {
    overflow: visible;
  }

  body.is-fleet-ui-classic .page-bots .lab-layout > .bots-detail {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 1rem;
    width: 100%;
    max-width: 100%;
    height: auto;
    min-height: 0;
    overflow: visible;
    scrollbar-gutter: auto;
  }

  body.is-fleet-ui-classic .page-bots .positions-header {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem 1rem;
  }

  body.is-fleet-ui-classic .page-bots .positions-header .actions-inline {
    flex: 0 0 auto;
  }

  body.is-fleet-ui-classic .page-bots .positions-header .actions-inline .btn {
    flex: 0 0 auto;
  }

  body.is-fleet-ui-classic .page-bots .bots-fleet-table .bot-row,
  body.is-fleet-ui-classic .page-bots .bots-fleet-table .bot-row-head,
  body.is-fleet-ui-classic .page-bots .bots-fleet-table .bot-row-filters {
    width: 100%;
    max-width: 100%;
  }

  body.is-fleet-ui-classic .page-bots .bot-lab-tabs {
    display: inline-flex;
    flex-wrap: wrap;
    width: auto;
    max-width: 100%;
  }

  body.is-fleet-ui-classic .page-bots .bot-lab-tab {
    flex: 0 0 auto;
    padding: 0.45rem 0.75rem;
  }
}

