* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
}

body {
    font-family: Arial, Helvetica, sans-serif;
    background: #f4f6f8;
    color: #263238;
}

/* =========================================================
   ШАПКА
   ========================================================= */

.header {
    height: 72px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 30px;
    padding: 0 28px;
    background: #ffffff;
    border-bottom: 1px solid #dfe5e8;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-brand {
    display: flex;
    align-items: center;
    min-width: 0;
}

.header-title {
    font-size: 21px;
    font-weight: 700;
    white-space: nowrap;
}

.header-home-link {
    color: #263238;
    text-decoration: none;
}

.header-home-link:hover {
    color: #1976d2;
}

.header-subtitle {
    margin-left: 18px;
    color: #78909c;
    font-size: 14px;
}

.header-search {
    width: 430px;
    max-width: 45%;
    display: flex;
    position: relative;
}

.header-search input {
    width: 100%;
    height: 40px;
    padding: 0 14px;
    border: 1px solid #cfd8dc;
    border-right: 0;
    border-radius: 7px 0 0 7px;
    outline: none;
    font-size: 14px;
}

.header-search input:focus {
    border-color: #1976d2;
}

.header-search button {
    height: 40px;
    padding: 0 18px;
    border: 0;
    border-radius: 0 7px 7px 0;
    background: #1976d2;
    color: #ffffff;
    cursor: pointer;
    font-weight: 600;
}

.header-search button:hover {
    background: #1565c0;
}

/* =========================================================
   ОСНОВНОЙ МАКЕТ
   ========================================================= */

.layout {
    display: grid;
    grid-template-columns: 370px minmax(0, 1fr);
    min-height: calc(100vh - 72px);
}

/* =========================================================
   ЛЕВОЕ МЕНЮ
   ========================================================= */

.sidebar {
    height: calc(100vh - 72px);
    position: sticky;
    top: 72px;
    overflow-y: auto;
    background: #ffffff;
    border-right: 1px solid #dfe5e8;
}

.sidebar-header {
    padding: 18px 20px;
    border-bottom: 1px solid #eceff1;
    position: sticky;
    top: 0;
    background: #ffffff;
    z-index: 10;
}

.sidebar-header strong {
    display: block;
    margin-bottom: 5px;
    font-size: 15px;
}

.sidebar-header small {
    color: #78909c;
}

/* =========================================================
   ДЕРЕВО
   ========================================================= */

.tree,
.tree-children {
    list-style: none;
    margin: 0;
    padding: 0;
}

.tree {
    padding: 10px 8px 40px;
}

.tree-children {
    margin-left: 20px;
    border-left: 1px solid #e5eaed;
    padding-left: 4px;
}

.tree-children[hidden] {
    display: none;
}

.tree-item {
    margin: 1px 0;
}

.tree-row {
    display: flex;
    align-items: flex-start;
    width: 100%;
}

.tree-toggle,
.tree-toggle-placeholder {
    width: 26px;
    min-width: 26px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tree-toggle {
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
    border-radius: 5px;
}

.tree-toggle:hover {
    background: #eef3f6;
}

.tree-arrow {
    width: 0;
    height: 0;
    border-top: 5px solid transparent;
    border-bottom: 5px solid transparent;
    border-left: 7px solid #78909c;
    transition: transform 0.15s ease;
}

.tree-toggle.open .tree-arrow {
    transform: rotate(90deg);
}

.tree-link {
    flex: 1;
    display: flex;
    gap: 5px;
    align-items: flex-start;
    padding: 8px 9px;
    border-radius: 6px;
    text-decoration: none;
    color: #37474f;
    line-height: 1.35;
    font-size: 14px;
}

.tree-link:hover {
    background: #eef3f6;
}

.tree-link.active {
    background: #e3f2fd;
    color: #0d47a1;
    font-weight: 700;
}

.section-number {
    font-weight: 700;
    white-space: nowrap;
}

.section-title {
    min-width: 0;
}

/* =========================================================
   СОДЕРЖИМОЕ
   ========================================================= */

.content {
    width: 100%;
    max-width: 1250px;
    padding: 34px 46px 80px;
}

.breadcrumb {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    color: #78909c;
    font-size: 13px;
    margin-bottom: 18px;
}

.breadcrumb a {
    color: #546e7a;
    text-decoration: none;
}

.breadcrumb a:hover {
    color: #1976d2;
    text-decoration: underline;
}

.breadcrumb-separator {
    color: #b0bec5;
}

.breadcrumb-current {
    color: #78909c;
}

.content h1 {
    margin: 0;
    font-size: 29px;
    line-height: 1.35;
    color: #263238;
}

.page-section-number {
    margin-right: 5px;
}

.document-text {
    background: #ffffff;
    padding: 32px 36px;
    border-radius: 10px;
    border: 1px solid #e2e7ea;
    line-height: 1.72;
    font-size: 16px;
    margin-bottom: 20px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.025);
}

.empty {
    padding: 25px;
    background: #fff8e1;
    border: 1px solid #ffe082;
    border-radius: 8px;
}

/* =========================================================
   ЖИВОЙ ПОИСК
   ========================================================= */

.search-suggestions {
    position: absolute;
    top: calc(100% + 7px);
    left: 0;
    right: 0;
    max-height: 480px;
    overflow-y: auto;
    background: #ffffff;
    border: 1px solid #cfd8dc;
    border-radius: 8px;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.16);
    z-index: 1000;
}

.search-suggestions[hidden] {
    display: none;
}

.search-suggestion {
    display: block;
    padding: 12px 14px;
    color: #263238;
    text-decoration: none;
    border-bottom: 1px solid #eceff1;
}

.search-suggestion:last-child {
    border-bottom: 0;
}

