/* ==========================================================================
   ПЕРЕМЕННЫЕ ТЕМ ОФОРМЛЕНИЯ (ТЁМНАЯ ПО УМОЛЧАНИЮ / СВЕТЛАЯ)
   ========================================================================== */
:root,
[data-theme="dark"] {
    --bg-app: #121418;
    --bg-panel: #1b1f26;
    --bg-card: #1e222b;
    --bg-block: #161920;
    --bg-input: #252a34;
    --bg-input-readonly: #181b22;
    --border-color: #2e3440;
    --border-focus: #3b82f6;
    --text-main: #e5e9f0;
    --text-muted: #94a3b8;
    --accent-primary: #3b82f6;
    --accent-hover: #2563eb;
    --accent-secondary: #2d333f;
    --accent-secondary-hover: #3b4252;
    --recalc-bg: #2a3441;
    --recalc-hover: #0ea5e9;
    --shadow-card: 0 4px 12px rgba(0, 0, 0, 0.35);
}

[data-theme="light"] {
    --bg-app: #f1f5f9;
    --bg-panel: #ffffff;
    --bg-card: #ffffff;
    --bg-block: #f8fafc;
    --bg-input: #ffffff;
    --bg-input-readonly: #e2e8f0;
    --border-color: #cbd5e1;
    --border-focus: #2563eb;
    --text-main: #0f172a;
    --text-muted: #475569;
    --accent-primary: #2563eb;
    --accent-hover: #1d4ed8;
    --accent-secondary: #e2e8f0;
    --accent-secondary-hover: #cbd5e1;
    --recalc-bg: #dbeafe;
    --recalc-hover: #2563eb;
    --shadow-card: 0 2px 8px rgba(15, 23, 42, 0.08);
}

/* ==========================================================================
   БАЗОВЫЙ СБРОС И ОБЩИЕ СТИЛИ
   ========================================================================== */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: var(--bg-app);
    color: var(--text-main);
    font-size: 13px;
    line-height: 1.4;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ==========================================================================
   ПЕРВАЯ СТРОКА: ВЕРХНЯЯ ПАНЕЛЬ УПРАВЛЕНИЯ
   ========================================================================== */
.main-header-panel {
    background-color: var(--bg-panel);
    border-bottom: 1px solid var(--border-color);
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo-area h1 {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.3px;
    white-space: nowrap;
}

.logo-area h1 span {
    color: var(--accent-primary);
}

.control-toolbar {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    flex-wrap: wrap;
    flex: 1;
    justify-content: flex-end;
}

.toolbar-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.toolbar-item--compact {
    min-width: 75px;
}

.toolbar-item label {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 500;
}

/* Элементы форм в шапке */
.select-main,
.input-small {
    height: 32px;
    background-color: var(--bg-input);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    border-radius: 5px;
    padding: 0 8px;
    font-size: 12px;
    outline: none;
    transition: border-color 0.15s;
}

.select-main {
    min-width: 190px;
    max-width: 260px;
}

.input-small {
    width: 72px;
    text-align: center;
}

.select-main:focus,
.input-small:focus {
    border-color: var(--border-focus);
}

.input-small:disabled {
    background-color: var(--bg-input-readonly);
    color: var(--text-muted);
    cursor: not-allowed;
}

/* Кнопки */
button {
    height: 32px;
    padding: 0 12px;
    border-radius: 5px;
    border: 1px solid transparent;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}
.btn-secondary, a{
    height: 32px;
    padding: 0 12px;
    border-radius: 5px;
    border: 1px solid transparent;
    font-size: 12px;
    font-weight: 600;
	text-decoration: none;
	color: var(--text-main);
    cursor: pointer;
    white-space: nowrap;
    transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}
.btn-accent {
    background-color: var(--accent-primary);
    color: #ffffff;
}

.btn-accent:hover {
    background-color: var(--accent-hover);
}

.btn-secondary,
.btn-icon {
    background-color: var(--accent-secondary);
    color: var(--text-main);
    border-color: var(--border-color);
}

.btn-secondary:hover,
.btn-icon:hover {
    background-color: var(--accent-secondary-hover);
}

/* ==========================================================================
   ВТОРАЯ СТРОКА: СЕТКА ИЗ 5 ПЛАШЕК ОФОРМЛЕНИЙ
   ========================================================================== */
.enclosures-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(260px, 1fr));
    gap: 12px;
    padding: 12px 16px;
    flex: 1;
    align-items: start;
}

