/* Атрибут hidden всегда прячет элемент. Без этого правила любой класс
   с display: flex или grid перебивает hidden и оставляет пустую плашку. */
[hidden] {
    display: none !important;
}

/* ===== Design Tokens ===== */
:root {
    --bg: #0d1117;
    --surface: #161b22;
    --surface-2: #1c2128;
    --surface-3: #21262d;
    --border: #30363d;
    --text: #e6edf3;
    --text-muted: #8b949e;
    --text-faint: #6e7681;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --green: #26a69a;
    --red: #ef5350;
    --orange: rgba(255, 165, 0, 0.15);
    --zone-line: rgba(226, 232, 240, 0.82);
    --radius-sm: 6px;
    --radius-md: 8px;
    --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-mono: ui-monospace, 'SF Mono', 'Roboto Mono', Consolas, monospace;
    --transition: 180ms cubic-bezier(0.16, 1, 0.3, 1);
}

[data-theme="light"] {
    --bg: #f6f8fa;
    --surface: #ffffff;
    --surface-2: #f0f2f5;
    --surface-3: #e8eaed;
    --border: #d0d7de;
    --text: #1f2328;
    --text-muted: #59636e;
    --text-faint: #818b98;
    --zone-line: rgba(51, 65, 85, 0.95);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: var(--font-body);
    font-size: 14px;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

/* ===== Layout ===== */
.app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
}

/* Кнопка меню — только на узких экранах */
.menu-toggle {
    display: none;
    background: rgba(255,255,255,0.12);
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-sm);
    align-items: center;
    justify-content: center;
}

.sidebar-backdrop {
    display: none;
}

.header {
    background: linear-gradient(135deg, #1e293b 0%, #312e81 100%);
    color: #fff;
    padding: 8px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    height: 52px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* 150 (20.10.2026, документ — раздел 15): название сервиса в шапке — не H1,
   на странице один H1 — заголовок раздела или ситуации */
.header .hdr-title {
    font-size: 16px;
    font-weight: 600;
    line-height: 1.2;
    margin: 0;
}

.header p {
    font-size: 11px;
    opacity: 0.7;
    line-height: 1.2;
}

.logo {
    flex-shrink: 0;
}

/* Знак CrossEdge8 — картинка, а не svg: скругление задаём здесь, чтобы
   квадрат не выглядел обрезанным на фоне шапки. */
.logo-ce8 { border-radius: 7px; display: block; }
/* Знак 8levels вытянут по высоте (40×52), поэтому ширину не задаём жёстко:
   правила телефона и Telegram ставят .logo квадрат 20×20 — для этого знака
   он сплющил бы восьмёрку. */
.logo.logo-8l { display: block; width: auto; height: 28px; }

/* Название модуля рядом с брендом: «CrossEdge8 Levels». Тоньше и бирюзовое —
   читается как часть платформы, а не как второе название сервиса. */
.header-name .h1-mod { font-weight: 500; color: #2dd4bf; }
[data-theme="light"] .header-name .h1-mod { color: #0e9f86; }

.theme-toggle {
    background: rgba(255,255,255,0.1);
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition);
}

.theme-toggle:hover {
    background: rgba(255,255,255,0.2);
}

/* Ссылка на страницу справки — выглядит так же, как кнопка темы */
.help-link {
    text-decoration: none;
}

.main {
    display: flex;
    flex: 1;
    min-height: 0;
}

/* ===== Sidebar ===== */
.sidebar {
    /* Шире, чтобы тексты оповещений и названия инструментов не ломались по слогам */
    width: 320px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 14px;
    overflow-y: auto;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.sidebar::-webkit-scrollbar {
    width: 4px;
}

.sidebar::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* ===== Разделы левого меню ===== */
/* Настройки собраны в четыре сворачиваемых раздела: одним столбиком до нижних
   пунктов приходилось долго прокручивать. Шапка — обычная кнопка, чтобы
   работали клавиатура и озвучка. */
.side-sec {
    /* Панель — колонка flex, и без запрета на сжатие разделы ужимаются по
       высоте: содержимое обрезается краем скруглённой рамки. */
    flex: 0 0 auto;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-elevated, var(--bg-secondary));
}
.side-sec-head {
    flex: 0 0 auto;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 9px 11px;
    background: none;
    border: 0;
    cursor: pointer;
    color: var(--text-primary);
    font: inherit;
    text-align: left;
}
.side-sec-head:hover { background: var(--bg-hover, rgba(127, 127, 127, 0.08)); }
.side-sec-head:focus-visible { outline: 2px solid var(--accent, #22c55e); outline-offset: -2px; }
.side-sec-name { font-size: 12px; font-weight: 600; letter-spacing: 0.01em; }
.side-sec-caret {
    font-size: 11px;
    color: var(--text-secondary);
    transition: transform 0.15s ease;
}
.side-sec.open .side-sec-caret { transform: rotate(180deg); }
.side-sec-body {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 2px 11px 12px;
}

.control-group label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
}

select {
    width: 100%;
    padding: 7px 10px;
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: var(--font-body);
    cursor: pointer;
    outline: none;
    transition: border-color var(--transition);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%238b949e' stroke-width='2'%3E%3Cpath d='M2 4l4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 28px;
}

select:hover, select:focus {
    border-color: var(--primary);
}

.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 400 !important;
    color: var(--text) !important;
    cursor: pointer;
    user-select: none;
}

.checkbox-label input[type="checkbox"] {
    margin: 0;
    width: 14px;
    height: 14px;
    accent-color: var(--primary);
    cursor: pointer;
}

.dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* ===== Buttons ===== */
.btn {
    width: 100%;
    padding: 9px 12px;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    font-family: var(--font-body);
    transition: all var(--transition);
}

.btn-primary {
    background: linear-gradient(135deg, #3b82f6 0%, #6366f1 100%);
    color: #fff;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.btn-secondary {
    background: var(--surface-2);
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--surface-3);
    color: var(--text);
}

/* ===== Status ===== */
.status {
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    font-size: 11px;
    line-height: 1.4;
    display: none;
}

.status.show {
    display: block;
}

.status.success {
    background: rgba(38, 166, 154, 0.1);
    color: #26a69a;
    border: 1px solid rgba(38, 166, 154, 0.2);
}

.status.error {
    background: rgba(239, 83, 80, 0.1);
    color: #ef5350;
    border: 1px solid rgba(239, 83, 80, 0.2);
}

.status.loading {
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
    border: 1px solid rgba(59, 130, 246, 0.2);
}

/* ===== Info Box ===== */
.info-box {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px;
    margin-top: 8px;
}

.zone-swatch {
    flex-shrink: 0;
    width: 14px;
    height: 4px;
    border-radius: 2px;
    background: var(--zone-line);
}

.info-box p {
    font-size: 11px;
    color: var(--text-muted);
    margin: 3px 0;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ===== Chart Area ===== */
.chart-area {
    flex: 1;
    min-width: 0;
    position: relative;
    background: var(--bg);
    display: flex;
    flex-direction: column;
}

/* Полоса над графиками с переключателем 1 / 2 / 4 */
.chart-topbar {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    /* Значки переносим на вторую строку, а не выпускаем за край полосы.
       Без переноса при открытых панелях справа («Карта рынка сейчас»,
       «Карта зон 8levels») область графика сужается, и последние значки —
       в том числе «Карта зон 8levels» и карандаш — уезжали за границу
       полосы: они оставались в разметке видимыми, но нажать их было
       нельзя, и это читалось как «кнопка не работает». Перенос включается
       сам и только когда места действительно не хватает. */
    flex-wrap: wrap;
    row-gap: 6px;
    gap: 10px;
    padding: 4px 8px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}

.multi-switch {
    display: inline-flex;
    gap: 2px;
    padding: 2px;
    border-radius: 6px;
    background: var(--surface-alt, rgba(127, 127, 127, 0.10));
}

.multi-btn {
    min-width: 26px;
    height: 22px;
    padding: 0 6px;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: background 120ms ease, color 120ms ease;
}

.multi-btn:hover:not(:disabled) {
    background: var(--surface);
    color: var(--text);
}

.multi-btn.active {
    background: var(--primary);
    color: #fff;
}

.multi-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Кнопка «свернуть настройки»: колонка слева уходит, графику достаётся её ширина */
.topbar-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 22px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 120ms ease, border-color 120ms ease;
}

.topbar-icon svg {
    width: 15px;
    height: 15px;
}

/* Кнопку прячет код: без разрешённой биржевой цены панелей с расстояниями
   нет, а карта уровней есть только у платных тарифов. Правило с !important
   нужно потому, что display у .topbar-icon задан жёстко, и одного атрибута
   hidden не хватает — в узкой полосе тоже. */
.topbar-icon[hidden] { display: none !important; }

/* Свёрнутая панель рисования: видна только первая кнопка, остальное раскрывается
   при наведении мыши. Так панель не закрывает свечи в тесной сетке четырёх графиков. */
body.draw-folded .draw-panel {
    opacity: 0.85;
    max-width: none;
    overflow: visible;
}

body.draw-folded .draw-panel > *:not(:first-child) {
    display: none;
}

body.draw-folded .draw-panel:hover {
    opacity: 1;
}

body.draw-folded .draw-panel:hover > * {
    display: flex;
}

/* Кнопка «во весь экран» прижата к правому краю полосы */
.topbar-icon-right {
    margin-left: auto;
}

/* Режим «во весь экран»: шапка и подвал уходят, вся высота — свечам */
body.chart-full .header,
body.chart-full .site-legal {
    display: none;
}

/* Полный экран браузера (F11): подвал с реквизитами тоже убираем — он там лишний,
   а высота нужна свечам. Шапку не трогаем: без неё не выйти в кабинет и к справке. */
body.browser-full .site-legal {
    display: none;
}

@media all and (display-mode: fullscreen) {
    .site-legal { display: none; }
}

.topbar-icon:hover {
    color: var(--text);
    border-color: var(--primary);
}

.main.no-sidebar > .sidebar {
    display: none;
}

/* Со свёрнутыми настройками бумагу видно и меняют прямо в верхней полосе */
.topbar-instrument-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-family: var(--font-body);
    white-space: nowrap;
}

.topbar-instrument-btn[hidden] {
    display: none;
}

.topbar-instrument {
    max-width: 240px;
    height: 22px;
    padding: 0 6px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
}

/* Таймфрейм в полосе над графиком: тот же вид, что у выбора бумаги рядом,
   и такой же, как у селекта таймфрейма в шапке мини-панелей раскладок 2 и 4 */
.topbar-timeframe {
    /* Ширина по содержимому: растянутый на всю полосу селект оставлял пустое
       поле справа от «1 час» и выглядел как поле ввода, а не как выбор */
    width: auto;
    max-width: 108px;
    height: 22px;
    padding: 0 6px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
}

.main.no-sidebar #sidebar-collapse svg {
    transform: scaleX(-1);
}

/* Скрепка: четыре графика одной бумаги с разными таймфреймами */
.multi-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    height: 22px;
    padding: 0 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: transparent;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}

.multi-link svg {
    width: 14px;
    height: 14px;
}

.multi-link:hover:not(:disabled) {
    color: var(--text);
    border-color: var(--primary);
}

.multi-link.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.multi-link:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.multi-note {
    font-size: 11px;
    color: var(--text-muted);
}

/* Сетка графиков: одна, две рядом или четыре квадратом */
/* ===== Строка «график + ключевые уровни» =====
   В режиме официального виджета TradingView линии уровней внутрь чужого окна
   не попадают, поэтому уровни 8levels стоят рядом отдельным блоком: на
   большом экране — колонкой справа, на телефоне и в Telegram — под графиком
   (переворот делает медиа-правило ниже). Блок появляется только когда график
   рисует виджет: в своём окне уровни и так линиями на свечах. */
.chart-row {
    flex: 1;
    min-height: 0;
    display: flex;
    /* Точка отсчёта для незакреплённой боковой панели уровней: без булавки она
       лежит поверх графика и цепляется за правый край именно этой строки. */
    position: relative;
    align-items: stretch;
    gap: 1px;
    background: var(--border);
    /* Страховка от вылезания: строка графика сжимается вместе с областью, а
       блок ключевых уровней своей высоты не отдаёт. Без обрезки его содержимое
       рисовалось поверх складок под графиком. */
    overflow: hidden;
}
.key-levels {
    flex: 0 0 320px;
    min-width: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-left: 1px solid var(--border);
    background: var(--surface);
}
.key-levels[hidden] { display: none; }
/* Справа помещается одна панель. Когда открыта «Карта рынка сейчас», блок
   ключевых уровней уходит: две панели рядом оставляли графику меньше
   половины экрана. Уровни при этом не теряются — они в складках под
   графиком, а блок вернётся, как только карту рынка закроют. */
.chart-area.mn-open .key-levels { display: none; }
.kl-head {
    flex: 0 0 auto;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
}
.kl-title { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.kl-title b { font-size: 0.9rem; }
.kl-sub { font-size: 0.78rem; color: var(--text-muted); }
.kl-warn {
    flex: 0 0 auto;
    margin: 8px 12px 0;
    padding: 6px 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.74rem;
    color: var(--text-muted);
    background: var(--surface-2);
}
.kl-warn[hidden] { display: none; }
/* Пояснение про собственную кнопку «без значений». Рамку ему не даём:
   это не предупреждение о проблеме, а напоминание о своём же выборе. */
.kl-note {
    flex: 0 0 auto;
    margin: 6px 12px 0;
    font-size: 0.72rem;
    line-height: 1.35;
    color: var(--text-muted);
}
.kl-note[hidden] { display: none; }
.kl-body { flex: 1; min-height: 0; overflow-y: auto; padding: 8px 12px 4px; }
.kl-foot {
    flex: 0 0 auto;
    padding: 6px 12px 10px;
    font-size: 0.72rem;
    line-height: 1.45;
    color: var(--text-muted);
}

/* Карточка уровня: цифра зоны крупная, признаки — строками «название/значение».
   Тип различается цветной полосой слева, как линия того же уровня на графике. */
.kl-card {
    margin-bottom: 8px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-left-width: 3px;
    border-radius: 10px;
    background: var(--surface-2);
}
.kl-card.sup { border-left-color: var(--green); }
.kl-card.res { border-left-color: var(--red); }
.kl-chead {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
    font-size: 0.76rem;
    color: var(--text-muted);
}
.kl-ctf { font-size: 0.72rem; }
.kl-cprice {
    margin: 2px 0 4px;
    font-size: 1.02rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}
.kl-crow {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    font-size: 0.76rem;
    line-height: 1.5;
}
.kl-crow > span:first-child { color: var(--text-muted); }
.kl-note {
    margin-top: 4px;
    font-size: 0.74rem;
    line-height: 1.45;
    color: var(--text-muted);
}
.kl-empty { padding: 10px 0; font-size: 0.8rem; color: var(--text-muted); }

/* ===== Складки под графиком ===== */
.chart-folds {
    flex: 0 0 auto;
    border-top: 1px solid var(--border);
    background: var(--surface);
    max-height: 46vh;
    overflow-y: auto;
}
.chart-folds[hidden] { display: none; }
.chart-fold { border-bottom: 1px solid var(--border); }
.chart-fold > summary {
    padding: 8px 12px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
}
.chart-fold > summary::marker { color: var(--text-muted); }
.chart-fold-body { padding: 0 12px 10px; }

/* Панель, переехавшая в складку, перестаёт быть плавающей: ни своего угла,
   ни тени, ни кнопок стыковки — местом теперь распоряжается складка */
.levels-panel.dock-fold {
    position: static;
    width: auto;
    max-width: none;
    height: auto;
    max-height: 42vh;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    background: transparent;
}
.levels-panel.dock-fold .lp-head { display: none; }
/* Маркера текущей цены и карточек ключевых уровней в складке нет: и цену, и
   ключевые уровни показывает главный блок рядом с графиком, а второй такой
   же набор рядом читался бы как расхождение данных */
.levels-panel.dock-fold .lp-key { display: none; }
.levels-panel.dock-fold .lp-all > summary { display: none; }
.levels-panel.dock-fold .lp-list { max-height: 34vh; overflow-y: auto; }

/* ===== Боковая полоса значков и панель уровней (режим виджета, большой экран) =====
   Складки под графиком отнимали у свечей высоту, а высота графику дороже
   ширины: на ноутбуке раскрытая карта уровней съедала почти половину окна.
   Поэтому справа стоит узкая полоса из трёх значков, а панель открывается
   по нажатию. Булавка решает, сдвигать график (панель колонкой) или лечь
   поверх свечей (панель плавающая) — второе не отнимает у графика ничего. */
.dock-rail {
    /* 52 px: в более узкую полосу подпись «Ключевые» не влезала и выходила
       за края кнопки на полпикселя — читалось как обрезанный текст. */
    flex: 0 0 52px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 6px 0;
    background: var(--surface);
    border-left: 1px solid var(--border);
    z-index: 41;
}
.dock-rail[hidden] { display: none; }
.dock-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    width: 50px;
    padding: 6px 0;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
}
.dock-tab svg { width: 18px; height: 18px; }
.dock-tab:hover { background: var(--surface-2, rgba(127, 127, 127, .12)); color: var(--text); }
/* Подпись под значком короткая в одно слово: без неё человек угадывает
   назначение по рисунку, а всплывающую подсказку на планшете не видно. */
.dock-tab-name {
    font-size: 9px;
    line-height: 1.1;
    letter-spacing: .2px;
    white-space: nowrap;
}
.dock-tab.active {
    background: var(--accent-soft, rgba(56, 132, 255, .16));
    color: var(--accent, #3884ff);
}
.dock-pane {
    flex: 0 0 340px;
    min-width: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--surface);
    border-left: 1px solid var(--border);
}
.dock-pane[hidden] { display: none; }
/* Панель без булавки лежит поверх графика у самой полосы значков: график
   остаётся во всю ширину, а числа уровней всё равно перед глазами. */
.dock-pane.dock-float {
    position: absolute;
    top: 0;
    bottom: 0;
    right: 52px;
    width: 360px;
    z-index: 40;
    box-shadow: -10px 0 24px rgba(0, 0, 0, .28);
}
.dock-head {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 7px 8px 7px 12px;
    border-bottom: 1px solid var(--border);
}
.dock-title { font-size: 13px; }
/* Пометка «значения скрыты вами»: лежит между шапкой и телом панели, чтобы
   попадалась на глаза до самих точек, но не спорила с заголовком по весу. */
.dock-note {
    margin: 0;
    padding: 6px 10px;
    font-size: 0.72rem;
    line-height: 1.35;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}
.dock-head-btns { display: flex; align-items: center; gap: 2px; }
.dock-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--text-muted);
    font-size: 13px;
    cursor: pointer;
}
.dock-btn svg { width: 15px; height: 15px; }
.dock-btn:hover { background: var(--surface-2, rgba(127, 127, 127, .12)); color: var(--text); }
/* Булавка нажата — панель закреплена колонкой. Отличать состояния нужно
   на глаз: иначе непонятно, почему панель то сдвигает график, то нет. */
.dock-btn[aria-pressed="true"] { color: var(--accent, #3884ff); }
.dock-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}
/* Блоки внутри панели: своя рамка, фон и заголовок им уже не нужны —
   местом и подписью распоряжается сама панель. */
.key-levels.kl-in-dock,
.levels-panel.dock-side {
    position: static;
    flex: 1 1 auto;
    width: auto;
    max-width: none;
    height: auto;
    max-height: none;
    min-height: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    background: transparent;
}
.key-levels.kl-in-dock .kl-head { display: none; }
.levels-panel.dock-side .lp-head { display: none; }
.levels-panel.dock-side .lp-all > summary { display: none; }
.levels-panel.dock-side .lp-list { max-height: none; }
/* Карта рынка сейчас открывается тем же правым краем. Двум панелям рядом
   графику остаётся меньше половины окна, поэтому закреплённая панель
   уровней на это время уходит — значки остаются, вернуть её одно нажатие. */
.chart-area.mn-open .dock-pane { display: none; }
@media (max-width: 1100px) {
    /* Узкий экран: полоса значков не нужна, там уровни живут складками
       под графиком — колонка рядом не влезает в принципе. */
    .dock-rail, .dock-pane { display: none; }
}

@media (max-width: 1100px) {
    /* Места на колонку рядом с графиком нет: блок уровней уходит под график.
       Своя прокрутка у блока остаётся, а высоту делим с графиком. */
    .chart-row { flex-direction: column; }
    .key-levels {
        flex: 0 0 auto;
        max-height: 44vh;
        border-left: 0;
        border-top: 1px solid var(--border);
    }
    .chart-folds { max-height: 46vh; }
    /* Блок ключевых уровней переехал в складку: своей рамки, фона и
       потолка высоты ему больше не нужно — местом распоряжается складка,
       а собственный заголовок дублировал бы её подпись. */
    .key-levels.kl-in-fold {
        flex: none;
        max-height: none;
        border: 0;
        background: transparent;
        overflow: visible;
    }
    .key-levels.kl-in-fold .kl-head { display: none; }
    .key-levels.kl-in-fold .kl-warn { margin-left: 0; margin-right: 0; }
    .key-levels.kl-in-fold .kl-body { padding-left: 0; padding-right: 0; }
    .key-levels.kl-in-fold .kl-foot { padding-left: 0; padding-right: 0; }
    /* Правило «рядом с графиком помещается одна панель» к складке не
       относится: она под графиком и ничего не занимает у свечей. */
    .chart-area.mn-open .key-levels.kl-in-fold { display: flex; }
    /* В складке панель уровней живёт в потоке: потолок задаёт сама складка,
       а список внутри прокручивается. Своей высоты панель здесь не считает. */
    .levels-panel.dock-fold { max-height: none; }
    .levels-panel.dock-fold .lp-list { max-height: 30vh; }
}

.chart-grid {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
    gap: 1px;
    background: var(--border);
}

.chart-grid[data-layout="2"] {
    grid-template-columns: 1fr 1fr;
}

.chart-grid[data-layout="4"] {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
}

#chart {
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    position: relative;
    background: var(--bg);
}

/* Подписи «где смотреть уровни» в углу графика больше нет: её закрывала
   панель «Уровни рядом», и найти подпись было нельзя. Про виджет говорит
   значок «График: TradingView» в верхней полосе (см. «Свежесть данных»). */

/* ===== Официальный виджет TradingView ===== */
/* Блок из двух частей: само окно и подпись со ссылкой под ним. Подпись
   обязательна и стоит непосредственно под графиком — в браузере, на телефоне
   и в Телеграме одинаково, потому что это часть того же блока. Высоту задаём
   явно: виджет с autosize внутри блока нулевой высоты остаётся белым. */
.tv-embed {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    /* В ячейках раскладок высоту задаёт сама сетка, и свой минимум здесь
       ломал бы четырёхоконную раскладку: блок вылезал бы за ячейку. */
    min-height: 0;
    position: relative;
}

/* Главное окно одно на всю ширину — ему нужен явный минимум: виджет с
   autosize в блоке почти нулевой высоты остаётся белым прямоугольником. */
.chart-grid[data-layout="1"] #chart > .tv-embed {
    min-height: 360px;
}

/* Гнездо для окна: скрипт TradingView распоряжается его содержимым сам, и
   ничего своего внутрь класть нельзя — он это вычистит. */
.tv-embed-host {
    flex: 1 1 auto;
    min-height: 0;
    position: relative;
}

.tv-embed-host .tradingview-widget-container,
.tv-embed-host .tradingview-widget-container__widget {
    width: 100%;
    height: 100%;
}

.tv-embed-host iframe {
    display: block;
    width: 100%;
    height: 100%;
    border: 0;
}

/* Подпись с логотипом. Убирать её нельзя ни в какой раскладке: это условие
   использования виджета, а не украшение. Поэтому у неё фиксированная высота
   и она никогда не прячется — сжимается сам график. */
.tv-copyright {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    padding: 4px 8px;
    background: var(--bg);
    font-size: 11px;
    line-height: 1.2;
}

.tv-copyright a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-secondary, var(--text-muted));
    text-decoration: none;
}

.tv-copyright a:hover { text-decoration: underline; }

.tv-logo {
    display: block;
    height: 14px;
    width: auto;
}

/* В тесных ячейках раскладки на четыре графика словам места нет, а логотип и
   ссылка остаются: сокращать можно пояснение, но не саму атрибуцию. */
.chart-grid[data-layout="4"] .tv-copyright-text { display: none; }

/* Заглушка: показывается, когда окно виджета так и не открылось. Лежит
   поверх гнезда, а подпись со ссылкой при этом остаётся на месте. */
.tv-fallback {
    position: absolute;
    inset: 0;
    bottom: 26px;
    z-index: 4;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 16px;
    text-align: center;
    background: var(--bg);
    /* Содержимое не должно вылезать за окно графика: на телефоне
       график низкий, и длинное пояснение закрывало собой подпись
       с логотипом и обрезало саму кнопку. */
    overflow: hidden;
}

.tv-fallback[hidden] { display: none; }

.tv-fallback-title {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.tv-fallback-text,
.tv-fallback-hint {
    margin: 0;
    max-width: 460px;
    font-size: 12px;
    line-height: 1.45;
    color: var(--text-secondary, var(--text-muted));
}

.tv-fallback-hint { font-size: 11px; }

/* Короткая строка вместо полного пояснения. На широком экране она лишняя —
   там целиком виден обычный текст, — а на телефоне и в Телеграме наоборот:
   полное пояснение скрыто, и без этой строки оставался голый заголовок про
   недоступный график, из которого человек делал вывод, что сломался сервис. */
.tv-fallback-short {
    display: none;
    margin: 0;
    max-width: 460px;
    font-size: 11px;
    line-height: 1.35;
    color: var(--text-secondary, var(--text-muted));
}

.tv-fallback-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}

/* В тесных ячейках оставляем только заголовок и кнопки: длинные объяснения
   там всё равно не читаются, а кнопка со ссылкой нужна. */
.chart-grid[data-layout="4"] .tv-fallback-text,
.chart-grid[data-layout="4"] .tv-fallback-hint { display: none; }

/* Телефон и Телеграм: окно графика низкое, и важно сохранить главное —
   заголовок, кнопки и подпись с логотипом. Подробное пояснение про домен
   и блокировщик там не влезает и вытесняет кнопку за край окна. */