.search-suggestion:hover,
.search-suggestion.selected {
    background: #e3f2fd;
}

.search-suggestion-header {
    display: flex;
    gap: 7px;
    align-items: flex-start;
    margin-bottom: 5px;
}

.search-suggestion-number {
    flex-shrink: 0;
    color: #1565c0;
    font-size: 13px;
    font-weight: 700;
}

.search-suggestion-title {
    font-size: 14px;
    line-height: 1.35;
    font-weight: 600;
}

.search-suggestion-snippet {
    font-size: 12px;
    color: #78909c;
    line-height: 1.4;
    overflow: hidden;
}

.search-suggestion-empty {
    padding: 16px;
    color: #78909c;
    font-size: 14px;
    text-align: center;
}

/* =========================================================
   СТРАНИЦА ПОИСКА
   ========================================================= */

.search-page {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: 34px 30px 80px;
}

.search-back {
    margin-bottom: 20px;
}

.search-back a {
    color: #546e7a;
    text-decoration: none;
    font-size: 14px;
}

.search-back a:hover {
    color: #1976d2;
    text-decoration: underline;
}

.search-page h1 {
    margin: 0 0 22px;
    font-size: 30px;
}

.search-summary {
    margin-bottom: 24px;
    padding: 14px 18px;
    background: #ffffff;
    border: 1px solid #e0e5e8;
    border-radius: 8px;
    color: #546e7a;
}

.search-info {
    padding: 24px;
    background: #ffffff;
    border: 1px solid #e0e5e8;
    border-radius: 8px;
    color: #607d8b;
}

.search-results {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.search-result {
    display: block;
    padding: 20px 22px;
    background: #ffffff;
    border: 1px solid #dfe5e8;
    border-radius: 9px;
    color: #263238;
    text-decoration: none;
}

.search-result:hover {
    border-color: #90caf9;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.06);
}

.search-result-header {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 10px;
}

.search-result-number {
    flex-shrink: 0;
    padding: 3px 7px;
    background: #e3f2fd;
    border-radius: 5px;
    color: #0d47a1;
    font-size: 13px;
    font-weight: 700;
}

.search-result-title {
    font-size: 17px;
    font-weight: 700;
    line-height: 1.45;
}

.search-result-snippet {
    line-height: 1.6;
    color: #546e7a;
    font-size: 14px;
}

.search-result mark {
    padding: 1px 2px;
    border-radius: 2px;
    background: #fff59d;
    color: inherit;
    font-weight: 700;
}

.search-empty {
    padding: 28px;
    background: #ffffff;
    border: 1px solid #e0e5e8;
    border-radius: 9px;
}

/* =========================================================
   РЕДАКТОР ТЕКСТА
   ========================================================= */

.content-title-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 25px;
    margin-bottom: 26px;
}

.content-title-row h1 {
    flex: 1;
}

.edit-button {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    padding: 9px 14px;
    border: 1px solid #90a4ae;
    border-radius: 7px;
    background: #ffffff;
    color: #455a64;
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
}

.edit-button:hover {
    background: #eceff1;
    border-color: #78909c;
}

.save-success {
    margin-bottom: 20px;
    padding: 13px 16px;
    background: #e8f5e9;
    border: 1px solid #a5d6a7;
    border-radius: 7px;
    color: #2e7d32;
    font-weight: 600;
}

.editor-card {
    padding: 24px;
    background: #ffffff;
    border: 1px solid #dfe5e8;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.editor-label {
    margin-bottom: 10px;
    font-size: 14px;
    font-weight: 700;
    color: #455a64;
}

.content-editor {
    display: block;
    width: 100%;
    min-height: 550px;
    resize: vertical;
    padding: 18px;
    border: 1px solid #b0bec5;
    border-radius: 7px;
    outline: none;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 16px;
    line-height: 1.65;
    color: #263238;
    background: #ffffff;
}

.content-editor:focus {
    border-color: #1976d2;
    box-shadow: 0 0 0 3px rgba(25, 118, 210, 0.10);
}

.editor-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 18px;
}

.save-button {
    padding: 11px 18px;
    border: 0;
    border-radius: 7px;
    background: #1976d2;
    color: #ffffff;
    cursor: pointer;
    font-size: 14px;
    font-weight: 700;
}

.save-button:hover {
    background: #1565c0;
}

.cancel-button {
    padding: 10px 17px;
    border: 1px solid #cfd8dc;
    border-radius: 7px;
    background: #ffffff;
    color: #546e7a;
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
}

.cancel-button:hover {
    background: #eceff1;
}

/* =========================================================
   АДАПТИВ
   ========================================================= */

@media (max-width: 1000px) {
    .header-subtitle {
        display: none;
    }

    .header-search {
        max-width: none;
        width: 380px;
    }

    .layout {
        grid-template-columns: 320px minmax(0, 1fr);
    }

    .content {
        padding: 28px 28px 60px;
    }
}

@media (max-width: 760px) {
    .header {
        height: auto;
        min-height: 72px;
        padding: 12px 15px;
        flex-wrap: wrap;
    }

    .header-search {
        width: 100%;
    }

    .layout {
        display: block;
    }

    .sidebar {
        height: auto;
        max-height: 450px;
        position: static;
        border-right: 0;
        border-bottom: 1px solid #dfe5e8;
    }

    .content {
        padding: 24px 16px 50px;
    }

    .document-text {
        padding: 22px 20px;
        font-size: 15px;
    }

    .content-title-row {
        display: block;
    }

    .edit-button {
        margin-top: 15px;
    }

    .content-editor {
        min-height: 400px;
        font-size: 15px;
    }

    .search-page {
        padding: 24px 16px 50px;
    }
}