@media (max-width: 1400px) {
    .enclosures-grid {
        grid-template-columns: repeat(3, minmax(260px, 1fr));
    }
}

@media (max-width: 900px) {
    .enclosures-grid {
        grid-template-columns: repeat(2, minmax(250px, 1fr));
    }
}

@media (max-width: 600px) {
    .enclosures-grid {
        grid-template-columns: 1fr;
    }
}

/* Карточка одного оформления */
.enclosure-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: var(--shadow-card);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.card-header {
    padding: 10px 12px;
    background-color: var(--bg-block);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.card-header h2 {
    font-size: 13px;
    font-weight: 700;
}

.qtc-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    background-color: var(--accent-secondary);
    color: var(--text-main);
}

/* 5 внутренних блоков в столбик */
.card-block {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-color);
}

.card-block:last-child {
    border-bottom: none;
}

/* Блоки 1, 2, 3: Чертёж и графики АЧХ */
.block-svg {
    height: 170px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--bg-block);
}

.block-svg svg {
    width: 100%;
    height: 100%;
    display: block;
}

.block-chart {
    height: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--bg-block);
}

.block-chart canvas,
.block-chart svg {
    width: 100%;
    height: 100%;
    display: block;
}

.placeholder-box {
    width: 100%;
    height: 100%;
    border: 1px dashed var(--border-color);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 11px;
    text-align: center;
    padding: 8px;
}

/* Блок 4: Параметры коррекции корпуса */
.block-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.control-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.control-row label {
    font-size: 11px;
    color: var(--text-muted);
}

.select-small {
    width: 100%;
    height: 30px;
    background-color: var(--bg-input);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0 6px;
    font-size: 12px;
    outline: none;
}

.select-small:focus {
    border-color: var(--border-focus);
}

/* Строка размеров: Высота / Ширина / Глубина (пассивное) */
.dimensions-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
}

.dim-field {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.dim-field label {
    font-size: 11px;
    color: var(--text-muted);
    text-align: center;
}

.input-dim {
    width: 100%;
    height: 28px;
    background-color: var(--bg-input);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    text-align: center;
    font-size: 12px;
    padding: 0 4px;
    outline: none;
}

.input-dim:focus {
    border-color: var(--border-focus);
}

.input-dim[readonly] {
    background-color: var(--bg-input-readonly);
    color: var(--text-muted);
    cursor: default;
}

/* Строка целевого объёма */
.volume-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding-top: 2px;
}

.volume-row label {
    font-size: 12px;
    color: var(--text-muted);
}

.volume-input-wrap {
    display: flex;
    align-items: center;
    gap: 4px;
}

.input-readonly {
    width: 72px;
    height: 28px;
    background-color: var(--bg-input-readonly);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    text-align: right;
    padding: 0 6px;
    font-weight: 600;
    font-size: 12px;
}

.unit-label {
    font-size: 12px;
    color: var(--text-muted);
}

/* Кнопка локального пересчёта одной плашки */
.btn-recalc {
    width: 100%;
    height: 30px;
    background-color: var(--recalc-bg);
    color: var(--text-main);
    border: 1px solid var(--border-color);
}

.btn-recalc:hover {
    background-color: var(--recalc-hover);
    border-color: var(--recalc-hover);
    color: #ffffff;
}

/* Блок 5: Ссылка-переход на детальный расчёт */
.block-footer {
    background-color: var(--bg-block);
    padding: 8px 12px;
}

.btn-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 32px;
    background-color: transparent;
    border: 1px solid var(--accent-primary);
    color: var(--accent-primary);
    border-radius: 5px;
    text-decoration: none;
    font-weight: 600;
    font-size: 12px;
    transition: background-color 0.15s, color 0.15s;
}

.btn-link:hover {
    background-color: var(--accent-primary);
    color: #ffffff;
}

/* ==========================================================================
   МОДАЛЬНЫЕ ОКНА
   ========================================================================== */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.65);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 16px;
}

.modal-backdrop[hidden] {
    display: none;
}

.modal-window {
    background-color: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    width: 100%;
    max-width: 640px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: var(--shadow-card);
}

.modal-window--wide {
    max-width: 960px;
}

