/* Анимация загрузки */
.search-loading {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #94a3b8;
    padding: 1rem;
}

.ruble-spinner {
    display: inline-block;
    font-size: 1.5rem;
    font-weight: 700;
    color: #3b82f6;
    animation: ruble-flip 1s ease-in-out infinite;
}

@keyframes ruble-flip {
    0% { transform: rotateY(0deg); }
    50% { transform: rotateY(180deg); }
    100% { transform: rotateY(360deg); }
}

.search-reset-btn {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    white-space: nowrap;
}

.search-result-rating {
    color: #f59e0b;
    font-size: 0.85rem;
    font-weight: 600;
}

.search-result-isin {
    color: #94a3b8;
    font-size: 0.85rem;
    font-family: monospace;
}

.risk-form {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin: 1rem 0;
    flex-wrap: wrap;
}

.risk-label {
    color: var(--text-primary, #f1f5f9);
    font-weight: 600;
}

.risk-slider {
    flex: 1;
    min-width: 200px;
    accent-color: #3b82f6;
}

.risk-value {
    color: #3b82f6;
    font-weight: 700;
    font-size: 1.2rem;
    min-width: 50px;
}

.opt-custom {
    border-left: 4px solid #3b82f6;
    margin-top: 1rem;
}

.period-selector {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 0.75rem;
}

.period-btn {
    padding: 0.5rem 1rem;
    border-radius: 6px;
    border: 1px solid var(--border, #555);
    background: var(--bg-input, #1e293b);
    color: var(--text-secondary, #94a3b8);
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.period-btn:hover {
    border-color: #3b82f6;
    color: #f1f5f9;
}

.period-btn.active {
    background: #3b82f6;
    color: white;
    border-color: #3b82f6;
    font-weight: 600;
}

.period-hint {
    margin-top: 0.75rem;
    padding: 0.75rem;
    background: var(--bg-input, #1e293b);
    border-radius: 6px;
    color: #94a3b8;
    font-size: 0.85rem;
    line-height: 1.5;
}

.period-hint strong {
    color: #cbd5e1;
}

.method-selector {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 0.75rem;
}

.method-btn {
    padding: 0.5rem 1rem;
    border-radius: 6px;
    border: 1px solid var(--border, #555);
    background: var(--bg-input, #1e293b);
    color: var(--text-secondary, #94a3b8);
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.method-btn:hover {
    border-color: #3b82f6;
    color: #f1f5f9;
}

.method-btn.active {
    background: #3b82f6;
    color: white;
    border-color: #3b82f6;
    font-weight: 600;
}

.method-explanation {
    margin-top: 0.75rem;
    padding: 0.75rem;
    background: var(--bg-input, #1e293b);
    border-radius: 6px;
    color: #94a3b8;
    font-size: 0.85rem;
    line-height: 1.5;
}

.method-explanation strong {
    color: #cbd5e1;
}

.risk-input {
    width: 100px;
    padding: 0.5rem;
    border-radius: 6px;
    border: 1px solid var(--border, #555);
    background: var(--bg-input, #1e293b);
    color: var(--text-primary, #f1f5f9);
    font-size: 1rem;
    text-align: center;
}

.risk-input:focus {
    border-color: #3b82f6;
    outline: none;
}

/* Черный текст в поле логина */


/* Сообщения */
.messages-container {
    max-width: 1200px;
    margin: 1rem auto;
    padding: 0 1rem;
}

.message {
    padding: 0.75rem 1rem;
    border-radius: 6px;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.message-success {
    background: rgba(46, 204, 113, 0.15);
    color: #2ecc71;
    border: 1px solid #2ecc71;
}

.message-error {
    background: rgba(239, 83, 80, 0.15);
    color: #ef5350;
    border: 1px solid #ef5350;
}

.message-warning {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
    border: 1px solid #f59e0b;
}

.form-errors {
    background: rgba(239, 83, 80, 0.15);
    border: 1px solid #ef5350;
    border-radius: 6px;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
}

.form-error {
    color: #ef5350;
    font-size: 0.9rem;
    margin: 0.25rem 0;
}

.weight-input {
    width: 7rem;
    text-align: center;
    padding: 0.3rem 0.5rem;
    border: 1px solid var(--border, #555);
    border-radius: 4px;
    background: var(--bg-input, #ffffff);
    color: var(--text-primary, #1a1a1a);
}

.quantity-input {
    width: 7rem;
    text-align: center;
    padding: 0.3rem 0.5rem;
    border: 1px solid var(--border, #555);
    border-radius: 4px;
    background: var(--bg-input, #ffffff);
    color: var(--text-primary, #1a1a1a);
}

/* Таблица портфеля — центрирование */
.data-table th {
    text-align: center !important;
    vertical-align: middle;
}

.data-table td {
    text-align: center;
    vertical-align: middle;
}

.data-table td input {
    margin: 0 auto;
    display: block;
}

/* Название инструмента — оставляем по левому краю для читаемости */
.data-table td:first-child {
    text-align: left;
}

.data-table td:first-child strong,
.data-table td:first-child span {
    display: inline-block;
}

/* Сетка для стресс-тестов и VaR */
.risk-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    align-items: start;
}

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

.chart-explanation {
    margin-top: 1.5rem;
    padding: 1rem;
    background: var(--bg-input, #1e293b);
    border-radius: 8px;
    border: 1px solid var(--border, #444);
}

.chart-explanation h3 {
    color: var(--text-primary, #f1f5f9);
    margin-bottom: 0.75rem;
    font-size: 1.1rem;
}

.chart-explanation p {
    color: #cbd5e1;
    font-size: 0.9rem;
    line-height: 1.6;
    margin: 0.5rem 0;
}

.chart-explanation strong {
    color: var(--text-primary, #f1f5f9);
}

.period-disclaimer {
    margin-top: 0.75rem;
    padding: 0.75rem;
    background: rgba(245, 158, 11, 0.1);
    border-left: 3px solid #f59e0b;
    border-radius: 4px;
}

.period-disclaimer strong {
    color: #f59e0b;
}

.frontier-warning {
    margin-top: 0.75rem;
    padding: 0.75rem;
    background: rgba(239, 83, 80, 0.15);
    border-left: 3px solid #ef5350;
    border-radius: 4px;
    color: #ef5350;
    font-size: 0.9rem;
    line-height: 1.5;
}

.frontier-warning strong {
    color: #ef5350;
}

.correlation-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-top: 1rem;
}

.correlation-block {
    background: var(--bg-input, #1e293b);
    border: 1px solid var(--border, #555);
    border-radius: 8px;
    padding: 0.75rem;
}

.correlation-explanation {
    margin-top: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: rgba(59, 130, 246, 0.05);
    border-radius: 4px;
    font-size: 0.85rem;
    color: #94a3b8;
    line-height: 1.5;
}

.correlation-explanation strong {
    color: #cbd5e1;
}

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

/* === Вынесенные инлайн-стили из dashboard/home.html === */

/* Бегущая строка */
.ticker-container {
    display: flex;
    gap: 1.5rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.separator {
    margin: 0 1rem;
}

.key-rate, .inflation {
    font-size: 0.9rem;
}

/* Поиск */
.search-input-flex {
    flex: 1;
}

.search-results-margin {
    margin-top: 1rem;
}

/* Кнопка оптимизации */
.btn-optimize-margin {
    margin-top: 0.75rem;
}

/* Счетчик инструментов */
.counter-text {
    font-size: 0.85rem;
}

/* Таблица портфеля */
.table-container {
    overflow-x: auto;
    margin-top: 1rem;
}

.secid-text {
    font-size: 0.8rem;
}

.unit-text {
    font-size: 0.8rem;
}

.div-date {
    font-size: 0.7rem;
}

/* Кнопка удаления */
.btn-remove {
    padding: 0.2rem 0.5rem;
    font-size: 0.8rem;
    margin-left: 0.25rem;
}

/* Итого */
.total-weight-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.total-weight-label {
    font-weight: 600;
}

/* Кнопки действий */
.action-buttons {
    display: flex;
    gap: 0.75rem;
    margin-top: 1rem;
}

.btn-flex {
    flex: 1;
    text-align: center;
}

/* Пустой портфель */
.empty-portfolio {
    text-align: center;
    padding: 2rem;
}

/* Графики корреляции */
.correlation-chart-height {
    height: 350px;
}

.correlation-hint {
    font-size: 0.8rem;
    margin-top: 0.5rem;
}

/* === Дополнительные классы из dashboard/home.html === */

/* Периоды */
.period-selector {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.period-label {
    color: var(--text-secondary);
}

.period-btn {
    padding: 0.3rem 0.75rem;
    font-size: 0.85rem;
}

/* Волатильность */
.volatility-container {
    text-align: center;
    margin-bottom: 1rem;
}

.volatility-badge {
    font-size: 1.1rem;
    padding: 0.6rem 1.5rem;
}

/* Метрики */
.metric-center {
    text-align: center;
    margin-bottom: 0.5rem;
}

.text-red {
    color: #c0392b;
}

.text-green {
    color: #2ecc71;
}

.metric-card {
    background: var(--bg-card);
    padding: 0.4rem 0.6rem;
    border-radius: 6px;
    border: 1px solid var(--border);
}

.metric-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    margin: 0;
}

.metric-value {
    font-size: 1.1rem;
    font-weight: 700;
    margin: 0;
}

/* Двухколоночный layout для корреляций */
.correlation-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

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

/* Активная кнопка периода */
.period-btn.active {
    box-shadow: 0 0 0 2px var(--accent);
    font-weight: 700;
}

/* Сетка для Scatter + Network */
.signal-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

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

/* Сетка для коэффициентов (2 колонки) */
.metrics-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

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

/* Цвета коэффициентов */
.metric-good {
    color: #2ecc71;
}

.metric-warn {
    color: #fbbf24;
}

.metric-bad {
    color: #c0392b;
}

/* Предупреждение об исключённых инструментах */
.excluded-warning {
    background: rgba(251, 191, 36, 0.1);
    border-left: 3px solid #fbbf24;
    padding: 0.75rem 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    font-size: 0.85rem;
}

.excluded-list {
    margin: 0.5rem 0 0 1.25rem;
    padding: 0;
    font-size: 0.8rem;
}

.excluded-list li {
    margin-bottom: 0.25rem;
}

/* Предупреждение об исключённых инструментах */
.excluded-warning {
    background: rgba(251, 191, 36, 0.1);
    border-left: 3px solid #fbbf24;
    padding: 0.75rem 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    font-size: 0.85rem;
}

.excluded-list {
    margin: 0.5rem 0 0 1.25rem;
    padding: 0;
    font-size: 0.8rem;
}

.excluded-list li {
    margin-bottom: 0.25rem;
}


.tooltip-detail {
    min-width: 200px !important;
    max-width: 240px !important;
    text-align: left !important;
    font-size: 0.75rem !important;
    line-height: 1.4 !important;
    padding: 0.5rem 0.75rem !important;
}

.tooltip-detail b {
    color: var(--accent);
    font-weight: 600;
}

.tooltip-detail em {
    color: var(--text-secondary);
    font-size: 0.7rem;
}

/* Заглушка для пустых графиков */
.empty-chart-card {
    min-height: 200px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.empty-chart-message {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text-secondary);
}

.empty-chart-message p:first-child {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.empty-chart-message p:last-child {
    font-size: 0.85rem;
    opacity: 0.7;
}

/* ============================================
   Таблицы страницы оптимизации (.table)
   Центрирование значений — согласовано с .data-table
   ============================================ */
.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    text-align: center;
    vertical-align: middle;
    padding: 0.5rem;
    border-bottom: 1px solid var(--border-light);
}

.table th {
    color: var(--accent);
    font-size: 0.85rem;
    text-transform: uppercase;
    font-weight: 600;
    border-bottom: 1px solid var(--border);
}

.table tr:hover td {
    background: var(--border-light);
}

/* Первая колонка в таблицах оптимизации — по левому краю (читаемость названий) */
.table td:first-child,
.table th:first-child {
    text-align: left;
}

/* VaR-блок с интерпретацией */
.var-intro {
    font-size: 0.85rem;
    color: var(--text-secondary);
    padding: 0.75rem;
    background: rgba(59, 130, 246, 0.08);
    border-left: 3px solid var(--accent);
    border-radius: 6px;
    margin-bottom: 1rem;
    line-height: 1.5;
}

.var-table {
    width: 100%;
    margin: 0.75rem 0;
    border-collapse: collapse;
}

.var-table td {
    padding: 0.35rem 0.5rem;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.9rem;
}

.var-table td:first-child {
    color: var(--text-secondary);
}

.var-table td:last-child {
    text-align: right;
}

.var-table strong {
    color: var(--accent);
    font-size: 1.05rem;
    font-weight: 700;
}

.var-interpretation {
    font-size: 0.82rem;
    color: var(--text-primary);
    margin-top: 0.75rem;
    padding: 0.6rem 0.75rem;
    background: var(--bg-input);
    border-radius: 6px;
    line-height: 1.6;
    border: 1px solid var(--border);
}

.var-summary {
    font-size: 0.85rem;
    color: var(--text-secondary);
    padding: 0.75rem;
    background: rgba(251, 191, 36, 0.08);
    border-left: 3px solid #fbbf24;
    border-radius: 6px;
    margin-top: 1rem;
    line-height: 1.5;
}

/* Цвета для бэктеста */
.text-green {
    color: #2ecc71 !important;
}

.text-red {
    color: #c0392b !important;
}

.text-yellow {
    color: #fbbf24 !important;
}

/* График эффективной границы */
.chart-frontier {
    width: 100%;
    height: 500px;
    min-height: 500px;
}

/* ============================================
   HERO — Портфель крупным планом
   ============================================ */
.hero-portfolio {
    background: linear-gradient(135deg, var(--bg-card) 0%, rgba(59, 130, 246, 0.05) 100%);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem 2rem;
    margin-bottom: 2rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.hero-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.hero-title {
    margin: 0;
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--text-primary);
}

.hero-body {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 2rem;
    align-items: center;
    margin-bottom: 1.5rem;
}

@media (max-width: 768px) {
    .hero-body {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
}

.hero-return {
    text-align: center;
    padding: 0.5rem 1.5rem;
    border-right: 1px solid var(--border);
}

@media (max-width: 768px) {
    .hero-return {
        border-right: none;
        border-bottom: 1px solid var(--border);
        padding-bottom: 1rem;
    }
}

.hero-return-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.25rem;
}

.hero-return-value {
    font-size: 3rem;
    font-weight: 700;
    line-height: 1;
    font-variant-numeric: tabular-nums;
    font-family: 'Inter', -apple-system, sans-serif;
}

.hero-return-period {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.hero-verdict {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.hero-verdict-text {
    font-size: 1.1rem;
    font-weight: 600;
    line-height: 1.4;
    padding: 0.5rem 0;
}

.verdict-good { color: #10b981; }
.verdict-warn { color: #f59e0b; }
.verdict-bad  { color: #ef4444; }

.hero-metrics {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.hero-metric {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.hero-metric-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.hero-metric-value {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

.hero-benchmarks {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-light);
}

@media (max-width: 600px) {
    .hero-benchmarks {
        grid-template-columns: 1fr;
    }
}

.hero-benchmark {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.hero-benchmark-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.hero-benchmark-value {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

/* ============================================
   Предупреждение об ограниченном периоде
   ============================================ */
.period-warning {
    background: rgba(251, 191, 36, 0.1);
    border-left: 4px solid #fbbf24;
    border-radius: 8px;
    padding: 1rem 1.25rem;
    margin: 1.5rem 0;
    font-size: 0.9rem;
    line-height: 1.5;
}

.period-warning-header {
    font-size: 0.95rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.period-warning-header strong {
    color: #fbbf24;
}

.period-warning-text {
    margin: 0.5rem 0;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.period-warning-list {
    margin: 0.5rem 0 0.75rem 1.25rem;
    padding: 0;
    font-size: 0.85rem;
    color: var(--text-primary);
}

.period-warning-list li {
    margin-bottom: 0.25rem;
}

.period-warning-list strong {
    color: var(--accent);
}

.period-warning-hint {
    margin: 0.75rem 0 0 0;
    padding-top: 0.75rem;
    border-top: 1px solid rgba(251, 191, 36, 0.2);
    color: var(--text-secondary);
    font-size: 0.8rem;
    line-height: 1.5;
}

/* Подсказка под таблицей секции */
.section-hint {
    font-size: 0.85rem;
    color: var(--text-secondary);
    padding: 0.75rem 1rem;
    margin-top: 1rem;
    background: rgba(59, 130, 246, 0.05);
    border-left: 3px solid var(--accent);
    border-radius: 6px;
    line-height: 1.5;
}

.section-hint strong {
    color: var(--text-primary);
}
