/* static/css/chart.css */
/* ✅ v7.3: Исправлены названия, добавлены стили для мини-хедера и попапов */
/* ✅ v1.0: Добавлены индикаторы статуса кэша в золотисто-серебристом стиле */

/* ==================== MAIN CONTENT ==================== */

.main-content {
    flex: 1;
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
}

/* ==================== CHART CONTAINER ==================== */

.chart-container {
    flex: 1;
    background: var(--bg-primary);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* ==================== CHART HEADER BAR ==================== */

.chart-header-bar {
    flex-shrink: 0;
    height: 48px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-primary);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 16px;
    gap: 16px;
    z-index: 50;
}

.chb-left {
    display: flex;
    align-items: center;
    gap: 16px;
    flex: 1;
    min-width: 0;
}

.chb-symbol-btn {
    background: var(--bg-primary);
    border: 1px solid var(--border-secondary);
    padding: 8px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 700;
    color: var(--accent-primary);
    font-size: 15px;
    transition: all 0.2s ease;
    white-space: nowrap;
    flex-shrink: 0;
}

.chb-symbol-btn:hover {
    background: var(--bg-secondary);
    border-color: var(--border-primary);
}

.chb-symbol-btn:active {
    transform: scale(0.98);
}

.chb-symbol-btn:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

.chb-price {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    min-width: 140px;
    font-variant-numeric: tabular-nums;
    transition: color 0.3s ease;
}

.chb-price.price-up {
    color: #0ecb81;
}

.chb-price.price-down {
    color: #f6465d;
}

.chb-change {
    font-size: 16px;
    font-weight: 700;
    min-width: 100px;
    font-variant-numeric: tabular-nums;
}

.chb-change.positive {
    color: #0ecb81;
}

.chb-change.negative {
    color: #f6465d;
}

.chb-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.chb-btn {
    width: 36px;
    height: 36px;
    padding: 0;
    background: var(--bg-primary);
    border: 1px solid var(--border-secondary);
    border-radius: 6px;
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all 0.2s ease;
}

.chb-btn:hover {
    background: var(--bg-secondary);
    border-color: var(--border-primary);
    color: var(--accent-primary);
}

.chb-btn:active {
    transform: scale(0.95);
}

.chb-btn:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

.chb-btn svg {
    width: 16px;
    height: 16px;
}

/* ==================== CHART CANVAS ZONE ==================== */

.chart-canvas-zone {
    flex: 1;
    position: relative;
    overflow: hidden;
    border-top: 1px solid var(--border-secondary);
}

/* ── Мультиграфик (Layout Grid) ── */
.layout-1x1 {
    display: grid;
    grid-template: 1fr / 1fr;
}

.layout-2x1 {
    display: grid;
    grid-template: 1fr / 1fr 1fr;
    gap: 0;
    background: transparent;
    padding: 0;
}

.layout-1x2 {
    display: grid;
    grid-template: 1fr 1fr / 1fr;
    gap: 0;
    background: transparent;
    padding: 0;
}

.layout-2x2 {
    display: grid;
    grid-template: 1fr 1fr / 1fr 1fr;
    gap: 0;
    background: transparent;
    padding: 0;
}

/* ==================== CHART ITEMS (Multi-Chart) ==================== */

.chart-item {
    position: relative;
    overflow: hidden;
    background: var(--bg-primary);
    transition: all 0.2s ease;
    border: 1px solid transparent;
    cursor: pointer;
    min-height: 200px;
}

/* ── Разделители между графиками ── */
.layout-2x1 .chart-item,
.layout-1x2 .chart-item,
.layout-2x2 .chart-item {
    border-color: var(--border-secondary);
}

/* Правая граница (не для последнего в строке) */
.layout-2x1 .chart-item:nth-child(1),
.layout-1x2 .chart-item:first-child,
.layout-2x2 .chart-item:nth-child(1),
.layout-2x2 .chart-item:nth-child(3) {
    border-right-color: var(--border-primary);
}

/* Нижняя граница (не для последней в столбце) */
.layout-2x1 .chart-item:nth-child(1),
.layout-1x2 .chart-item:first-child,
.layout-2x2 .chart-item:nth-child(1),
.layout-2x2 .chart-item:nth-child(2) {
    border-bottom-color: var(--border-primary);
}

/* ── Активный график (выделение) ── */
.chart-item.active {
    box-shadow: inset 0 0 0 2px var(--accent-primary);
    z-index: 10;
}

.chart-item.active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--accent-primary);
    z-index: 100;
}

/* ── Hover эффект для неактивного графика ── */
.chart-item:not(.active):hover {
    background: var(--bg-secondary);
    border-color: var(--accent-primary);
    opacity: 0.9;
}

/* ── Плавный переход при смене раскладки ── */
.chart-canvas-zone {
    transition: all 0.3s ease;
}

.chart-item {
    animation: chartItemFadeIn 0.3s ease;
}

