/* SMC Lux Algo — production UI. Единая принудительная тёмная тема. */

:root {
  color-scheme: dark;

  /* Поверхности */
  --bg: #0a0d13;
  --surface: #10141c;
  --surface-2: #161b25;
  --surface-3: #1d2330;
  --border: #232a37;
  --border-strong: #2e3747;

  /* Текст */
  --text: #e6ebf3;
  --text-dim: #8d96a8;
  --text-faint: #5c6577;

  /* Интерактив */
  --accent: #4c8dff;
  --accent-strong: #6ea2ff;
  --accent-dim: rgba(76, 141, 255, .14);

  /* Семантика PnL/directional */
  --bull: #22a67a;
  --bull-text: #3ecb97;
  --bull-dim: rgba(34, 166, 122, .14);
  --bear: #e0475b;
  --bear-text: #f16b7d;
  --bear-dim: rgba(224, 71, 91, .13);
  --warn: #c98500;
  --warn-text: #e3a53a;
  --warn-dim: rgba(201, 133, 0, .14);
  --violet: #9085e9;
  --violet-text: #aba2f0;
  --violet-dim: rgba(144, 133, 233, .14);

  /* Системные предупреждения */
  --alert-danger-bg: #4a1420;
  --alert-danger-text: #ffd7dc;
  --alert-danger-border: #6b1c2c;
  --alert-warn-bg: #4a3410;
  --alert-warn-text: #ffe2b0;
  --alert-warn-border: #6b4d16;

  /* График */
  --chart-bg: #0b0f16;
  --chart-grid: #1a2029;
  --chart-axis: #5c6577;
  --chart-wick: #4a5364;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "SF Mono", "JetBrains Mono", Consolas, monospace;

  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;

  --topbar-h: 52px;
  --pairs-w: 288px;
  --bottom-h: 252px;
  --bottom-h-collapsed: 40px;
  --drawer-w: 380px;

  --shadow-1: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-2: 0 12px 32px rgba(0, 0, 0, .5);
  --shadow-3: 0 24px 64px rgba(0, 0, 0, .55);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
[hidden] { display: none !important; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  height: 100dvh;
}

button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; }
::selection { background: rgba(76, 141, 255, .3); }

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

.num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); }
.dim { color: var(--text-dim); }
.faint { color: var(--text-faint); }
.bull { color: var(--bull-text); }
.bear { color: var(--bear-text); }

/* ---------- Каркас страницы ----------------------------------- */

