/* style.css */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

body {
    background: #f5f7fa;
    color: #1e293b;
    line-height: 1.5;
}

.container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 20px;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    flex-wrap: wrap;
    gap: 15px;
}

header h1 {
    font-size: 2rem;
    background: linear-gradient(135deg, #f7931a, #4d4d4d);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.controls {
    display: flex;
    align-items: center;
    gap: 20px;
}

.btn {
    background: #3b82f6;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.btn:hover {
    background: #2563eb;
}

#updateTime {
    color: #64748b;
    font-size: 0.9rem;
}

.dashboard {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 25px;
}

.timeframe-card {
    background: white;
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.05);
    transition: transform 0.2s;
}

.timeframe-card > h2 {
    font-size: 1.4rem;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.timeframe-card > h2 small {
    font-size: 0.8rem;
    color: #94a3b8;
    font-weight: normal;
}

.card {
    background: #f8fafc;
    border-radius: 16px;
    padding: 15px;
    margin-bottom: 20px;
    border: 1px solid #e2e8f0;
}

.card h3 {
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #475569;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Тренд */
.trend-value {
    font-size: 1.6rem;
    font-weight: 700;
    margin: 5px 0;
}
.trend-value.bullish { color: #22c55e; }
.trend-value.bearish { color: #ef4444; }
.trend-value.flat    { color: #64748b; }

/* Паттерны */
.pattern-name {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}
.pattern-name strong {
    font-size: 1.2rem;
}
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 30px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}
.badge.buy { background: #dcfce7; color: #166534; }
.badge.sell { background: #fee2e2; color: #991b1b; }
.badge.reversal { background: #fef9c3; color: #854d0e; }
.badge.confirmation { background: #dbeafe; color: #1e40af; }

/* Уровни */
.levels-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}
.support h4, .resistance h4 {
    font-size: 0.9rem;
    color: #475569;
    margin-bottom: 10px;
}
.level-item {
    display: flex;
    justify-content: space-between;
    padding: 5px 0;
    border-bottom: 1px dashed #cbd5e1;
}
.price { font-weight: 600; }
.strength { color: #64748b; font-size: 0.8rem; }

/* Волатильность */
.compact-table {
    width: 100%;
    font-size: 0.9rem;
}
.compact-table td:first-child {
    color: #475569;
    width: 40%;
}
.signals {
    background: #fff3cd;
    border-left: 4px solid #ffc107;
    padding: 8px 12px;
    border-radius: 6px;
    margin-top: 10px;
    font-size: 0.85rem;
}

/* История */
.history-content {
    overflow-x: auto;
    transition: max-height 0.3s;
}
.history-content table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}
.history-content th {
    text-align: left;
    background: #e2e8f0;
    padding: 6px;
}
.history-content td {
    padding: 6px;
    border-bottom: 1px solid #e2e8f0;
}
.history-content td.buy { color: #166534; font-weight: 600; }
.history-content td.sell { color: #991b1b; font-weight: 600; }

/* Состояния */
.no-data {
    color: #94a3b8;
    font-style: italic;
    text-align: center;
    padding: 20px 0;
}

small {
    color: #94a3b8;
    display: block;
    margin-top: 8px;
}

/* Контейнер графика */
.chart-container {
    width: 100%;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid #e2e8f0;
    background: #ffffff;
}

.card h3 {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
}
.toggle-btn {
    font-size: 1.2rem;
    width: 24px;
    text-align: center;
    background: #e2e8f0;
    border-radius: 4px;
    padding: 2px 0;
    transition: background 0.2s;
    cursor: pointer;
}
.toggle-btn:hover {
    background: #cbd5e1;
}
/* Волновой анализ */
.wave-table {
    width: 100%;
    font-size: 0.9rem;
    border-collapse: collapse;
}
.wave-table th {
    text-align: left;
    color: #475569;
    font-weight: 500;
    width: 40%;
    padding: 4px 0;
}
.wave-table td {
    padding: 4px 0;
    font-weight: 500;
}
/* Модальное окно */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.5);
}

.modal-content {
    background-color: #fff;
    margin: 10% auto;
    padding: 20px;
    border-radius: 8px;
    width: 400px;
    max-width: 90%;
}

.tabs {
    display: flex;
    border-bottom: 1px solid #ccc;
    margin-bottom: 15px;
}

.tab-btn {
    padding: 10px 15px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    border-bottom: 2px solid transparent;
}

.tab-btn.active {
    border-bottom-color: #007bff;
    font-weight: bold;
}

.instrument-list ul {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 300px;
    overflow-y: auto;
}

.instrument-list li {
    padding: 8px 12px;
    cursor: pointer;
    border-bottom: 1px solid #eee;
}

.instrument-list li:hover {
    background-color: #f0f0f0;
}

/* ===== Стили шапки ===== */
.container header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(145deg, #ffffff 0%, #f8faff 100%);
    padding: 20px 30px;
    border-radius: 24px;
    box-shadow: 0 12px 30px rgba(0, 20, 50, 0.08);
    margin-bottom: 35px;
    border: 1px solid rgba(230, 240, 255, 0.8);
    backdrop-filter: blur(2px);
}

.container header h1 {
    font-size: 2rem;
    font-weight: 600;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 15px;
    color: #1a2639;
    letter-spacing: -0.02em;
}

.controls {
    display: flex;
    gap: 15px;
    align-items: center;
    flex-wrap: wrap;
}

.btn {
    padding: 12px 28px;
    border: none;
    border-radius: 50px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    background: white;
    color: #1e293b;
    border: 1px solid #e2e8f0;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.02);
}

.btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 20px rgba(0, 0, 0, 0.1);
    border-color: #cbd5e1;
}

.btn:active {
    transform: translateY(0);
    box-shadow: 0 4px 8px rgba(0,0,0,0.05);
}

#refreshBtn {
    background: #22c55e;
    color: white;
    border: none;
    box-shadow: 0 8px 16px rgba(34, 197, 94, 0.25);
}

#refreshBtn:hover {
    background: #16a34a;
    box-shadow: 0 12px 24px rgba(34, 197, 94, 0.35);
}

#changeInstrumentBtn {
    background: #3b82f6;
    color: white;
    border: none;
    box-shadow: 0 8px 16px rgba(59, 130, 246, 0.25);
}

#changeInstrumentBtn:hover {
    background: #2563eb;
    box-shadow: 0 12px 24px rgba(59, 130, 246, 0.35);
}

#updateTime {
    background: #f1f5f9;
    padding: 10px 22px;
    border-radius: 40px;
    font-size: 0.95rem;
    color: #334155;
    border: 1px solid #e2e8f0;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.02);
    font-weight: 500;
    white-space: nowrap;
}

/* Адаптивность */
@media (max-width: 850px) {
    .container header {
        flex-direction: column;
        align-items: stretch;
        gap: 20px;
        padding: 20px;
    }

    .container header h1 {
        justify-content: space-between;
        width: 100%;
        font-size: 1.7rem;
    }

    .container header h1 span {
        font-size: 1.1rem;
        padding: 6px 16px;
    }

    .controls {
        justify-content: center;
        width: 100%;
    }
}

@media (max-width: 550px) {
    .controls {
        flex-direction: column;
        align-items: stretch;
    }

    .btn, #updateTime {
        width: 100%;
        text-align: center;
        justify-content: center;
    }
}