@keyframes chartItemFadeIn {
    from {
        opacity: 0;
        transform: scale(0.98);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ==================== CHART ZONES ==================== */

.chart-zone {
    flex: 1;
    background: var(--bg-primary);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.chart-zone .chart-header-bar {
    height: 40px;
    padding: 0 12px;
}

.chart-zone .chb-price {
    font-size: 16px;
    min-width: 100px;
}

.chart-zone .chb-symbol-btn {
    font-size: 13px;
    padding: 6px 10px;
    min-width: auto;
}

.chart-zone .chb-change {
    font-size: 13px;
    min-width: 70px;
}

.chart-zone .chb-btn {
    width: 28px;
    height: 28px;
    font-size: 12px;
}

/* ══════════════════════════════════════════════════════════════════════ */
/* ✅ v7.3: CHART EMPTY STATE STYLES */
/* ══════════════════════════════════════════════════════════════════════ */

/**
 * Панель выбора актива для пустых графиков в мульти-режиме
 * Используется в chart-ui.js методом showEmptyState()
 */

.chart-empty-state {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    z-index: 20;
    gap: 20px;
    padding: 20px;
    text-align: center;
    animation: emptyStateFadeIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes emptyStateFadeIn {
    from {
        opacity: 0;
        transform: scale(0.98);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ── Logo & Brand ── */
.chart-empty-state > div:first-child {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.chart-empty-state > div:first-child > div:first-child {
    font-size: 28px;
    font-weight: 800;
    background: linear-gradient(135deg, #d4af37 0%, #f5e7a3 50%, #d4af37 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    letter-spacing: 2px;
    font-family: 'DM Mono', monospace;
}

.chart-empty-state > div:first-child > div:last-child {
    width: 60px;
    height: 2px;
    background: linear-gradient(90deg, transparent, #d4af37, transparent);
}

/* ── Заголовок ── */
.chart-empty-state > div:nth-child(2) {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

/* ── Контейнер поиска ── */
.empty-search-container {
    width: 100%;
    max-width: 280px;
    position: relative;
}

.empty-symbol-search {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-secondary);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: inherit;
}

.empty-symbol-search:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(212, 175, 55, 0.2);
    background: var(--bg-primary);
}

.empty-symbol-search::placeholder {
    color: var(--text-secondary);
}

/* ── Результаты поиска ── */
.empty-search-results {
    margin-top: 8px;
    max-height: 250px;
    overflow-y: auto;
    display: none;
    background: var(--bg-elevated);
    border-radius: 12px;
    border: 1px solid var(--border-secondary);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 30;
    scrollbar-width: thin;
    scrollbar-color: var(--border-secondary) var(--bg-primary);
}

.empty-search-results.visible {
    display: block;
    animation: searchResultsSlideDown 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes searchResultsSlideDown {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.empty-search-results::-webkit-scrollbar {
    width: 4px;
}

.empty-search-results::-webkit-scrollbar-track {
    background: var(--bg-primary);
    border-radius: 2px;
}

.empty-search-results::-webkit-scrollbar-thumb {
    background: var(--border-secondary);
    border-radius: 2px;
    transition: background 0.2s;
}

.empty-search-results::-webkit-scrollbar-thumb:hover {
    background: var(--border-primary);
}

.empty-search-result {
    padding: 10px 14px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-secondary);
    transition: background 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    color: var(--text-primary);
    font-size: 13px;
}

.empty-search-result:last-child {
    border-bottom: none;
}

.empty-search-result:hover {
    background: var(--bg-secondary);
}

.empty-search-result > div:first-child {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    color: var(--accent-primary);
}

.empty-search-result > div:last-child {
    font-size: 11px;
    color: var(--text-secondary);
}

/* ── Метаинформация ── */
.chart-empty-state > div:last-child {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    font-size: 11px;
    color: var(--text-secondary);
}

/* ==================== MINI HEADER (per chart) v7.3 ==================== */

/**
 * ✅ v7.3: Мини-хедер отображается на каждом графике в мульти-режиме
 * Показывает символ, цену, иконку закрытия и смены актива
 * Стили полностью переработаны для правильного отображения
 */

.chart-mini-header {
    position: absolute;
    top: 8px;
    left: 8px;
    right: 8px;
    z-index: 10;
    background: var(--bg-secondary);
    backdrop-filter: blur(8px);
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    font-family: 'DM Mono', monospace;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--accent-primary);
    color: var(--text-primary);
    pointer-events: auto;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    animation: miniHeaderFadeIn 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
    letter-spacing: 0.3px;
}

@keyframes miniHeaderFadeIn {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ── Инфо о символе (кликабельно) ── */
.mini-symbol-info {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 4px 8px;
    border-radius: 6px;
    margin: -4px -8px -4px -8px;
}

.mini-symbol-info:hover {
    opacity: 0.85;
    background: rgba(212, 175, 55, 0.1);
}

.mini-symbol-info:active {
    transform: scale(0.98);
}

.mini-symbol-info > span:first-child {
    font-size: 14px;
    flex-shrink: 0;
}

.mini-symbol-info > span:nth-child(2) {
    font-weight: 700;
    color: var(--accent-primary);
    font-variant-numeric: tabular-nums;
}

.mini-symbol-info > span:nth-child(3) {
    font-size: 10px;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}

.mini-symbol-info > span:nth-child(4) {
    font-size: 10px;
    color: var(--text-tertiary);
    flex-shrink: 0;
}

/* ── Контейнер для цены и процента ── */
.chart-mini-header > div:last-child {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chart-mini-header > div:last-child > span:first-child {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    min-width: 80px;
    text-align: right;
}

.chart-mini-header > div:last-child > span:nth-child(2) {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    min-width: 60px;
    text-align: right;
}

/* ── Кнопка закрытия ── */
.mini-close-btn {
    width: 22px;
    height: 22px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
    color: var(--text-primary);
}

.mini-close-btn:hover {
    background: rgba(246, 70, 93, 0.8);
    color: white;
    transform: scale(1.05);
}

.mini-close-btn:active {
    transform: scale(0.95);
}

/* ==================== LOCAL CHART LOADER ==================== */

/**
 * Локальный спиннер загрузки для каждого графика
 * Используется методом showLoadingForChart()
 */

.chart-loader-local {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-secondary);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spinLocal 1s linear infinite;
    z-index: 25;
}

@keyframes spinLocal {
    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

/* ══════════════════════════════════════════════════════════════════════ */
/* CANDLE TOOLTIP STYLES */
/* ══════════════════════════════════════════════════════════════════════ */

#chart-candle-tooltip {
    position: fixed;
    background: var(--bg-elevated);
    border: 1.5px solid var(--accent-primary);
    border-radius: 8px;
    padding: 12px 14px;
    font-size: 12px;
    z-index: 10000;
    pointer-events: none;
    box-shadow: 
        0 8px 24px rgba(0, 0, 0, 0.6),
        0 0 0 1px rgba(212, 175, 55, 0.1);
    min-width: 280px;
    font-family: 'DM Mono', 'Courier New', monospace;
    opacity: 0;
    transition: opacity 0.2s ease;
    backdrop-filter: blur(2px);
    background-clip: padding-box;
    left: 0;
    top: 0;
}

/* ── Показываем tooltip ── */
#chart-candle-tooltip.visible {
    opacity: 1;
}

/* ── При наведении на график ── */
#chart-candle-tooltip[style*="opacity: 1"] {
    animation: tooltipFadeIn 0.15s ease;
}

@keyframes tooltipFadeIn {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ── Дата в заголовке tooltip'а ── */
#chart-candle-tooltip > div:first-child {
    border-bottom: 1px solid var(--border-secondary);
    padding-bottom: 8px;
    margin-bottom: 8px;
}

#chart-candle-tooltip > div:first-child > div:first-child {
    font-weight: 700;
    color: var(--accent-primary);
    font-size: 12px;
    margin-bottom: 2px;
    letter-spacing: 0.3px;
}

/* ── OHLC Info Grid ── */
#chart-candle-tooltip > div:nth-child(2) {
    display: grid;
    grid-template-columns: auto auto;
    gap: 8px 12px;
    margin-bottom: 0;
}

#chart-candle-tooltip > div:nth-child(2) > div {
    display: contents;
}

#chart-candle-tooltip > div:nth-child(2) > div > div:first-child {
    color: var(--text-secondary);
    font-weight: 500;
    text-align: left;
    min-width: 45px;
}

#chart-candle-tooltip > div:nth-child(2) > div > div:last-child {
    color: var(--text-primary);
    font-weight: 600;
    text-align: right;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.2px;
}

/* ── High (зелёный) ── */
#chart-candle-tooltip > div:nth-child(2) > div:nth-child(2) > div:first-child {
    color: #0ecb81 !important;
    font-weight: 700;
}

#chart-candle-tooltip > div:nth-child(2) > div:nth-child(2) > div:last-child {
    color: #0ecb81 !important;
}

