/* ===== МОДАЛЬНЫЕ ОКНА ===== */

:root {
    --z-index-modal-backdrop: 10000;
    --z-index-modal-content: 10001;
    --z-index-modal-overlay: 10002;
    --z-index-modal-alert: 10003;
    --z-index-modal-tooltip: 10004;
    --z-index-modal-dropdown: 10005;
}

.modal {
    display: none;
    position: fixed;
    z-index: var(--z-index-modal-backdrop);
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(10, 14, 18, 0.6);
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: var(--surface);
    color: var(--text);
    margin: 2% auto;
    padding: 0;
    border: 1px solid var(--border);
    width: 95%;
    max-width: 1200px;
    height: 90%;
    max-height: 800px;
    border-radius: 10px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    font-family: var(--font-primary);
    position: relative;
    z-index: var(--z-index-modal-content);
    overflow: hidden;
}

.modal-header {
    padding: 14px 20px;
    background-color: var(--surface-2);
    border-bottom: 1px solid var(--border);
    border-radius: 10px 10px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.modal-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 16px;
    color: var(--text);
    margin: 0;
}

.modal-body {
    padding: 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-height: 0;
    overflow-y: auto;
}

.modal .close,
.diagnosis-close {
    background: none;
    border: none;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    color: var(--text-faint);
    padding: 4px;
    border-radius: 6px;
    transition: color 0.15s ease, background-color 0.15s ease;
}

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

.loading {
    display: none;
}

#chart {
    width: 100%;
    flex: 1;
    /* #1e1e1e — совпадает с layout.background в chart.js/bond-diag-chart.js
       (LightweightCharts рисует на canvas сам, но пока он не заполнил область
       полностью, виден фон контейнера — если он светлый, верх графика на
       миг/по краям "просвечивает" белым на фоне тёмной гистограммы объёма). */
    background: #1e1e1e;
    border-radius: 8px;
    border: 1px solid var(--border);
    position: relative;
    min-height: 400px;
}

#candle-info-panel {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    font-size: 13px;
    display: none;
    box-shadow: var(--shadow);
}

.candle-info-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

@media (max-width: 700px) {
    .candle-info-grid { grid-template-columns: repeat(2, 1fr); }
}

.candle-info-item {
    display: flex;
    flex-direction: column;
}

.candle-info-label {
    font-size: 11px;
    color: var(--text-faint);
    margin-bottom: 4px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.candle-info-value {
    font-size: 14px;
    color: var(--text);
    font-weight: 600;
    font-family: var(--font-mono), var(--font-mono-fallback);
    font-variant-numeric: tabular-nums;
}

#y-axis-label {
    position: absolute;
    right: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 12px;
    color: var(--text);
    pointer-events: none;
    z-index: 10;
    min-width: 90px;
    text-align: center;
    box-shadow: var(--shadow);
    font-family: var(--font-mono), var(--font-mono-fallback);
    line-height: 1.3;
    display: none;
}

#loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--surface);
    padding: 16px 24px;
    border-radius: 8px;
    color: var(--text);
    font-size: 14px;
    z-index: 100;
    border: 1px solid var(--border);
    display: none;
    box-shadow: var(--shadow);
    font-weight: 500;
}

#debug-info {
    font-size: 12px;
    color: var(--text-faint);
    padding: 8px;
    background: var(--surface-2);
    border-radius: 4px;
    display: none;
}

/* ===== Модалка диагностики бумаги ===== */

.diagnosis-modal {
    display: none;
    position: fixed;
    z-index: var(--z-index-modal-backdrop);
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(10, 14, 18, 0.6);
    align-items: center;
    justify-content: center;
}

.diagnosis-modal-content {
    background-color: var(--surface);
    color: var(--text);
    margin: 2% auto;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 10px;
    width: 95%;
    max-width: 1200px;
    height: 90vh;
    max-height: 95vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow);
    font-family: var(--font-primary);
    overflow: hidden;
}

.diagnosis-modal-header {
    padding: 14px 20px;
    background-color: var(--surface-2);
    border-bottom: 1px solid var(--border);
    border-radius: 10px 10px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.diagnosis-modal-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 16px;
    color: var(--text);
    margin: 0;
}

.diagnosis-modal-body {
    background-color: var(--bg);
    padding: 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-height: 0;
    overflow: hidden;
    position: relative;
    box-sizing: border-box;
}

#diagnosis-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-grow: 1;
    color: var(--text-muted);
    font-size: 14px;
    gap: 10px;
}

#diagnosis-content {
    flex-grow: 1;
    overflow-y: auto;
    max-height: 100%;
    padding: 0;
    margin: 0;
    box-sizing: border-box;
    display: block;
}

#diagnosis-content .diagnosis-page {
    width: 100%;
    height: auto;
    min-height: auto;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    display: block;
}