/* Стили для таблицы Фибоначчи */
.fib-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
    font-size: 12px;
}
.fib-table td {
    padding: 2px 4px;
    border-bottom: 1px solid #eee;
}
.fib-table td:first-child {
    font-weight: bold;
    width: 40%;
}

/* Стили для списка волн Эллиотта */
.wave ul {
    margin: 5px 0;
    padding-left: 20px;
}
.wave li {
    font-size: 12px;
}

/* Компактная таблица для карточки объёма */
.compact-table th {
    text-align: left;
    font-weight: normal;
    color: #666;
    padding-right: 10px;
}
.compact-table td {
    font-weight: 500;
}
.signals {
    margin-top: 8px;
    font-size: 12px;
    background: #f9f9f9;
    padding: 5px;
    border-radius: 4px;
}

/* Цвета для действий в торговом сигнале */
.trading-signal .compact-table td.buy { color: #22c55e; font-weight: bold; }
.trading-signal .compact-table td.sell { color: #ef4444; font-weight: bold; }
.trading-signal .compact-table td.hold { color: #64748b; font-weight: bold; }

/* Вкладки для переключения панелей */
#mainTabs {
    display: flex;
    gap: 5px;
    margin-bottom: 20px;
    border-bottom: 1px solid #e2e8f0;
}
#mainTabs .tab-btn {
    padding: 10px 20px;
    background: none;
    border: none;
    font-size: 1rem;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: 0.2s;
}
#mainTabs .tab-btn.active {
    border-bottom-color: #3b82f6;
    font-weight: bold;
    color: #3b82f6;
}
#mainTabs .tab-btn:hover:not(.active) {
    border-bottom-color: #94a3b8;
}