/* ── Low (красный) ── */
#chart-candle-tooltip > div:nth-child(2) > div:nth-child(3) > div:first-child {
    color: #f6465d !important;
    font-weight: 700;
}

#chart-candle-tooltip > div:nth-child(2) > div:nth-child(3) > div:last-child {
    color: #f6465d !important;
}

/* ── Close (жёлтый) ── */
#chart-candle-tooltip > div:nth-child(2) > div:nth-child(4) > div:first-child {
    color: var(--accent-primary) !important;
    font-weight: 700;
}

#chart-candle-tooltip > div:nth-child(2) > div:nth-child(4) > div:last-child {
    color: var(--accent-primary) !important;
}

/* ── Volume Info ── */
#chart-candle-tooltip > div:nth-child(3) {
    border-top: 1px solid var(--border-secondary);
    padding-top: 8px;
    margin-top: 8px;
}

#chart-candle-tooltip > div:nth-child(3) > div:first-child {
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 600;
    margin-bottom: 4px;
    letter-spacing: 0.3px;
}

#chart-candle-tooltip > div:nth-child(3) > div:last-child {
    color: var(--text-primary);
    font-weight: 700;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.2px;
}

/* ── Светлая тема ── */
[data-theme="light"] #chart-candle-tooltip {
    background: #ffffff;
    border-color: #b8860b;
    box-shadow: 
        0 8px 24px rgba(0, 0, 0, 0.15),
        0 0 0 1px rgba(184, 134, 11, 0.2);
}

[data-theme="light"] #chart-candle-tooltip > div:first-child {
    border-bottom-color: #e5e7eb;
}

[data-theme="light"] #chart-candle-tooltip > div:nth-child(2) > div > div:first-child {
    color: #6b7280;
}

[data-theme="light"] #chart-candle-tooltip > div:nth-child(2) > div > div:last-child {
    color: #111827;
}

[data-theme="light"] #chart-candle-tooltip > div:nth-child(3) {
    border-top-color: #e5e7eb;
}

[data-theme="light"] #chart-candle-tooltip > div:nth-child(3) > div:first-child {
    color: #6b7280;
}

[data-theme="light"] #chart-candle-tooltip > div:nth-child(3) > div:last-child {
    color: #111827;
}

/* ── Иконки в tooltip'е ── */
#chart-candle-tooltip > div:nth-child(2) > div:nth-child(2) > div:first-child::before {
    content: '⬆ ';
}

#chart-candle-tooltip > div:nth-child(2) > div:nth-child(3) > div:first-child::before {
    content: '⬇ ';
}

/* ==================== SYMBOL SEARCH POPUP ==================== */

#symbol-search-popup {
    position: fixed;
    top: 70px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-elevated);
    border: 2px solid var(--accent-primary);
    border-radius: 10px;
    padding: 12px;
    z-index: 2000;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.6);
    width: 90%;
    max-width: 400px;
    animation: popupSlideDown 0.3s ease;
}

@keyframes popupSlideDown {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

#symbol-search-input {
    width: 100%;
    padding: 10px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-secondary);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 14px;
    margin-bottom: 8px;
    transition: all 0.2s ease;
}

#symbol-search-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    background: var(--bg-primary);
    box-shadow: 0 0 0 2px rgba(212, 175, 55, 0.1);
}

#symbol-search-input::placeholder {
    color: var(--text-secondary);
}

#symbol-search-results {
    max-height: 300px;
    overflow-y: auto;
    border-top: 1px solid var(--border-secondary);
    padding-top: 8px;
}

.ss-result {
    padding: 10px 12px;
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    transition: all 0.2s ease;
}

.ss-result:hover {
    background: var(--bg-secondary);
}

.ss-result span:first-child {
    font-weight: 600;
    color: var(--accent-primary);
}

.ss-result span:last-child {
    font-weight: 500;
}

/* ==================== SYMBOL PICKER POPUP (Mini) ==================== */

/**
 * ✅ v7.3: Попап выбора символа для отдельного графика
 * Используется методом showSymbolPickerForChart()
 */

#symbol-picker-popup {
    position: absolute;
    top: 45px;
    left: 8px;
    background: var(--bg-elevated);
    border: 1px solid var(--accent-primary);
    border-radius: 12px;
    padding: 12px;
    z-index: 100;
    min-width: 260px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    animation: popupSlideDown 0.2s ease;
    max-width: 90vw;
}

#symbol-picker-popup[id^="symbol-picker-popup"] {
    position: absolute;
    top: 45px;
    left: 8px;
    background: var(--bg-elevated);
    border: 1px solid var(--accent-primary);
    border-radius: 12px;
    padding: 12px;
    z-index: 100;
    min-width: 260px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    animation: popupSlideDown 0.2s ease;
}

#symbol-picker-input {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-secondary);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 13px;
    outline: none;
    box-sizing: border-box;
    transition: all 0.2s ease;
    margin-bottom: 8px;
}

#symbol-picker-input:focus {
    border-color: var(--accent-primary);
    background: var(--bg-primary);
    box-shadow: 0 0 0 2px rgba(212, 175, 55, 0.1);
}

#symbol-picker-input::placeholder {
    color: var(--text-secondary);
}

#symbol-picker-results {
    max-height: 200px;
    overflow-y: auto;
    margin-top: 8px;
}

