:root {
    --wp-sidebar: #1d2327;
    --wp-sidebar-hover: #2c3338;
    --wp-sidebar-text: #c3c4c7;
    --wp-blue: #2271b1;
    --wp-blue-dark: #135e96;
    --wp-bg: #f0f0f1;
    --wp-border: #c3c4c7;
    --wp-text: #1d2327;
    --wp-muted: #646970;
    --wp-danger: #b32d2e;
    --wp-green: #2e7d32;
    --radius: 4px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    background: var(--wp-bg);
    color: var(--wp-text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu,
        Cantarell, "Helvetica Neue", sans-serif;
    font-size: 13px;
    line-height: 1.5;
}

.hidden { display: none !important; }
a { color: var(--wp-blue); text-decoration: none; }
a:hover { color: var(--wp-blue-dark); }

/* ================= Логин ================= */
.login-screen {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background: #f0f0f1;
}

.login-card {
    width: 100%;
    max-width: 360px;
    background: #fff;
    border: 1px solid var(--wp-border);
    border-radius: var(--radius);
    box-shadow: 0 1px 3px rgba(0, 0, 0, .04);
    padding: 26px 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.login-brand { text-align: center; padding-bottom: 8px; }
.login-brand h1 { margin: 10px 0 0; font-size: 20px; font-weight: 600; }
.login-brand p { margin: 2px 0 0; color: var(--wp-muted); font-size: 13px; }

.logo-badge {
    width: 52px; height: 52px; margin: 0 auto;
    display: grid; place-items: center;
    background: var(--wp-green);
    color: #fff; border-radius: 10px;
    font-weight: 700; font-size: 20px;
}
.logo-badge.sm { width: 28px; height: 28px; font-size: 12px; border-radius: 6px; margin: 0; }

.field { display: flex; flex-direction: column; gap: 4px; }
.field span { color: var(--wp-muted); font-size: 12px; }

input, select, textarea {
    width: 100%;
    padding: 6px 8px;
    font: inherit;
    color: var(--wp-text);
    background: #fff;
    border: 1px solid #8c8f94;
    border-radius: var(--radius);
    min-height: 32px;
}
input:focus, select:focus, textarea:focus {
    outline: 2px solid transparent;
    border-color: var(--wp-blue);
    box-shadow: 0 0 0 1px var(--wp-blue);
}
textarea { min-height: 90px; resize: vertical; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font: inherit;
    font-weight: 500;
    padding: 5px 12px;
    min-height: 30px;
    border: 1px solid var(--wp-blue);
    border-radius: var(--radius);
    background: #f6f7f7;
    color: var(--wp-blue);
    cursor: pointer;
}
.btn:hover { background: #f0f0f1; }
.btn-primary { background: var(--wp-blue); border-color: var(--wp-blue); color: #fff; }
.btn-primary:hover { background: var(--wp-blue-dark); border-color: var(--wp-blue-dark); }
.btn-danger { border-color: var(--wp-danger); color: var(--wp-danger); background: #fcf0f1; }
.btn-danger:hover { background: #fbeaea; }
.btn-link { border: none; background: transparent; color: var(--wp-sidebar-text); padding: 4px 8px; }
.btn-link:hover { color: #fff; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.login-error {
    margin: 0;
    padding: 8px 10px;
    border-left: 4px solid var(--wp-danger);
    background: #fcf0f1;
    color: var(--wp-danger);
}
.login-hint { margin: 0; color: var(--wp-muted); font-size: 12px; text-align: center; }

/* ================= Каркас ================= */
.admin-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 190px;
    flex: 0 0 190px;
    background: var(--wp-sidebar);
    color: var(--wp-sidebar-text);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 14px 18px;
    color: #fff;
    font-weight: 600;
    font-size: 14px;
}
.sidebar-nav { display: flex; flex-direction: column; }
.menu-item {
    display: block;
    padding: 10px 16px;
    color: var(--wp-sidebar-text);
    font-size: 14px;
    border-left: 4px solid transparent;
}
.menu-item:hover { background: var(--wp-sidebar-hover); color: #fff; }
.menu-item.active {
    background: var(--wp-sidebar-hover);
    color: #fff;
    border-left-color: var(--wp-blue);
    font-weight: 600;
}
/* Группа меню с подпунктами: «Системные уведомления» */
.menu-group-title {
    display: block;
    padding: 14px 16px 6px;
    font-size: 11px;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    color: #8c8f94;
}
.menu-item.menu-sub { padding-left: 30px; font-size: 13px; }

/* Модальное окно выбора новости для ссылки */
.modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(0, 0, 0, 0.35);
}
.modal-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    max-width: 560px;
    max-height: 80vh;
    padding: 16px;
    background: #fff;
    border-radius: 8px;
}
.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.modal-head h2 { margin: 0; font-size: 16px; }
.modal-list {
    min-height: 120px;
    overflow: auto;
    border: 1px solid var(--wp-border);
    border-radius: var(--radius);
}
.modal-item {
    padding: 8px 12px;
    border-bottom: 1px solid #f0f0f1;
    cursor: pointer;
}
.modal-item:last-child { border-bottom: none; }
.modal-item:hover { background: #f6f7f7; }
.modal-item .muted { display: block; font-size: 12px; }

/* Подсказка под заголовком раздела */
.help-panel {
    margin: 0 0 16px;
    padding: 10px 16px 12px;
    background: #fff;
    border: 1px solid var(--wp-border);
    border-left: 4px solid var(--wp-blue);
    border-radius: var(--radius);
    font-size: 13px;
}
.help-panel summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--wp-blue);
    outline: none;
}
.help-panel ul {
    margin: 10px 0 0;
    padding-left: 20px;
}
.help-panel li { margin: 4px 0; }
.help-panel li:last-child { margin-bottom: 0; }
.help-panel b { color: var(--wp-text); }
.sidebar-foot {
    margin-top: auto;
    padding: 12px 16px;
    font-size: 11px;
    color: #787c82;
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.adminbar {
    height: 46px;
    background: var(--wp-sidebar);
    color: var(--wp-sidebar-text);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
}
.adminbar-left, .adminbar-right { display: flex; align-items: center; gap: 12px; }
.page-title { color: #fff; font-weight: 600; font-size: 14px; }
.icon-btn {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    padding: 2px 6px;
}
.user-chip { font-size: 13px; }
.user-chip.role-admin { color: #ffb3b3; }
.user-chip.role-moderator { color: #b8e6b8; }

.content {
    padding: 20px 24px 48px;
    width: 100%;
    max-width: 1300px;
    margin: 0 auto;
}

/* ================= Страницы ================= */
.view-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 12px;
}
.view-head h1 { margin: 0; font-size: 23px; font-weight: 400; }
.back-link { font-size: 13px; }

.search-form { display: flex; gap: 6px; align-items: center; }
.search-form input, .search-form select { min-width: 220px; }

/* ================= Таблицы ================= */
.table-wrap {
    background: #fff;
    border: 1px solid var(--wp-border);
    border-radius: var(--radius);
    overflow-x: auto;
    box-shadow: 0 1px 1px rgba(0, 0, 0, .04);
}
table.list-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.list-table thead th {
    text-align: left;
    font-weight: 600;
    padding: 9px 12px;
    border-bottom: 1px solid var(--wp-border);
    background: #f6f7f7;
    white-space: nowrap;
}
.list-table tbody td {
    padding: 10px 12px;
    border-bottom: 1px solid #f0f0f1;
    vertical-align: top;
}
.list-table tbody tr:last-child td { border-bottom: none; }
.list-table tbody tr:hover { background: #f6f7f7; }
.list-table .row-title { font-weight: 600; color: var(--wp-blue); }
.list-table .row-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.list-table .muted { color: var(--wp-muted); }

.badge {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    background: #f0f0f1;
    color: #50575e;
    white-space: nowrap;
}
.badge.admin { background: #fcf0f1; color: var(--wp-danger); }
.badge.moderator { background: #edfaef; color: var(--wp-green); }
.badge.active { background: #edfaef; color: var(--wp-green); }
.badge.blocked { background: #fcf0f1; color: var(--wp-danger); }
.badge.pending { background: #fcf9e8; color: #996800; }
.badge.plus { background: #eef4ff; color: #1d4ed8; }
.badge.free { background: #f0f0f1; color: #50575e; }

.pagination {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
    color: var(--wp-muted);
    font-size: 12px;
}
.pagination .btn { min-height: 26px; padding: 2px 10px; }
.pagination .spacer { flex: 1; }

.empty-state { padding: 28px; text-align: center; color: var(--wp-muted); }

/* ================= Формы ================= */
.form-panel {
    background: #fff;
    border: 1px solid var(--wp-border);
    border-radius: var(--radius);
    box-shadow: 0 1px 1px rgba(0, 0, 0, .04);
    padding: 4px 20px 20px;
}
.form-table { width: 100%; border-collapse: collapse; }
.form-table th {
    width: 220px;
    text-align: left;
    vertical-align: top;
    padding: 16px 12px 16px 0;
    font-weight: 600;
}
.form-table td { padding: 12px 0; }
.form-table tr + tr th, .form-table tr + tr td { border-top: 1px solid #f0f0f1; }
.form-table .desc { color: var(--wp-muted); font-size: 12px; margin-top: 4px; }
.form-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 16px 0 0;
    border-top: 1px solid #f0f0f1;
    margin-top: 8px;
}
.checkbox-row { display: flex; align-items: center; gap: 8px; margin: 6px 0; }
.checkbox-row input { width: auto; min-height: auto; }
.readonly-value { padding: 6px 0; }

/* ================= Доступ PLUS ================= */
.access-editor { display: flex; flex-direction: column; gap: 8px; max-width: 640px; }
.access-editor .field-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.access-editor .field-row > span:first-child { min-width: 140px; font-weight: 600; }
.access-editor .field-row input,
.access-editor .field-row select { width: auto; min-width: 180px; }
.access-features {
    display: flex;
    flex-direction: column;
    gap: 6px;
    border: 1px solid #f0f0f1;
    border-radius: var(--radius);
    padding: 10px;
    margin: 4px 0;
}
.access-feature {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas: "title select" "code select";
    align-items: center;
    gap: 2px 10px;
    padding: 4px 0;
}
.access-feature + .access-feature { border-top: 1px solid #f7f7f7; }
.access-feature-title { font-weight: 600; grid-area: title; }
.access-feature .muted { grid-area: code; color: var(--wp-muted); font-size: 12px; }
.access-feature select { grid-area: select; width: auto; min-width: 140px; }
.access-history { margin-top: 6px; }
.access-history summary { cursor: pointer; font-weight: 600; color: var(--wp-blue); }
.access-history .list-table { margin-top: 8px; }
.access-history .list-table th,
.access-history .list-table td { font-size: 12px; padding: 6px 8px; }

.review-text { max-width: 280px; white-space: pre-wrap; word-break: break-word; }

/* ================= Редактор новостей ================= */
.editor-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 6px;
    background: #f6f7f7;
    border: 1px solid var(--wp-border);
    border-bottom: none;
    border-radius: var(--radius) var(--radius) 0 0;
}
.editor-toolbar button {
    min-width: 32px;
    min-height: 28px;
    padding: 2px 8px;
    background: #fff;
    border: 1px solid var(--wp-border);
    border-radius: 3px;
    color: var(--wp-text);
    font-size: 12px;
}
.editor-toolbar button:hover { background: var(--wp-bg); }

.editor {
    min-height: 240px;
    max-height: 60vh;
    overflow-y: auto;
    padding: 12px 14px;
    border: 1px solid var(--wp-border);
    border-radius: 0 0 var(--radius) var(--radius);
    background: #fff;
    font-size: 14px;
    line-height: 1.6;
}
.editor:focus { outline: 2px solid var(--wp-blue); outline-offset: -2px; }
.editor:empty::before {
    content: attr(data-placeholder);
    color: #8c8f94;
}
.editor h2 { font-size: 18px; margin: 12px 0 6px; }
.editor p { margin: 0 0 10px; }
.editor img { max-width: 100%; height: auto; border-radius: 4px; margin: 6px 0; }
.editor a { color: var(--wp-blue); }
.editor ul, .editor ol { margin: 0 0 10px 20px; }

/* ================= Уведомление ================= */
.notice {
    margin-bottom: 14px;
    padding: 9px 12px;
    background: #fff;
    border: 1px solid var(--wp-border);
    border-left: 4px solid var(--wp-blue);
    border-radius: var(--radius);
    box-shadow: 0 1px 1px rgba(0, 0, 0, .04);
}
.notice.success { border-left-color: var(--wp-green); }
.notice.error { border-left-color: var(--wp-danger); }

/* ================= Мобильный ================= */
@media (max-width: 782px) {
    .sidebar {
        position: fixed;
        z-index: 20;
        transform: translateX(-100%);
        transition: transform .18s ease;
    }
    .sidebar.open { transform: translateX(0); }
    .admin-shell.sidebar-open::after {
        content: "";
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, .45);
        z-index: 10;
    }
    .content { padding: 14px; }
    .view-head { align-items: stretch; }
    .search-form { width: 100%; }
    .search-form input, .search-form select { min-width: 0; flex: 1; }
    .form-table th { display: block; width: auto; padding-bottom: 4px; }
    .form-table td { display: block; padding-top: 0; }
}
/* ================= Каналы ================= */
.channel-card { display: flex; flex-direction: column; gap: 12px; }
.channel-head { display: flex; align-items: center; gap: 14px; }
.channel-logo {
    width: 56px; height: 56px; border-radius: 14px; object-fit: cover;
    border: 1px solid var(--wp-border);
}
.channel-logo.placeholder {
    display: flex; align-items: center; justify-content: center;
    background: var(--wp-primary-soft, #e8f0ec); color: var(--wp-primary, #1f7a4d);
    font-weight: 600; font-size: 22px;
}
.channel-head h2 { margin: 0; font-size: 20px; }

/* ================= Загруженные картинки ================= */
.cover-preview {
    display: block;
    max-width: 240px;
    max-height: 140px;
    margin-top: 8px;
    border-radius: 10px;
    border: 1px solid var(--wp-border);
    object-fit: cover;
}