.app {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.app > .topbar { flex: none; }
.app > .alert-bar { flex: none; }
.app > .workspace { flex: 1; min-height: 0; }

.workspace {
  display: grid;
  grid-template-columns: 1fr var(--pairs-w);
  grid-template-rows: 1fr var(--bottom-h);
  min-height: 0;
  min-width: 0;
  transition: grid-template-rows .16s ease;
}
.workspace.bottom-collapsed { grid-template-rows: 1fr var(--bottom-h-collapsed); }

/* ---------- Топбар ---------------------------------------------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  height: var(--topbar-h);
  padding: 0 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  min-width: 0;
}

.tb-brand { display: flex; align-items: center; gap: 8px; flex: none; }
.tb-logo {
  width: 26px; height: 26px; border-radius: 7px; flex-shrink: 0;
  background: linear-gradient(135deg, #3a6fd8, #7a5ff0);
  display: grid; place-items: center;
  color: #fff; font-weight: 800; font-size: 11px; letter-spacing: -.02em;
}
.tb-name { font-weight: 700; font-size: 12.5px; letter-spacing: .04em; color: var(--text); white-space: nowrap; }

.tb-sep { width: 1px; align-self: stretch; margin: 12px 0; background: var(--border); flex: none; }

.tb-active { display: flex; align-items: center; gap: 10px; min-width: 0; flex: none; }
.tb-active__symbol {
  font-weight: 700; font-size: 13.5px; white-space: nowrap;
  display: flex; align-items: center; gap: 6px;
}
.tb-active__dot { width: 6px; height: 6px; border-radius: 50%; background: var(--bull-text); flex: none; }
.tb-active__dot.paused { background: var(--text-faint); }

.seg {
  display: inline-flex; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 8px; padding: 2px; gap: 1px; flex: none;
}
.seg button {
  background: none; border: none; color: var(--text-dim); font-family: var(--font);
  font-size: 11.5px; font-weight: 600; padding: 4px 9px; border-radius: 6px; white-space: nowrap;
}
.seg button.active { background: var(--surface-3); color: var(--text); box-shadow: var(--shadow-1); }
.seg button:hover:not(.active) { color: var(--text); }

.tb-profile {
  flex: none; white-space: nowrap;
  border: 1px solid var(--border); border-radius: 999px;
  padding: 3px 10px 3px 8px; font-size: 11px; color: var(--text-dim);
  display: inline-flex; align-items: center; gap: 6px;
  background: none; cursor: pointer;
}
.tb-profile:hover { border-color: var(--border-strong); color: var(--text); }
.tb-profile b { color: var(--text); font-weight: 600; }
.tb-profile svg { width: 11px; height: 11px; color: var(--text-faint); }

.tb-spacer { flex: 1; min-width: 8px; }

.tb-status {
  flex: none; color: var(--text-faint); font-size: 11.5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 270px;
}

.icon-btn {
  position: relative; flex: none;
  display: grid; place-items: center;
  width: 32px; height: 32px;
  background: none; border: 1px solid transparent; border-radius: 8px;
  color: var(--text-dim);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn.is-open { background: var(--surface-3); color: var(--text); border-color: var(--border-strong); }

.icon-btn__badge {
  position: absolute; top: 3px; right: 3px;
  min-width: 14px; height: 14px; padding: 0 3px;
  border-radius: 999px; background: var(--bear);
  color: #fff; font-size: 9px; font-weight: 700; line-height: 14px; text-align: center;
  box-shadow: 0 0 0 2px var(--surface);
}

/* ---------- Alert banner ---------------------------------------- */

.alert-bar {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 9px 14px; font-size: 12px; line-height: 1.5;
  background: var(--alert-danger-bg); color: var(--alert-danger-text);
  border-bottom: 1px solid var(--alert-danger-border);
}
.alert-bar.warn {
  background: var(--alert-warn-bg); color: var(--alert-warn-text);
  border-bottom-color: var(--alert-warn-border);
}
.alert-bar svg { width: 15px; height: 15px; flex: none; margin-top: 1px; }
.alert-bar__body { display: grid; gap: 2px; min-width: 0; }
.alert-bar code { background: rgba(0, 0, 0, .3); padding: 1px 5px; border-radius: 4px; }
/* ---------- График ------------------------------------------------ */

.chart-col { position: relative; min-width: 0; min-height: 0; grid-row: 1 / 2; grid-column: 1 / 2; background: var(--chart-bg); }
#chart-surface { position: absolute; inset: 0; touch-action: none; }

.legend {
  position: absolute; top: 10px; left: 14px; z-index: 3;
  display: flex; flex-wrap: wrap; gap: 4px 14px;
  font-size: 11px; color: var(--text-dim); pointer-events: none;
  text-shadow: 0 1px 3px rgba(0,0,0,.6);
}
.legend b { font-weight: 700; color: var(--text); }
.legend .bull { color: var(--bull-text); }
.legend .bear { color: var(--bear-text); }

.tooltip {
  position: absolute; z-index: 5; pointer-events: none;
  background: var(--surface-2); border: 1px solid var(--border-strong);
  border-radius: var(--r-sm); padding: 8px 10px; font-size: 11.5px; line-height: 1.5;
  max-width: 270px; box-shadow: var(--shadow-2);
}
.tooltip h4 { margin: 0 0 4px; font-size: 11.5px; font-weight: 700; }
.tooltip dl { display: grid; grid-template-columns: auto 1fr; gap: 1px 10px; }
.tooltip dt { color: var(--text-dim); }
.tooltip dd { text-align: right; margin: 0; }
.tooltip hr { border: 0; border-top: 1px solid var(--border); margin: 6px 0; }

.chart-tools {
  position: absolute; right: 64px; bottom: 30px; z-index: 4; display: flex; gap: 6px;
}
.chart-tools button {
  padding: 4px 8px; border: 1px solid var(--border); border-radius: var(--r-sm);
  background: var(--surface); color: var(--text-dim); box-shadow: var(--shadow-1); font-size: 11px;
}
.chart-tools button:hover { border-color: var(--accent); color: var(--accent-strong); }

.chart-empty {
  position: absolute; inset: 0; z-index: 4;
  display: grid; place-content: center; justify-items: center; gap: 8px; text-align: center;
  background: var(--chart-bg);
}
.chart-empty h2 { font-size: 15px; font-weight: 700; }
.chart-empty p { color: var(--text-dim); max-width: 320px; }

/* Плашка активного профиля алгоритма поверх графика — всегда видна (docs/06 §11) */
.chart-profile-flag {
  position: absolute; top: 10px; right: 14px; z-index: 3;
  font-size: 10.5px; color: var(--text-faint);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 999px; padding: 3px 10px;
  pointer-events: none; opacity: .86;
}
.chart-profile-flag b { color: var(--text-dim); font-weight: 600; }

/* ---------- Правая панель: пары ---------------------------------- */

.pairs {
  grid-row: 1 / 3; grid-column: 2 / 3;
  border-left: 1px solid var(--border);
  background: var(--surface);
  display: flex; flex-direction: column;
  min-height: 0;
}

.pairs__head {
  flex: none; padding: 12px 12px 10px;
  border-bottom: 1px solid var(--border);
  display: grid; gap: 9px;
}
.pairs__title-row { display: flex; align-items: center; gap: 8px; }
.pairs__title { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--text-faint); font-weight: 700; }
.pairs__count {
  background: var(--surface-3); color: var(--text-dim); font-size: 10.5px; font-weight: 700;
  padding: 1px 7px; border-radius: 999px;
}
.pairs__add {
  margin-left: auto; flex: none;
  display: grid; place-items: center; width: 24px; height: 24px;
  border-radius: 7px; border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text-dim);
}
.pairs__add:hover { color: var(--accent-strong); border-color: var(--accent); }
.pairs__add svg { width: 14px; height: 14px; }

