/* Портал «Авалон» — общие стили.
   Цвета задаются переменными ниже; тёмная тема переопределяет их в [data-theme="dark"].
   Стили своего раздела кладите в <style> шаблона, классы — с префиксом раздела (.cb-…). */

/* ---------- Переменные ---------- */
:root {
  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Roboto, Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, "Liberation Mono", monospace;

  --bg: #f4f4f5;            /* фон страницы */
  --surface: #ffffff;       /* карточки, меню */
  --surface-2: #fafafa;     /* шапки таблиц, вторичные панели */
  --hover: #f4f4f5;         /* наведение */
  --line: #e4e4e7;          /* рамки */
  --line-strong: #d4d4d8;   /* рамки полей и кнопок */
  --text: #18181b;
  --text-2: #52525b;
  --text-3: #71717a;
  --primary: #18181b;       /* основная кнопка */
  --primary-hover: #3f3f46;
  --on-primary: #ffffff;
  --side-bg: #ffffff;
  --side-active: #f4f4f5;

  --ok: #15803d;   --ok-bg: #f0fdf4;   --ok-line: #bbf7d0;
  --bad: #b91c1c;  --bad-bg: #fef2f2;  --bad-line: #fecaca;
  --warn: #a16207; --warn-bg: #fefce8; --warn-line: #fde68a;
  --info: #1d4ed8; --info-bg: #eff6ff; --info-line: #bfdbfe;

  --ring: 0 0 0 3px rgba(24, 24, 27, .13);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .04);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, .06);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, .12), 0 2px 6px rgba(0, 0, 0, .05);

  --radius: 12px;
  --radius-sm: 8px;
  --side-w: 248px;
  --side-w-mini: 64px;

  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #0f0f11;
  --surface: #18181b;
  --surface-2: #1d1d21;
  --hover: #26262b;
  --line: #2a2a2f;
  --line-strong: #3f3f46;
  --text: #f4f4f5;
  --text-2: #b4b4bb;
  --text-3: #8b8b94;
  --primary: #f4f4f5;
  --primary-hover: #d4d4d8;
  --on-primary: #18181b;
  --side-bg: #131316;
  --side-active: #26262b;

  --ok: #4ade80;   --ok-bg: rgba(74, 222, 128, .09);  --ok-line: rgba(74, 222, 128, .28);
  --bad: #f87171;  --bad-bg: rgba(248, 113, 113, .09); --bad-line: rgba(248, 113, 113, .3);
  --warn: #fbbf24; --warn-bg: rgba(251, 191, 36, .08); --warn-line: rgba(251, 191, 36, .28);
  --info: #60a5fa; --info-bg: rgba(96, 165, 250, .09); --info-line: rgba(96, 165, 250, .3);

  --ring: 0 0 0 3px rgba(244, 244, 245, .16);
  --shadow-sm: none;
  --shadow-md: 0 2px 10px rgba(0, 0, 0, .35);
  --shadow-lg: 0 14px 36px rgba(0, 0, 0, .55);

  color-scheme: dark;
}

/* ---------- Основа ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 15px/1.5 var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 600; }
p { margin: 0 0 .75em; }
p:last-child { margin-bottom: 0; }
a { color: inherit; text-decoration-color: var(--line-strong); text-underline-offset: 3px; }
a:hover { text-decoration-color: currentColor; }
img, svg { vertical-align: middle; }
svg.i { flex: none; }
hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
code { font-family: var(--mono); font-size: .88em; background: var(--hover); border-radius: 5px; padding: 1px 5px; }
pre.code {
  font: 13px/1.55 var(--mono); background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 12px 14px; overflow: auto; margin: 0 0 12px;
}
:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
::selection { background: rgba(113, 113, 122, .28); }
[hidden] { display: none !important; }

.muted { color: var(--text-3); }
.small { font-size: 13px; }
.num, .tnum { font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.stack > * + * { margin-top: 14px; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- Каркас ---------- */
.app {
  display: grid;
  grid-template-columns: var(--side-w) minmax(0, 1fr);
  min-height: 100vh;
  transition: grid-template-columns .2s ease;
}
.side {
  position: sticky; top: 0; height: 100vh; width: var(--side-w);
  display: flex; flex-direction: column;
  background: var(--side-bg);
  border-right: 1px solid var(--line);
  padding: 14px 12px 12px;
  z-index: 40;
  transition: width .2s ease, box-shadow .2s ease;
}
.brand {
  display: flex; align-items: center; gap: 11px; min-width: 0; overflow: hidden;
  padding: 4px 4px 16px; text-decoration: none; color: var(--text);
}
.logo {
  flex: none; width: 32px; height: 32px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--primary); color: var(--on-primary);
  font-weight: 700; font-size: 16px; letter-spacing: -.02em;
}
.brand-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.brand-text b { font-size: 15px; font-weight: 650; white-space: nowrap; }
.brand-text small { font-size: 12px; color: var(--text-3); white-space: nowrap; }

