:root {
  color-scheme: dark;
  --bg: #0a0a0a; --panel: #0f0f0f; --surface: #141414; --border: #2a2a2a;
  /* Контраст третичного текста (WCAG AA для мелкого текста — не ниже 4.5:1).
     Прежний #737373 не проходил: 4.18:1 на --bg и 4.04:1 на --panel, а на
     hover-фонах (--surface #141414, #1b1b1b, #262626) падал до 3.89 / 3.63 / 3.19.
     #8f8f8f: 6.12:1 на --bg, 5.93:1 на --panel, 5.70:1 на --surface,
     5.33:1 на #1b1b1b и 4.68:1 на #262626 — везде выше 4.5:1.
     Для справки: --text-2 #a3a3a3 = 7.85 / 7.60, --text #e5e5e5 = 15.72 / 15.22. */
  --text: #e5e5e5; --text-2: #a3a3a3; --text-3: #8f8f8f;
  --support: #22c55e; --resist: #ef4444; --both: #f59e0b;
  /* Ширина правой панели находок. Медиазапросы переопределяют её, а оверлеи
     графика (.chartctl, .chart-loading, .chart-legend) считают свой центр
     через calc() — иначе при сужении панели они уезжали от центра графика. */
  --panel-w: 340px;
  /* Единый цвет видимого кольца фокуса (>3:1 к любому фону терминала). */
  --focus: #9ca3af;
}
* { box-sizing: border-box; }
/* атрибут hidden обязан прятать всегда: авторский display:flex (легенда, плашка,
   оверлей загрузки, полоса прогресса) иначе перебивает UA-правило [hidden] */
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font-family: -apple-system, "Segoe UI", sans-serif; font-size: 14px; }

/* --- экраны (роутер): рынок / график --- */
/* Неактивный экран прячем visibility, НЕ display: контейнер графика обязан
   сохранять размеры, иначе autoSize у Lightweight Charts измерит 0×0. */
.view { position: absolute; inset: 0; display: flex; flex-direction: column;
  background: var(--bg); overflow: hidden;   /* ничто не «торчит» за край окна */
  opacity: 1; transition: opacity 0.18s ease, visibility 0.18s; }   /* кроссфейд экранов */
/* opacity:0 не роняет размеры (в отличие от display:none) — autoSize графика цел.
   visibility в переходе с задержкой = fade успевает до скрытия. */
.view-off { visibility: hidden; opacity: 0; pointer-events: none; }
@media (prefers-reduced-motion: reduce) { .view { transition: none; } }

header { display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  background: var(--panel); border-bottom: 1px solid var(--border); flex-shrink: 0; }
.brand { font-weight: 600; }
input, select { background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px; padding: 6px 10px; font-size: 13px; }
/* без text-transform: у фьючерсов регистр значащий («SiU6», не «SIU6») —
   показываем ровно тот тикер, который вернула биржа */
input#ticker { width: 96px; }
.status { margin-left: auto; color: var(--text-2); font-size: 12px; font-variant-numeric: tabular-nums; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: #52525b;
  flex-shrink: 0; transition: background 0.2s; }