.pairs__search {
  position: relative;
}
.pairs__search svg {
  position: absolute; left: 8px; top: 50%; transform: translateY(-50%);
  width: 12px; height: 12px; color: var(--text-faint); pointer-events: none;
}
.pairs__search input {
  width: 100%; background: var(--bg); border: 1px solid var(--border-strong);
  border-radius: 7px; padding: 6px 8px 6px 26px; font-size: 12px; color: var(--text); outline: none;
}
.pairs__search input:focus { border-color: var(--accent); }

.pairs__filters { display: flex; gap: 4px; }
.pairs__filters button {
  flex: 1; background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text-dim); font-size: 10.5px; font-weight: 600; padding: 4px 4px; border-radius: 6px;
}
.pairs__filters button.active { background: var(--accent-dim); color: var(--accent-strong); border-color: rgba(76,141,255,.4); }

.market-groups__head { display: flex; align-items: flex-start; gap: 5px; min-width: 0; }
.market-groups {
  display: flex; gap: 4px; min-width: 0; overflow-x: auto; scrollbar-width: thin;
  padding-bottom: 2px; flex: 1;
}
.market-groups button, .market-groups__manage {
  flex: none; background: none; border: 1px solid var(--border); border-radius: 999px;
  color: var(--text-faint); font-size: 10px; padding: 3px 7px; white-space: nowrap;
}
.market-groups button.active { color: var(--accent-strong); border-color: var(--accent); background: var(--accent-dim); }
.market-groups__manage:hover, .market-groups button:hover { color: var(--text); border-color: var(--border-strong); }

.market-bulk {
  display: grid; grid-template-columns: 1fr; gap: 5px; padding: 7px;
  border: 1px solid var(--border); border-radius: 7px; background: var(--bg);
}
.market-bulk label { display: flex; align-items: center; gap: 6px; font-size: 10.5px; color: var(--text-dim); }
.market-bulk input, .pair__select input { accent-color: var(--accent); }
.market-bulk select {
  width: 100%; background: var(--surface-2); border: 1px solid var(--border-strong);
  border-radius: 6px; padding: 4px 6px; font-size: 10.5px;
}
.market-bulk__actions { display: flex; gap: 5px; }
.market-bulk__actions button {
  flex: 1; background: var(--surface-2); border: 1px solid var(--border-strong);
  border-radius: 6px; padding: 4px; color: var(--text-dim); font-size: 10.5px;
}
.market-bulk__actions button:hover { color: var(--accent-strong); border-color: var(--accent); }

.pairs__list { flex: 1; overflow-y: auto; padding: 6px; min-height: 0; }
.data-list { list-style: none; margin: 0; }
.pairs__empty { padding: 24px 12px; text-align: center; color: var(--text-faint); font-size: 12px; }

.pair {
  border: 1px solid transparent; border-radius: var(--r-sm);
  margin-bottom: 2px;
}
.pair.is-active { background: var(--accent-dim); border-color: rgba(76, 141, 255, .35); }
.pair.is-paused .pair__row { opacity: .68; }
.pair.is-archived .pair__row { opacity: .5; }

.pair__row {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 6px 7px 4px;
  border-radius: var(--r-sm);
  cursor: pointer;
}
.pair__row:hover { background: var(--surface-2); }
.pair__select { width: 16px; height: 18px; display: grid; place-items: center; flex: none; }
.pair__select input { width: 13px; height: 13px; }
.pair__state-dot.pending { background: var(--accent-strong); }
.pair__state-dot.error { background: var(--bear-text); }
.pair__group-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px; }
.pair__group-chip { font-size: 9.5px; color: var(--violet-text); background: var(--violet-dim); border-radius: 999px; padding: 2px 6px; }
.pair.is-active .pair__row:hover { background: rgba(76, 141, 255, .12); }