.picker-result {
    padding: 8px 12px;
    cursor: pointer;
    border-radius: 6px;
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    border-bottom: 1px solid var(--border-secondary);
    transition: background 0.2s ease;
    color: var(--text-primary);
}

.picker-result:last-child {
    border-bottom: none;
}

.picker-result:hover {
    background: var(--bg-secondary);
}

.picker-result span:first-child {
    font-weight: 600;
    color: var(--accent-primary);
}

.picker-result span:last-child {
    font-size: 10px;
    color: var(--text-secondary);
}

/* ==================== LAYOUT PICKER POPUP ==================== */

.layout-picker-popup {
    position: fixed;
    background: var(--bg-elevated);
    border: 1px solid var(--border-secondary);
    border-radius: 8px;
    padding: 8px;
    z-index: 1000;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    animation: popupSlideDown 0.2s ease;
}

.layout-opt {
    padding: 10px 14px;
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    transition: all 0.2s ease;
    color: var(--text-primary);
}

.layout-opt:hover {
    background: var(--bg-secondary);
}

.layout-opt span:last-child {
    margin-left: auto;
    color: var(--accent-primary);
    font-weight: 700;
    visibility: hidden;
}

.layout-opt[data-layout].active span:last-child {
    visibility: visible;
}

/* ==================== COLOR PICKER POPUP ==================== */

#cp-apply,
#cp-cancel {
    flex: 1;
    padding: 8px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    border: none;
    transition: all 0.2s ease;
    font-size: 13px;
}

#cp-apply {
    background: var(--accent-primary);
    color: white;
}

#cp-apply:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

#cp-apply:active {
    transform: translateY(0);
}

#cp-cancel {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-secondary);
}

#cp-cancel:hover {
    border-color: var(--border-primary);
    background: var(--bg-primary);
}

/* ==================== LOADING OVERLAY ==================== */

.loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 999;
    border-radius: 8px;
}

.loading-overlay.active {
    display: flex;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border-secondary);
    border-top: 4px solid var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ==================== LIGHT THEME - EMPTY STATE ==================== */

[data-theme="light"] .chart-empty-state {
    background: #ffffff;
}

[data-theme="light"] .chart-empty-state > div:nth-child(2) {
    color: #6b7280;
}

[data-theme="light"] .empty-symbol-search {
    background: #f8f9fa;
    border-color: #d1d5db;
    color: #111827;
}

[data-theme="light"] .empty-symbol-search:focus {
    border-color: #b8860b;
    background: #ffffff;
}

[data-theme="light"] .empty-symbol-search::placeholder {
    color: #9ca3af;
}

[data-theme="light"] .empty-search-results {
    background: #ffffff;
    border-color: #e5e7eb;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .empty-search-result {
    border-bottom-color: #e5e7eb;
    color: #111827;
}

[data-theme="light"] .empty-search-result:hover {
    background: #f3f4f6;
}

[data-theme="light"] .empty-search-result > div:first-child {
    color: #b8860b;
}

[data-theme="light"] .empty-search-result > div:last-child {
    color: #6b7280;
}

[data-theme="light"] .chart-empty-state > div:last-child {
    color: #6b7280;
}

/* ── Мини-шапка светлая тема ── */
[data-theme="light"] .chart-mini-header {
    background: var(--bg-secondary);
    border-bottom-color: #b8860b;
    color: #111827;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .mini-symbol-info {
    color: #111827;
}

[data-theme="light"] .mini-symbol-info:hover {
    background: rgba(184, 134, 11, 0.1);
}

[data-theme="light"] .mini-symbol-info > span:nth-child(2) {
    color: #b8860b;
}

[data-theme="light"] .mini-symbol-info > span:nth-child(3) {
    color: #6b7280;
}

[data-theme="light"] .mini-symbol-info > span:nth-child(4) {
    color: #9ca3af;
}

[data-theme="light"] .mini-close-btn {
    background: rgba(0, 0, 0, 0.05);
    color: #6b7280;
}

[data-theme="light"] .mini-close-btn:hover {
    background: rgba(246, 70, 93, 0.8);
    color: white;
}

[data-theme="light"] #symbol-picker-popup {
    background: #ffffff;
    border-color: #b8860b;
}

[data-theme="light"] #symbol-picker-input {
    background: #f8f9fa;
    border-color: #d1d5db;
    color: #111827;
}

[data-theme="light"] #symbol-picker-input:focus {
    background: #ffffff;
    border-color: #b8860b;
}

[data-theme="light"] .picker-result {
    border-bottom-color: #e5e7eb;
    color: #111827;
}

[data-theme="light"] .picker-result:hover {
    background: #f9fafb;
}

[data-theme="light"] .picker-result span:first-child {
    color: #b8860b;
}

/* ==================== LIGHT THEME - GENERAL ==================== */

[data-theme="light"] .chart-header-bar {
    background: #f8f9fa;
    border-bottom-color: #e5e7eb;
}

[data-theme="light"] .chb-symbol-btn {
    background: #ffffff;
    border-color: #d1d5db;
    color: #b8860b;
}

[data-theme="light"] .chb-symbol-btn:hover {
    background: #f9fafb;
    border-color: #b8860b;
}

[data-theme="light"] .chb-price {
    color: #111827;
}

[data-theme="light"] .chb-price.price-up {
    color: #0ecb81;
}

[data-theme="light"] .chb-price.price-down {
    color: #f6465d;
}

[data-theme="light"] .chb-btn {
    background: #ffffff;
    border-color: #d1d5db;
    color: #111827;
}

[data-theme="light"] .chb-btn:hover {
    background: #f9fafb;
    border-color: #b8860b;
    color: #b8860b;
}

[data-theme="light"] .chart-canvas-zone {
    border-top-color: #e5e7eb;
}

[data-theme="light"] .chart-item {
    background: #ffffff;
    border-color: #e5e7eb;
}

[data-theme="light"] .layout-2x1 .chart-item,
[data-theme="light"] .layout-1x2 .chart-item,
[data-theme="light"] .layout-2x2 .chart-item {
    border-color: #e5e7eb;
}

[data-theme="light"] .layout-2x1 .chart-item:nth-child(1),
[data-theme="light"] .layout-1x2 .chart-item:first-child,
[data-theme="light"] .layout-2x2 .chart-item:nth-child(1),
[data-theme="light"] .layout-2x2 .chart-item:nth-child(3) {
    border-right-color: #d1d5db;
}