.live-dot.on { background: #22c55e; }

/* заполняет экран под шапкой; relative — якорь для absolute-детей
   (.chartctl, .chart-loading, .legend, .toast, .drawbar, .drawstyle) */
.layout { flex: 1; min-height: 0; position: relative; display: flex; }
/* overflow:hidden — канвас Lightweight Charts на кадр после ресайза бывает шире
   контейнера; без обрезки он вылезал за правый край окна (горизонтальный скролл) */
#chart { flex: 1; min-width: 0; overflow: hidden; }

/* центр графика, а не всего .layout (в нём ещё панель --panel-w справа) */
.chartctl { position: absolute; left: calc((100% - var(--panel-w)) / 2); transform: translateX(-50%);
  bottom: 38px; z-index: 5; display: flex; gap: 5px; }
.chartctl button { width: 30px; height: 30px; display: flex; align-items: center;
  justify-content: center; background: rgba(20, 20, 20, 0.82); color: var(--text-2);
  border: 1px solid var(--border); border-radius: 7px; cursor: pointer;
  line-height: 1; backdrop-filter: blur(2px); transition: background 0.12s, color 0.12s, border-color 0.12s; }
.chartctl button:hover { background: #262626; color: var(--text); border-color: #3f3f46; }
.chartctl button:active { background: #1a1a1a; }
.chartctl button svg { width: 16px; height: 16px; }

.drawbar { position: absolute; left: 14px; top: 14px; z-index: 5; display: flex;
  flex-direction: column; gap: 3px; padding: 4px; background: rgba(15, 15, 15, 0.72);
  border: 1px solid var(--border); border-radius: 9px; backdrop-filter: blur(3px); }
.drawbar button { width: 30px; height: 30px; display: flex; align-items: center;
  justify-content: center; background: transparent; color: var(--text-2); border: 0;
  border-radius: 6px; cursor: pointer; transition: all 0.12s; }
.drawbar button:hover { background: #262626; color: var(--text); }
.drawbar button.active { background: #3f3f46; color: #fafafa; }
.drawbar button:disabled { opacity: 0.32; cursor: default; }
.drawbar button:disabled:hover { background: transparent; color: var(--text-2); }
.drawbar button svg { width: 18px; height: 18px; }
.drawbar .div { height: 1px; background: var(--border); margin: 3px 4px; }

.drawstyle { position: absolute; left: 60px; top: 14px; z-index: 5; display: flex;
  align-items: center; gap: 8px; padding: 5px 8px; background: rgba(15, 15, 15, 0.82);
  border: 1px solid var(--border); border-radius: 9px; backdrop-filter: blur(3px); }
.drawstyle .row { display: flex; align-items: center; gap: 3px; }
.drawstyle .row + .row { padding-left: 8px; border-left: 1px solid var(--border); }
.drawstyle button { display: flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; padding: 0; background: transparent; color: var(--text-2);
  border: 1px solid transparent; border-radius: 5px; cursor: pointer; transition: all 0.12s; }
.drawstyle button:hover { background: #262626; color: var(--text); }
.drawstyle button.active { border-color: #6b7280; color: #fafafa; background: #262626; }
.drawstyle button svg { width: 18px; height: 18px; }
.drawstyle .sw { width: 18px; height: 18px; border-radius: 50%; border: 1px solid rgba(255,255,255,0.25); }
.drawstyle .sw:hover { transform: scale(1.12); }
.drawstyle .sw.active { border: 2px solid #fafafa; }

#panel { width: var(--panel-w); flex-shrink: 0; border-left: 1px solid var(--border);
  background: var(--panel); display: flex; flex-direction: column; }
.panel-head { display: flex; align-items: center; justify-content: space-between;
  /* в 340px всё в один ряд не помещается — «мин. скор» и «?» уходят на вторую
     строку, а не обрезаются за краем панели */
  flex-wrap: wrap; row-gap: 6px;
  gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.panel-title { font-weight: 600; }
.tabs { display: flex; gap: 14px; }
.tab { background: transparent; border: 0; padding: 2px 0 4px; cursor: pointer;
  font-size: 13px; font-weight: 600; color: var(--text-3);
  border-bottom: 2px solid transparent; transition: color 0.12s, border-color 0.12s; }
.tab:hover { color: var(--text-2); }
.tab.active { color: var(--text); border-bottom-color: #6b7280; }
.minscore { font-size: 11px; color: var(--text-2); display: flex; align-items: center;
  gap: 6px; white-space: nowrap; }
.minscore b { color: var(--text); font-variant-numeric: tabular-nums; }
.minscore input[type=range] { width: 76px; accent-color: #6b7280; cursor: pointer; }

#findings { overflow-y: auto; padding: 6px; }
.empty { color: var(--text-3); font-size: 12px; text-align: center; padding: 28px 12px; line-height: 1.6; }

.lvl { display: grid; grid-template-columns: 42px 1fr; gap: 9px; padding: 8px;
  border-radius: 8px; cursor: pointer; }
.lvl + .lvl { margin-top: 2px; }
.lvl:hover { background: var(--surface); }
.lvl.sel { background: #1b1b1b; outline: 1px solid var(--border); }
.pill { align-self: start; font-variant-numeric: tabular-nums; font-weight: 700;
  text-align: center; border-radius: 6px; padding: 5px 0; font-size: 14px; color: #0a0a0a; }
.lvl-body { min-width: 0; }
.lvl-row1 { display: flex; align-items: center; gap: 6px; }
.badge { font-size: 10px; font-weight: 700; letter-spacing: .03em; padding: 1px 5px;
  border-radius: 4px; text-transform: uppercase; flex-shrink: 0; }
.badge.support { background: rgba(34,197,94,.18); color: #4ade80; }
.badge.resist  { background: rgba(239,68,68,.18); color: #f87171; }
.badge.both    { background: rgba(245,158,11,.18); color: #fbbf24; }
.seg { display: flex; border: 1px solid var(--border); border-radius: 7px; overflow: hidden; }
.seg-btn { background: var(--surface); color: var(--text-2); border: 0;
  padding: 6px 12px; font-size: 13px; cursor: pointer; }
.seg-btn.active { background: #3f3f46; color: #fafafa; }

.tf-group { padding: 2px 0 6px; }
.tf-group-head { display: flex; align-items: baseline; gap: 8px;
  font-size: 11px; color: var(--text-3); padding: 8px 6px 5px;
  position: sticky; top: 0; background: var(--panel); }
.tf-group-head b { color: var(--text); font-size: 13px; }

.zone { font-variant-numeric: tabular-nums; color: var(--text); font-size: 13px; }
.statustag { font-size: 10px; color: var(--text-3); margin-left: auto; flex-shrink: 0; }
.statustag.broken { color: #f87171; }
.statustag.confirmed { color: #4ade80; }
.statustag.confirming { color: #a3e635; }
.figname { font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
.expl { color: var(--text-2); font-size: 11px; line-height: 1.45; margin-top: 3px;
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.conf { color: #fbbf24; }

/* --- автодополнение тикера --- */
.ticker-box { position: relative; }
.suggest { position: absolute; top: 100%; left: 0; z-index: 30; min-width: 220px;
  margin-top: 3px; background: var(--panel); border: 1px solid var(--border);
  border-radius: 7px; overflow: hidden; box-shadow: 0 6px 20px rgba(0,0,0,0.5); }
.suggest-row { display: flex; gap: 8px; align-items: baseline; padding: 6px 10px;
  cursor: pointer; font-size: 13px; }
.suggest-row.active, .suggest-row:hover { background: #1f1f1f; }
.suggest-row b { color: var(--text); min-width: 54px; }
.suggest-row span { color: var(--text-3); font-size: 12px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }

/* --- оверлей загрузки графика --- */
.chart-loading { position: absolute; top: 50%; left: calc((100% - var(--panel-w)) / 2);
  transform: translate(-50%, -50%); z-index: 6; display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; background: rgba(15,15,15,0.9); border: 1px solid var(--border);
  border-radius: 9px; color: var(--text-2); font-size: 13px; }
.spinner { width: 16px; height: 16px; border: 2px solid #3f3f46; border-top-color: #a3a3a3;
  border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* --- легенда, тост, тумблер Все ТФ, ошибки --- */
.icon-btn { width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--border);
  background: var(--surface); color: var(--text-2); cursor: pointer; font-size: 12px; }
.icon-btn:hover { color: var(--text); border-color: #3f3f46; }
.legend { position: absolute; top: 56px; right: 12px; z-index: 40; background: var(--panel);
  border: 1px solid var(--border); border-radius: 9px; padding: 10px 12px; display: flex;
  flex-direction: column; gap: 6px; font-size: 12px; color: var(--text-2);
  max-width: calc(100vw - 24px); }   /* не вылезать за край на узком окне */
.legend .dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; }
.pill-legend { display: inline-block; padding: 0 6px; border-radius: 4px; background: #52525b;
  color: #0a0a0a; font-weight: 700; margin-right: 6px; }
.toast { position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 50;
  background: #7f1d1d; color: #fecaca; border: 1px solid #b91c1c; border-radius: 8px;
  padding: 8px 14px; font-size: 13px; max-width: 70%; }
.status.err { color: #f87171; }
.alltf-toggle { display: flex; align-items: center; gap: 6px; padding: 8px 10px;
  font-size: 12px; color: var(--text-2); border-bottom: 1px solid var(--border); cursor: pointer; }
.alltf-toggle input { cursor: pointer; }

/* ===== Сдержанные кнопки с текстом и SVG-иконкой (шапки, «К рынку», «Обновить») ===== */
.text-btn { display: inline-flex; align-items: center; gap: 6px; background: var(--surface);
  color: var(--text-2); border: 1px solid var(--border); border-radius: 7px;
  padding: 6px 12px; font-size: 13px; font-family: inherit; cursor: pointer;
  text-decoration: none; white-space: nowrap;
  transition: background 0.12s, color 0.12s, border-color 0.12s; }
.text-btn:hover { background: #262626; color: var(--text); border-color: #3f3f46; }
.text-btn:disabled { opacity: 0.55; cursor: default; }
.text-btn:disabled:hover { background: var(--surface); color: var(--text-2); border-color: var(--border); }
.text-btn svg { width: 15px; height: 15px; flex-shrink: 0; }
.text-btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ===== Экран «Рынок»: шапка, плашка, фильтры, таблица ===== */
input#mktSearch { width: 230px; }
.mkt-updated { margin-left: auto; color: var(--text-2); font-size: 12px;
  font-variant-numeric: tabular-nums; }

/* плашка устаревания данных */
.mkt-stale { display: flex; align-items: center; gap: 12px; padding: 7px 14px;
  background: rgba(245, 158, 11, 0.12); color: #fbbf24; font-size: 13px;
  border-bottom: 1px solid rgba(245, 158, 11, 0.25); flex-shrink: 0; }
.mkt-stale button { background: transparent; border: 1px solid rgba(245, 158, 11, 0.45);
  color: #fbbf24; border-radius: 6px; padding: 3px 10px; font-size: 12px;
  font-family: inherit; cursor: pointer; }
.mkt-stale button:hover { background: rgba(245, 158, 11, 0.15); }
.mkt-stale button:disabled { opacity: 0.6; cursor: default; }
.mkt-stale button:focus-visible { outline: 2px solid #fbbf24; outline-offset: 2px; }

/* тулбар фильтров */
.mkt-toolbar { display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  border-bottom: 1px solid var(--border); flex-wrap: wrap; flex-shrink: 0; }
.mkt-min { font-size: 12px; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.mkt-min b { color: var(--text); font-variant-numeric: tabular-nums; min-width: 3ch; text-align: right; }
.mkt-min input[type=range] { width: 130px; accent-color: #6b7280; cursor: pointer; }
.mkt-count { color: var(--text-2); font-size: 12px; font-variant-numeric: tabular-nums; }
.mkt-spacer { flex: 1; }

/* прогресс полного прохода рынка */
.mkt-progress { display: flex; align-items: center; gap: 8px; min-width: 240px;
  font-size: 12px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.mkt-progress-track { flex: 1; height: 4px; border-radius: 2px; background: #262626; overflow: hidden; }
.mkt-progress-fill { height: 100%; width: 0; background: #6b7280; transition: width 0.4s; }

/* таблица находок */
.mkt-table-wrap { flex: 1; min-height: 0; overflow: auto; }
.mkt-table { width: 100%; max-width: 1280px; margin: 0 auto;
  border-collapse: separate; border-spacing: 0; font-variant-numeric: tabular-nums; }
.mkt-table:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.mkt-table th { position: sticky; top: 0; z-index: 2; background: var(--panel);
  text-align: left; font-size: 11px; font-weight: 600; letter-spacing: 0.04em;
  /* --text-2, не --text-3: 11px-текст на --panel обязан держать 4.5:1 (WCAG AA) */
  text-transform: uppercase; color: var(--text-2); padding: 9px 10px;
  box-shadow: 0 1px 0 var(--border); /* нижняя рамка, «липнущая» вместе с th */ }
.sort-btn { background: transparent; border: 0; padding: 0; color: inherit;
  font: inherit; letter-spacing: inherit; text-transform: inherit; cursor: pointer; }
.sort-btn:hover { color: var(--text); }
.sort-btn.active { color: var(--text); }
.sort-btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 3px; }
.mkt-table th[aria-sort="descending"] .sort-btn::after { content: " ↓"; }
.mkt-table th[aria-sort="ascending"] .sort-btn::after { content: " ↑"; }
.mkt-table td { padding: 5px 10px; height: 36px; font-size: 13px;
  border-bottom: 1px solid #161616; }
.mkt-table tbody tr { cursor: pointer;
  scroll-margin-top: 36px; /* стрелка вверх не прячет строку под sticky-шапкой */ }
.mkt-table tbody tr:hover { background: var(--surface); }
.mkt-table tbody tr.kbd { background: #1b1b1b; outline: 1px solid #6b7280; outline-offset: -1px; }
.mkt-table tbody tr.mkt-msg { cursor: default; }
.mkt-table tbody tr.mkt-msg:hover { background: transparent; }
.mkt-table .pill { display: inline-block; min-width: 42px; padding: 3px 0; font-size: 13px; }
.c-ticker { font-weight: 700; font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; }
.c-name { color: var(--text-2); max-width: 260px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
.c-tf { color: var(--text-2); }
.c-desc { color: var(--text-2); max-width: 480px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }

/* бейджи типа находки */
.kbadge { font-size: 10px; font-weight: 700; letter-spacing: 0.03em; padding: 2px 6px;
  border-radius: 4px; text-transform: uppercase; white-space: nowrap; }
.kbadge.level { background: rgba(34, 197, 94, 0.16); color: #4ade80; }
.kbadge.trendline { background: rgba(59, 130, 246, 0.16); color: #93c5fd; }
.kbadge.triangle { background: rgba(245, 158, 11, 0.16); color: #fbbf24; }

/* пустая выдача и ошибка сети (--text-2: 13px на --bg должны держать 4.5:1) */
.mkt-empty { color: var(--text-2); text-align: center; padding: 44px 12px;
  line-height: 1.7; font-size: 13px; }
.mkt-error { color: var(--text-2); text-align: center; padding: 44px 12px; font-size: 13px;
  display: flex; flex-direction: column; align-items: center; gap: 12px; }

/* skeleton первой загрузки */
.skel-bar { height: 12px; border-radius: 4px;
  background: linear-gradient(90deg, #1a1a1a 25%, #262626 40%, #1a1a1a 60%);
  background-size: 300% 100%; animation: mkt-shimmer 1.3s linear infinite; }
.skel-bar.w-pill { width: 42px; height: 22px; border-radius: 6px; }
.skel-bar.w-s { width: 52px; }
.skel-bar.w-m { width: 150px; }
.skel-bar.w-l { width: 320px; max-width: 100%; }
@keyframes mkt-shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }
@media (prefers-reduced-motion: reduce) {
  .skel-bar { animation: none; background: #1a1a1a; }
}

/* ===== Узкое окно: держим терминал собранным, без горизонтального скролла ===== */
@media (max-width: 720px) {
  /* график: панель уже, шапка компактнее (бренд прячем — место дороже).
     --panel-w правим на :root — от него зависят оверлеи графика в calc(). */
  :root { --panel-w: 288px; }
  #chartView .brand { display: none; }
  header { gap: 8px; padding: 9px 10px; }
  .tabs { gap: 10px; }
  /* рынок: колонки сдвинулись на +2 (★ и «Сигнал» в начале).
     Прячем «дорогие» по ширине Название(5) и Описание(8), таблица влезает целиком. */
  .mkt-table th:nth-child(5), .mkt-table td:nth-child(5),   /* Название */
  .mkt-table th:nth-child(8), .mkt-table td:nth-child(8) {  /* Описание */
    display: none;
  }
  input#mktSearch { width: 150px; }
  .mkt-toolbar { gap: 8px; padding: 9px 10px; }
}
@media (max-width: 520px) {
  /* совсем узко: панель ещё уже, легенда прижата слева, не перекрывает край */
  :root { --panel-w: 240px; }
  .legend { right: 8px; left: 8px; }
  /* дополнительно прячем ТФ(6) и Тип(7) — остаются ★, Сила, Сигнал, Тикер */
  .mkt-table th:nth-child(6), .mkt-table td:nth-child(6),   /* ТФ */
  .mkt-table th:nth-child(7), .mkt-table td:nth-child(7) {  /* Тип */
    display: none;
  }
}

/* ===== UX-пакет: чипы-фильтры, звёзды-избранное, колонка «Сигнал», чипы ТФ ===== */

/* --- чипы фильтров рынка (Тип · ТФ · Избранное) --- */
.chip-row { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 5px; background: var(--surface);
  color: var(--text-2); border: 1px solid var(--border); border-radius: 999px;
  padding: 5px 12px; font-size: 12.5px; font-family: inherit; cursor: pointer; white-space: nowrap;
  transition: background 0.12s, color 0.12s, border-color 0.12s; }
.chip:hover { background: #262626; color: var(--text); border-color: #3f3f46; }
.chip.active { background: #3f3f46; color: #fafafa; border-color: #52525b; }
.chip:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.chip-count { font-size: 11px; font-variant-numeric: tabular-nums; color: var(--text-3);
  background: rgba(255, 255, 255, 0.06); border-radius: 999px; padding: 0 6px;
  min-width: 18px; text-align: center; }
.chip.active .chip-count { color: #e5e5e5; background: rgba(0, 0, 0, 0.28); }
.chip-fav { border-color: rgba(245, 179, 1, 0.35); }
.chip-fav.active { background: rgba(245, 179, 1, 0.16); color: #f5b301; border-color: rgba(245, 179, 1, 0.5); }
.chip-fav.active .chip-count { color: #f5b301; background: rgba(0, 0, 0, 0.28); }

/* --- звезда «в избранное» (шапка графика и мини-кнопка в строке рынка) --- */
.star-btn { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  width: 30px; height: 30px; padding: 0; background: transparent; border: 1px solid transparent;
  border-radius: 7px; color: var(--text-3); cursor: pointer;
  transition: color 0.12s, background 0.12s; }
.star-btn:hover { background: #1f1f1f; color: var(--text-2); }
.star-btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.7; }
.star-btn.on { color: #f5b301; }
.star-btn.on svg { fill: currentColor; stroke: currentColor; }
.star-btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.star-btn.mini { width: 24px; height: 24px; }
.star-btn.mini svg { width: 15px; height: 15px; }

/* --- колонка «Сигнал» и мини-колонка звезды в таблице рынка --- */
.th-star { width: 1%; }
.c-star { width: 1%; padding-left: 8px; padding-right: 2px; }
.c-sig { width: 1%; white-space: nowrap; }
.sig { width: 12px; height: 12px; display: inline-block; vertical-align: middle; }
.sig.bull { fill: #22c55e; }
.sig.bear { fill: #ef4444; }
.sig.neutral { fill: #f59e0b; }
.skel-bar.w-xs { width: 16px; }

/* строки таблицы — чуть чётче разделены */
.mkt-table td { border-bottom-color: #1c1c1c; }

/* --- скрытый select#tf: значение читает код графика, UI даёт ряд чипов --- */
.tf-select-hidden { display: none; }
.tf-chip-row { display: flex; align-items: center; gap: 4px; flex: 0 1 auto; min-width: 0;
  overflow-x: auto; scrollbar-width: thin; }
.tf-chip { flex: 0 0 auto; background: var(--surface); color: var(--text-2);
  border: 1px solid var(--border); border-radius: 6px; padding: 5px 9px; font-size: 12px;
  font-family: inherit; cursor: pointer; transition: background 0.12s, color 0.12s, border-color 0.12s; }
.tf-chip:hover { background: #262626; color: var(--text); border-color: #3f3f46; }
.tf-chip.active { background: #3f3f46; color: #fafafa; border-color: #52525b; }
.tf-chip:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ===================================================================
   Доступность и строгость: фокус, новые элементы, тост, reduced-motion
   =================================================================== */

/* --- Единое кольцо фокуса на всех интерактивных элементах ---
   Показываем только при :focus-visible (клавиатура), чтобы клик мышью
   не оставлял рамку. outline:none нигде не используется без замены. */
.tab:focus-visible,
.seg-btn:focus-visible,
.icon-btn:focus-visible,
.chartctl button:focus-visible,
.drawbar button:focus-visible,
.drawstyle button:focus-visible,
.drawstyle .sw:focus-visible,
.mkt-toolbar button:focus-visible,
.toast-close:focus-visible,
.panel-count .text-btn:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--focus); outline-offset: 2px;
}
/* Ползунки: кольцо вплотную, иначе задевает соседний текст шапки */
input[type=range]:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; border-radius: 6px; }
/* Строки-списки: кольцо внутрь, чтобы не выходило за край панели/таблицы */
.lvl:focus-visible,
.suggest-row:focus-visible,
.mkt-table tbody tr:focus-visible {
  outline: 2px solid var(--focus); outline-offset: -2px; border-radius: 6px;
}
/* Строки таблицы — outline на <tr> в некоторых движках рисуется по ячейкам,
   поэтому дублируем подсветкой фона: строка в фокусе всегда заметна */
.mkt-table tbody tr:focus-visible td { background: #1b1b1b; }
.mkt-table tbody tr:focus { outline: none; }   /* видимое кольцо даёт :focus-visible выше */
.alltf-toggle:focus-within { outline: 2px solid var(--focus); outline-offset: -2px; }

/* --- Легенда OHLC поверх графика ---
   Смещена вправо и вниз от .drawbar (левый верхний угол) и от .drawstyle
   (её плашка занимает left:60px/top:14px), поэтому top:56px. */
.chart-legend { position: absolute; top: 56px; left: 60px; z-index: 4;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  max-width: calc(100% - var(--panel-w) - 72px);
  padding: 5px 10px; border: 1px solid var(--border); border-radius: 8px;
  background: rgba(15, 15, 15, 0.72); backdrop-filter: blur(4px);
  font-size: 12px; color: var(--text-2); line-height: 1.3;
  pointer-events: none;   /* плашка не перехватывает курсор у графика */
  user-select: none; }
.chart-legend .cl-item { display: inline-flex; align-items: baseline; gap: 4px; white-space: nowrap; }
.chart-legend .cl-k { color: var(--text-3); font-size: 11px; text-transform: uppercase; letter-spacing: .03em; }
.chart-legend .cl-v { color: var(--text); font-weight: 600;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-variant-numeric: tabular-nums; }
.chart-legend .cl-title { color: var(--text); font-weight: 600; }
.chart-legend .cl-v.up { color: #4ade80; }     /* 11.36:1 на --bg */
.chart-legend .cl-v.down { color: #f87171; }   /* 7.16:1 на --bg */
.chart-legend .cl-sep { width: 1px; align-self: stretch; background: var(--border); }
@media (max-width: 900px) {
  /* места меньше — прячем второстепенные поля (объём, изменение) и жмём отступы */
  .chart-legend { gap: 7px; padding: 4px 8px; font-size: 11px; }
  .chart-legend .cl-extra { display: none; }
}
@media (max-width: 720px) {
  /* совсем узко: только заголовок и цена закрытия */
  .chart-legend { top: 52px; left: 56px; gap: 6px; }
  .chart-legend .cl-item:not(.cl-keep) { display: none; }
  .chart-legend .cl-sep { display: none; }
}

/* --- Дистанция до уровня в строке находки --- */
.lvl-dist { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-variant-numeric: tabular-nums; font-size: 11px; color: var(--text-3);
  white-space: nowrap; flex-shrink: 0; }
.lvl-dist.up { color: #f87171; }     /* цена ниже — уровень работает как сопротивление */
.lvl-dist.down { color: #4ade80; }   /* цена выше — уровень работает как поддержка */
.mkt-table .lvl-dist { font-size: 12px; }

/* --- Счётчик «12 из 37» в шапке панели + кнопка «показать все» --- */
.panel-count { display: inline-flex; align-items: center; gap: 8px;
  font-size: 11px; color: var(--text-3); font-variant-numeric: tabular-nums;
  white-space: nowrap; }
.panel-count b { color: var(--text-2); font-weight: 600; }
.panel-count .text-btn { padding: 3px 8px; font-size: 11px; border-radius: 6px; }

/* --- Активная серверная сортировка колонки --- */
.sort-active { color: var(--text); }
.mkt-table th.sort-active { color: var(--text); background: #151515; }
.mkt-table th.sort-active .sort-btn { color: var(--text); }
.sort-btn.sort-active { color: var(--text); }
/* тонкая линия под активной колонкой — видно даже без стрелки направления */
.mkt-table th.sort-active { box-shadow: inset 0 -2px 0 #6b7280, 0 1px 0 var(--border); }

/* --- Тост: вариант «инфо», кнопка закрытия, пауза таймера при наведении --- */
.toast { display: flex; align-items: center; gap: 10px; }
.toast.info { background: #1f2937; color: #e5e7eb; border-color: #3f4a5a; }
/* при наведении js паузит автоскрытие — визуально подтверждаем «залипание» */
.toast:hover, .toast:focus-within { box-shadow: 0 6px 20px rgba(0, 0, 0, 0.55); }
.toast-close { display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0; width: 20px; height: 20px; margin: -2px -6px -2px 0; padding: 0;
  background: transparent; border: 0; border-radius: 5px; color: inherit;
  font: inherit; font-size: 15px; line-height: 1; opacity: 0.7; cursor: pointer;
  transition: opacity 0.12s, background 0.12s; }
.toast-close:hover { opacity: 1; background: rgba(255, 255, 255, 0.12); }
.toast-close svg { width: 13px; height: 13px; }

/* --- prefers-reduced-motion: гасим все переходы и анимации ---
   Спиннер и shimmer оставляем статичными, кроссфейд экранов — мгновенным. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .spinner { animation: none; border-top-color: #a3a3a3; }
  .skel-bar { animation: none; background: #1a1a1a; }
  .drawstyle .sw:hover { transform: none; }
}