.pair__chevron {
  flex: none; width: 16px; height: 16px; display: grid; place-items: center;
  color: var(--text-faint); transition: transform .14s ease;
}
.pair.is-open .pair__chevron { transform: rotate(90deg); }

.pair__symbol { font-weight: 650; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pair__meta { margin-left: 2px; flex: 1; min-width: 0; display: flex; align-items: center; gap: 5px; }
.pair__state-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--bull-text); flex: none; }
.pair__state-dot.paused { background: var(--text-faint); }
.pair__state-dot.archived { background: var(--warn-text); }
.pair__badge-tf { color: var(--text-faint); font-size: 10px; }

.pair__actions { display: flex; align-items: center; gap: 6px; flex: none; }

.switch { position: relative; display: inline-block; width: 30px; height: 17px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch .track {
  position: absolute; inset: 0; border-radius: 999px;
  background: var(--surface-3); border: 1px solid var(--border-strong); transition: background .15s;
}
.switch .track::before {
  content: ''; position: absolute; top: 1px; left: 1px; width: 13px; height: 13px; border-radius: 50%;
  background: var(--text-dim); transition: transform .15s, background .15s;
}
.switch input:checked + .track { background: var(--bull); border-color: var(--bull); }
.switch input:checked + .track::before { transform: translateX(13px); background: #fff; }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }

.trash-btn {
  flex: none; width: 24px; height: 24px; display: grid; place-items: center;
  border-radius: 6px; border: 1px solid transparent; background: none; color: var(--text-faint);
}
.trash-btn:hover:not(:disabled) { color: var(--bear-text); background: var(--bear-dim); }
.trash-btn:disabled { opacity: .32; cursor: not-allowed; }
.trash-btn svg { width: 13.5px; height: 13.5px; }

.pair__body {
  display: none;
  padding: 2px 8px 10px 26px;
}
.pair.is-open .pair__body { display: block; }

.pair__tracking-note { font-size: 10.5px; color: var(--text-faint); margin-bottom: 6px; line-height: 1.5; }

.tf-list { display: grid; gap: 4px; }
.tf-entry { display: grid; gap: 2px; }
.tf-chip {
  display: flex; align-items: center; gap: 7px;
  border: 1px solid var(--border); border-radius: var(--r-sm);
  width: 100%; padding: 5px 8px; cursor: pointer; background: var(--bg); text-align: left;
}
.tf-chip:hover { border-color: var(--border-strong); }
.tf-chip.is-active { border-color: var(--accent); background: var(--accent-dim); }
.tf-chip__dot { width: 6px; height: 6px; border-radius: 50%; flex: none; }
.tf-chip__dot.ok { background: var(--bull-text); }
.tf-chip__dot.pending { background: var(--accent-strong); }
.tf-chip__dot.error { background: var(--bear-text); }
.tf-chip__tf { font-weight: 700; font-size: 11.5px; width: 28px; flex: none; }
.tf-chip__meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; overflow: hidden; }
.tf-chip__meta span { font-size: 10px; color: var(--text-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tf-chip__meta strong { font-size: 10.5px; color: var(--text-dim); font-weight: 500; }
.tf-chip__issue { color: var(--bear-text) !important; }
.tf-diagnostics {
  color: var(--text-faint); font-size: 10px; padding: 0 8px 3px;
}
.tf-diagnostics summary { cursor: pointer; width: max-content; max-width: 100%; }
.tf-diagnostics__grid { display: grid; gap: 2px; padding: 5px 0 2px; line-height: 1.4; }
.tf-diagnostics__backlog { color: var(--warn-text); }

.mini-btn {
  background: var(--surface-2); border: 1px solid var(--border-strong); color: var(--text);
  font-size: 11px; font-weight: 600; padding: 5px 10px; border-radius: 7px;
}
.mini-btn:hover { border-color: var(--accent); color: var(--accent-strong); }
.mini-btn.danger { color: var(--bear-text); border-color: rgba(224,71,91,.4); background: none; }
.mini-btn.danger:hover { background: var(--bear-dim); border-color: var(--bear); }
.mini-btn:disabled { opacity: .4; cursor: not-allowed; }

.delete-confirm {
  margin-top: 8px; padding: 9px; border: 1px dashed var(--border-strong); border-radius: var(--r-sm);
  display: grid; gap: 7px; background: var(--bg);
}
.delete-confirm p { font-size: 10.5px; color: var(--text-dim); line-height: 1.5; }
.delete-confirm p.warn { color: var(--bear-text); }
.delete-confirm input {
  width: 100%; background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 6px; padding: 6px 8px; font-size: 11.5px; color: var(--text); outline: none;
}
.delete-confirm input:focus { border-color: var(--bear); }
.delete-confirm .row { display: flex; gap: 6px; }

.pairs__archive { margin: 6px 10px 10px; }
.pairs-scrim { display: none; }

/* ---------- Нижняя панель: слои / правила / состояние / сигналы --- */

.bottom {
  grid-row: 2 / 3; grid-column: 1 / 2;
  border-top: 1px solid var(--border);
  background: var(--surface);
  display: flex; flex-direction: column; min-height: 0;
}

.bottom__tabs {
  flex: none; display: flex; align-items: center; gap: 2px;
  padding: 0 6px; height: 38px; border-bottom: 1px solid var(--border);
}
.bottom__tab {
  background: none; border: none; height: 100%;
  color: var(--text-dim); font-size: 12px; font-weight: 650;
  padding: 0 13px; border-bottom: 2px solid transparent;
  display: inline-flex; align-items: center; gap: 6px;
}
.bottom__tab:hover { color: var(--text); }
.bottom__tab.active { color: var(--accent-strong); border-bottom-color: var(--accent); }
.bottom__tab .cnt {
  background: var(--surface-3); color: var(--text-dim); font-size: 10px; font-weight: 700;
  padding: 0 5px; border-radius: 999px; line-height: 15px; min-width: 15px; text-align: center;
}
.bottom__tab.active .cnt { background: var(--accent-dim); color: var(--accent-strong); }
.bottom__spacer { flex: 1; }
.bottom__collapse {
  flex: none; width: 26px; height: 26px; display: grid; place-items: center;
  border-radius: 6px; color: var(--text-faint); background: none; border: none;
}
.bottom__collapse:hover { background: var(--surface-2); color: var(--text); }
.bottom__collapse svg { width: 14px; height: 14px; transition: transform .16s ease; }
.workspace.bottom-collapsed .bottom__collapse svg { transform: rotate(180deg); }

.bottom__body { flex: 1; min-height: 0; overflow-y: auto; }
.workspace.bottom-collapsed .bottom__body { display: none; }

.bottom__pane { display: none; padding: 14px 16px; }
.bottom__pane.active { display: block; }

.pane-group { margin-bottom: 16px; }
.pane-group:last-child { margin-bottom: 0; }
.pane-group__title {
  font-size: 10px; text-transform: uppercase; letter-spacing: .07em; color: var(--text-faint);
  font-weight: 700; margin-bottom: 8px;
}

/* Четыре группы слоёв — четыре колонки: самая длинная группа (4 строки)
   помещается в высоту нижней панели целиком, без прокрутки. */
.layers {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px 24px; align-items: start;
}
.layers .pane-group { margin-bottom: 0; min-width: 0; }

.layer-grid { display: grid; grid-template-columns: 1fr; gap: 1px; }
.layer-row {
  display: flex; align-items: center; gap: 8px; padding: 3px 2px; cursor: pointer; font-size: 11.5px; min-width: 0;
}
.layer-row:hover { color: var(--text); }
.layer-row input { accent-color: var(--accent); width: 13px; height: 13px; flex: none; }
.layer-row__preview { display: flex; flex: none; }
.layer-row__preview .lp { width: 22px; height: 12px; display: block; }
.layer-row span.name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.rules-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
@media (max-width: 1180px) { .rules-cols { grid-template-columns: 1fr; } }

.rule-row, .preset-row {
  display: flex; align-items: center; gap: 10px; justify-content: space-between;
  padding: 7px 0; border-bottom: 1px solid var(--border);
}
.rule-row:last-child, .preset-row:last-child { border-bottom: none; }
.rule-row__name { display: grid; gap: 1px; font-size: 12px; min-width: 0; }
.rule-row__name b { display: block; font-weight: 650; }
.rule-row__name span { color: var(--text-faint); font-size: 11px; }
.preset-row__text { min-width: 0; }
.preset-row__text b { font-size: 12px; font-weight: 650; display: block; }
.preset-row__text span { color: var(--text-dim); font-size: 11px; line-height: 1.4; }
.preset-row__actions { display: flex; align-items: center; gap: 6px; flex: none; }
.rules-empty { color: var(--text-faint); font-size: 12px; padding: 4px 0 12px; }
.rules-status { font-size: 11px; color: var(--accent-strong); margin-top: 8px; }
.rules-list { list-style: none; }
.pane-note { color: var(--text-faint); font-size: 11px; line-height: 1.45; margin-bottom: 8px; }
.pane-title-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.preview-range { display: flex; align-items: center; gap: 7px; color: var(--text-faint); font-size: 10.5px; }
.preview-range select { background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 3px 5px; }
.panel__button {
  background: var(--surface-2); border: 1px solid var(--border-strong); color: var(--text-dim);
  border-radius: 6px; padding: 4px 8px; font-size: 10.5px; white-space: nowrap;
}
.panel__button:hover { border-color: var(--accent); color: var(--accent-strong); }
.panel__button:disabled { opacity: .45; cursor: not-allowed; }
.panel__note { color: var(--text-dim); font-size: 11px; line-height: 1.45; }
.panel__note--warning { color: var(--bear-text); }
.bottom__status { margin: 8px 16px 14px; }

.state-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.state-tile {
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: 9px 11px;
}
.state-tile__label { font-size: 10px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-faint); font-weight: 650; margin-bottom: 5px; }
.state-tile__value { font-size: 14.5px; font-weight: 700; }
.state-tile__value.bull { color: var(--bull-text); }
.state-tile__value.bear { color: var(--bear-text); }

.signals-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.signals-table th {
  text-align: left; color: var(--text-faint); font-weight: 650; font-size: 10px; text-transform: uppercase;
  letter-spacing: .04em; padding: 0 10px 7px; position: sticky; top: 0; background: var(--surface);
}
.signals-table td { padding: 7px 10px; border-top: 1px solid var(--border); vertical-align: middle; }
.signals-table tr.signal-row { cursor: pointer; }
.signals-table tr.signal-row:hover td { background: var(--surface-2); }
.signals-table td.num { text-align: right; }
.signals-table .signals-empty td { color: var(--text-faint); text-align: center; padding: 22px; }
.table-scroll { overflow-x: auto; }
.dir-chip {
  display: inline-flex; align-items: center; gap: 4px; font-weight: 650; font-size: 11px;
  padding: 1px 7px; border-radius: 5px;
}
.dir-chip.bullish { background: var(--bull-dim); color: var(--bull-text); }
.dir-chip.bearish { background: var(--bear-dim); color: var(--bear-text); }
.dir-chip.neutral { background: var(--surface-3); color: var(--text-dim); }
.pair-tag { color: var(--text-dim); font-size: 11px; }
.pair-tag b { color: var(--text); font-weight: 650; }

/* ---------- Drawer (бургер-меню) ---------------------------------- */

.drawer-backdrop {
  position: fixed; inset: 0; background: rgba(4, 6, 10, .55); z-index: 40;
  opacity: 0; pointer-events: none; transition: opacity .18s ease;
}
.drawer-backdrop.open { opacity: 1; pointer-events: auto; }

.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(var(--drawer-w), 100vw);
  background: var(--surface); border-left: 1px solid var(--border-strong);
  z-index: 41; display: flex; flex-direction: column; min-height: 0;
  transform: translateX(100%); transition: transform .2s ease;
  box-shadow: var(--shadow-3);
}
.drawer.open { transform: translateX(0); }

.drawer__head {
  flex: none; display: flex; align-items: center; gap: 10px;
  padding: 14px 14px; border-bottom: 1px solid var(--border);
}
.drawer__head h2 { font-size: 14px; font-weight: 700; }
.drawer__close {
  margin-left: auto; width: 28px; height: 28px; display: grid; place-items: center;
  border-radius: 7px; background: none; border: none; color: var(--text-dim);
}
.drawer__close:hover { background: var(--surface-2); color: var(--text); }
.drawer__close svg { width: 15px; height: 15px; }

.drawer__body { flex: 1; overflow-y: auto; padding: 4px 0 24px; }

.drawer-section { padding: 14px 16px; border-bottom: 1px solid var(--border); }
.drawer-section:last-child { border-bottom: none; }
.drawer-section h3 {
  font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-faint);
  font-weight: 700; margin-bottom: 9px; display: flex; align-items: center; gap: 8px;
}
.drawer-section p.note { font-size: 11.5px; color: var(--text-dim); line-height: 1.55; margin-bottom: 9px; }
.drawer-section p.note:last-child { margin-bottom: 0; }
.drawer-section p.note.warn { color: var(--warn-text); }
.drawer-section p.note code { font-family: var(--mono); color: var(--text); background: var(--bg); padding: 1px 5px; border-radius: 4px; }
.drawer-section p.note small { display: block; margin-top: 4px; font-size: 10.5px; color: var(--text-faint); }