.modal-header,
.modal-footer {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 {
    font-size: 14px;
    font-weight: 700;
}

.modal-footer {
    border-bottom: none;
    border-top: 1px solid var(--border-color);
    justify-content: flex-end;
    gap: 8px;
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    line-height: 1;
    padding: 0 6px;
}

.modal-close:hover {
    color: var(--text-main);
}

.modal-body {
    padding: 16px;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 10px;
}

/* ==========================================================================
   СЛАЙДЕР СХЕМ И ГРАФИКОВ (90% ЭКРАНА)
   ========================================================================== */
.modal-window--slider {
    width: 90vw;
    height: 90vh;
    max-width: 90vw;
    max-height: 90vh;
}

.slider-counter {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    background-color: var(--bg-block);
    padding: 3px 10px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.slider-stage {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--bg-block);
    overflow: hidden;
    padding: 12px 54px;
}

.slider-viewport {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.slider-viewport img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 6px;
    background-color: #ffffff;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}

.slider-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 38px;
    height: 54px;
    padding: 0;
    font-size: 18px;
    background-color: var(--accent-secondary);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    opacity: 0.85;
}

.slider-nav:hover {
    background-color: var(--accent-primary);
    border-color: var(--accent-primary);
    color: #ffffff;
    opacity: 1;
}

.slider-nav--prev {
    left: 10px;
}

.slider-nav--next {
    right: 10px;
}

.slider-thumbs {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 10px 16px;
    background-color: var(--bg-panel);
    border-top: 1px solid var(--border-color);
    overflow-x: auto;
}

.slider-thumb-btn {
    height: 44px;
    padding: 3px 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    background-color: var(--bg-block);
    border: 1px solid var(--border-color);
    border-radius: 5px;
    color: var(--text-muted);
    font-size: 11px;
}

.slider-thumb-btn.active {
    border-color: var(--accent-primary);
    color: var(--text-main);
    background-color: var(--accent-secondary);
}

.slider-thumb-btn img {
    height: 34px;
    width: 46px;
    object-fit: contain;
    background-color: #ffffff;
    border-radius: 3px;
}
.modal-window--compact {
    max-width: 420px;
}

.modal-body--single {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
/* ==========================================================================
   БЛОК КРАТКОГО РЕЗЮМЕ В КАРТОЧКЕ ОФОРМЛЕНИЯ
   ========================================================================== */
.block-summary {
    background-color: var(--bg-block);
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-height: 76px;
}

.summary-status {
    display: inline-block;
    align-self: flex-start;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    padding: 2px 6px;
    border-radius: 4px;
}

.status-good {
    background-color: rgba(16, 185, 129, 0.18);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.35);
}

.status-warn {
    background-color: rgba(245, 158, 11, 0.18);
    color: #f59e0b;
    border: 1px solid rgba(245, 158, 11, 0.35);
}

.status-bad {
    background-color: rgba(239, 68, 68, 0.18);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.35);
}

.status-neutral {
    background-color: var(--accent-secondary);
    color: var(--text-muted);
}

.summary-text {
    font-size: 11px;
    line-height: 1.35;
    color: var(--text-main);
}
/* ==========================================================================
   ОДНОСТРОЧНЫЙ ВЫВОД ДВУХ КАМЕР V1 И V2 В ПЛАШКЕ БАНДПАССА
   ========================================================================== */
.volume-row--dual {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    width: 100%;
}

.volume-row--dual .vol-sub-field {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 4px;
    flex: 1 1 0;
    min-width: 0;
}

.volume-row--dual .vol-sub-field label {
    margin: 0;
    flex: 0 0 auto;
    white-space: nowrap;
}

.volume-row--dual .volume-input-wrap {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 2px;
    flex: 1 1 auto;
    min-width: 0;
}

.volume-row--dual .input-readonly {
    width: 100%;
    min-width: 0;
    padding: 0 4px;
    text-align: right;
}
/* ==========================================================================
   КНОПКА ИНФОРМАЦИИ "i" В МОНИТОРАХ И ВСПЛЫВАЮЩАЯ ПОДСКАЗКА
   ========================================================================== */
.monitor-item {
    position: relative;
}

.mon-info-btn {
    position: absolute;
    top: 3px;
    right: 3px;
    width: 13px;
    height: 13px;
    padding: 0;
    border-radius: 50%;
    border: 1px solid rgba(148, 163, 184, 0.45);
    background: rgba(15, 23, 42, 0.55);
    color: #94a3b8;
    font-size: 9px;
    font-weight: 700;
    font-style: italic;
    font-family: Georgia, serif;
    line-height: 11px;
    text-align: center;
    cursor: pointer;
    opacity: 0.75;
    transition: opacity 0.15s, border-color 0.15s, color 0.15s;
}

.mon-info-btn:hover {
    opacity: 1;
    color: #38bdf8;
    border-color: #38bdf8;
}