.side-scroll { flex: 1 1 auto; min-height: 0; overflow: hidden auto; margin: 0 -4px; padding: 0 4px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a, .nav button {
  display: flex; align-items: center; gap: 11px; overflow: hidden;
  height: 38px; padding: 0 11px; border-radius: var(--radius-sm);
  color: var(--text-2); text-decoration: none; font: inherit; font-size: 14.5px;
  background: none; border: 0; width: 100%; cursor: pointer; text-align: left;
}
.nav a:hover, .nav button:hover { background: var(--hover); color: var(--text); }
.nav a.active { background: var(--side-active); color: var(--text); font-weight: 600; }
.nav a.active svg.i { color: var(--text); }
.nav-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-badge {
  font-size: 11px; font-weight: 500; line-height: 18px; padding: 0 7px;
  border-radius: 999px; color: var(--text-3); background: var(--hover); border: 1px solid var(--line);
}
.nav-group { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }

.side-user { position: relative; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.user-btn {
  display: flex; align-items: center; gap: 10px; width: 100%; overflow: hidden;
  padding: 6px; border: 0; border-radius: var(--radius-sm);
  background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer;
}
.user-btn:hover, .user-btn[aria-expanded="true"] { background: var(--hover); }
.user-text { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.25; }
.user-text b { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-text small { font-size: 12px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-btn > svg.i { color: var(--text-3); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: none; }
.content {
  width: 100%; max-width: 1400px; margin: 0 auto;
  padding: 28px 32px 56px;
  outline: none;
}
.side-backdrop { display: none; }

.page-wide .content { max-width: none; }

/* Кнопка сворачивания — круглая, на правой кромке меню */
.side-toggle {
  position: absolute; top: 22px; right: -12px; z-index: 2;
  width: 24px; height: 24px; padding: 0; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text-2);
  box-shadow: var(--shadow-sm); cursor: pointer;
  transition: background-color .12s, border-color .12s, color .12s;
}
.side-toggle:hover { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.side-toggle::before { content: ""; position: absolute; inset: -8px; border-radius: 50%; } /* попадать проще: 40×40 */
.side-toggle svg.i { transition: transform .2s ease; }
.brand-text, .nav-label, .nav-badge, .user-text, .user-btn > svg.i { transition: opacity .15s ease; }

/* Свёрнутое меню: остаются значки. При наведении раскрывается поверх страницы (side-peek), не сдвигая её. */
@media (min-width: 961px) {
  .side-collapsed .app { grid-template-columns: var(--side-w-mini) minmax(0, 1fr); }
  .side-collapsed .side { width: var(--side-w-mini); }
  .side-collapsed .side-toggle svg.i { transform: rotate(180deg); }
  .side-collapsed:not(.side-peek) :is(.brand-text, .nav-label, .nav-badge, .user-text, .user-btn > svg.i) { opacity: 0; }
  .side-collapsed.side-peek .side { width: var(--side-w); box-shadow: var(--shadow-lg); }
  .side-collapsed .menu { left: 0; right: auto; width: 230px; }
}

/* ---------- Заголовок страницы ---------- */
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px;
  flex-wrap: wrap; margin-bottom: 22px;
}
.page-head > :first-child { flex: 1 1 360px; min-width: 0; }
.page-head h1 { font-size: 24px; letter-spacing: -.01em; }
.page-sub { color: var(--text-2); margin: 6px 0 0; max-width: 72ch; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.back-link {
  display: inline-flex; align-items: center; gap: 6px; margin-bottom: 10px;
  font-size: 13.5px; color: var(--text-3); text-decoration: none;
}
.back-link:hover { color: var(--text); }

/* ---------- Карточки ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 20px 22px;
  margin-bottom: 16px;
}
.card > h2, .card-head h2 { font-size: 16px; margin-bottom: 14px; }
.card.narrow { max-width: 680px; }
.card.flush { padding: 0; overflow: hidden; }
.card.flush > h2, .card.flush > .card-head { padding: 16px 20px 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head h2 { margin-bottom: 0; }
.card.flush > .card-head { margin-bottom: 12px; }
.card-sub { color: var(--text-2); font-size: 14px; margin: -8px 0 14px; }

.split { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; align-items: start; }
.split > * { margin-bottom: 0; }
.split > .stack-col > .card { margin-bottom: 16px; }

/* ---------- Кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 14px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  font: inherit; font-size: 14px; font-weight: 500; line-height: 1;
  text-decoration: none; white-space: nowrap; cursor: pointer; user-select: none;
  transition: background-color .12s, border-color .12s, color .12s;
}
.btn:hover { background: var(--hover); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn.disabled { opacity: .5; pointer-events: none; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--hover); color: var(--text); }
.btn.danger { color: var(--bad); border-color: var(--bad-line); }
.btn.danger:hover { background: var(--bad-bg); }
.btn.danger.primary { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; gap: 6px; }
.btn.icon { width: 36px; padding: 0; }
.btn.sm.icon { width: 30px; }
.btn.block { display: flex; width: 100%; }
.btn.is-busy { pointer-events: none; opacity: .85; }
.btn.is-busy::before {
  content: ""; width: 13px; height: 13px; flex: none;
  border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%;
  animation: spin .7s linear infinite;
}
.btn.is-busy > svg.i { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Формы ---------- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px 18px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 500; color: var(--text-2); min-width: 0; }
.field.wide { grid-column: 1 / -1; }
.hint { font-size: 12.5px; font-weight: 400; color: var(--text-3); }

input[type="text"], input[type="password"], input[type="email"], input[type="number"], input[type="search"],
input[type="date"], input[type="datetime-local"], input[type="time"], input[type="tel"], input[type="url"],
select, textarea {
  width: 100%; min-width: 0; height: 38px; padding: 0 11px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  font: inherit; font-size: 14.5px; font-weight: 400;
  transition: border-color .12s, box-shadow .12s;
}
textarea { height: auto; min-height: 96px; padding: 9px 11px; line-height: 1.5; resize: vertical; }
select {
  appearance: none; padding-right: 34px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2371717a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
input::placeholder, textarea::placeholder { color: var(--text-3); opacity: 1; }
input:hover, select:hover, textarea:hover { border-color: var(--text-3); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--text-2); box-shadow: var(--ring); }
input:disabled, select:disabled, textarea:disabled { background: var(--surface-2); color: var(--text-3); cursor: not-allowed; }
input[type="checkbox"], input[type="radio"] { width: 16px; height: 16px; margin: 0; accent-color: var(--primary); cursor: pointer; }
input[type="file"] { font: inherit; font-size: 14px; }

.check { display: inline-flex; align-items: center; gap: 9px; font-size: 14px; font-weight: 400; color: var(--text); cursor: pointer; }
.input-wrap { position: relative; display: block; }
.input-wrap > input { padding-right: 42px; }
.input-btn {
  position: absolute; top: 50%; right: 4px; transform: translateY(-50%);
  width: 32px; height: 30px; border: 0; border-radius: 6px; background: none;
  color: var(--text-3); cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
}
.input-btn:hover { color: var(--text); background: var(--hover); }
.input-icon { position: relative; display: block; }
.input-icon > svg.i { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.input-icon > input { padding-left: 36px; }

.actions-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 20px; }
.actions-row .spacer { flex: 1; }

label.drop {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 26px 20px; border: 1.5px dashed var(--line-strong); border-radius: var(--radius);
  background: var(--surface); color: var(--text-2); text-align: center; cursor: pointer;
  font-size: 14px; font-weight: 400; transition: border-color .12s, background-color .12s;
}
label.drop:hover, label.drop.is-over { border-color: var(--text-3); background: var(--surface-2); }
label.drop > svg.i { color: var(--text-3); }
label.drop input[type="file"] { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
label.drop:focus-within { border-color: var(--text-2); box-shadow: var(--ring); }
.drop-file { font-weight: 500; color: var(--text); word-break: break-word; }
label.drop.has-file { border-style: solid; }

/* ---------- Сообщения и метки ---------- */
.alert {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 11px 14px; margin-bottom: 14px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--text); font-size: 14px;
}
.alert > svg.i { margin-top: 1px; color: var(--text-3); }
.alert.ok   { background: var(--ok-bg);   border-color: var(--ok-line); }
.alert.ok > svg.i { color: var(--ok); }
.alert.bad  { background: var(--bad-bg);  border-color: var(--bad-line); }
.alert.bad > svg.i { color: var(--bad); }
.alert.warn { background: var(--warn-bg); border-color: var(--warn-line); }
.alert.warn > svg.i { color: var(--warn); }
.alert.info { background: var(--info-bg); border-color: var(--info-line); }
.alert.info > svg.i { color: var(--info); }

.tag {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px;
  border: 1px solid var(--line); border-radius: 6px; background: var(--surface-2);
  color: var(--text-2); font-size: 12px; font-weight: 500; line-height: 1; white-space: nowrap; vertical-align: middle;
}
.tag.ok   { color: var(--ok);   background: var(--ok-bg);   border-color: var(--ok-line); }
.tag.bad  { color: var(--bad);  background: var(--bad-bg);  border-color: var(--bad-line); }
.tag.warn { color: var(--warn); background: var(--warn-bg); border-color: var(--warn-line); }
.tag.info { color: var(--info); background: var(--info-bg); border-color: var(--info-line); }
.badge {
  display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px;
  padding: 0 6px; border-radius: 999px; background: var(--primary); color: var(--on-primary);
  font-size: 11.5px; font-weight: 600; line-height: 1;
}

/* ---------- Таблицы ---------- */
.scroll { overflow: auto; max-width: 100%; }
table.grid { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; }
table.grid th {
  position: sticky; top: 0; z-index: 1;
  text-align: left; font-weight: 500; font-size: 12.5px; color: var(--text-3);
  padding: 10px 14px; background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.grid td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.grid tbody tr:last-child td { border-bottom: 0; }
table.grid tbody tr:hover td { background: var(--surface-2); }
table.grid tr.current td { background: var(--info-bg); }
table.grid tr.missing td { background: var(--bad-bg); }
table.grid tr.dim td { color: var(--text-3); }
table.grid .num { text-align: right; }
.card.flush table.grid th:first-child, .card.flush table.grid td:first-child { padding-left: 20px; }
.card.flush table.grid th:last-child, .card.flush table.grid td:last-child { padding-right: 20px; }
.card > .scroll { border: 1px solid var(--line); border-radius: var(--radius-sm); }
.card.flush > .scroll { border: 0; border-radius: 0; }
.card.flush > h2 + .scroll, .card.flush > .card-head + .scroll { border-top: 1px solid var(--line); }

.pager {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 12px 20px; border-top: 1px solid var(--line); font-size: 13.5px; color: var(--text-2);
}
.pager-nav { display: flex; gap: 6px; }

/* ---------- Прочее ---------- */
.sticky-bar {
  position: sticky; bottom: 12px; z-index: 5;
  display: flex; align-items: center; justify-content: flex-end; gap: 10px; flex-wrap: wrap;
  margin-top: 16px; padding: 12px 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}
.sticky-bar .grow { flex: 1; color: var(--text-2); font-size: 14px; }

.empty { text-align: center; padding: 44px 20px; color: var(--text-2); }
.empty-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 52px; height: 52px; border-radius: 50%; background: var(--hover); color: var(--text-3); margin-bottom: 14px;
}
.empty h2, .empty h3 { font-size: 16px; color: var(--text); margin-bottom: 6px; }
.empty p { max-width: 48ch; margin: 0 auto; }
.empty .actions-row { justify-content: center; }
.empty.compact { padding: 24px 12px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.tile {
  display: flex; align-items: flex-start; gap: 14px; padding: 18px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); color: var(--text); text-decoration: none;
  transition: border-color .15s, box-shadow .15s;
}
.tile:hover { border-color: var(--line-strong); box-shadow: var(--shadow-md); }
.tile-icon {
  flex: none; width: 40px; height: 40px; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--hover); color: var(--text);
}
.tile-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.tile-title { display: flex; align-items: center; gap: 8px; font-size: 15.5px; font-weight: 600; }
.tile-text { font-size: 13.5px; color: var(--text-2); }

.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: flex; align-items: flex-start; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.feed li:first-child { padding-top: 2px; }
.feed li:last-child { border-bottom: 0; padding-bottom: 0; }
.feed-body { flex: 1; min-width: 0; }
.feed-action { font-size: 14px; }
.feed-meta { font-size: 12.5px; color: var(--text-3); margin-top: 1px; }
.feed-time { flex: none; font-size: 12.5px; color: var(--text-3); white-space: nowrap; }
.link-more { display: inline-block; margin-top: 14px; font-size: 13.5px; color: var(--text-2); }

.avatar {
  flex: none; width: 32px; height: 32px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--hover); color: var(--text-2); border: 1px solid var(--line);
  font-size: 12px; font-weight: 600; letter-spacing: .02em;
}
.avatar.sm { width: 28px; height: 28px; font-size: 11px; }
.avatar.lg { width: 44px; height: 44px; font-size: 15px; }
.person { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; min-width: 0; }
.person b { font-weight: 600; display: block; }
.person small { display: block; font-size: 12.5px; color: var(--text-3); }
a.person:hover b { text-decoration: underline; text-underline-offset: 3px; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs a {
  padding: 9px 12px; margin-bottom: -1px; border-bottom: 2px solid transparent;
  color: var(--text-2); text-decoration: none; font-size: 14px; white-space: nowrap;
}
.tabs a:hover { color: var(--text); }
.tabs a.active { color: var(--text); border-bottom-color: var(--text); font-weight: 600; }

dl.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 9px 18px; margin: 0; font-size: 14px; }
dl.kv dt { color: var(--text-3); }
dl.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); margin-right: 7px; vertical-align: 1px; }
.status-dot.ok { background: var(--ok); }
.status-dot.bad { background: var(--bad); }
.status-dot.warn { background: var(--warn); }