@media (max-width: 900px) {
    /* На телефоне высоту окна графика считает сама страница под лист, и
       свой минимум в 360 точек выталкивал подпись с логотипом за край
       экрана — а её видно быть обязано всегда. */
    .chart-grid[data-layout="1"] #chart > .tv-embed { min-height: 0; }
    /* На телефоне строка атрибуции не влезала в ширину и уезжала за правый
       край — на снимках от подписчиков конец слов был обрезан. Логотип и
       ссылку мы обязаны показывать целиком, поэтому строку выравниваем по
       центру, разрешаем ей сжиматься и чуть уменьшаем шрифт. */
    .tv-copyright {
        padding: 2px 6px;
        font-size: 9px;
        justify-content: center;
    }
    .tv-copyright a { min-width: 0; }
    .tv-copyright-text {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .tv-logo { height: 12px; }
    .tv-fallback {
        gap: 6px;
        padding: 8px;
        bottom: 20px;
    }
    .tv-fallback-title { font-size: 13px; }
    .tv-fallback-text,
    .tv-fallback-hint { display: none; }
    .tv-fallback-short { display: block; }
    .tv-fallback-actions { gap: 6px; }
}

/* В тесных ячейках на четыре графика места нет даже под короткую строку. */
.chart-grid[data-layout="4"] .tv-fallback-short { display: none; }

.tg-app .tv-fallback-text,
.tg-app .tv-fallback-hint { display: none; }
.tg-app .tv-fallback-short { display: block; }

/* ===== Активный график (при двух и четырёх панелях) ===== */
/* Обводим внутренней тенью, а не рамкой: рамка сдвинула бы содержимое
   панели и график пересчитывал бы размер при каждом переключении. */
.pane-active {
    box-shadow: inset 0 0 0 2px var(--accent, #22c55e);
    border-radius: 4px;
}
.pane-tag {
    position: absolute;
    left: 8px;
    bottom: 6px;
    z-index: 6;
    padding: 2px 7px;
    border-radius: 999px;
    background: var(--accent, #22c55e);
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    white-space: nowrap;
    pointer-events: none;
}
.pane-tag.is-mini { background: #f59e0b; }
.pane-tag[hidden] { display: none; }
/* Строка в шапке меню: чем именно управляют настройки слева */
.side-active-hint {
    margin: 0;
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent, #22c55e);
    border-radius: 8px;
    background: var(--bg-secondary, rgba(127, 127, 127, 0.06));
    font-size: 11px;
    line-height: 1.4;
    color: var(--text-secondary, var(--text-muted));
}
/* Выбрана дополнительная панель — предупреждаем жёлтым, что левое меню
   меняет не её, а главный график. */
.side-active-hint.is-warn {
    border-left-color: #f59e0b;
    color: #b45309;
}
.side-active-hint[hidden] { display: none; }

/* Дополнительный график: своя шапка с выбором бумаги и таймфрейма */
.mini-panel {
    position: relative;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    background: var(--bg);
}

.mini-head {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 3px 5px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}

.mini-head select {
    min-height: 24px;
    height: 24px;
    padding: 0 4px;
    font-size: 11px;
    border-radius: 4px;
}

.mini-head .mini-instrument {
    flex: 1 1 auto;
    min-width: 0;
}

.mini-head .mini-timeframe {
    flex: 0 0 auto;
    width: 84px;
}

.mini-body {
    flex: 1;
    min-height: 0;
    position: relative;
}

.mini-status {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
    pointer-events: none;
}

.mini-title {
    position: absolute;
    top: 4px;
    left: 8px;
    z-index: 5;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    pointer-events: none;
}

/* ===== Chart Overlays ===== */
.chart-title-bar {
    position: absolute;
    top: 8px;
    left: 12px;
    z-index: 5;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.chart-title-main {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    text-shadow: 0 0 4px var(--bg);
}

.chart-title-meta {
    font-size: 10px;
    color: var(--text-muted);
    text-shadow: 0 0 4px var(--bg);
}

.chart-toolbar {
    position: absolute;
    top: 8px;
    right: 60px;
    z-index: 5;
    display: flex;
    gap: 2px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 2px;
}

.toolbar-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 11px;
    font-family: var(--font-body);
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    transition: all var(--transition);
}

.toolbar-btn:hover {
    background: var(--surface-3);
    color: var(--text);
}

.toolbar-btn.active {
    background: var(--primary);
    color: #fff;
}

.chart-legend {
    position: absolute;
    bottom: 30px;
    left: 12px;
    z-index: 9;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    display: flex;
    flex-direction: column;
    gap: 3px;
    pointer-events: none;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 10px;
    color: var(--text-muted);
}

.legend-dot {
    display: inline-block;
    width: 8px;
    height: 2px;
    border-radius: 1px;
    flex-shrink: 0;
}

/* Короткая подпись показывается только в тесной сетке 2 и 4 графиков */
.legend-short {
    display: none;
}

/* Заголовок легенды — как в колонке настроек */
.legend-head {
    font-size: 10px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 1px;
}

/* Период выбран, но уровней в кадре нет — показываем бледнее */
.legend-item.legend-empty {
    opacity: 0.42;
}

/* Полоска зоны: закраска внутри и контрастные границы сверху и снизу */
.legend-band {
    display: inline-block;
    width: 10px;
    height: 8px;
    flex-shrink: 0;
    border-top: 2px solid;
    border-bottom: 2px solid;
}

.chart-legend .legend-zone {
    max-width: 190px;
    align-items: flex-start;
    line-height: 1.25;
    margin-top: 2px;
}

/* ===== Легенда в дополнительном графике ===== */
.mini-legend {
    position: absolute;
    bottom: 22px;
    left: 8px;
    z-index: 9;
    display: flex;
    flex-wrap: wrap;
    gap: 2px 7px;
    max-width: calc(100% - 100px);
    padding: 2px 6px;
    border: 1px solid var(--border);
    border-radius: 5px;
    background: var(--surface);
    opacity: 0.85;
    pointer-events: none;
    transition: opacity var(--transition);
}

.mini-panel:hover .mini-legend {
    opacity: 1;
}

.mini-legend .legend-item {
    gap: 4px;
    font-size: 10px;
    white-space: nowrap;
}

.mini-legend .legend-band {
    width: 9px;
    height: 7px;
}

.chart-grid[data-layout="4"] .mini-legend {
    gap: 1px 5px;
    padding: 1px 4px;
}

.chart-grid[data-layout="4"] .mini-legend .legend-item {
    font-size: 9px;
}

/* ===== Loading Overlay ===== */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(13, 17, 23, 0.7);
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 12px;
    z-index: 10;
}

.loading-overlay.show {
    display: flex;
}

[data-theme="light"] .loading-overlay {
    background: rgba(246, 248, 250, 0.7);
}

.loading-overlay p {
    color: var(--text-muted);
    font-size: 13px;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ===== Responsive ===== */
@media (max-width: 1024px) and (min-width: 861px) {
    .sidebar {
        width: 270px;
        padding: 10px;
    }
    .header p { display: none; }
}

/* ===== Телефоны и планшеты ===== */
.sidebar-head { display: none; }

@media (max-width: 860px) {
    .menu-toggle {
        display: inline-flex;
    }

    /* На телефоне настройки открываются кнопкой меню — свёрнутость с большого экрана не применяем */
    .main.no-sidebar > .sidebar {
        display: flex;
    }

    .sidebar-head {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        margin-bottom: 4px;
        font-size: 15px;
        font-weight: 600;
        color: var(--text);
    }

    /* На телефоне настройки применяются сразу, кнопка не нужна */
    #build-btn {
        display: none;
    }

    .sidebar-close {
        border: 1px solid var(--border);
        background: var(--surface-2, var(--surface));
        color: var(--text);
        border-radius: var(--radius-sm);
        padding: 8px 12px;
        min-height: 40px;
        font-size: 14px;
        cursor: pointer;
    }

    .header {
        padding: 8px 12px;
        height: 56px;
    }

    /* Название целиком, в две строки. Одной строкой «Динамические уровни» на
       узком экране не влезало и обрезалось троеточием — оставалось «Динамические …».
       Двумя строками по 11,5 px оно занимает ту же высоту, что кнопки справа,
       и читается полностью. */
    .header .hdr-title {
        font-size: 11.5px;
        line-height: 1.15;
        white-space: normal;
        overflow-wrap: break-word;
        display: -webkit-box;
        -webkit-line-clamp: 2;      /* третьей строке взяться неоткуда, но страхуемся */
        -webkit-box-orient: vertical;
        overflow: hidden;
    }
    .header p { display: none; }
    .logo { width: 20px; height: 20px; }
    .header-left { gap: 8px; min-width: 0; }

    /* Название сервиса уступает место тикеру: на телефоне важнее видеть,
       какая бумага и какой таймфрейм сейчас на экране. */
    .header-name { display: none; }

    .head-ticker {
        display: inline-flex;
        flex-direction: column;
        align-items: flex-start;
        gap: 1px;
        min-width: 0;
        max-width: 46vw;
        padding: 4px 8px;
        border: 1px solid var(--border);
        border-radius: var(--radius-sm);
        background: var(--surface-2, var(--surface));
        color: var(--text);
        cursor: pointer;
        text-align: left;
    }
    .head-ticker-name {
        max-width: 100%;
        font-size: 12.5px;
        font-weight: 700;
        line-height: 1.1;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .head-ticker-tf {
        font-size: 9.5px;
        line-height: 1.1;
        color: var(--text-muted);
        white-space: nowrap;
    }

    /* На телефоне значки чуть крупнее: палец должен попадать по ним без
       прицеливания, а места в узкой полосе для этого хватает. */
    .data-fresh .df-chip {
        padding: 5px 8px;
        gap: 5px;
    }
    .data-fresh .df-chip .df-dot { width: 7px; height: 7px; }
    .data-fresh .df-tip { font-size: 0.74rem; }

    .topbar-icon-draw { display: inline-flex; }

    /* Боковая панель — выдвижное меню поверх графика */
    .sidebar {
        position: fixed;
        top: 56px;
        left: 0;
        bottom: 0;
        width: 92%;
        max-width: 380px;
        z-index: 40;
        padding: 14px;
        transform: translateX(-102%);
        transition: transform 0.25s ease;
        box-shadow: 4px 0 24px rgba(0,0,0,0.25);
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-backdrop {
        display: block;
        position: fixed;
        top: 56px;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0,0,0,0.5);
        z-index: 35;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.25s ease;
    }

    .sidebar-backdrop.show {
        opacity: 1;
        pointer-events: auto;
    }

    .chart-area {
        width: 100%;
    }

    /* Удобные для пальца элементы управления */
    select,
    input[type="text"],
    input[type="number"] {
        font-size: 16px;
        min-height: 42px;
    }

    .btn {
        min-height: 44px;
        font-size: 14px;
    }

    .checkbox-group label,
    .radio-group label {
        min-height: 32px;
    }

    /* Подписи над графиком: переключатель масштаба сверху, название под ним */
    .chart-toolbar {
        top: 6px;
        left: 8px;
        right: 8px;
        justify-content: space-between;
        overflow-x: auto;
    }

    .toolbar-btn {
        font-size: 12px;
        padding: 7px 9px;
        flex: 1 1 auto;
    }

    /* Полоса таймфреймов на телефоне: все периоды в один ряд,
       лишнее уезжает вбок пальцем — без полосы прокрутки на экране */
    .chart-tf-strip {
        justify-content: flex-start;
        gap: 2px;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-x: contain;
    }

    .chart-tf-strip::-webkit-scrollbar {
        display: none;
    }

    .chart-tf-strip .tf-btn {
        flex: 0 0 auto;
        min-width: 40px;
        padding: 7px 10px;
        font-weight: 600;
        white-space: nowrap;
    }

    .chart-title-bar {
        top: 48px;
        left: 8px;
        right: auto;
        max-width: calc(100% - 76px);
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: var(--radius-sm);
        padding: 4px 8px;
    }

    .chart-title-main { font-size: 12px; }
    .chart-title-meta { font-size: 10px; line-height: 1.35; }

    /* Строка названия на телефоне — одна строка без плашки: раньше плашка в
       две-три строки (периоды, фильтр, зоны, число уровней) ложилась на
       свечи. Теперь название и сведения идут одной строкой с многоточием,
       а верх полотна под ними оставляет пустым отступ шкалы (верхШкалы). */
    .chart-title-bar {
        background: transparent;
        border: 0;
        padding: 0 2px;
        flex-direction: row;
        align-items: baseline;
        gap: 6px;
        white-space: nowrap;
        overflow: hidden;
        max-width: calc(100% - 70px);
    }
    .chart-title-main { flex: none; }
    .chart-title-meta { overflow: hidden; text-overflow: ellipsis; min-width: 0; }

    /* На телефоне легенда занимает нужное место на графике, а расшифровка цветов
       и так есть в настройках («Периоды уровней» и «Цвета уровней») */
    .chart-legend,
    .mini-legend {
        display: none;
    }
}

/* Сообщение, когда данные не загрузились */
.chart-fatal {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    height: 100%;
    min-height: 240px;
    padding: 24px;
    text-align: center;
    font-family: var(--font-body);
    color: var(--text);
}

.chart-fatal p {
    margin: 0;
    max-width: 30ch;
    font-size: 15px;
    line-height: 1.5;
}

.chart-fatal button {
    padding: 12px 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    color: var(--text);
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
}

/* ===== Alerts ===== */
.hint {
    font-size: 10px;
    line-height: 1.4;
    color: var(--text-faint);
    margin-top: 2px;
}

.hint:empty {
    display: none;
}

.hint.warn {
    color: #e0a030;
}

.alert-log-box {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.alert-log-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    width: 100%;
    padding: 0;
    border: 0;
    background: none;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    font-family: inherit;
    text-align: left;
    cursor: pointer;
}

.alert-log-title svg {
    width: 14px;
    height: 14px;
    flex: 0 0 auto;
    transition: transform 140ms ease;
}

.alert-log-title:hover {
    color: var(--text);
}

/* Свёрнутый список оповещений: остаётся только заголовок */
.alert-log-box.collapsed .alert-log-legend,
.alert-log-box.collapsed #alert-log,
.alert-log-box.collapsed .alert-log-clear {
    display: none;
}

.alert-log-box.collapsed .alert-log-title svg {
    transform: rotate(-90deg);
}

/* Компактные действия вместо больших кнопок «Построить» и «Обновить список» */
.mini-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

.link-btn {
    padding: 0;
    border: 0;
    background: none;
    color: var(--primary);
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    border-bottom: 1px dashed currentColor;
}

.link-btn:hover {
    color: var(--text);
}

.link-btn:disabled {
    opacity: 0.55;
    cursor: default;
}

#alert-log {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 168px;
    overflow-y: auto;
}

.alert-item {
    display: flex;
    gap: 6px;
    align-items: baseline;
    font-size: 11px;
    line-height: 1.35;
    color: var(--text);
    border-left: 2px solid var(--border);
    padding-left: 6px;
}

.alert-item .alert-time {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-faint);
    flex-shrink: 0;
}

.alert-log-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 10px;
    margin: 0 0 4px;
    font-size: 10px;
    color: var(--text-faint);
}

.alert-legend {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.alert-legend::before {
    content: "";
    width: 8px;
    height: 2px;
    border-radius: 1px;
    background: var(--border);
}

.alert-legend.touch::before { background: #e0a030; }
.alert-legend.cross::before { background: var(--primary); }
.alert-legend.zone::before { background: var(--green); }

.alert-item .alert-ticker {
    flex-shrink: 0;
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted, var(--text));
    background: var(--surface-2, rgba(127, 127, 127, 0.12));
    border-radius: 3px;
    padding: 0 4px;
}

.alert-item.cross {
    border-left-color: var(--primary);
}

.alert-item.touch {
    border-left-color: #e0a030;
}

.alert-item.zone {
    border-left-color: var(--green);
}

.alert-log-clear {
    align-self: flex-start;
    background: transparent;
    border: none;
    padding: 0;
    font-family: inherit;
    font-size: 10px;
    color: var(--text-faint);
    cursor: pointer;
    text-decoration: underline;
}

.alert-log-clear:hover {
    color: var(--text);
}

.alert-banner {
    position: absolute;
    top: 44px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 20;
    max-width: min(440px, calc(100% - 24px));
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    background: var(--surface);
    border: 1px solid var(--primary);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
    animation: alert-in 220ms cubic-bezier(0.16, 1, 0.3, 1);
}

.alert-banner[hidden] {
    display: none;
}

.alert-banner.touch {
    border-color: #e0a030;
}

.alert-banner.zone {
    border-color: var(--green);
}

.alert-banner-text {
    font-size: 13px;
    line-height: 1.4;
    color: var(--text);
}

.alert-banner-text .alert-extra {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

.alert-banner-close {
    background: transparent;
    border: none;
    color: var(--text-faint);
    font-size: 13px;
    line-height: 1;
    padding: 2px 0 2px 4px;
    cursor: pointer;
    flex-shrink: 0;
}

.alert-banner-close:hover {
    color: var(--text);
}

@keyframes alert-in {
    from { opacity: 0; transform: translateX(-50%) translateY(-8px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@media (max-width: 860px) {
    .alert-banner {
        top: auto;
        bottom: 130px;
        max-width: calc(100% - 16px);
        padding: 12px;
    }

    .alert-banner-text { font-size: 14px; }

    .alert-banner-close {
        font-size: 16px;
        padding: 4px 0 4px 8px;
    }
}

/* Панель рисования появляется только по кнопке-карандашу в полосе над графиком.
   Раньше правило стояло в мобильном медиа-блоке, и в браузере полоса кнопок
   всегда занимала левый край полотна: она отнимала место у свечей и закрывала
   логотип TradingView в углу. Теперь одинаково на всех ширинах. */
body.draw-off .draw-panel { display: none; }

/* Карандаш нужен на всех ширинах: без него спрятанную панель не достать */
.topbar-icon-draw { display: inline-flex; }

/* Отступ слева под боковую панель рисования: её кнопки стоят в этой полосе,
   а свечи, линии уровней и подписи цен начинаются правее и уже не перекрываются. */
body.draw-gutter { --draw-gutter: 52px; }
body.draw-gutter .mini-body { --draw-gutter: 38px; }

body.draw-gutter #chart,
body.draw-gutter .mini-body { padding-left: var(--draw-gutter, 0px); }

/* Полотно рисования и подписи должны совпадать с областью свечей, а не с полосой панели */
body.draw-gutter #chart > .draw-canvas,
body.draw-gutter .mini-body > .draw-canvas { left: var(--draw-gutter, 0px); }

body.draw-gutter #chart > .chart-legend,
body.draw-gutter #chart > .chart-title-bar,
body.draw-gutter .mini-body > .mini-legend,
body.draw-gutter .mini-body > .mini-title { margin-left: var(--draw-gutter, 0px); }

/* На узком экране панель уезжает вниз, полоса слева там не нужна — место дороже */
@media (max-width: 860px) {
    body.draw-gutter { --draw-gutter: 0px; }
    body.draw-gutter .mini-body { --draw-gutter: 0px; }
}

/* ===== Панель рисования ===== */
.draw-canvas {
    position: absolute;
    inset: 0;
    z-index: 8;
    pointer-events: none;
    touch-action: none;
}

.draw-panel {
    position: absolute;
    top: 50%;
    left: 8px;
    transform: translateY(-50%);
    z-index: 12;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 4px;
    border-radius: var(--radius-md);
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
}

.draw-tool {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: background 120ms ease, color 120ms ease;
}

.draw-tool svg {
    width: 18px;
    height: 18px;
}

.draw-tool:hover {
    background: var(--surface-alt, rgba(127, 127, 127, 0.12));
    color: var(--text);
}

.draw-tool.active {
    background: var(--primary);
    color: #fff;
}

.draw-sep {
    height: 1px;
    margin: 3px 4px;
    background: var(--border);
}

.draw-swatch {
    width: 14px;
    height: 14px;
    border-radius: 4px;
    border: 1px solid var(--border);
}

/* Где держать панель рисования — задаётся в кабинете: сбоку, сверху или снизу.
   Без класса панель стоит слева (как раньше). */
.draw-panel.pos-top,
.draw-panel.pos-bottom {
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    flex-direction: row;
    flex-wrap: nowrap;
    max-width: calc(100% - 16px);
    overflow-x: auto;
    scrollbar-width: none;
}

.draw-panel.pos-top { top: 52px; bottom: auto; }
.draw-panel.pos-bottom { top: auto; bottom: 34px; }

.draw-panel.pos-top::-webkit-scrollbar,
.draw-panel.pos-bottom::-webkit-scrollbar { display: none; }

.draw-panel.pos-top .draw-tool,
.draw-panel.pos-bottom .draw-tool { flex: 0 0 auto; }

.draw-panel.pos-top .draw-sep,
.draw-panel.pos-bottom .draw-sep {
    width: 1px;
    height: auto;
    margin: 4px 3px;
}

@media (max-width: 860px) {
    .draw-panel {
        top: auto;
        bottom: 6px;
        left: 6px;
        right: 6px;
        transform: none;
        flex-direction: row;
        flex-wrap: nowrap;
        justify-content: flex-start;
        overflow-x: auto;
        scrollbar-width: none;
        padding: 3px 4px;
    }

    /* На телефоне место панели не выбирается: всегда полоса внизу */
    .draw-panel.pos-top,
    .draw-panel.pos-bottom {
        top: auto;
        bottom: 6px;
        left: 6px;
        right: 6px;
        transform: none;
        max-width: none;
    }

    .draw-panel::-webkit-scrollbar { display: none; }

    .draw-tool { flex: 0 0 auto; }

    .draw-tool {
        width: 34px;
        height: 34px;
    }

    .draw-sep {
        width: 1px;
        height: auto;
        margin: 4px 3px;
    }
}

/* ===== Настройки каждого способа оповещения ===== */
.channel {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.channel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
}

/* Подсказка о тарифе занимает всю строку под названием канала */
.channel-head .lock-tip {
    flex: 1 0 100%;
    order: 10;
    margin: 0;
}

.channel-gear {
    flex: 0 0 auto;
    padding: 2px 6px;
    font-size: 10px;
    font-family: inherit;
    color: var(--text-muted);
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: color 120ms ease, border-color 120ms ease;
}

.channel-gear:hover {
    color: var(--text);
    border-color: var(--primary);
}

.channel-body {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin: 2px 0 6px 20px;
    padding: 8px;
    border-left: 2px solid var(--primary);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    background: var(--surface-2);
}

.channel-body[hidden] {
    display: none;
}

.channel-sub {
    font-size: 10px;
    font-weight: 500;
    color: var(--text-muted);
    margin: 2px 0 0;
}

.channel-kinds {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 12px;
}

.channel-test {
    align-self: flex-start;
    margin-top: 6px;
    padding: 4px 10px;
    font-size: 11px;
    font-family: inherit;
    color: var(--primary);
    background: transparent;
    border: 1px solid var(--primary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 120ms ease, color 120ms ease;
}

.channel-test:hover {
    background: var(--primary);
    color: #fff;
}

/* Фильтр по времени торговых сессий */
.session-block {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px dashed var(--border);
}

.session-custom {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 4px;
}

.session-custom[hidden] {
    display: none;
}

.session-time-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: var(--text-muted);
}

.session-time-row input[type="time"] {
    width: auto;
    min-width: 96px;
}

.session-tz {
    font-size: 10px;
    color: var(--text-muted);
}

.session-days {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 10px;
}

.session-days label {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 500;
    color: var(--text);
    cursor: pointer;
}

/* Инструменты для оповещений в телеграме (серверное слежение) */
.tg-watch-block {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px dashed var(--border);
}

.tg-watch-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.tg-watch-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 6px 3px 10px;
    font-size: 11px;
    font-weight: 500;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 999px;
}

.tg-watch-chip-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    padding: 0;
    font-size: 11px;
    line-height: 1;
    color: var(--text-muted);
    background: transparent;
    border: none;
    border-radius: 50%;
    cursor: pointer;
}

.tg-watch-chip-remove:hover {
    color: #fff;
    background: var(--danger, #d64545);
}

.tg-watch-add-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.tg-watch-add-row select {
    flex: 1;
    min-width: 160px;
}

#tg-watch-limit-hint {
    margin: 0;
}

/* Плашка снизу графика */
.alert-banner.pos-bottom {
    top: auto;
    bottom: 16px;
}

@media (max-width: 860px) {
    .alert-banner.pos-top {
        top: 110px;
        bottom: auto;
    }

    .alert-banner.pos-bottom {
        top: auto;
        bottom: 130px;
    }

    .channel-body {
        margin-left: 12px;
    }

    .channel-gear,
    .channel-test {
        padding: 5px 10px;
        font-size: 11px;
    }
}

/* Поле ввода надписи на графике */
.draw-text-input {
    position: absolute;
    z-index: 14;
    width: 186px;
    padding: 5px 8px;
    font-family: inherit;
    font-size: 13px;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--primary);
    border-radius: var(--radius-sm);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
    outline: none;
}

.draw-text-input::placeholder {
    color: var(--text-faint);
    font-size: 11px;
}

/* Файл оповещений */
.alert-file-row {
    display: flex;
    gap: 6px;
    margin-top: 6px;
}

.alert-file-row .btn-small {
    flex: 1;
    padding: 7px 8px;
    font-size: 12px;
    margin: 0;
}

#alert-file-list {
    margin-top: 6px;
}

/* Подсказка по свече */
.candle-tip {
    position: absolute;
    z-index: 26;
    pointer-events: none;
    min-width: 168px;
    padding: 8px 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.14);
    font-size: 12px;
    line-height: 1.35;
    color: var(--text);
}

/* В дополнительной панели места меньше — подсказку делаем компактнее */
.mini-tip {
    min-width: 132px;
    padding: 6px 8px;
    font-size: 11px;
    z-index: 28;
}

.mini-tip .candle-tip-head {
    margin-bottom: 4px;
    padding-bottom: 4px;
}

.mini-tip .candle-tip-grid {
    gap: 1px 8px;
}

.candle-tip[hidden] {
    display: none;
}

.candle-tip-head {
    font-weight: 600;
    margin-bottom: 5px;
    padding-bottom: 5px;
    border-bottom: 1px solid var(--border);
}

.candle-tip-grid {
    display: grid;
    grid-template-columns: auto auto;
    gap: 2px 12px;
}

.candle-tip-grid span {
    color: var(--text-muted);
}

.candle-tip-grid b {
    font-weight: 600;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.candle-tip-grid b.up {
    color: #26a69a;
}

.candle-tip-grid b.down {
    color: #ef5350;
}

@media (max-width: 900px) {
    .candle-tip {
        min-width: 150px;
        font-size: 11px;
        padding: 7px 8px;
    }
}


/* Плашка источника котировок */
.source-badge {
    margin-top: 6px;
    font-size: 12px;
    line-height: 1.35;
    color: var(--text-muted);
    display: none;
}
.source-badge.visible { display: block; }
.source-badge .dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
    vertical-align: middle;
    background: var(--text-faint);
}
.source-badge.live .dot { background: #22c55e; }
.source-badge.warn .dot { background: #f59e0b; }
.source-badge.off .dot { background: #ef4444; }

/* ===== Cabinet UI (merged from cabinet.css) ===== */
/* ===== Кабинет, вход, тарифы ===== */

.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-account {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    padding: 7px 14px;
    font-size: 13px;
    font-weight: 600;
    font-family: var(--font-body);
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.btn-account:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(34, 197, 94, 0.35);
}

.btn-account.is-logged {
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
}

/* Значок нужен только там, где почта не влезает: на телефоне и в Телеграме */
.btn-account-icon {
    display: none;
    flex-shrink: 0;
}

/* Название сервиса не должно выдавливать кнопки справа */
.header-left {
    min-width: 0;
}

/* Блок с названием и подписью тоже должен уметь сжиматься: без этого он держит
   свою ширину и заголовок налезает на кнопки аккаунта на узком экране. */
.header-left > div {
    min-width: 0;
    overflow: hidden;
}

.header p {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* На большом экране название влезает в одну строку, поэтому там прежнее
   поведение с троеточием. Перенос в две строки включается ниже, для телефона. */
.header .hdr-title { overflow: hidden; }

@media (min-width: 861px) {
    .header .hdr-title { text-overflow: ellipsis; white-space: nowrap; }
}

.header-right > * {
    flex-shrink: 0;
}

.link-btn {
    background: none;
    border: none;
    padding: 0;
    color: #22c55e;
    font-size: 12px;
    font-family: var(--font-body);
    cursor: pointer;
    text-decoration: underline;
    text-align: left;
}

.link-btn:hover {
    color: #4ade80;
}

/* ===== Модалка (общая для входа и др.) ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 16px;
}

.modal-overlay[hidden] {
    display: none;
}

.modal-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    width: 100%;
    max-width: 380px;
    max-height: calc(100vh - 32px);
    overflow-y: auto;
    padding: 18px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
}

.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.modal-head h2 {
    font-size: 17px;
    font-weight: 600;
    color: var(--text);
}

.modal-close {
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    width: 30px;
    height: 30px;
    cursor: pointer;
    font-size: 14px;
    flex-shrink: 0;
}

/* Окно «Pine-код уровней». Поле с кодом делаем моноширинным и с прокруткой:
   код читают глазами перед вставкой, а на узком экране он иначе расползается
   переносами и понять, где кончается строка, невозможно. */
.pine-box {
    max-width: 720px;
    width: min(92vw, 720px);
}

.pine-code {
    width: 100%;
    min-height: 240px;
    max-height: 46vh;
    margin: 6px 0 4px;
    padding: 10px 12px;
    box-sizing: border-box;
    font-family: var(--font-mono);
    font-size: 12px;
    line-height: 1.45;
    white-space: pre;
    overflow: auto;
    resize: vertical;
    color: var(--text);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

.pine-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 10px;
}

.modal-close:hover {
    color: var(--text);
    background: var(--surface-3);
}

/* ===== Вкладки входа ===== */
.auth-tabs {
    display: flex;
    gap: 4px;
    background: var(--surface-2);
    border-radius: var(--radius-sm);
    padding: 3px;
    margin-bottom: 14px;
}

.auth-tab {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 500;
    font-family: var(--font-body);
    padding: 8px 4px;
    border-radius: 5px;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.auth-tab.active {
    background: var(--surface);
    color: #22c55e;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

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

.auth-step[hidden] {
    display: none;
}

.auth-step {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.auth-step label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
}

.auth-step input[type="email"],
.auth-step input[type="tel"],
.auth-step input[type="text"],
.account-link-box input {
    width: 100%;
    padding: 9px 10px;
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: var(--font-body);
    outline: none;
}

.auth-step input:focus,
.account-link-box input:focus {
    border-color: #22c55e;
}

.auth-error {
    color: #ef5350;
    font-size: 12px;
    margin-top: 8px;
    line-height: 1.4;
}

.auth-error:empty {
    display: none;
}

.auth-telegram-code {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: 4px;
    text-align: center;
    color: #22c55e;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px;
}

.auth-panel .btn,
.auth-step .btn {
    width: 100%;
}

/* ===== Кабинет ===== */
.cabinet-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 90;
    padding: 16px;
}

.cabinet-overlay[hidden] {
    display: none;
}

.cabinet-box {
    --cab-pad: 18px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    width: 100%;
    max-width: 620px;
    max-height: calc(100vh - 32px);
    overflow-y: auto;
    padding: var(--cab-pad);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
}

/* Заголовок прилипает к верху окна: крестик виден на любой прокрутке */
.cabinet-head {
    position: sticky;
    top: 0;
    /* Ниже в кабинете есть карточки и плашки со своим z-index: при прокрутке на
       телефоне они пролезали над шапкой. Поднимаем шапку выше всего кабинета. */
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    background: var(--surface);
    margin: calc(-1 * var(--cab-pad)) calc(-1 * var(--cab-pad)) 12px;
    padding: var(--cab-pad) var(--cab-pad) 10px;
    border-bottom: 1px solid var(--border);
    /* Тень отделяет шапку от уезжающего под неё текста */
    box-shadow: 0 6px 12px -8px rgba(0, 0, 0, 0.55);
}

.cabinet-head h2 {
    font-size: 18px;
    font-weight: 600;
}

.cabinet-tabs {
    display: flex;
    gap: 4px;
    background: var(--surface-2);
    border-radius: var(--radius-sm);
    padding: 3px;
    margin-bottom: 16px;
}

.cabinet-tab {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    font-family: var(--font-body);
    padding: 9px 6px;
    border-radius: 5px;
    cursor: pointer;
    transition: all var(--transition);
}

.cabinet-tab.active {
    background: var(--surface);
    color: #22c55e;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

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

.cabinet-guest-note {
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.25);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    margin-bottom: 14px;
    font-size: 12px;
    color: var(--text);
}

.account-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 0;
    border-bottom: 1px solid var(--border);
}

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

.account-row-label {
    width: 76px;
    flex-shrink: 0;
    font-size: 12px;
    color: var(--text-muted);
}

.account-row-value {
    flex: 1 1 auto;
    min-width: 120px;
    font-size: 13px;
    color: var(--text);
    overflow-wrap: anywhere;
}

/* Кнопка «Привязать» не должна сжимать значение до одной буквы в строке
   и не должна вылезать за край окна кабинета */
.account-row .btn-small {
    flex: 0 0 auto;
    width: auto;
    white-space: nowrap;
}

.account-link-box {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px;
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.account-link-box[hidden] {
    display: none;
}

.account-link-box .btn {
    width: auto;
}

.cabinet-section {
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}

.cabinet-section h3 {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.session-row {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    font-size: 12px;
    color: var(--text-muted);
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
}

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

/* ===== набор инструментов (слоты) ===== */
.slot-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}

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

.slot-num {
    width: 22px;
    height: 22px;
    flex: 0 0 auto;
    border-radius: 50%;
    background: var(--bg-elevated, rgba(127, 127, 127, .15));
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
}

.slot-ticker {
    font-weight: 600;
    color: var(--text);
}

.slot-ticker.is-empty {
    font-weight: 400;
    color: var(--text-muted);
}

.slot-state {
    margin-left: auto;
    color: var(--text-muted);
    font-size: 12px;
    text-align: right;
}

.slot-row .btn-small {
    width: auto;
    flex: 0 0 auto;
}

/* ===== вкладка «Администратор» ===== */
.admin-section .btn-small {
    width: auto;
}

.admin-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 10px;
}

.admin-field label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
}

.admin-field input {
    width: 100%;
    padding: 9px 10px;
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: var(--font-body);
    outline: none;
}

.admin-field input:focus {
    border-color: #22c55e;
}

.admin-stats {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 10px;
}

/* Таблицы платежей и входов бывают длинными — прокручиваем их внутри блока,
   чтобы остальные разделы вкладки «Администратор» оставались под рукой. */
.admin-scroll-tall {
    max-height: 320px;
    overflow: auto;
}

.admin-users-table-wrap {
    overflow-x: auto;
}

.admin-users-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.admin-users-table th,
.admin-users-table td {
    padding: 6px 6px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.admin-users-table th {
    color: var(--text-muted);
    font-weight: 500;
}

.admin-users-table select {
    width: auto;
    padding: 5px 8px;
    padding-right: 22px;
    font-size: 12px;
}

.admin-users-table input[type="number"] {
    padding: 5px 6px;
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-family: var(--font-body);
}

@media (max-width: 640px) {
    .admin-users-table-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .admin-users-table {
        min-width: 560px;
    }
}

.session-row .session-current {
    color: #22c55e;
    font-weight: 600;
}

#account-logout-btn {
    margin-top: 16px;
}

/* ===== Тарифы ===== */
.billing-period-toggle {
    display: flex;
    gap: 4px;
    background: var(--surface-2);
    border-radius: var(--radius-sm);
    padding: 3px;
    margin-bottom: 14px;
    max-width: 360px;
}

.billing-period {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 500;
    font-family: var(--font-body);
    padding: 7px 6px;
    border-radius: 5px;
    cursor: pointer;
    white-space: nowrap;
}

.billing-period.active {
    background: #22c55e;
    color: #06210f;
}

/* Процент скидки на кнопке срока. */
.billing-period-save {
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
    padding: 2px 4px;
    border-radius: 4px;
    background: rgba(34, 197, 94, 0.16);
    color: #22c55e;
}

.billing-period.active .billing-period-save {
    background: rgba(6, 33, 15, 0.16);
    color: #06210f;
}

@media (max-width: 560px) {
    .billing-period-toggle {
        max-width: none;
    }

    .billing-period {
        flex-direction: column;
        gap: 2px;
        padding: 6px 4px;
        font-size: 11px;
    }
}

/* Старая цена без скидки и цена за месяц в карточке тарифа. */
.plan-price-was {
    display: block;
    margin-top: 3px;
    font-size: 11px;
    font-weight: 400;
    color: var(--text-muted);
}

.plan-price-was s {
    opacity: 0.75;
}

.plan-price-save {
    color: #22c55e;
    font-weight: 600;
}

.billing-plans {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 14px;
}

@media (max-width: 640px) {
    .billing-plans {
        grid-template-columns: 1fr;
    }
}

.plan-card {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    position: relative;
}

.plan-card.current {
    border-color: #22c55e;
    box-shadow: 0 0 0 1px #22c55e inset;
}

.plan-current-badge {
    position: absolute;
    top: -9px;
    right: 10px;
    background: #22c55e;
    color: #06210f;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
}

.plan-name {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
}

.plan-price {
    font-size: 20px;
    font-weight: 700;
    color: #22c55e;
}

.plan-price span {
    font-size: 11px;
    font-weight: 400;
    color: var(--text-muted);
}

.plan-features {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 5px;
    font-size: 11px;
    color: var(--text-muted);
    flex: 1;
}

.plan-features li {
    display: flex;
    gap: 6px;
    align-items: flex-start;
    line-height: 1.35;
}

.plan-features li::before {
    content: "✓";
    color: #22c55e;
    flex-shrink: 0;
}

.plan-card .btn {
    margin-top: auto;
}

.history-row {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    font-size: 12px;
    color: var(--text-muted);
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
}

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

.history-status {
    font-weight: 600;
}

.history-status.paid { color: #22c55e; }
.history-status.pending { color: #e0a030; }
.history-status.failed { color: #ef5350; }

/* На узком экране четыре ячейки в один ряд не влезают и слова рвутся:
   раскладываем их в две строки — сверху тариф и состояние, снизу сумма и дата. */
@media (max-width: 560px) {
    .history-row {
        display: grid;
        grid-template-columns: 1fr auto;
        row-gap: 2px;
        padding: 8px 0;
    }

    .history-row span:nth-child(3),
    .history-row span:nth-child(4) {
        color: var(--text-muted);
    }

    .history-row span:nth-child(2),
    .history-row span:nth-child(4) {
        text-align: right;
    }
}

/* ===== Настройки: перенесённые блоки в кабинете ===== */
#cabinet-settings-mount .control-group {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px;
    margin-bottom: 10px;
}

#cabinet-settings-mount .channel {
    background: var(--surface);
}

.settings-notes {
    background: rgba(224, 160, 48, 0.12);
    border: 1px solid rgba(224, 160, 48, 0.3);
    color: #e0a030;
    border-radius: var(--radius-sm);
    padding: 8px 10px;
    font-size: 12px;
    margin-bottom: 12px;
}

.settings-notes:empty {
    display: none;
}

/* ===== Замки по тарифу ===== */
.locked-control {
    opacity: 0.6;
    position: relative;
}

.lock-icon {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: #e0a030;
    font-size: 11px;
    cursor: help;
}

.lock-tip {
    display: block;
    width: 100%;
    font-size: 11px;
    color: #e0a030;
    margin: 3px 0 8px 0;
    line-height: 1.4;
}

.lock-tip a,
.lock-tip button.link-btn {
    color: #e0a030;
    font-size: 11px;
}

/* ===== Скрытые в панели графика блоки — теперь только в кабинете ===== */
.cabinet-only {
    display: none;
}

/* ===== Мобильная адаптация ===== */
@media (max-width: 860px) {
    .header-right {
        gap: 6px;
    }

    .btn-account {
        padding: 6px 10px;
        font-size: 12px;
    }

    /* Вошли — вместо длинной почты круглая кнопка кабинета: справка и тема
       больше не уезжают за край, а название сервиса не перекрывается */
    .btn-account.is-logged {
        width: 36px;
        height: 36px;
        padding: 0;
        border-radius: 50%;
        /* В один вид со справкой и темой: три круглых кнопки на синей шапке */
        background: rgba(255, 255, 255, 0.14);
        border: 1px solid rgba(255, 255, 255, 0.25);
        color: #fff;
    }

    .btn-account.is-logged .btn-account-text {
        display: none;
    }

    .btn-account.is-logged .btn-account-icon {
        display: block;
    }

    /* Пальцем в маленькие значки не попасть — увеличиваем */
    .theme-toggle,
    .help-link {
        width: 36px;
        height: 36px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        padding: 0;
    }

    .modal-box,
    .cabinet-box {
        max-width: 100%;
        width: 100%;
        max-height: calc(100dvh - 16px);
        padding: 14px;
    }

    .cabinet-box {
        --cab-pad: 14px;
    }

    .cabinet-overlay,
    .modal-overlay {
        padding: 8px;
    }

    .billing-plans {
        grid-template-columns: 1fr;
    }

    .cabinet-tab,
    .auth-tab {
        font-size: 11px;
        padding: 8px 4px;
    }

    .account-row {
        flex-wrap: wrap;
    }

    .account-row-value {
        width: 100%;
        order: 2;
    }

    /* Кнопка «Привязать» уходит под значение, а не над ним */
    .account-row .btn-small {
        order: 3;
        width: 100%;
    }
}

/* ===== Cabinet UI: green accent override for primary buttons ===== */
#auth-modal .btn-primary,
#cabinet-screen .btn-primary,
.header-right .btn-primary {
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
    color: #fff;
}

#auth-modal .btn-primary:hover,
#cabinet-screen .btn-primary:hover,
.header-right .btn-primary:hover {
    box-shadow: 0 4px 12px rgba(34, 197, 94, 0.35);
}

#auth-modal .btn-primary:disabled,
#cabinet-screen .btn-primary:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}


/* ===== Дополнительный блок в окне входа ===== */
.auth-extra {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color, #e5e7eb);
}

.auth-svc-box {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Блок ввода ключа и строки кабинета скрываются атрибутом hidden,
   а display: flex его перебивает — поэтому скрываем явно */
.auth-svc-box[hidden],
.account-row[hidden],
.slot-row[hidden] {
    display: none;
}


/* Таблица пользователей: компактные поля, чтобы кнопка «Выдать» была видна */
.admin-users-table input[type="number"],
.admin-users-table input[type="text"] {
    width: 52px;
    padding: 5px 6px;
    font-size: 12px;
}

.admin-users-table select {
    max-width: 118px;
}

.admin-users-table td:first-child {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.admin-users-table {
    font-size: 11px;
}

.admin-users-table td:last-child,
.admin-users-table th:last-child {
    padding-right: 0;
}

/* ===== Режим мини-приложения Telegram (.tg-app на <body>) =====
   В Телеграме уже есть своя панель сверху (аватар, крестик закрытия), поэтому
   шапку сайта делаем компактнее, а график занимает максимум высоты экрана. */
.tg-app .header {
    padding: 4px 10px;
    height: 40px;
}

/* В мини-приложении экран маленький — легенду с графика тоже убираем */
.tg-app .chart-legend,
.tg-app .mini-legend {
    display: none;
}

.tg-app .header .hdr-title {
    font-size: 11.5px;
    line-height: 1.15;
}

.tg-app .header p {
    display: none;
}

.tg-app .logo {
    width: 20px;
    height: 20px;
}

.tg-app .header-left {
    gap: 8px;
}

/* Кнопка входа скрыта до входа (скрипт ставит hidden), а после входа она становится
   входом в кабинет: настройки, подписка и список инструментов для оповещений. */
.tg-app #account-btn[hidden] {
    display: none;
}

.tg-app #account-btn.tg-cabinet-btn {
    display: inline-flex;
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: 50%;
}

.tg-app #account-btn.tg-cabinet-btn .btn-account-text {
    display: none;
}

.tg-app #account-btn.tg-cabinet-btn .btn-account-icon {
    display: block;
}

.tg-app #build-btn {
    display: none;
}

.tg-app .sidebar {
    padding: 8px;
}

.tg-app .control-group {
    margin-bottom: 8px;
}

.tg-app .chart-container,
.tg-app #chart {
    min-height: 0;
}

/* Узкие экраны Telegram (проверено на ширине 390px) — убираем отступы вокруг графика */
@media (max-width: 360px) {
    .header .hdr-title { font-size: 11px; }
    .header-left { gap: 6px; }
    .header { padding: 8px 10px; }
}

@media (max-width: 480px) {
    .tg-app .main {
        gap: 0;
    }

    .tg-app .header {
        height: auto;
        min-height: 36px;
        padding: 3px 8px;
    }

    /* Две строки названия: высоту шапке добавляем ровно под них, поэтому
       height заменён на min-height — иначе вторая строка обрезалась. */
    .tg-app .header .hdr-title {
        font-size: 11.5px;
        line-height: 1.15;
    }
}

/* ---------- Экран оплаты подписки ---------- */
.billing-pay-box {
    margin: 14px 0;
    padding: 14px 16px;
    border: 1px solid rgba(148, 163, 184, 0.28);
    border-radius: 12px;
    background: rgba(34, 197, 94, 0.06);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.billing-pay-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    font-weight: 600;
}

.billing-pay-amount {
    font-size: 1.15rem;
    white-space: nowrap;
}

.billing-pay-box .btn {
    align-self: flex-start;
    text-decoration: none;
}

.billing-autopay,
.admin-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.admin-check {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 8px 0;
    font-size: 0.92rem;
    cursor: pointer;
}

/* Готовый текст письма в служебной вкладке: показываем ровно так, как
   он уйдёт людям — с переносами строк и без вольной вёрстки браузера. */
.admin-pre {
    margin: 8px 0;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface-2);
    color: var(--text);
    font: inherit;
    font-size: 0.9rem;
    line-height: 1.45;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.admin-pre[hidden] {
    display: none;
}

.billing-autopay input,
.admin-check input {
    width: 16px;
    height: 16px;
    flex: none;
}

.billing-pay-box[hidden],
.billing-autopay[hidden] {
    display: none;
}

/* Скидка на первый месяц в кабинете */
.billing-promo {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin: 10px 0;
    padding: 12px 14px;
    border: 1px solid var(--accent, #2dd4bf);
    border-radius: 10px;
    background: rgba(45, 212, 191, 0.08);
}
.billing-promo[hidden] { display: none; }
.billing-promo-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.billing-promo .btn { flex: 0 0 auto; }
#billing-trial-note[hidden] { display: none; }

/* Таблица пробных периодов: переносим текст, чтобы кнопка отзыва была видна */
#admin-trials-table { width: 100%; table-layout: fixed; }
#admin-trials-table th,
#admin-trials-table td {
    white-space: normal;
    word-break: break-word;
    font-size: 12px;
    vertical-align: top;
}
#admin-trials-table th:nth-child(1), #admin-trials-table td:nth-child(1) { width: 12%; }
#admin-trials-table th:nth-child(2), #admin-trials-table td:nth-child(2) { width: 16%; }
#admin-trials-table th:nth-child(3), #admin-trials-table td:nth-child(3) { width: 20%; }
#admin-trials-table th:nth-child(4), #admin-trials-table td:nth-child(4) { width: 14%; }
#admin-trials-table th:nth-child(5), #admin-trials-table td:nth-child(5) { width: 20%; }
#admin-trials-table th:nth-child(6), #admin-trials-table td:nth-child(6) { width: 18%; }
#admin-trials-table td:nth-child(6) .btn { white-space: nowrap; padding: 6px 10px; }

/* ===== Инструкция в служебной вкладке ===== */
.owner-guide {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin-bottom: 16px;
}

.owner-guide > summary {
    cursor: pointer;
    padding: 12px 14px;
    font-weight: 600;
    font-size: 14px;
    list-style: none;
}

.owner-guide > summary::-webkit-details-marker { display: none; }

.owner-guide > summary::before {
    content: "▸ ";
    color: var(--text-muted);
}

.owner-guide[open] > summary::before { content: "▾ "; }

.owner-guide-body {
    padding: 0 14px 14px;
    font-size: 13.5px;
    line-height: 1.6;
    color: var(--text);
}

.owner-guide-body .lead { color: var(--text-muted); margin-bottom: 12px; }
.owner-guide-body h3 { font-size: 13.5px; margin: 16px 0 6px; }
.owner-guide-body p { margin-bottom: 10px; }
.owner-guide-body ul,
.owner-guide-body ol { margin: 0 0 12px 20px; }
.owner-guide-body li { margin-bottom: 5px; }
.owner-guide-body .tw { overflow-x: auto; margin-bottom: 12px; }
.owner-guide-body table { border-collapse: collapse; width: 100%; font-size: 13px; }
.owner-guide-body th,
.owner-guide-body td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.owner-guide-body th { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-faint); }
.owner-guide-body tbody tr:last-child td { border-bottom: 0; }
.owner-guide-body td:first-child { font-weight: 560; }
.owner-guide-body .note {
    padding: 10px 12px;
    border-left: 3px solid var(--green);
    background: var(--surface-3);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    margin-bottom: 12px;
}