[data-theme="light"] .layout-2x1 .chart-item:nth-child(1),
[data-theme="light"] .layout-1x2 .chart-item:first-child,
[data-theme="light"] .layout-2x2 .chart-item:nth-child(1),
[data-theme="light"] .layout-2x2 .chart-item:nth-child(2) {
    border-bottom-color: #d1d5db;
}

[data-theme="light"] .chart-item.active {
    box-shadow: inset 0 0 0 2px #b8860b;
}

[data-theme="light"] .chart-item.active::before {
    background: #b8860b;
}

[data-theme="light"] .chart-item:not(.active):hover {
    background: #f9fafb;
    border-color: #b8860b;
}

[data-theme="light"] .chart-zone {
    background: #ffffff;
}

[data-theme="light"] #symbol-search-popup {
    background: #ffffff;
    border-color: #b8860b;
}

[data-theme="light"] #symbol-search-input {
    background: #f8f9fa;
    border-color: #d1d5db;
    color: #111827;
}

[data-theme="light"] #symbol-search-input:focus {
    background: #ffffff;
    border-color: #b8860b;
}

[data-theme="light"] #symbol-search-results {
    border-top-color: #e5e7eb;
}

[data-theme="light"] .ss-result {
    color: #111827;
}

[data-theme="light"] .ss-result:hover {
    background: #f9fafb;
}

[data-theme="light"] .ss-result span:first-child {
    color: #b8860b;
}

[data-theme="light"] .layout-picker-popup {
    background: #ffffff;
    border-color: #d1d5db;
}

[data-theme="light"] .layout-opt {
    color: #111827;
}

[data-theme="light"] .layout-opt:hover {
    background: #f9fafb;
}

[data-theme="light"] #cp-apply {
    background: #b8860b;
    color: #ffffff;
}

[data-theme="light"] #cp-apply:hover {
    opacity: 0.85;
}

[data-theme="light"] #cp-cancel {
    background: #f8f9fa;
    border-color: #d1d5db;
    color: #111827;
}

[data-theme="light"] #cp-cancel:hover {
    background: #f1f3f5;
    border-color: #b8860b;
}

/* ==================== RESPONSIVE - DESKTOP ==================== */

@media (max-width: 1400px) {
    .chart-header-bar {
        gap: 12px;
        padding: 0 12px;
    }

    .chb-price {
        font-size: 18px;
        min-width: 120px;
    }

    .chb-btn {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }

    #chart-candle-tooltip {
        min-width: 260px;
        font-size: 11px;
    }
}

@media (max-width: 1280px) {
    .chart-header-bar {
        height: 44px;
    }

    .chb-symbol-btn {
        font-size: 12px;
        padding: 6px 10px;
    }

    .chb-price {
        font-size: 16px;
        min-width: 100px;
    }

    .chb-change {
        font-size: 13px;
        min-width: 80px;
    }

    .chb-btn {
        width: 32px;
        height: 32px;
        font-size: 13px;
    }

    #chart-candle-tooltip {
        min-width: 240px;
        font-size: 11px;
        padding: 10px 12px;
    }
}

/* ==================== RESPONSIVE - TABLET ==================== */

@media (max-width: 1024px) {
    .layout-2x1,
    .layout-1x2,
    .layout-2x2 {
        grid-template-columns: 1fr !important;
        grid-template-rows: repeat(auto-fit, minmax(300px, 1fr)) !important;
    }

    .layout-2x1 .chart-item:nth-child(1),
    .layout-1x2 .chart-item:first-child,
    .layout-2x2 .chart-item:nth-child(1),
    .layout-2x2 .chart-item:nth-child(2),
    .layout-2x2 .chart-item:nth-child(3) {
        border-right-color: var(--border-secondary);
        border-bottom-color: var(--border-primary);
    }

    .chart-item {
        min-height: 280px;
    }

    .chart-header-bar {
        height: 44px;
        gap: 8px;
        padding: 0 12px;
    }

    .chb-symbol-btn {
        font-size: 13px;
        padding: 6px 10px;
        min-width: 70px;
    }

    .chb-price {
        font-size: 16px;
        min-width: 100px;
    }

    .chb-change {
        font-size: 13px;
        min-width: 70px;
    }

    .chb-btn {
        width: 32px;
        height: 32px;
        font-size: 13px;
    }

    #chart-candle-tooltip {
        min-width: 220px;
        font-size: 11px;
        padding: 10px 12px;
    }

    .chart-empty-state > div:first-child > div:first-child {
        font-size: 22px;
    }

    .empty-symbol-search {
        padding: 10px 14px !important;
        font-size: 13px !important;
    }

    .empty-search-result {
        padding: 8px 12px !important;
        font-size: 12px !important;
    }

    .chart-mini-header {
        font-size: 12px;
        padding: 6px 10px;
    }

    [data-theme="light"] .layout-2x1 .chart-item:nth-child(1),
    [data-theme="light"] .layout-1x2 .chart-item:first-child,
    [data-theme="light"] .layout-2x2 .chart-item:nth-child(1),
    [data-theme="light"] .layout-2x2 .chart-item:nth-child(2),
    [data-theme="light"] .layout-2x2 .chart-item:nth-child(3) {
        border-right-color: #e5e7eb;
        border-bottom-color: #d1d5db;
    }
}

/* ==================== RESPONSIVE - MOBILE ==================== */