.field-copy { display: flex; gap: 6px; margin-bottom: 9px; }
.url-field {
  display: block; width: 100%; background: var(--bg); border: 1px solid var(--border-strong);
  border-radius: 7px; padding: 7px 9px; font-size: 10.5px; font-family: var(--mono);
  color: var(--text); outline: none;
}
.copy-btn {
  flex: none; background: var(--surface-2); border: 1px solid var(--border-strong); color: var(--text-dim);
  border-radius: 7px; padding: 0 11px; font-size: 11px; font-weight: 600;
}
.copy-btn:hover { border-color: var(--accent); color: var(--accent-strong); }
.copy-btn.copied { border-color: var(--bull); color: var(--bull-text); }

.btn-block {
  width: 100%; background: var(--surface-2); border: 1px solid var(--border-strong);
  color: var(--text); font-size: 12px; font-weight: 600; padding: 8px 12px; border-radius: 8px;
  margin-bottom: 8px; text-align: left; display: flex; align-items: center; gap: 8px;
}
.btn-block:hover { border-color: var(--accent); color: var(--accent-strong); }
.btn-block.primary { background: var(--accent); border-color: var(--accent); color: #fff; justify-content: center; }
.btn-block.primary:hover { background: var(--accent-strong); }
.btn-block svg { width: 14px; height: 14px; flex: none; }

.status-line { display: flex; align-items: center; gap: 7px; font-size: 11.5px; color: var(--text-dim); margin-bottom: 8px; }
.status-line .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--bull-text); flex: none; }
.status-line.warn .dot { background: var(--warn-text); }
.status-line.warn { color: var(--warn-text); }
.profile-readonly {
  display: flex; align-items: center; gap: 9px; padding: 9px 10px; margin-bottom: 9px;
  border: 1px solid var(--accent); border-radius: var(--r-sm); background: var(--accent-dim);
}
.profile-readonly__dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent-strong); flex: none; }
.profile-readonly div { display: grid; gap: 1px; }
.profile-readonly strong { font-size: 12px; }
.profile-readonly span { color: var(--text-dim); font-size: 10.5px; }
.btn-block.danger { color: var(--bear-text); border-color: rgba(224, 71, 91, .45); }