/* ===== Плашка о сроке подписки в кабинете ===== */
.sub-notice {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    margin-bottom: 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface-2);
    font-size: 13px;
    line-height: 1.45;
}

.sub-notice-text {
    flex: 1;
    min-width: 0;
    color: var(--text);
}

/* .btn задаёт ширину 100% — внутри плашки кнопка должна быть по тексту,
   иначе она отжимает надпись и та ломается по одному слову на строку. */
.sub-notice .btn-small {
    width: auto;
    flex: 0 0 auto;
    white-space: nowrap;
    padding: 6px 14px;
    font-size: 12px;
}

/* Спокойное напоминание — просто факт, без тревоги */
.sub-notice[data-level="info"] {
    border-color: rgba(59, 130, 246, 0.35);
    background: rgba(59, 130, 246, 0.08);
}

/* Срок подходит к концу — нужно внимание */
.sub-notice[data-level="warn"] {
    border-color: rgba(255, 165, 0, 0.45);
    background: rgba(255, 165, 0, 0.1);
}

/* Уже закончилась — самое заметное состояние */
.sub-notice[data-level="alert"] {
    border-color: rgba(239, 83, 80, 0.45);
    background: rgba(239, 83, 80, 0.1);
}

@media (max-width: 560px) {
    .sub-notice {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .sub-notice .btn-small {
        width: 100%;
        flex: 0 0 auto;
    }
}

/* ===== Подвал с реквизитами =====
   Требование платёжного сервиса: реквизиты продавца, контакты и ссылки на
   оферту видны на сайте и не спрятаны. Полоса тонкая, чтобы не отнимать
   место у графика; на узком экране переносится в две строки. */
.site-legal {
    flex: 0 0 auto;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 14px;
    padding: 7px 14px;
    border-top: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    font-size: 11.5px;
    line-height: 1.5;
}
.site-legal-links,
.site-legal-contacts {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 4px 12px;
}
.site-legal a {
    color: var(--text-muted);
    text-decoration: none;
    border-bottom: 1px dotted var(--border);
}
.site-legal a:hover { color: var(--text); border-bottom-color: var(--text-faint); }
.site-legal-req { color: var(--text); }

/* Обёртка нужна только телефону, где подвал сворачивается. На большом экране
   display: contents делает её прозрачной — раскладка подвала прежняя. */
.site-legal-body { display: contents; }
/* Две строки свежести данных в окне «Откуда котировки» */
.csp-fresh {
    margin-bottom: 6px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
    font-size: 11.5px;
    color: var(--text-muted);
}
.csp-fresh[hidden] { display: none; }
.site-legal-toggle { display: none; }

/* ===== Телефон: тикер в шапке вместо названия сервиса =====
   Скрываем только на широком экране: правила для телефона стоят выше по файлу,
   и глобальное display: none их перебивало бы. */
@media (min-width: 861px) {
    .head-ticker { display: none; }
    /* Карандаш прежде прятали на широком экране: панель рисования там стояла
       сбоку всегда, и кнопка была не нужна. Теперь панель спрятана и в
       браузере, поэтому кнопка нужна на любой ширине. */
}

@media (max-width: 720px) {
    /* На телефоне подвал сжат до трёх коротких строк мелким кеглем: реквизиты
       и контакты обязаны остаться видимыми, но графику нужно место. */
    .site-legal {
        gap: 0 8px;
        padding: 4px 10px 5px;
        font-size: 9.5px;
        line-height: 1.35;
    }
    .site-legal a { border-bottom: none; text-decoration: underline; text-decoration-style: dotted; }
    .site-legal-links { order: 1; width: 100%; }
    .site-legal-contacts { order: 2; width: 100%; }
    .site-legal-req { order: 3; width: 100%; }

    /* Свёрнутый подвал: одна строка вместо десяти ссылок и реквизитов */
    .site-legal { flex-direction: column; align-items: stretch; }
    .site-legal-toggle {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
        width: 100%;
        padding: 3px 0;
        border: none;
        background: none;
        color: var(--text-muted);
        font-size: 10.5px;
        cursor: pointer;
    }
    .site-legal-caret { transition: transform 150ms ease; }
    .site-legal-toggle[aria-expanded="true"] .site-legal-caret { transform: rotate(180deg); }
    .site-legal-body {
        display: flex;
        flex-direction: column;
        gap: 3px;
        padding-top: 3px;
    }
    .site-legal-body[hidden] { display: none; }
}

/* Строка условий над кнопкой оплаты */
.billing-legal { margin-top: 10px; line-height: 1.6; }
.billing-legal a { color: var(--primary); text-decoration: none; border-bottom: 1px dotted currentColor; }

/* Уровни инструментов на вкладке «Администратор» */
.admin-details {
    margin-top: 12px;
}

.admin-details > summary {
    cursor: pointer;
    font-weight: 600;
    padding: 6px 0;
}

/* Свёрнутый служебный блок: заголовок выглядит как <h3> раздела, но у него
   есть галочка открытия и закрытия — иначе вкладка растягивается на экраны. */
.admin-fold {
    margin-top: 0;
}

.admin-fold > summary {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    padding: 0;
    margin-bottom: 8px;
}

.admin-fold[open] > summary {
    color: var(--text);
}

.admin-levels-versions {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 8px;
    font-size: 13px;
}

.admin-levels-version {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    justify-content: space-between;
    padding: 6px 8px;
    border: 1px solid var(--border, #2a3140);
    border-radius: 8px;
}

.admin-levels-table {
    margin-top: 8px;
    font-size: 13px;
}

.admin-levels-table td {
    white-space: nowrap;
}

.levels-ticker {
    opacity: 0.65;
}

/* Редактор уровней инструментов (служебная вкладка) */
.admin-levels-form {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px;
    margin: 10px 0 14px;
    background: var(--surface-2, rgba(127, 127, 127, .06));
}
.admin-levels-period { margin: 10px 0; }
.admin-levels-period > label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 4px;
}
.admin-levels-cells {
    display: grid;
    grid-template-columns: repeat(8, minmax(0, 1fr));
    gap: 6px;
}
.admin-levels-cell {
    width: 100%;
    min-width: 0;
    padding: 6px 8px;
    font-size: 13px;
    font-variant-numeric: tabular-nums;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
}
.admin-levels-editor-list { margin-top: 8px; }
.admin-levels-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}
.admin-levels-row:last-of-type { border-bottom: 0; }
@media (max-width: 640px) {
    .admin-levels-cells { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .admin-levels-row { flex-wrap: wrap; }
}

/* ---- Оповещения от сервера: общий список бумаг и свои алерты ---- */
.watch-block {
    margin-top: 16px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface-2, rgba(255, 255, 255, 0.02));
}
.watch-title {
    margin: 0 0 6px;
    font-size: 14px;
    font-weight: 600;
}
.custom-alert-form {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin: 10px 0;
}
.custom-alert-form select,
.custom-alert-form input[type="number"],
.custom-alert-form input[type="text"] {
    flex: 1 1 140px;
    min-width: 110px;
}
.custom-alert-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.custom-alert-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 13px;
}
.custom-alert-row.off { opacity: 0.6; }
/* Волна 145 (19.10.2026): сервер не следит за своими алертами — плашка над списком */
.alerts-watch-off {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    padding: 8px 10px;
    margin-bottom: 8px;
    border: 1px solid rgba(217, 119, 6, 0.45);
    background: rgba(245, 158, 11, 0.12);
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.4;
    color: var(--text);
}
.alerts-watch-off .btn { flex: 0 0 auto; }
/* Кнопки строки не должны растягиваться на всю ширину: текст алерта важнее */
.custom-alert-row .btn,
.custom-alert-form .btn {
    flex: 0 0 auto;
    width: auto;
}
.custom-alert-row span { flex: 1 1 200px; }
.admin-watch-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 14px;
    max-height: 260px;
    overflow-y: auto;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
}
.admin-watch-list .checkbox-label { flex: 0 1 220px; font-size: 13px; }
@media (max-width: 640px) {
    .custom-alert-form select,
    .custom-alert-form input { flex: 1 1 100%; }
    .admin-watch-list .checkbox-label { flex: 1 1 100%; }
}


/* Несколько графиков рядом — только браузер на большом экране */
@media (max-width: 860px) {
    .chart-grid { grid-template-columns: 1fr !important; grid-template-rows: 1fr !important; }
}

.tg-app .chart-grid { grid-template-columns: 1fr !important; grid-template-rows: 1fr !important; }

/* В тесной сетке легенда остаётся, но становится короткой строкой:
   вместо «Часовые» — «1ч», заголовок и длинный текст про зоны убираются */
.chart-grid[data-layout="2"] #chart > .chart-legend,
.chart-grid[data-layout="4"] #chart > .chart-legend {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 2px 7px;
    bottom: 24px;
    left: 8px;
    padding: 2px 6px;
    max-width: calc(100% - 100px);
    opacity: 0.9;
}

.chart-grid[data-layout="2"] .chart-legend .legend-head,
.chart-grid[data-layout="4"] .chart-legend .legend-head,
.chart-grid[data-layout="2"] .chart-legend .legend-full,
.chart-grid[data-layout="4"] .chart-legend .legend-full {
    display: none;
}

.chart-grid[data-layout="2"] .chart-legend .legend-short,
.chart-grid[data-layout="4"] .chart-legend .legend-short {
    display: inline;
}

.chart-grid[data-layout="2"] .chart-legend .legend-zone,
.chart-grid[data-layout="4"] .chart-legend .legend-zone {
    max-width: none;
    margin-top: 0;
    align-items: center;
}

.chart-grid[data-layout="4"] #chart > .chart-legend .legend-item {
    font-size: 9px;
}

/* В сетке 2 и 4 графиков подробная строка под названием не влезает — прячем,
   всё это видно в боковой панели */
.chart-grid[data-layout="2"] .chart-title-meta,
.chart-grid[data-layout="4"] .chart-title-meta {
    display: none;
}

/* ===== Дополнительный график: свои настройки и рисование ===== */
.mini-head .mini-btn {
    flex: 0 0 auto;
    width: 24px;
    height: 24px;
    min-height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg);
    color: var(--text-muted);
    cursor: pointer;
}

.mini-head .mini-btn svg {
    width: 14px;
    height: 14px;
}

.mini-head .mini-btn:hover {
    color: var(--text);
}

.mini-head .mini-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

/* Окошко настроек панели */
.mini-opts {
    position: absolute;
    top: 32px;
    right: 6px;
    z-index: 20;
    width: 226px;
    max-height: calc(100% - 44px);
    overflow-y: auto;
    padding: 8px 9px 9px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.22);
    font-size: 11px;
    color: var(--text);
}

.mini-opts-own {
    display: flex;
    align-items: center;
    gap: 5px;
    font-weight: 600;
    cursor: pointer;
    margin-bottom: 6px;
}

.mini-opts-body.off {
    opacity: 0.5;
}

.mini-opts-label {
    color: var(--text-muted);
}

.mini-opts-periods {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin: 3px 0 7px;
}

.mini-opts-check {
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
}

.mini-opts-check input {
    margin: 0;
}

/* Пояснение в окошке настроек панели, когда включена «скрепка» */
.mini-opts-hint {
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.3;
    margin-bottom: 6px;
}

/* Галочка индикатора объёма стоит отдельной строкой под остальными настройками */
.mini-opts-volume {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
}

.mini-opts-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex: 0 0 auto;
}

.mini-opts-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    margin-bottom: 5px;
}

.mini-opts-select {
    flex: 0 0 auto;
    width: 104px;
    height: 24px;
    min-height: 24px;
    padding: 0 4px;
    font-size: 11px;
    border-radius: 4px;
}

.mini-opts-close {
    width: 100%;
    margin-top: 3px;
    padding: 5px 0;
    font-size: 11px;
    border: none;
    border-radius: 5px;
    background: var(--primary);
    color: #fff;
    cursor: pointer;
}

/* Панель рисования внутри дополнительного графика — компактнее главной */
.draw-panel.mini-draw {
    padding: 3px;
    gap: 1px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.18);
}

/* Сбоку панель прижимаем к левому краю, сверху и снизу — оставляем по центру */
.draw-panel.mini-draw.pos-side {
    left: 6px;
}

.draw-panel.mini-draw .draw-tool {
    width: 22px;
    height: 22px;
    border-radius: 5px;
}

.draw-panel.mini-draw .draw-tool svg {
    width: 13px;
    height: 13px;
}

.draw-panel.mini-draw .draw-swatch {
    width: 11px;
    height: 11px;
}

.draw-panel.mini-draw.pos-top { top: 24px; }
.draw-panel.mini-draw.pos-bottom { bottom: 26px; }

/* Кнопка перехода на график из отчёта о правке уровней */
.levels-show-btn {
    display: block;
    margin-top: 6px;
}

/* Проверка автоматического расчёта: подсветка расхождений с таблицей */
.levels-diff-bad {
    background: rgba(214, 69, 69, 0.14);
    color: var(--text);
    font-weight: 600;
}
.levels-diff-row td:first-child {
    border-left: 3px solid rgba(214, 69, 69, 0.75);
}
.admin-diff-cell {
    max-width: 17rem;
    white-space: normal;
    word-break: break-word;
    vertical-align: top;
}
.admin-diff-cell .hint { display: block; line-height: 1.35; }
.admin-step-digits,
.admin-step-value {
    width: 7rem;
    max-width: 100%;
}

/* Кнопка быстрого создания своего алерта — поверх графика, видна и на телефоне */
.quick-alert-btn {
    position: absolute;
    right: 14px;
    bottom: 16px;
    z-index: 6;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 13px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--text);
    font: inherit;
    font-size: 0.86rem;
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.28);
}
.quick-alert-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}
.quick-alert-btn svg { width: 17px; height: 17px; }
.quick-alert-btn[hidden] { display: none; }
@media (max-width: 760px) {
    .quick-alert-btn {
        right: 10px;
        /* поднимаем над панелью рисования, иначе она закрывает кнопку */
        bottom: 76px;
        padding: 9px 14px;
    }
    .quick-alert-btn span { display: none; }
}
/* Подсветка формы, когда её открыли кнопкой у графика */
.custom-alert-highlight {
    outline: 2px solid var(--primary);
    outline-offset: 4px;
    border-radius: 8px;
}

/* Уровни из терминала MetaTrader в служебной вкладке. */
.admin-tas-row {
    margin: 10px 0 14px;
    padding: 10px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.admin-tas-row p {
    margin: 0 0 4px;
    font-size: 13px;
}

/* Правка выгрузки: добавить, изменить или убрать инструмент. */
.admin-tas-editor {
    margin: 12px 0;
    padding: 12px;
    background: var(--surface-2);
    border: 1px solid var(--accent);
    border-radius: var(--radius-sm);
}

.admin-tas-editor h4 {
    margin: 0 0 6px;
    font-size: 14px;
}

.admin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 8px;
    margin: 8px 0;
}

.admin-grid label,
.admin-tas-level label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 13px;
}

.admin-tas-level {
    margin: 6px 0;
}

.admin-tas-off {
    opacity: 0.6;
}

.admin-tas-row .admin-actions {
    margin-top: 6px;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    margin-top: 6px;
}

.admin-table th,
.admin-table td {
    padding: 4px 6px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

.admin-table th {
    color: var(--text-muted);
    font-weight: 500;
    white-space: nowrap;
}

.admin-table td:last-child {
    font-variant-numeric: tabular-nums;
    word-break: break-word;
}

@media (max-width: 640px) {
    .admin-table {
        font-size: 11px;
    }
}

/* ===== Обозреватель бумаг ===== */
/* Родной список остаётся в разметке хранителем значения, но не виден */
.inst-native {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    border: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.inst-open {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 13px;
    padding: 9px 10px;
    cursor: pointer;
    text-align: left;
    transition: border-color var(--transition);
}

.inst-open:hover {
    border-color: #22c55e;
}

.inst-open-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.inst-open-caret {
    color: var(--text-muted);
    font-size: 11px;
}

.inst-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 95;
    padding: 16px;
}

.inst-overlay[hidden] {
    display: none;
}

.inst-box {
    --inst-pad: 14px;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    width: 100%;
    max-width: 520px;
    max-height: min(80vh, 640px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
    overflow: hidden;
}

.inst-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: var(--inst-pad);
    border-bottom: 1px solid var(--border);
}

.inst-search {
    flex: 1;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 14px;
    padding: 9px 11px;
}

.inst-search:focus {
    outline: none;
    border-color: #22c55e;
}

.inst-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px var(--inst-pad) 0;
}

.inst-chip {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--text-muted);
    font-family: var(--font-body);
    font-size: 12px;
    padding: 5px 11px;
    cursor: pointer;
    white-space: nowrap;
    transition: all var(--transition);
}

.inst-chip:hover {
    color: var(--text);
}

.inst-chip.active {
    background: rgba(34, 197, 94, 0.14);
    border-color: rgba(34, 197, 94, 0.5);
    color: #22c55e;
}

.inst-chip-num {
    opacity: 0.65;
    margin-left: 4px;
}

.inst-toolrow {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px var(--inst-pad);
}

.inst-count {
    flex: 1;
    color: var(--text-muted);
    font-size: 12px;
    white-space: nowrap;
}

.inst-sort-label {
    color: var(--text-muted);
    font-size: 12px;
}

.inst-sort {
    flex: none;
    max-width: 190px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 12px;
    padding: 5px 7px;
}

.inst-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 var(--inst-pad) 4px;
    -webkit-overflow-scrolling: touch;
}

.inst-group {
    position: sticky;
    top: 0;
    background: var(--surface);
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 8px 2px 4px;
    z-index: 1;
}

.inst-row {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    padding: 8px 6px;
    cursor: pointer;
    text-align: left;
    color: var(--text);
    font-family: var(--font-body);
}

.inst-row:hover,
.inst-row.is-cursor {
    background: var(--surface-2);
}

.inst-row.is-current {
    background: rgba(34, 197, 94, 0.12);
}

.inst-star {
    flex: none;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 50%;
    color: var(--text-muted);
    font-size: 15px;
    cursor: pointer;
    padding: 0;
}

.inst-star:hover {
    color: #eab308;
    background: var(--surface-2);
}

.inst-star.is-on {
    color: #eab308;
}

.inst-main {
    flex: 1;
    min-width: 0;
}

.inst-name {
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.inst-sub {
    color: var(--text-muted);
    font-size: 11px;
    display: flex;
    gap: 6px;
    align-items: center;
}

.inst-lock {
    flex: none;
    color: var(--text-muted);
    font-size: 12px;
}

.inst-alerts {
    flex: none;
    color: #22c55e;
    font-size: 11px;
}

.inst-more {
    flex: none;
    width: 26px;
    height: 26px;
    background: transparent;
    border: none;
    border-radius: 50%;
    color: var(--text-muted);
    font-size: 15px;
    cursor: pointer;
    padding: 0;
}

.inst-more:hover {
    color: var(--text);
    background: var(--surface-2);
}

.inst-picker {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin: 2px 6px 8px;
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.inst-picker-title {
    color: var(--text-muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.inst-picker label {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 13px;
    cursor: pointer;
}

.inst-empty {
    color: var(--text-muted);
    font-size: 13px;
    padding: 18px 6px;
    text-align: center;
}

.inst-foot {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    border-top: 1px solid var(--border);
    padding: 10px var(--inst-pad);
    color: var(--text-muted);
    font-size: 12px;
}

.inst-foot-note {
    flex: 1;
    min-width: 140px;
}

.inst-foot .btn-small {
    flex: none;
    font-size: 12px;
    padding: 6px 10px;
}

.inst-picker .hint {
    font-size: 12px;
    margin: 0;
}

@media (max-width: 640px) {
    .inst-overlay {
        align-items: flex-end;
        padding: 0;
    }

    .inst-box {
        max-width: 100%;
        max-height: 92dvh;
        border-radius: var(--radius-md) var(--radius-md) 0 0;
        border-bottom: none;
    }

    .inst-row {
        padding: 11px 6px;
    }

    .inst-star,
    .inst-more {
        width: 32px;
        height: 32px;
    }
}

/* ===== Быстрый алерт поверх графика ===== */
.qa-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 96;
    padding: 16px;
}

.qa-overlay[hidden] {
    display: none;
}

.qa-box {
    --qa-pad: 16px;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 400px;
    max-height: min(86vh, 700px);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
    overflow: hidden;
}

.qa-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px var(--qa-pad);
    border-bottom: 1px solid var(--border);
}

.qa-tabs {
    display: flex;
    gap: 6px;
    flex: 1;
}

.qa-tab {
    background: transparent;
    border: 1px solid transparent;
    border-radius: 999px;
    color: var(--text-muted);
    font-family: var(--font-body);
    font-size: 13px;
    padding: 6px 12px;
    cursor: pointer;
}

.qa-tab.active {
    background: rgba(34, 197, 94, 0.14);
    border-color: rgba(34, 197, 94, 0.5);
    color: #22c55e;
}

.qa-panel {
    padding: var(--qa-pad);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

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

.qa-field {
    margin-bottom: 12px;
}

.qa-field > label {
    display: block;
    color: var(--text-muted);
    font-size: 12px;
    margin-bottom: 5px;
}

.qa-field select,
.qa-field input[type="text"] {
    width: 100%;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 14px;
    padding: 9px 10px;
}

.qa-price-row {
    display: flex;
    gap: 6px;
}

.qa-price-row input {
    flex: 1;
    text-align: center;
    font-size: 17px !important;
    font-weight: 600;
}

.qa-step {
    flex: none;
    width: 42px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 18px;
    cursor: pointer;
}

.qa-step:hover {
    border-color: #22c55e;
    color: #22c55e;
}

.qa-hint {
    color: var(--text-muted);
    font-size: 11px;
    margin: 5px 0 0;
}

.qa-check {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    margin-bottom: 10px;
}

.qa-msg {
    font-size: 12px;
    margin: 0 0 10px;
    color: var(--text-muted);
    min-height: 16px;
}

.qa-msg.is-bad {
    color: #ef4444;
}

.qa-msg.is-good {
    color: #22c55e;
}

.qa-submit {
    width: 100%;
}

.qa-row {
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid var(--border);
    padding: 9px 0;
}

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

.qa-row.off {
    opacity: 0.55;
}

.qa-row-main {
    flex: 1;
    min-width: 0;
}

.qa-row-title {
    font-size: 13px;
}

.qa-row-sub {
    color: var(--text-muted);
    font-size: 11px;
}

.qa-row-btn {
    flex: none;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 12px;
    padding: 5px 8px;
    cursor: pointer;
}

.qa-row-btn:hover {
    color: var(--text);
    border-color: #22c55e;
}

@media (max-width: 640px) {
    .qa-overlay {
        align-items: flex-end;
        padding: 0;
        /* Окно алертов не доходит до самого низа: полоса с реквизитами и
           ссылками на тарифы должна оставаться видимой */
        bottom: calc(var(--legal-h, 0px) + env(safe-area-inset-bottom, 0px));
    }

    .qa-box {
        max-width: 100%;
        max-height: 84dvh;
        border-radius: var(--radius-md) var(--radius-md) 0 0;
        border-bottom: none;
    }

    .qa-step {
        width: 48px;
        height: 44px;
    }
}

/* ===== Полоса рабочего списка ===== */
/* Перебор бумаг своего списка — частое действие, поэтому оно вынесено из
   обозревателя: полоса всегда над графиком, одно нажатие меняет бумагу. */
.list-strip {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    min-width: 0;
}

.strip-list {
    flex: 0 0 auto;
    max-width: 190px;
    height: 26px;
    padding: 0 6px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--text);
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
}

.strip-arrow,
.strip-more {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 26px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--text-muted);
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
    transition: color var(--transition), border-color var(--transition);
}

.strip-arrow:hover,
.strip-more:hover {
    color: var(--text);
    border-color: var(--primary);
}

.strip-arrow:disabled {
    opacity: 0.4;
    cursor: default;
}

.strip-items {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    gap: 4px;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    min-width: 0;
}

.strip-items::-webkit-scrollbar {
    display: none;
}

.strip-chip {
    flex: 0 0 auto;
    height: 26px;
    padding: 0 9px;
    border: 1px solid var(--border);
    border-radius: 13px;
    background: var(--surface-2);
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 600;
    font-family: var(--font-mono);
    white-space: nowrap;
    cursor: pointer;
    transition: background var(--transition), color var(--transition), border-color var(--transition);
}

.strip-chip:hover {
    color: var(--text);
    border-color: var(--primary);
}

.strip-chip.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.strip-chip .strip-chip-mark {
    margin-left: 4px;
    font-family: var(--font-body);
    font-size: 10px;
}

.strip-empty {
    color: var(--text-faint);
    font-size: 12px;
    white-space: nowrap;
}

/* Столбик списка в левой панели: там есть место на названия бумаг */
.side-strip {
    margin-top: 6px;
    max-height: 216px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
}

.side-strip:empty {
    display: none;
}

.side-row {
    display: flex;
    align-items: baseline;
    gap: 6px;
    width: 100%;
    padding: 5px 8px;
    border: none;
    border-bottom: 1px solid var(--border);
    background: transparent;
    color: var(--text);
    font-size: 12px;
    font-family: inherit;
    text-align: left;
    cursor: pointer;
}

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

.side-row:hover {
    background: var(--surface-3);
}

.side-row.active {
    background: var(--primary);
    color: #fff;
}

.side-row-name {
    flex: 1 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.side-row-ticker {
    flex: 0 0 auto;
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-muted);
}

.side-row.active .side-row-ticker {
    color: rgba(255, 255, 255, 0.85);
}

@media (max-width: 640px) {
    .list-strip {
        padding: 4px 6px;
        gap: 4px;
    }

    .strip-list {
        max-width: 120px;
        font-size: 11px;
    }

    /* На узком экране стрелки лишние: полоса и так прокручивается пальцем */
    .strip-arrow {
        display: none;
    }
}

/* ===== Панель масштаба в дополнительном графике ===== */
/* Та же полоса, что на главном графике, только компактнее: в панели мало места,
   поэтому кнопки мельче и стоят в правом верхнем углу. */
.mini-toolbar {
    position: absolute;
    top: 3px;
    right: 46px;
    z-index: 9;
    display: flex;
    gap: 1px;
    padding: 1px;
    border: 1px solid var(--border);
    border-radius: 5px;
    background: var(--surface);
    opacity: 0.85;
    transition: opacity var(--transition);
}

.mini-panel:hover .mini-toolbar,
.mini-toolbar:focus-within {
    opacity: 1;
}

.mini-toolbar-btn {
    padding: 2px 5px;
    border: none;
    border-radius: 3px;
    background: transparent;
    color: var(--text-muted);
    font-size: 10px;
    font-family: var(--font-body);
    line-height: 1.2;
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
}

.mini-toolbar-btn:hover {
    background: var(--surface-3);
    color: var(--text);
}

.mini-toolbar-btn.active {
    background: var(--primary);
    color: #fff;
}

/* Четыре графика: панель ещё компактнее, чтобы не наезжать на название */
.chart-grid[data-layout="4"] .mini-toolbar {
    right: 40px;
    opacity: 0.8;
}

.chart-grid[data-layout="4"] .mini-toolbar-btn {
    padding: 2px 4px;
    font-size: 10px;
}

@media (max-width: 640px) {
    .mini-toolbar {
        opacity: 1;
        right: 40px;
    }
}

/* ===== Окно «Скрепка — своя раскладка» ===== */
.link-box {
    max-width: 620px;
}

.link-use {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    cursor: pointer;
    margin-bottom: 6px;
}

.link-use input {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
    accent-color: var(--primary);
}

.link-tabs {
    display: flex;
    gap: 6px;
    margin: 10px 0;
}

.link-tab {
    flex: 1;
    padding: 7px 10px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
}

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

.link-tab.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.link-slot {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 10px 10px;
    margin-bottom: 8px;
    background: var(--surface-2);
}

.link-slot-head {
    font-size: 12px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
}

.link-slot-head span {
    font-weight: 400;
    color: var(--text-muted);
}

.link-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 6px 10px;
}