.form-error-text { white-space: pre-line; }

ol.steps { margin: 0 0 16px; padding-left: 20px; color: var(--text-2); font-size: 14px; }
ol.steps li { margin-bottom: 6px; }

ul.checks { list-style: none; margin: 0 0 16px; padding: 0; }
ul.checks li { display: flex; align-items: flex-start; gap: 4px; padding: 8px 0; border-bottom: 1px solid var(--line); }
ul.checks li:first-child { padding-top: 0; }
ul.checks .status-dot { margin-top: 7px; }
ul.checks b { display: block; font-size: 14px; font-weight: 500; }
ul.checks small { display: block; font-size: 12.5px; color: var(--text-3); }

dl.log-details {
  display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 2px 12px;
  margin: 6px 0 0; font-size: 12.5px; color: var(--text-2);
}
dl.log-details dt { color: var(--text-3); }
dl.log-details dd { margin: 0; overflow-wrap: anywhere; }
dl.log-details dd.full { grid-column: 1 / -1; }

/* ---------- Списки выбора (флажки с подписями) ---------- */
.choices { display: flex; flex-direction: column; gap: 2px; margin: 0 -10px; }
.choices.cols { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 2px 8px; }
.choices.scroll-list { max-height: 480px; overflow-y: auto; }
.choices.is-off { opacity: .45; pointer-events: none; }
label.choice {
  display: flex; align-items: flex-start; gap: 11px; padding: 9px 10px;
  border-radius: var(--radius-sm); color: var(--text); font-size: 14px; font-weight: 400; cursor: pointer;
}
label.choice:hover { background: var(--hover); }
label.choice > input { flex: none; margin-top: 2px; }
label.choice > svg.i { color: var(--text-3); margin-top: 1px; }
label.choice > .avatar { margin-top: -5px; }
label.choice.dim .choice-title { color: var(--text-3); }
label.choice.lead { margin: 0 0 8px; border: 1px solid var(--line); background: var(--surface-2); }
label.choice.lead:hover { background: var(--hover); }
.choice-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.choice-title { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; font-weight: 500; line-height: 1.35; }
.choice-title > svg.i { color: var(--text-2); }
.choice-hint { font-size: 12.5px; color: var(--text-3); line-height: 1.4; }
.form-section { font-size: 14px; margin: 24px 0 2px; }
.form-section-hint { margin: 0 0 10px; }

