/* Админка Gebe. Палитра та же, что в мобильном приложении. */
:root {
    --bg: #F7F3F5;
    --card: #FFFFFF;
    --text: #2A1620;
    --muted: #6B5560;
    --accent: #C2185B;
    --accent-dark: #7D1539;
    --tint: #FCE4EC;
    --line: #EAD9DF;
    --ok: #2E7D32;
    --ok-tint: #E3F3E4;
    --warn: #8A5A00;
    --warn-tint: #FFF3D6;
    --radius: 14px;
    --shadow: 0 1px 2px rgba(42, 22, 32, .05), 0 4px 16px rgba(42, 22, 32, .05);
    --sidebar-width: 248px;
    --topbar-height: 64px;
    /* Тёмные полосы вверху: общая для меню и рабочей области */
    --bar: #2A1620;
    --bar-text: #FFFFFF;
    --bar-muted: #CDB9C2;
    --bar-field: rgba(255, 255, 255, .10);
    --bar-line: rgba(255, 255, 255, .14);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.5 "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: 24px; line-height: 1.25; margin: 0 0 4px; letter-spacing: -.01em; }
h2 { font-size: 17px; margin: 28px 0 12px; }

svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }

.muted { color: var(--muted); font-weight: normal; }
.error { color: var(--accent-dark); }
.ok { color: var(--ok); }
.notice { background: var(--tint); color: var(--accent-dark); padding: 12px 16px; border-radius: var(--radius); }

/* Каркас */
.shell { display: flex; min-height: 100vh; }
.nav-toggle { display: none; }
.scrim { display: none; }