.link-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    font-size: 11px;
    color: var(--text-muted);
}

.link-row select {
    flex: 1;
    min-width: 0;
    max-width: 96px;
    padding: 3px 4px;
    font-size: 11px;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.link-periods {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 10px;
    margin-top: 7px;
}

.link-check {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: var(--text);
    cursor: pointer;
}

.link-check input {
    width: 13px;
    height: 13px;
    accent-color: var(--primary);
}

.link-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

#link-slots.off {
    opacity: 0.45;
    pointer-events: none;
}

.link-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 4px;
}

@media (max-width: 640px) {
    .link-actions {
        flex-wrap: wrap;
    }
}

/* Выбор режима: по каким бумагам сервер шлёт оповещения */
#watch-mode {
    width: 100%;
    margin-bottom: 4px;
}

#watch-mode-hint {
    margin-bottom: 4px;
}

/* Кнопки «Добавить» и «Из избранного» — одной строкой */
.tg-watch-add-row .btn-small {
    flex: 1 1 auto;
    min-width: 120px;
}

/* ===== Статусы своих алертов: активен, сработал, на паузе, истёк, отменён ===== */
.alert-badge {
    display: inline-block;
    flex: none;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 1px 8px;
    font-size: 11px;
    line-height: 17px;
    white-space: nowrap;
    color: var(--text-muted);
    background: var(--surface-2);
}

.alert-badge-active {
    color: var(--green);
    border-color: color-mix(in srgb, var(--green) 45%, transparent);
    background: color-mix(in srgb, var(--green) 12%, transparent);
}

.alert-badge-triggered {
    color: var(--primary);
    border-color: color-mix(in srgb, var(--primary) 45%, transparent);
    background: color-mix(in srgb, var(--primary) 12%, transparent);
}

.alert-badge-expired,
.alert-badge-cancelled {
    color: var(--text-faint);
}

.qa-row-status {
    display: block;
    margin: 2px 0;
}

.qa-row-fired {
    font-size: 11px;
    color: var(--text-muted);
}

.qa-row-link {
    background: none;
    border: none;
    padding: 0;
    font-size: 11px;
    color: var(--primary);
    cursor: pointer;
    text-decoration: underline;
}

.qa-row-hist .qa-row-main {
    padding-right: 4px;
}

.qa-row-mark {
    background: color-mix(in srgb, var(--primary) 8%, transparent);
}

/* Короткая форма алерта: тонкие настройки спрятаны под «Дополнительно» */
.qa-more {
    border-top: 1px solid var(--border);
    margin-top: 10px;
    padding-top: 8px;
}

.qa-more > summary {
    cursor: pointer;
    font-size: 12px;
    color: var(--text-muted);
    list-style: none;
    padding: 4px 0;
}

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

.qa-more > summary::before {
    content: '▸ ';
}

.qa-more[open] > summary::before {
    content: '▾ ';
}

/* Строка алерта в кабинете: плашка статуса слева от текста */
.custom-alert-row .alert-badge {
    margin-right: 6px;
}

/* ===== Панель ближайших уровней =====
   Список уровней вокруг текущей цены: сколько до уровня, какой таймфрейм,
   сколько уровней рядом. По нажатию открывается карточка уровня с кнопкой
   «Поставить алерт сюда». Панель лежит поверх графика справа и закрывается
   крестиком, поэтому не отнимает место у свечей. */
.levels-panel-btn {
    position: absolute;
    right: 14px;
    bottom: 60px;
    /* выше слоя рисования (z-index: 8), иначе подписи цен видны сквозь панель */
    z-index: 12;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 13px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--text);
    font: inherit;
    font-size: 0.86rem;
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.28);
}
.levels-panel-btn:hover { border-color: var(--primary); color: var(--primary); }
.levels-panel-btn svg { width: 17px; height: 17px; }
.levels-panel-btn[hidden] { display: none; }
.levels-panel-btn[aria-expanded="true"] { border-color: var(--primary); color: var(--primary); }

.levels-panel {
    position: absolute;
    right: 14px;
    /* Отсчёт от низа полосы значков, а не от верха области графика. Панель
       лежит внутри той же области, что и полоса, и с фиксированным top: 14px
       накрывала её правый край: значки «Карта зон 8levels» и карандаш
       оставались видимыми, но нажатие уходило в панель — со стороны это
       выглядело как мёртвая кнопка. Высоту полосы пишет в --topbar-h код
       (она меняется от ширины окна: значки переносятся на вторую строку). */
    top: calc(var(--topbar-h, 0px) + 14px);
    bottom: 100px;
    width: 290px;
    max-width: calc(100% - 28px);
    z-index: 12;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
    box-shadow: 0 14px 40px rgba(0, 0, 0, 0.34);
    overflow: hidden;
}
.levels-panel[hidden] { display: none; }
.lp-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
    padding: 11px 12px 8px;
    border-bottom: 1px solid var(--border);
}
.lp-title b { display: block; font-size: 0.94rem; }
.lp-sub { display: block; margin-top: 2px; font-size: 0.76rem; color: var(--text-muted); }
/* Короткая пометка про скрытые значения в шапке панели «Уровни рядом».
   Курсор-подсказка несёт полный текст: в узкой шапке телефона длинная
   строка переносилась бы на три ряда и съедала первый экран списка. */
