@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700&display=swap');

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: 'Manrope', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: #575757;
    background-color: #F1F5F8;
    line-height: 1.6;
}

.site-header {
    background-color: #ffffff;
    color: #1E4381;
    border-bottom: 1px solid #F1F3F7;
}

.header-top {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 14px 2rem;
}

.header-user-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.4rem 2rem;
    background: #eef2f8;
    border-top: 1px solid #dce3ea;
    font-size: 0.85rem;
}

.logo-with-region {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    white-space: nowrap;
    flex-shrink: 0;
}

.site-title {
    margin: 0;
    font-size: 1.05rem;
    color: #1E4381;
    font-weight: 600;
    white-space: nowrap;
    flex-shrink: 0;
}

.main-nav {
    display: flex;
    align-items: center;
    flex: 1;
    justify-content: center;
}

.logo-img {
    height: 28px;
    width: auto;
}

.logo-region-text {
    font-size: 12px;
    line-height: 1.3;
    color: #575757;
    max-width: 180px;
}

.main-nav {
    display: flex;
    align-items: center;
    justify-content: center;
}

.main-nav a {
    color: #1E4381;
    text-decoration: none;
    margin-right: 1rem;
    font-size: 0.95rem;
    font-weight: 500;
    transition: color 0.2s ease;
}

.main-nav a:hover {
    color: #4F8CC9;
    text-decoration: none;
}

/* ---------- Dropdown menu (nav) ---------- */
.dropdown {
    position: relative;
    display: inline-block;
    margin-right: 1rem;
}

.dropdown-toggle {
    color: #1E4381;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: color 0.2s ease;
}

.dropdown-toggle::after {
    content: '▾';
    margin-left: 0.3rem;
    font-size: 0.7em;
    opacity: 0.6;
}

.dropdown-toggle:hover {
    color: #4F8CC9;
}

.dropdown-menu {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    background-color: #ffffff;
    padding: 8px 0;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    min-width: 260px;
}

/* Правые dropdown'ы — выравнивание по правому краю */
.main-nav .dropdown:last-child {
    margin-right: 0;
}

.main-nav .dropdown:last-child .dropdown-menu {
    left: auto;
    right: 0;
}

/* Невидимый мостик, чтобы меню не схлопывалось при смещении курсора */
.dropdown-menu::before {
    content: '';
    position: absolute;
    top: -8px;
    left: 0;
    right: 0;
    height: 8px;
}

.dropdown:hover .dropdown-menu {
    display: block;
}

.dropdown-menu a {
    display: block;
    padding: 10px 20px;
    margin-right: 0;
    color: #1E4381;
    text-decoration: none;
    font-size: 0.9rem;
    white-space: nowrap;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.dropdown-menu a:hover {
    background-color: #F1F5F8;
    color: #4F8CC9;
}

.container {
    max-width: none;
    margin: 2rem auto;
    padding: 0 2rem;
}

@media (min-width: 1800px) {
    .container {
        padding: 0 3rem;
    }
}

.status-card {
    background-color: #ffffff;
    border: none;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.06);
}

.status-card h2 {
    margin-top: 0;
    color: #1E4381;
}

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

.page-head h2 {
    margin: 0;
    color: #153162;
    font-weight: 700;
}

/* ---------- Flash messages ---------- */
.flash-messages {
    margin-bottom: 1rem;
}

.flash {
    padding: 0.6rem 1rem;
    border-radius: 6px;
    margin-bottom: 0.5rem;
    font-size: 0.92rem;
}

.flash-success {
    background-color: #e6f4ea;
    color: #147a3d;
    border: 1px solid #bfe3c8;
}

.flash-error {
    background-color: #fdecea;
    color: #b02a1d;
    border: 1px solid #f5c6c0;
}

/* ---------- Table ---------- */
.data-table {
    width: 100%;
    border-collapse: collapse;
    background-color: #ffffff;
    border: none;
    border-radius: 12px;
    font-size: 0.9rem;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.06);
}

.data-table thead tr {
    background-color: #F1F5F8;
}

.data-table thead th:first-child {
    border-top-left-radius: 12px;
}