/* ---------- Диалог добавления пары --------------------------------- */

dialog.app-dialog {
  border: 1px solid var(--border-strong); border-radius: var(--r-lg);
  background: var(--surface-2); color: var(--text); padding: 22px; width: min(380px, 92vw);
}
dialog.app-dialog::backdrop { background: rgba(4, 6, 10, .6); }
dialog.app-dialog h2 { font-size: 15px; margin-bottom: 6px; }
dialog.app-dialog p.hint { color: var(--text-dim); font-size: 11.5px; margin-bottom: 16px; line-height: 1.5; }

.dialog__field { display: grid; gap: 5px; margin-bottom: 14px; }
.dialog__field span { color: var(--text-dim); font-size: 12px; }
.dialog__field input {
  background: var(--bg); border: 1px solid var(--border-strong); border-radius: 8px;
  padding: 9px 11px; outline: none; font-size: 13px;
}
.dialog__field input:focus { border-color: var(--accent); }
.dialog__frames { border: 1px solid var(--border-strong); border-radius: 8px; padding: 10px 12px; margin: 0 0 16px; display: grid; gap: 6px; }
.dialog__frames legend { color: var(--text-dim); font-size: 11px; padding: 0 3px; }
.dialog__frames label { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.dialog__frames input { accent-color: var(--accent); }
.dialog__actions { display: flex; justify-content: flex-end; gap: 8px; }
.dialog__actions button {
  background: none; border: 1px solid var(--border-strong); border-radius: 8px;
  padding: 8px 15px; color: var(--text);
}
.dialog__actions .primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 650; }