.lp-hidden-note {
    display: block;
    margin-top: 2px;
    font-size: 0.72rem;
    color: var(--warn, var(--text-muted));
    cursor: help;
}
.lp-close {
    border: 0; background: none; color: var(--text-muted);
    font-size: 0.95rem; cursor: pointer; padding: 2px 4px; line-height: 1;
}
.lp-close:hover { color: var(--text); }
.lp-sorts { display: flex; gap: 4px; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.lp-sort {
    flex: 1; padding: 5px 6px; border: 1px solid var(--border); border-radius: 8px;
    background: transparent; color: var(--text-muted); font: inherit; font-size: 0.74rem;
    cursor: pointer; white-space: nowrap;
}
.lp-sort:hover { color: var(--text); }
.lp-sort.active { background: var(--surface-2); border-color: var(--primary); color: var(--primary); }
.lp-list { flex: 1; overflow-y: auto; padding: 4px 0; }
.lp-row {
    display: grid;
    grid-template-columns: 9px 1fr auto;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 7px 12px;
    border: 0;
    border-left: 2px solid transparent;
    background: none;
    color: var(--text);
    font: inherit;
    text-align: left;
    cursor: pointer;
}
.lp-row:hover { background: var(--surface-2); }
.lp-row.active { background: var(--surface-2); border-left-color: var(--primary); }
.lp-dot { width: 9px; height: 9px; border-radius: 50%; }
.lp-price { font-size: 0.86rem; font-variant-numeric: tabular-nums; }
.lp-meta { display: block; font-size: 0.72rem; color: var(--text-muted); margin-top: 1px; }
.lp-dist { font-size: 0.78rem; font-variant-numeric: tabular-nums; color: var(--text-muted); }
.lp-dist.up { color: var(--danger, #ef4444); }
.lp-dist.down { color: var(--success, #22c55e); }
.lp-here {
    padding: 5px 12px; margin: 3px 0;
    font-size: 0.72rem; color: var(--primary);
    border-top: 1px dashed var(--border); border-bottom: 1px dashed var(--border);
    font-variant-numeric: tabular-nums;
}
.lp-card {
    border-top: 1px solid var(--border);
    padding: 10px 12px 12px;
    background: var(--surface-2);
}
.lp-card[hidden] { display: none; }
.lp-card-price { font-size: 1.02rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.lp-card-list { margin: 7px 0 9px; display: grid; gap: 3px; }
.lp-card-list div { display: flex; justify-content: space-between; gap: 10px; font-size: 0.77rem; }
.lp-card-list span:first-child { color: var(--text-muted); }
.lp-card-list span:last-child { font-variant-numeric: tabular-nums; }
.lp-card-btn {
    width: 100%; padding: 8px 10px; border: 0; border-radius: 9px;
    background: var(--primary); color: #fff; font: inherit; font-size: 0.83rem; cursor: pointer;
}
.lp-card-btn:hover { filter: brightness(1.06); }
.lp-foot { margin: 0; padding: 7px 12px; font-size: 0.71rem; color: var(--text-muted); border-top: 1px solid var(--border); }
.lp-empty { padding: 16px 12px; font-size: 0.8rem; color: var(--text-muted); text-align: center; }

/* ----- Ключевые уровни -----
   Две карточки на первом экране: ближайшая поддержка и ближайшее
   сопротивление. Цвет — только тонкая полоса слева: цветная заливка
   всей карточки на телефоне рябит и мешает читать цифры. */
.lp-key { padding: 10px 12px 4px; }
.lp-key-title {
    font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em;
    color: var(--text-muted);
}
.lp-key-price {
    margin-top: 2px; font-size: 0.78rem; color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}
.lp-kcard {
    margin-top: 8px; padding: 8px 10px;
    border: 1px solid var(--border); border-left-width: 3px; border-radius: 10px;
    background: var(--surface-2); cursor: pointer;
}
.lp-kcard:hover { border-color: var(--primary); }
.lp-kcard.sup { border-left-color: var(--green); }
.lp-kcard.res { border-left-color: var(--red); }
.lp-khead {
    display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
    font-size: 0.76rem; color: var(--text-muted);
}
.lp-ktf { font-size: 0.72rem; }
.lp-kprice {
    margin: 2px 0 6px; font-size: 1.02rem; font-weight: 600;
    font-variant-numeric: tabular-nums; white-space: nowrap;
}
.lp-krow { display: flex; justify-content: space-between; gap: 10px; font-size: 0.77rem; }
.lp-krow span:first-child { color: var(--text-muted); }
.lp-krow span:last-child { font-variant-numeric: tabular-nums; }
.lp-kempty {
    margin-top: 8px; padding: 8px 10px; border: 1px dashed var(--border); border-radius: 10px;
    font-size: 0.76rem; color: var(--text-muted);
}

/* Полный список лежит под складкой и растягивается только в раскрытом
   виде, иначе закрытая складка съедала бы всю высоту панели. */
.lp-all { display: flex; flex-direction: column; min-height: 0; }
/* min-height: 0 и overflow — не украшение: без них список внутри складки
   растёт за край панели и наезжает на подвал с числом уровней. */
.lp-all[open] { flex: 1; overflow: hidden; }
.lp-all > .lp-list { flex: 1; min-height: 0; overflow-y: auto; }

/* Список внутри раскрытой складки не прокручивался, и низ его уходил под
   подвал панели: свежие браузеры (Chrome 131 и новее) заворачивают
   содержимое <details> в скрытый блок ::details-content, и цепочка
   «панель → складка → список» рвалась на нём. Этот блок — обычный блочный
   контейнер по высоте содержимого, поэтому список получал всю нужную ему
   высоту, считал, что прокручивать нечего, и обрезался внешним overflow.
   Делаем обёртку такой же колонкой с нулевой минимальной высотой, как и
   остальные звенья, — тогда высоту задаёт панель, а лишнее прокручивается.
   В браузерах без ::details-content (Safari, старый Chrome) правило просто
   игнорируется: там содержимое лежит прямыми детьми складки и работает по
   правилам выше. */
.lp-all[open]::details-content {
    display: flex;
    flex-direction: column;
    min-height: 0;
    height: 100%;
    overflow: hidden;
}
.lp-all > summary {
    padding: 9px 12px; border-top: 1px solid var(--border);
    font-size: 0.78rem; color: var(--text-muted); cursor: pointer; user-select: none;
}
.lp-all > summary:hover { color: var(--text); }
.lp-all[open] > summary { color: var(--text); }

/* ===== Карта уровней 8levels =====
   Панель повторяет устройство «Уровней рядом» (тот же класс .levels-panel),
   но живёт по своим правилам: строк-кнопок здесь нет, потому что нажимать
   не на что — карточка уровня показывает расстояние до цены, а цены нет.
   Уровни идут группами по таймфреймам, сверху вниз, как линии на графике. */
.lm-warn {
    margin: 0;
    padding: 9px 12px;
    font-size: 0.74rem;
    line-height: 1.4;
    color: var(--text-muted);
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
}
.lm-warn[hidden] { display: none; }
/* Пометки в подвале: резервный набор и устаревшая разметка. Устаревание
   выделено цветом предупреждения — это единственное место, где человек
   узнает, что линии считались слишком давно. */
.lm-note { margin-top: 5px; line-height: 1.4; }
.lm-note-stale { color: var(--danger, #d64545); font-weight: 500; }
.lm-group { padding: 6px 0 2px; }
.lm-group + .lm-group { border-top: 1px solid var(--border); }
.lm-group-head {
    display: flex; align-items: center; gap: 7px;
    padding: 4px 12px 5px;
    font-size: 0.75rem; color: var(--text-muted);
}
.lm-group-head b { color: var(--text); font-size: 0.82rem; font-weight: 600; }
.lm-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.lm-values { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 10px; padding: 0 12px 7px; }
.lm-val { font-size: 0.85rem; font-variant-numeric: tabular-nums; }

@media (max-width: 760px) {
    .levels-panel-btn { right: 10px; bottom: 124px; padding: 9px 14px; }
    .levels-panel { left: 10px; right: 10px; top: 10px; bottom: 76px; width: auto; }
}

/* ===== Откуда котировки: плашка прямо на графике =====
   Раньше источник данных был виден только в кабинете, и человек не понимал,
   почему цена отличается от терминала. Плашка стоит в углу графика и
   по нажатию объясняет, что даёт свечи, что цену и какая задержка. */
.chart-source {
    position: absolute;
    left: 14px;
    bottom: 16px;
    z-index: 12;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: min(320px, calc(100% - 28px));
    padding: 5px 10px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--text-muted);
    font: inherit;
    font-size: 0.75rem;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.22);
}
.chart-source:hover { color: var(--text); border-color: var(--primary); }
/* На большом экране кнопка с подписью — значок не нужен */
.cs-glyph { display: none; }
.chart-source[hidden] { display: none; }
.cs-dot { width: 7px; height: 7px; border-radius: 50%; background: #22c55e; flex: none; }
.chart-source.warn .cs-dot { background: #f59e0b; }
.chart-source.off .cs-dot { background: #ef4444; }
.cs-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cs-q {
    flex: none; width: 14px; height: 14px; border-radius: 50%;
    border: 1px solid currentColor; font-size: 0.62rem; line-height: 12px; text-align: center;
    opacity: 0.75;
}

/* В браузере плашка источника дублировала полосу свежести и постоянно
   писала про MetaTrader, хотя агент живёт на отдельном компьютере.
   На большом экране прячем её: источник и так написан в чипе «Цена: …»,
   а окно «Откуда котировки» открывается нажатием на этот же чип.
   На телефоне и в Телеграме плашка остаётся — там она только значок в шапке. */
@media (min-width: 861px) {
    .chart-topbar .chart-source { display: none; }
    .data-fresh #df-price { cursor: pointer; }
    .data-fresh #df-price:hover { border-color: var(--primary); }
}

.chart-source-pop {
    position: absolute;
    left: 14px;
    bottom: 52px;
    z-index: 13;
    width: 300px;
    max-width: calc(100% - 28px);
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    box-shadow: 0 14px 40px rgba(0, 0, 0, 0.34);
    overflow: hidden;
}
.chart-source-pop[hidden] { display: none; }
.csp-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 12px 8px; border-bottom: 1px solid var(--border); font-size: 0.9rem;
}
.csp-close { border: 0; background: none; color: var(--text-muted); cursor: pointer; font-size: 0.9rem; line-height: 1; }
.csp-close:hover { color: var(--text); }
.csp-body { padding: 10px 12px; display: grid; gap: 7px; font-size: 0.79rem; }
.csp-row { display: flex; justify-content: space-between; gap: 12px; }
.csp-row span:first-child { color: var(--text-muted); flex: none; }
.csp-row span:last-child { text-align: right; }
.csp-note { color: var(--text-muted); line-height: 1.45; }
.csp-link {
    width: 100%; padding: 9px 10px; border: 0; border-top: 1px solid var(--border);
    background: none; color: var(--primary); font: inherit; font-size: 0.8rem; cursor: pointer;
}
.csp-link:hover { background: var(--surface-2); }

@media (max-width: 760px) {
    .chart-source { left: 10px; bottom: 76px; font-size: 0.72rem; max-width: calc(100% - 130px); }
    .chart-source-pop { left: 10px; right: 10px; width: auto; bottom: 112px; }
}

/* Подсветка блока настроек, к которому нас перебросили из пояснения об источнике */
.control-group.flash {
    animation: flash-block 1.6s ease;
    border-radius: 10px;
}
@keyframes flash-block {
    0%, 100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
    25% { box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.45); }
}

/* ===== Быстрый старт =====
   Новичок видит график, но не понимает, что с ним делать. Тур подсвечивает
   по одной кнопке за раз и объясняет её одним предложением. */
.tour-start {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    margin: 0 0 14px;
    padding: 10px 12px;
    border: 1px solid var(--primary);
    border-radius: 10px;
    background: color-mix(in srgb, var(--primary) 12%, transparent);
    color: var(--text);
    font: inherit;
    font-size: 0.85rem;
    cursor: pointer;
}
.tour-start:hover { background: color-mix(in srgb, var(--primary) 20%, transparent); }
.tour-start-icon { color: var(--primary); font-size: 0.7rem; }

.tour { position: fixed; inset: 0; z-index: 3000; }
.tour[hidden] { display: none; }
.tour-mask {
    position: fixed;
    background: rgba(3, 7, 12, 0.66);
    pointer-events: auto;
}
.tour-hole {
    position: fixed;
    border-radius: 12px;
    border: 2px solid var(--primary);
    box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.22);
    transition: all 0.2s ease;
    pointer-events: none;
}
.tour-hole[hidden] { display: none; }
.tour-card {
    position: fixed;
    width: 330px;
    max-width: calc(100vw - 24px);
    padding: 16px 18px 14px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
    box-shadow: 0 22px 60px rgba(0, 0, 0, 0.45);
}
.tour-step { color: var(--text-muted); font-size: 0.72rem; margin-bottom: 6px; }
.tour-title { margin: 0 0 6px; font-size: 1rem; }
.tour-text { margin: 0 0 14px; color: var(--text-muted); font-size: 0.85rem; line-height: 1.5; }
.tour-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.tour-nav { display: flex; gap: 8px; }
.tour-skip {
    border: 0; background: none; color: var(--text-muted); font: inherit; font-size: 0.8rem; cursor: pointer;
}
.tour-skip:hover { color: var(--text); }
.tour-back, .tour-next {
    padding: 8px 14px; border-radius: 9px; font: inherit; font-size: 0.82rem; cursor: pointer;
}
.tour-back { border: 1px solid var(--border); background: none; color: var(--text); }
.tour-back:hover { border-color: var(--primary); }
.tour-back[hidden] { display: none; }
.tour-next { border: 0; background: var(--primary); color: #04150c; font-weight: 600; }
.tour-next:hover { filter: brightness(1.08); }

@media (max-width: 760px) {
    .tour-card { width: auto; left: 12px; right: 12px; }
}

/* ===== Где держать панель уровней =====
   Поверх графика панель закрывала свечи, а в режимах 2 и 4 графиков закрывала
   целую панель. Поэтому по умолчанию она встаёт сбоку: область графиков
   ужимается на ширину панели, и ничего не перекрывается. Ужатие сделано
   отступом у .chart-area — панель лежит absolute в освободившейся полосе,
   а наблюдатель размера сам перерисовывает графики. */
.chart-area.lp-dock-right { padding-right: 306px; }
.chart-area.lp-dock-left { padding-left: 306px; }
.levels-panel.dock-left { left: 14px; right: auto; }
.levels-panel.dock-right { right: 14px; left: auto; }
.levels-panel.dock-float { box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45); }

/* Снизу — полосой во всю ширину под графиком. Так ширина остаётся у свечей:
   уровни сравнивают глазами с ценой, и узкий график мешает этому сильнее,
   чем невысокая полоса списка. Область графиков ужимается по высоте. */
.chart-area.lp-dock-bottom { padding-bottom: 258px; }
.levels-panel.dock-bottom {
    left: 14px;
    right: 14px;
    top: auto;
    bottom: 14px;
    width: auto;
    max-width: none;
    height: 238px;
}
/* В полосе снизу места по горизонтали много, а по вертикали мало: ключевые
   карточки встают рядом, а не друг под другом, и список получает всю высоту.
   Подпись и цена занимают только своё, растягиваются лишь сами карточки —
   иначе заголовок «Ключевые уровни» отбирал треть полосы. */
.levels-panel.dock-bottom .lp-key {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding-bottom: 8px;
}
.levels-panel.dock-bottom .lp-key-title,
.levels-panel.dock-bottom .lp-key-price { flex: none; }
.levels-panel.dock-bottom .lp-kcard { flex: 1; min-width: 220px; margin-top: 0; }
.levels-panel.dock-bottom .lp-list { min-height: 0; }

/* Раскрыли складку «Все уровни рядом» — полосе нужно вдвое больше высоты,
   иначе списку остаётся пара пикселей и прокрутка бессмысленна. Класс
   ставит код панели (отметитьСкладку), область ужимается на ту же величину. */
.chart-area.lp-dock-bottom.lp-bottom-tall { padding-bottom: 420px; }
.chart-area.lp-bottom-tall .levels-panel.dock-bottom { height: 400px; }
/* Место в полосе дороже подписей: с раскрытым списком ключевые карточки
   уходят — их уровни и так стоят первыми строками списка */
.levels-panel.dock-bottom.lp-open-all .lp-key { display: none; }

/* Кнопки в углах графика уводим из-под панели, чтобы не оказаться под ней */
.chart-area.lp-dock-right .levels-panel-btn,
.chart-area.lp-dock-right .quick-alert-btn { right: 320px; }
.chart-area.lp-dock-left .chart-source { left: 320px; }
.chart-area.lp-dock-left .chart-source-pop { left: 320px; }

.lp-head-btns { display: flex; align-items: center; gap: 2px; flex: none; }
.lp-dock {
    width: 22px; height: 22px; padding: 0;
    border: 1px solid transparent; border-radius: 6px;
    background: none; color: var(--text-muted);
    font: inherit; font-size: 0.8rem; line-height: 1; cursor: pointer;
}
.lp-dock:hover { color: var(--text); border-color: var(--border); }
.lp-dock.active { color: var(--primary); border-color: var(--primary); }

/* На узком экране места на две колонки нет: панель всегда лежит поверх графика,
   а переключатель положения прячем, чтобы не обманывать кнопками без действия */
@media (max-width: 1100px) {
    .chart-area.lp-dock-right { padding-right: 0; }
    .chart-area.lp-dock-left { padding-left: 0; }
    /* Стыковка «снизу» на узком экране тоже не нужна: там панель и так лист
       снизу, а высоту области считает подстроитьГрафикПодЛист() ниже */
    .chart-area.lp-dock-bottom,
    .chart-area.lp-dock-bottom.lp-bottom-tall { padding-bottom: 0; }
    .chart-area.lp-bottom-tall .levels-panel.dock-bottom,
    .levels-panel.dock-bottom { height: auto; }

    /* Лист «Уровни рядом» (и «Карта уровней») лежит поверх графика и накрывал
       его низ: под панелью прятались шкала времени и значок TradingView,
       который библиотека графиков ставит обязательной ссылкой на источник.
       Теперь область графиков ужимается снизу ровно на перекрытую часть —
       число считает подстроитьГрафикПодЛист() в app.js и кладёт в переменную. */
    .chart-area.lp-sheet { padding-bottom: var(--lp-sheet-h, 0px); }

    .chart-area.lp-dock-right .levels-panel-btn,
    .chart-area.lp-dock-right .quick-alert-btn { right: 14px; }
    .chart-area.lp-dock-left .chart-source,
    .chart-area.lp-dock-left .chart-source-pop { left: 14px; }
    .lp-dock { display: none; }
}

/* ===== Плашка источника переехала в верхнюю полосу =====
   В углу графика её закрывала легенда цветов, а в режимах 2 и 4 графиков
   легенда есть у каждого графика, и плашку было не видно совсем.
   В полосе над графиками место свободно и одинаково во всех режимах. */
.chart-topbar .chart-source {
    position: static;
    margin-left: auto;
    bottom: auto;
    left: auto;
    max-width: 260px;
    padding: 4px 9px;
    font-size: 11px;
    box-shadow: none;
}
/* Кнопка «во весь экран» прижимается вправо сама, только когда плашки нет */
.chart-topbar .chart-source:not([hidden]) ~ .topbar-icon-right { margin-left: 8px; }
.chart-topbar .chart-source .cs-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Пояснение раскрывается под плашкой, у правого края */
.chart-source-pop {
    top: 46px;
    right: 14px;
    left: auto;
    bottom: auto;
}
/* Панель уровней справа — сдвигаем пояснение из-под неё */
.chart-area.lp-dock-right .chart-source-pop { right: 320px; }
.chart-area.lp-dock-left .chart-source-pop { right: 14px; left: auto; }

@media (max-width: 700px) {
    .chart-topbar .chart-source { max-width: 150px; }
    .chart-source-pop { right: 10px; width: auto; left: 10px; }
    .chart-area.lp-dock-right .chart-source-pop { right: 10px; }
}

/* Узкая полоса на телефоне и в мини-приложении: только плашка источника */
.chart-topbar.topbar-min {
    padding: 4px 10px;
    justify-content: flex-start;
}
.chart-topbar.topbar-min .chart-source { margin-left: 0; }

/* ===== Кнопки действий переехали на полосу над графиками =====
   Пилюли «Уровни рядом» и «Свой алерт» стояли в правом нижнем углу графика и
   закрывали свечи, а в режимах 2 и 4 графиков — сразу нижний правый график.
   Теперь это значки в полосе: над свечами не висит ничего. */
.chart-topbar .topbar-act {
    position: static;
    right: auto;
    bottom: auto;
    margin: 0;
    padding: 0;
    box-shadow: none;
    border: 1px solid var(--border);
}
.chart-topbar .topbar-act svg { width: 17px; height: 17px; }
.chart-topbar .topbar-act:hover { border-color: var(--primary); color: var(--primary); }
/* Нажатая кнопка «без значений уровней» видна сразу: во время записи нужно
   одним взглядом понимать, скрыты цифры или нет. */
.chart-topbar .hide-values-btn.active {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--surface-2);
}
.chart-topbar .levels-panel-btn[aria-expanded="true"] {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--surface-2);
}

/* Панель уровней тянется до низа области: место под кнопки больше не нужно */
.levels-panel { bottom: 14px; }

/* На узкой полосе оставляем плашку источника и оба значка действий */
/* Кнопку панели рисования оставляем в узкой полосе: без неё панель не достать */
.chart-topbar.topbar-min > *:not(.chart-source):not(.topbar-act):not(.topbar-icon-draw):not(.topbar-timeframe):not(.data-fresh) { display: none; }
/* Таймфрейм остаётся и в узкой полосе: период свечей меняют чаще всего,
   а иначе за ним пришлось бы раскрывать все настройки */
.chart-topbar.topbar-min .topbar-timeframe { display: inline-flex; order: -1; }

/* ===== Режим официального виджета TradingView =====
   Рисование от руки в чужом окне не работает: линии наносит наш код
   по нашей ценовой шкале, а виджет её наружу не отдаёт. Показывать
   кнопку, которая ничего не сделает, хуже, чем её не показывать: человек
   решит, что сервис сломан.
   А вот раскладки 2 и 4 и скрепка здесь работают и из полосы больше не
   убираются: сетку окон строит наш код, а бумагу и таймфрейм каждой
   рамке задаёт её адрес — то же самое, что в главном окне. */
body.chart-widget .topbar-icon-draw,
body.chart-widget .mini-btn-draw,
body.chart-widget .draw-panel { display: none; }
/* Панели уровней в этом режиме живут складками под графиком, поэтому кнопки
   их открытия из полосы убираем: два способа открыть одно и то же место
   путают, а плавающая панель закрывала бы чужое окно графика */
body.chart-widget .levels-panel-btn,
body.chart-widget .levels-map-btn { display: none; }
/* Значки свежести ставим перед кнопкой источника, справа от рисования */
.chart-topbar.topbar-min .data-fresh { display: flex; margin-left: auto; }
.chart-topbar.topbar-min .chart-source + .data-fresh,
.chart-topbar.topbar-min .data-fresh ~ .chart-source { margin-left: 6px; }
.chart-topbar.topbar-min .topbar-icon-draw { display: inline-flex; order: -1; }
/* В чужом окне рисовать нечем, поэтому карандаш убираем и в узкой полосе:
   правило выше возвращало его на телефоне и в Telegram */
body.chart-widget .chart-topbar.topbar-min .topbar-icon-draw { display: none; }
.chart-topbar.topbar-min { gap: 6px; }
.chart-topbar.topbar-min .chart-source { margin-left: auto; }

/* Отступы для кнопок в углах графика больше не нужны — кнопок там нет */
.chart-area.lp-dock-right .levels-panel-btn,
.chart-area.lp-dock-right .quick-alert-btn { right: auto; }

/* ===== Вошли — кнопка кабинета значком и в браузере =====
   Раньше в браузере в шапке стояла длинная маскированная почта: она занимала
   пол-шапки и выглядела иначе, чем на телефоне и в Телеграме. Теперь везде
   одинаково — круглый значок в один вид со справкой и темой. Сама почта
   осталась в подсказке при наведении и внутри кабинета. */
.btn-account.is-logged {
    width: 34px;
    height: 34px;
    padding: 0;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.22);
    color: #fff;
}
.btn-account.is-logged:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: none;
    box-shadow: none;
}
.btn-account.is-logged .btn-account-text { display: none; }
.btn-account.is-logged .btn-account-icon { display: block; }

/* ===== Микро-подсказки первого запуска =====
   Три коротких «шепотка» подряд: без затемнения и без блокировки экрана,
   в отличие от быстрого старта. Стрелка смотрит на нужную кнопку. */
.hint-bubble {
    position: fixed;
    z-index: 60;
    max-width: 268px;
    padding: 10px 12px 9px;
    border: 1px solid var(--primary);
    border-radius: 12px;
    background: var(--surface);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.32);
    animation: hint-in 0.22s ease-out;
}
.hint-bubble[hidden] { display: none; }
@keyframes hint-in {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}
/* Носик пузыря: направление задаётся классом */
.hint-bubble::after {
    content: '';
    position: absolute;
    width: 10px; height: 10px;
    background: var(--surface);
    border-left: 1px solid var(--primary);
    border-top: 1px solid var(--primary);
    transform: rotate(45deg);
}
.hint-bubble.arrow-left::after { left: -6px; top: 18px; }
.hint-bubble.arrow-right::after { right: -6px; top: 18px; transform: rotate(225deg); }
.hint-bubble.arrow-top::after { top: -6px; left: 22px; }
.hint-bubble.arrow-bottom::after { bottom: -6px; left: 22px; transform: rotate(225deg); }
.hint-bubble.arrow-none::after { display: none; }

.hint-num { font-size: 10.5px; color: var(--text-muted); }
.hint-text { margin: 3px 0 8px; font-size: 13px; line-height: 1.35; color: var(--text); }
.hint-btns { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.hint-skip {
    border: 0; background: none; padding: 0;
    color: var(--text-muted); font: inherit; font-size: 11.5px; cursor: pointer;
}
.hint-skip:hover { color: var(--text); }
.hint-ok {
    border: 1px solid var(--primary);
    border-radius: 8px;
    padding: 4px 12px;
    background: var(--primary);
    color: #fff;
    font: inherit; font-size: 12px; cursor: pointer;
}
.hint-ok:hover { filter: brightness(1.06); }

/* Цель подсказки подсвечивается мягким кольцом, экран не затемняется */
.hint-target {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
    border-radius: 8px;
}

/* Кому подходит тариф — строка под ценой, чтобы не читать весь список */
.plan-for-whom {
    /* Отступ и рамка сверху разводят эту строку со строкой выгоды: обе мелкие
       и серые, подряд они читались как одна */
    margin: 8px 0 10px;
    padding-top: 8px;
    border-top: 1px dashed var(--border);
    font-size: 12px;
    line-height: 1.35;
    color: var(--text);
    opacity: 0.85;
}
/* Кнопка «Скоро будет доступно»: видно, что тариф есть, но платить пока некуда */
.btn-order-soon {
    width: 100%;
    cursor: default;
    opacity: 0.75;
}

/* ===== Всплывающие сообщения с отменой ===== */
.toast-wrap {
    position: fixed;
    left: 50%;
    bottom: 18px;
    transform: translateX(-50%);
    z-index: 4000;             /* выше окон: сообщение должно быть видно всегда */
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
    pointer-events: none;
    width: min(520px, calc(100vw - 24px));
}
.toast {
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
    font-size: 13px;
    animation: toast-in 0.18s ease-out;
}
.toast.gone { opacity: 0; transform: translateY(6px); transition: 0.2s ease; }
.toast-bad { border-color: #ef4444; }
.toast-text { flex: 1; min-width: 0; }
.toast-action {
    flex: none;
    padding: 5px 10px;
    border: 1px solid var(--accent, #22c55e);
    border-radius: 8px;
    background: transparent;
    color: var(--accent, #22c55e);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}
.toast-close {
    flex: none;
    border: 0;
    background: transparent;
    color: var(--text-muted);
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    padding: 2px 4px;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ===== Мои алерты: управление списком ===== */
.qa-tools {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 10px;
}
.qa-tool-search {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text);
    font: inherit;
}
.qa-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.qa-chip {
    padding: 5px 10px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: transparent;
    color: var(--text-muted);
    font: inherit;
    font-size: 12px;
    cursor: pointer;
}
.qa-chip.active {
    border-color: var(--accent, #22c55e);
    color: var(--accent, #22c55e);
    background: rgba(34, 197, 94, 0.08);
}
.qa-tools-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}
.qa-tool-check { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-muted); }
.qa-tool-sort {
    padding: 6px 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text);
    font: inherit;
    font-size: 12px;
}
/* Панель массовых действий висит над списком, пока что-то выбрано */
.qa-bulk {
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding: 8px 10px;
    margin-bottom: 8px;
    border: 1px solid var(--accent, #22c55e);
    border-radius: 8px;
    background: var(--surface);
}
.qa-bulk-count { font-size: 12px; font-weight: 600; margin-right: auto; }

/* ===== Мои алерты: группы и строки ===== */
.qa-group { margin-bottom: 12px; }
.qa-group-head {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding: 6px 8px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.03);
    font-size: 12px;
    color: var(--text-muted);
}
.qa-group.is-current .qa-group-head { box-shadow: inset 0 0 0 1px rgba(34, 197, 94, 0.45); }
.qa-group-name { font-size: 13px; font-weight: 700; color: var(--text); }
.qa-group-flag {
    padding: 1px 6px;
    border-radius: 999px;
    background: rgba(34, 197, 94, 0.16);
    color: var(--accent, #22c55e);
    font-size: 11px;
}
.qa-group-count { margin-left: auto; }
.qa-pick { display: inline-flex; align-items: center; }
/* Строка алерта всегда в два ряда: текст занимает всю ширину, кнопки уходят
   под него. Раньше кнопки стояли рядом и в узком окне алерта (а оно узкое и
   на большом экране) подпись сжималась в столбик по два слова. */
.qa-row2 {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 8px;
    padding: 8px;
    border-bottom: 1px solid var(--border);
}
.qa-row2 > .qa-pick { order: 0; }
/* Галочка выбора остаётся в одном ряду с заголовком: отдельной строкой она
   висела в пустоте. Кнопкам ширины не хватает — они переносятся вниз сами. */
.qa-row2 > .qa-row2-main { order: 1; flex: 1 1 220px; }
.qa-row2 > .qa-switch,
.qa-row2 > .qa-row-btn { order: 2; }
/* Первая кнопка после текста отодвигает остальные вправо */
.qa-row2 > .qa-switch { margin-left: auto; }
.qa-row2.off { opacity: 0.62; }
/* Цена рядом — подсвечиваем полосой слева: видно без чтения цифр */
.qa-row2.is-near { box-shadow: inset 3px 0 0 #ef4444; }
.qa-row2.is-soon { box-shadow: inset 3px 0 0 #f59e0b; }
.qa-row2-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.qa-row2-top { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.qa-row2-title { font-size: 13px; font-weight: 600; }
.qa-row2-near {
    padding: 1px 6px;
    border-radius: 999px;
    background: rgba(239, 68, 68, 0.16);
    color: #ef4444;
    font-size: 11px;
}
.qa-row2-sub { font-size: 12px; color: var(--text-muted); word-break: break-word; }
/* Заметка человека — курсивом и чуть светлее рамкой слева: это его слова,
   а не расчёт сервиса, и их надо отличать от строк с условиями */
.qa-row2-note {
    font-size: 12px;
    font-style: italic;
    color: var(--text);
    padding-left: 7px;
    border-left: 2px solid var(--border);
    word-break: break-word;
}
/* Цифры (создан, последняя цена, до уровня) — мельче: их читают вторыми */
.qa-row2-nums { font-size: 11px; color: var(--text-muted); word-break: break-word; }
/* Отметка об отправке в Телеграм. Слово «доставлено» не пишем: сайт знает
   только то, что сообщение ушло боту */
.qa-tg { padding: 1px 6px; border-radius: 999px; font-size: 11px; background: var(--border); }
.qa-tg-sent, .qa-tg-resent { background: rgba(34, 197, 94, 0.16); color: #16a34a; }
.qa-tg-error { background: rgba(239, 68, 68, 0.16); color: #ef4444; }
.qa-hist-acts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.qa-hist-note-edit { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 5px; }
.qa-hist-note-edit input {
    flex: 1 1 180px;
    min-width: 0;
    padding: 5px 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg);
    color: var(--text);
    font-size: 12px;
}
.qa-hist-count { font-size: 11px; color: var(--text-muted); }
/* В истории кнопок справа нет, поэтому строке не нужен отступ под них */
.qa-row-hist { align-items: flex-start; }
.qa-row-btn.is-danger { border-color: rgba(239, 68, 68, 0.5); color: #f87171; }
/* Переключатель паузы: одно нажатие вместо кнопки со сменой надписи */
.qa-switch { position: relative; flex: none; width: 38px; height: 22px; }
.qa-switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.qa-switch-run {
    position: absolute;
    inset: 0;
    border-radius: 999px;
    background: var(--border);
    transition: background 0.15s ease;
    pointer-events: none;
}
.qa-switch-run::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    transition: transform 0.15s ease;
}
.qa-switch input:checked + .qa-switch-run { background: var(--accent, #22c55e); }
.qa-switch input:checked + .qa-switch-run::after { transform: translateX(16px); }
.qa-switch input:focus-visible + .qa-switch-run { outline: 2px solid var(--accent, #22c55e); outline-offset: 2px; }

/* Полоса режима правки над формой */
.qa-editbar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    margin-bottom: 10px;
    border: 1px solid #f59e0b;
    border-radius: 8px;
    background: rgba(245, 158, 11, 0.1);
    font-size: 12px;
}
.qa-editbar span { flex: 1; min-width: 0; }

@media (max-width: 640px) {
    /* Всплывающие сообщения поднимаем над полосой кнопок и подвалом: внизу
       они закрывали реквизиты и ссылки на тарифы */
    .toast-wrap { bottom: calc(var(--legal-h, 0px) + var(--mob-bar-h) + 8px); }
}

/* ===== Нижние панели на телефоне =====
   На маленьком экране график — главное, поэтому настройки, списки, уровни и
   оповещения живут в нижних панелях: они появляются по кнопке и не отнимают место
   постоянно. Кнопка «Алерт» стоит в середине полосы и всегда видна. */
.mob-bar { display: none; }
.sheet { display: none; }
.sheet-backdrop { display: none; }

@media (max-width: 860px) {
    /* Высота полосы кнопок в одном месте: от неё считаются отступы подвала и
       графика. В мини-приложении Телеграма полоса выше — под ней ещё
       платформенная кнопка «Закрыть», и её нельзя перекрывать. */
    :root { --mob-bar-h: 58px; }

    .mob-bar {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 46;                 /* выше выдвижных панелей, ниже окон */
        display: flex;
        align-items: stretch;
        gap: 2px;
        padding: 4px 4px calc(4px + env(safe-area-inset-bottom, 0px));
        border-top: 1px solid var(--border);
        background: var(--surface);
        box-shadow: 0 -6px 18px rgba(0, 0, 0, 0.28);
    }
    /* Кнопку «Уровни» прячет код, когда показывать нечего: без разрешённой
       цены нет расстояний, а карта уровней доступна не всем тарифам. */
    .mob-btn[hidden] { display: none; }
    .mob-btn {
        flex: 1 1 0;
        min-width: 0;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        min-height: 50px;
        padding: 4px 2px;
        border: 0;
        border-radius: 10px;
        background: transparent;
        color: var(--text-muted);
        font: inherit;
        font-size: 10px;
        line-height: 1.1;
        cursor: pointer;
    }
    .mob-btn svg { width: 20px; height: 20px; flex: none; }
    .mob-btn span {
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .mob-btn[aria-expanded="true"] { color: var(--primary); background: rgba(34, 197, 94, 0.12); }
    /* Главное действие сервиса — поставить алерт. Выделяем цветом, чтобы его
       находили без объяснений. */
    .mob-btn-main {
        background: var(--primary);
        color: #fff;
        font-weight: 600;
    }
    .mob-btn-main svg { width: 22px; height: 22px; }
    .mob-btn-main:active { filter: brightness(0.94); }

    /* Подвал с реквизитами стоит под графиком и остаётся в потоке, поэтому
       место под полосу кнопок отдаём именно ему: раньше отступ висел на .main,
       и между панелью рисования и полосой кнопок зияла пустая полоса высотой
       с подвал — сам подвал при этом прятался за полосой. */
    /* Порядок снизу вверх: подвал с реквизитами в самом низу, над ним полоса
       кнопок, над ней график. Полосу поднимаем на высоту подвала: её меряет
       код и пишет в --legal-h (0, когда подвал скрыт в режиме «во весь экран»). */
    .main { padding-bottom: calc(var(--mob-bar-h) + var(--legal-h, 0px) + env(safe-area-inset-bottom, 0px)); }
    /* Подвал закреплён у нижнего края и лежит выше выдвижных панелей: пока он
       был в общем потоке, панель настроек накрывала его собой, полоса кнопок
       висела посреди панели, а под ней оставалось пустое место. */
    .site-legal {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 47;
        margin: 0;
        border-top: 1px solid var(--border);
        background: var(--surface);
    }
    .mob-bar { bottom: var(--legal-h, 0px); }

    /* Значки «Уровни рядом» и «Свой алерт» убраны из полосы над графиком:
       на телефоне те же действия есть в нижней полосе кнопок, два одинаковых
       входа рядом только путают и отнимают место у названия бумаги. */
    #levels-panel-btn,
    #quick-alert-btn { display: none; }

    /* «Откуда котировки» переезжает в шапку рядом с кабинетом: над графиком
       пилюля с подписью занимала половину полосы. В шапке — только значок
       с цветной точкой состояния, вид как у кнопок справки и темы. */
    .header-right .chart-source {
        position: static;
        z-index: auto;
        max-width: none;
        gap: 4px;
        padding: 6px;
        border: none;
        border-radius: var(--radius-sm);
        background: rgba(255, 255, 255, 0.1);
        color: #fff;
        box-shadow: none;
    }
    .header-right .chart-source .cs-text,
    .header-right .chart-source .cs-q { display: none; }
    .header-right .chart-source .cs-glyph { display: block; width: 18px; height: 18px; }
    .header-right .chart-source .cs-dot { width: 6px; height: 6px; }
    .site-foot, .footer { padding-bottom: calc(var(--mob-bar-h) + 4px + env(safe-area-inset-bottom, 0px)); }
    /* Полоса рабочего списка переехала в нижнюю панель «Списки» */
    .list-strip { display: none; }

    /* Настройки выезжают снизу, а не слева: до низа экрана палец достаёт легче,
       и панель не спорит с нижней полосой кнопок */
    .sidebar {
        top: auto;
        left: 0;
        right: 0;
        /* Панель кончается там, где начинается полоса кнопок: раньше она шла
           до самого низа, накрывала подвал и полосу, а место под кнопки
           держал внутренний отступ — из-за него панель «проваливалась» вниз */
        bottom: calc(var(--mob-bar-h) + var(--legal-h, 0px) + env(safe-area-inset-bottom, 0px));
        width: auto;
        max-width: none;
        max-height: 78vh;
        border-radius: 16px 16px 0 0;
        transform: translateY(102%);
        box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.35);
        padding-bottom: 10px;
    }
    .sidebar.open { transform: translateY(0); }
    .sidebar-backdrop { top: 0; }

    /* Панель уровней — такая же нижняя панель */
    .levels-panel {
        position: fixed;
        top: auto;
        left: 0;
        right: 0;
        bottom: calc(var(--mob-bar-h) + var(--legal-h, 0px) + env(safe-area-inset-bottom, 0px));
        width: auto;
        max-width: none;
        /* Раньше лист поднимался до 74vh — от графика оставалась полоска, а
           после ужатия области под лист (.chart-area.lp-sheet) свечи и вовсе
           сплющивались. Половина экрана листу хватает: список внутри
           прокручивается, а график остаётся читаемым. */
        max-height: 52vh;
        border-radius: 16px 16px 0 0;
        border-left: 0;
        border-right: 0;
        padding-bottom: 10px;
        z-index: 44;
    }

    /* Раскрыли полный список — листу нужно чуть больше места, а ключевые
       карточки уходят: их уровни всё равно стоят первыми строками списка. */
    .levels-panel.lp-open-all { max-height: 62vh; }
    /* На телефоне высоту листа считают правила выше, поэтому жёсткую высоту
       стыковки «снизу» с большого экрана снимаем — иначе лист был бы 238px */
    .levels-panel.dock-bottom { height: auto; }
    .levels-panel.lp-open-all .lp-key { display: none; }
    .levels-panel.lp-open-all .lp-list { min-height: 150px; }

    /* Ключевые уровни на телефоне — две компактные карточки в одну строку:
       поддержка слева, сопротивление справа, только цена, таймфрейм и
       расстояние. Статус и сила остаются в карточке уровня по нажатию.
       Так над раскрытым списком остаётся одна строка, а не полэкрана, и
       карточки больше не нужно прятать при раскрытой складке. */
    .levels-panel .lp-key { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; align-items: start; }
    .levels-panel.lp-open-all .lp-key,
    .levels-panel.dock-bottom.lp-open-all .lp-key { display: grid; }
    .levels-panel .lp-key { padding: 6px 12px 8px; }
    .levels-panel .lp-key-title,
    .levels-panel .lp-key-price,
    .levels-panel .lp-kempty { grid-column: 1 / -1; }
    .levels-panel .lp-key-title { display: none; }
    .levels-panel .lp-kcard { margin-top: 0; padding: 6px 8px; }
    .levels-panel .lp-kcard .lp-krow ~ .lp-krow { display: none; }
    .levels-panel .lp-kprice { margin: 0 0 2px; font-size: 0.95rem; }
    .levels-panel .lp-krow span:first-child { display: none; }
    .levels-panel.lp-open-all { max-height: 56vh; }

    /* Панель помнит, к какому краю её пристыковали на большом экране, и классы
       dock-* перебивали правило выше: на телефоне она открывалась узкой полосой
       у правого края поверх шапки. Здесь стыковка не нужна — всегда нижний лист. */
    .levels-panel.dock-left,
    .levels-panel.dock-right,
    .levels-panel.dock-bottom,
    .levels-panel.dock-float {
        top: auto;
        left: 0;
        right: 0;
        width: auto;
        max-width: none;
        box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.35);
    }

    /* Нижняя панель «Списки» */
    .sheet {
        position: fixed;
        left: 0;
        right: 0;
        bottom: calc(var(--mob-bar-h) + var(--legal-h, 0px) + env(safe-area-inset-bottom, 0px));
        z-index: 44;
        display: flex;
        flex-direction: column;
        max-height: 74vh;
        border-top: 1px solid var(--border);
        border-radius: 16px 16px 0 0;
        background: var(--surface);
        box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.35);
        padding-bottom: 10px;
    }
    .sheet[hidden] { display: none; }
    .sheet-head {
        position: relative;
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 14px 12px 8px;
        font-size: 14px;
    }
    .sheet-grip {
        position: absolute;
        top: 6px;
        left: 50%;
        transform: translateX(-50%);
        width: 38px;
        height: 4px;
        border-radius: 999px;
        background: var(--border);
    }
    .sheet-head b { flex: 1; min-width: 0; }
    .sheet-close {
        flex: none;
        border: 0;
        background: transparent;
        color: var(--text-muted);
        font-size: 15px;
        line-height: 1;
        padding: 4px 6px;
        cursor: pointer;
    }
    .sheet-body { flex: 1; min-height: 0; overflow: auto; padding: 0 12px; }
    .sheet-foot { padding: 8px 12px 4px; }
    .sheet-foot .btn { width: 100%; }
    /* В панели полоса списка разворачивается в столбик: бумаг много, а
       горизонтальная прокрутка на телефоне неудобна */
    .sheet-body .list-strip {
        display: flex;
        flex-wrap: wrap;
        border-bottom: 0;
        background: transparent;
        padding: 0;
    }
    .sheet-body .strip-list { flex: 1 1 100%; }
    .sheet-body .strip-items { flex: 1 1 100%; flex-wrap: wrap; overflow: visible; }
    .sheet-body .strip-arrow { display: none; }
    .sheet-body .strip-more { display: none; }

    .sheet-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 43;
        background: rgba(0, 0, 0, 0.5);
    }
    .sheet-backdrop[hidden] { display: none; }
}

/* В мини-приложении Телеграма полоса кнопок такая же, как в браузере телефона:
   она заметно удобнее прежней раскладки. Запас под платформенную кнопку
   Телеграма держит подвал: он лежит ниже полосы, поэтому кнопки уже не
   упираются в край экрана и добавлять им отступ не нужно. */
.tg-app .site-legal {
    padding-bottom: calc(18px + env(safe-area-inset-bottom, 0px));
}

/* Скрытая полоса списка не должна проявляться в нижней панели */
.sheet-body .list-strip[hidden] { display: none; }
.sheet-empty { margin: 8px 0 4px; }

/* ---------- Название сервиса на узком экране ---------- */
/* Одной строкой «Динамические уровни» не влезало между значком и кнопками
   справа и обрезалось троеточием: оставалось «Динамические …». Пускаем его в
   две строки — по высоте это ровно столько же, сколько занимают кнопки. */
@media (max-width: 860px) {
    .header .header-left .hdr-title {
        font-size: 11.5px;
        line-height: 1.15;
        white-space: normal;
        text-overflow: clip;
        overflow-wrap: break-word;
        display: -webkit-box;
        -webkit-line-clamp: 2;       /* третьей строке взяться неоткуда, но страхуемся */
        -webkit-box-orient: vertical;
        overflow: hidden;
    }
    /* Блок с названием должен сжиматься: с жёсткой минимальной шириной он
       вылезал из шапки и уезжал под кнопку «Войти» */
    .header .header-left > div { flex: 0 1 auto; min-width: 0; }
}

/* Совсем узкие корпуса и мини-приложение: слово «Динамические» длинное,
   поэтому шрифт чуть мельче, чтобы строка не разрывалась посередине слова */
@media (max-width: 380px) {
    .header .header-left .hdr-title { font-size: 10.5px; }
}

.tg-app .header .header-left .hdr-title {
    font-size: 11.5px;
    line-height: 1.15;
    white-space: normal;
    text-overflow: clip;
}

/* Мини-приложение на узком корпусе: правило без медиазапроса перебивало общий
   мелкий шрифт, и слово «Динамические» рвалось посередине — «Динамически/е» */
@media (max-width: 380px) {
    .tg-app .header .header-left .hdr-title { font-size: 10.5px; }
}

/* Совсем узкие корпуса (360 px и меньше): места под название нет — даже в две
   строки оно уезжало под кнопку «Войти». Оставляем значок «8», он и так
   подписан для чтецов экрана, а название видно на всех остальных ширинах. */
@media (max-width: 365px) {
    .header .header-left .hdr-title { display: none; }
}

/* Обязательная отметка согласия перед оплатой.
   Кнопка оплаты остаётся видимой, но заблокирована до отметки — так покупателю
   понятно, что именно нужно сделать, а согласие фиксируется осознанно. */
.billing-consent {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    margin: 10px 0 4px;
    font-size: 0.86rem;
    line-height: 1.5;
    color: var(--text-muted);
    cursor: pointer;
}
.billing-consent input {
    width: 17px;
    height: 17px;
    flex: none;
    margin-top: 1px;
}
.billing-consent a { color: var(--accent); }
/* Заблокированная кнопка оплаты: гасим цвет, но клик перехватываем в скрипте,
   чтобы можно было подсказать, чего не хватает. */
.btn.is-locked {
    opacity: 0.45;
    cursor: not-allowed;
}
.site-legal-hours { color: var(--text-faint); }

/* ===== Свежесть данных (4.5) ===== */
/* Полоса под верхними кнопками: откуда цена, сколько назад обновилась, когда
   пересчитаны уровни. Раньше это было видно только внутри пояснения к
   источнику, и «график завис» было не отличить от стоящего рынка. */
/* Значки живут в верхней полосе графика (JS переставляет узел туда при
   загрузке), поэтому своих отступов и своей строки у полосы нет. Подписи
   скрыты на всех ширинах: две длинные строки «Цена: … · обновлено … назад»
   и «Уровни: 8levels · пересчитаны …» занимали место графика и повторяли
   то, что открывается нажатием. Остаётся цветная точка со значком —
   состояние читается мгновенно, подробности в подсказке. */
.data-fresh {
    display: flex;
    flex-wrap: nowrap;
    gap: 4px;
    padding: 0;
    margin-left: auto;
    font-size: 0.72rem;
    color: var(--text-muted);
}
.data-fresh[hidden] { display: none; }
.df-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 8px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface-2);
    white-space: nowrap;
}
.df-dot {
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--text-faint);
    flex: 0 0 auto;
}
.df-chip.ok .df-dot { background: #4CAF50; }
.df-chip.warn .df-dot { background: #FFB300; }
.df-chip.bad .df-dot { background: #E53935; }
.df-chip.warn { border-color: rgba(255, 179, 0, 0.45); }
.df-chip.bad { border-color: rgba(229, 57, 53, 0.5); }

/* Значок и подсказка. Значок виден всегда, подпись — никогда: полный текст
   показывается подсказкой при наведении и касании. */
.df-text { display: none; }
.df-glyph {
    display: inline-block;
    width: 14px;
    height: 14px;
    flex: 0 0 auto;
}
.df-chip { cursor: pointer; }
.df-chip:hover { border-color: var(--primary); }
.df-chip { position: relative; cursor: default; }
.df-tip {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    z-index: 40;
    display: none;
    max-width: min(78vw, 320px);
    width: max-content;
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font-size: 0.72rem;
    line-height: 1.35;
    white-space: normal;
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.18);
    pointer-events: none;
}
.df-chip:hover .df-tip,
.df-chip:focus-visible .df-tip,
.df-chip.df-open .df-tip { display: block; }
/* Значки стоят у правого края полосы, поэтому подсказку тянем влево от
   значка — иначе она уезжает за край окна */
.df-tip { left: auto; right: 0; }

/* ===== Карта рынка сейчас (5.1) ===== */
/* Стоит справа от графика и не перекрывает свечи: область графика получает
   отступ, как и для панели «Уровни рядом». */
.market-now {
    position: absolute;
    right: 14px;
    top: 14px;
    width: 292px;
    max-width: calc(100% - 28px);
    z-index: 13;                    /* выше «Уровней рядом»: это главная подсказка */
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 11px 12px 12px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
    box-shadow: 0 14px 40px rgba(0, 0, 0, 0.34);
}
.market-now[hidden] { display: none; }
.mn-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
}
.mn-title b { display: block; font-size: 0.94rem; }
.mn-sub { display: block; margin-top: 2px; font-size: 0.76rem; color: var(--text-muted); }
.mn-close {
    border: 0; background: none; color: var(--text-muted);
    font-size: 0.95rem; cursor: pointer; padding: 2px 4px; line-height: 1;
}
.mn-close:hover { color: var(--text); }
.mn-price-row {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 8px;
}
.mn-price { font-size: 1.34rem; font-weight: 600; line-height: 1.1; }
.mn-between { font-size: 0.74rem; color: var(--text-muted); }
.mn-rows { display: flex; flex-direction: column; gap: 5px; }
.mn-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
    font-size: 0.78rem;
}
.mn-row-name {
    display: inline-flex; align-items: center; gap: 6px;
    color: var(--text-muted);
    flex: 0 0 auto;
    /* Без запрета переноса «Старшая зона» ломалась на две строки и строка
       карточки становилась выше остальных */
    white-space: nowrap;
}
.mn-row-val { text-align: right; }
.mn-row-val b { font-weight: 600; }
/* Расстояние до уровня — второй строкой, иначе строка не влезает в 292 пкс
   и значение переносится посреди числа */
.mn-row-val span {
    display: block;
    font-size: 0.72rem;
    color: var(--text-muted);
    white-space: nowrap;
}
.mn-row .mn-dot { width: 7px; height: 7px; border-radius: 50%; flex: 0 0 auto; }
/* Пояснение про свою же кнопку «без значений» в карте рынка: не рамка
   предупреждения, а спокойная строка мелким шрифтом. */
.mn-note { margin: 6px 0 0; font-size: 0.72rem; line-height: 1.35; color: var(--text-muted); }
.mn-note[hidden] { display: none; }
.mn-status {
    padding: 7px 9px;
    border-radius: 9px;
    background: var(--surface-2);
    font-size: 0.76rem;
    line-height: 1.4;
}
.mn-acts { display: flex; gap: 6px; }
.mn-btn {
    flex: 1;
    padding: 8px 6px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: transparent;
    color: var(--text);
    font: inherit;
    font-size: 0.78rem;
    cursor: pointer;
    white-space: nowrap;
}
.mn-btn:hover { background: var(--surface-2); }
.mn-btn-main { background: var(--primary); border-color: var(--primary); color: #fff; }
.mn-btn-main:hover { filter: brightness(1.08); background: var(--primary); }
.mn-fresh { display: none; font-size: 0.7rem; color: var(--text-faint); line-height: 1.45; }
.mn-fresh div + div { margin-top: 2px; }

/* Область графика отодвигается, чтобы карточка не легла на свечи */
.chart-area.mn-open { padding-right: 320px; }
.chart-area.mn-open .levels-panel.dock-right { right: 320px; }
/* Открытая карта рынка занимает правый край, и полоса списка снизу должна
   кончаться перед ней, иначе они лежали бы друг на друге */
.chart-area.mn-open .levels-panel.dock-bottom { right: 320px; }
.chart-area.mn-open.lp-dock-right { padding-right: 612px; }
.chart-area.mn-open .levels-panel-btn,
.chart-area.mn-open .quick-alert-btn,
.chart-area.mn-open .market-now-btn { right: auto; }

@media (max-width: 1100px) {
    /* Места на два столбца справа уже не хватает — карточка ложится поверх */
    .chart-area.mn-open { padding-right: 0; }
    .chart-area.mn-open.lp-dock-right { padding-right: 306px; }
    .market-now { box-shadow: 0 18px 46px rgba(0, 0, 0, 0.5); }
}

@media (max-width: 860px) {
    /* На телефоне карточка — выезжающий снизу лист: вертикаль дорога, а
       читать её удобнее во всю ширину. Отступ снизу — под полосу кнопок. */
    .market-now {
        position: fixed;
        left: 0;
        right: 0;
        top: auto;
        /* Лист встаёт НАД полосой кнопок, а не под ней. Раньше он доходил до
           низа экрана, полоса кнопок (она выше по слою) закрывала кнопки
           «Поставить алерт» и «Открыть сценарий», и главное действие
           приходилось искать прокруткой. */
        bottom: calc(var(--mob-bar-h, 58px) + env(safe-area-inset-bottom, 0px));
        width: auto;
        max-width: none;
        z-index: 45;
        border-radius: 16px 16px 0 0;
        border-left: 0;
        border-right: 0;
        border-bottom: 0;
        max-height: calc(80vh - var(--mob-bar-h, 58px));
        overflow-y: auto;
    }
    /* Два значка свежести стоят в один ряд и не переносятся */
    .data-fresh {
        flex-wrap: nowrap;
        scrollbar-width: none;
    }
    .data-fresh::-webkit-scrollbar { display: none; }
    .chart-area.mn-open { padding-right: 0; }
    .chart-area.mn-open.lp-dock-right { padding-right: 0; }
    .mn-price { font-size: 1.42rem; }
    .mn-row { font-size: 0.82rem; }
    .mn-btn { padding: 11px 6px; font-size: 0.82rem; }
    /* На телефоне полоса свежести над графиком узкая, поэтому подписи
       повторяем внутри листа — там для них есть место */
    .mn-fresh { display: block; }
    .data-fresh { padding: 0; font-size: 0.68rem; }
}

/* Кнопка карты рынка подсвечивается, когда карточка открыта — как «Уровни рядом» */
.chart-topbar .market-now-btn[aria-expanded="true"] {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--surface-2);
}

/* ===== Быстрые сценарии в форме алерта =====
   Шесть готовых наборов вместо ручного подбора условия и допуска. Кнопки в
   сетку по три: в один ряд шесть штук не влезают даже в браузере, а перенос
   «по остатку» давал кривые ряды из четырёх и двух. */
.qa-scen {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
}
.qa-scen-btn {
    padding: 9px 6px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--surface);
    color: var(--text);
    font-size: 0.82rem;
    font-family: inherit;
    cursor: pointer;
    transition: border-color .15s, color .15s, background .15s;
    /* Длинные названия не переносим по слогам: «Закреп-ление» читается плохо */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.qa-scen-btn:hover { border-color: var(--primary); color: var(--primary); }
.qa-scen-btn.active {
    border-color: var(--primary);
    background: var(--primary);
    color: #fff;
}
#qa-scen-hint:empty { display: none; }

/* ===== Меню уровня по клику на линию =====
   Всплывает у самой линии, поэтому положение задаётся из кода. Ширину держим
   фиксированной: иначе меню растягивается по самой длинной подписи действия. */
.lvl-menu {
    position: fixed;
    z-index: 60;
    width: 262px;
    max-width: calc(100vw - 24px);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 12px 34px rgba(15, 23, 42, .18);
    padding: 12px 13px 11px;
}
.lvl-menu-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 9px;
}
.lvl-menu-head b { font-size: 0.95rem; display: block; }
.lvl-menu-head .modal-close { position: static; flex: 0 0 auto; }
.lvl-menu-sub {
    font-size: 0.76rem;
    color: var(--text-muted);
    line-height: 1.45;
    margin-top: 2px;
}
.lvl-menu-acts { display: flex; flex-direction: column; gap: 5px; }
.lvl-menu-act {
    display: block;
    width: 100%;
    text-align: left;
    padding: 9px 10px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--surface);
    color: var(--text);
    font-size: 0.84rem;
    font-family: inherit;
    cursor: pointer;
    transition: border-color .15s, color .15s;
}
.lvl-menu-act:hover { border-color: var(--primary); color: var(--primary); }
.lvl-menu-act.primary {
    border-color: var(--primary);
    background: var(--primary);
    color: #fff;
}
.lvl-menu-act.primary:hover { color: #fff; opacity: .92; }

/* На телефоне меню уровня — нижний лист: попасть пальцем в маленькое
   всплывающее окно у линии почти невозможно */
@media (max-width: 860px) {
    .lvl-menu {
        left: 0 !important;
        right: 0;
        top: auto !important;
        width: auto;
        max-width: none;
        border-radius: 16px 16px 0 0;
        border-left: 0;
        border-right: 0;
        border-bottom: 0;
        padding: 14px 15px 15px;
    }
    .lvl-menu-act { padding: 12px 12px; font-size: 0.9rem; }
    .qa-scen-btn { padding: 11px 6px; font-size: 0.8rem; }
}

/* ===== Лист «Сценарий» =====
   Отдельное окно со списком наблюдений: где цена, что рядом, что считать
   пробоем, насколько свежи данные. Раньше «Открыть сценарий» лишь раскрывал
   тонкие настройки формы алерта — человек видел поля, но не понимал, зачем.

   В браузере окно строго по содержимому: высота не задана, растёт от текста и
   упирается в 82vh, после чего прокручивается только список наблюдений.
   Пустоты снизу не остаётся — этим и отличается от прежних листов с
   фиксированной высотой. */
.scen {
    position: fixed;
    z-index: 90;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    width: 460px;
    max-width: calc(100vw - 32px);
    max-height: 82vh;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.42);
    overflow: hidden;
}
.scen[hidden] { display: none; }
.scen-backdrop {
    position: fixed;
    inset: 0;
    z-index: 89;
    background: rgba(0, 0, 0, 0.5);
}
.scen-backdrop[hidden] { display: none; }

.scen-head {
    position: relative;
    flex: none;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 13px 14px 11px;
    border-bottom: 1px solid var(--border);
}
.scen-grip { display: none; }
.scen-title { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.scen-title b { font-size: 0.98rem; }
.scen-sub {
    color: var(--text-muted);
    font-size: 0.76rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.scen-close {
    flex: none;
    border: 0;
    background: none;
    color: var(--text-muted);
    font-size: 0.92rem;
    line-height: 1;
    padding: 3px 4px;
    cursor: pointer;
}
.scen-close:hover { color: var(--text); }

/* Прокручивается только список: голова и кнопки остаются на месте */
.scen-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    padding: 11px 14px 12px;
    display: grid;
    gap: 10px;
}
.scen-item {
    display: grid;
    grid-template-columns: 9px 1fr;
    gap: 9px;
    align-items: start;
}
/* Точка цвета таймфрейма: тот же язык, что на графике и в карте рынка */
.scen-dot {
    width: 9px;
    height: 9px;
    margin-top: 5px;
    border-radius: 50%;
    background: var(--text-muted);
}
.scen-item-b { min-width: 0; }
.scen-item-h {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px 8px;
    font-size: 0.83rem;
    font-weight: 600;
}
.scen-item-h .scen-val { color: var(--text); }
.scen-item-h .scen-meta { color: var(--text-muted); font-weight: 400; font-size: 0.76rem; }
.scen-item-t {
    margin-top: 3px;
    color: var(--text-muted);
    font-size: 0.78rem;
    line-height: 1.45;
}
.scen-note {
    padding: 9px 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface-2);
    color: var(--text-muted);
    font-size: 0.77rem;
    line-height: 1.45;
}
.scen-foot {
    flex: none;
    display: grid;
    gap: 8px;
    padding: 11px 14px 13px;
    border-top: 1px solid var(--border);
}
.scen-foot .btn { width: 100%; }

/* Телефон и Телеграм: обычный нижний лист над полосой кнопок. Отступ снизу
   считается по той же переменной, что и остальные листы, иначе кнопки
   уезжают под полосу и до них не дотянуться. */
@media (max-width: 860px) {
    .scen {
        left: 0;
        right: 0;
        top: auto;
        bottom: calc(var(--mob-bar-h) + var(--legal-h, 0px) + env(safe-area-inset-bottom, 0px));
        transform: none;
        width: auto;
        max-width: none;
        max-height: 76vh;
        border: 0;
        border-top: 1px solid var(--border);
        border-radius: 16px 16px 0 0;
        box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.35);
    }
    .scen-head { padding: 16px 12px 10px; }
    .scen-grip {
        display: block;
        position: absolute;
        top: 6px;
        left: 50%;
        transform: translateX(-50%);
        width: 38px;
        height: 4px;
        border-radius: 999px;
        background: var(--border);
    }
    .scen-body { padding: 11px 12px 12px; }
    .scen-foot { padding: 10px 12px 12px; }
    .scen-item-h { font-size: 0.87rem; }
    .scen-item-t { font-size: 0.81rem; }
}

/* ===== Режим ограничения по рыночным данным ===== */
/* Плашка вверху страницы и водяной знак на графике. Оба элемента говорят об
   одном: цены и свечи сейчас демонстрационные. Цвет янтарный, а не красный:
   это не поломка сервиса, остальные возможности работают. */
.md-strip {
    flex-shrink: 0;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 8px 20px;
    background: linear-gradient(135deg, #78350f 0%, #92400e 100%);
    color: #fef3c7;
    border-bottom: 1px solid rgba(251, 191, 36, 0.45);
    font-size: 0.85rem;
    line-height: 1.45;
}

.md-strip-mark {
    flex-shrink: 0;
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(251, 191, 36, 0.22);
    border: 1px solid rgba(251, 191, 36, 0.55);
    color: #fde68a;
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    margin-top: 1px;
}

/* Заголовок и пояснение переносятся вместе, поэтому строка не рвётся
   посередине слова даже при длинном тексте из настроек */
.md-strip-body {
    min-width: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px 8px;
    overflow-wrap: anywhere;
}

.md-strip-title { color: #fff; }
.md-strip-text { color: #fde68a; }

/* ----- свёрнутое состояние полосы -----
   По умолчанию вверху страницы видна одна строка: предупреждение на
   полэкрана перестают читать вовсе, а важное слово — само наличие
   полосы и метка — читается и в одной строке. Обрезание только
   визуальное: весь текст остаётся в разметке и доступен читалке. */
.md-strip-compact .md-strip-body {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 1;
    line-clamp: 1;
}

.md-strip-compact .md-strip-title { margin-right: 6px; }

/* Область нажатия кнопок — не меньше 44×44 px: обе живут в узкой
   полосе, и пальцем по мелкой цели попасть невозможно. Отрицательные
   отступы по вертикали держат саму полосу компактной: цель больше
   своего видимого размера, а высота строки от этого не растёт. */
.md-strip-more,
.md-strip-close {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    margin: -11px 0;
    padding: 0 8px;
    background: none;
    border: none;
    border-radius: 8px;
    color: #fde68a;
    font: inherit;
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 2px;
    cursor: pointer;
}

.md-strip-close {
    font-size: 1.15rem;
    font-weight: 700;
    text-decoration: none;
    line-height: 1;
}

.md-strip-more:hover,
.md-strip-close:hover { background: rgba(251, 191, 36, 0.16); color: #fff; }

.md-strip-more:focus-visible,
.md-strip-close:focus-visible {
    outline: 2px solid #fbbf24;
    outline-offset: 2px;
}

/* Знак лежит поверх графика и не перехватывает нажатия: рисовать и ставить
   алерты можно как обычно */
.chart-grid { position: relative; }

.chart-demo-mark {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-18deg);
    pointer-events: none;
    z-index: 4;
    font-size: clamp(1.6rem, 6vw, 4rem);
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(251, 191, 36, 0.14);
    white-space: nowrap;
    user-select: none;
}

[data-theme="light"] .chart-demo-mark { color: rgba(146, 64, 14, 0.13); }

/* Метка рядом с ценой и в полосе свежести данных */
.demo-tag {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 999px;
    background: rgba(251, 191, 36, 0.18);
    border: 1px solid rgba(251, 191, 36, 0.5);
    color: #fbbf24;
    font-size: 0.72rem;
    font-weight: 700;
    white-space: nowrap;
}

/* Бейдж «ТЕСТ» у заголовков разделов и в шапке каждой карточки зоны. Цвет
   тот же янтарный, что и у остальных пометок режима: человек привыкает к
   одному сигналу, а не разгадывает три разных. Метку не прячем на узком
   экране — она короче любого заголовка и важнее его. */
.test-badge {
    display: inline-block;
    padding: 0 6px;
    border-radius: 999px;
    background: rgba(251, 191, 36, 0.18);
    border: 1px solid rgba(251, 191, 36, 0.55);
    color: #fbbf24;
    font-size: 0.66rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    line-height: 1.5;
    white-space: nowrap;
    vertical-align: middle;
}

[data-theme="light"] .test-badge { color: #92400e; }

/* Подпись у самого числа в карточке: цифра без пояснения рядом читается как
   биржевая цена, поэтому «тестовое значение» стоит вплотную к ней. */
.kl-test-note {
    font-size: 0.7rem;
    font-weight: 600;
    color: #fbbf24;
    white-space: nowrap;
}

[data-theme="light"] .kl-test-note { color: #92400e; }

/* Левая полоса карточки в тестовом режиме — янтарная поверх зелёной или
   красной: цвет стороны уровня остаётся в заголовке, а характер данных
   виден по всей высоте карточки. */
.kl-card.kl-test { border-left-color: rgba(251, 191, 36, 0.85); }

@media (max-width: 768px) {
    /* На телефоне плашка занимает всю ширину и текст уходит на вторую строку:
       обрезать его нельзя, иначе предупреждение потеряет смысл */
    .md-strip {
        padding: 7px 12px;
        font-size: 0.8rem;
    }

    /* На телефоне в одну строку заголовок и начало текста не влезают,
       и одного заголовка мало, чтобы понять суть. Две строки — предел:
       дальше полоса начинает съедать экран, а график на телефоне
       и так невысокий. */
    .md-strip-compact .md-strip-body {
        -webkit-line-clamp: 2;
        line-clamp: 2;
    }
}

/* Граница между чужим графиком и числами сервиса.
   Виджет TradingView показывает биржевые свечи, а рядом стоят зоны 8levels —
   собственный расчёт сервиса, в тестовом режиме на тестовых числах. Если
   блоки соприкасаются без зазора, всё вместе читается как одна картинка от
   биржи. Поэтому между графиком и картой зон — видимая линия и воздух:
   слева на широком экране, сверху на телефоне, где блок уезжает под график. */
.chart-row .key-levels {
    border-left: 2px solid var(--border);
    padding-left: 12px;
    margin-left: 4px;
}

@media (max-width: 1024px) {
    .chart-row .key-levels {
        border-left: 0;
        padding-left: 0;
        margin-left: 0;
        border-top: 2px solid var(--border);
        padding-top: 12px;
        margin-top: 12px;
    }
}

/* Предупреждение о режиме в блоке подписки: янтарная рамка, как у остальных
   пометок режима, чтобы его не приняли за обычную серую сноску с ценами. */
.billing-test-note {
    margin: 0 0 10px;
    padding: 8px 10px;
    border: 1px solid rgba(251, 191, 36, 0.5);
    border-radius: 10px;
    background: rgba(251, 191, 36, 0.10);
    color: var(--text);
    line-height: 1.5;
}

/* ===== Отдельная страница кабинета 8levels.ru/kabinet =====
   Сервер ставит <html data-page="kabinet">. Графики, уровни и котировки живут
   на crossedge8.ru, поэтому здесь от приложения остаются шапка, кабинет
   (аккаунт, подписка с оплатой, настройки), окна входа и подвал с документами.
   Кабинет стоит в потоке страницы, а не окном поверх графика. */
.cabinet-to-charts { display: none; }
/* У приложения страница не прокручивается (график на весь экран); у кабинета — обычная прокрутка */
html[data-page="kabinet"],
html[data-page="kabinet"] body { height: auto; min-height: 100%; overflow: visible; overflow-x: hidden; }
/* Окна (и кабинет) стоят в разметке после .app, поэтому .app — только шапка */
html[data-page="kabinet"] .app { height: auto; min-height: 0; }
html[data-page="kabinet"] .main,
html[data-page="kabinet"] .mob-bar,
html[data-page="kabinet"] .sheet,
html[data-page="kabinet"] .sheet-backdrop,
html[data-page="kabinet"] .scen,
html[data-page="kabinet"] .scen-backdrop,
html[data-page="kabinet"] .md-strip,
html[data-page="kabinet"] .menu-toggle,
html[data-page="kabinet"] .head-ticker,
html[data-page="kabinet"] .tour,
html[data-page="kabinet"] .hint-bubble,
html[data-page="kabinet"] #cabinet-close { display: none !important; }
html[data-page="kabinet"] .cabinet-overlay {
    position: static;
    min-height: calc(100vh - 52px - 40px);
    inset: auto;
    background: none;
    display: block;
    flex: 1 0 auto;
    padding: 28px 16px 40px;
    z-index: auto;
}
html[data-page="kabinet"] .cabinet-overlay[hidden] { display: block; visibility: hidden; }
/* Подвал с реквизитами — внизу страницы, в общем потоке (app.js переносит его
   в конец body). У приложения на телефоне он закреплён у нижнего края, а в
   полноэкранном режиме браузера скрыт — здесь ни то, ни другое не нужно:
   реквизиты продавца на странице оплаты должны быть видны. */
html[data-page="kabinet"] .site-legal,
html[data-page="kabinet"] body.browser-full .site-legal,
html[data-page="kabinet"] body.chart-full .site-legal {
    display: flex;
    position: static;
    margin-top: 0;
}
html[data-page="kabinet"] .cabinet-box { max-width: 760px; margin: 0 auto; max-height: none; overflow: visible; }
/* Шапка кабинета прилипает под шапкой сайта, а не к верху окна */
html[data-page="kabinet"] .cabinet-head { top: 0; }
html[data-page="kabinet"] .cabinet-to-charts {
    display: inline-flex;
    flex: 0 0 auto;
    width: auto;
    margin-left: auto;
    text-decoration: none;
    white-space: nowrap;
}

/* Знак 8levels на телефоне и в Telegram — той же высоты, что прежний
   квадратный знак, ширина по пропорции. Стоит в конце файла, чтобы
   перекрыть .logo { width: 20px; height: 20px } из правил узкого экрана. */
@media (max-width: 860px) { .logo.logo-8l { width: auto; height: 22px; } }
.tg-app .logo.logo-8l { width: auto; height: 22px; }

/* ===== вкладка «Администратор», 07.10.2026 =====
   Владелец просил видеть таблицы целиком, без прокрутки вбок: пока открыта
   вкладка «Администратор», окно кабинета расширяется почти на весь экран.
   Остальные вкладки остаются прежней ширины — там узкая колонка удобнее. */
.cabinet-box:has(.cabinet-panel[data-cabinet-panel="admin"]:not([hidden])),
html[data-page="kabinet"] .cabinet-box:has(.cabinet-panel[data-cabinet-panel="admin"]:not([hidden])) {
    max-width: min(1320px, 96vw);
}

/* Каждый раздел вкладки сворачивается: заголовок — кнопка во всю ширину */
.admin-sec-fold > summary.admin-sec-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    cursor: pointer;
    padding: 4px 0;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 8px;
}

.admin-sec-fold > summary.admin-sec-title::-webkit-details-marker {
    display: none;
}

.admin-sec-fold > summary.admin-sec-title::before {
    content: "▸";
    color: var(--text-muted);
    transition: transform 0.15s ease;
}

.admin-sec-fold[open] > summary.admin-sec-title::before {
    transform: rotate(90deg);
}

.admin-sec-fold[open] > summary.admin-sec-title {
    margin-bottom: 8px;
}

/* Почта в таблице пользователей больше не обрезается многоточием */
#admin-users-table td:first-child {
    max-width: none;
    overflow: visible;
}

#admin-users-table select {
    max-width: none;
}

#admin-gsheet-box ol.hint {
    padding-left: 18px;
    margin: 6px 0;
}

/* На телефоне таблица пользователей — карточками: строка становится блоком,
   у каждой клетки подпись слева. Так ничего не надо листать вбок. */
@media (max-width: 700px) {
    #admin-users-table thead { display: none; }
    #admin-users-table { min-width: 0; }
    #admin-users-table, #admin-users-table tbody,
    #admin-users-table tr, #admin-users-table td { display: block; width: 100%; }
    #admin-users-table tr {
        border-bottom: 1px solid var(--border);
        padding: 8px 0;
    }
    #admin-users-table td {
        border: 0;
        padding: 3px 0;
        display: flex;
        gap: 8px;
        align-items: center;
        flex-wrap: wrap;
    }
    #admin-users-table td[data-label]::before {
        content: attr(data-label);
        color: var(--text-muted);
        font-size: 12px;
        min-width: 72px;
    }
    #admin-users-table-wrap, .admin-users-table-wrap { overflow-x: visible; }
}

/* ===== Меню платформы CrossEdge8 (07.10.2026) =====
   Полоса разделов под шапкой. Горизонтальная, а не левая колонка, как в
   макете: слева уже стоит панель настроек графика, и вторая колонка отняла
   бы у свечей ещё 200 px. На телефоне полоса прокручивается пальцем. */
.pf-nav {
    display: flex;
    gap: 2px;
    padding: 0 12px;
    height: 40px;
    align-items: stretch;
    flex-shrink: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}
.pf-nav::-webkit-scrollbar { display: none; }
.pf-tab {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 0 12px;
    border: 0;
    background: none;
    color: var(--text-muted);
    font: 500 13px/1 var(--font-body);
    white-space: nowrap;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: color var(--transition), border-color var(--transition), background var(--transition);
}
.pf-tab svg { width: 17px; height: 17px; flex-shrink: 0; }
.pf-tab:hover { color: var(--text); background: var(--surface-2); }
.pf-tab:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.pf-tab.is-active { color: var(--text); border-bottom-color: #0e9f86; }
/* 114l (14.10.2026): значки разделов, вариант 03 «Фирменные» (ikonki.py). Основной штрих —
   цвет текста вкладки, акцентная часть — фирменный бирюзовый: у неактивной вкладки приглушён
   (0,6), у активной — полный. В светлой теме бирюзовый темнее (#0e9f86): #2dd4bf на белом
   не читается на 14 px. Активную вкладку по-прежнему отмечает полоса снизу. */
.pf-tab.is-active svg { color: var(--text); }
.ri-ac { stroke: #2dd4bf; opacity: .6; transition: opacity var(--transition); }
.pf-tab.is-active .ri-ac, .pf-tab:hover .ri-ac { opacity: 1; }
[data-theme="light"] .ri-ac { stroke: #0e9f86; }
.tour-invite-ic { display: inline-flex; vertical-align: -3px; margin-right: 6px; color: var(--text); }
.tour-invite-ic svg { width: 16px; height: 16px; }
.tour-invite-ic .ri-ac { opacity: 1; }
.pf-tab[aria-disabled="true"] { cursor: default; opacity: .62; }
.pf-tab[aria-disabled="true"]:hover { background: none; color: var(--text-muted); }
.pf-soon {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: .02em;
    padding: 2px 6px;
    border-radius: 999px;
    color: #b45309;
    background: rgba(245, 158, 11, .14);
    border: 1px solid rgba(245, 158, 11, .32);
}
[data-theme="dark"] .pf-soon, :root:not([data-theme="light"]) .pf-soon { color: #fbbf24; }
.pf-soon[hidden] { display: none; }
.pf-tip {
    position: fixed;
    z-index: 3000;
    max-width: 272px;
    padding: 8px 11px;
    border-radius: var(--radius-md);
    background: var(--surface-3);
    color: var(--text);
    border: 1px solid var(--border);
    box-shadow: 0 8px 24px rgba(0, 0, 0, .28);
    font-size: 12.5px;
    line-height: 1.4;
    opacity: 0;
    transform: translateY(-4px);
    pointer-events: none;
    transition: opacity var(--transition), transform var(--transition);
}
.pf-tip.is-on { opacity: 1; transform: none; }

/* Страница раздела: занимает место графика */
.app > .main[hidden], .mob-bar[hidden] { display: none !important; }
.pf-page { flex: 1; min-height: 0; overflow-y: auto; background: var(--bg); }
.pf-page[hidden] { display: none; }
.pf-page-inner { max-width: 960px; margin: 0 auto; padding: 32px 20px 48px; }
.pf-page-kicker {
    display: inline-block;
    font-size: 12px; font-weight: 600; letter-spacing: .03em;
    color: #b45309; background: rgba(245, 158, 11, .12);
    border: 1px solid rgba(245, 158, 11, .3);
    padding: 3px 10px; border-radius: 999px; margin-bottom: 14px;
}
:root:not([data-theme="light"]) .pf-page-kicker { color: #fbbf24; }
.pf-page-title { font-size: 26px; line-height: 1.2; font-weight: 700; margin-bottom: 10px; }
.pf-page-lead { font-size: 15px; line-height: 1.55; color: var(--text-muted); max-width: 64ch; margin-bottom: 18px; }
.pf-page-list { list-style: none; display: grid; gap: 8px; margin-bottom: 22px; max-width: 64ch; }
.pf-page-list li {
    padding: 10px 14px 10px 34px; position: relative;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
    font-size: 14px; line-height: 1.45;
}
.pf-page-list li::before {
    content: ""; position: absolute; left: 14px; top: 17px;
    width: 8px; height: 8px; border-radius: 50%; background: #0e9f86;
}
.pf-back {
    padding: 9px 16px; border-radius: var(--radius-md); cursor: pointer;
    background: #0e9f86; color: #fff; border: 0; font: 600 14px var(--font-body);
}
.pf-back:hover { background: #0b8571; }
.pf-maket { margin-top: 28px; }
.pf-maket[hidden] { display: none; }
.pf-maket figcaption { font-size: 12px; color: var(--text-faint); margin-bottom: 8px; }
.pf-maket img { width: 100%; height: auto; border-radius: var(--radius-md); border: 1px solid var(--border); display: block; }

/* Плашка модели ASC на графике: режим, возраст сетки, CONF */
.asc-badge {
    position: absolute; left: 10px; top: 44px; z-index: 6;
    display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center;
    max-width: calc(100% - 90px);
    padding: 5px 9px; border-radius: var(--radius-sm);
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    border: 1px solid var(--border);
    font: 11.5px/1.35 var(--font-mono); color: var(--text-muted);
    pointer-events: auto;
}
.asc-badge b { font-family: var(--font-body); color: #f59e0b; font-weight: 700; }

/* Пометка словами занимает место: девять разделов с ней не влезают в
   1440 px. Уже 1680 px пометка становится янтарной точкой, а расшифровку
   держит легенда в конце полосы и всплывающая подсказка при нажатии. */
.pf-legend {
    margin-left: auto; padding-left: 14px; flex-shrink: 0;
    display: none; align-items: center; gap: 6px;
    font-size: 11.5px; color: var(--text-faint); white-space: nowrap;
}
.pf-legend[hidden] { display: none !important; }
.pf-legend i { width: 7px; height: 7px; border-radius: 50%; background: #f59e0b; display: inline-block; }
@media (max-width: 1679px) {
    .pf-soon { font-size: 0; padding: 0; width: 7px; height: 7px; border: 0; background: #f59e0b; align-self: flex-start; margin-top: 10px; margin-left: -3px; }
    .pf-legend { display: inline-flex; }
}
@media (max-width: 700px) {
    .pf-nav { height: 38px; padding: 0 6px; }
    .pf-tab { padding: 0 9px; gap: 5px; font-size: 12.5px; }
    .pf-tab svg { width: 15px; height: 15px; }
    .pf-soon { margin-top: 9px; }
    .pf-legend { padding-right: 6px; }
    .pf-page-inner { padding: 22px 14px 36px; }
    .pf-page-title { font-size: 21px; }
    .asc-badge { top: 48px; font-size: 10.5px; }
}
.admin-pf-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 6px 14px; margin: 8px 0 12px; }
.admin-pf-sub { font-size: 13px; margin: 6px 0 2px; }
/* Мини-приложение Telegram: экран и так урезан панелью Телеграма, поэтому
   полоса разделов ниже (32 px) и без легенды — пометку объясняет подсказка
   при нажатии на раздел. */
.tg-app .pf-nav { height: 32px; }
.tg-app .pf-tab { font-size: 12px; padding: 0 8px; }
.tg-app .pf-tab svg { width: 14px; height: 14px; }
.tg-app .pf-soon { margin-top: 7px; }
.tg-app .pf-legend { display: none; }

/* ---------- Карта уровней ASC и контекст рынка (07.10.2026) ----------
   Колонка справа от графика; на узком экране уходит под график и
   сворачивается складками, чтобы не отнимать у свечей высоту. */
.asc-map {
    flex: 0 0 300px; width: 300px; min-height: 0; overflow-y: auto;
    background: var(--surface); border-left: 1px solid var(--border);
    font-size: 12px; color: var(--text);
}
.asc-map-fold > summary {
    list-style: none; cursor: pointer; padding: 10px 12px 8px;
    display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
    font-size: 13px;
}
.asc-map-fold > summary::-webkit-details-marker { display: none; }
.asc-map-sub { color: var(--text-muted); font-size: 11px; font-weight: 400; }
.asc-map-body, .asc-ctx-body { padding: 0 10px 10px; }
.asc-map-empty { color: var(--text-muted); font-size: 11.5px; padding: 6px 2px; }
.asc-zc {
    border: 1px solid color-mix(in srgb, var(--zc) 45%, var(--border));
    border-left: 3px solid var(--zc); border-radius: 7px; margin-bottom: 6px;
    background: color-mix(in srgb, var(--zc) 7%, var(--surface));
}
.asc-zc > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px; padding: 6px 9px; }
.asc-zc > summary::-webkit-details-marker { display: none; }
.asc-zc-name { color: var(--zc); font-weight: 700; font-size: 11px; white-space: nowrap; min-width: 62px; }
.asc-zc-range { font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.asc-zc-meta { margin-left: auto; color: var(--text-muted); font-size: 10.5px; white-space: nowrap; }
.asc-zc-rows { border-top: 1px solid var(--border); padding: 4px 9px 6px; }
.asc-zc-rows div { display: flex; gap: 8px; padding: 2px 0; font-size: 11px; }
.asc-zc-rows b { width: 30px; color: var(--text-muted); font-weight: 600; }
.asc-zc-rows i { font-style: normal; margin-left: auto; font-variant-numeric: tabular-nums; }
.asc-line-row {
    display: flex; align-items: center; gap: 8px; padding: 4px 9px; margin-bottom: 6px;
    border: 1px solid var(--border); border-left: 3px solid var(--zc); border-radius: 7px; opacity: .9;
}
.asc-price-card {
    display: flex; justify-content: space-between; gap: 8px; margin: 2px 0 8px; padding: 8px 10px;
    border: 1px solid #3b82f6; border-radius: 8px; background: color-mix(in srgb, #3b82f6 12%, var(--surface));
}
.asc-price-card small { display: block; color: var(--text-muted); font-size: 10px; }
.asc-price-card b { font-size: 16px; font-variant-numeric: tabular-nums; }
.asc-price-in { text-align: right; color: #3b82f6; font-weight: 600; font-size: 11px; }
.asc-ctx-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.asc-ctx-table th { color: var(--text-faint); font-weight: 500; text-align: left; padding: 3px 2px; border-bottom: 1px solid var(--border); }
.asc-ctx-table td { padding: 4px 2px; border-bottom: 1px solid var(--border); font-variant-numeric: tabular-nums; }
.asc-ctx-table .up, .asc-ctx-sum .up { color: #16a34a; font-weight: 600; }
.asc-ctx-table .dn, .asc-ctx-sum .dn { color: #dc2626; font-weight: 600; }
.asc-ctx-table .warn, .asc-ctx-sum .warn { color: #d97706; }
[data-theme="dark"] .asc-ctx-table .up, [data-theme="dark"] .asc-ctx-sum .up { color: #3fb950; }
[data-theme="dark"] .asc-ctx-table .dn, [data-theme="dark"] .asc-ctx-sum .dn { color: #f85149; }
.asc-ctx-sum { display: grid; gap: 5px; margin-top: 8px; }
.asc-ctx-sum div { display: flex; justify-content: space-between; gap: 10px; font-size: 11px; }
.asc-ctx-sum span { color: var(--text-muted); }
.asc-ctx-sum b { text-align: right; }
.asc-ctx-note { margin-top: 8px; color: var(--text-faint); font-size: 10px; line-height: 1.4; }
.asc-zone-opts, .asc-alert-opts { display: grid; gap: 4px; margin-top: 6px; }
@media (max-width: 1100px) {
    .asc-map { flex: 0 0 auto; width: auto; max-height: 46vh; border-left: 0; border-top: 1px solid var(--border); }
    .asc-map-fold:not([open]) > summary { padding-bottom: 10px; }
}
.tg-app .asc-map { max-height: 40vh; }
/* 114e (13.10.2026, пункт 8а): «Карта рынка сейчас» видна и при модели ASC —
   строится по зонам и линиям ASC. Прежнее правило, которое её прятало, снято. */
.mn-status[hidden] { display: none; }
.mn-empty { display: grid; gap: 6px; padding: 6px 0; color: var(--text-muted); font-size: 12px; }
.mn-empty .pl-btn { justify-self: start; }

/* ---------- Уровни на телефоне и в мини-приложении (07.10.2026) ----------
   Карта ASC под графиком и классический лист поверх неё оставляли свечам
   полоску. Теперь на узком экране всё про уровни — один нижний лист по кнопке
   «Уровни»: при ASC — карта и контекст, при классике — «Уровни рядом», «Все
   уровни» и «Карта зон». Виды переключаются вкладками в шапке листа. */
.asc-sheet-head { display: none; }
.mob-lv-tabs { display: none; }
@media (max-width: 860px) {
    .asc-map:not(.sheet-open) { display: none !important; }
    .asc-map.sheet-open:not([hidden]) {
        display: block;
        position: fixed;
        left: 0; right: 0;
        bottom: calc(var(--mob-bar-h) + var(--legal-h, 0px) + env(safe-area-inset-bottom, 0px));
        width: auto; flex: none;
        max-height: 52vh;
        overflow-y: auto;
        overscroll-behavior: contain;
        z-index: 44;
        border: 0; border-top: 1px solid var(--border);
        border-radius: 16px 16px 0 0;
        box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.35);
        padding-bottom: 8px;
    }
    .asc-map.sheet-open .asc-sheet-head {
        display: flex; align-items: center; gap: 8px;
        position: sticky; top: 0; z-index: 2;
        padding: 8px 10px 6px; background: var(--surface);
        border-bottom: 1px solid var(--border);
    }
    .asc-map.sheet-open .asc-sheet-head .mob-lv-tabs { flex: 1; margin: 0; padding: 0; border: 0; }
    .asc-sheet-close {
        flex: 0 0 34px; height: 34px; border: 0; border-radius: 8px;
        background: transparent; color: var(--text-muted); font-size: 16px; cursor: pointer;
    }
    .asc-map.sheet-open .asc-map-fold > summary { display: none; }
    .asc-map.sheet-open .asc-map-body, .asc-map.sheet-open .asc-ctx-body { padding-top: 8px; }
    .asc-map.sheet-open[data-tab="map"] #asc-ctx-fold,
    .asc-map.sheet-open[data-tab="ctx"] #asc-map-fold { display: none; }

    /* Вкладки: сегменты на всю ширину, крупные под палец */
    .mob-lv-tabs:not([hidden]) {
        display: flex; gap: 4px; padding: 6px 10px 8px; margin: 0;
        border-bottom: 1px solid var(--border);
    }
    .mob-lv-tab {
        flex: 1 1 0; min-height: 36px; padding: 0 6px;
        border: 1px solid var(--border); border-radius: 9px;
        background: transparent; color: var(--text-muted);
        font: inherit; font-size: 13px; font-weight: 600; white-space: nowrap; cursor: pointer;
    }
    .mob-lv-tab[hidden] { display: none; }
    .mob-lv-tab.active {
        background: color-mix(in srgb, var(--accent, #3b82f6) 16%, transparent);
        border-color: var(--accent, #3b82f6); color: var(--text);
    }
    /* Во вкладке «Все уровни» карточек поддержки и сопротивления нет: те же
       уровни стоят первыми строками списка, а место отдаём списку */
    .levels-panel.lp-open-all .lp-key { display: none !important; }
    /* Стыковка «снизу», запомненная с компьютера, ставила карточки в строку
       flex: на телефоне цена занимала пол-строки, а сопротивление уезжало
       вниз. На телефоне — всегда две карточки рядом */
    .levels-panel.dock-bottom .lp-key { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
    .levels-panel .lp-kcard, .levels-panel.dock-bottom .lp-kcard { min-width: 0; }
    .levels-panel.lp-open-all { max-height: 56vh; }
    /* Складку «Все уровни рядом» открывает вкладка — заголовок складки лишний */
    .levels-panel:has(.lv-tabs-classic:not([hidden])) #lp-all > summary { display: none; }
}

/* ---------- Лист уровней во весь экран на телефоне (07.10.2026) ----------
   При графике на половину экрана под ним помещались только шапка и вкладки
   листа, а список уровней — нет. Теперь на телефоне и в мини-приложении лист
   открывается от верха экрана до нижней полосы кнопок, а закрытие (✕ или
   повторное «Уровни») возвращает график на всю высоту. */
@media (max-width: 860px) {
    /* «Уровни рядом» — две карточки, им весь экран не нужен: остаются
       компактным листом над графиком. Во весь экран — «Все уровни», «Карта
       зон» и карта ASC, где строк много. */
    .levels-panel.lp-open-all,
    .levels-panel.lp-open-all.dock-left, .levels-panel.lp-open-all.dock-right,
    .levels-panel.lp-open-all.dock-bottom, .levels-panel.lp-open-all.dock-float,
    .levels-panel.levels-map,
    .levels-panel.levels-map.dock-left, .levels-panel.levels-map.dock-right,
    .levels-panel.levels-map.dock-float,
    .asc-map.sheet-open:not([hidden]) {
        top: env(safe-area-inset-top, 0px);
        bottom: calc(var(--mob-bar-h) + var(--legal-h, 0px) + env(safe-area-inset-bottom, 0px));
        max-height: none !important;
        height: auto;
        border-radius: 0;
        z-index: 46;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }
    .levels-panel[hidden] { display: none !important; }
    .asc-map.sheet-open:not([hidden]) { display: block; overflow-y: auto; }
    /* Список уровней забирает всю оставшуюся высоту и прокручивается сам */
    .levels-panel > .lp-all[open] { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
    .levels-panel > .lp-all[open] .lp-list { flex: 1 1 auto; min-height: 0; max-height: none; overflow-y: auto; }
    .levels-panel .lp-key { flex: none; }
    .levels-map #lm-list { flex: 1 1 auto; min-height: 0; max-height: none; overflow-y: auto; }
    .levels-panel > .lp-head, .levels-panel > .mob-lv-tabs, .levels-panel > .lp-foot, .levels-map > .lm-warn { flex: none; }
}

/* Pine-код уровней — инструмент администратора для записи роликов на
   компьютере. На телефоне и в мини-приложении вставить код в редактор Pine
   всё равно негде, а кнопка занимала место в полосе над графиком —
   убрана по просьбе владельца 07.10.2026. */
@media (max-width: 860px) {
    #pine-levels-btn { display: none !important; }
}
.tg-app #pine-levels-btn { display: none !important; }
/* 141 (18.10.2026): Pine собирает только классические уровни — в режиме «только ASC» кнопки нет */
[data-level-model="asc"] #pine-levels-btn { display: none !important; }

/* Вкладки окон над картой ASC (07.10.2026): в раскладках 2 и 4 без скрепки
   у каждого окна своя бумага, и карта показывает выбранное окно. Выбранное
   окно обведено, чтобы было видно, к какому графику относятся числа. */
.asc-win-tabs { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 0 10px; }
.asc-win-tabs[hidden] { display: none; }
.asc-win-tab {
    flex: 1 1 calc(50% - 6px); min-width: 0; padding: 6px 8px;
    border: 1px solid var(--color-border, #2a2e39); border-radius: 8px;
    background: transparent; color: var(--color-text-muted, #8b949e);
    font: 600 12px/1.2 Inter, sans-serif; cursor: pointer;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.asc-win-tab:hover:not(:disabled) { color: var(--color-text, #e6edf3); }
.asc-win-tab.active {
    border-color: #3b82f6; color: var(--color-text, #e6edf3);
    background: rgba(59, 130, 246, .14);
}
.asc-win-tab:disabled { opacity: .45; cursor: default; }
#chart.asc-picked, .mini-panel.asc-picked { outline: 2px solid #3b82f6; outline-offset: -2px; }


/* ===== Один экран (08.10.2026, просьба владельца) =====
   Вкладка «Уровни» на всех устройствах без лишних строк над графиком.
   1) Компьютер: «Уровни рядом» под «Картой рынка» в одном правом столбце
      (было два столбца по 300 пкс, и под картой пустовало место).
   2) Телефон и Telegram: выбор таймфрейма в полосе над графиком дублировал
      ленту таймфреймов на самом графике и раздувал полосу до 51 пкс (список
      на телефоне — 44 пкс под палец). Где лента есть, список убираем.
   3) Горизонтальный телефон: шапка, вкладки разделов и нижние кнопки ниже —
      при высоте 390 пкс графику оставалось 170 пкс. Правило общее для всех
      разделов, «Арбитраж» тоже получает место. */
@media (min-width: 1101px) {
    .chart-area.mn-open.lp-dock-right { padding-right: 320px; }
    .chart-area.mn-open .levels-panel.dock-right { right: 14px; top: calc(14px + var(--mn-h, 350px) + 10px); width: 292px; }
}
@media (max-width: 860px) {
    .chart-area:has(.chart-tf-strip) .chart-topbar .topbar-timeframe { display: none; }
    .chart-topbar .topbar-timeframe { height: 30px; min-height: 30px; }
    .chart-topbar { padding-top: 3px; padding-bottom: 3px; }
}
@media (max-height: 520px) and (orientation: landscape) {
    .header, .tg-app .header { height: 40px; min-height: 40px; padding-top: 2px; padding-bottom: 2px; }
    .pf-nav { height: 32px; }
    .pf-tab { font-size: 12px; padding: 0 10px; }
    :root { --mob-bar-h: 40px; }
    .mob-bar { padding: 2px 4px calc(2px + env(safe-area-inset-bottom, 0px)); }
    .mob-btn { min-height: 34px; flex-direction: row; gap: 6px; font-size: 11px; }
    .mob-btn svg { width: 17px; height: 17px; }
    .mob-btn-main svg { width: 18px; height: 18px; }
}
/* Ноутбук 1280–1500 с открытой «Картой рынка»: полоса над графиком
   переносилась на вторую строку из-за одной кнопки «Во весь экран».
   Ужимаем промежутки и оставляем у «Скрепки» только значок (подсказка
   в title остаётся) — полоса снова в одну строку. */
@media (min-width: 861px) and (max-width: 1500px) {
    .chart-topbar { gap: 4px; }
    .chart-topbar .multi-link span { display: none; }
    .chart-topbar .multi-link { padding-left: 7px; padding-right: 7px; }
}

/* ===== deploy101 (10.10.2026): общий актив разделов и переходы — pfasset.js ===== */
.pf-tab[hidden] { display: none; }
/* На компьютере в «Арбитраже» и «Опционах» в шапке тоже виден актив раздела:
   у них нет полосы бумаги, как на «Уровнях», а выбор общего актива нужен */
@media (min-width: 861px) {
    html[data-pf-page="arbitrage"] .head-ticker,
    html[data-pf-page="options"] .head-ticker {
        display: inline-flex; flex-direction: column; align-items: flex-start; gap: 1px;
        min-height: 40px; justify-content: center; max-width: 260px; padding: 4px 10px; margin-left: 10px;
        border: 1px solid var(--border); border-radius: var(--radius-sm);
        background: var(--surface-2, var(--surface)); color: var(--text); cursor: pointer; text-align: left;
    }
    html[data-pf-page="arbitrage"] .head-ticker-name,
    html[data-pf-page="options"] .head-ticker-name { font-size: 13px; font-weight: 700; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
    html[data-pf-page="arbitrage"] .head-ticker-tf,
    html[data-pf-page="options"] .head-ticker-tf { font-size: 10.5px; line-height: 1.1; color: var(--text-muted); white-space: nowrap; }
}
.pf-pick { position: fixed; inset: 0; z-index: 90; background: rgba(0, 0, 0, .35); display: flex; align-items: flex-start; justify-content: center; padding-top: 70px; }
.pf-pick[hidden] { display: none; }
.pf-pick-box { width: min(440px, calc(100vw - 24px)); max-height: calc(100vh - 100px); overflow: auto; background: var(--surface); color: var(--text);
    border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px 16px; box-shadow: 0 12px 40px rgba(0, 0, 0, .25); }
.pf-pick-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; font-size: 15px; }
.pf-pick-close { min-width: 40px; min-height: 40px; border: 0; background: none; color: var(--text-muted); font-size: 22px; cursor: pointer; }
.pf-pick-list { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.pf-asset-chip { min-height: 40px; padding: 0 12px; border: 1px solid var(--border); border-radius: 20px; background: var(--surface-2, var(--surface));
    color: var(--text); font: 500 13px/1 var(--font-body); cursor: pointer; }
.pf-asset-chip.on { border-color: #0e9f86; background: rgba(14, 159, 134, .12); font-weight: 700; }
.pf-pick-sync { display: flex; gap: 10px; align-items: flex-start; padding-top: 12px; border-top: 1px solid var(--border); cursor: pointer; font-size: 13.5px; }
.pf-pick-sync input { width: 20px; height: 20px; margin: 1px 0 0; flex-shrink: 0; }
.pf-pick-sync small { display: block; margin-top: 3px; color: var(--text-muted); font-size: 12px; line-height: 1.35; }
@media (max-width: 760px) {
    .pf-pick { align-items: flex-end; padding-top: 0; }
    .pf-pick-box { width: 100%; border-radius: 14px 14px 0 0; padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px)); }
}
.pf-asset-note { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 8px 12px; padding: 8px 10px; border-radius: 8px;
    background: rgba(245, 158, 11, .12); border: 1px solid rgba(245, 158, 11, .35); color: var(--text); font-size: 13px; }
.pf-asset-note > span { flex: 1 1 260px; }
.pf-asset-note .pf-asset-chip { min-height: 32px; padding: 0 10px; font-size: 12.5px; }
.pf-asset-x { min-width: 40px; min-height: 32px; border: 0; background: none; color: var(--text-muted); font-size: 18px; cursor: pointer; }
.pf-rel { display: inline-flex; gap: 4px; align-items: center; }
.pf-rel[hidden] { display: none; }
.pf-rel-btn { height: 28px; padding: 0 9px; border: 1px solid var(--border); border-radius: 14px; background: none; color: var(--text);
    font: 500 12px/1 var(--font-body); white-space: nowrap; cursor: pointer; }
.pf-rel-btn:hover { background: var(--surface-2); }
.arb-legs-lv { min-height: 32px; padding: 0 10px; border: 1px solid var(--border); border-radius: 6px; background: none; color: var(--text);
    font: 500 12.5px/1 var(--font-body); white-space: nowrap; cursor: pointer; }
.arb-legs-lv:hover { background: var(--surface-2); }
.pf-legs { position: fixed; z-index: 91; width: 240px; padding: 6px; background: var(--surface); border: 1px solid var(--border);
    border-radius: 10px; box-shadow: 0 10px 30px rgba(0, 0, 0, .22); }
.pf-legs[hidden] { display: none; }
.pf-legs button { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%; min-height: 44px; padding: 6px 10px;
    border: 0; border-radius: 6px; background: none; color: var(--text); text-align: left; cursor: pointer; }
.pf-legs button:hover:not(:disabled) { background: var(--surface-2); }
.pf-legs button:disabled { opacity: .55; cursor: default; }
.pf-legs small { color: var(--text-muted); font-size: 11.5px; }

/* ---------- deploy102 (10.10.2026): режим «Основной / Подробный» ---------- */
.pf-mode { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; flex: 0 0 auto; }
.pf-mode button { border: 0; background: transparent; color: var(--text-muted); font: inherit; font-size: 12px; padding: 4px 10px; cursor: pointer; min-height: 28px; }
.pf-mode button + button { border-left: 1px solid var(--border); }
.pf-mode button.on { background: var(--accent, #2962ff); color: #fff; }
.pf-mode-hint { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 1200; display: flex; align-items: center; gap: 10px;
    max-width: min(560px, calc(100vw - 24px)); padding: 10px 12px; border-radius: 10px; background: var(--surface, #fff); color: var(--text, #111);
    border: 1px solid var(--border); box-shadow: 0 8px 24px rgba(0, 0, 0, .18); font-size: 13px; line-height: 1.35; }
.pf-mode-hint span { flex: 1 1 auto; }
.pf-mode-try { border: 0; border-radius: 8px; background: var(--accent, #2962ff); color: #fff; padding: 6px 12px; font: inherit; cursor: pointer; white-space: nowrap; }
.pf-mode-x { border: 0; background: transparent; color: var(--text-muted); font-size: 18px; cursor: pointer; padding: 0 4px; }
@media (max-width: 640px) { .pf-mode-hint { bottom: 72px; font-size: 12px; } }
/* Длинные подписи в «Основном»: одна строка и «Подробнее» */
html[data-ui-mode="basic"] :is(.opt-foot, .pf-clamp):not(.pf-open) { display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
html[data-ui-mode="basic"] :is(.opt-foot, .pf-clamp).pf-measure { display: -webkit-box; -webkit-line-clamp: 1; }
html[data-ui-mode="basic"] :is(.opt-foot, .pf-clamp).pf-long { cursor: pointer; position: relative; padding-right: 92px; }
html[data-ui-mode="basic"] :is(.opt-foot, .pf-clamp).pf-long::after { content: 'Подробнее'; position: absolute; right: 0; top: 0; color: var(--accent, #2962ff); background: var(--bg, transparent); padding-left: 6px; }
html[data-ui-mode="basic"] :is(.opt-foot, .pf-clamp).pf-long.pf-open::after { content: 'Свернуть'; top: auto; bottom: 0; }
/* Элементы только для «Подробного» и только для «Основного» */
html[data-ui-mode="basic"] .pf-full-only:not(.pf-shown) { display: none !important; }
html[data-ui-mode="full"] .pf-basic-only { display: none !important; }
.lv-uimode.pf-mode { margin-left: 6px; }
.lv-uimode.pf-mode button { min-height: 26px; padding: 3px 8px; }
#sidebar .lv-more { display: block; margin: 4px 0 8px; font-size: 12px; }
@media (max-width: 760px) { .pf-mode button { min-height: 40px; min-width: 40px; } .lv-uimode.pf-mode button { padding: 3px 7px; font-size: 11px; } }
.chart-topbar.topbar-min > .lv-uimode.pf-mode { display: inline-flex !important; }
.pf-mode .pf-s { display: none; }
@media (max-width: 760px) {
    .pf-mode .pf-l { display: none; }
    .pf-mode .pf-s { display: inline; }
    .pf-mode button { padding: 4px 10px; }
}

/* ---------- deploy103 (10.10.2026): единый центр оповещений ---------- */
.pf-bell { position: relative; }
.pf-bell[hidden] { display: none !important; }
.pf-bell-n { position: absolute; top: 2px; right: 2px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: #ef5350; color: #fff;
    font-size: 10px; font-weight: 700; line-height: 16px; text-align: center; pointer-events: none; }
.centr { position: fixed; inset: 0; z-index: 1300; }
.centr[hidden] { display: none; }
.cz-back { position: absolute; inset: 0; background: rgba(0, 0, 0, .28); }
.cz-panel { position: absolute; top: 0; right: 0; bottom: 0; width: min(440px, 100vw); display: flex; flex-direction: column;
    background: var(--surface, #fff); color: var(--text, #111); box-shadow: -8px 0 24px rgba(0, 0, 0, .18); }
.cz-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px 6px; font-size: 16px; }
.cz-x { border: 0; background: transparent; color: var(--text-muted); font-size: 24px; line-height: 1; cursor: pointer; min-width: 40px; min-height: 40px; }
.cz-tabs { display: flex; gap: 4px; padding: 0 14px 8px; border-bottom: 1px solid var(--border); }
.cz-tabs button, .cz-chips button, .cz-seg button { border: 1px solid var(--border); background: transparent; color: var(--text-muted); border-radius: 8px;
    padding: 6px 12px; font: inherit; font-size: 13px; cursor: pointer; min-height: 34px; }
.cz-tabs button.on, .cz-chips button.on, .cz-seg button.on { background: var(--accent, #2962ff); border-color: var(--accent, #2962ff); color: #fff; }
.cz-body { flex: 1 1 auto; overflow-y: auto; padding: 10px 14px 24px; font-size: 13px; line-height: 1.4; }
.cz-note { padding: 8px 10px; border-radius: 8px; background: var(--surface-2, rgba(0, 0, 0, .04)); margin-bottom: 10px; color: var(--text-muted); }
.cz-note b { color: var(--text, #111); }
.cz-warn { background: rgba(255, 152, 0, .12); color: var(--text, #111); }
.cz-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.cz-chips button { padding: 4px 10px; min-height: 30px; font-size: 12px; }
.cz-list { list-style: none; margin: 0; padding: 0; }
.cz-ev { padding: 8px 0; border-bottom: 1px solid var(--border); }
.cz-ev.cz-new { box-shadow: inset 3px 0 0 var(--accent, #2962ff); padding-left: 8px; }
.cz-ev-h { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 11px; color: var(--text-muted); margin-bottom: 2px; }
.cz-ev-t { overflow-wrap: anywhere; }
/* 128 (18.10.2026): кнопка события портфеля — на «Риск-панель» */
.cz-ev-a { margin-top: 6px; }
.cz-tag { padding: 1px 6px; border-radius: 6px; font-weight: 600; background: rgba(41, 98, 255, .1); color: var(--accent, #2962ff); }
.cz-tag-arb { background: rgba(156, 39, 176, .1); color: #8e24aa; }
.cz-tag-opt, .cz-tag-radar { background: rgba(0, 150, 136, .12); color: #00897b; }
.cz-tag-pos { background: rgba(239, 83, 80, .12); color: #e53935; }
.cz-tag-own { background: rgba(255, 152, 0, .14); color: #ef6c00; }
.cz-tg { margin-left: auto; }
.cz-empty { color: var(--text-muted); padding: 16px 0; }
.cz-set { display: grid; gap: 14px; }
.cz-row { display: flex; gap: 8px; align-items: flex-start; cursor: pointer; }
.cz-row input { margin-top: 3px; }
.cz-row small, .cz-block small { display: block; color: var(--text-muted); font-size: 12px; margin-top: 4px; }
.cz-block { display: grid; gap: 6px; }
.cz-seg { display: flex; gap: 6px; }
.cz-seg button { min-width: 56px; }
.cz-hours { display: flex; align-items: center; gap: 6px; }
.cz-sel { font: inherit; padding: 4px 6px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface, #fff); color: inherit; }
.cz-prio { margin: 0; padding-left: 20px; display: grid; gap: 4px; }
.cz-msg { min-height: 18px; color: var(--text-muted); font-size: 12px; }
.cz-rules { list-style: none; margin: 0; padding: 0; }
.cz-rules li { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.cz-rules li > span:first-child { flex: 1 1 auto; display: grid; }
.cz-rules small { color: var(--text-muted); font-size: 12px; }
.cz-rn { font-weight: 700; min-width: 24px; text-align: right; }
.cz-btn { border: 1px solid var(--border); background: transparent; color: var(--accent, #2962ff); border-radius: 8px; padding: 6px 12px; font: inherit; cursor: pointer; min-height: 34px; }
body.cz-on { overflow: hidden; }
@media (max-width: 760px) {
    .cz-panel { top: auto; left: 0; width: 100vw; height: 88vh; border-radius: 14px 14px 0 0; box-shadow: 0 -8px 24px rgba(0, 0, 0, .2); }
    .cz-tabs button, .cz-seg button, .cz-btn, .cz-chips button { min-height: 40px; }
}

/* ---------- deploy104 (10.10.2026): «Как сыграть уровень» в «Карте рынка сейчас» ---------- */
@media (min-width: 861px) {
    .market-now { max-height: calc(100% - 28px); overflow-y: auto; }
}
.mn-play[hidden] { display: none; }
.mn-play { display: grid; gap: 8px; padding-top: 8px; border-top: 1px solid var(--border); font-size: 12px; line-height: 1.4; }
.pl-head { font-size: 13px; }
.pl-head span { display: block; color: var(--text-muted); font-size: 11px; }
.pl-lead, .pl-note, .pl-disc, .pl-why, .pl-more { color: var(--text-muted); font-size: 11px; }
.pl-disc { border-top: 1px dashed var(--border); padding-top: 6px; }
.pl-m { display: grid; gap: 6px; padding: 8px; border: 1px solid var(--border); border-radius: 10px; }
.pl-m-h { font-weight: 700; font-size: 12px; display: flex; justify-content: space-between; gap: 6px; flex-wrap: wrap; }
.pl-m-h span { font-weight: 400; color: var(--text-muted); font-size: 11px; }
.pl-sc { display: grid; gap: 3px; }
.pl-sc + .pl-sc { border-top: 1px solid var(--border); padding-top: 6px; }
.pl-sc-t { overflow-wrap: anywhere; }
.pl-nums { display: flex; flex-wrap: wrap; gap: 4px 10px; }
.pl-nums span { color: var(--text-muted); }
.pl-nums b { color: var(--text, inherit); font-variant-numeric: tabular-nums; }
.pl-btn { justify-self: start; border: 1px solid var(--border); background: transparent; color: var(--accent, #2962ff); border-radius: 8px;
    padding: 4px 10px; font: inherit; font-size: 12px; cursor: pointer; min-height: 30px; }
@media (max-width: 860px) { .pl-btn { min-height: 40px; } }

/* 114e (13.10.2026, пункт 8г): панель способов — каждый свёрнут в одну строку
   с итогом и двумя проверками по профилю; строка раскрывает расчёт */
.pl-ways { display: grid; gap: 6px; }
.pl-way { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.pl-way.is-pass { border-color: color-mix(in srgb, #16a34a 45%, var(--border)); }
.pl-way-h { display: grid; grid-template-columns: auto 1fr auto; align-items: baseline; gap: 4px 10px; width: 100%;
    padding: 8px 10px; border: 0; background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer; min-height: 36px; }
.pl-way-h b { font-size: 12px; }
.pl-way-s { color: var(--text-muted); font-size: 11px; font-variant-numeric: tabular-nums; min-width: 0; overflow-wrap: anywhere; }
.pl-way-a { width: 8px; height: 8px; border-right: 1.5px solid var(--text-muted); border-bottom: 1.5px solid var(--text-muted);
    transform: rotate(45deg); align-self: center; transition: transform .15s; }
.pl-way.is-open .pl-way-a { transform: rotate(-135deg); }
.pl-way-h:hover { background: var(--surface-2, rgba(127, 127, 127, .06)); }
.pl-way-h:focus-visible { outline: 2px solid var(--accent, #2962ff); outline-offset: -2px; }
.pl-way-c { display: flex; flex-wrap: wrap; gap: 4px; padding: 0 10px 8px; }
.pl-chk { font-size: 11px; line-height: 1.3; padding: 2px 6px; border-radius: 6px; background: var(--surface-2, rgba(127, 127, 127, .08)); color: var(--text-muted); }
.pl-chk.is-ok { color: #15803d; background: rgba(22, 163, 74, .1); }
.pl-chk.is-no { color: #b91c1c; background: rgba(220, 38, 38, .09); }
[data-theme="dark"] .pl-chk.is-ok, :root:not([data-theme="light"]) .pl-chk.is-ok { color: #4ade80; }
[data-theme="dark"] .pl-chk.is-no, :root:not([data-theme="light"]) .pl-chk.is-no { color: #f87171; }
[data-theme="light"] .pl-chk.is-ok { color: #15803d; }
[data-theme="light"] .pl-chk.is-no { color: #b91c1c; }
.pl-way-b { display: grid; gap: 8px; padding: 0 8px 8px; }
.pl-way-b > .pl-m { border-color: var(--border); }
.pl-qty input[data-pl-qty] { width: 86px; }
.pl-qty input[data-pl-qty]::placeholder { font-size: 11px; }
.pl-cmp-d > summary { cursor: pointer; font-weight: 700; font-size: 12px; padding: 6px 0; }
.pl-cmp-d[open] > summary { margin-bottom: 6px; }
@media (max-width: 860px) {
    .pl-way-h { grid-template-columns: 1fr auto; min-height: 44px; }
    .pl-way-h .pl-way-s { grid-column: 1 / -1; grid-row: 2; }
}

/* deploy105b (10.10.2026): копия плашки поверх страницы — для разделов, где
   графика «Уровней» не видно («Арбитраж», «Опционы», «Обзор»). */
.alert-banner.alert-banner-float { position: fixed; top: 72px; z-index: 1200; }
.alert-banner.alert-banner-float.pos-bottom { top: auto; bottom: calc(var(--legal-h, 0px) + 24px); }
@media (max-width: 760px) {
    .alert-banner.alert-banner-float.pos-bottom { bottom: calc(var(--legal-h, 0px) + var(--mob-bar-h, 56px) + 12px); }
}

/* 113c (12.10.2026): раздел не входит в подписку — маленький замок у вкладки;
   вкладка открывает описание раздела по уровням подписки */
.pf-tab.is-locked::after {
    content: ""; display: inline-block; width: 10px; height: 10px; margin-left: 6px; vertical-align: -1px;
    opacity: .7; background: currentColor;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 10V7a6 6 0 0 1 12 0v3h1a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V11a1 1 0 0 1 1-1h1zm2 0h8V7a4 4 0 0 0-8 0v3z'/%3E%3C/svg%3E") center / contain no-repeat;
            mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 10V7a6 6 0 0 1 12 0v3h1a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V11a1 1 0 0 1 1-1h1zm2 0h8V7a4 4 0 0 0-8 0v3z'/%3E%3C/svg%3E") center / contain no-repeat;
}
.pf-page-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.pf-more { text-decoration: none; background: var(--accent, #14b8a6); color: #fff; border-color: transparent; }
.pf-more[hidden] { display: none !important; }

/* 113c (12.10.2026): плашка «по профилю трейдера» — профиль и состав подписки */
.pf-gap { position: fixed; left: 18px; bottom: 18px; z-index: 60;
    width: min(400px, calc(100vw - 24px)); display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
    padding: 12px 14px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2, #1b1f27);
    color: var(--text); box-shadow: 0 10px 30px rgba(0,0,0,.25); font-size: 13px; line-height: 1.45; }
.pf-gap-t { flex: 1 1 100%; }
.pf-gap-more { color: var(--accent, #14b8a6); font-weight: 600; white-space: nowrap; }
.pf-gap-x { background: none; border: 1px solid var(--border); color: var(--text-muted, inherit); border-radius: 6px; padding: 4px 10px; cursor: pointer; font: inherit; }
@media (max-width: 900px) { .pf-gap { left: 12px; right: 12px; width: auto; bottom: calc(72px + env(safe-area-inset-bottom, 0px)); } }

/* 113c-2 (12.10.2026): ранняя цена «Деривативов» в карточке тарифа */
.plan-early { margin: 6px 0 8px; padding: 7px 10px; border-radius: 8px; border: 1px dashed var(--accent, #14b8a6); font-size: 12.5px; line-height: 1.45; }
/* 113c-2: блок «Акции «Деривативов»» у администратора — поля в строку */
#admin-promo-box fieldset { display: flex; flex-direction: row; justify-content: flex-start; flex-wrap: wrap; align-items: center; gap: 8px 18px; border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin: 10px 0; }
#admin-promo-box fieldset legend { padding: 0 6px; font-weight: 600; font-size: 13px; }
#admin-promo-box fieldset label { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-size: 13px; }
#admin-promo-box fieldset input[type=date] { width: 150px; }
#admin-promo-box fieldset input[type=number] { width: 90px; }
#admin-promo-box #admin-promo-save { width: auto; }

/* 113d (12.10.2026): «Приведи друга» и зачёт бонусных дней в кабинете */
.billing-bonus { display: flex; align-items: center; gap: 8px; margin: 10px 0 4px; font-size: 0.92rem; cursor: pointer; }
.billing-bonus input { width: 16px; height: 16px; flex: none; }
.billing-bonus[hidden], .billing-ref[hidden], .billing-ref-link[hidden], #billing-ref-term[hidden], #billing-ref-msg[hidden] { display: none; }
.plan-bonus { margin: 6px 0 8px; padding: 7px 10px; border-radius: 8px; background: var(--surface-2); font-size: 12.5px; line-height: 1.45; }
.billing-ref { margin: 16px 0 8px; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); }
.billing-ref-head { font-weight: 650; font-size: 1rem; margin-bottom: 6px; }
.billing-ref-link { display: flex; gap: 8px; margin: 8px 0; }
.billing-ref-link input { flex: 1 1 auto; min-width: 0; padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); color: var(--text); font: inherit; font-size: 0.88rem; }
.billing-ref .billing-ref-link .btn, .billing-ref #billing-ref-term { flex: none; width: auto; min-width: 0; padding-left: 16px; padding-right: 16px; margin: 0; }
.billing-ref #billing-ref-term { margin-top: 4px; }
.billing-ref .billing-ref-link input { flex: 1 1 auto; width: auto; margin: 0; }
@media (max-width: 520px) {
    .billing-ref .billing-ref-link .btn { padding-left: 12px; padding-right: 12px; }
}

/* 113f (12.10.2026): «Сообщить о проблеме». Кнопка в шапке перед темой:
   на широком экране — значок и подпись, на узком — только значок, чтобы
   не теснить бумагу и вход. Окно выше кабинета и центра оповещений. */
.fb-btn { gap: 6px; }
.fb-btn .fb-btn-text { display: none; font-size: 13px; font-weight: 500; white-space: nowrap; }
@media (min-width: 1280px) {
    .fb-btn { padding: 6px 10px 6px 8px; }
    .fb-btn .fb-btn-text { display: inline; }
}
.fb-overlay { z-index: 1400; }
@media (max-width: 600px) { .fb-btn { display: none; } }
.fb-help-menu {
    position: fixed; z-index: 1350; min-width: 210px; padding: 4px;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35); display: flex; flex-direction: column;
}
.fb-help-menu a, .fb-help-menu button {
    display: block; text-align: left; padding: 11px 12px; font: inherit; font-size: 15px; color: var(--text);
    background: none; border: 0; border-radius: var(--radius-sm); text-decoration: none; cursor: pointer;
}
.fb-help-menu a:hover, .fb-help-menu button:hover { background: var(--surface-2); }
.fb-box { max-width: 460px; }
.fb-label { display: block; font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.fb-form textarea {
    width: 100%; box-sizing: border-box; resize: vertical; min-height: 110px;
    font: inherit; font-size: 14px; color: var(--text); background: var(--surface-2);
    border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 10px;
}
.fb-form textarea:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
.fb-check { display: flex; align-items: center; gap: 8px; margin: 10px 0 6px; font-size: 14px; color: var(--text); cursor: pointer; }
.fb-we { font-size: 12px; line-height: 1.45; color: var(--text-muted); margin: 6px 0 0; }
.fb-msg { font-size: 13px; min-height: 18px; margin: 8px 0 0; color: var(--text); }
.fb-msg.is-bad { color: var(--red); }
.fb-actions { display: flex; justify-content: flex-end; margin-top: 10px; }
.fb-guest p { font-size: 14px; color: var(--text); margin: 0 0 12px; }
@media (max-width: 600px) {
    .fb-overlay { align-items: flex-end; padding: 0; }
    .fb-box { max-width: none; border-radius: var(--radius-md) var(--radius-md) 0 0; max-height: 92vh; }
}
/* 113f: список обращений в панели администратора */
.fb-adm-new { color: var(--red); font-weight: 600; }
.fb-adm-filters { display: flex; gap: 12px; flex-wrap: wrap; }
.fb-adm-filters .admin-field { min-width: 150px; }
.fb-adm-item { border: 1px solid var(--border); border-left: 3px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; margin: 10px 0; background: var(--surface-2); }
.fb-adm-item.fb-st-new { border-left-color: var(--red); }
.fb-adm-item.fb-st-work { border-left-color: var(--primary); }
.fb-adm-item.fb-st-done { border-left-color: var(--green); }
.fb-adm-item.fb-adm-focus { outline: 2px solid var(--primary); }
.fb-adm-head { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; color: var(--text); }
.fb-adm-meta { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.admin-section .fb-adm-head .fb-adm-status { margin-left: auto; width: auto; min-width: 120px; font-size: 13px; padding: 3px 6px; }
.fb-adm-where { font-size: 12px; color: var(--text-muted); margin: 4px 0 6px; }
.fb-adm-text { font-size: 14px; color: var(--text); white-space: pre-wrap; overflow-wrap: anywhere; }
.fb-adm-shot img { display: block; max-width: 100%; max-height: 220px; margin-top: 8px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.fb-adm-more { font-size: 12px; color: var(--text-muted); margin-top: 6px; overflow-wrap: anywhere; }
.fb-adm-more summary { cursor: pointer; }
.fb-adm-errs { margin: 4px 0 0 16px; padding: 0; }
.fb-adm-answer { font-size: 13px; color: var(--text); margin-top: 8px; padding: 6px 8px; background: var(--surface-3); border-radius: var(--radius-sm); white-space: pre-wrap; }
.fb-adm-reply { display: flex; gap: 8px; align-items: flex-start; margin-top: 8px; }
.fb-adm-reply textarea { flex: 1; min-width: 0; font: inherit; font-size: 13px; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 6px 8px; resize: vertical; }

/* 114d (13.10.2026): полоса «← к ситуации № N» под меню разделов */
.pf-sitback { display: flex; align-items: center; gap: 6px; padding: 4px 12px; background: color-mix(in srgb, var(--accent, #3b82f6) 8%, var(--surface, #fff)); border-bottom: 1px solid var(--border, #e5e7eb); font-size: 13px; }
.pf-sitback[hidden] { display: none; }
.pf-sitback-go { border: 0; background: none; color: var(--accent, #2563eb); font: inherit; font-weight: 600; cursor: pointer; padding: 2px 0; }
.pf-sitback-go:hover { text-decoration: underline; }
.pf-sitback-x { margin-left: auto; border: 0; background: none; color: var(--text-muted, #6b7280); font-size: 18px; line-height: 1; cursor: pointer; padding: 0 4px; }

/* 114k (14.10.2026): плотность больших таблиц — «Основные / Подробные», закрепление
   ключевой колонки, свежесть котировок, синхронность ног, карточки на телефоне (dense.js) */
.u-dseg { display: inline-flex; align-items: center; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm, 6px); overflow: hidden; flex: none; }
.u-dseg button { background: none; border: 0; color: var(--text-muted); padding: 6px 10px; font-size: 12px; cursor: pointer; font-family: inherit; white-space: nowrap; }
.u-dseg button.on { background: rgba(59, 130, 246, .18); color: var(--text); }
.u-dseg button:focus-visible { outline: 2px solid #3b82f6; outline-offset: -2px; }
table.u-dense.u-basic .u-more { display: none; }
table.u-dense:not(.u-cards) .u-stick { position: sticky; left: 0; z-index: 1; background: var(--surface); }
table.u-dense:not(.u-cards) th.u-stick { z-index: 3; }
table.u-dense:not(.u-cards) .u-stick::after { content: ""; position: absolute; top: 0; right: -1px; bottom: 0; width: 1px; background: var(--border); }
.u-old, table .u-old { color: var(--text-faint, #8b8f98) !important; }
.u-age { font-size: 10.5px; color: var(--text-faint, #8b8f98); white-space: nowrap; }
.u-sync { font-size: 11px; white-space: nowrap; padding: 1px 6px; border-radius: 999px; border: 1px solid var(--border); }
.u-sync-ok { color: #26a69a; border-color: rgba(38, 166, 154, .45); }
.u-sync-mid { color: var(--text-muted); }
.u-sync-warn { color: #b7791f; background: rgba(245, 158, 11, .14); border-color: rgba(245, 158, 11, .55); }
.u-sync-na { color: var(--text-faint, #8b8f98); }
.u-hq { display: inline-block; margin-left: 3px; width: 14px; height: 14px; line-height: 13px; text-align: center; border-radius: 50%; border: 1px solid var(--border); color: var(--text-muted); font-size: 10px; text-decoration: none; vertical-align: 1px; }
.u-hq:hover { color: var(--text); border-color: currentColor; }
td.u-ctog { display: none; }
/* Карточки на телефоне: шапка скрыта, строка — карточка; в свёрнутой — главные числа */
@media (max-width: 640px) {
    table.u-cards, table.u-cards tbody { display: block; width: 100%; }
    table.u-cards thead { display: none; }
    table.u-cards tr { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; margin: 0 0 8px; background: var(--surface); }
    table.u-cards td { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; padding: 0 !important; border: 0 !important; text-align: left !important; white-space: normal !important; min-width: 0 !important; max-width: none !important; position: static !important; background: none !important; }
    table.u-cards td::before { content: attr(data-l); font-size: 10.5px; color: var(--text-muted); font-weight: 400; }
    table.u-cards td:not([data-l])::before, table.u-cards td[data-l=""]::before { content: none; }
    table.u-cards td.u-stick { grid-column: 1 / -1; font-size: 13.5px; }
    table.u-cards td.u-stick::before { content: none; }
    table.u-cards tr:not(.u-open) td:not(.u-cmain):not(.u-ctog) { display: none; }
    table.u-cards.u-basic tr.u-open td.u-more { display: flex; }
    table.u-cards td.u-ctog { display: flex; grid-column: 1 / -1; align-items: flex-start; }
    table.u-cards td.u-ctog button { background: none; border: 0; padding: 2px 0; color: #3b82f6; font: inherit; font-size: 12.5px; cursor: pointer; text-decoration: underline; }
    table.u-cards tr td[colspan] { grid-column: 1 / -1; }
}

/* 118 (17.10.2026): режим «только ASC». Когда выбрана модель ASC (у подписчика —
   всегда, если классика выключена в админке), классических панелей нет: ни
   «Уровней рядом», ни «Карты зон», ни легенды цветов уровней и их настроек.
   Сами классические оповещения работают, пока человек их не выключит. */
[data-level-model="asc"] #levels-panel-btn,
[data-level-model="asc"] #levels-map-btn,
[data-level-model="asc"] #key-levels,
[data-level-model="asc"] #levels-panel,
[data-level-model="asc"] #levels-map-panel,
[data-level-model="asc"] #dock-rail,
[data-level-model="asc"] #dock-pane,
[data-level-model="asc"] #chart-folds,
[data-level-model="asc"] .chart-legend,
[data-level-model="asc"] .legacy-only { display: none !important; }

/* 118: «Сценарии по зоне» — вместо цены и ближайших уровней одна выбранная зона */
.mn-zone-mode .mn-price-row { display: none; }
.mn-zone { display: flex; align-items: center; gap: 8px; padding: 7px 9px; border: 1px solid var(--border); border-radius: 8px; }
.mn-zone-m { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.mn-zone-m b { font-variant-numeric: tabular-nums; font-size: 0.95rem; }
.mn-zone-m span { font-size: 0.78rem; color: var(--text-muted); }
.mn-zone-nav { display: flex; flex-direction: column; gap: 3px; }
.mn-zbtn { width: 28px; height: 22px; border: 1px solid var(--border); border-radius: 6px; background: transparent; color: var(--text); cursor: pointer; font-size: 11px; line-height: 1; }
.mn-zbtn:disabled { opacity: 0.35; cursor: default; }
.mn-zbtn:not(:disabled):hover { border-color: var(--accent, #3b82f6); }
.mn-zsit { font-size: 0.8rem; padding: 2px 2px 0; }
.mn-zhint { font-size: 0.74rem; color: var(--text-muted); padding: 0 2px; }
.asc-zc-play { display: block; margin: 0 9px 7px; padding: 3px 8px; font-size: 11px; border: 1px solid var(--border); border-radius: 6px; background: transparent; color: var(--text); cursor: pointer; }
.asc-zc-play.is-mini { display: inline-block; margin: 0 0 0 6px; padding: 1px 6px; }
.asc-zc-play:hover { border-color: var(--accent, #3b82f6); }

/* 141 (18.10.2026): «Сценарии по зоне» по макету владельца. Алерт — на всю зону,
   сценарий — от исходной линии: общей кнопки «Открыть сценарий» в режиме зоны нет. */
.mn-zone-mode #mn-scenario { display: none !important; }
.mn-zone-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 2px; }
.mn-chip { display: inline-block; padding: 1px 7px; border-radius: 999px; border: 1px solid var(--border); font-size: 0.74rem; color: var(--text-muted); white-space: nowrap; }
.mn-chip.is-up { color: #16a34a; border-color: rgba(22, 163, 74, 0.45); }
.mn-chip.is-dn { color: #dc2626; border-color: rgba(220, 38, 38, 0.45); }
.mn-zone-m b { font-size: 1.05rem; white-space: nowrap; }
.mn-comp { border: 1px solid var(--border); border-radius: 8px; padding: 6px 8px; display: flex; flex-direction: column; gap: 4px; }
.mn-comp-h { font-size: 0.78rem; font-weight: 600; }
.mn-comp-t { width: 100%; border-collapse: collapse; font-size: 0.8rem; font-variant-numeric: tabular-nums; }
.mn-comp-t th { text-align: left; font-weight: 500; color: var(--text-muted); font-size: 0.72rem; padding: 2px 4px; }
.mn-comp-t td { padding: 3px 4px; border-top: 1px solid var(--border); }
.mn-comp-t td:last-child, .mn-comp-t th:last-child { text-align: right; }
.mn-comp-r { cursor: pointer; }
.mn-comp-r:hover td { background: rgba(59, 130, 246, 0.07); }
.mn-comp-r.is-on td { background: rgba(59, 130, 246, 0.12); }
.mn-line-btn { border: 1px solid var(--border); border-radius: 6px; background: transparent; color: var(--text); font-size: 0.74rem; padding: 2px 7px; cursor: pointer; white-space: nowrap; }
.mn-line-btn:hover, .mn-line-btn.is-on { border-color: var(--accent, #3b82f6); color: var(--accent, #3b82f6); }
.mn-comp-all { align-self: flex-start; font-size: 0.78rem; }

/* 118: «Свой инструмент» под выбором бумаги */
.own-inst { margin-top: 6px; }
.own-toggle { background: none; border: 0; padding: 2px 0; color: var(--accent, #3b82f6); cursor: pointer; font-size: 0.82rem; }
.own-toggle span { color: var(--text-muted); margin-left: 4px; }
.own-body { border: 1px solid var(--border); border-radius: 8px; padding: 8px; margin-top: 4px; }
.own-form { display: flex; gap: 6px; margin: 6px 0; }
.own-form input { flex: 1; min-width: 0; text-transform: uppercase; }
.own-err { color: #e5534b; font-size: 0.8rem; margin: 4px 0; }
.own-list { list-style: none; padding: 0; margin: 6px 0 0; font-size: 0.82rem; display: flex; flex-direction: column; gap: 4px; }
.own-st { font-size: 0.75rem; padding: 0 6px; border-radius: 10px; border: 1px solid var(--border); }
.own-active, .own-shared { color: #22c55e; }
.own-rejected, .own-expired { color: var(--text-muted); }
.own-form input::placeholder { text-transform: none; }

/* 119 (17.10.2026): паспорт качества данных — значок Q и статус котировки опциона */
.u-q { display: inline-block; font-size: 11px; line-height: 16px; white-space: nowrap; padding: 0 6px; border-radius: 999px; border: 1px solid var(--border); color: var(--text-muted); cursor: help; font-variant-numeric: tabular-nums; }
/* 150 (20.10.2026): светлая тема — цвета пометок качества темнее, контраст не ниже 4,5 */
.u-q-LIVE { color: #00766c; border-color: rgba(38, 166, 154, .45); }
.u-q-ACCEPTABLE { color: var(--text-muted); }
.u-q-PARTIAL { color: #8a5a00; background: rgba(245, 158, 11, .12); border-color: rgba(245, 158, 11, .5); }
.u-q-STALE, .u-q-UNAVAILABLE { color: #c0392b; background: rgba(239, 83, 80, .1); border-color: rgba(239, 83, 80, .45); }
.u-q-none { color: var(--text-faint, #8b8f98); }
.u-blocked { display: inline-block; font-size: 11px; color: #c0392b; white-space: nowrap; }
.u-qs { font-size: 10.5px; white-space: nowrap; padding: 0 5px; border-radius: 4px; border: 1px solid var(--border); color: var(--text-muted); }
.u-qs-LIVE { color: #00766c; border-color: rgba(38, 166, 154, .4); }
.u-qs-DELAYED { color: var(--text-muted); }
.u-qs-STALE, .u-qs-MODEL_ONLY { color: #c0392b; border-color: rgba(239, 83, 80, .45); }
.u-qs-NO_BID, .u-qs-NO_ASK { color: #8a5a00; border-color: rgba(245, 158, 11, .5); }
[data-theme="dark"] .u-q-LIVE, [data-theme="dark"] .u-qs-LIVE { color: #4fd1c5; }
[data-theme="dark"] .u-q-STALE, [data-theme="dark"] .u-q-UNAVAILABLE, [data-theme="dark"] .u-blocked, [data-theme="dark"] .u-qs-STALE, [data-theme="dark"] .u-qs-MODEL_ONLY { color: #ff8a80; }
.ok-theory { grid-column: 1 / -1; font-size: 12px; padding: 4px 8px; border-radius: 6px; color: #b7791f; background: rgba(245, 158, 11, .12); border: 1px solid rgba(245, 158, 11, .5); }
.u-q-closed { color: var(--text-muted) !important; background: none !important; border-color: var(--border) !important; }

/* 136 (18.10.2026): этап 11 — цепочка «теоретическое → исполнимое → после издержек»
   (window.urovniRez в platform.js): одна разметка для «Как сыграть уровень» и «Опционов». */
.rz { margin: 6px 0 4px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px; font-size: 12.5px; }
.rz-h { font-weight: 600; margin-bottom: 4px; }
.rz-u, .rz-muted { color: var(--text-muted); font-weight: 400; }
.rz-row { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.rz-step { display: inline-flex; flex-direction: column; min-width: 0; }
.rz-l { font-size: 11px; color: var(--text-muted); }
.rz-main b { font-size: 14px; }
.rz-ar { color: var(--text-muted); }
.rz-up { color: var(--green); }
.rz-dn { color: var(--red); }
.rz-why { margin-top: 4px; font-weight: 600; }
.rz-sz { margin-top: 4px; }
.rz-short b { opacity: .75; }
.rz-d { margin-top: 4px; }
.rz-d summary { cursor: pointer; color: var(--text-muted); }
.rz-t { width: 100%; border-collapse: collapse; margin: 4px 0; }
.rz-t td { padding: 2px 6px 2px 0; vertical-align: top; }
.rz-t .rz-n { text-align: right; white-space: nowrap; }
.rz-t .rz-w { color: var(--text-muted); font-size: 11.5px; }
.rz-t .rz-sum td { font-weight: 600; border-top: 1px solid var(--border); }
@media (max-width: 600px) { .rz-t .rz-w { display: none; } }

/* 139 (18.10.2026): полоса закрытой Alpha — документ «Интерфейс Alpha». Только участникам Alpha и администратору */
.alpha-bar {
    display: flex; align-items: center; justify-content: space-between; gap: 10px 16px; flex-wrap: wrap;
    padding: 7px 16px; font-size: 13px; line-height: 1.4; color: var(--text);
    background: color-mix(in srgb, var(--primary) 9%, var(--surface)); border-bottom: 1px solid var(--border);
}
.alpha-bar[hidden] { display: none; }
.alpha-bar-t { display: flex; gap: 4px 10px; flex-wrap: wrap; align-items: baseline; min-width: 0; }
.alpha-bar-t b { letter-spacing: 0.04em; white-space: nowrap; }
.alpha-bar-t span { color: var(--text-muted); }
.alpha-bar-a { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.alpha-role { font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.alpha-btn {
    font: inherit; font-size: 13px; padding: 5px 10px; min-height: 32px; cursor: pointer; white-space: nowrap;
    color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.alpha-btn:hover { border-color: var(--primary); }
.alpha-row { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.alpha-row .fb-label { flex: 1 1 150px; display: flex; flex-direction: column; gap: 4px; }
.alpha-sel {
    font: inherit; font-size: 14px; font-weight: 400; color: var(--text); background: var(--surface-2);
    border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 7px 8px; min-height: 36px;
}
.alpha-stars { display: flex; gap: 8px; margin: 4px 0 2px; }
.alpha-star input { position: absolute; opacity: 0; pointer-events: none; }
.alpha-star span {
    display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; cursor: pointer;
    font-size: 16px; font-weight: 600; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2);
}
.alpha-star input:checked + span { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 18%, var(--surface-2)); }
.alpha-star input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 1px; }
@media (max-width: 600px) {
    .alpha-bar { padding: 6px 10px; font-size: 12px; }
    .alpha-bar-t span { font-size: 11px; }
    .alpha-role { display: none; }
    .alpha-btn { font-size: 12px; padding: 4px 8px; }
}

/* 141 (18.10.2026): плашка «сигналы классические, а график ASC» — выбор за подписчиком */
.asc-sig-offer { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 0 0 8px; padding: 8px 12px; border: 1px solid var(--accent, #3b82f6); border-radius: 8px; font-size: 0.85rem; background: rgba(59, 130, 246, 0.06); }
.asc-sig-offer > span:first-child { flex: 1 1 320px; }
.asc-sig-acts { display: flex; flex-wrap: wrap; gap: 6px; }
.asc-sig-acts .btn { width: auto; margin: 0; padding: 5px 12px; }

/* 150 (20.10.2026, документ — раздел 15): заголовок для экранного диктора без
   места на экране — у «Уровней» нет видимого названия раздела */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
           clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* 150 (20.10.2026, документ — раздел 15): на телефоне и при касании пальцем общие
   кнопки приложения — шапка, вкладки разделов, полоса Alpha, приглашение в быстрый
   старт — не меньше 44×44. На компьютере с мышью размеры прежние */
@media (pointer: coarse), (max-width: 760px) {
    .menu-toggle, .btn-account, .header .theme-toggle, .header [data-testid="button-bell"] { min-height: 44px; }
    .head-ticker, .chart-source { min-height: 44px; }
}
/* Ширина 44 у иконок шапки — только от 401 px: на 360–400 шесть иконок по 44
   сжимают поле с тикером до нечитаемого. Там иконки 36 × 44 (WCAG AA — от 24) */
@media (pointer: coarse) and (min-width: 401px), (min-width: 401px) and (max-width: 760px) {
    .menu-toggle, .btn-account, .header .theme-toggle, .header [data-testid="button-bell"], .chart-source { min-width: 44px; }
}
@media (pointer: coarse), (max-width: 760px) {
    .pf-tab, .alpha-btn, .tour-invite-later, .tour-invite-start { min-height: 44px; }
}

/* 155 (23.10.2026): «Моя средняя» — форма на графике */
.avg-form {
    position: absolute;
    z-index: 15;
    top: 44px;
    left: 50%;
    transform: translateX(-50%);
    width: min(300px, calc(100% - 24px));
    padding: 12px;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
    font-size: 13px;
}
.avg-form-t { font-weight: 600; margin-bottom: 8px; }
.avg-form-l { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.avg-form-l input { width: 130px; padding: 5px 8px; font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.avg-form-side { display: flex; gap: 16px; margin: 8px 0 6px; }
.avg-form-side label { display: inline-flex; align-items: center; gap: 5px; cursor: pointer; }
.avg-form-hint { color: var(--text-muted); font-size: 11.5px; line-height: 1.35; margin-bottom: 10px; }
.avg-form-b { display: flex; flex-wrap: wrap; gap: 6px; }
.avg-form-b .btn { width: auto; flex: 1 1 auto; }

/* 156 (23.10.2026): отметка согласия в окне входа — тот же вид, что у отметки перед подпиской;
   красная подпись, если нажали «Получить код» без отметки */
.auth-consent { margin: 4px 0 12px; }
.auth-consent.need, .auth-consent.need span { color: var(--danger, #d64545); }

/* ===== Волна 181a (01.11.2026): верх экрана на телефоне (mob8.js ставит .m8 при ≤ 760 px) =====
   Почему: шапка, полоса ALPHA и ряд разделов занимали до 213 px из 844 — рабочая
   область начиналась с четверти экрана. Шапка и полоса уходят при прокрутке вниз
   отрицательным отступом: раздел в колонке flex сам получает освободившуюся высоту. */
.alpha-short, .alpha-more { display: none; }
.m8 .header { margin-top: var(--m8-top, 0px); transition: margin-top .22s ease; }
@media (prefers-reduced-motion: reduce) { .m8 .header { transition: none; } }
.m8 .alpha-bar { flex-wrap: nowrap; gap: 8px; padding: 3px 6px 3px 10px; min-height: 30px; font-size: 11.5px; line-height: 1.3; }
.m8 .alpha-bar-t { flex: 1 1 auto; flex-wrap: nowrap; overflow: hidden; white-space: nowrap; cursor: pointer; gap: 6px; }
.m8 .alpha-bar-t .alpha-full { display: none; }
.m8 .alpha-bar-t .alpha-short { display: inline; }
.m8 .alpha-bar-t .alpha-sum { overflow: hidden; text-overflow: ellipsis; min-width: 0; font-size: 11px; }
.m8 .alpha-bar-a { display: none; }
.m8 .alpha-more {
    display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto;
    width: 30px; height: 26px; padding: 0; font-size: 15px; cursor: pointer; color: var(--text-muted);
    background: transparent; border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.m8 .alpha-bar.alpha-open { flex-wrap: wrap; padding: 6px 10px; }
.m8 .alpha-bar.alpha-open .alpha-bar-t { white-space: normal; flex-wrap: wrap; flex-basis: calc(100% - 40px); }
.m8 .alpha-bar.alpha-open .alpha-bar-t .alpha-full { display: inline; }
.m8 .alpha-bar.alpha-open .alpha-bar-t .alpha-short { display: none; }
.m8 .alpha-bar.alpha-open .alpha-bar-a { display: flex; flex-basis: 100%; }
/* Ряд разделов: затухание у края, если дальше есть ещё вкладки (иначе «Портфель» выглядел как обрезанный) */
.m8 .pf-nav.m8-more-r { -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 36px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 36px), transparent); }
.m8 .pf-nav.m8-more-l.m8-more-r { -webkit-mask-image: linear-gradient(90deg, transparent, #000 28px, #000 calc(100% - 36px), transparent); mask-image: linear-gradient(90deg, transparent, #000 28px, #000 calc(100% - 36px), transparent); }
.m8 .pf-nav.m8-more-l:not(.m8-more-r) { -webkit-mask-image: linear-gradient(90deg, transparent, #000 28px); mask-image: linear-gradient(90deg, transparent, #000 28px); }
/* Клавиатура открыта — нижние панели не закрывают поле ввода */
.m8.m8-kb #mob-bar, .m8.m8-kb #opm-nav, .m8.m8-kb #opm-acts { display: none !important; }

/* ===== Волна 181b (01.11.2026): «Уровни» — полоса над графиком на телефоне =====
   Почему: таймфреймы, подпись и плашка ASC лежали поверх свечей и закрывали
   верх графика. mob8.js переносит их в #m8-cbar над сеткой графиков, график
   (flex: 1) сам становится ниже на высоту полосы. Свечи больше ничем не закрыты. */
.m8-cbar { display: none; }
.m8 .m8-cbar {
    display: flex; flex-direction: column; gap: 3px; flex: 0 0 auto;
    padding: 4px 6px 4px; background: var(--surface); border-bottom: 1px solid var(--border); min-width: 0;
}
.m8 .m8-cbar > div { min-width: 0; }
.m8 .m8-cbar .chart-toolbar {
    position: static; inset: auto; width: 100%; max-width: 100%; overflow-x: auto; flex-wrap: nowrap;
    margin: 0; box-shadow: none;
}
.m8 .m8-cbar-r2 { display: flex; align-items: center; gap: 6px; }
.m8 .m8-cbar-t { flex: 1 1 auto; min-width: 0; overflow: hidden; }
.m8 .m8-cbar .chart-title-bar {
    position: static; max-width: 100%; pointer-events: auto; background: transparent; border: 0; padding: 0 2px;
}
.m8 .m8-cbtn {
    flex: 0 0 auto; min-height: 32px; min-width: 36px; padding: 4px 9px; font: 600 11.5px var(--font-body);
    color: var(--text-muted); background: transparent; border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer;
}
.m8 .m8-cbtn[hidden] { display: none; }
.m8 .m8-cbar .asc-badge { position: static; max-width: 100%; margin: 0; }
/* Кратко — одна строка с многоточием; Подробно — как было; Скрыто — нет плашки */
.m8 .m8-cbar[data-asc="short"] .asc-badge { flex-wrap: nowrap; overflow: hidden; white-space: nowrap; padding: 3px 8px; }
.m8 .m8-cbar[data-asc="short"] .asc-badge > * { flex: 0 0 auto; }
.m8 .m8-cbar[data-asc="off"] .m8-cbar-asc { display: none; }
.m8 .m8-cbar-asc:empty { display: none; }
.m8.chart-full .m8-cbar .m8-cbar-asc { display: none; }
.m8.chart-full.m8-asc-fs .m8-cbar .m8-cbar-asc { display: block; }
.m8.m8-notitle .m8-cbar-t .chart-title-bar { display: none; }

/* Общий лист «Настроить экран» — снизу во всю ширину, над нижними панелями */
.m8-sheet-wrap { position: fixed; inset: 0; z-index: 4000; display: flex; flex-direction: column; justify-content: flex-end; }
.m8-sheet-bg { position: absolute; inset: 0; background: rgba(0, 0, 0, .45); }
.m8-sheet {
    position: relative; max-height: 82vh; max-height: 82dvh; display: flex; flex-direction: column;
    background: var(--surface); color: var(--text); border-radius: 14px 14px 0 0; border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom, 0px);
}
@media (min-width: 761px) { .m8-sheet { width: 440px; margin: 0 auto 24px; border-radius: 14px; border: 1px solid var(--border); } }
.m8-sheet-h { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 14px 8px; border-bottom: 1px solid var(--border); }
.m8-sheet-h b { font-size: 15px; }
.m8-x { width: 40px; height: 40px; border: 0; background: transparent; color: var(--text-muted); font-size: 18px; cursor: pointer; }
.m8-sheet-b { overflow-y: auto; padding: 6px 14px 16px; overscroll-behavior: contain; }
.m8-grp { padding: 10px 0; border-bottom: 1px solid var(--border); }
.m8-grp:last-child { border-bottom: 0; }
.m8-grp-h { font-size: 12px; font-weight: 700; color: var(--text-muted); margin-bottom: 8px; text-transform: none; }
.m8-seg { display: flex; gap: 4px; flex-wrap: wrap; }
.m8-seg button {
    flex: 1 1 0; min-height: 40px; padding: 6px 8px; border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: transparent; color: var(--text); font: 600 13px var(--font-body); cursor: pointer;
}
.m8-seg button.on { background: var(--accent, #3b82f6); border-color: var(--accent, #3b82f6); color: #fff; }
.m8-note { margin: 6px 0 0; font-size: 12px; color: var(--text-muted); line-height: 1.4; }
.m8-btn {
    display: block; width: 100%; min-height: 42px; margin-top: 8px; padding: 8px 12px; border: 1px solid var(--border);
    border-radius: var(--radius-sm); background: transparent; color: var(--text); font: 600 13px var(--font-body); cursor: pointer;
}
.m8-reset { color: var(--danger, #d64545); }
.m8-sheet-b .m8-grp > * { max-width: 100%; }
.m8-sheet-on #mob-bar, .m8-sheet-on #opm-nav, .m8-sheet-on #opm-acts { visibility: hidden; }

/* ===== Волна 181c (01.11.2026): компактный верх «Арбитража» на телефоне =====
   Ряд 1 — пара, ☆ и ⚙; ряд 2 — режим и таймфрейм (лишнее уезжает пальцем);
   ряд 3 — три главных числа. Подборки, вид графика и кнопки — в листе ⚙. */
.m8-only { display: none; }
.m8 .m8-only { display: inline-flex; align-items: center; justify-content: center; }
.m8 #arb-top .arb-title,
.m8 #arb-top .arb-title-row > #arb-legs-lv,
.m8 #arb-top .arb-title-row > .arb-link,
.m8 #arb-top .arb-title-row > #arb-nav,
.m8 #arb-top .arb-title-row > #arb-uimode,
.m8 #arb-top .arb-title-row > #arb-layout,
.m8 #arb-toolbar > #arb-view,
.m8 #arb-toolbar > #arb-lines,
.m8 #arb-toolbar > .arb-btn,
.m8 #arb-toolbar > .arb-spacer { display: none !important; }
.m8 #arb-top .arb-title-row { flex-wrap: nowrap; }
.m8 #arb-top .arb-pair-open { flex: 1 1 auto; min-width: 0; }
.m8 #arb-toolbar { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; gap: 6px; }
.m8 #arb-toolbar::-webkit-scrollbar { display: none; }
.m8 #arb-toolbar > .arb-seg { flex: 0 0 auto; }
.m8 #arb-toolbar #arb-mode button span { display: none; }
.m8 #arb-toolbar #arb-mode button::after { content: attr(data-short); }
/* Элементы раздела внутри листа ⚙ — обычный поток, во всю ширину */
.m8-sheet .arb-btn, .m8-sheet #arb-legs-lv { display: inline-flex !important; margin: 0 6px 6px 0; min-height: 40px; }
.m8-sheet #arb-nav { display: flex !important; flex-direction: column; gap: 8px; }
.m8-sheet #arb-nav .inst-chips { flex-wrap: wrap; overflow: visible; }
.m8-sheet #arb-nav .arb-petals { flex-wrap: nowrap; overflow-x: auto; max-width: 100%; }
.m8-sheet .arb-seg, .m8-sheet .multi-switch { display: inline-flex !important; margin: 0 6px 6px 0; }

/* ===== Волна 181d (01.11.2026): доска опционов на телефоне — ±8 страйков у центра =====
   Почему: в 390 px доска в 40–60 строк прокручивалась бесконечно, а нужны в
   основном страйки рядом с ценой. Остальные — по кнопке, выбор на эту сессию. */
.opt-allk-row { display: none; }
.opm-m8 .opt-allk-row { display: table-row; }
.opt-allk-row td { padding: 6px 8px; text-align: center; }
.opt-allk { min-height: 38px; width: 100%; }
.opm-near .opt-allk-less, .opm-m8:not(.opm-near) .opt-allk:not(.opt-allk-less) { display: none; }
.opm-near #opt-scroll tr.opt-far { display: none; }

/* ===== Волна 181f (01.11.2026): «Опционы» на телефоне — короткий верх =====
   Заголовок, активы, тип, список, ссылка и «Главное/Всё», справка об
   инструменте, обозначения и сноска — в листе «Si · марж. ▾». Статус доски —
   одна строка (цена и экспирация), остальное по нажатию. */
.m8 #opt-page .opt-title-row,
.m8 #opt-page #opt-instr,
.m8 #opt-page #opt-legend,
.m8 #opt-page #opt-foot { display: none !important; }
.m8 .opt-m #opm-bar { flex-wrap: nowrap; gap: 4px; }
.m8 .opt-m #opm-bar .opt-btn { flex: 0 1 auto; padding-left: 8px; padding-right: 8px; white-space: nowrap; }
.m8 .opt-m #opm-bar #opm-side button { padding-left: 7px; padding-right: 7px; }
/* «Настройки» — значком ⚙, подпись остаётся для чтения с экрана */
.m8 .opt-m #opm-bar #opm-tb { font-size: 0; min-width: 40px; }
.m8 .opt-m #opm-bar #opm-tb::before { content: '⚙'; font-size: 16px; }
.m8 .opt-m #opm-bar .m8-opt-inst { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; justify-content: flex-start; font-weight: 700; }
.m8 #opt-status:not(.m8-open) { display: flex; flex-wrap: nowrap; overflow: hidden; white-space: nowrap; gap: 8px; cursor: pointer; padding-top: 6px; padding-bottom: 6px; }
.m8 #opt-status:not(.m8-open) > span:nth-child(n+3) { display: none; }
.m8 #opt-status:not(.m8-open)::after { content: '▾'; margin-left: auto; color: var(--text-muted); }
.m8 #opt-status.m8-open { cursor: pointer; }
/* Элементы раздела в листе — обычный поток, во всю ширину */
.m8-sheet #opt-assets, .m8-sheet #opt-style { display: flex !important; flex-wrap: wrap; gap: 4px; }
.m8-sheet #opt-asset-all { width: 100%; }
.m8-sheet #opt-instr { display: flex !important; flex-direction: column; gap: 6px; align-items: flex-start; text-align: left; }
.m8-sheet #opt-legend, .m8-sheet #opt-foot { display: flex !important; flex-wrap: wrap; gap: 6px; }
.m8-sheet #opt-foot { display: block !important; font-size: 12px; }

/* 181g (01.11.2026): сворачиваемые блоки страниц ситуации и идеи «Тренда».
   Свёрнутый блок — только строка заголовка; скрытый убран совсем (вернуть — «Вид страницы»). */
.m8-fold > .m8-fold-h { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.m8-fold > .m8-fold-h > h2, .m8-fold > .m8-fold-h > h3, .m8-fold > h2.m8-fold-h, .m8-fold > h3.m8-fold-h { flex: 1 1 auto; }
.m8-fold-b { margin-left: auto; flex: 0 0 auto; min-width: 32px; min-height: 32px; border: 1px solid var(--border, #2a3340); border-radius: 8px; background: transparent; color: inherit; font-size: 14px; line-height: 1; cursor: pointer; }
.m8-fold.is-folded > :not(.m8-fold-h) { display: none !important; }
.m8-fold.is-folded > .m8-fold-h { margin-bottom: 0; }
.m8-fold.is-folded { padding-top: 10px; padding-bottom: 10px; }
.m8-fold.is-off { display: none !important; }
.m8-fold-t .ov-sec-h { margin: 0; }
.m8-fold-cfg { white-space: nowrap; }
/* В свёрнутом «Способах действия» кнопка «Пересчитать» и время не нужны — только заголовок */
.m8-fold.is-folded .ov-ways-h > .ov-btn, .m8-fold.is-folded .ov-ways-h > .ov-muted { display: none !important; }
.m8-fold.is-folded .ov-ways-h { flex-wrap: nowrap; }
/* 181g: на телефоне легенда графика идеи мельче — график важнее подписей */
.m8 .tr-legend { font-size: 11px; line-height: 1.35; gap: 2px 10px; }
