/* ============================================================
   ГЛОБАЛЬНЫЕ БАЗОВЫЕ СТИЛИ
   ============================================================ */
*, *::before, *::after {
    user-select: none !important;
    -webkit-user-select: none !important;
}
input, textarea, [contenteditable] {
    user-select: text !important;
    -webkit-user-select: text !important;
}
html { background-color: #000000; }

/* Dash renderer: hide English "Loading..." before HYDRATED; match #app-loader look */
._dash-loading {
    position: fixed;
    inset: 0;
    z-index: 99998;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #0b0e11;
    color: transparent !important;
    font-size: 0 !important;
    line-height: 0 !important;
    overflow: hidden;
}
._dash-loading::after {
    content: "";
    display: block;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 3px solid #2b3139;
    border-top-color: #848e9c;
    animation: spin 0.8s linear infinite;
}

body {
    margin: 0;
    background: transparent;
    font-family: 'Roboto', sans-serif;
    overflow: hidden;
    color: #eee;
    touch-action: none;
    height: 100dvh;
}
body::before {
    content: "";
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(to top, #001401 65%, #000000 100%);
    z-index: -1;
    pointer-events: none;
}
* { scrollbar-width: thin; scrollbar-color: #4e5561 #161a1e; }
::-webkit-scrollbar { width: 6px; height: 6px; background: #161a1e; }
::-webkit-scrollbar-track { background: #161a1e; }
::-webkit-scrollbar-thumb { background: #4e5561; border-radius: 3px; border: 1px solid #161a1e; }
::-webkit-scrollbar-thumb:hover { background: #848e9c; }
::-webkit-scrollbar-corner { background: #161a1e; }

/* ============================================================
   LAYOUT
   ============================================================ */
.main-body {
    display: flex;
    flex: 1;
    min-height: 0;
    flex-direction: row;
}
.charts-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
}
#price-container  { width: 100%; position: relative; flex: 72 1 0%; min-height: 0; background: transparent; }
#gd-container     { width: 100%; position: relative; flex: 14 1 0%; min-height: 20px; background: transparent; overflow: hidden; }
#macd-container   { width: 100%; position: relative; flex: 14 1 0%; min-height: 20px; background: transparent; overflow: hidden; }

/* ============================================================
   RESIZER
   ============================================================ */
.resizer {
    height: 1px;
    background-color: rgba(255,255,255,0.15);
    background-clip: content-box;
    cursor: row-resize;
    z-index: 100;
    position: relative;
    padding: 4px 0;
    margin: -4px 0;
}
.resizer:hover, .resizer.dragging { background-color: #0ecb81 !important; }
.resizer-vertical {
    width: 1px;
    background-color: rgba(255,255,255,0.15);
    cursor: col-resize;
    z-index: 100;
    position: relative;
    padding: 0 5px;
    margin: 0 -5px;
    background-clip: content-box;
    transition: background-color 0.1s;
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
}
.resizer-vertical:hover, .resizer-vertical.dragging { background-color: #0ecb81 !important; }

/* ============================================================
   SYMBOL BUTTON & MODAL
   ============================================================ */
#symbol-btn:hover { background: rgba(255,255,255,0.05); border-radius: 6px; }

.topbar-undo-redo {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 100%;
    padding: 0 6px 0 2px;
    flex-shrink: 0;
    box-sizing: border-box;
}
.topbar-undo-redo-sep {
    width: 1px;
    height: 22px;
    background: rgba(255, 255, 255, 0.14);
    flex-shrink: 0;
}
#undo-btn, #redo-btn {
    flex-shrink: 0;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    transition: filter 0.12s ease;
}
#undo-btn:hover, #redo-btn:hover {
    filter: brightness(1.2);
}

/* Правая полоса: TF → отмена/повтор → авторизация справа (как на телефоне) */
#topbar-controls {
    flex: 1;
    min-width: 0;
    margin-left: 6px;
    padding-left: 8px;
    border-left: 1px solid rgba(255, 255, 255, 0.16);
    gap: 6px;
}
#topbar-controls #auth-btn {
    margin-left: auto;
}
#notif-btn:hover  { background: rgba(255,255,255,0.05) !important; }
#sym-modal-overlay { display: none; }
#sym-list::-webkit-scrollbar { width: 6px; }
#sym-list::-webkit-scrollbar-track { background: transparent; }
#sym-list::-webkit-scrollbar-thumb { background: #363a45; border-radius: 3px; }
#sym-search::placeholder { color: #4a505e; }

/* ============================================================
   STATUS ICONS
   ============================================================ */
.status-icon { width: 18px; height: 18px; border-radius: 4px; margin-right: 8px; }
.status-on  { border: 2.5px solid #00ff88; padding: 1px; }
.status-off { border: 2.5px solid #f6465d; filter: grayscale(1); opacity: 0.5; padding: 1px; }

/* ============================================================
   DASH TABLE
   ============================================================ */
.dash-table-container tr:first-child { display: none; }
.dash-table-container .dash-spreadsheet-container .dash-spreadsheet-inner img {
    height: 16px !important; width: 16px !important; vertical-align: middle; border-radius: 3px;
}
.dash-spreadsheet td, .dash-spreadsheet th { padding: 2px 4px !important; height: auto !important; line-height: 12px !important; }

/* ============================================================
   TOOLBAR
   ============================================================ */
.toolbar {
    order: -1;
    width: 52px;
    min-width: 52px;
    background-color: #000000;
    border-right: 1px solid #2b3139;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 10px;
    z-index: 50;
}
.tool-btn {
    width: 32px;
    height: 32px;
    border-radius: 4px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    color: #848e9c;
    margin-bottom: 8px;
    transition: all 0.1s ease;
    position: relative;
}
.tool-btn:hover { background-color: #2b3139; color: #fff; }
.tool-btn.active { background-color: #2b3139; color: #0ecb81; }
/* Один визуальный размер глифа внутри кнопок 32×32 (inline-стили в main.py переопределяются) */
.toolbar img {
    width: 22px !important;
    height: 22px !important;
    object-fit: contain;
    display: block;
    flex-shrink: 0;
}
.toolbar-separator {
    width: 24px;
    height: 1px;
    margin: 2px 0 10px;
    background: rgba(255, 255, 255, 0.18);
}
.toolbar-trash-group { margin-bottom: 0; }
.toolbar-trash-btn { margin-bottom: 0 !important; color: #848e9c; }
.toolbar-trash-btn:hover,
.toolbar-trash-btn.open {
    background-color: #2b3139;
    color: #fff;
}
.toolbar-trash-submenu { min-width: 280px; }
.toolbar-clear-all-btn:hover .tv-submenu-item-label { color: #ffffff; }

/* ============================================================
   TOOL GROUP & SUBMENU (из chart.js, авторитетная версия)
   ============================================================ */
.tv-tool-group {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    margin-bottom: 4px;
}
.tv-group-btn {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 4px;
    cursor: pointer;
    transition: 0.1s;
    position: relative;
    color: #848e9c;
}
.tv-group-btn:hover, .tv-group-btn.active { background: #2a2e39; color: #fff; }

.tv-submenu-arrow {
    position: absolute;
    right: -10px;
    top: 0;
    width: 10px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
    opacity: 0;
    border-radius: 3px 0 0 3px;
    cursor: pointer;
    transition: opacity 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}
.tv-submenu-arrow::after {
    content: '';
    display: block;
    width: 4px;
    height: 4px;
    border-top: 1.5px solid #848e9c;
    border-right: 1.5px solid #848e9c;
    transform: rotate(45deg);
    transition: transform 0.2s ease, border-color 0.2s ease;
}
.tv-group-btn:hover .tv-submenu-arrow { opacity: 1; }
.tv-submenu-arrow:hover { background: rgba(255,255,255,0.12) !important; opacity: 1 !important; }
.tv-submenu-arrow:hover::after { border-color: #ffffff; }
.tv-submenu-arrow.open { opacity: 1; background: rgba(255,255,255,0.08); box-shadow: inset 0 0 0 1px rgba(255,255,255,0.3); }
.tv-submenu-arrow.open::after,
.tool-btn.menu-open .tv-submenu-arrow::after {
    transform: rotate(-135deg);
    border-color: #ffffff;
}

.tv-submenu {
    display: none;
    position: absolute;
    left: 100%;
    top: 0;
    margin-left: 6px;
    background: #131722;
    border: 1px solid #2a2e39;
    border-radius: 4px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.7);
    padding: 4px 0;
    z-index: 10000;
    flex-direction: column;
    min-width: 240px;
}
.tv-submenu.active { display: flex; }

.tv-submenu-header {
    padding: 8px 12px 4px;
    font-size: 11px;
    font-weight: 600;
    color: #787b86;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    user-select: none;
}

.tv-submenu-separator {
    height: 1px;
    background: #434651;
    margin: 4px 0;
}

.tv-submenu-item {
    display: flex;
    align-items: center;
    padding: 0 8px;
    margin: 0 4px;
    height: 36px;
    cursor: pointer;
    font-size: 13px;
    color: #d1d4dc;
    white-space: nowrap;
    border-radius: 4px;
    transition: background-color 0.1s ease, color 0.1s ease;
}
.tv-submenu-item:hover { background: #2a2e39; color: #ffffff; }
.tv-submenu-item.active {
    background: #e0e3eb;
    color: #131722;
}
.tv-submenu-item.active .tv-submenu-shortcut { color: #434651; }
.tv-submenu-item.active img { filter: brightness(0) !important; }

.tv-submenu-shortcut {
    margin-left: auto;
    padding-left: 20px;
    font-size: 12px;
    color: #6b7280;
    white-space: nowrap;
}

.tv-submenu-item-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.tv-submenu-item-label {
    flex: 1;
    margin-left: 6px;
}

/* ============================================================
   TRENDLINE TOOLBAR (из chart.js)
   ============================================================ */
#trendline-toolbar {
    position: fixed; display: none; z-index: 9999;
    background: #1e222d; border: 1px solid #434651; border-radius: 6px;
    padding: 4px; gap: 2px; align-items: center;
    box-shadow: 0 4px 10px rgba(0,0,0,0.4);
    color: #848e9c; user-select: none;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
#tl-drag-handle:hover { color: #fff; }
#tl-drag-handle:active { cursor: grabbing !important; }

.tv-tool-btn {
    width: 32px; height: 32px;
    display: flex; justify-content: center; align-items: center;
    border-radius: 4px; cursor: pointer; transition: 0.1s;
    position: relative; flex-direction: column; gap: 2px;
}
.tv-tool-btn-row { flex-direction: row; gap: 4px; width: auto; padding: 0 8px; font-size: 13px; font-weight: 500; color: #d1d4dc; }
.tv-tool-btn:hover, .tv-tool-btn.active-btn { background: #2a2e39; color: #fff; }
.tv-divider { width: 1px; height: 24px; background: #434651; margin: 0 4px; }
.tl-color-indicator { width: 16px; height: 3px; border-radius: 1.5px; margin-top: -2px; }
.tl-delete:hover { color: #f6465d; }
#ahl-del:hover { color: #f6465d; }

.tv-popover {
    position: absolute; top: 100%; left: 0; margin-top: 6px;
    background: #1e222d; border: 1px solid #434651; border-radius: 6px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.4);
    display: none; flex-direction: column; padding: 8px;
    z-index: 10000; cursor: default;
}
.tv-popover.active { display: flex; }
#tl-color-popover { width: 190px; }
#tl-style-popover { width: 170px; padding: 4px; }

.tl-colors-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; margin-bottom: 12px; }
.tl-color-item { width: 18px; height: 18px; border-radius: 3px; cursor: pointer; border: 1px solid rgba(255,255,255,0.05); box-sizing: border-box; }
.tl-color-item:hover { border-color: #d1d4dc; }
.tl-color-item.active { border-color: #fff; box-shadow: 0 0 0 1px #2962ff; }

.tl-opacity-container { border-top: 1px solid #434651; padding-top: 8px; }
.tl-op-header { font-size: 12px; margin-bottom: 8px; color: #848e9c; }
.tl-op-slider-row { display: flex; align-items: center; gap: 8px; font-size: 12px; color: #d1d4dc; }
#tl-opacity-slider { flex: 1; -webkit-appearance: none; height: 4px; background: #434651; border-radius: 2px; outline: none; }
#tl-opacity-slider::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none;
    width: 12px; height: 12px; border-radius: 50%;
    background: #2962ff; border: 2px solid #fff; cursor: pointer;
}
#tl-width-popover { width: 100px; padding: 4px; }
.tl-width-option { display: flex; align-items: center; gap: 4px; padding: 6px 8px; cursor: pointer; border-radius: 4px; font-size: 13px; color: #d1d4dc; }
.tl-width-option:hover { background: #2a2e39; color: #fff; }
.tl-width-option.active { background: #2962ff; color: #fff; }
.tl-w-line { background: currentColor; }

/* ============================================================
   MOBILE TF MODAL (desktop: trigger hidden)
   ============================================================ */
.tf-mobile-trigger {
    display: none;
    align-items: center;
    justify-content: center;
    min-width: 52px;
    height: 24px;
    padding: 0 8px;
    margin-right: 2px;
    background-color: #161a1e;
    border: 1px solid #474d57;
    border-radius: 4px;
    color: #eaecef;
    font-size: 12px;
    font-weight: 500;
    font-family: 'Roboto', sans-serif;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    flex-shrink: 0;
}
.tf-mobile-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 12000;
    align-items: center;
    justify-content: center;
}
.tf-mobile-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.72);
}
.tf-mobile-modal-dialog {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    z-index: 1;
    width: min(300px, calc(100vw - 40px));
    max-height: min(420px, calc(100dvh - 80px));
    padding: 18px 16px 14px;
    background: #1e222d;
    border: 1px solid #363a45;
    border-radius: 12px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.65);
}
.tf-mobile-modal-title {
    font-size: 14px;
    font-weight: 600;
    color: #eaecef;
    text-align: center;
    margin-bottom: 14px;
}
.tf-mobile-modal-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}
.tf-mobile-modal-opt {
    height: 36px;
    padding: 0 8px;
    border: 1px solid transparent;
    border-radius: 4px;
    background: transparent;
    color: #d1d4dc;
    font-size: 13px;
    font-weight: 500;
    font-family: 'Roboto', sans-serif;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background-color 0.1s ease, color 0.1s ease, border-color 0.1s ease;
}
.tf-mobile-modal-opt:hover {
    background: #2a2e39;
    color: #ffffff;
}
.tf-mobile-modal-opt:active {
    background: #2a2e39;
    color: #ffffff;
}
.tf-mobile-modal-opt--active {
    border-color: #e0e3eb;
    background: #e0e3eb;
    color: #131722;
}
/* ============================================================
   CUSTOM DROPDOWN (tf-selector, vol-filter)
   ============================================================ */

/* Кнопка */
.custom-dropdown .Select-control {
    background-color: #161a1e !important;
    border: 1px solid #474d57 !important;
    height: 24px !important;
    min-height: 24px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 4px !important;
    cursor: pointer;
    border-radius: 4px !important;
    overflow: visible !important;
}
.custom-dropdown .Select-multi-value-wrapper {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: center !important;
    height: 100% !important;
    width: auto !important;
}
.custom-dropdown .Select-value {
    position: relative !important;
    display: flex !important;
    align-items: center !important;
    padding: 0 !important;
    margin: 0 !important;
    line-height: 1 !important;
    order: 1 !important;
}
.custom-dropdown .Select-value-label {
    color: #eaecef !important;
    font-family: 'Roboto', sans-serif !important;
    font-size: 12px !important;
    font-weight: 500 !important;
    padding: 0 !important;
}
.custom-dropdown .Select-arrow-zone {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    position: relative !important;
    padding: 0 !important;
    margin-left: 3px !important;
    width: auto !important;
    order: 2 !important;
}
.custom-dropdown .Select-arrow {
    border-color: #848e9c transparent transparent !important;
    border-width: 4px 3px 0 !important;
    display: inline-block !important;
    position: static !important;
}
.custom-dropdown .Select-input,
.custom-dropdown .Select-placeholder,
.custom-dropdown .Select-clear-zone { display: none !important; }

/* Выпадающий список */
.custom-dropdown .Select-menu-outer {
    background-color: #1e2329 !important;
    border: 1px solid #474d57 !important;
    margin-top: 5px !important;
    min-width: 100% !important;
    width: max-content !important;
    overflow: hidden !important;
}
.custom-dropdown .Select-menu {
    overflow: hidden !important;
}
/* Скрываем AutoSizer-div (второй дочерний элемент .Select-menu),
   он создаёт лишнее пустое пространство по высоте и ширине */
.custom-dropdown .Select-menu > div:nth-child(2) {
    display: none !important;
}
/* Опции */
.custom-dropdown .VirtualizedSelectOption,
.custom-dropdown [class*="VirtualSelectGrid"] .ReactVirtualized__Grid__innerScrollContainer > div > div {
    padding: 6px 12px !important;
    font-size: 12px !important;
    color: #848e9c !important;
}
.custom-dropdown .VirtualizedSelectFocusedOption,
.custom-dropdown .is-focused {
    background-color: #2b3139 !important;
    color: #f0b90b !important;
}

/* ============================================================
   АВТОРИЗАЦИЯ (серо-белая палитра как у графика)
   ============================================================ */
.auth-tab {
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: #848e9c;
    padding: 8px 2px;
    border-bottom: 2px solid transparent;
    transition: color 0.15s, border-color 0.15s;
    user-select: none;
}
.auth-tab:hover { color: #d1d4dc; }
.auth-tab-active { color: #ffffff !important; border-bottom-color: #b2b9c7 !important; }
#auth-modal-close:hover { color: #d1d4dc !important; }
#auth-email-input:focus, #auth-password-input:focus, #auth-password2-input:focus {
    border-color: #6a7280 !important;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.06) !important;
}
#auth-login-btn:hover { background-color: #4a5160 !important; border-color: #6a7280 !important; }
#auth-logout-btn:hover { background-color: #2b3139 !important; color: #ffffff !important; border-color: #848e9c !important; }
#auth-save-now-btn:hover, #notif-toggle-btn:hover { background-color: #363c45 !important; border-color: #5c6370 !important; }
#auth-modal-overlay { backdrop-filter: blur(5px); }
#auth-email-input::placeholder,
#auth-password-input::placeholder,
#auth-password2-input::placeholder {
    color: #5c6370 !important;
    opacity: 1;
}

/* ============================================================
   ИНДИКАТОРЫ (верхняя кнопка + модалка в стиле TradingView)
   ============================================================ */
.indicators-top-btn {
    width: 24px;
    height: 24px;
    border-radius: 5px;
    background-color: #2b3139;
    border: 1px solid #474d57;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: border-color 0.2s, background-color 0.2s;
}
.indicators-top-btn:hover {
    background-color: #363c45;
    border-color: #5c6370;
}
.indicators-top-btn-inner {
    width: 15px;
    height: 15px;
    display: block;
    background-color: #d1d4dc;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2'%3E%3Cpath d='M4 19h16M4 15h10M4 11h16M4 7h10' stroke-linecap='round'/%3E%3Ccircle cx='18' cy='6' r='2.5' fill='black' stroke='none'/%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' fill='none' stroke='black' stroke-width='2'%3E%3Cpath d='M4 19h16M4 15h10M4 11h16M4 7h10' stroke-linecap='round'/%3E%3Ccircle cx='18' cy='6' r='2.5' fill='black' stroke='none'/%3E%3C/svg%3E") center / contain no-repeat;
}

.indicators-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 10050;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    overscroll-behavior: none;
}
.indicators-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.72);
}
.indicators-modal-panel {
    position: relative;
    z-index: 1;
    width: min(720px, 94vw);
    max-height: min(560px, 86vh);
    background: #131722;
    border: 1px solid #363a45;
    border-radius: 10px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.55);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-family: 'Roboto', sans-serif;
}
.indicators-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px 10px 20px;
    flex-shrink: 0;
}
.indicators-modal-title {
    font-size: 15px;
    font-weight: 600;
    color: #ffffff;
    letter-spacing: 0.02em;
}
.indicators-modal-close {
    cursor: pointer;
    color: #848e9c;
    font-size: 18px;
    line-height: 1;
    padding: 4px 6px;
    user-select: none;
    border-radius: 4px;
}
.indicators-modal-close:hover {
    color: #d1d4dc;
    background: rgba(255, 255, 255, 0.06);
}
.indicators-modal-search-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 20px 12px 20px;
    padding: 0 12px;
    height: 38px;
    background: #1e222d;
    border: 1px solid #363a45;
    border-radius: 8px;
    flex-shrink: 0;
}
.indicators-modal-search-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    opacity: 0.55;
    background: #848e9c;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M16.5 16.5L21 21' stroke-linecap='round'/%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' fill='none' stroke='black' stroke-width='2.2'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M16.5 16.5L21 21' stroke-linecap='round'/%3E%3C/svg%3E") center / contain no-repeat;
}
.indicators-modal-search-row input,
.indicators-modal-search {
    flex: 1;
    min-width: 0;
    border: none !important;
    outline: none !important;
    background: transparent !important;
    color: #d1d4dc !important;
    font-size: 13px;
    font-family: inherit;
    height: 100%;
    box-shadow: none !important;
}
.indicators-modal-search-row input::placeholder,
.indicators-modal-search::placeholder {
    color: #5c6370;
}
.indicators-modal-body {
    display: flex;
    min-height: 0;
    flex: 1;
    border-top: 1px solid #2a2e39;
}
.indicators-modal-sidebar {
    width: 168px;
    flex-shrink: 0;
    border-right: 1px solid #2a2e39;
    padding: 12px 0 16px 0;
    background: #131722;
}
.indicators-modal-side-caption {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.08em;
    color: #5c6370;
    padding: 4px 14px 10px 14px;
    text-transform: uppercase;
}
.indicators-modal-side-item {
    padding: 10px 14px;
    font-size: 13px;
    color: #d1d4dc;
    cursor: pointer;
    user-select: none;
    transition: background 0.12s, color 0.12s;
}
.indicators-modal-side-item:hover {
    background: rgba(255, 255, 255, 0.04);
    color: #ffffff;
}
.indicators-modal-side-active {
    background: #2a2e39 !important;
    color: #ffffff !important;
}
.indicators-modal-side-muted {
    color: #848e9c;
}
.indicators-modal-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: #131722;
}
.indicators-modal-tabs {
    display: flex;
    gap: 6px;
    padding: 12px 16px 10px 16px;
    flex-shrink: 0;
}
.indicators-modal-tab {
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-size: 12px;
    font-weight: 500;
    padding: 6px 14px;
    border-radius: 4px;
    background: #2b3139;
    color: #d1d4dc;
    border: 1px solid #363a45;
    transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.indicators-modal-tab:hover {
    background: #363c45;
    color: #ffffff;
}
.indicators-modal-tab-active {
    background: #ffffff !important;
    color: #131722 !important;
    border-color: #ffffff !important;
}
.indicators-modal-table-head {
    display: grid;
    grid-template-columns: 28px 1fr 88px;
    gap: 8px;
    padding: 6px 16px 6px 16px;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #5c6370;
    border-bottom: 1px solid #2a2e39;
    flex-shrink: 0;
}
.indicators-modal-list {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 4px 8px 12px 8px;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}
.indicators-modal-row {
    display: grid;
    grid-template-columns: 28px 1fr 88px;
    gap: 8px;
    align-items: center;
    padding: 10px 8px;
    margin: 2px 0;
    border-radius: 6px;
    font-size: 13px;
    color: #d1d4dc;
    cursor: pointer;
    transition: background 0.1s;
}
.indicators-modal-row:hover {
    background: rgba(255, 255, 255, 0.05);
}
.indicators-modal-row-on .ind-name {
    color: #ffffff;
}
.ind-fav {
    text-align: center;
    color: #787b86;
    font-size: 15px;
    line-height: 1;
    user-select: none;
}
.indicators-modal-row:hover .ind-fav {
    color: #b2b9c7;
}
.ind-name {
    color: #d1d4dc;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ind-state {
    font-size: 11px;
    color: #5c6370;
    text-align: right;
}
.indicators-modal-row-on .ind-state {
    color: #848e9c;
}
.indicators-modal-empty {
    padding: 36px 24px;
    text-align: center;
    font-size: 13px;
    color: #848e9c;
    line-height: 1.55;
}
.indicators-modal-empty-sub {
    display: block;
    margin-top: 8px;
    font-size: 12px;
    color: #5c6370;
}

/* ─── Легенда индикаторов на панелях графика (TradingView-style) ─── */
.study-legend-mount {
    position: absolute;
    left: 6px;
    top: 2px;
    z-index: 25;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    max-width: calc(100% - 70px);
    pointer-events: none;
}
.study-legend-row {
    position: relative;
    display: inline-flex;
    align-items: center;
    flex-wrap: nowrap;
    border-radius: 4px;
    border: 1px solid transparent;
    background: rgba(19, 23, 34, 0.92);
    pointer-events: auto;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.study-legend-row:hover,
.study-legend-row.is-expanded {
    border-color: rgba(41, 98, 255, 0.55);
    box-shadow: 0 0 0 1px rgba(41, 98, 255, 0.2);
}
.study-legend-row--dim .study-legend-name {
    opacity: 0.45;
}
.study-legend-name {
    margin: 0;
    padding: 1px 8px;
    border: none;
    border-radius: 3px 0 0 3px;
    background: transparent;
    color: #d1d4dc;
    font: 11px/1.22 Roboto, sans-serif;
    cursor: pointer;
    text-align: left;
    transition: background 0.2s ease, color 0.2s ease;
}
.study-legend-row:hover .study-legend-name,
.study-legend-row.is-expanded .study-legend-name {
    background: rgba(255, 255, 255, 0.06);
    color: #ffffff;
}
.study-legend-actions {
    display: flex;
    align-items: center;
    gap: 1px;
    padding: 0 2px 0 0;
    min-height: 0;
    max-width: 0;
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    white-space: nowrap;
    transition: max-width 0.38s cubic-bezier(0.4, 0, 0.2, 1),
        max-height 0.32s cubic-bezier(0.4, 0, 0.2, 1),
        opacity 0.28s ease;
    pointer-events: none;
}
.study-legend-row:hover .study-legend-actions,
.study-legend-row.is-expanded .study-legend-actions {
    max-width: 126px;
    max-height: 26px;
    opacity: 1;
    pointer-events: auto;
}
.study-legend-btn {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    padding: 0;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 2px;
    background: transparent;
    color: #b2b9c7;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}
.study-legend-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
}
.study-legend-btn-danger:hover {
    background: rgba(246, 70, 93, 0.15);
    color: #f6465d;
}
.study-legend-brace {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: -0.5px;
    color: inherit;
    line-height: 1;
}

@media (max-width: 768px) {
    .indicators-modal-overlay {
        padding: max(10px, env(safe-area-inset-top, 0px)) 12px max(10px, env(safe-area-inset-bottom, 0px)) 12px;
        align-items: center;
        justify-content: center;
    }
    .indicators-modal-panel {
        width: min(100%, calc(100vw - 24px));
        max-height: min(85vh, 640px);
        margin: 0;
        border-radius: 10px;
    }
    .indicators-modal-body {
        flex-direction: column;
    }
    .indicators-modal-sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid #2a2e39;
        display: flex;
        flex-wrap: wrap;
        gap: 4px;
        padding: 10px 12px;
    }
    .indicators-modal-side-caption {
        width: 100%;
        padding-bottom: 4px;
    }
    .indicators-modal-side-item {
        padding: 8px 12px;
        border-radius: 6px;
        background: #1e222d;
        border: 1px solid #363a45;
    }
    .indicators-modal-table-head,
    .indicators-modal-row {
        grid-template-columns: 22px 1fr 72px;
    }
}

/* ============================================================
   TABLE COLLAPSE
   ============================================================ */
/* Resizer has padding:0 5px → padding-box = 11px wide,
   the actual 1px line sits at offset 5–6px inside that box.
   Button on TABLE side: left: 6px  (starts right at the line's right edge)
   Button on CHART side: right: 6px (ends right at the line's left edge) */
.table-collapse-tab {
    position: absolute;
    bottom: 80px;
    left: 6px;
    right: auto;
    width: 10px;
    height: 26px;
    background: #2b3139;
    border: 1px solid #474d57;
    border-radius: 0 4px 4px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer !important;
    font-size: 11px;
    line-height: 1;
    color: #848e9c;
    z-index: 500;
    pointer-events: all !important;
    transition: background 0.15s, color 0.15s;
}
.table-collapse-tab:hover { background: #3c4150; color: #c9d1dc; }
/* Collapsed: button flips to chart/scale side, resizer becomes non-interactive */
.resizer-vertical.table-collapsed { cursor: default !important; pointer-events: none; }
.resizer-vertical.table-collapsed .table-collapse-tab {
    left: auto;
    right: 6px;
    border-radius: 3px 0 0 3px;
    pointer-events: all !important;
    cursor: pointer !important;
}
.table-wrapper.table-collapsed { width: 0 !important; overflow: hidden; }

/* ============================================================
   МОБИЛЬНАЯ ВЕРСИЯ (≤768px)
   ============================================================ */
@media (max-width: 768px) {
    * { box-sizing: border-box; }
    body { overflow-y: auto !important; touch-action: pan-y !important; height: auto !important; }
    .main-container { display: flex !important; flex-direction: column !important; height: auto !important; }
    .main-body { flex-direction: column !important; }
    .charts-wrapper {
        width: 100vw !important;
        height: calc(100dvh - 120px) !important;
        max-height: calc(100dvh - 120px) !important;
        flex: none !important;
    }
    .toolbar {
        order: 0;
        width: 100vw !important;
        height: 80px !important;
        min-height: 80px !important;
        flex-direction: row !important;
        border-right: none !important;
        border-top: 1px solid #2b3139 !important;
        justify-content: center !important;
        align-items: flex-start !important;
        padding-top: 12px !important;
        padding-bottom: 40px !important;
        background-color: #000000 !important;
        flex: none !important;
        box-sizing: border-box !important;
        z-index: 2001 !important;
    }
    .tool-btn { margin-bottom: 0 !important; margin-right: 10px !important; height: 32px !important; width: 32px !important; }
    .tv-tool-group { margin-bottom: 0 !important; margin-right: 10px !important; }
    .tv-tool-group .tv-group-btn { margin: 0 !important; }
    .tv-submenu-shortcut { display: none !important; }
    .toolbar-separator {
        width: 1px;
        height: 24px;
        margin: 4px 8px 0 2px;
    }
    .toolbar-trash-group { margin-right: 8px !important; }
    .toolbar-trash-submenu {
        top: auto !important;
        bottom: 100% !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
        margin: 0 0 8px !important;
        min-width: 260px !important;
    }
    .table-wrapper { width: 100vw !important; border-left: none !important; display: block !important; height: auto !important; flex: none !important; }
    .table-collapse-tab { display: none !important; }
    #price-container { flex: 50 1 0%; min-height: 50px; }
    #gd-container    { flex: 25 1 0%; min-height: 40px; }
    #macd-container  { flex: 25 1 0%; min-height: 40px; }
    #time-area { flex: 0 0 24px !important; height: 24px !important; }

    #top-bar {
        justify-content: flex-start !important;
    }
    #tf-selector { display: none !important; }
    #topbar-controls {
        padding-right: 10px !important;
    }
    .tf-mobile-trigger {
        display: flex !important;
        position: relative;
        left: 0;
    }

    .tv-submenu-arrow {
        opacity: 1 !important;
        left: 50% !important;
        right: auto !important;
        top: -8px !important;
        bottom: auto !important;
        transform: translateX(-50%) !important;
        width: 32px !important;
        height: 8px !important;
        border-radius: 0 0 3px 3px !important;
    }
    .tv-submenu-arrow::after {
        transform: rotate(-45deg) !important;
    }
    .tv-submenu-arrow.open::after,
    .tool-btn.menu-open .tv-submenu-arrow::after {
        transform: rotate(135deg) !important;
    }
    .tv-submenu {
        top: auto !important;
        bottom: 100% !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
        margin-left: 0 !important;
        margin-bottom: 8px !important;
    }
    .resizer {
        display: block !important; height: 24px !important; background: transparent !important;
        z-index: 1000; position: relative; cursor: row-resize; margin: -12px 0 !important;
        touch-action: none; -webkit-tap-highlight-color: transparent;
        outline: none !important; border: none !important;
    }
    .resizer:hover,
    .resizer:active,
    .resizer:focus,
    .resizer:focus-visible {
        background: transparent !important;
    }
    .resizer::after {
        content: ""; display: block; position: absolute; top: 50%; left: 0;
        width: 100%; height: 1px; background-color: rgba(255,255,255,0.15);
        transform: translateY(-50%); transition: background-color 0.1s; pointer-events: none;
    }
    .resizer.dragging::after { background-color: #0ecb81 !important; height: 1px !important; }
    .resizer-vertical { display: none !important; }
}

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