/* Панели */
.pane {
    display: none;
}
.pane.active {
    display: block;
}

/* Стили для ИНС-блоков */
.ins-container {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-top: 10px;
}
.ins-block {
    flex: 1;
    min-width: 280px;
    background: white;
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.05);
    border: 1px solid #e2e8f0;
}
.ins-block h3 {
    font-size: 1.3rem;
    margin-bottom: 15px;
    padding-bottom: 8px;
    border-bottom: 2px solid #e2e8f0;
}
.ins-card {
    background: #f8fafc;
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 15px;
}
.ins-card h4 {
    font-size: 0.9rem;
    color: #475569;
    margin-bottom: 8px;
}
.ins-content {
    font-size: 1rem;
    font-weight: 500;
    color: #1e293b;
}
.ins-content .price {
    font-weight: 600;
    color: #3b82f6;
}
.ins-content .probability {
    color: #22c55e;
}
.ins-content .direction {
    font-weight: bold;
}
/* История прогнозов ИНС */
.history-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}
.history-table th {
    text-align: left;
    background: #e2e8f0;
    padding: 8px;
    font-weight: 600;
}
.history-table td {
    padding: 8px;
    border-bottom: 1px solid #e2e8f0;
    vertical-align: top;
}
.history-time {
    white-space: nowrap;
    color: #64748b;
}
.history-content {
    word-break: break-word;
}
.ins-content .error {
    color: #ef4444;
}
/* Стили для истории прогнозов ИНС в виде карточек */
.ins-history-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 400px;
    overflow-y: auto;
    padding-right: 5px;
}
.ins-history-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 12px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
    transition: all 0.2s;
}
.ins-history-card:hover {
    background: #fafcff;
    border-color: #cbd5e1;
    box-shadow: 0 4px 8px rgba(0,0,0,0.05);
}
.ins-history-time {
    font-size: 0.75rem;
    color: #64748b;
    margin-bottom: 8px;
    border-bottom: 1px dashed #e2e8f0;
    padding-bottom: 4px;
}
.ins-history-content {
    font-size: 0.9rem;
    line-height: 1.4;
}
.ins-history-content .error {
    color: #ef4444;
    font-size: 0.85rem;
    margin-top: 6px;
}
/* Стили для карточек ИНС анализа */
.ins-card-item {
    background: white;
    border-radius: 20px;
    margin-bottom: 20px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.05);
    border: 1px solid #e2e8f0;
    overflow: hidden;
    max-width:32%
}
.ins-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
}
.ins-card-header h3 {
    margin: 0;
    font-size: 1.1rem;
    color: #1e293b;
}
.ins-card-toggle {
    font-size: 1.2rem;
    color: #64748b;
    transition: transform 0.2s;
}
.ins-card-content {
    padding: 20px;
}
.ins-analysis-section {
    margin-bottom: 20px;
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 12px;
}
.ins-analysis-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}
.ins-analysis-section h4 {
    font-size: 0.9rem;
    color: #475569;
    margin-bottom: 8px;
}
.ins-analysis-detail {
    font-size: 0.9rem;
}
.ins-analysis-detail .error{
    color:red;
}
.ins-stats-panel {
    background: #f5f5f5;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
}
.stats-summary {
    display: flex;
    gap: 20px;
    margin-bottom: 15px;
}
.stat-item {
    font-size: 14px;
}
.stats-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.stats-table th, .stats-table td {
    border: 1px solid #ddd;
    padding: 6px 8px;
    text-align: center;
}
.stats-table td.high {
    color: #26a69a;
    font-weight: bold;
}
.stats-table td.medium {
    color: #ffa726;
}
.stats-table td.low {
    color: #ef5350;
}
.direction.up {
    color: #26a69a;
    font-weight: bold;
}
.direction.down {
    color: #ef5350;
    font-weight: bold;
}
.direction.neutral {
    color: #ffa726;
    font-weight: bold;
}
/* Цвета для советов ATR и Wave Range */
.atr-analysis .compact-table td.good, 
.wave-range .compact-table td.good { 
    color: #22c55e; 
    font-weight: bold; 
}
.atr-analysis .compact-table td.caution, 
.wave-range .compact-table td.caution { 
    color: #f59e0b; 
    font-weight: bold; 
}
.atr-analysis .compact-table td.avoid, 
.wave-range .compact-table td.avoid { 
    color: #ef4444; 
    font-weight: bold; 
}