/* ============================================================
   reference.css – Единые стили для всех страниц справочника ПКО
   Группировка по компонентам и страницам
   ============================================================ */

/* ============================================================
   1. ОБЩИЕ СТИЛИ (применяются ко всем страницам)
   ============================================================ */
.reference-wrapper {
    max-width: 1200px;
    margin: 0 auto;
    padding: 10px 32px;
    background: var(--surface, #ffffff);
    border-radius: var(--radius, 8px);
    box-shadow: var(--shadow-sm, 0 1px 2px rgba(0, 0, 0, 0.06));
    overflow-y: auto;
    max-height: 95vh;
    /* Ограничение высоты для скролла */
}

/* Общие заголовки */
.reference-wrapper h1 {
    font-family: 'Manrope', sans-serif;
    font-weight: 700;
    font-size: 24px;
    color: var(--ink, #16202b);
    margin-top: 0;
    margin-bottom: 0.5rem;
}

.reference-wrapper h2 {
    font-family: 'Manrope', sans-serif;
    font-weight: 700;
    font-size: 22px;
    color: var(--ink, #16202b);
    border-bottom: 2px solid var(--line, #e3e7ec);
    padding-bottom: 12px;
    margin-top: 28px;
    margin-bottom: 20px;
}

.reference-wrapper h3 {
    font-family: 'Manrope', sans-serif;
    font-weight: 600;
    font-size: 18px;
    color: var(--ink, #16202b);
    margin-top: 24px;
    margin-bottom: 12px;
}

.reference-wrapper h4 {
    font-family: 'Manrope', sans-serif;
    font-weight: 600;
    font-size: 15px;
    color: var(--ink-soft, #5b6774);
    margin-top: 20px;
    margin-bottom: 10px;
}

.reference-wrapper p {
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    line-height: 1.7;
    color: var(--ink, #16202b);
    margin-bottom: 12px;
}

.reference-wrapper ul,
.reference-wrapper ol {
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    line-height: 1.7;
    color: var(--ink, #16202b);
    padding-left: 24px;
    margin-bottom: 16px;
}

.reference-wrapper li {
    margin-bottom: 4px;
}

.reference-wrapper code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    background: var(--bg, #f5f6f8);
    padding: 2px 8px;
    border-radius: 4px;
    color: var(--accent-dark, #1b5bbc);
}

/* Версия */
.reference-wrapper .version {
    font-style: italic;
    text-align: right;
    font-size: 13px;
    color: var(--ink-soft, #5b6774);
    margin-bottom: 20px;
    font-family: 'Inter', sans-serif;
}

/* Оглавление */
.reference-wrapper .toc {
    background: var(--bg, #f5f6f8);
    padding: 18px 24px;
    border-radius: 8px;
    margin-bottom: 24px;
    border: 1px solid var(--line, #e3e7ec);
}

.reference-wrapper .toc h2 {
    border-bottom: none;
    padding-bottom: 0;
    margin-bottom: 12px;
    font-size: 18px;
}

.reference-wrapper .toc ul {
    list-style: none;
    padding-left: 0;
    margin-bottom: 0;
}

.reference-wrapper .toc li {
    margin-bottom: 4px;
}

.reference-wrapper .toc a {
    color: var(--accent, #3b7ddd);
    text-decoration: none;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
}

.reference-wrapper .toc a:hover {
    text-decoration: underline;
}

/* Информационные блоки */
.reference-wrapper .note {
    background: #fffde7;
    padding: 14px 18px;
    border-left: 4px solid #ffd600;
    margin: 16px 0;
    border-radius: 0 8px 8px 0;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
}

.reference-wrapper .warning {
    background: #ffebee;
    padding: 14px 18px;
    border-left: 4px solid #f44336;
    margin: 16px 0;
    border-radius: 0 8px 8px 0;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
}

.reference-wrapper .info-box {
    background: var(--accent-soft, #e6f0ff);
    padding: 14px 18px;
    border-left: 4px solid var(--accent, #3b7ddd);
    margin: 16px 0;
    border-radius: 0 8px 8px 0;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
}

.reference-wrapper .example {
    background: #e8f5e9;
    padding: 16px 20px;
    border-left: 4px solid #4caf50;
    border-radius: 0 8px 8px 0;
    margin: 16px 0;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
}

.reference-wrapper .formula {
    background: var(--bg, #f5f6f8);
    padding: 12px 18px;
    border-radius: 8px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 14px;
    margin: 12px 0;
    border: 1px solid var(--line, #e3e7ec);
}

/* Таблицы */
.reference-wrapper .table-container {
    overflow-x: auto;
    margin: 16px 0 24px 0;
    border: 1px solid var(--line, #e3e7ec);
    border-radius: 8px;
}

.reference-wrapper table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    font-family: 'Inter', sans-serif;
}

.reference-wrapper table th,
.reference-wrapper table td {
    padding: 10px 14px;
    border: 1px solid var(--line, #e3e7ec);
    text-align: left;
    vertical-align: middle;
}

.reference-wrapper table th {
    background: var(--bg, #f5f6f8);
    font-weight: 600;
    color: var(--ink-soft, #5b6774);
    position: sticky;
    top: 0;
    z-index: 5;
}

.reference-wrapper table tr:nth-child(even) {
    background: var(--bg, #f5f6f8);
}

.reference-wrapper table tr:hover {
    background: var(--hover-clr, #f1f5f9);
}

.reference-wrapper .table-caption {
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--ink, #16202b);
}

/* Изображения */
.reference-wrapper .image-container {
    text-align: center;
    margin: 20px 0;
    border: 1px solid var(--line, #e3e7ec);
    padding: 16px;
    background: var(--bg, #f5f6f8);
    border-radius: 8px;
}

.reference-wrapper .image-container img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
}

.reference-wrapper .image-caption {
    font-style: italic;
    margin-top: 8px;
    font-size: 13px;
    color: var(--ink-soft, #5b6774);
    font-family: 'Inter', sans-serif;
}

/* PDF-вьюер */
.reference-wrapper .pdf-viewer {
    width: 100%;
    border: 1px solid var(--line, #e3e7ec);
    border-radius: 8px;
    overflow: hidden;
}

.reference-wrapper .pdf-viewer embed {
    width: 100%;
    height: 85vh;
    border: none;
}

/* Футер */
.reference-wrapper footer {
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid var(--line, #e3e7ec);
    text-align: center;
    font-size: 13px;
    color: var(--ink-faint, #8b96a3);
    font-family: 'Inter', sans-serif;
}

/* Стили для ссылок */
.reference-wrapper a {
    color: var(--accent, #3b7ddd);
    text-decoration: none;
}

.reference-wrapper a:hover {
    text-decoration: underline;
}

/* ============================================================
   2. СТИЛИ ДЛЯ СТРАНИЦЫ "ТРЕБОВАНИЯ К ПРОЕКТНОЙ ДОКУМЕНТАЦИИ"
   (RequirementsProjectDocumentation)
   ============================================================ */
.reference-wrapper .requirements-list {
    margin-bottom: 20px;
}

.reference-wrapper .requirements-list .requirement {
    margin-bottom: 16px;
    padding-left: 4px;
}

.reference-wrapper .requirements-list .requirement p {
    margin-bottom: 6px;
}

.reference-wrapper .requirements-list .sub-requirement {
    margin-left: 20px;
    padding-left: 12px;
    border-left: 2px solid var(--line, #e3e7ec);
}

.reference-wrapper .requirements-list .sub-requirement p {
    font-size: 13px;
    color: var(--ink-soft, #5b6774);
}

/* ============================================================
   3. СТИЛИ ДЛЯ СТРАНИЦЫ "ГРАФИК СОГЛАСОВАНИЯ"
   (ApprovalScheduleDocumentation)
   ============================================================ */

/* Контейнер таблицы с прокруткой */
.reference-wrapper .table-container {
    max-height: 76vh;
    overflow: auto;
    border: 1px solid var(--line, #dee2e6);
    border-radius: 8px;
    background: var(--surface, #ffffff);
}

/* Основная таблица */
.reference-wrapper .approval-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    min-width: 950px;
}

/* ===== ФИКСИРОВАННАЯ ШАПКА ===== */
.reference-wrapper .approval-table thead {
    position: sticky;
    top: 0;
    z-index: 50;
}

.reference-wrapper .approval-table thead th {
    position: sticky;
    top: 0;
    z-index: 51;
    background: var(--bg, #f8f9fa);
    border-bottom: 2px solid var(--line, #dee2e6);
}

/* Первая строка шапки - общий заголовок "Участники согласования" */
.reference-wrapper .approval-table .col-approvers-header {
    background: var(--accent-soft, #e6f0ff);
    text-align: center;
    padding: 10px 4px;
    font-size: 0.95rem;
    font-weight: 700;
    border-bottom: 2px solid var(--accent, #3b7ddd);
    z-index: 52;
}

/* Вторая строка шапки - названия должностей */
.reference-wrapper .approval-table .col-approver {
    background: var(--bg, #f8f9fa);
    font-size: 0.72rem;
    line-height: 1.2;
    padding: 6px 3px;
    text-align: center;
    word-wrap: break-word;
    word-break: break-word;
    white-space: normal;
    min-width: 75px;
    max-width: 95px;
    border-bottom: 2px solid var(--line, #dee2e6);
    z-index: 51;
}

/* Первая строка шапки - остальные заголовки */
.reference-wrapper .approval-table .col-id,
.reference-wrapper .approval-table .col-doc,
.reference-wrapper .approval-table .col-count,
.reference-wrapper .approval-table .col-note {
    background: var(--bg, #f8f9fa);
    padding: 10px 8px;
    border-bottom: 2px solid var(--line, #dee2e6);
    z-index: 51;
}

/* Ширина колонок */
.reference-wrapper .approval-table .col-id {
    width: 45px;
    min-width: 45px;
    max-width: 55px;
    text-align: center;
}

/* Колонка "Перечень документов" - самая широкая */
.reference-wrapper .approval-table .col-doc {
    min-width: 180px;
    max-width: 280px;
    text-align: left;
}

.reference-wrapper .approval-table .col-count {
    width: 55px;
    min-width: 55px;
    max-width: 65px;
    text-align: center;
}

.reference-wrapper .approval-table .col-note {
    min-width: 100px;
    max-width: 160px;
    text-align: left;
    font-size: 0.78rem;
    color: var(--ink-soft, #5b6774);
}

.reference-wrapper .approval-table .col-approver-icon {
    text-align: center;
    font-size: 1.2rem;
    padding: 6px 2px;
    min-width: 55px;
}

/* ===== ОБЩИЕ СТИЛИ ДЛЯ ЯЧЕЕК ===== */
.reference-wrapper .approval-table th,
.reference-wrapper .approval-table td {
    padding: 8px 6px;
    border: 1px solid var(--line, #dee2e6);
    vertical-align: middle;
}

.reference-wrapper .approval-table th {
    background: var(--bg, #f8f9fa);
    font-weight: 600;
    color: var(--ink-soft, #5b6774);
    text-align: center;
}

.reference-wrapper .approval-table th small {
    font-weight: 400;
    font-size: 0.65rem;
    display: block;
    color: var(--ink-soft, #6c757d);
    line-height: 1.3;
}

/* ===== ЗАГОЛОВКИ РАЗДЕЛОВ ===== */
.reference-wrapper .approval-table .section-header {
    background: var(--accent-soft, #e6f0ff);
    font-weight: 700;
}

.reference-wrapper .approval-table .section-header td {
    padding: 12px 8px;
    text-align: center;
    font-size: 0.95rem;
    background: var(--accent-soft, #e6f0ff);
    border-top: 2px solid var(--accent, #3b7ddd);
    border-bottom: 2px solid var(--accent, #3b7ddd);
}

/* ===== БЕЙДЖИ ===== */
.reference-wrapper .approval-table .badge {
    display: inline-block;
    padding: 0.25rem 0.6rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 50rem;
    background: var(--accent, #3b7ddd);
    color: white;
    min-width: 28px;
}

/* ===== ИКОНКИ СОГЛАСОВАНИЯ ===== */
.reference-wrapper .approval-icon {
    font-size: 1.4rem;
    display: inline-block;
    line-height: 1;
    font-weight: 700;
}

.reference-wrapper .icon-required {
    color: #198754;
}

.reference-wrapper .icon-or {
    color: #ffc107;
}

.reference-wrapper .icon-conditional {
    color: #0dcaf0;
}

.reference-wrapper .icon-none {
    color: #adb5bd;
    opacity: 0.5;
}

/* ===== ПОЛОСА ПРОКРУТКИ ===== */
.reference-wrapper .table-container::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

.reference-wrapper .table-container::-webkit-scrollbar-track {
    background: var(--line-soft, #f1f1f1);
    border-radius: 4px;
}

.reference-wrapper .table-container::-webkit-scrollbar-thumb {
    background: var(--ink-faint, #8b96a3);
    border-radius: 4px;
}

.reference-wrapper .table-container::-webkit-scrollbar-thumb:hover {
    background: var(--ink-soft, #5b6774);
}

/* ===== АДАПТИВ ===== */
@media (max-width: 1200px) {
    .reference-wrapper .approval-table {
        font-size: 0.78rem;
        min-width: 780px;
    }

    .reference-wrapper .approval-table .col-approver {
        font-size: 0.68rem;
        min-width: 65px;
        max-width: 80px;
    }

    .reference-wrapper .approval-table .col-doc {
        min-width: 150px;
        max-width: 220px;
    }

    .reference-wrapper .approval-table th[colspan] {
        font-size: 0.82rem;
    }
}

@media (max-width: 992px) {
    .reference-wrapper .approval-table {
        font-size: 0.7rem;
        min-width: 700px;
    }

    .reference-wrapper .approval-table th,
    .reference-wrapper .approval-table td {
        padding: 5px 4px;
    }

    .reference-wrapper .approval-table .col-approver {
        font-size: 0.62rem;
        min-width: 55px;
        max-width: 70px;
    }

    .reference-wrapper .approval-icon {
        font-size: 1.1rem;
    }
}

@media (max-width: 576px) {
    .reference-wrapper .table-container {
        max-height: 60vh;
    }

    .reference-wrapper .approval-table {
        font-size: 0.6rem;
        min-width: 580px;
    }

    .reference-wrapper .approval-table th,
    .reference-wrapper .approval-table td {
        padding: 3px 3px;
    }

    .reference-wrapper .approval-table .col-approver {
        font-size: 0.55rem;
        min-width: 45px;
        max-width: 55px;
        padding: 4px 2px;
    }

    .reference-wrapper .approval-icon {
        font-size: 0.9rem;
    }

    .reference-wrapper .approval-table .col-approvers-header {
        font-size: 0.8rem;
    }
}

/* ============================================================
   4. СТИЛИ ДЛЯ СТРАНИЦЫ "ЛИТЬЕ"
   (castingsDocs)
   ============================================================ */
.reference-wrapper .form-section,
.reference-wrapper .result-section {
    background: var(--surface, #ffffff);
    padding: 20px 24px;
    border-radius: var(--radius, 8px);
    box-shadow: var(--shadow-sm, 0 1px 2px rgba(0, 0, 0, 0.06));
}

.reference-wrapper .form-section .form-group {
    margin-bottom: 1.5rem;
}

.reference-wrapper .form-section label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--ink, #16202b);
}

.reference-wrapper .form-section input,
.reference-wrapper .form-section select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--line, #e3e7ec);
    border-radius: 6px;
    font-size: 14px;
    font-family: 'Inter', sans-serif;
    transition: border-color 0.3s;
}

.reference-wrapper .form-section input:focus,
.reference-wrapper .form-section select:focus {
    border-color: var(--accent, #3b7ddd);
    outline: none;
    box-shadow: 0 0 0 3px var(--accent-soft, #e6f0ff);
}

.reference-wrapper .form-section .inline-group {
    display: flex;
    gap: 10px;
}

.reference-wrapper .form-section .inline-group>div {
    flex: 1;
}

.reference-wrapper .form-section .checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.reference-wrapper .form-section .checkbox-item {
    display: flex;
    align-items: center;
    gap: 10px;
}

.reference-wrapper .form-section .checkbox-item input {
    width: auto;
}

.reference-wrapper .form-section button {
    background: var(--accent, #3b7ddd);
    color: white;
    border: none;
    padding: 12px 24px;
    font-size: 16px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.3s;
    font-weight: 600;
    font-family: 'Manrope', sans-serif;
}

.reference-wrapper .form-section button:hover {
    background: var(--accent-dark, #1b5bbc);
}

.reference-wrapper .requirements-output {
    background: var(--bg, #f5f6f8);
    border-left: 4px solid var(--accent, #3b7ddd);
    padding: 20px;
    white-space: pre-line;
    font-family: 'JetBrains Mono', monospace;
    line-height: 1.8;
    min-height: 200px;
    border-radius: 0 6px 6px 0;
}

.reference-wrapper .property-group {
    display: none;
    background: var(--accent-soft, #e6f0ff);
    padding: 15px;
    border-radius: 6px;
    margin-top: 10px;
    border-left: 3px solid var(--accent, #3b7ddd);
}

.reference-wrapper .property-group.visible {
    display: block;
}

.reference-wrapper .error {
    color: #d32f2f;
    background: #ffebee;
    padding: 15px;
    border-radius: 6px;
    margin-bottom: 20px;
    border-left: 3px solid #d32f2f;
}

/* ============================================================
   5. СТИЛИ ДЛЯ СТРАНИЦЫ "СВАРКА"
   (metalStructuresAndWeldingDoc)
   ============================================================ */
/* ===== КОНТЕЙНЕР ТАБЛИЦЫ ===== */
.reference-wrapper .table-container.welding-table {
    overflow-x: auto;           /* горизонтальная прокрутка при необходимости */
    overflow-y: visible;
    margin: 16px 0 24px 0;
    border: 1px solid var(--line, #e3e7ec);
    border-radius: 8px;
    background: var(--surface, #ffffff);
    max-width: 100%;            /* не выходит за границы */
}

/* ===== ТАБЛИЦА СВАРКИ ===== */
.reference-wrapper .welding-table table {
    width: 100%;
    min-width: 900px;           /* минимальная ширина для читаемости */
    max-width: 100%;
    border-collapse: collapse;
    font-size: 0.75rem;         /* УМЕНЬШЕННЫЙ ШРИФТ */
    font-family: 'Inter', sans-serif;
    table-layout: fixed;        /* фиксированная ширина колонок */
}

/* ===== ВСЕ ЯЧЕЙКИ ТАБЛИЦЫ ===== */
.reference-wrapper .welding-table table th,
.reference-wrapper .welding-table table td {
    padding: 6px 8px;
    border: 1px solid var(--line, #e3e7ec);
    vertical-align: middle;
    text-align: center;
    word-wrap: break-word;
    word-break: break-word;
    white-space: normal;        /* РАЗРЕШАЕМ ПЕРЕНОС ТЕКСТА */
    line-height: 1.3;
}

/* ===== ШАПКА ТАБЛИЦЫ ===== */
.reference-wrapper .welding-table table th {
    background: var(--bg, #f5f6f8);
    font-weight: 600;
    color: var(--ink-soft, #5b6774);
    font-size: 0.7rem;          /* УМЕНЬШЕННЫЙ ШРИФТ В ШАПКЕ */
    padding: 6px 4px;
    white-space: normal;        /* ПЕРЕНОС ТЕКСТА В ШАПКЕ */
    word-wrap: break-word;
    word-break: break-word;
}

/* ===== ШИРИНА КОЛОНОК ===== */
.reference-wrapper .welding-table table th:nth-child(1),
.reference-wrapper .welding-table table td:nth-child(1) {
    width: 10%;                 /* Тип соединения */
    min-width: 80px;
}

.reference-wrapper .welding-table table th:nth-child(2),
.reference-wrapper .welding-table table td:nth-child(2) {
    width: 15%;                 /* Форма подготовленных кромок */
    min-width: 100px;
}

.reference-wrapper .welding-table table th:nth-child(3),
.reference-wrapper .welding-table table td:nth-child(3) {
    width: 15%;                 /* Форма выполненного шва */
    min-width: 100px;
}

.reference-wrapper .welding-table table th:nth-child(4),
.reference-wrapper .welding-table table td:nth-child(4) {
    width: 12%;                 /* ИН */
    min-width: 60px;
}

.reference-wrapper .welding-table table th:nth-child(5),
.reference-wrapper .welding-table table td:nth-child(5) {
    width: 12%;                 /* ИНп */
    min-width: 60px;
}

.reference-wrapper .welding-table table th:nth-child(6),
.reference-wrapper .welding-table table td:nth-child(6) {
    width: 12%;                 /* ИП */
    min-width: 60px;
}

.reference-wrapper .welding-table table th:nth-child(7),
.reference-wrapper .welding-table table td:nth-child(7) {
    width: 12%;                 /* УП */
    min-width: 60px;
}

.reference-wrapper .welding-table table th:nth-child(8),
.reference-wrapper .welding-table table td:nth-child(8) {
    width: 12%;                 /* Условное обозначение */
    min-width: 60px;
}

/* ===== ИЗОБРАЖЕНИЯ В ТАБЛИЦЕ ===== */
.reference-wrapper .welding-table .figure-cell {
    text-align: center;
    background: var(--bg, #f5f6f8);
    padding: 4px 2px;
}

.reference-wrapper .welding-table .figure-cell img {
    width: 100%;                /* изображение подстраивается под ширину колонки */
    max-width: 120px;           /* максимальный размер */
    height: auto;
    display: block;
    margin: 0 auto;
    border-radius: 4px;
    background: var(--surface, #ffffff);
}

/* ===== ЗАГОЛОВКИ РАЗДЕЛОВ В ТАБЛИЦЕ (Стыковое, Угловое и т.д.) ===== */
.reference-wrapper .welding-table table tr td[rowspan] {
    font-weight: 700;
    background: var(--accent-soft, #e6f0ff);
    font-size: 0.8rem;
    padding: 8px 4px;
    min-width: 60px;
}

/* ===== ПРИМЕЧАНИЕ ПОД ТАБЛИЦЕЙ ===== */
.reference-wrapper .footnote {
    font-size: 0.8rem;
    color: var(--ink-soft, #5b6774);
    margin-top: 8px;
    font-style: italic;
    padding: 8px 12px;
    background: var(--bg, #f5f6f8);
    border-radius: 4px;
}

/* ===== АДАПТИВ ===== */

/* Для экранов до 1200px */
@media (max-width: 1200px) {
    .reference-wrapper .welding-table table {
        font-size: 0.65rem;
        min-width: 750px;
    }
    .reference-wrapper .welding-table table th {
        font-size: 0.6rem;
    }
    .reference-wrapper .welding-table .figure-cell img {
        max-width: 80px;
    }
}

/* Для экранов до 992px */
@media (max-width: 992px) {
    .reference-wrapper .welding-table table {
        font-size: 0.6rem;
        min-width: 650px;
    }
    .reference-wrapper .welding-table table th {
        font-size: 0.55rem;
        padding: 4px 3px;
    }
    .reference-wrapper .welding-table table td {
        padding: 4px 3px;
    }
    .reference-wrapper .welding-table .figure-cell img {
        max-width: 60px;
    }
}

/* Для экранов до 768px */
@media (max-width: 768px) {
    .reference-wrapper .welding-table table {
        font-size: 0.55rem;
        min-width: 550px;
    }
    .reference-wrapper .welding-table table th {
        font-size: 0.5rem;
    }
    .reference-wrapper .welding-table .figure-cell img {
        max-width: 50px;
    }
}

/* Для экранов до 576px (мобильные) */
@media (max-width: 576px) {
    .reference-wrapper .welding-table table {
        font-size: 0.5rem;
        min-width: 480px;
    }
    .reference-wrapper .welding-table table th {
        font-size: 0.45rem;
        padding: 3px 2px;
    }
    .reference-wrapper .welding-table table td {
        padding: 3px 2px;
    }
    .reference-wrapper .welding-table .figure-cell img {
        max-width: 40px;
    }
}

/* ============================================================
   6. СТИЛИ ДЛЯ СТРАНИЦЫ "ОФОРМЛЕНИЕ ЗАДАЧ"
   (CompletingTasksDocumentation)
   ============================================================ */
/* Используются общие стили из раздела 1 */

/* ============================================================
   7. СТИЛИ ДЛЯ СТРАНИЦЫ "ВЫБОР МОТОР-РЕДУКТОРОВ"
   (SelectionGearMotorsDocumentation)
   ============================================================ */
.reference-wrapper .code-breakdown {
    background: var(--bg, #f5f6f8);
    padding: 16px 20px;
    border-radius: 8px;
    border: 1px solid var(--line, #e3e7ec);
    margin: 20px 0;
}

.reference-wrapper .code-part {
    display: flex;
    margin-bottom: 6px;
    align-items: center;
    flex-wrap: wrap;
}

.reference-wrapper .code-label {
    font-weight: 700;
    min-width: 100px;
    font-family: 'JetBrains Mono', monospace;
    color: var(--accent, #3b7ddd);
}

.reference-wrapper .code-value {
    flex: 1;
    padding: 4px 10px;
    background: var(--surface, #ffffff);
    border-radius: 4px;
    border: 1px solid var(--line, #e3e7ec);
    font-family: 'Inter', sans-serif;
    font-size: 13px;
}

.reference-wrapper .code-explanation {
    font-style: italic;
    color: var(--ink-soft, #5b6774);
    margin-top: 2px;
    padding-left: 115px;
    font-size: 13px;
}

.reference-wrapper .contact-table {
    font-size: 0.85rem;
}

.reference-wrapper .contact-table th {
    background: var(--accent-soft, #e6f0ff);
}

/* ============================================================
   8. СТИЛИ ДЛЯ СТРАНИЦЫ "ОБОЗНАЧЕНИЕ МАТЕРИАЛА БЧ"
   (DesignationBchDocumentation)
   ============================================================ */

/* Полноэкранный режим для PDF - убираем все отступы */
.reference-wrapper.pdf-fullscreen {
    padding: 0 !important;
    margin: 0 !important;
    max-width: 100% !important;
    height: calc(100vh - 64px) !important;
    max-height: calc(100vh - 64px) !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    background: var(--surface, #ffffff);
    overflow: hidden !important;
}

.reference-wrapper.pdf-fullscreen .pdf-viewer {
    height: 100% !important;
    max-height: 100% !important;
    min-height: auto !important;
    border: none !important;
    border-radius: 0 !important;
}

.reference-wrapper.pdf-fullscreen .pdf-viewer p {
    display: none;
    /* скрываем текст "Документ доступен..." */
}

.reference-wrapper.pdf-fullscreen .pdf-viewer embed {
    height: 100% !important;
    min-height: auto !important;
}

/*============================================================*/

/* PDF-вьюер - занимает всё доступное пространство */
.reference-wrapper .pdf-viewer {
    /* ЗАНИМАЕМ ВСЁ ДОСТУПНОЕ ПРОСТРАНСТВО */
    height: calc(100vh - 180px);
    /* 180px = topbar(64px) + версия(30px) + отступы(86px) */
    min-height: 800px;
    /* минимальная высота, чтобы было удобно читать */
    max-height: calc(100vh - 180px);

    width: 100%;
    /* занимает всю ширину */
    max-width: 100%;

    border: 1px solid var(--line, #e3e7ec);
    border-radius: 8px;
    overflow: hidden;
    background: var(--surface, #ffffff);

    display: flex;
    flex-direction: column;
}

/* Контейнер для embed - растягивается на всю высоту */
.reference-wrapper .pdf-viewer embed {
    width: 100%;
    height: 100%;
    /* занимает 100% высоты родителя */
    min-height: 550px;
    /* минимальная высота для embed */
    border: none;
    flex: 1;
    /* растягивается на всё доступное место */
}

/* Ссылка на скачивание - компактная */
.reference-wrapper .pdf-viewer p {
    flex-shrink: 0;
    /* не сжимается */
    margin-bottom: 12px;
    padding: 8px 0;
    font-size: 14px;
    color: var(--ink-soft, #5b6774);
}

/* Стили для сообщения об ошибке */
.reference-wrapper .alert-warning {
    background: #fff3cd;
    padding: 16px 20px;
    border-radius: 8px;
    border: 1px solid #ffc107;
    color: #856404;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
}

/* ===== АДАПТИВ ДЛЯ PDF ===== */

/* Для экранов до 1200px (ноутбуки) */
@media (max-width: 1200px) {
    .reference-wrapper .pdf-viewer {
        height: calc(100vh - 160px);
        min-height: 500px;
        max-height: calc(100vh - 160px);
    }

    .reference-wrapper .pdf-viewer embed {
        min-height: 450px;
    }
}

/* Для экранов до 992px (планшеты) */
@media (max-width: 992px) {
    .reference-wrapper .pdf-viewer {
        height: calc(100vh - 140px);
        min-height: 400px;
        max-height: calc(100vh - 140px);
    }

    .reference-wrapper .pdf-viewer embed {
        min-height: 350px;
    }
}

/* Для экранов до 576px (мобильные) */
@media (max-width: 576px) {
    .reference-wrapper .pdf-viewer {
        height: calc(100vh - 120px);
        min-height: 300px;
        max-height: calc(100vh - 120px);
    }

    .reference-wrapper .pdf-viewer embed {
        min-height: 250px;
    }

    .reference-wrapper .pdf-viewer p {
        font-size: 12px;
    }
}

/* ============================================================
   9. АДАПТИВНОСТЬ
   ============================================================ */
@media (max-width: 768px) {
    .reference-wrapper {
        padding: 16px;
    }

    .reference-wrapper h1 {
        font-size: 20px;
    }

    .reference-wrapper h2 {
        font-size: 18px;
    }

    .reference-wrapper .code-explanation {
        padding-left: 0;
    }

    .reference-wrapper .code-label {
        min-width: 80px;
    }

    .reference-wrapper .form-section .inline-group {
        flex-direction: column;
    }
}

@media (max-width: 576px) {
    .reference-wrapper {
        padding: 12px;
    }

    .reference-wrapper table {
        font-size: 12px;
    }

    .reference-wrapper table th,
    .reference-wrapper table td {
        padding: 6px 10px;
    }

    .reference-wrapper .approval-table th,
    .reference-wrapper .approval-table td {
        padding: 4px 6px;
    }
}