.group-dialog { width: min(520px, 94vw) !important; max-height: 82vh; overflow: auto; }
.group-dialog__create { padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.group-dialog__list { display: grid; gap: 6px; margin-top: 14px; }
.group-dialog__row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px; align-items: center; }
.group-dialog__row input {
  min-width: 0; background: var(--bg); border: 1px solid var(--border-strong);
  border-radius: 7px; padding: 7px 8px; outline: none;
}
.group-dialog__actions { display: flex; gap: 4px; }
.group-dialog__actions button {
  background: var(--surface-3); border: 1px solid var(--border-strong); border-radius: 6px;
  color: var(--text-dim); padding: 5px 7px; font-size: 10.5px;
}
.group-dialog__actions button:hover:not(:disabled) { color: var(--text); border-color: var(--accent); }
.group-dialog__actions button.danger:hover { color: var(--bear-text); border-color: var(--bear); }
.group-dialog__actions button:disabled { opacity: .35; cursor: not-allowed; }

/* ---------- Bell dropdown ------------------------------------------ */

.bell-pop {
  position: fixed; top: calc(var(--overlay-top, var(--topbar-h)) + 6px); right: 84px; z-index: 42;
  width: 340px; max-height: 62vh; display: flex; flex-direction: column;
  background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: var(--r-md);
  box-shadow: var(--shadow-3); overflow: hidden;
  opacity: 0; transform: translateY(-6px); pointer-events: none; transition: opacity .14s ease, transform .14s ease;
}
.bell-pop.open { opacity: 1; transform: translateY(0); pointer-events: auto; }
.bell-pop__head { display: flex; align-items: center; gap: 8px; padding: 11px 13px; border-bottom: 1px solid var(--border); flex: none; }
.bell-pop__head h2, .bell-pop__head h3 { font-size: 12.5px; font-weight: 700; }
.bell-pop__head .link { margin-left: auto; font-size: 11px; color: var(--accent-strong); background: none; border: none; }
.bell-pop__head .link:hover { text-decoration: underline; }
.bell-pop__list { overflow-y: auto; flex: 1; }
.bell-item {
  display: flex; gap: 9px; width: 100%; padding: 9px 13px;
  border: 0; border-bottom: 1px solid var(--border); background: none;
  color: inherit; text-align: left; cursor: pointer;
}
.bell-item:last-child { border-bottom: none; }
.bell-item:hover { background: var(--surface-3); }
.bell-item__dot { width: 7px; height: 7px; border-radius: 50%; margin-top: 4px; flex: none; }
.bell-item__dot.bullish { background: var(--bull-text); }
.bell-item__dot.bearish { background: var(--bear-text); }
.bell-item__dot.neutral { background: var(--text-faint); }
.bell-item__body { display: block; min-width: 0; }
.bell-item__rule { display: block; font-size: 12px; font-weight: 650; }
.bell-item__meta { display: block; font-size: 10.5px; color: var(--text-faint); margin-top: 1px; }
.bell-pop__empty { padding: 26px 14px; text-align: center; color: var(--text-faint); font-size: 12px; }

