/* ===== Reset & Base ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    background: #f5f5f5;
    color: #333333;
    line-height: 1.5;
}

/* Скрытый текст для screen readers */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
}

/* ===== Фокус (accessibility) ===== */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid #2c3e50;
    outline-offset: 2px;
    border-radius: 2px;
}

/* ===== Контейнер ===== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
}

/* ===== Шапка ===== */
.header {
    background: #ffffff;
    border-bottom: 1px solid #e0e0e0;
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

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

.logo {
    font-size: 1.35rem;
    font-weight: 600;
    text-decoration: none;
    color: #2c3e50;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.logo span {
    background: #e8e8e8;
    padding: 0.2rem 0.6rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 400;
    color: #666;
}

.nav-links {
    display: flex;
    gap: 1.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.nav-links a {
    color: #555;
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.2s;
}

.nav-links a:hover {
    color: #2c3e50;
}

.nav-links a.active {
    color: #2c3e50;
    font-weight: 600;
}

/* ===== Кнопки авторизации ===== */
.btn-logout {
    background: #c62828 !important;
    color: white !important;
    padding: 0.4rem 1rem !important;
    border-radius: 6px !important;
    text-decoration: none !important;
    font-size: 0.9rem !important;
    font-weight: 500 !important;
    display: inline-block !important;
    border: none !important;
}

.btn-logout:hover {
    background: #b71c1c !important;
    color: white !important;
}

.btn-login {
    background: #2c3e50 !important;
    color: white !important;
    padding: 0.4rem 1rem !important;
    border-radius: 6px !important;
    text-decoration: none !important;
    font-size: 0.9rem !important;
    font-weight: 500 !important;
    display: inline-block !important;
    border: none !important;
}

.btn-login:hover {
    background: #1a2a3a !important;
    color: white !important;
}

/* ===== Поисковая секция ===== */
.search-section {
    background: #ffffff;
    border-bottom: 1px solid #e0e0e0;
    padding: 2rem 0;
}

.search-container {
    max-width: 700px;
    margin: 0 auto;
    text-align: center;
}

.search-tagline {
    font-size: 1.75rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #2c3e50;
}

.search-subtitle {
    color: #888;
    margin-bottom: 1.5rem;
    font-size: 0.95rem;
}

.search-box {
    display: flex;
    gap: 0.5rem;
    background: #fafafa;
    border: 1px solid #ddd;
    border-radius: 12px;
    padding: 0.25rem;
    transition: all 0.2s;
}

.search-box:focus-within {
    border-color: #aaa;
    box-shadow: 0 0 0 3px rgba(0,0,0,0.05);
}

.search-box input {
    flex: 1;
    padding: 0.85rem 1.25rem;
    border: none;
    border-radius: 10px;
    font-size: 0.95rem;
    outline: none;
    background: transparent;
}

.search-box button {
    background: #2c3e50;
    border: none;
    padding: 0 1.75rem;
    border-radius: 10px;
    color: white;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.search-box button:hover {
    background: #1a2a3a;
}

/* ===== Основной контент ===== */
.main-content {
    padding: 1.5rem 0 3rem;
    min-height: calc(100vh - 320px);
}

/* ===== Хлебные крошки ===== */
.breadcrumbs {
    margin-bottom: 1.5rem;
    font-size: 0.8rem;
    color: #aaa;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem;
}

.breadcrumbs a {
    color: #999;
    text-decoration: none;
}

.breadcrumbs a:hover {
    color: #555;
    text-decoration: underline;
}

.breadcrumbs span {
    color: #ccc;
}

/* ===== Кнопки ===== */
.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    text-decoration: none;
    font-size: 0.85rem;
    border: 1px solid #ddd;
    background: white;
    color: #333;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: #2c3e50;
    border-color: #2c3e50;
    color: white;
}

.btn-primary:hover {
    background: #1a2a3a;
    color: white;
}

.btn-danger {
    color: #c62828;
    border-color: #c62828;
    background: white;
}

.btn-danger:hover {
    background: #c62828;
    color: white;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.action-buttons {
    display: flex;
    gap: 0.75rem;
    margin: 1rem 0;
    flex-wrap: wrap;
}

/* ===== Статистика ===== */
.stats {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 2rem;
    justify-content: center;
    flex-wrap: wrap;
}

.stat-card {
    background: #ffffff;
    border-radius: 12px;
    padding: 1.25rem 2rem;
    text-align: center;
    border: 1px solid #e8e8e8;
    transition: all 0.2s;
    flex: 1;
    min-width: 120px;
}

.stat-card:hover {
    border-color: #ccc;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.stat-card h2 {
    font-size: 1.75rem;
    font-weight: 600;
    color: #2c3e50;
}

.stat-card p {
    color: #888;
    font-size: 0.85rem;
    margin-top: 0.25rem;
}

/* ===== Секции ===== */
.section-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1.25rem;
    color: #2c3e50;
}

/* ===== Сетка карточек ===== */
.docs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2rem;
}

/* ===== Карточка ===== */
.doc-card {
    background: #ffffff;
    border-radius: 12px;
    padding: 1.25rem;
    border: 1px solid #e8e8e8;
    transition: all 0.25s ease;
    cursor: default;
    display: flex;
    flex-direction: column;
}

.doc-card:hover {
    border-color: #c0c0c0;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    transform: translateY(-2px);
}

.doc-icon {
    font-size: 1.75rem;
    margin-bottom: 0.75rem;
    flex-shrink: 0;
}

.doc-card h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #2c3e50;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.doc-card p {
    color: #777;
    margin-bottom: 0.75rem;
    font-size: 0.85rem;
    line-height: 1.45;
    flex: 1;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.doc-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.7rem;
    color: #aaa;
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid #f0f0f0;
    flex-wrap: wrap;
}