.sidebar {
    position: sticky;
    top: 0;
    width: var(--sidebar-width);
    height: 100vh;
    flex-shrink: 0;
    background: var(--card);
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.sidebar-head { height: var(--topbar-height); flex-shrink: 0; display: flex; align-items: center; padding: 0 16px; background: var(--bar); }

.brand { display: flex; align-items: center; gap: 10px; color: var(--bar-text); }
.brand:hover { text-decoration: none; }
.brand-mark { width: 36px; height: 36px; border-radius: 11px; background: var(--accent); color: #fff; font-weight: 800; font-size: 18px; display: grid; place-items: center; }
.brand-name { font-size: 19px; font-weight: 800; letter-spacing: .06em; }

.sidebar nav { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; }
.nav-group { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding: 12px 10px 6px; }
.sidebar nav a { display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 10px; color: var(--muted); font-weight: 600; }
.sidebar nav a:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.sidebar nav a.active { background: var(--tint); color: var(--accent-dark); }
.sidebar-foot { margin-top: auto; padding: 12px 22px; font-size: 12px; color: var(--muted); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* Верхняя полоса */
.topbar {
    position: sticky;
    top: 0;
    z-index: 5;
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 24px;
    background: var(--bar);
    color: var(--bar-text);
}

.topbar-title { font-size: 18px; font-weight: 700; white-space: nowrap; }

.topbar-search { flex: 1; max-width: 460px; margin-left: 8px; display: flex; align-items: center; gap: 8px; padding: 0 12px; height: 40px; background: var(--bar-field); border: 1px solid transparent; border-radius: 12px; color: var(--bar-muted); }
.topbar-search:focus-within { background: rgba(255, 255, 255, .16); border-color: var(--bar-muted); }
/* Селектор усилен, чтобы общие правила для полей ввода ниже не перекрасили поле в белое. */
.topbar .topbar-search input { flex: 1; min-width: 0; width: auto; border: 0; background: none; padding: 0; margin: 0; font: inherit; color: var(--bar-text); outline: none; }
.topbar .topbar-search input::placeholder { color: var(--bar-muted); }

.topbar-date { margin-left: auto; display: flex; align-items: center; gap: 8px; color: var(--bar-muted); font-size: 14px; white-space: nowrap; }

.topbar-user { display: flex; align-items: center; gap: 10px; padding-left: 16px; border-left: 1px solid var(--bar-line); }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--accent); color: #fff; font-weight: 700; display: grid; place-items: center; }
.user-text { line-height: 1.25; }
.user-name { font-weight: 600; font-size: 14px; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-role { font-size: 12px; color: var(--bar-muted); }
.topbar-user form { margin: 0; }

/* Кнопки-иконки на тёмной полосе */
.topbar .icon-button { color: var(--bar-muted); }
.topbar .icon-button:hover { background: var(--bar-field); color: var(--bar-text); }

.icon-button { width: 38px; height: 38px; padding: 0; border: 0; border-radius: 10px; background: none; color: var(--muted); display: grid; place-items: center; cursor: pointer; }
.icon-button:hover { background: var(--bg); color: var(--text); }
.menu-button { display: none; }

.content { flex: 1; width: 100%; max-width: 1280px; padding: 26px 28px 56px; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { margin: 0; }
.page-sub { color: var(--muted); margin: 2px 0 0; }
.filters, .nav-weeks { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.back-link { display: inline-block; margin-bottom: 10px; font-weight: 600; }

/* Карточки и плитки */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.card + .card { margin-top: 18px; }
.card-title { font-size: 16px; font-weight: 700; margin: 0 0 12px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 20px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; color: var(--text); }
a.tile:hover { text-decoration: none; border-color: var(--accent); }
.tile-head { display: flex; align-items: center; gap: 10px; color: var(--muted); font-weight: 600; font-size: 13px; }
.tile-icon { width: 34px; height: 34px; border-radius: 10px; background: var(--tint); color: var(--accent-dark); display: grid; place-items: center; }
.tile-value { font-size: 28px; font-weight: 800; line-height: 1.1; letter-spacing: -.02em; }
.tile-note { font-size: 13px; color: var(--muted); }
.meter { height: 6px; border-radius: 3px; background: var(--bg); overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--ok); border-radius: 3px; }

.two-columns { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 18px; align-items: start; }
.two-columns .card + .card { margin-top: 0; }

.activity { list-style: none; margin: 0; padding: 0; }
.activity li { display: flex; align-items: baseline; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.activity li:last-child { border-bottom: 0; }
.activity .kind { font-size: 12px; font-weight: 700; color: var(--muted); width: 64px; flex-shrink: 0; }
.activity .what { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.activity .when { font-size: 12px; color: var(--muted); white-space: nowrap; }

/* Формы */
label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 14px; }
label.inline { display: inline-flex; align-items: center; gap: 8px; margin: 0; color: var(--muted); }

input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="search"], select, textarea {
    display: block;
    width: 100%;
    margin-top: 5px;
    padding: 9px 11px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--card);
    color: var(--text);
    font: inherit;
    font-weight: normal;
}
label.inline select, label.inline input { width: auto; margin-top: 0; }
textarea { resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
input:disabled, select:disabled, textarea:disabled { background: var(--bg); color: var(--muted); }

fieldset.form { border: 0; padding: 0; margin: 0; }
.form.narrow { max-width: 460px; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 28px; }
.grid-2.tight { grid-template-columns: 1fr 1fr; gap: 12px; }

button, a.button {
    font: inherit;
    font-weight: 600;
    padding: 9px 16px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: var(--card);
    color: var(--text);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}
button:hover, a.button:hover { background: var(--bg); text-decoration: none; }
button.primary, a.button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover, a.button.primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
button:disabled { opacity: .55; cursor: default; }
button.link { border: 0; background: none; padding: 2px 6px; color: var(--accent); }
button.link:hover { text-decoration: underline; background: none; }
button.link.danger { color: var(--accent-dark); }

.actions { display: flex; align-items: center; gap: 14px; margin-top: 16px; flex-wrap: wrap; }

/* Панель над списком: поиск, фильтры, сортировка */
.list-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius) var(--radius) 0 0; border-bottom: 0; }
.list-bar .search { flex: 1; min-width: 220px; display: flex; align-items: center; gap: 8px; padding: 0 12px; height: 40px; background: var(--bg); border: 1px solid transparent; border-radius: 10px; color: var(--muted); }
.list-bar .search:focus-within { background: var(--card); border-color: var(--accent); }
.list-bar .search input { flex: 1; min-width: 0; border: 0; background: none; padding: 0; margin: 0; outline: none; }
.list-bar select { width: auto; margin: 0; height: 40px; padding: 0 10px; }
.list-bar .reset { margin-left: auto; }
.list-bar + .table-wrap { border-radius: 0; }
.list-foot { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 14px; background: var(--card); border: 1px solid var(--line); border-top: 0; border-radius: 0 0 var(--radius) var(--radius); color: var(--muted); font-size: 14px; }
.list-foot .pager { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.list-foot select { width: auto; margin: 0; padding: 6px 8px; }
.list-foot button { padding: 6px 12px; }
.empty { padding: 36px 16px; text-align: center; color: var(--muted); }

/* Таблицы */
.table-wrap { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; background: var(--card); }
:not(.table-wrap) > .table { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.table th, .table td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: #FBF8F9; white-space: nowrap; }
.table tbody tr:hover td { background: #FDFAFB; }
.table tr:last-child td { border-bottom: 0; }
.table input, .table select, .table textarea { margin-top: 0; }
.table .title-cell a { font-weight: 600; color: var(--text); }
.table .title-cell a:hover { color: var(--accent); }
.table .sub { font-size: 13px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.table .num { white-space: nowrap; color: var(--muted); }
.row-actions { white-space: nowrap; text-align: right; }

.status, .chip { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--bg); color: var(--muted); }
.status.s-Published { background: var(--ok-tint); color: var(--ok); }
.status.s-Reviewed { background: var(--warn-tint); color: var(--warn); }
.status.s-Draft { background: var(--tint); color: var(--accent-dark); }

/* Картинки */
.thumb { width: 36px; height: 36px; object-fit: contain; display: block; }
.image-box { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 14px; background: var(--card); font-weight: 600; font-size: 13px; }
.preview { width: 160px; height: 160px; object-fit: contain; display: flex; align-items: center; justify-content: center; margin: 10px 0; background: var(--tint); border-radius: 50%; padding: 18px; }
.preview.empty, .cover.empty { color: var(--muted); font-weight: normal; }
.cover { width: 100%; max-height: 180px; object-fit: cover; display: flex; align-items: center; justify-content: center; margin: 10px 0; background: var(--tint); border-radius: var(--radius); min-height: 100px; }

/* Визуальный редактор статей */
.field-title { font-weight: 600; font-size: 13px; margin-bottom: 5px; }
.editor-box { border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); overflow: hidden; }
.toolbar { display: flex; flex-wrap: wrap; gap: 4px; padding: 8px; border-bottom: 1px solid var(--line); background: #FBF8F9; }
.toolbar button { padding: 5px 10px; font-size: 13px; font-weight: 500; border-radius: 8px; }
.toolbar .sep { width: 1px; background: var(--line); margin: 2px 4px; }
.editor { min-height: 360px; max-height: 70vh; overflow-y: auto; padding: 16px 18px; font-size: 16px; line-height: 1.6; outline: none; }
.editor:focus { box-shadow: inset 0 0 0 2px var(--accent); }
.editor p { margin: 0 0 12px; }
.editor h2 { font-size: 21px; margin: 20px 0 10px; }
.editor h3 { font-size: 17px; margin: 16px 0 8px; }
.editor ul, .editor ol { margin: 0 0 12px; padding-left: 24px; }
.editor blockquote { margin: 0 0 12px; padding: 8px 14px; border-left: 3px solid var(--accent); background: var(--tint); border-radius: 0 8px 8px 0; }
.editor img { max-width: 100%; height: auto; border-radius: 10px; margin: 8px 0; }
.editor a { text-decoration: underline; }
.inline-upload { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 10px 0 16px; font-size: 13px; color: var(--muted); }

/* Результаты общего поиска */
.results { list-style: none; margin: 0; padding: 0; }
.results li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.results li:last-child { border-bottom: 0; }
.results a { font-weight: 600; }
.results .sub { font-size: 13px; color: var(--muted); }

/* Вход */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { width: 100%; max-width: 380px; padding: 28px; border-radius: 20px; }
.login-card .brand { padding: 0; margin-bottom: 12px; color: var(--accent); font-size: 24px; font-weight: 800; letter-spacing: .06em; }
.login-card h1 { font-size: 20px; margin-bottom: 18px; }
.login-card button { width: 100%; margin-top: 4px; justify-content: center; }
.login-card img { display: block; margin: 8px auto 12px; }
.login-card code { display: block; margin-bottom: 14px; overflow-wrap: anywhere; }
.login-card pre { margin: 10px 0 16px; padding: 12px 14px; border-radius: 12px; background: var(--bg, #f6f4f2); font-size: 15px; line-height: 1.6; text-align: center; }
.login-card .button-link { display: block; padding: 12px 16px; border-radius: 12px; background: var(--accent); color: #fff; font-weight: 700; text-align: center; text-decoration: none; }

#blazor-error-ui { display: none; position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; padding: 12px 20px; background: var(--accent-dark); color: #fff; }
#blazor-error-ui a { color: #fff; text-decoration: underline; }

/* Узкие экраны: меню выезжает по кнопке, второстепенное в полосе скрывается */
@media (max-width: 1100px) {
    .topbar-date span { display: none; }
    .user-text { display: none; }
}

@media (max-width: 860px) {
    .sidebar { position: fixed; z-index: 15; left: 0; transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow); }
    .nav-toggle:checked ~ .sidebar { transform: none; }
    .nav-toggle:checked ~ .scrim { display: block; position: fixed; inset: 0; z-index: 10; background: rgba(42, 22, 32, .35); }
    .menu-button { display: grid; }
    .topbar { padding: 0 12px; gap: 10px; }
    .topbar-date { display: none; }
    .content { padding: 18px 14px 40px; }
    .grid-2, .two-columns { grid-template-columns: 1fr; }
}

/* Комментарии статьи в редакторе: ответы с отступом под своим комментарием */
.comments-panel { margin-top: 18px; }
.comment-row { padding: 10px 0; border-top: 1px solid var(--line); }
.comment-row:first-of-type { border-top: 0; }
.comment-row.reply { margin-left: 32px; padding-left: 12px; border-left: 2px solid var(--line); border-top: 0; }
.comment-row.hidden .comment-text { opacity: .55; }
.comment-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; }
.comment-meta .row-actions { margin-left: auto; }
.comment-text { white-space: pre-wrap; margin-top: 4px; }

/* Выбор недель справочной статьи: сетка номеров 0–42, отмеченные — акцентом */
.week-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 6px; margin: 6px 0 4px; }
.week-cell { height: 36px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--text); font: inherit; font-size: 13px; cursor: pointer; }
.week-cell:hover { border-color: var(--accent); }
.week-cell.on { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }
label.check { display: flex; align-items: center; gap: 8px; }

.incoming-links { list-style: none; margin: 6px 0 0; padding: 0; font-size: 14px; }
.incoming-links li { padding: 4px 0; display: flex; gap: 8px; align-items: center; justify-content: space-between; }
/* Колонка формы не шире экрана: длинное содержимое не растягивает страницу. */
.grid-2 > div { min-width: 0; }
fieldset.form { min-width: 0; }

/* Окно «Ссылка на статью»: поиск и выбор статьи поверх страницы. */
.modal-overlay { position: fixed; inset: 0; z-index: 100; background: rgba(43, 33, 30, .45); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px 16px; }
.modal { width: 100%; max-width: 680px; max-height: 88vh; display: flex; flex-direction: column; gap: 10px; background: var(--card); border-radius: var(--radius); box-shadow: 0 18px 50px rgba(0, 0, 0, .25); padding: 18px 20px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.modal-head h2 { margin: 0; font-size: 19px; }
.modal > p { margin: 0; font-size: 13px; }
.modal-search { margin: 0; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip-button { padding: 5px 12px; font-size: 13px; border-radius: 999px; }
.chip-button.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.pick-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; min-height: 120px; border: 1px solid var(--line); border-radius: 10px; }
.pick-list li + li { border-top: 1px solid var(--line); }
.pick-list button { width: 100%; display: flex; flex-direction: column; align-items: flex-start; gap: 3px; padding: 9px 12px; border: 0; border-radius: 0; background: none; text-align: left; white-space: normal; font-weight: 500; }
.pick-list button:hover, .pick-list button:focus-visible { background: var(--tint); }
.pick-title { overflow-wrap: anywhere; }
.pick-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: var(--muted); font-size: 12px; font-weight: normal; }
.modal-foot { font-size: 13px; }

/* Пользователи приложения */
.status.s-blocked { background: var(--tint); color: var(--accent-dark); }
.facts { display: grid; grid-template-columns: minmax(130px, auto) 1fr; gap: 6px 16px; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.danger-note { padding: 10px 12px; border-radius: 10px; background: var(--tint); color: var(--accent-dark); font-size: 13px; }
button.danger-action { background: var(--accent-dark); border-color: var(--accent-dark); color: #fff; }

/* Сотрудники */
.role-picker { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.role-picker legend { padding: 0; margin-bottom: 6px; font-weight: 600; }
.role-picker label { display: flex; align-items: center; gap: 8px; margin: 0; font-weight: 500; }
.role-picker input { width: auto; margin: 0; }
.temp-password { display: block; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); font-size: 18px; letter-spacing: .04em; user-select: all; overflow-wrap: anywhere; }
.login { flex-direction: column; gap: 14px; }
.login-back { font-size: 14px; }