/* ---------- Доступ, группы ---------- */
.tag-list { display: inline-flex; flex-wrap: wrap; gap: 4px; vertical-align: middle; }
a.tag { text-decoration: none; }
.warn-text { color: var(--warn); }
a.tag:hover { border-color: var(--line-strong); color: var(--text); }
.tag > svg.i { margin-left: -2px; }
.tab-count { margin-left: 6px; color: var(--text-3); font-weight: 400; font-variant-numeric: tabular-nums; }
.inline-field { display: inline-flex; align-items: center; gap: 10px; font-size: 13.5px; color: var(--text-2); }
.inline-field select { width: auto; min-width: 220px; height: 34px; }
form.card-head { flex-wrap: wrap; }
.group-name { font-weight: 600; text-decoration: none; }
.group-name:hover { text-decoration: underline; }
.group-desc { display: block; font-size: 12.5px; color: var(--text-3); margin-top: 1px; }
ul.access-list { list-style: none; margin: 0; padding: 0; }
ul.access-list li { display: flex; align-items: center; gap: 10px; padding: 8px 0; font-size: 14px; }
ul.access-list li:not([hidden]) ~ li:not([hidden]) { border-top: 1px solid var(--line); }
ul.access-list svg.i { color: var(--text-3); }
ul.access-list a { text-decoration: none; }
ul.access-list a:hover { text-decoration: underline; }
.access-full { display: flex; align-items: flex-start; gap: 10px; font-size: 14px; }
.access-full > svg.i { color: var(--ok); margin-top: 1px; }
.group-form .sticky-bar { justify-content: flex-start; }