/* ---------- Вход / установка ---------------------------------------- */

.gate {
  position: fixed; inset: 0; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(ellipse at top, var(--surface-3) 0%, var(--bg) 60%);
  z-index: 90;
}
.gate__card {
  width: min(370px, 100%); background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 30px; display: grid; gap: 14px; box-shadow: var(--shadow-3);
}
.gate__brand { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.gate__card h1 { font-size: 17px; font-weight: 700; }
.gate__hint { color: var(--text-dim); font-size: 12px; line-height: 1.55; }
.gate__hint code { background: var(--bg); padding: 1px 5px; border-radius: 4px; }
.gate__card input {
  background: var(--bg); border: 1px solid var(--border-strong); border-radius: 9px;
  padding: 11px 12px; outline: none; font-size: 13px;
}
.gate__card input:focus { border-color: var(--accent); }
.gate__card button.primary {
  background: var(--accent); color: #fff; border: 0; border-radius: 9px; padding: 11px; font-weight: 650;
}
.gate__card button.primary:hover { background: var(--accent-strong); }
.gate__error { color: var(--bear-text); font-size: 12px; }
.gate__note { color: var(--text-faint); font-size: 11px; }

/* ---------- Адаптив -------------------------------------------------- */

.tb-pairs-toggle { display: none; }

@media (max-width: 1000px) {
  :root { --pairs-w: 260px; --drawer-w: 320px; }
  .tb-status { display: none; }
}

@media (max-width: 860px) {
  :root { --bottom-h: 240px; }
  .workspace { grid-template-columns: 1fr; }
  .chart-col { grid-column: 1 / 2; }
  .bottom { grid-column: 1 / 2; }

  .pairs {
    position: fixed; top: var(--overlay-top, var(--topbar-h)); right: 0; bottom: 0; z-index: 30;
    width: min(300px, 88vw); grid-row: auto; grid-column: auto;
    transform: translateX(100%); transition: transform .18s ease;
    box-shadow: var(--shadow-3);
  }
  .pairs.open { transform: translateX(0); }
  .pairs-scrim {
    display: block;
    position: fixed; inset: var(--overlay-top, var(--topbar-h)) 0 0 0; background: rgba(4,6,10,.5); z-index: 29;
    border: 0;
    opacity: 0; pointer-events: none; transition: opacity .18s ease;
  }
  .pairs-scrim.open { opacity: 1; pointer-events: auto; }
  .tb-pairs-toggle { display: grid; }

  .rules-cols { grid-template-columns: 1fr; }
  .bell-pop { right: 10px; width: min(340px, 92vw); }
}

@media (max-width: 1240px) {
  .layers { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 20px; }
}

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

@media (max-width: 620px) {
  .topbar { padding: 0 8px; gap: 6px; }
  .tb-active { gap: 6px; }
  .tb-active__symbol { font-size: 12.5px; }
  .seg button { padding: 4px 7px; }
  .tb-name { display: none; }
  .tb-sep { display: none; }
  .tb-profile { display: none; }
  .layer-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .state-grid { grid-template-columns: repeat(2, 1fr); }
  .drawer { width: 100vw; }
}

@media (max-width: 420px) {
  .signals-table th:nth-child(2), .signals-table td:nth-child(2) { display: none; }
}