@media (max-width: 768px) {
    .main-content {
        height: auto;
        min-height: calc(100vh - 96px);
    }

    .chart-canvas-zone {
        min-height: 400px;
    }

    .layout-1x1,
    .layout-2x1,
    .layout-1x2,
    .layout-2x2 {
        grid-template-columns: 1fr !important;
        grid-template-rows: auto !important;
    }

    .chart-item {
        min-height: 320px;
        border-right-color: transparent !important;
        border-bottom-color: var(--border-primary) !important;
    }

    .chart-item:last-child {
        border-bottom-color: transparent !important;
    }

    .chart-header-bar {
        height: 40px;
        padding: 0 8px;
        gap: 6px;
    }

    .chb-left {
        gap: 8px;
    }

    .chb-symbol-btn {
        font-size: 12px;
        padding: 4px 8px;
        min-width: 60px;
    }

    .chb-price {
        font-size: 14px;
        min-width: 80px;
    }

    .chb-change {
        font-size: 12px;
        min-width: 60px;
    }

    .chb-right {
        gap: 4px;
    }

    .chb-btn {
        width: 28px;
        height: 28px;
        font-size: 12px;
    }

    #symbol-search-popup {
        width: 95vw;
        max-width: 350px;
        top: 60px;
    }

    #symbol-search-input {
        font-size: 13px;
        padding: 8px;
    }

    #symbol-picker-popup {
        max-width: 85vw;
    }

    #symbol-picker-input {
        font-size: 12px;
        padding: 6px 10px;
    }

    #chart-candle-tooltip {
        font-size: 11px;
        padding: 8px 10px;
        min-width: 200px;
        max-width: 90vw;
    }

    #chart-candle-tooltip > div:nth-child(2) {
        gap: 6px 10px;
    }

    .layout-picker-popup {
        top: 60px;
        right: 10px;
        left: auto;
        transform: none;
    }

    .chart-empty-state > div:first-child > div:first-child {
        font-size: 20px;
    }

    .empty-symbol-search {
        padding: 10px 14px;
        font-size: 13px;
    }

    .empty-search-result {
        padding: 8px 12px;
        font-size: 12px;
    }

    .chart-mini-header {
        font-size: 10px;
        padding: 6px 10px;
        top: 6px;
        left: 6px;
        right: 6px;
        gap: 10px;
    }

    .mini-symbol-info {
        gap: 6px;
    }

    .mini-symbol-info > span:first-child {
        font-size: 12px;
    }

    .mini-close-btn {
        width: 20px;
        height: 20px;
        font-size: 12px;
    }

    [data-theme="light"] .chart-item {
        border-bottom-color: #d1d5db;
    }

    [data-theme="light"] .chart-item:last-child {
        border-bottom-color: transparent;
    }
}

/* ==================== RESPONSIVE - SMALL MOBILE ==================== */

@media (max-width: 480px) {
    .chart-item {
        min-height: 280px;
    }

    .chart-header-bar {
        height: 36px;
        padding: 0 6px;
        gap: 4px;
    }

    .chb-symbol-btn {
        font-size: 11px;
        padding: 4px 6px;
        min-width: 50px;
    }

    .chb-price {
        font-size: 12px;
        min-width: 70px;
    }

    .chb-change {
        display: none;
    }

    .chb-btn {
        width: 24px;
        height: 24px;
        font-size: 10px;
    }

    #symbol-search-popup {
        top: 50px;
        padding: 8px;
        width: 98vw;
    }

    #symbol-search-input {
        font-size: 12px;
        padding: 6px;
        margin-bottom: 6px;
    }

    #symbol-search-results {
        max-height: 250px;
        padding-top: 6px;
    }

    #symbol-picker-popup {
        max-width: 95vw;
        padding: 8px;
    }

    #symbol-picker-input {
        font-size: 11px;
        padding: 6px;
        margin-bottom: 6px;
    }

    .ss-result {
        padding: 8px 10px;
        font-size: 12px;
    }

    .picker-result {
        padding: 6px 10px;
        font-size: 11px;
    }

    #chart-candle-tooltip {
        font-size: 10px;
        padding: 6px 8px;
        min-width: 160px;
        max-width: 95vw;
    }

    #chart-candle-tooltip > div:first-child {
        padding-bottom: 6px;
        margin-bottom: 6px;
    }

    #chart-candle-tooltip > div:nth-child(2) {
        gap: 4px 8px;
    }

    #chart-candle-tooltip > div:nth-child(3) {
        padding-top: 6px;
        margin-top: 6px;
    }

    .layout-picker-popup {
        top: 50px;
        right: 6px;
        padding: 6px;
    }

    .layout-opt {
        padding: 8px 10px;
        font-size: 12px;
    }

    .layout-opt span:first-child {
        font-size: 14px;
    }

    .chart-empty-state > div:first-child > div:first-child {
        font-size: 18px;
    }

    .empty-symbol-search {
        padding: 8px 12px;
        font-size: 12px;
    }

    .empty-search-result {
        padding: 6px 10px;
        font-size: 11px;
    }

    .chart-mini-header {
        font-size: 9px;
        padding: 4px 8px;
        top: 4px;
        left: 4px;
        right: 4px;
        gap: 6px;
    }

    .mini-symbol-info {
        gap: 4px;
    }

    .mini-symbol-info > span:first-child {
        font-size: 10px;
    }

    .mini-close-btn {
        width: 18px;
        height: 18px;
        font-size: 10px;
    }
}

/* ==================== PRINT STYLES ==================== */

@media print {
    .chart-header-bar {
        display: none !important;
    }

    #chart-candle-tooltip {
        display: none !important;
    }

    #symbol-search-popup {
        display: none !important;
    }

    #symbol-picker-popup {
        display: none !important;
    }

    .chart-empty-state {
        display: none !important;
    }

    .chart-mini-header {
        display: none !important;
    }

    .chart-item {
        page-break-inside: avoid;
        border: 1px solid #ccc;
    }

    .layout-2x1,
    .layout-1x2,
    .layout-2x2 {
        display: block !important;
    }

    .chart-item {
        display: block !important;
        margin-bottom: 20px;
        min-height: 400px;
    }

    .chart-item:last-child {
        margin-bottom: 0;
    }
}

/* ==================== ANIMATIONS ==================== */

@keyframes fadeInChart {
    from {
        opacity: 0;
        transform: scale(0.98);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ==================== PERFORMANCE ==================== */

.chart-canvas-zone,
.chart-item,
.chb-btn,
#chart-candle-tooltip,
#symbol-picker-popup,
.chart-empty-state,
.chart-mini-header {
    will-change: auto;
    transform: translateZ(0);
    backface-visibility: hidden;
}

.chart-item.active {
    will-change: box-shadow;
}

.chart-mini-header {
    will-change: transform, opacity;
}

#chart-candle-tooltip {
    will-change: opacity, transform;
}

#symbol-picker-popup {
    will-change: opacity, transform;
}

.empty-symbol-search {
    will-change: border-color, background-color;
}

.mini-symbol-info {
    will-change: transform, background-color;
}

.mini-close-btn {
    will-change: background-color, transform;
}

/* ==================== TRANSITIONS ==================== */