[data-theme="light"] .mon-info-btn {
    background: rgba(241, 245, 249, 0.9);
    color: #475569;
    border-color: #94a3b8;
}

/* Всплывающее окно расшифровки монитора */
.mon-popover {
    position: fixed;
    z-index: 9999;
    width: 260px;
    padding: 10px 12px;
    border-radius: 8px;
    background: #1e293b;
    border: 1px solid #475569;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.45);
    color: #f1f5f9;
    font-size: 11.5px;
    line-height: 1.4;
}

[data-theme="light"] .mon-popover {
    background: #ffffff;
    border-color: #cbd5e1;
    color: #0f172a;
    box-shadow: 0 10px 25px rgba(15, 23, 42, 0.18);
}

.mon-popover-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
    padding-bottom: 4px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.25);
    font-weight: 700;
    font-size: 12px;
}

.mon-popover-close {
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 15px;
    cursor: pointer;
    line-height: 1;
    padding: 0 2px;
}

.mon-popover-badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10.5px;
    font-weight: 600;
    margin-bottom: 6px;
}

.mon-popover-badge.is-ok {
    background: rgba(16, 185, 129, 0.18);
    color: #34d399;
}

.mon-popover-badge.is-warn {
    background: rgba(245, 158, 11, 0.18);
    color: #fbbf24;
}

.mon-popover-badge.is-danger {
    background: rgba(239, 68, 68, 0.18);
    color: #f87171;
}

.mon-popover-badge.is-neutral {
    background: rgba(148, 163, 184, 0.18);
    color: #94a3b8;
}

.mon-popover-section {
    margin-top: 5px;
}

.mon-popover-section strong {
    color: #38bdf8;
    font-weight: 600;
}

[data-theme="light"] .mon-popover-section strong {
    color: #2563eb;
}
/* ==========================================================================
   ЦВЕТОВАЯ ИНДИКАЦИЯ СТАТУСОВ МОНИТОРОВ (НОРМА / ВНИМАНИЕ / РИСК)
   ========================================================================== */
.monitor-item.status-ok,
.monitor-item.status-good {
    border-color: rgba(16, 185, 129, 0.55);
    background: rgba(16, 185, 129, 0.12);
}
.monitor-item.status-ok .mon-value,
.monitor-item.status-good .mon-value {
    color: #34d399;
}

.monitor-item.status-warn {
    border-color: rgba(245, 158, 11, 0.55);
    background: rgba(245, 158, 11, 0.12);
}
.monitor-item.status-warn .mon-value {
    color: #fbbf24;
}

.monitor-item.status-danger,
.monitor-item.status-bad {
    border-color: rgba(239, 68, 68, 0.60);
    background: rgba(239, 68, 68, 0.14);
}
.monitor-item.status-danger .mon-value,
.monitor-item.status-bad .mon-value {
    color: #f87171;
}

/* Адаптация контраста для светлой темы */
[data-theme="light"] .monitor-item.status-ok .mon-value,
[data-theme="light"] .monitor-item.status-good .mon-value {
    color: #059669;
}

[data-theme="light"] .monitor-item.status-warn .mon-value {
    color: #d97706;
}

[data-theme="light"] .monitor-item.status-danger .mon-value,
[data-theme="light"] .monitor-item.status-bad .mon-value {
    color: #dc2626;
}
/* ==========================================================================
   ПРИНУДИТЕЛЬНАЯ СЕТКА НА 6 КОЛОНОК В ОДИН РЯД (ЗЯ, ФИ, ПИ, БП-4, ЧВР, ОЯ)
   ========================================================================== */
.enclosures-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 8px;
    width: 100%;
    align-items: stretch;
}

.enclosure-card {
    min-width: 0;
    width: 100%;
}
/* ==========================================================================
   ПРИЖАТИЕ БЛОКА КНОПОК ("Пересчитать" И "Выбрать конструкцию") К НИЗУ ПЛАШКИ
   ========================================================================== */
.enclosure-card {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.card-actions-bottom {
    margin-top: auto;
    padding-top: 8px;
}
/* Кнопки */
.btn-back {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 26px;
    padding: 0 10px;
    border-radius: 5px;
    font-size: 11.5px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    border: 1px solid transparent;
    transition: background-color 0.15s, border-color 0.15s, opacity 0.15s;
}

.btn-back {
    background-color: var(--btn-sec-bg);
    color: var(--text-main);
    border-color: var(--border-color);
}

.btn-back:hover {
    background-color: var(--btn-sec-hover);
}