/* ---------- Меню пользователя ---------- */
.menu {
  position: absolute; left: 0; right: 0; bottom: calc(100% + 6px); z-index: 50;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: 6px;
}
.menu a, .menu button.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 10px; border: 0; border-radius: 7px; background: none;
  color: var(--text); font: inherit; font-size: 14px; text-align: left; text-decoration: none; cursor: pointer;
}
.menu a:hover, .menu button.menu-item:hover { background: var(--hover); }
.menu form { margin: 0; }
.menu-sep { height: 1px; background: var(--line); margin: 6px 4px; }
.menu-label { padding: 6px 10px 4px; font-size: 12px; color: var(--text-3); }
.seg { display: flex; gap: 2px; padding: 3px; margin: 0 4px 4px; background: var(--hover); border-radius: 8px; }
.seg button {
  flex: 1; min-width: 0; display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  padding: 7px 2px 6px; border: 0; border-radius: 6px; background: none; color: var(--text-2);
  font: inherit; font-size: 12px; line-height: 1.2; cursor: pointer;
}
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-md); }

/* ---------- Всплывающие сообщения, загрузка, диалог ---------- */
.toasts {
  position: fixed; right: 20px; bottom: 20px; z-index: 80;
  display: flex; flex-direction: column; gap: 8px; width: min(380px, calc(100vw - 40px));
  pointer-events: none;
}
.toast {
  display: flex; align-items: flex-start; gap: 10px; padding: 12px 12px 12px 14px;
  background: var(--text); color: var(--bg); border-radius: 10px; box-shadow: var(--shadow-lg);
  font-size: 14px; pointer-events: auto; animation: toast-in .18s ease-out;
}
.toast > svg.i { margin-top: 1px; }
.toast.ok > svg.i { color: #4ade80; }
.toast.bad > svg.i { color: #f87171; }
.toast.warn > svg.i { color: #fbbf24; }
.toast.info > svg.i { color: #93c5fd; }
[data-theme="dark"] .toast.ok > svg.i { color: var(--ok); filter: brightness(.7); }
[data-theme="dark"] .toast.bad > svg.i { color: #dc2626; }
[data-theme="dark"] .toast.warn > svg.i { color: #b45309; }
[data-theme="dark"] .toast.info > svg.i { color: #2563eb; }
.toast-text { flex: 1; min-width: 0; padding-top: 0; }
.toast-close {
  flex: none; width: 24px; height: 24px; margin: -2px -2px 0 0; border: 0; border-radius: 6px;
  background: none; color: inherit; opacity: .6; cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
}
.toast-close:hover { opacity: 1; }
.toast.out { animation: toast-out .16s ease-in forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(6px); } }

.progress {
  position: fixed; top: 0; left: 0; z-index: 90; height: 2px; width: 0;
  background: var(--text); opacity: 0; transition: width .25s ease, opacity .3s ease;
  pointer-events: none;
}
.progress.on { opacity: 1; }

dialog.modal {
  width: min(440px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg);
}
dialog.modal::backdrop { background: rgba(9, 9, 11, .45); }
.modal-body { padding: 22px 22px 6px; font-size: 15px; }
.modal-body h3 { font-size: 16px; margin-bottom: 6px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 18px 22px 20px; }

/* ---------- Страница ошибки ---------- */
.error-page { max-width: 560px; margin: 9vh auto 0; text-align: center; }
.error-code { display: block; font-size: 64px; font-weight: 700; line-height: 1; letter-spacing: -.03em; color: var(--line-strong); margin-bottom: 18px; }
.error-page h1 { font-size: 22px; margin-bottom: 10px; }
.error-page p { color: var(--text-2); }
.error-page .actions-row { justify-content: center; }

/* ---------- Вход ---------- */
.auth-body { background: var(--bg); }
.auth { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px 16px; }
.auth-box { width: min(440px, 100%); }
.auth-brand { display: flex; align-items: center; justify-content: center; gap: 11px; margin-bottom: 22px; color: var(--text); text-decoration: none; }
.auth-brand .logo { width: 38px; height: 38px; font-size: 19px; border-radius: 10px; }
.auth-brand .brand-text b { font-size: 17px; }
.auth-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow-md); padding: 28px 28px 30px;
}
.auth-card h1 { font-size: 20px; margin-bottom: 6px; }
.auth-card .lead { color: var(--text-2); font-size: 14px; margin-bottom: 20px; }
.auth-foot { margin-top: 18px; text-align: center; font-size: 12.5px; color: var(--text-3); }

/* ---------- Главная ---------- */
.home-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(300px, 1fr); gap: 16px; align-items: start; }
.home-grid .tiles { grid-template-columns: 1fr; gap: 12px; }
.home-grid > .card { margin-bottom: 0; }

/* ---------- Адаптивность ---------- */
@media (max-width: 1100px) {
  .split, .home-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 960px) {
  .app, .side-collapsed .app { grid-template-columns: minmax(0, 1fr); }
  .side {
    position: fixed; left: 0; top: 0; bottom: 0; width: min(280px, 86vw); height: auto; overflow-y: auto;
    transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow-lg);
  }
  .side-toggle { display: none; }
  .drawer-open .side { transform: none; }
  .drawer-open .side-backdrop { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(9, 9, 11, .4); }
  .topbar {
    display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 30;
    height: 54px; padding: 0 12px; background: var(--side-bg); border-bottom: 1px solid var(--line);
  }
  .topbar .brand { padding: 0; }
  .content { padding: 20px 16px 48px; }
}
@media (max-width: 640px) {
  .page-head { align-items: flex-start; flex-direction: column; }
  .page-head > :first-child { flex: none; }
  .group-form .sticky-bar .btn.danger { width: 36px; padding: 0; }
  .group-form .sticky-bar .btn.danger [data-label] { display: none; }
  .page-head h1 { font-size: 21px; }
  .card { padding: 16px; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .auth-card { padding: 22px 18px 24px; }
  .toasts { right: 12px; bottom: 12px; width: calc(100vw - 24px); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
@media print {
  .side, .topbar, .page-actions, .toasts, .progress, .sticky-bar { display: none !important; }
  .app { display: block; }
  .content { padding: 0; max-width: none; }
  .card { box-shadow: none; break-inside: avoid; }
  body { background: #fff; }
}

/* menu: значок меню (клош, тот же, что favicon) вместо первой буквы названия, а название — его цветом
   (CORE.md, «Изменения ядра»). В тёмной теме название светлее, чтобы читалось. */
:root { --brand-color: #6C222E; }
[data-theme="dark"] { --brand-color: #e0727f; }
.logo.logo-mark { background: url(favicon.svg) center / cover no-repeat; color: transparent; }
.brand-text b { color: var(--brand-color); }