.chart-item {
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.chart-item.active {
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

.chart-mini-header {
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.mini-symbol-info {
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.mini-close-btn {
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.chb-btn {
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

#symbol-search-input,
#symbol-picker-input {
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

#chart-candle-tooltip {
    transition: opacity 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

#symbol-picker-popup {
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.empty-symbol-search {
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==================== FOCUS & ACCESSIBILITY ==================== */

.chart-item:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: -2px;
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.empty-symbol-search:focus-visible,
#symbol-search-input:focus-visible,
#symbol-picker-input:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

.mini-symbol-info:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

.mini-close-btn:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

/* ==================== CUSTOM SCROLLBAR ==================== */

#symbol-search-results::-webkit-scrollbar,
#symbol-picker-results::-webkit-scrollbar,
.empty-search-results::-webkit-scrollbar {
    width: 6px;
}

#symbol-search-results::-webkit-scrollbar-track,
#symbol-picker-results::-webkit-scrollbar-track,
.empty-search-results::-webkit-scrollbar-track {
    background: var(--bg-primary);
    border-radius: 3px;
}

#symbol-search-results::-webkit-scrollbar-thumb,
#symbol-picker-results::-webkit-scrollbar-thumb,
.empty-search-results::-webkit-scrollbar-thumb {
    background: var(--border-secondary);
    border-radius: 3px;
}

#symbol-search-results::-webkit-scrollbar-thumb:hover,
#symbol-picker-results::-webkit-scrollbar-thumb:hover,
.empty-search-results::-webkit-scrollbar-thumb:hover {
    background: var(--border-primary);
}

/* ==================== Z-INDEX HIERARCHY ==================== */

/* 
 * 0-10: Elements inside content
 * 10: Chart item active, mini header
 * 20: Chart empty state
 * 25: Chart local loader
 * 30: Empty search results (absolute positioning)
 * 50: Chart header bar
 * 100: Chart item active top border, symbol picker popup
 * 200: Chart loading indicator (high priority)
 * 999: Loading overlay
 * 1000: General popups & tooltips
 * 2000: Symbol search popup
 * 10000: Candle tooltip (highest)
 */

/* ══════════════════════════════════════════════════════════════════════ */
/* ✅ v1.0: CACHE INDICATORS - Gold/Silver Theme */
/* ══════════════════════════════════════════════════════════════════════ */

/**
 * ✅ v1.0: Индикаторы статуса кэша в золотисто-серебристом стиле
 * Интеграция с CacheManager v1.1
 * 
 * CSS переменные (используются из переменных темы):
 * - --accent-primary: #d4af37 (золото)
 * - --accent-light: #f5e7a3 (светлое золото)
 * - --bg-glass: прозрачный фон с blur
 * - --border-accent: граница акцента
 * - --shadow-sm: маленькая тень
 * - --shadow-lg: большая тень
 */

/* ── Предупреждение об устаревших данных (Золотой акцент) ── */
.cache-warning {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(20, 28, 38, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: var(--accent-primary);
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 11px;
    font-family: 'DM Mono', monospace;
    font-weight: 500;
    z-index: 100;
    display: flex;
    gap: 10px;
    align-items: center;
    border-left: 3px solid var(--accent-primary);
    border-right: 1px solid rgba(212, 175, 55, 0.3);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(212, 175, 55, 0.1);
    pointer-events: none;
    animation: cacheWarningSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    letter-spacing: 0.2px;
}

.cache-warning span:first-child {
    color: var(--accent-light);
    text-shadow: 0 0 4px rgba(212, 175, 55, 0.2);
}

.cache-warning .refresh-spinner {
    width: 12px;
    height: 12px;
    border: 2px solid rgba(212, 175, 55, 0.25);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: cacheSpin 0.8s linear infinite;
}

/* ── Успешная загрузка из кэша (Серебристый акцент) ── */
.cache-success {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(20, 28, 38, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: #c0c0c0;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 11px;
    font-family: 'DM Mono', monospace;
    font-weight: 500;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 8px;
    border-left: 3px solid #c0c0c0;
    border-right: 1px solid rgba(192, 192, 192, 0.3);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
    animation: cacheSuccessFadeIn 0.3s ease, cacheSuccessFadeOut 2s forwards 1.5s;
    pointer-events: none;
    letter-spacing: 0.2px;
}

.cache-success::before {
    content: '✓';
    font-weight: 700;
    font-size: 12px;
    color: #c0c0c0;
}

/* ── Свежие данные из кэша (Золотая молния) ── */
.cache-status-fresh {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(20, 28, 38, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: var(--accent-primary);
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 10px;
    font-family: 'DM Mono', monospace;
    font-weight: 600;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 6px;
    border-left: 3px solid var(--accent-primary);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
    animation: cacheFreshPulse 2s ease-in-out infinite, cacheSuccessFadeOut 2.5s forwards 1s;
    pointer-events: none;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.cache-status-fresh::before {
    content: '⚡';
    font-size: 10px;
}

/* ── Стало данные из кэша (Оранжевый) ── */
.cache-status-stale {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(20, 28, 38, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: #ff9800;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 11px;
    font-family: 'DM Mono', monospace;
    font-weight: 500;
    z-index: 100;
    display: flex;
    gap: 10px;
    align-items: center;
    border-left: 3px solid #ff9800;
    border-right: 1px solid rgba(255, 152, 0, 0.3);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
    pointer-events: none;
    animation: cacheWarningSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    letter-spacing: 0.2px;
}

.cache-status-stale .refresh-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-left: 4px;
    font-size: 10px;
}

.cache-status-stale .refresh-indicator::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    border: 1.5px solid rgba(255, 152, 0, 0.3);
    border-top-color: #ff9800;
    border-radius: 50%;
    animation: cacheSpin 0.8s linear infinite;
}

/* ── Локальный спиннер загрузки для графика ── */
.chart-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(20, 28, 38, 0.9);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    padding: 14px 24px;
    border-radius: 12px;
    display: flex;
    gap: 12px;
    align-items: center;
    z-index: 200;
    font-size: 13px;
    font-weight: 600;
    font-family: 'DM Mono', monospace;
    color: var(--text-primary);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(212, 175, 55, 0.1);
    animation: chartLoadingFadeIn 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
    letter-spacing: 0.3px;
}

.chart-loading .spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(212, 175, 55, 0.25);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: cacheSpin 0.8s linear infinite;
}

.chart-loading span {
    background: linear-gradient(135deg, var(--text-primary), var(--accent-light));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

/* ── Ошибка загрузки ── */
.chart-error {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(20, 28, 38, 0.9);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    padding: 16px 28px;
    border-radius: 12px;
    text-align: center;
    z-index: 200;
    color: #f6465d;
    border: 1px solid rgba(246, 70, 93, 0.3);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    animation: chartErrorFadeIn 0.25s ease;
    min-width: 260px;
}

.chart-error span {
    display: block;
    margin-bottom: 12px;
    font-family: 'DM Mono', monospace;
    font-size: 12px;
    font-weight: 500;
}

.chart-error button {
    margin-top: 0;
    padding: 6px 16px;
    background: var(--accent-primary);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 700;
    font-size: 11px;
    font-family: var(--font-body);
    color: black;
    transition: all 0.2s ease;
}

.chart-error button:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(212, 175, 55, 0.3);
}

/* ── Индикатор обновления в мини-хедерах ── */
.chart-mini-header .cache-refresh-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-left: 8px;
    font-size: 9px;
    font-family: 'DM Mono', monospace;
    color: var(--accent-primary);
    opacity: 0.8;
}

.chart-mini-header .cache-refresh-indicator .spinner-mini {
    width: 8px;
    height: 8px;
    border: 1.5px solid rgba(212, 175, 55, 0.3);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: cacheSpin 0.6s linear infinite;
}

/* ==================== CACHE ANIMATIONS ==================== */

@keyframes cacheSpin {
    to { transform: rotate(360deg); }
}

@keyframes cacheWarningSlideIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes cacheSuccessFadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes cacheSuccessFadeOut {
    0% { opacity: 1; }
    70% { opacity: 1; }
    100% { opacity: 0; visibility: hidden; }
}

@keyframes cacheFreshPulse {
    0%, 100% {
        opacity: 0.9;
        box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
    }
    50% {
        opacity: 1;
        box-shadow: 0 0 12px rgba(212, 175, 55, 0.3);
    }
}

@keyframes chartLoadingFadeIn {
    from {
        opacity: 0;
        transform: translate(-50%, -40%);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%);
    }
}

@keyframes chartErrorFadeIn {
    from {
        opacity: 0;
        transform: translate(-50%, -45%);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%);
    }
}

/* ==================== LIGHT THEME - CACHE INDICATORS ==================== */

[data-theme="light"] .cache-warning {
    background: rgba(250, 249, 247, 0.95);
    border-left-color: #b8860b;
    color: #b8860b;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08), 0 0 0 1px rgba(184, 134, 11, 0.15);
}

[data-theme="light"] .cache-warning span:first-child {
    color: #8b6300;
}

[data-theme="light"] .cache-warning .refresh-spinner {
    border-color: rgba(184, 134, 11, 0.25);
    border-top-color: #b8860b;
}

[data-theme="light"] .cache-success {
    background: rgba(250, 249, 247, 0.95);
    border-left-color: #a9a9a9;
    color: #6b7280;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .cache-success::before {
    color: #888888;
}

[data-theme="light"] .cache-status-fresh {
    background: rgba(250, 249, 247, 0.95);
    border-left-color: #b8860b;
    color: #b8860b;
}

[data-theme="light"] .cache-status-stale {
    background: rgba(250, 249, 247, 0.95);
    border-left-color: #ff9800;
    color: #f57c00;
}

[data-theme="light"] .cache-status-stale .refresh-indicator::before {
    border-color: rgba(255, 152, 0, 0.25);
    border-top-color: #ff9800;
}

[data-theme="light"] .chart-loading {
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(184, 134, 11, 0.2);
    color: #111827;
}

[data-theme="light"] .chart-loading .spinner {
    border-color: rgba(184, 134, 11, 0.25);
    border-top-color: #b8860b;
}

[data-theme="light"] .chart-loading span {
    background: linear-gradient(135deg, #111827, #b8860b);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

[data-theme="light"] .chart-error {
    background: rgba(255, 255, 255, 0.98);
    border-color: rgba(245, 67, 54, 0.3);
    color: #d32f2f;
}

[data-theme="light"] .chart-error button {
    background: #b8860b;
    color: white;
}

[data-theme="light"] .chart-mini-header .cache-refresh-indicator {
    color: #b8860b;
}

/* ==================== CACHE INDICATORS RESPONSIVE ==================== */

@media (max-width: 768px) {
    .cache-warning,
    .cache-success,
    .cache-status-fresh,
    .cache-status-stale {
        top: 8px;
        right: 8px;
        padding: 5px 10px;
        font-size: 9px;
    }
    
    .cache-warning,
    .cache-status-stale {
        gap: 6px;
    }
    
    .cache-warning .refresh-spinner,
    .cache-status-stale .refresh-indicator::before {
        width: 10px;
        height: 10px;
    }
    
    .chart-loading {
        padding: 10px 18px;
        font-size: 11px;
    }
    
    .chart-loading .spinner {
        width: 16px;
        height: 16px;
    }
    
    .chart-error {
        padding: 12px 20px;
        min-width: 220px;
    }
    
    .chart-error span {
        font-size: 11px;
    }
}

@media (max-width: 480px) {
    .cache-warning,
    .cache-success,
    .cache-status-fresh,
    .cache-status-stale {
        top: 6px;
        right: 6px;
        padding: 4px 8px;
        font-size: 8px;
    }
    
    .cache-warning,
    .cache-status-stale {
        gap: 4px;
    }
    
    .chart-loading {
        padding: 8px 14px;
        font-size: 10px;
        gap: 8px;
    }
    
    .chart-loading .spinner {
        width: 14px;
        height: 14px;
    }
}

/* ==================== CACHE INDICATORS PRINT ==================== */

@media print {
    .cache-warning,
    .cache-success,
    .cache-status-fresh,
    .cache-status-stale,
    .chart-loading,
    .chart-error {
        display: none !important;
    }
}

/* ==================== HIGH CONTRAST ==================== */

@media (prefers-contrast: more) {
    .cache-warning {
        border-left-width: 4px;
        background: var(--bg-primary);
        backdrop-filter: none;
    }
    
    .cache-success {
        border-left-width: 4px;
        background: var(--bg-primary);
        backdrop-filter: none;
    }
    
    .cache-status-fresh,
    .cache-status-stale {
        border-left-width: 4px;
        background: var(--bg-primary);
        backdrop-filter: none;
    }
}