.action-links {
    display: flex;
    gap: 1rem;
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid #f0f0f0;
    flex-wrap: wrap;
    align-items: center;
}

.action-links a {
    font-size: 0.8rem;
    text-decoration: none;
    color: #2c3e50;
    white-space: nowrap;
}

.action-links a:hover {
    text-decoration: underline;
}

/* ===== Боковая панель ===== */
.content-grid {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 2rem;
}

.sidebar {
    background: #ffffff;
    border-radius: 12px;
    padding: 1.25rem;
    border: 1px solid #e8e8e8;
    position: sticky;
    top: 100px;
    height: fit-content;
    align-self: start;
}

.sidebar h3 {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #999;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #f0f0f0;
}

/* ===== Дерево категорий ===== */
.category-tree {
    list-style: none;
}

.category-tree li {
    margin: 0.2rem 0;
}

.category-tree a {
    display: block;
    padding: 0.35rem 0.6rem;
    color: #555;
    text-decoration: none;
    font-size: 0.85rem;
    border-radius: 6px;
    transition: all 0.15s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.category-tree a:hover {
    background: #f0f0f0;
    color: #2c3e50;
}

.category-tree a.active {
    background: #2c3e50;
    color: white;
}

.category-tree ul {
    list-style: none;
    padding-left: 1rem;
    margin-top: 0.2rem;
}

/* ===== Просмотр страницы ===== */
.page-header {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #ebebeb;
}

.page-header h1 {
    font-size: 1.75rem;
    margin-bottom: 0.5rem;
    color: #1a1a1a;
    line-height: 1.3;
}

.page-meta {
    color: #999;
    font-size: 0.78rem;
    margin-bottom: 1rem;
}

.page-meta a {
    color: #777;
    text-decoration: none;
}

.page-meta a:hover {
    text-decoration: underline;
}

.history-link-btn {
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    font: inherit;
    color: #777;
    cursor: pointer;
    text-decoration: none;
}

.history-link-btn:hover {
    color: #2c3e50;
    text-decoration: underline;
}

/* ===== Попап истории изменений страницы ===== */
.history-list {
    max-height: 60vh;
    overflow-y: auto;
}

.history-item {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 10px 15px;
    margin-bottom: 8px;
}

.history-item:last-child {
    margin-bottom: 0;
}

.history-item.history-current {
    background: #eef4fb;
    border-color: #d7e6f5;
}

.history-date {
    font-size: 0.8rem;
    color: #777;
    white-space: nowrap;
    flex-shrink: 0;
}

.history-title {
    flex: 1;
    font-size: 0.9rem;
    color: #333;
    min-width: 0;
}

.history-badge {
    font-size: 0.7rem;
    font-weight: 600;
    color: #2c3e50;
    background: #dbe7f5;
    padding: 3px 10px;
    border-radius: 10px;
    white-space: nowrap;
    flex-shrink: 0;
}

.history-empty {
    color: #999;
    font-size: 0.9rem;
    text-align: center;
    padding: 1rem 0;
}

.page-content {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    border: 1px solid #e8e8e8;
    line-height: 1.7;
}

.page-content h1 { font-size: 1.75rem; margin: 1.5rem 0 0.75rem; color: #1a1a1a; }
.page-content h2 { font-size: 1.35rem; margin: 1.5rem 0 0.75rem; color: #2c3e50; border-bottom: 1px solid #f0f0f0; padding-bottom: 0.4rem; }
.page-content h3 { font-size: 1.1rem;  margin: 1.25rem 0 0.5rem; color: #2c3e50; }
.page-content h4 { font-size: 1rem;   margin: 1rem 0 0.5rem; color: #333; }

.page-content p {
    margin-bottom: 0.85rem;
}

.page-content ul,
.page-content ol {
    margin-left: 1.5rem;
    margin-bottom: 0.85rem;
}

.page-content li {
    margin-bottom: 0.25rem;
}

.page-content code {
    background: #f3f3f3;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-family: 'SFMono-Regular', Consolas, monospace;
    font-size: 0.88em;
    color: #c7254e;
}

.page-content pre {
    background: #f8f8f8;
    border: 1px solid #ebebeb;
    padding: 1.25rem;
    border-radius: 8px;
    overflow-x: auto;
    margin-bottom: 1rem;
}

.page-content pre code {
    background: none;
    padding: 0;
    color: inherit;
    font-size: 0.9em;
}

.page-content blockquote {
    border-left: 3px solid #ddd;
    padding: 0.5rem 1rem;
    margin: 1rem 0;
    color: #666;
    background: #fafafa;
}

/* Таблицы в контенте */
.page-content table {
    border-collapse: collapse;
    width: 100%;
    margin: 1rem 0;
    font-size: 0.9rem;
    border-radius: 8px;
    overflow: hidden;
}

.page-content th,
.page-content td {
    border: 1px solid #e0e0e0;
    padding: 0.6rem 0.85rem;
    text-align: left;
    vertical-align: top;
}

.page-content th {
    background: #f5f5f5;
    font-weight: 600;
    color: #2c3e50;
}

.page-content tr:hover td {
    background: #fafafa;
}

/* Изображения в контенте */
.page-content img {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
    cursor: pointer;
}

/* ===== Блоки документов в контенте страницы ===== */
.doc-row {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 10px 15px;
    margin: 10px 0;
    transition: background 0.15s;
}

.doc-row:hover {
    background: #f1f3f5;
    border-color: #dee2e6;
}

.doc-row .doc-icon {
    font-size: 1.4rem;
    margin-bottom: 0;
    flex-shrink: 0;
}

.doc-row .doc-name {
    flex: 1;
    font-size: 0.875rem;
    color: #333;
    word-break: break-word;
    min-width: 0;
}

.doc-row .doc-buttons {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.doc-btn {
    padding: 5px 13px;
    font-size: 0.75rem;
    font-weight: 500;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
    display: inline-block;
    white-space: nowrap;
}

.doc-download {
    background: #2c3e50;
    color: white;
}

.doc-download:hover {
    background: #1a2a3a;
    color: white;
}

.doc-view {
    background: #e9ecef;
    color: #495057;
}

.doc-view:hover {
    background: #dee2e6;
    color: #343a40;
}

/* ===== Формы ===== */
.form-card {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    border: 1px solid #e8e8e8;
    max-width: 860px;
    margin: 0 auto;
}

.form-group {
    margin-bottom: 1.1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.3rem;
    font-weight: 500;
    font-size: 0.9rem;
    color: #333;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.9rem;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: #fff;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #2c3e50;
    box-shadow: 0 0 0 3px rgba(44,62,80,0.08);
}

.form-group textarea {
    font-family: inherit;
    min-height: 200px;
    resize: vertical;
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
    flex-wrap: wrap;
}

/* ===== Авторизация ===== */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f5f5f5;
}

.login-card {
    max-width: 400px;
    width: 100%;
    margin: 2rem;
    background: white;
    border-radius: 16px;
    padding: 2rem;
    border: 1px solid #e8e8e8;
    box-shadow: 0 4px 24px rgba(0,0,0,0.06);
}

.login-card h1 {
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
    text-align: center;
    color: #2c3e50;
}

/* ===== Сообщения ===== */
.alert {
    padding: 0.85rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* ===== Пустое состояние ===== */
.empty-state {
    text-align: center;
    padding: 3rem 2rem;
    background: white;
    border-radius: 12px;
    border: 1px solid #e8e8e8;
}

.empty-state p {
    color: #888;
    margin-bottom: 1rem;
    font-size: 0.95rem;
}

.empty-message {
    color: #bbb;
    font-size: 0.82rem;
    font-style: italic;
}

/* ===== Футер ===== */
.footer {
    background: #ffffff;
    border-top: 1px solid #e0e0e0;
    padding: 1.5rem 0;
    text-align: center;
    font-size: 0.8rem;
    color: #aaa;
}

.footer-contact {
    margin-top: 0.4rem;
    font-size: 0.75rem;
}

.footer a {
    color: #888;
    text-decoration: none;
}

.footer a:hover {
    text-decoration: underline;
}

/* ===== Модальное окно ===== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 16px;
    max-width: 500px;
    width: 90%;
    padding: 1.5rem;
}

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

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #666;
    line-height: 1;
}

/* ===== Просмотр документов (модал) ===== */
#docModal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.85);
    z-index: 10000;
    align-items: center;
    justify-content: center;
}

#docModal > div {
    position: relative;
    width: 90%;
    height: 90%;
    background: white;
    border-radius: 10px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

#docModal .modal-header {
    padding: 10px 16px;
    background: #f5f5f5;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #ddd;
    flex-shrink: 0;
}

#docModal .modal-header span {
    font-weight: 600;
    font-size: 0.9rem;
    color: #333;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#docModal .modal-header button {
    background: none;
    border: none;
    font-size: 1.3rem;
    cursor: pointer;
    color: #666;
    flex-shrink: 0;
    padding: 2px 6px;
    border-radius: 4px;
}

#docModal .modal-header button:hover {
    background: #e0e0e0;
}

#modalFrame {
    flex: 1;
    width: 100%;
    border: none;
}

/* ===== CKEditor стили ===== */
.ck-editor__editable {
    min-height: 350px !important;
    max-height: 700px !important;
}

.ck.ck-editor {
    width: 100% !important;
}

.ck-content {
    font-family: inherit !important;
    line-height: 1.7 !important;
}

.ck-content h2 { font-size: 1.35rem !important; margin: 1.5rem 0 0.75rem !important; }
.ck-content h3 { font-size: 1.1rem !important;  margin: 1.25rem 0 0.5rem !important; }
.ck-content p  { margin-bottom: 0.85rem !important; }

.ck-content ul,
.ck-content ol {
    margin-left: 1.5rem !important;
    margin-bottom: 0.85rem !important;
}

.ck-content pre {
    background: #f8f8f8;
    border: 1px solid #ebebeb;
    padding: 1rem;
    border-radius: 8px;
    overflow-x: auto;
}

.ck-content code {
    background: #f3f3f3;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-family: 'SFMono-Regular', Consolas, monospace;
    font-size: 0.88em;
}

.ck-content table {
    border-collapse: collapse;
    width: 100%;
    margin-bottom: 1rem;
}

.ck-content th,
.ck-content td {
    border: 1px solid #ddd;
    padding: 0.5rem;
}

.ck-content th {
    background: #f5f5f5;
    font-weight: 600;
}

/* ===== Акцентные цвета категорий (6 вариантов в тон #2c3e50) ===== */
.cat-accent-0 { --accent: #2c4a7c; --accent-light: #eaeff8; --accent-mid: #b8cce0; }
.cat-accent-1 { --accent: #1a7a64; --accent-light: #e6f4f1; --accent-mid: #9ed0c5; }
.cat-accent-2 { --accent: #6b3d8a; --accent-light: #f0eaf7; --accent-mid: #c9aee0; }
.cat-accent-3 { --accent: #1a6b8a; --accent-light: #e6f1f7; --accent-mid: #9ec8e0; }
.cat-accent-4 { --accent: #2d7a4f; --accent-light: #e8f4ed; --accent-mid: #9ed0b5; }
.cat-accent-5 { --accent: #7a4f1a; --accent-light: #f7f0e6; --accent-mid: #d4b98a; }

/* ===== Сетка категорий (главная страница) ===== */
.cat-index-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2.5rem;
}

.cat-index-card {
    background: #ffffff;
    border-radius: 12px;
    border: 1px solid #e8e8e8;
    border-top: 4px solid var(--accent, #2c3e50);
    display: flex;
    flex-direction: column;
    transition: box-shadow 0.2s, transform 0.2s;
}

.cat-index-card:hover {
    box-shadow: 0 6px 20px rgba(0,0,0,0.1);
    transform: translateY(-2px);
}

.cat-index-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 1.1rem 0.5rem;
    flex-wrap: wrap;
}

.cat-index-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--accent, #2c3e50);
    text-decoration: none;
    flex: 1;
    min-width: 0;
    line-height: 1.3;
}

.cat-index-title:hover {
    text-decoration: underline;
}

.cat-index-badge {
    background: var(--accent-light, #eaeff8);
    color: var(--accent, #2c3e50);
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.2rem 0.55rem;
    border-radius: 20px;
    flex-shrink: 0;
    white-space: nowrap;
}

.cat-index-desc {
    padding: 0 1.1rem 0.6rem;
    font-size: 0.82rem;
    color: #888;
    line-height: 1.45;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.cat-index-children {
    list-style: none;
    margin: 0 1.1rem 0.5rem;
    padding: 0.5rem 0 0;
    border-top: 1px solid var(--accent-mid, #e0e0e0);
    flex: 1;
}

.cat-index-children li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.22rem 0;
    font-size: 0.8rem;
}

.cat-index-children li::before {
    content: '↳';
    color: var(--accent-mid, #ccc);
    margin-right: 0.4rem;
    flex-shrink: 0;
}

.cat-index-children a {
    color: #555;
    text-decoration: none;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cat-index-children a:hover {
    color: var(--accent, #2c3e50);
    text-decoration: underline;
}

.cat-index-children span {
    color: #bbb;
    font-size: 0.72rem;
    margin-left: 0.5rem;
    flex-shrink: 0;
}

.cat-index-footer {
    padding: 0.6rem 1.1rem 0.9rem;
    margin-top: auto;
}

.cat-index-footer a {
    font-size: 0.82rem;
    color: var(--accent, #2c3e50);
    text-decoration: none;
    font-weight: 500;
}

.cat-index-footer a:hover {
    text-decoration: underline;
}

/* ===== Таблица категорий в admin (индентация) ===== */
.cat-row-root td:nth-child(2) {
    font-weight: 600;
}

.cat-row-child td:nth-child(2) {
    color: #555;
}

.cat-child-arrow {
    color: #bbb;
    font-style: normal;
    margin-right: 0.2rem;
}

.cat-slug {
    font-family: 'SFMono-Regular', Consolas, monospace;
    font-size: 0.8rem;
    color: #888;
    background: #f5f5f5;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
}

/* ===== Раскладка страницы с оглавлением ===== */
.page-layout {
    display: grid;
    grid-template-columns: 1fr 240px;
    gap: 2rem;
    align-items: start;
}

.page-layout--full {
    grid-template-columns: 1fr;
}

.page-main {
    min-width: 0;
}

.page-toc-wrap {
    position: sticky;
    top: 100px;
    align-self: start;
}

.page-toc {
    background: #ffffff;
    border: 1px solid #e8e8e8;
    border-radius: 12px;
    padding: 1.25rem;
}

.page-toc h3 {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #999;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #f0f0f0;
}

.page-toc ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.page-toc li {
    margin: 0;
}

.page-toc a {
    display: block;
    padding: 0.3rem 0;
    font-size: 0.9rem;
    line-height: 1.4;
    color: #555;
    text-decoration: none;
    border-left: 2px solid transparent;
    padding-left: 0.6rem;
    transition: color 0.15s, border-color 0.15s;
}

.page-toc a:hover {
    color: #2c3e50;
    border-left-color: #2c3e50;
}

.page-toc a.active {
    color: #2c3e50;
    font-weight: 600;
    border-left-color: #2c3e50;
}

.page-toc__l3 a {
    padding-left: 1.4rem;
    font-size: 0.85rem;
    color: #777;
}

/* Компенсация липкого хедера при переходе по якорям */
.page-content h2[id],
.page-content h3[id] {
    scroll-margin-top: 90px;
}

/* ===== Навигация «предыдущая / следующая» ===== */
.page-nav {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-top: 2.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid #ececec;
}

.page-nav__link {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.9rem 1.1rem;
    border: 1px solid #e8e8e8;
    border-radius: 10px;
    text-decoration: none;
    background: #fff;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.page-nav__link:hover {
    border-color: #2c3e50;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

/* ===== Контент-виджеты: callout-блоки ===== */
.callout {
    --callout-accent: #2c7a7b;
    --callout-bg: #edf7f7;
    border: 1px solid var(--callout-accent);
    border-left-width: 4px;
    border-radius: 8px;
    background: var(--callout-bg);
    padding: 0.85rem 1rem;
    margin: 1.25rem 0;
}

.callout__head {
    font-weight: 600;
    color: var(--callout-accent);
    margin-bottom: 0.35rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.callout__icon { font-style: normal; }

.callout__body > :last-child { margin-bottom: 0; }
.callout__body p:last-child { margin-bottom: 0; }

.callout--note      { --callout-accent: #2b6cb0; --callout-bg: #ebf3fb; }
.callout--tip       { --callout-accent: #2d7a4f; --callout-bg: #e9f5ee; }
.callout--important  { --callout-accent: #6b46c1; --callout-bg: #f1ecfb; }
.callout--warning   { --callout-accent: #b7791f; --callout-bg: #fbf3e3; }
.callout--caution   { --callout-accent: #c53030; --callout-bg: #fbeaea; }

/* ===== Контент-виджеты: сворачиваемые блоки ===== */
.wiki-details {
    border: 1px solid #e2e2e2;
    border-radius: 8px;
    margin: 1.25rem 0;
    background: #fafafa;
    overflow: hidden;
}

.wiki-details > summary {
    cursor: pointer;
    padding: 0.7rem 1rem;
    font-weight: 600;
    color: #2c3e50;
    list-style: none;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.wiki-details > summary::-webkit-details-marker { display: none; }

.wiki-details > summary::before {
    content: '▸';
    transition: transform 0.15s;
    color: #888;
}

.wiki-details[open] > summary::before { transform: rotate(90deg); }

.wiki-details[open] > summary { border-bottom: 1px solid #e2e2e2; }

.wiki-details__body { padding: 0.85rem 1rem; }
.wiki-details__body > :last-child { margin-bottom: 0; }

/* ===== Контент-виджеты: блок кода с кнопкой «Копировать» ===== */
.page-content pre {
    position: relative;
    background: #1e293b;
    color: #e2e8f0;
    padding: 1rem;
    border-radius: 8px;
    overflow-x: auto;
    margin: 1.25rem 0;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
    font-size: 0.88rem;
    line-height: 1.5;
}

.page-content pre code {
    background: none;
    padding: 0;
    color: inherit;
    font-size: inherit;
}

.code-copy-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    padding: 0.25rem 0.6rem;
    font-size: 0.75rem;
    color: #cbd5e1;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 5px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s, background 0.15s;
}

.page-content pre:hover .code-copy-btn,
.code-copy-btn:focus-visible { opacity: 1; }

.code-copy-btn:hover { background: rgba(255, 255, 255, 0.16); }

.code-copy-btn.copied { color: #86efac; border-color: #4ade80; }

/* ===== Виджеты сайдбара статьи ===== */
.page-widget {
    margin-top: 1.75rem;
    font-size: 0.9rem;
}

.page-widget h3 {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #8a8a8a;
    margin-bottom: 0.6rem;
    padding-bottom: 0.35rem;
    border-bottom: 1px solid #ececec;
}

.page-widget ul { list-style: none; }

.page-widget li {
    margin-bottom: 0.55rem;
    line-height: 1.35;
}

.page-widget a {
    color: #2c3e50;
    text-decoration: none;
}

.page-widget a:hover {
    color: #1a7a64;
    text-decoration: underline;
}

.page-widget__date {
    display: block;
    font-size: 0.74rem;
    color: #aaa;
    margin-top: 0.1rem;
}

.page-nav__next {
    text-align: right;
    align-items: flex-end;
}

.page-nav__dir {
    font-size: 0.8rem;
    color: #999;
}

.page-nav__title {
    font-size: 0.95rem;
    font-weight: 600;
    color: #2c3e50;
}

/* ===== Адаптив ===== */
@media (max-width: 900px) {
    .content-grid {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
    }

    .page-layout {
        grid-template-columns: 1fr;
    }

    .page-toc-wrap {
        position: static;
        order: -1;
    }
}

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

    .page-nav__next {
        text-align: left;
        align-items: flex-start;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 0 1rem;
    }

    .header .container {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .nav-links {
        gap: 1rem;
        font-size: 0.85rem;
    }

    .search-tagline {
        font-size: 1.35rem;
    }

    .stats {
        flex-direction: column;
        gap: 0.75rem;
    }

    .docs-grid {
        grid-template-columns: 1fr;
    }

    .cat-index-grid {
        grid-template-columns: 1fr;
    }


    .action-buttons {
        flex-direction: column;
    }

    .btn {
        text-align: center;
    }

    .form-card {
        padding: 1rem;
    }

    .page-content {
        padding: 1.25rem;
    }

    .doc-row {
        flex-wrap: wrap;
    }

    .doc-row .doc-buttons {
        width: 100%;
    }

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

@media (max-width: 480px) {
    .page-header h1 {
        font-size: 1.35rem;
    }

    .search-tagline {
        font-size: 1.15rem;
    }

}

/* ===== Печать ===== */
@media print {
    .header, .search-section, .action-buttons, .breadcrumbs { display: none; }
    .page-content { border: none; box-shadow: none; }
    body { background: white; }
}

/* ===== Редактор: заголовок H4 и блоки кода ===== */
.ck-content h4 { font-size: 1rem !important; margin: 1rem 0 0.5rem !important; }

.page-content pre code[class*="language-"],
.ck-content pre code[class*="language-"] {
    font-family: 'SFMono-Regular', Consolas, monospace;
    font-size: 0.88em;
    white-space: pre;
}

/* ===== Редактор: панель восстановления черновика ===== */
.draft-restore-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    background: #fff8e1;
    border: 1px solid #ffe082;
    border-radius: 8px;
    padding: 0.65rem 1rem;
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
    color: #5d4037;
}

.draft-restore-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

.draft-restore-bar .btn {
    padding: 0.35rem 0.85rem;
    font-size: 0.85rem;
}

/* ===== Редактор: модальное окно предпросмотра ===== */
.editor-preview-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 10000;
    align-items: flex-start;
    justify-content: center;
    padding: 3vh 1rem;
    overflow-y: auto;
}

.editor-preview-modal.active {
    display: flex;
}

.editor-preview-dialog {
    background: #f4f5f7;
    border-radius: 12px;
    width: 100%;
    max-width: 900px;
    max-height: 94vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}

.editor-preview-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem 1.25rem;
    background: #2c3e50;
    color: #fff;
    font-weight: 600;
}

.editor-preview-close {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 1.1rem;
    cursor: pointer;
    line-height: 1;
}

.editor-preview-body {
    padding: 1.5rem;
    overflow-y: auto;
}

.editor-preview-body .page-content {
    margin: 0;
}