.data-table thead th:last-child {
    border-top-right-radius: 12px;
}

.data-table tbody tr:last-child td:first-child {
    border-bottom-left-radius: 12px;
}

.data-table tbody tr:last-child td:last-child {
    border-bottom-right-radius: 12px;
}

.data-table th,
.data-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    vertical-align: top;
    border-bottom: 1px solid #F1F3F7;
    word-break: break-word;
}

/* Ширина колонок: последняя — действия (nowrap) */
.data-table th:last-child,
.data-table td:last-child {
    width: auto;
    white-space: nowrap;
}

.data-table th {
    background-color: #F1F5F8;
    font-weight: 600;
    color: #1E4381;
}

.data-table tbody tr:hover {
    background-color: #f8fafc;
}

.data-table tr:last-child td {
    border-bottom: none;
}

.row-inactive {
    opacity: 0.55;
}

.actions {
    white-space: nowrap;
}

.inline-form {
    display: inline-block;
    margin-right: 0.3rem;
}

/* ---------- Tags & badges ---------- */
.tag {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    font-size: 0.78rem;
    background-color: #eef2f7;
    color: #3a4a5a;
}

.tag-rss { background-color: #e6f4ea; color: #147a3d; }
.tag-website { background-color: #e8f0fe; color: #1b4fa0; }
.tag-api { background-color: #fef3e2; color: #9a5b00; }
.tag-company { background-color: #f3e8ff; color: #6b21a8; }
.tag-government { background-color: #ffe8ec; color: #9c1d3a; }
.tag-media { background-color: #eef7fa; color: #0e5e73; }

.badge {
    display: inline-block;
    padding: 0.1rem 0.45rem;
    border-radius: 999px;
    font-size: 0.78rem;
}

.badge-on { background-color: #e6f4ea; color: #147a3d; }
.badge-off { background-color: #eceff2; color: #5b6672; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-block;
    padding: 0.6rem 1.2rem;
    border-radius: 12px;
    border: none;
    background-color: #ffffff;
    color: #1E4381;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn:hover {
    background-color: #F1F5F8;
    color: #4F8CC9;
}

.btn-primary {
    background-color: #4F8CC9;
    border-color: #4F8CC9;
    color: #ffffff;
}

.btn-primary:hover {
    background-color: #1E4381;
    color: #ffffff;
}

.btn-danger {
    background-color: #fdecea;
    border-color: #f5c6c0;
    color: #BD353F;
}

.btn-small {
    padding: 0.4rem 0.8rem;
    font-size: 0.82rem;
}

/* ---------- Forms ---------- */
.form-card {
    background-color: #ffffff;
    border: none;
    border-radius: 12px;
    padding: 1.5rem 2rem;
    max-width: none;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.06);
}

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

.form-row label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.4rem;
    color: #2c3a47;
    font-size: 0.95rem;
}

.form-row input,
.form-row select,
.form-row textarea {
    width: 100%;
    padding: 0.6rem 0.8rem;
    border: 1px solid #cdd5de;
    border-radius: 6px;
    font-size: 0.95rem;
    font-family: inherit;
    background-color: #ffffff;
}

.form-row textarea {
    resize: vertical;
    min-height: 4rem;
    line-height: 1.6;
}

.form-row input:focus,
.form-row select:focus,
.form-row textarea:focus {
    outline: none;
    border-color: #0b3d91;
    box-shadow: 0 0 0 2px rgba(11, 61, 145, 0.15);
}

/* Двухколоночная сетка для коротких полей (ФИО + должность и т.п.) */
.form-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 1.5rem;
}

@media (max-width: 768px) {
    .form-grid-2 {
        grid-template-columns: 1fr;
    }
}

/* Широкая форма — на всю рабочую область */
.form-wide {
    max-width: none;
}

/* Секции формы с заголовками */
.form-section {
    border: 1px solid #e4e7eb;
    border-radius: 8px;
    padding: 1.25rem 1.5rem 0.5rem;
    margin-bottom: 1.25rem;
}

.form-section legend {
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #0b3d91;
    padding: 0 0.5rem;
}

.form-section .form-row:last-child {
    margin-bottom: 1rem;
}

/* ---------- Вкладки (карточка автора) ---------- */
.tabs {
    display: flex;
    gap: 0.25rem;
    border-bottom: 2px solid #e4e7eb;
    margin-bottom: 1.25rem;
}

.tab {
    padding: 0.6rem 1.1rem;
    text-decoration: none;
    color: #5b6672;
    font-size: 0.92rem;
    font-weight: 500;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color 0.15s, border-color 0.15s;
}

.tab:hover {
    color: #0b3d91;
}

.tab.active {
    color: #0b3d91;
    border-bottom-color: #0b3d91;
    font-weight: 600;
}

.tab.external::after {
    content: " ↗";
    font-size: 0.75rem;
    opacity: 0.6;
}

/* Карточка профиля автора */
.author-profile-card {
    background-color: #ffffff;
    border: 1px solid #e4e7eb;
    border-radius: 8px;
    padding: 1.5rem 2rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.profile-section {
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid #eef1f4;
}

.profile-section h3 {
    margin: 0 0 0.5rem 0;
    font-size: 1rem;
    color: #1E4381;
    text-transform: none;
    letter-spacing: normal;
    font-weight: 600;
}

.profile-text {
    margin: 0;
    white-space: pre-line;
    line-height: 1.65;
    font-size: 0.92rem;
    color: #3a4a5a;
}

.expertise-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.expertise-list li {
    padding: 0.3rem 0;
    font-size: 0.92rem;
    color: #3a4a5a;
    border-bottom: 1px solid #f5f7fa;
}

.expertise-list li:last-child {
    border-bottom: none;
}

/* Список тегов (интересы автора и т.п.) */
.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

/* Бейдж fit-оценки в подборке автора */
.tag-fit {
    background-color: #e8f0fe;
    color: #0b3d91;
    font-weight: 600;
}

.tag-fit.fit-high { background-color: #e6f4ea; color: #147a3d; }
.tag-fit.fit-mid  { background-color: #fef3e2; color: #9a5b00; }
.tag-fit.fit-low  { background-color: #eceff2; color: #5b6672; }

/* Чекбоксы источников в форме автора */
.source-table { margin-top: 0.75rem; }

.source-table .row-selected td { background-color: #eef4fb; }

/* Панель инструментов вкладки (текст + кнопка справа) */
.tab-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

/* Заголовок внутри вкладки (формы добавления/редактирования) */
.tab-title {
    margin: 0 0 1rem 0;
    font-size: 1.2rem;
    color: #2c3a47;
}

/* Примечание под вкладками */
.tab-note {
    background-color: #eef2f7;
    border: 1px solid #d4dce6;
    border-radius: 8px;
    padding: 0.7rem 1rem;
    margin-bottom: 1rem;
    font-size: 0.88rem;
    color: #3a4a5a;
}

.tab-note p {
    margin: 0;
}

/* ---------- LLM test page ---------- */
.llm-form { margin-bottom: 1.25rem; }

.llm-result {
    border-radius: 8px;
    padding: 1rem 1.25rem;
    margin-top: 0.5rem;
}

.llm-result h3 {
    margin: 0 0 0.6rem 0;
    font-size: 1rem;
    color: #1E4381;
    font-weight: 600;
}

.llm-success {
    background-color: #eef7f1;
    border: 1px solid #bfe3c8;
}

.llm-error {
    background-color: #fdecea;
    border: 1px solid #f5c6c0;
}

.llm-error p { margin: 0; color: #b02a1d; font-size: 0.9rem; }

.llm-answer {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
    background-color: #ffffff;
    border: 1px solid #e4e7eb;
    border-radius: 6px;
    padding: 0.9rem 1rem;
    font-size: 0.92rem;
    line-height: 1.6;
    color: #1f2933;
}

.form-actions {
    margin-top: 1.2rem;
    display: flex;
    gap: 0.6rem;
}

/* ---------- Stats (collect) ---------- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.stat-card {
    background-color: #ffffff;
    border: 1px solid #e4e7eb;
    border-radius: 8px;
    padding: 1.25rem;
    text-align: center;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: #0b3d91;
    line-height: 1.2;
}

.stat-label {
    margin-top: 0.35rem;
    color: #5b6672;
    font-size: 0.88rem;
}

.stat-added .stat-value { color: #147a3d; }
.stat-error .stat-value { color: #b02a1d; }

/* ---------- Status tags (news) ---------- */
.tag-status-new { background-color: #e6f4ea; color: #147a3d; }
.tag-status-candidate { background-color: #fef3e2; color: #9a5b00; font-weight: 600; }
.tag-status-read { background-color: #e8f0fe; color: #1b4fa0; }
.tag-status-archived { background-color: #eceff2; color: #5b6672; }

/* Статусы комментариев (в карточках автора и на странице комментария) */
.tag-status-draft { background-color: #fef3e2; color: #9a5b00; font-weight: 600; }
.tag-status-review { background-color: #e8f0fe; color: #1b4fa0; font-weight: 600; }
.tag-status-approved { background-color: #d9f2e3; color: #0e5e3a; font-weight: 700; }
.tag-status-published { background-color: #c8f7dc; color: #0a5c36; font-weight: 700; border: 1px solid #7ddba3; }
.tag-status-rejected { background-color: #fce4e4; color: #9b2c2c; font-weight: 600; }

.nowrap { white-space: nowrap; }
.muted { color: #7b8794; font-size: 0.85rem; margin-top: 0.75rem; }

/* ---------- Pagination ---------- */
.pagination {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    justify-content: center;
    margin-top: 1rem;
    flex-wrap: wrap;
}

.page-jump-form {
    display: inline-flex;
    gap: 0.3rem;
    align-items: center;
}

.page-jump-input {
    width: 60px;
    padding: 0.35rem 0.4rem;
    border: 1px solid #cdd5de;
    border-radius: 6px;
    font-size: 0.85rem;
}

/* ---------- Batch toolbar ---------- */
.batch-toolbar {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}

.batch-toolbar .spacer {
    flex: 1;
}

/* ---------- Column header tooltips ---------- */
.col-help {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background-color: #cdd5de;
    color: #ffffff;
    font-size: 0.6rem;
    font-weight: 700;
    margin-left: 0.3rem;
    cursor: help;
    position: relative;
    vertical-align: middle;
}

.col-help:hover::after {
    content: attr(data-tip);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background-color: #2c3a47;
    color: #ffffff;
    padding: 0.4rem 0.6rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 400;
    white-space: nowrap;
    z-index: 9999;
    pointer-events: none;
}

.col-help:hover::before {
    content: '';
    position: absolute;
    bottom: calc(100% + 2px);
    left: 50%;
    transform: translateX(-50%);
    border: 4px solid transparent;
    border-top-color: #2c3a47;
    z-index: 9999;
}

/* ---------- Zebra striping (long tables) ---------- */
.data-table.zebra tbody tr:nth-child(even) {
    background-color: #fafbfc;
}

.data-table.zebra tbody tr:nth-child(even):hover {
    background-color: #f0f4f8;
}

/* ---------- Sources table column widths ---------- */
.sources-table {
    table-layout: fixed;
}

.sources-table th:nth-child(1) { width: 16%; }
.sources-table td:nth-child(1) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.sources-table th:nth-child(2),
.sources-table th:nth-child(3) { width: 20%; }

.sources-table td:nth-child(2),
.sources-table td:nth-child(3) {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sources-table td:nth-child(2) a,
.sources-table td:nth-child(3) a {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: block;
}

.sources-table th:nth-child(4),
.sources-table th:nth-child(5),
.sources-table th:nth-child(6) { width: 8%; }

.sources-table td:nth-child(4),
.sources-table td:nth-child(5),
.sources-table td:nth-child(6) { white-space: nowrap; }

.sources-table th:nth-child(7) { width: 12%; }

/* ---------- Filter bar (news list) ---------- */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    align-items: center;
    background-color: #ffffff;
    border: 1px solid #e4e7eb;
    border-radius: 8px;
    padding: 0.9rem 1rem;
    margin-bottom: 1.25rem;
}

.filter-bar input[type="search"] {
    flex: 1 1 220px;
    min-width: 160px;
    padding: 0.45rem 0.7rem;
    border: 1px solid #cdd5de;
    border-radius: 6px;
    font-size: 0.9rem;
}

.filter-bar select {
    padding: 0.4rem 0.5rem;
    border: 1px solid #cdd5de;
    border-radius: 6px;
    font-size: 0.85rem;
    background-color: #ffffff;
    max-width: 220px;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
}

.filter-date {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: #5b6672;
    font-size: 0.88rem;
}

.filter-date input[type="date"],
.filter-date input[type="number"] {
    padding: 0.4rem 0.5rem;
    border: 1px solid #cdd5de;
    border-radius: 6px;
    font-size: 0.85rem;
    width: 5.5rem;
}

/* ---------- News detail card ---------- */
.news-card {
    background-color: #ffffff;
    border: 1px solid #e4e7eb;
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.news-card-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.news-title {
    margin: 0;
    font-size: 1.4rem;
    line-height: 1.35;
    color: #1f2933;
}

.meta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.75rem 1.25rem;
    margin: 0 0 1.25rem 0;
}

.meta-item dt {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #7b8794;
    margin-bottom: 0.15rem;
}

.meta-item dd {
    margin: 0;
    font-size: 0.92rem;
    word-break: break-word;
}

.news-description h3 {
    margin: 0 0 0.4rem 0;
    font-size: 1rem;
    color: #1E4381;
    font-weight: 600;
}

.news-description p {
    margin: 0;
    white-space: pre-line;
    color: #3a4a5a;
}

.news-actions {
    display: flex;
    gap: 0.6rem;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid #eef1f4;
}

/* ---------- Article text (fetch) ---------- */
.article-text-block {
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid #eef1f4;
}

.article-text-block h3,
.fetch-error-block h3 {
    margin: 0 0 0.6rem 0;
    font-size: 1rem;
    color: #1E4381;
    font-weight: 600;
}

.article-text {
    background-color: #fafbfc;
    border: 1px solid #eef1f4;
    border-radius: 8px;
    padding: 1rem 1.25rem;
    max-height: 60vh;
    overflow-y: auto;
    white-space: pre-line;
    line-height: 1.7;
    font-size: 0.95rem;
    color: #3a4a5a;
}

.fetch-error-block {
    margin-top: 1.25rem;
    padding: 0.9rem 1.1rem;
    background-color: #fdecea;
    border: 1px solid #f5c6c0;
    border-radius: 8px;
}

.fetch-error-block p {
    margin: 0;
    color: #b02a1d;
    font-size: 0.9rem;
}

/* ---------- Дашборд: последние комментарии ---------- */
.comments-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

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

@media (max-width: 768px) {
    .comments-grid { grid-template-columns: 1fr; }
}

.comment-card {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    background-color: #ffffff;
    border: 1px solid #e4e7eb;
    border-radius: 12px;
    padding: 1rem 1.1rem;
    text-decoration: none;
    color: inherit;
    transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

.comment-card:hover {
    box-shadow: 0 2px 8px rgba(30, 67, 129, 0.1);
    border-color: #4F8CC9;
}

.comment-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.comment-author {
    font-size: 0.85rem;
    font-weight: 600;
    color: #1E4381;
}

.comment-card-point {
    margin: 0;
    font-size: 0.88rem;
    line-height: 1.55;
    color: #3a4a5a;
    flex: 1;
}

.comment-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    font-size: 0.82rem;
    padding-top: 0.4rem;
    border-top: 1px solid #f0f2f5;
}

.comment-card-link {
    color: #1E4381;
    text-decoration: none;
    font-weight: 500;
}

.comment-card-link:hover {
    color: #4F8CC9;
    text-decoration: underline;
}

/* ---------- Позиция (этап 11) ---------- */
.position-list {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

@media (max-width: 1200px) {
    .position-list { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .position-list { grid-template-columns: 1fr; }
}

.position-card {
    background-color: #ffffff;
    border: 1px solid #e4e7eb;
    border-radius: 12px;
    padding: 1.1rem 1.25rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.position-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.6rem;
}

.position-header h3 {
    margin: 0;
    font-size: 1.05rem;
    line-height: 1.4;
    color: #1E4381;
    font-weight: 600;
}

.position-text {
    margin: 0 0 0.75rem 0;
    white-space: pre-line;
    font-size: 0.92rem;
    line-height: 1.65;
    color: #3a4a5a;
}

.position-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding-top: 0.6rem;
    border-top: 1px solid #eef1f4;
}

.position-footer .actions {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

/* ---------- Анализ фактов события (этап 10) ---------- */
.cluster-actions {
    margin-top: 0.75rem;
}

.event-analysis {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #eef1f4;
}

.event-analysis h4 {
    margin: 0 0 0.9rem 0;
    font-size: 1rem;
    color: #2c3a47;
}

.analysis-section {
    margin-bottom: 0.85rem;
}

.analysis-section h5 {
    margin: 0 0 0.35rem 0;
    font-size: 0.88rem;
    color: #2c3a47;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.analysis-section p {
    margin: 0;
    white-space: pre-line;
    font-size: 0.92rem;
    line-height: 1.65;
    color: #3a4a5a;
}

.facts-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.facts-list li {
    padding: 0.3rem 0.5rem;
    margin-bottom: 0.25rem;
    border-radius: 4px;
    font-size: 0.9rem;
    line-height: 1.5;
}

.facts-list.confirmed li {
    background-color: #e6f4ea;
    color: #147a3d;
    border-left: 3px solid #147a3d;
}

.facts-list.claims li {
    background-color: #fef3e2;
    color: #9a5b00;
    border-left: 3px solid #9a5b00;
}

.facts-list.uncertainties li {
    background-color: #eceff2;
    color: #5b6672;
    border-left: 3px solid #cdd5de;
}

.primary-source-flag {
    margin: 0.5rem 0;
    font-size: 0.9rem;
    color: #2c3a47;
}

/* Выбранная позиция (этап 12) */
.facts-list.positions li {
    background-color: #eef2f7;
    color: #3a4a5a;
    border-left: 3px solid #0b3d91;
    padding: 0.6rem 0.8rem;
}

.facts-list.positions li .tag {
    margin-right: 0.5rem;
}

.facts-list.positions li strong {
    display: inline;
    color: #1f2933;
}

.facts-list.positions li p {
    margin: 0.4rem 0 0 0;
    font-size: 0.88rem;
    line-height: 1.6;
    white-space: pre-line;
    color: #5b6672;
}

/* Черновик комментария (этап 13) */
.comment-draft {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #eef1f4;
}

.comment-draft h4 {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin: 0 0 0.9rem 0;
    font-size: 1rem;
    color: #2c3a47;
}

.badge-comment-draft { background-color: #fef3e2; color: #9a5b00; }
.badge-comment-approved { background-color: #e6f4ea; color: #147a3d; }
.badge-comment-rejected { background-color: #eceff2; color: #5b6672; }

.theses-list {
    margin: 0.5rem 0 0 0;
    padding-left: 1.25rem;
}

.theses-list li {
    font-size: 0.9rem;
    line-height: 1.6;
    color: #3a4a5a;
    margin-bottom: 0.25rem;
}

.comment-text {
    margin-top: 0.75rem;
    border: 1px solid #eef1f4;
    border-radius: 8px;
    padding: 0.6rem 1rem;
    background-color: #fafbfc;
}

.comment-text summary {
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    color: #2c3a47;
}

.comment-body {
    margin: 0.75rem 0 0.25rem 0;
    white-space: pre-line;
    line-height: 1.7;
    font-size: 0.95rem;
    color: #3a4a5a;
}

.comment-status-approved .comment-body {
    background-color: #f6fbf7;
    border-left: 3px solid #147a3d;
    padding-left: 0.75rem;
}

.comment-status-rejected {
    opacity: 0.7;
}

/* Страница ревью комментария (этап 14) */
.badge-comment-review { background-color: #e8f0fe; color: #1b4fa0; }
.badge-comment-published { background-color: #e6f4ea; color: #147a3d; border: 1px solid #bfe3c8; }

.comment-edit-card .comment-event {
    margin-bottom: 1rem;
    font-size: 0.95rem;
    color: #2c3a47;
}

.char-count {
    display: inline-block;
    margin-top: 0.3rem;
    font-size: 0.8rem;
    color: #7b8794;
}

.divider {
    border: none;
    border-top: 1px solid #eef1f4;
    margin: 1.5rem 0;
}

.section-title {
    margin: 0 0 0.6rem 0;
    font-size: 1rem;
    color: #2c3a47;
}

.status-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.status-btn-draft { background-color: #fef3e2; border-color: #f5d9a8; color: #9a5b00; }
.status-btn-review { background-color: #e8f0fe; border-color: #c4d7fb; color: #1b4fa0; }
.status-btn-approved { background-color: #e6f4ea; border-color: #bfe3c8; color: #147a3d; }
.status-btn-published { background-color: #d9f2e3; border-color: #147a3d; color: #0e5e3a; font-weight: 600; }
.status-btn-rejected { background-color: #eceff2; border-color: #cdd5de; color: #5b6672; }

.approved-block,
.original-block {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.approved-block details,
.original-block details {
    border: 1px solid #eef1f4;
    border-radius: 8px;
    padding: 0.5rem 1rem;
    background-color: #fafbfc;
}

.approved-block summary,
.original-block summary {
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    color: #2c3a47;
}

.original-block details {
    background-color: #f5f7fa;
}

.theses-static {
    margin-top: 0.4rem;
}

/* ---------- Кластеры (этап 9) ---------- */
.head-actions {
    display: flex;
    gap: 0.5rem;
}

.clusters-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.cluster-card {
    background-color: #ffffff;
    border: 1px solid #e4e7eb;
    border-radius: 8px;
    padding: 1.25rem 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.cluster-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.cluster-count {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    background-color: #e8f0fe;
    color: #1b4fa0;
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
}

.cluster-title {
    margin: 0;
    font-size: 1.1rem;
    line-height: 1.4;
}

.cluster-title a {
    color: #1f2933;
    text-decoration: none;
}

.cluster-title a:hover {
    color: #0b3d91;
    text-decoration: underline;
}

.cluster-main .cluster-meta {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.cluster-others {
    margin-top: 0.75rem;
    border-top: 1px solid #eef1f4;
    padding-top: 0.75rem;
}

.cluster-others summary {
    cursor: pointer;
    font-size: 0.9rem;
    color: #2c3a47;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.others-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.others-list li {
    padding: 0.4rem 0;
    border-bottom: 1px solid #f5f7fa;
    font-size: 0.9rem;
}

.others-list li:last-child {
    border-bottom: none;
}

.others-list a {
    color: #2c3a47;
    text-decoration: none;
}

.others-list a:hover {
    color: #0b3d91;
    text-decoration: underline;
}

/* ---------- Кандидаты (этап 8) ---------- */
.candidates-table td {
    font-size: 0.88rem;
}

.candidate-row { border-left: 3px solid transparent; }
.candidate-hot      { border-left-color: #147a3d; background-color: #f6fbf7; }
.candidate-interesting { border-left-color: #9a5b00; background-color: #fefaf2; }
.candidate-low      { border-left-color: #cdd5de; }

.legend {
    display: flex;
    gap: 1.25rem;
    margin-top: 0.75rem;
    font-size: 0.85rem;
    color: #5b6672;
}

.legend-item {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

/* ---------- AI-анализ (этап 7) ---------- */
.analysis-block {
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid #eef1f4;
}

.analysis-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.9rem;
}

.analysis-header h3 {
    margin: 0;
    font-size: 1rem;
    color: #1E4381;
    font-weight: 600;
}

.score-badge {
    display: inline-block;
    padding: 0.25rem 0.7rem;
    border-radius: 999px;
    font-weight: 700;
    font-size: 0.88rem;
    white-space: nowrap;
}

.score-high { background-color: #e6f4ea; color: #147a3d; }
.score-mid  { background-color: #fef3e2; color: #9a5b00; }
.score-low  { background-color: #eceff2; color: #5b6672; }

/* ---------- Sortable column headers (news list) ---------- */
th.sortable a {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    text-decoration: none;
    color: inherit;
    font-weight: inherit;
}

th.sortable a:hover {
    color: #4F8CC9;
    text-decoration: none;
}

th.sortable.active {
    background-color: #E3EDF7;
    color: #1E4381;
}

th.sortable.active a {
    font-weight: 600;
}

.analysis-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.6rem;
    margin-bottom: 1rem;
}

.score-item {
    background-color: #fafbfc;
    border: 1px solid #eef1f4;
    border-radius: 6px;
    padding: 0.55rem 0.7rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.score-label {
    font-size: 0.78rem;
    color: #7b8794;
    text-transform: lowercase;
}

.score-value {
    font-weight: 600;
    font-size: 0.92rem;
    color: #1f2933;
}

.analysis-meta {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 0.75rem 1.25rem;
    margin: 0 0 0.9rem 0;
}

.analysis-meta .meta-item dt {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #7b8794;
    margin-bottom: 0.25rem;
}

.analysis-meta .meta-item dd {
    margin: 0;
    font-size: 0.92rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.comment-flag {
    margin: 0 0 0.75rem 0;
    font-size: 0.92rem;
    color: #2c3a47;
}

.analysis-reason {
    background-color: #fafbfc;
    border: 1px solid #eef1f4;
    border-radius: 8px;
    padding: 0.9rem 1.1rem;
}

.analysis-reason h4 {
    margin: 0 0 0.4rem 0;
    font-size: 0.92rem;
    color: #2c3a47;
}

.analysis-reason p {
    margin: 0;
    white-space: pre-line;
    font-size: 0.92rem;
    line-height: 1.65;
    color: #3a4a5a;
}

/* ---------- Дашборд (этап 18) ---------- */
.dashboard-metrics {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.stat-link {
    text-decoration: none;
    color: inherit;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.stat-link:hover {
    border-color: #0b3d91;
    box-shadow: 0 2px 8px rgba(11, 61, 145, 0.12);
}

.stat-hot .stat-value { color: #b02a1d; }

.dashboard-top {
    margin-top: 1.75rem;
}

.dashboard-top-table td {
    font-size: 0.88rem;
}

/* ---------- Логи / ошибки (этап 19) ---------- */
.log-table-wrap {
    overflow-x: auto;
    border: 1px solid #e4e7eb;
    border-radius: 8px;
}

.log-table td,
.log-table th {
    font-size: 0.85rem;
}

.log-row {
    border-left: 3px solid transparent;
}

.log-error   { border-left-color: #b02a1d; background-color: #fdf6f5; }
.log-warning { border-left-color: #9a5b00; background-color: #fefaf2; }
.log-info    { border-left-color: transparent; }

.log-badge-error   { background-color: #fdecea; color: #b02a1d; font-weight: 600; }
.log-badge-warning { background-color: #fef3e2; color: #9a5b00; }
.log-badge-info    { background-color: #e8f0fe; color: #1b4fa0; }

.log-message {
    word-break: break-word;
    white-space: pre-wrap;
    max-width: 600px;
}

.site-footer {
    text-align: center;
    padding: 1rem;
    color: #7b8794;
    font-size: 0.85rem;
}

/* ---------- HTML-превью статьи (prepare-html) ---------- */
/* Защита от вложенных <html>/<body> если raw_html содержит полный документ */
.html-preview > html, .html-preview > body {
    display: contents !important;
    opacity: 1 !important;
    background: none !important;
}
.html-preview h2 {
    font-size: 1.3rem;
    font-weight: 700;
    margin: 1.2rem 0 0.6rem;
    color: #153162;
}
.html-preview h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 1rem 0 0.4rem;
    color: #1E4381;
}
.html-preview p {
    margin: 0.6rem 0;
    line-height: 1.7;
    font-size: 0.95rem;
}
.html-preview ul, .html-preview ol {
    margin: 0.6rem 0;
    padding-left: 1.5rem;
}
.html-preview li {
    margin: 0.3rem 0;
    line-height: 1.6;
}
.html-preview blockquote {
    border-left: 3px solid #1a56db;
    padding: 0.5rem 1rem;
    margin: 0.8rem 0;
    background: #f0f4ff;
    color: #2d3748;
}
.html-preview strong {
    font-weight: 700;
}
