/*
 * Общий набор интерфейса: токены и компоненты.
 * Правила - DESIGN.md рядом с этим файлом: цвета только здесь и только OKLCH,
 * один фиолетовый акцент, главная кнопка нейтральная.
 *
 * Всё с префиксом ui- и базовые стили только под body.ui-body: страница
 * подключает набор и переезжает на него частями, старые классы не задеваются.
 * Тема системная; data-theme="light" | "dark" на <html> - выбор пользователя.
 */

@font-face {
  font-family: Onest;
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("fonts/onest-cyrillic.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: Onest;
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("fonts/onest-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 100 800;
  font-display: swap;
  src: url("fonts/jetbrains-mono-cyrillic.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 100 800;
  font-display: swap;
  src: url("fonts/jetbrains-mono-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ---------- Токены ----------
   Шкалы светлоты и статусы - как в arbi-lens; своё лицо дают холодные
   нейтрали (оттенок 270) и фиолетовый акцент (292). Выбрано 16.09.2026. */

:root {
  color-scheme: light;
  --ui-canvas: oklch(0.975 0.0072 270);
  --ui-surface: oklch(1 0 0);
  --ui-surface-2: oklch(0.955 0.0072 270);
  --ui-surface-3: oklch(0.93 0.009 270);
  --ui-line: oklch(0.915 0.009 270);
  --ui-line-strong: oklch(0.83 0.0108 270);
  --ui-fg: oklch(0.26 0.0144 270);
  --ui-fg-muted: oklch(0.46 0.0144 270);
  --ui-fg-subtle: oklch(0.53 0.0144 270);
  --ui-primary: oklch(0.26 0.0144 270);
  --ui-primary-hover: oklch(0.34 0.0144 270);
  --ui-primary-fg: oklch(0.985 0.0036 270);
  --ui-accent: oklch(0.5 0.17 292);
  --ui-accent-hover: oklch(0.45 0.17 292);
  --ui-accent-soft: oklch(0.955 0.025 292);
  --ui-accent-fg: oklch(1 0 0);
  --ui-success: oklch(0.52 0.12 155);
  --ui-success-soft: oklch(0.96 0.03 155);
  --ui-warning: oklch(0.68 0.15 80);
  --ui-warning-soft: oklch(0.975 0.045 95);
  --ui-danger: oklch(0.55 0.19 25);
  --ui-danger-soft: oklch(0.96 0.025 25);
  --ui-danger-fg: oklch(1 0 0);
  --ui-ring: oklch(0.5 0.17 292 / 0.35);
  --ui-glass: oklch(1 0 0 / 0.72);
  --ui-overlay: oklch(0.2 0.018 270 / 0.32);
  --ui-shadow-1: 0 1px 2px oklch(0.2 0.018 270 / 0.06);
  --ui-shadow-2: 0 4px 12px -2px oklch(0.2 0.018 270 / 0.1), 0 1px 2px oklch(0.2 0.018 270 / 0.06);
  --ui-shadow-3: 0 16px 40px -8px oklch(0.2 0.018 270 / 0.18), 0 2px 6px oklch(0.2 0.018 270 / 0.06);

  --ui-font: Onest, "Segoe UI", system-ui, sans-serif;
  --ui-font-code: "JetBrains Mono", Consolas, ui-monospace, monospace;

  --ui-radius-tag: 4px;
  --ui-radius-field: 6px;
  --ui-radius-ctl: 8px;
  --ui-radius-card: 10px;
  --ui-radius-pop: 14px;

  --ui-ease: cubic-bezier(0.2, 0, 0, 1);
  --ui-fast: 120ms;
  --ui-enter: 160ms;
  --ui-rise: 200ms;
}

/* Тёмная тема: блок повторён дважды - для системной настройки и для явного выбора. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --ui-canvas: oklch(0.215 0.0072 270);
    --ui-surface: oklch(0.245 0.0072 270);
    --ui-surface-2: oklch(0.285 0.009 270);
    --ui-surface-3: oklch(0.32 0.009 270);
    --ui-line: oklch(0.32 0.009 270);
    --ui-line-strong: oklch(0.39 0.0108 270);
    --ui-fg: oklch(0.95 0.0072 270);
    --ui-fg-muted: oklch(0.76 0.0108 270);
    --ui-fg-subtle: oklch(0.64 0.0108 270);
    --ui-primary: oklch(0.95 0.0072 270);
    --ui-primary-hover: oklch(0.87 0.0072 270);
    --ui-primary-fg: oklch(0.22 0.0072 270);
    --ui-accent: oklch(0.74 0.13 292);
    --ui-accent-hover: oklch(0.8 0.117 292);
    --ui-accent-soft: oklch(0.3 0.05 292);
    --ui-accent-fg: oklch(0.2 0.02 292);
    --ui-success: oklch(0.74 0.13 155);
    --ui-success-soft: oklch(0.29 0.04 155);
    --ui-warning: oklch(0.86 0.15 90);
    --ui-warning-soft: oklch(0.32 0.05 85);
    --ui-danger: oklch(0.7 0.16 25);
    --ui-danger-soft: oklch(0.3 0.05 25);
    --ui-danger-fg: oklch(0.2 0.02 25);
    --ui-ring: oklch(0.74 0.13 292 / 0.4);
    --ui-glass: oklch(0.26 0.0072 270 / 0.72);
    --ui-overlay: oklch(0 0 0 / 0.5);
    --ui-shadow-1: 0 1px 2px oklch(0 0 0 / 0.3);
    --ui-shadow-2: 0 4px 12px -2px oklch(0 0 0 / 0.4), inset 0 1px 0 oklch(1 0 0 / 0.04);
    --ui-shadow-3: 0 16px 40px -8px oklch(0 0 0 / 0.55), inset 0 1px 0 oklch(1 0 0 / 0.05);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --ui-canvas: oklch(0.215 0.0072 270);
  --ui-surface: oklch(0.245 0.0072 270);
  --ui-surface-2: oklch(0.285 0.009 270);
  --ui-surface-3: oklch(0.32 0.009 270);
  --ui-line: oklch(0.32 0.009 270);
  --ui-line-strong: oklch(0.39 0.0108 270);
  --ui-fg: oklch(0.95 0.0072 270);
  --ui-fg-muted: oklch(0.76 0.0108 270);
  --ui-fg-subtle: oklch(0.64 0.0108 270);
  --ui-primary: oklch(0.95 0.0072 270);
  --ui-primary-hover: oklch(0.87 0.0072 270);
  --ui-primary-fg: oklch(0.22 0.0072 270);
  --ui-accent: oklch(0.74 0.13 292);
  --ui-accent-hover: oklch(0.8 0.117 292);
  --ui-accent-soft: oklch(0.3 0.05 292);
  --ui-accent-fg: oklch(0.2 0.02 292);
  --ui-success: oklch(0.74 0.13 155);
  --ui-success-soft: oklch(0.29 0.04 155);
  --ui-warning: oklch(0.86 0.15 90);
  --ui-warning-soft: oklch(0.32 0.05 85);
  --ui-danger: oklch(0.7 0.16 25);
  --ui-danger-soft: oklch(0.3 0.05 25);
  --ui-danger-fg: oklch(0.2 0.02 25);
  --ui-ring: oklch(0.74 0.13 292 / 0.4);
  --ui-glass: oklch(0.26 0.0072 270 / 0.72);
  --ui-overlay: oklch(0 0 0 / 0.5);
  --ui-shadow-1: 0 1px 2px oklch(0 0 0 / 0.3);
  --ui-shadow-2: 0 4px 12px -2px oklch(0 0 0 / 0.4), inset 0 1px 0 oklch(1 0 0 / 0.04);
  --ui-shadow-3: 0 16px 40px -8px oklch(0 0 0 / 0.55), inset 0 1px 0 oklch(1 0 0 / 0.05);
}

@keyframes ui-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes ui-pop { from { opacity: 0; transform: translateY(-2px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes ui-rise { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes ui-shimmer { to { background-position: -200% 0; } }
@keyframes ui-spin { to { transform: rotate(360deg); } }

/* ---------- База (только для страниц, перешедших на набор) ---------- */

body.ui-body {
  margin: 0;
  background: var(--ui-canvas);
  color: var(--ui-fg);
  font-family: var(--ui-font);
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
/* Сброс завёрнут в :where() - нулевая специфичность, поэтому он никогда не
   перебивает цвет и отступы компонентов (иначе .ui-body button { color }
   сильнее, чем .ui-btn--primary, и текст главной кнопки пропадает). */
:where(.ui-body) *, :where(.ui-body) *::before, :where(.ui-body) *::after { box-sizing: border-box; }
:where(.ui-body) ::selection { background: var(--ui-accent-soft); color: var(--ui-fg); }
:where(.ui-body) :where(h1, h2, h3) { margin: 0; line-height: 1.2; letter-spacing: -0.015em; }
:where(.ui-body) :where(p) { margin: 0; }
:where(.ui-body) :where(a) { color: var(--ui-accent); text-decoration: none; }
:where(.ui-body) :where(a:hover) { color: var(--ui-accent-hover); }
:where(.ui-body) :where(input[type="checkbox"], input[type="radio"]) { accent-color: var(--ui-accent); }
:where(.ui-body) :where(button, input, select, textarea) { font: inherit; color: inherit; }

.ui-focus:focus-visible,
.ui-btn:focus-visible,
.ui-nav__item:focus-visible,
.ui-segmented__item:focus-visible,
.ui-select:focus-visible,
.ui-menu__item:focus-visible,
.ui-icon-btn:focus-visible,
.ui-tree__toggle:focus-visible,
.ui-dropzone:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--ui-ring);
}

.ui-scroll { scrollbar-width: thin; scrollbar-color: var(--ui-line-strong) transparent; }
.ui-tabular { font-variant-numeric: tabular-nums; }
.ui-mono { font-family: var(--ui-font-code); font-size: 12px; }
.ui-visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Текст: 24 страница · 18 раздел · 14 подзаголовок · 13 основной · 12 подписи ---------- */

.ui-h1 { font-size: 24px; font-weight: 600; line-height: 32px; }
.ui-h2 { font-size: 18px; font-weight: 600; line-height: 24px; }
.ui-h3 { font-size: 14px; font-weight: 600; line-height: 20px; }
.ui-text { font-size: 13px; line-height: 20px; }
.ui-caption { font-size: 12px; line-height: 16px; color: var(--ui-fg-muted); }
.ui-muted { color: var(--ui-fg-muted); }
.ui-subtle { color: var(--ui-fg-subtle); }

/* ---------- Иконки: lucide, 16 px, в плотных строках 14 ---------- */

.ui-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: -3px;
  /* Клик по иконке считается кликом по кнопке: иначе event.target - <svg>,
     и обработчики, проверяющие саму кнопку, молча не срабатывают. */
  pointer-events: none;
}
.ui-icon--sm { width: 14px; height: 14px; }
.ui-icon--xs { width: 12px; height: 12px; stroke-width: 2.5; }

/* ---------- Кнопка ---------- */

.ui-btn {
  position: relative;
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 36px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: var(--ui-radius-ctl);
  font-family: var(--ui-font);
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  user-select: none;
  outline: none;
  transition: background-color var(--ui-fast) var(--ui-ease), border-color var(--ui-fast) var(--ui-ease),
    color var(--ui-fast) var(--ui-ease), opacity var(--ui-fast) var(--ui-ease), box-shadow var(--ui-fast) var(--ui-ease);
}
.ui-btn:disabled, .ui-btn[aria-disabled="true"] { cursor: not-allowed; opacity: 0.45; }

.ui-btn--primary { background: var(--ui-primary); color: var(--ui-primary-fg); }
.ui-btn--primary:not(:disabled):hover { background: var(--ui-primary-hover); color: var(--ui-primary-fg); }
.ui-btn--accent { background: var(--ui-accent); color: var(--ui-accent-fg); }
.ui-btn--accent:not(:disabled):hover { background: var(--ui-accent-hover); color: var(--ui-accent-fg); }
.ui-btn--secondary { border-color: var(--ui-line); background: var(--ui-surface); color: var(--ui-fg); box-shadow: var(--ui-shadow-1); }
.ui-btn--secondary:not(:disabled):hover { background: var(--ui-surface-2); color: var(--ui-fg); }
.ui-btn--ghost { background: transparent; color: var(--ui-fg-muted); }
.ui-btn--ghost:not(:disabled):hover { background: var(--ui-surface-2); color: var(--ui-fg); }
/* Ссылка-кнопка внутри строки: фиолетовый текст, ниже обычной («Изменить» у целей). */
.ui-btn--link { height: 28px; padding: 0 8px; background: transparent; color: var(--ui-accent); }
.ui-btn--link:not(:disabled):hover { background: var(--ui-accent-soft); color: var(--ui-accent); }
.ui-btn--danger { background: transparent; color: var(--ui-danger); }
.ui-btn--danger:not(:disabled):hover { background: var(--ui-danger-soft); color: var(--ui-danger); }
.ui-btn--danger-solid { background: var(--ui-danger); color: var(--ui-danger-fg); }
.ui-btn--danger-solid:not(:disabled):hover { opacity: 0.9; color: var(--ui-danger-fg); }

.ui-btn--xs { height: 28px; padding: 0 10px; gap: 6px; font-size: 12px; }
.ui-btn--xs .ui-icon { width: 14px; height: 14px; }
.ui-btn--sm { height: 32px; padding: 0 12px; gap: 6px; }
.ui-btn--lg { height: 40px; padding: 0 16px; font-size: 14px; }
.ui-btn--icon { width: 36px; padding: 0; }
.ui-btn--icon.ui-btn--xs { width: 28px; }
.ui-btn--icon.ui-btn--sm { width: 32px; }
.ui-btn--icon.ui-btn--lg { width: 40px; }
.ui-btn--block { display: flex; width: 100%; }

/* Загрузка: подпись прячется, ширина кнопки не меняется. */
.ui-btn[aria-busy="true"] { cursor: progress; opacity: 1; }
.ui-btn[aria-busy="true"] > * { opacity: 0; }
.ui-btn[aria-busy="true"]::after {
  content: "";
  position: absolute;
  inset: 0;
  width: 16px;
  height: 16px;
  margin: auto;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: ui-spin 700ms linear infinite;
}

.ui-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  opacity: 0.8;
  animation: ui-spin 700ms linear infinite;
}

/* ---------- Поле ---------- */

.ui-field { display: flex; min-width: 0; flex-direction: column; font-family: var(--ui-font); }
.ui-field__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.ui-field__label { font-size: 12px; font-weight: 500; line-height: 16px; color: var(--ui-fg-muted); }
/* Строка под полем держит высоту, даже когда пуста: ошибка не сдвигает форму. */
.ui-field__msg { min-height: 16px; margin-top: 4px; font-size: 12px; line-height: 16px; color: var(--ui-fg-subtle); transition: color var(--ui-fast); }
.ui-field--error .ui-field__msg { color: var(--ui-danger); }

.ui-input {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--ui-line-strong);
  border-radius: var(--ui-radius-field);
  background: var(--ui-surface);
  color: var(--ui-fg);
  font-size: 13px;
  transition: border-color var(--ui-fast) var(--ui-ease), box-shadow var(--ui-fast) var(--ui-ease);
}
.ui-input:focus-within { border-color: var(--ui-accent); box-shadow: 0 0 0 3px var(--ui-ring); }
.ui-input--xs { height: 28px; padding: 0 8px; font-size: 12px; }
.ui-input--sm { height: 32px; padding: 0 10px; }
.ui-input[data-invalid], .ui-field--error .ui-input,
.ui-input[data-invalid]:focus-within, .ui-field--error .ui-input:focus-within { border-color: var(--ui-danger); }
.ui-input[data-disabled] { cursor: not-allowed; opacity: 0.55; }
.ui-input > input {
  height: 100%;
  min-width: 0;
  flex: 1;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  outline: none;
}
.ui-input > input::placeholder, .ui-textarea::placeholder { color: var(--ui-fg-subtle); }
.ui-input > input::-webkit-outer-spin-button, .ui-input > input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.ui-input > input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
.ui-input__affix { display: flex; flex-shrink: 0; align-items: center; color: var(--ui-fg-subtle); }
.ui-input--mono > input { font-family: var(--ui-font-code); font-size: 12px; }

.ui-textarea {
  display: block;
  width: 100%;
  min-height: 80px;
  padding: 8px 12px;
  border: 1px solid var(--ui-line-strong);
  border-radius: var(--ui-radius-field);
  background: var(--ui-surface);
  color: var(--ui-fg);
  font-family: var(--ui-font);
  font-size: 13px;
  line-height: 20px;
  outline: none;
  resize: vertical;
  transition: border-color var(--ui-fast) var(--ui-ease), box-shadow var(--ui-fast) var(--ui-ease);
}
.ui-textarea:focus { border-color: var(--ui-accent); box-shadow: 0 0 0 3px var(--ui-ring); }

/* Плотная панель: одна колонка подписи на всю панель, поля на одной линии. */
.ui-form-grid { display: grid; grid-template-columns: 150px minmax(0, 1fr); column-gap: 16px; row-gap: 4px; align-items: start; }
.ui-form-grid > .ui-field__label { padding-top: 10px; }
@media (max-width: 640px) {
  .ui-form-grid { grid-template-columns: minmax(0, 1fr); }
  .ui-form-grid > .ui-field__label { padding-top: 0; }
}

/* ---------- Селект (свой, портал, с поиском) ---------- */

.ui-select {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  height: 36px;
  padding: 0 8px 0 12px;
  border: 1px solid var(--ui-line-strong);
  border-radius: var(--ui-radius-field);
  background: var(--ui-surface);
  color: var(--ui-fg);
  font-family: var(--ui-font);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  outline: none;
  transition: border-color var(--ui-fast) var(--ui-ease), background-color var(--ui-fast) var(--ui-ease), box-shadow var(--ui-fast) var(--ui-ease);
}
.ui-select[aria-expanded="true"] { border-color: var(--ui-accent); box-shadow: 0 0 0 3px var(--ui-ring); }
.ui-select:disabled { cursor: not-allowed; opacity: 0.55; }
.ui-select--xs { height: 28px; padding: 0 6px 0 8px; font-size: 12px; }
.ui-select--sm { height: 32px; padding: 0 8px 0 10px; }
.ui-select__value { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ui-select__value[data-empty] { color: var(--ui-fg-subtle); }
.ui-select > .ui-icon { color: var(--ui-fg-subtle); transition: transform var(--ui-fast) var(--ui-ease); }
.ui-select[aria-expanded="true"] > .ui-icon { transform: rotate(180deg); }

.ui-pop {
  position: fixed;
  z-index: 1150;
  display: flex;
  max-width: min(420px, calc(100vw - 16px));
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--ui-line);
  border-radius: var(--ui-radius-pop);
  background: var(--ui-surface);
  color: var(--ui-fg);
  font-family: var(--ui-font);
  font-size: 13px;
  box-shadow: var(--ui-shadow-2);
  animation: ui-pop var(--ui-enter) var(--ui-ease) both;
}
.ui-pop__search { position: relative; padding: 6px; border-bottom: 1px solid var(--ui-line); }
.ui-pop__search .ui-icon { position: absolute; top: 50%; left: 14px; transform: translateY(-50%); color: var(--ui-fg-subtle); }
.ui-pop__search input {
  width: 100%;
  height: 32px;
  padding: 0 8px 0 28px;
  border: 1px solid var(--ui-line);
  border-radius: var(--ui-radius-field);
  background: var(--ui-surface-2);
  color: var(--ui-fg);
  font: inherit;
  outline: none;
  transition: border-color var(--ui-fast);
}
.ui-pop__search input:focus { border-color: var(--ui-accent); }
.ui-listbox { max-height: 320px; margin: 0; padding: 4px; overflow-y: auto; list-style: none; }
.ui-option {
  display: flex;
  min-height: 32px;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--ui-radius-field);
  cursor: default;
  user-select: none;
}
.ui-option[data-active] { background: var(--ui-surface-2); }
.ui-option[aria-disabled="true"] { opacity: 0.45; }
.ui-option__label { min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ui-option .ui-icon { color: var(--ui-accent); opacity: 0; }
.ui-option[aria-selected="true"] .ui-icon { opacity: 1; }
.ui-listbox__empty { padding: 8px; font-size: 12px; color: var(--ui-fg-subtle); }

/* Время: поле с маской ЧЧ:ММ и список с шагом. Нативный <input type="time">
   не используем - в Chrome он рисует ярко-синюю колонку вне набора. */
.ui-input--time { width: 112px; }
.ui-input--time > input { font-variant-numeric: tabular-nums; }
.ui-pop--time { width: 112px; }
.ui-pop--time .ui-listbox { max-height: 240px; }
.ui-pop--time .ui-option { justify-content: center; font-variant-numeric: tabular-nums; }
.ui-pop--time .ui-option .ui-icon { display: none; }
.ui-pop--time .ui-option[aria-selected="true"] { color: var(--ui-accent); font-weight: 500; }

/* ---------- Меню «⋯» ---------- */

.ui-menu { min-width: 180px; max-width: 280px; padding: 4px; }
.ui-menu__item {
  display: flex;
  width: 100%;
  height: 32px;
  align-items: center;
  gap: 8px;
  padding: 0 8px;
  border: 0;
  border-radius: var(--ui-radius-field);
  background: transparent;
  color: var(--ui-fg);
  font: inherit;
  font-size: 13px;
  text-align: left;
  cursor: default;
  outline: none;
}
.ui-menu__item .ui-icon { color: var(--ui-fg-subtle); }
.ui-menu__item:hover, .ui-menu__item:focus-visible { background: var(--ui-surface-2); box-shadow: none; }
.ui-menu__item--danger, .ui-menu__item--danger .ui-icon { color: var(--ui-danger); }
.ui-menu__item--danger:hover, .ui-menu__item--danger:focus-visible { background: var(--ui-danger-soft); }
.ui-menu__item:disabled { opacity: 0.45; }
.ui-menu__hint { margin-left: auto; font-size: 12px; color: var(--ui-fg-subtle); }
.ui-menu__sep { height: 1px; margin: 4px 0; background: var(--ui-line); }
.ui-menu__label { padding: 6px 8px 4px; font-size: 12px; font-weight: 500; color: var(--ui-fg-subtle); }

/* ---------- Диалог ---------- */

.ui-dialog { position: fixed; inset: 0; z-index: 1100; display: flex; align-items: center; justify-content: center; padding: 16px; font-family: var(--ui-font); }
.ui-dialog[hidden] { display: none; }
.ui-dialog__overlay { position: absolute; inset: 0; background: var(--ui-overlay); animation: ui-fade var(--ui-enter) var(--ui-ease) both; }
.ui-dialog__panel {
  position: relative;
  display: flex;
  width: 100%;
  max-width: 440px;
  max-height: calc(100vh - 32px);
  flex-direction: column;
  border: 1px solid var(--ui-line);
  border-radius: var(--ui-radius-pop);
  background: var(--ui-surface);
  color: var(--ui-fg);
  box-shadow: var(--ui-shadow-3);
  animation: ui-pop var(--ui-enter) var(--ui-ease) both;
}
.ui-dialog__panel--wide { max-width: 640px; }
.ui-dialog__head { display: flex; align-items: flex-start; gap: 12px; padding: 16px 20px 4px; }
.ui-dialog__heading { min-width: 0; flex: 1; }
.ui-dialog__title { font-size: 14px; font-weight: 600; line-height: 24px; }
.ui-dialog__desc { margin-top: 4px; font-size: 13px; line-height: 20px; color: var(--ui-fg-muted); }
.ui-dialog__head > .ui-btn { margin: -4px -8px 0 0; }
.ui-dialog__body { min-height: 0; overflow-y: auto; padding: 12px 20px; }
.ui-dialog__foot { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--ui-line); }

/* ---------- Тосты ---------- */

.ui-toasts {
  pointer-events: none;
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 1200;
  display: flex;
  width: min(380px, calc(100vw - 32px));
  flex-direction: column;
  gap: 8px;
  font-family: var(--ui-font);
}
.ui-toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 8px 10px 12px;
  border: 1px solid var(--ui-line);
  border-radius: var(--ui-radius-card);
  background: var(--ui-glass);
  color: var(--ui-fg);
  box-shadow: var(--ui-shadow-3);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  backdrop-filter: blur(16px) saturate(1.4);
  animation: ui-rise var(--ui-rise) var(--ui-ease) both;
}
.ui-toast[data-leaving] { opacity: 0; transform: translateY(4px); transition: opacity var(--ui-enter) var(--ui-ease), transform var(--ui-enter) var(--ui-ease); }
.ui-toast__icon { display: flex; width: 16px; height: 20px; flex-shrink: 0; align-items: center; justify-content: center; }
.ui-toast--success .ui-toast__icon { color: var(--ui-success); }
.ui-toast--danger .ui-toast__icon { color: var(--ui-danger); }
.ui-toast--info .ui-toast__icon { color: var(--ui-fg-subtle); }
.ui-toast--loading .ui-toast__icon { color: var(--ui-accent); }
.ui-toast__body { min-width: 0; flex: 1; }
.ui-toast__title { font-size: 13px; font-weight: 500; line-height: 20px; }
.ui-toast__desc { margin-top: 2px; font-size: 12px; line-height: 16px; color: var(--ui-fg-muted); }

/* ---------- Дата (одиночная) ----------
   Скрытый input хранит ГГГГ-ММ-ДД для кода страницы, видимое поле - ДД.ММ.ГГГГ.
   Нативный type="date" не используем, как и type="time". */
.ui-input--date { width: 148px; }
.ui-pop--date { width: 272px; padding: 12px; }
.ui-cal__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.ui-cal__title { font-size: 13px; font-weight: 600; text-transform: capitalize; }
.ui-cal__nav { display: flex; gap: 2px; }
.ui-cal__grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.ui-cal__weekday { padding: 4px 0; color: var(--ui-fg-subtle); font-size: 11px; font-weight: 500; text-align: center; }
.ui-cal__day {
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: var(--ui-radius-field);
  background: transparent;
  color: var(--ui-fg);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  outline: none;
  transition: background-color var(--ui-fast), color var(--ui-fast);
}
.ui-cal__day:hover { background: var(--ui-surface-2); }
.ui-cal__day:focus-visible { box-shadow: 0 0 0 3px var(--ui-ring); }
.ui-cal__day[data-outside] { color: var(--ui-fg-subtle); }
.ui-cal__day[data-today] { box-shadow: inset 0 0 0 1px var(--ui-line-strong); }
.ui-cal__day[aria-selected="true"] { background: var(--ui-accent); color: var(--ui-accent-fg); font-weight: 500; }
.ui-cal__day:disabled { cursor: default; opacity: 0.35; }
.ui-cal__foot { display: flex; justify-content: space-between; gap: 8px; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--ui-line); }

/* ---------- Подсказка ----------
   [data-ui-tooltip="текст"] на любом элементе. Слой рисуется поверх страницы,
   поэтому его не обрезает прокрутка таблицы. Значок «i» - .ui-hint. */
.ui-tooltip {
  position: fixed;
  z-index: 1250;
  max-width: 320px;
  padding: 6px 8px;
  border-radius: var(--ui-radius-field);
  background: var(--ui-fg);
  box-shadow: var(--ui-shadow-2);
  color: var(--ui-canvas);
  font-family: var(--ui-font);
  font-size: 12px;
  font-weight: 400;
  line-height: 16px;
  letter-spacing: 0;
  text-align: left;
  white-space: normal;
  pointer-events: none;
  animation: ui-fade var(--ui-fast) var(--ui-ease) both;
}
.ui-hint {
  display: inline-flex;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ui-fg-subtle);
  vertical-align: -3px;
  cursor: help;
  outline: none;
  transition: color var(--ui-fast);
}
.ui-hint .ui-icon { width: 14px; height: 14px; }
.ui-hint:hover { color: var(--ui-fg); }
.ui-hint:focus-visible { box-shadow: 0 0 0 3px var(--ui-ring); }

/* ---------- Мелкие контролы ---------- */

.ui-icon-btn {
  display: inline-flex;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: var(--ui-radius-field);
  background: transparent;
  color: var(--ui-fg-subtle);
  cursor: pointer;
  outline: none;
  transition: background-color var(--ui-fast), color var(--ui-fast);
}
.ui-icon-btn:hover { background: var(--ui-surface-2); color: var(--ui-fg); }

/* Обычный <input type="checkbox"> на страницах набора выглядит как ui-checkbox:
   списки каналов рисует скрипт, и оборачивать каждую галочку в разметку
   компонента было бы переписыванием, а не переездом. Галка - маска, цвет
   даёт фон, поэтому в обеих темах она берётся из токенов. */
:where(.ui-body input[type="checkbox"]:not(.ui-native)) {
  display: inline-grid;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  margin: 0;
  place-content: center;
  border: 1px solid var(--ui-line-strong);
  border-radius: var(--ui-radius-tag);
  background: var(--ui-surface);
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  transition: background-color var(--ui-fast) var(--ui-ease), border-color var(--ui-fast) var(--ui-ease), box-shadow var(--ui-fast) var(--ui-ease);
}
:where(.ui-body input[type="checkbox"]:not(.ui-native):hover) { border-color: var(--ui-fg-subtle); }
:where(.ui-body input[type="checkbox"]:not(.ui-native):focus-visible) { outline: none; box-shadow: 0 0 0 3px var(--ui-ring); }
:where(.ui-body input[type="checkbox"]:not(.ui-native):checked),
:where(.ui-body input[type="checkbox"]:not(.ui-native):indeterminate) { border-color: var(--ui-accent); background: var(--ui-accent); }
:where(.ui-body input[type="checkbox"]:not(.ui-native))::before {
  content: "";
  width: 10px;
  height: 10px;
  background: var(--ui-accent-fg);
  opacity: 0;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center / contain no-repeat;
}
:where(.ui-body input[type="checkbox"]:not(.ui-native):checked)::before { opacity: 1; }
:where(.ui-body input[type="checkbox"]:not(.ui-native):disabled) { cursor: not-allowed; opacity: 0.45; }

.ui-checkbox { position: relative; display: inline-flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.ui-checkbox > input { position: absolute; top: 0; left: 0; width: 16px; height: 16px; margin: 0; opacity: 0; cursor: inherit; }
.ui-checkbox > input:disabled,
.ui-switch > input:disabled { opacity: 0; }
.ui-checkbox__box {
  display: flex;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--ui-line-strong);
  border-radius: var(--ui-radius-tag);
  background: var(--ui-surface);
  color: var(--ui-accent-fg);
  pointer-events: none;
  transition: background-color var(--ui-fast) var(--ui-ease), border-color var(--ui-fast) var(--ui-ease), box-shadow var(--ui-fast) var(--ui-ease);
}
.ui-checkbox__box .ui-icon { opacity: 0; transition: opacity var(--ui-fast); }
.ui-checkbox:hover .ui-checkbox__box { border-color: var(--ui-fg-subtle); }
.ui-checkbox > input:checked + .ui-checkbox__box,
.ui-checkbox > input:indeterminate + .ui-checkbox__box { border-color: var(--ui-accent); background: var(--ui-accent); }
.ui-checkbox > input:checked + .ui-checkbox__box .ui-icon { opacity: 1; }
.ui-checkbox > input:focus-visible + .ui-checkbox__box { box-shadow: 0 0 0 3px var(--ui-ring); }
.ui-checkbox > input:disabled + .ui-checkbox__box { opacity: 0.45; }
.ui-checkbox:has(> input:disabled) { cursor: not-allowed; }

/* Переключатель: включено - акцент, выключено - нейтральная дорожка. */
.ui-switch { position: relative; display: inline-flex; width: 36px; height: 20px; flex-shrink: 0; cursor: pointer; }
.ui-switch > input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: inherit; }
.ui-switch__track {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 999px;
  background: var(--ui-line-strong);
  pointer-events: none;
  transition: background-color var(--ui-fast) var(--ui-ease), box-shadow var(--ui-fast) var(--ui-ease);
}
.ui-switch__track::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--ui-surface);
  box-shadow: var(--ui-shadow-1);
  transition: transform var(--ui-fast) var(--ui-ease);
}
.ui-switch > input:checked + .ui-switch__track { background: var(--ui-accent); }
.ui-switch > input:checked + .ui-switch__track::before { transform: translateX(16px); }
.ui-switch > input:focus-visible + .ui-switch__track { box-shadow: 0 0 0 3px var(--ui-ring); }
.ui-switch > input:disabled + .ui-switch__track { opacity: 0.45; }

.ui-segmented { display: inline-flex; gap: 2px; padding: 2px; border-radius: var(--ui-radius-ctl); background: var(--ui-surface-2); font-family: var(--ui-font); }
.ui-segmented--equal { display: grid; grid-auto-columns: 1fr; grid-auto-flow: column; }
.ui-segmented__item {
  display: inline-flex;
  height: 28px;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--ui-radius-field);
  background: transparent;
  color: var(--ui-fg-muted);
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  outline: none;
  transition: background-color var(--ui-fast) var(--ui-ease), color var(--ui-fast) var(--ui-ease), box-shadow var(--ui-fast) var(--ui-ease);
}
.ui-segmented__item .ui-icon { width: 14px; height: 14px; }
.ui-segmented__item:hover { color: var(--ui-fg); }
.ui-segmented__item[aria-checked="true"] { background: var(--ui-surface); color: var(--ui-fg); box-shadow: var(--ui-shadow-1); }
.ui-segmented--xs .ui-segmented__item { height: 24px; padding: 0 8px; }

.ui-tag { display: inline-flex; height: 20px; flex-shrink: 0; align-items: center; padding: 0 6px; border-radius: var(--ui-radius-tag); background: var(--ui-surface-2); color: var(--ui-fg-muted); font-size: 11px; font-weight: 500; line-height: 20px; }
.ui-tag--success { background: var(--ui-success-soft); color: var(--ui-success); }
.ui-tag--warning { background: var(--ui-warning-soft); color: var(--ui-warning); }
.ui-tag--danger { background: var(--ui-danger-soft); color: var(--ui-danger); }
.ui-tag--accent { background: var(--ui-accent-soft); color: var(--ui-accent); }

.ui-dot { display: inline-block; width: 6px; height: 6px; flex-shrink: 0; border-radius: 50%; background: var(--ui-line-strong); }
.ui-dot--success { background: var(--ui-success); }
.ui-dot--warning { background: var(--ui-warning); }
.ui-dot--danger { background: var(--ui-danger); }
.ui-dot--accent { background: var(--ui-accent); }
/* Статус одной строкой: точка + текст обычного цвета. */
.ui-status { display: inline-flex; min-width: 0; align-items: center; gap: 6px; font-size: 12px; line-height: 16px; color: var(--ui-fg-muted); }

.ui-skeleton {
  border-radius: var(--ui-radius-field);
  background: linear-gradient(90deg, var(--ui-surface-2) 0, color-mix(in oklch, var(--ui-surface-2) 45%, var(--ui-surface)) 50%, var(--ui-surface-2) 100%);
  background-size: 200% 100%;
  animation: ui-shimmer 1.4s linear infinite;
}

/* Ползунок нейтральный. */
.ui-range { width: 100%; accent-color: var(--ui-fg); }

.ui-dropzone {
  display: flex;
  width: 100%;
  height: 48px;
  align-items: center;
  gap: 10px;
  padding: 0 10px;
  border: 1px dashed var(--ui-line-strong);
  border-radius: var(--ui-radius-field);
  background: var(--ui-surface);
  color: var(--ui-fg);
  font-family: var(--ui-font);
  text-align: left;
  cursor: pointer;
  outline: none;
  transition: background-color var(--ui-fast), border-color var(--ui-fast);
}
.ui-dropzone:hover { background: var(--ui-surface-2); }
.ui-dropzone[data-dragging] { border-color: var(--ui-accent); background: var(--ui-accent-soft); }
.ui-dropzone__icon { display: inline-flex; width: 28px; height: 28px; flex-shrink: 0; align-items: center; justify-content: center; border-radius: var(--ui-radius-ctl); background: var(--ui-surface-2); color: var(--ui-fg-muted); }
.ui-dropzone__text { min-width: 0; flex: 1; }
.ui-dropzone__title { display: block; overflow: hidden; font-size: 13px; font-weight: 500; line-height: 16px; text-overflow: ellipsis; white-space: nowrap; }
.ui-dropzone[data-dragging] .ui-dropzone__title { color: var(--ui-accent); }
.ui-dropzone__hint { display: block; margin-top: 2px; font-size: 12px; line-height: 16px; color: var(--ui-fg-subtle); }

/* ---------- Паттерны ---------- */

.ui-card { border: 1px solid var(--ui-line); border-radius: var(--ui-radius-card); background: var(--ui-surface); box-shadow: var(--ui-shadow-1); }
.ui-card--pad { padding: 24px; }
.ui-card__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.ui-card__title { font-size: 18px; font-weight: 600; line-height: 24px; }
.ui-card__desc { margin-top: 4px; font-size: 13px; line-height: 20px; color: var(--ui-fg-muted); }
.ui-card__foot { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 8px; }
@media (max-width: 640px) { .ui-card--pad { padding: 16px; } }

/* Предупреждение: мягкая плашка, иконка цветная, текст обычного цвета. */
.ui-callout { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border: 1px solid var(--ui-line); border-radius: var(--ui-radius-ctl); background: var(--ui-surface-2); color: var(--ui-fg); font-size: 13px; line-height: 20px; }
.ui-callout > .ui-icon { margin-top: 2px; color: var(--ui-fg-subtle); }
.ui-callout--warning { border-color: color-mix(in oklch, var(--ui-warning) 30%, transparent); background: var(--ui-warning-soft); }
.ui-callout--warning > .ui-icon { color: var(--ui-warning); }
.ui-callout--danger { border-color: color-mix(in oklch, var(--ui-danger) 30%, transparent); background: var(--ui-danger-soft); }
.ui-callout--danger > .ui-icon { color: var(--ui-danger); }
.ui-callout--info { border-color: color-mix(in oklch, var(--ui-accent) 25%, transparent); background: var(--ui-accent-soft); }
.ui-callout--info > .ui-icon { color: var(--ui-accent); }

.ui-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 56px 24px; border: 1px dashed var(--ui-line-strong); border-radius: var(--ui-radius-card); background: var(--ui-surface); text-align: center; animation: ui-fade var(--ui-enter) var(--ui-ease) both; }
.ui-empty__icon { display: flex; width: 36px; height: 36px; align-items: center; justify-content: center; margin-bottom: 12px; border-radius: var(--ui-radius-ctl); background: var(--ui-surface-2); color: var(--ui-fg-muted); }
.ui-empty__title { font-size: 14px; font-weight: 500; }
.ui-empty__desc { max-width: 440px; margin-top: 4px; font-size: 13px; color: var(--ui-fg-muted); }
.ui-empty__action { margin-top: 16px; }

.ui-metrics { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.ui-metric { padding: 14px 16px; border: 1px solid var(--ui-line); border-radius: var(--ui-radius-card); background: var(--ui-surface); box-shadow: var(--ui-shadow-1); }
.ui-metric__label { font-size: 12px; line-height: 16px; color: var(--ui-fg-muted); }
.ui-metric__value { margin-top: 6px; font-size: 24px; font-weight: 600; line-height: 32px; letter-spacing: -0.015em; }
.ui-metric__hint { margin-top: 2px; font-size: 12px; line-height: 16px; color: var(--ui-fg-subtle); }

/* Список: строка со статусом (точка + слово), метаданные через «·», меню «⋯». */
.ui-list { display: flex; flex-direction: column; gap: 8px; }
.ui-list__row { display: flex; min-height: 56px; align-items: center; gap: 12px; padding: 10px 8px 10px 16px; border: 1px solid var(--ui-line); border-radius: var(--ui-radius-card); background: var(--ui-surface); box-shadow: var(--ui-shadow-1); }
.ui-list__main { min-width: 0; flex: 1; }
.ui-list__title { overflow: hidden; font-size: 13px; font-weight: 500; line-height: 20px; text-overflow: ellipsis; white-space: nowrap; }
.ui-list__meta { overflow: hidden; font-size: 12px; line-height: 16px; color: var(--ui-fg-subtle); text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Таблица данных ---------- */

.ui-table-wrap { overflow: auto; border: 1px solid var(--ui-line); border-radius: var(--ui-radius-card); background: var(--ui-surface); box-shadow: var(--ui-shadow-1); }
/* Цифры пропорциональные, не tabular-nums: у Onest в моноширинном режиме
   единица шире остальных и «1 011» рассыпается на отдельные знаки. Колонки
   чисел выровнены по правому краю, поэтому разряды совпадают и так. */
.ui-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; line-height: 20px; }
.ui-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 8px 12px;
  border-bottom: 1px solid var(--ui-line);
  background: var(--ui-surface-2);
  color: var(--ui-fg-muted);
  font-size: 12px;
  font-weight: 500;
  line-height: 16px;
  text-align: left;
  white-space: nowrap;
}
.ui-table td { padding: 8px 12px; border-bottom: 1px solid var(--ui-line); vertical-align: top; }
.ui-table tbody tr:last-child td { border-bottom: 0; }
.ui-table tbody tr { transition: background-color var(--ui-fast); }
.ui-table tbody tr:hover { background: color-mix(in oklch, var(--ui-surface-2) 60%, transparent); }
.ui-table .ui-num { text-align: right; white-space: nowrap; }
.ui-table__sub { display: block; font-size: 12px; line-height: 16px; color: var(--ui-fg-subtle); }
/* Оценка в таблице: точка статуса + число. Цифры пропорциональные, поэтому
   под число держим место ширины «100,00%», а само число прижимаем к точке:
   прижатое вправо давало зигзаг точек, с запасом по ширине - дыру у коротких. */
.ui-rate { display: inline-flex; align-items: center; gap: 6px; }
.ui-rate__value { min-width: 6.2ch; text-align: left; }
.ui-table tr[data-total] td { background: var(--ui-surface-2); font-weight: 500; }
.ui-table tr[data-total] .ui-table__sub { font-weight: 400; }
.ui-table--dense th, .ui-table--dense td { padding: 6px 10px; }

.ui-tree { display: inline-flex; min-width: 0; align-items: center; gap: 4px; }
.ui-tree__toggle {
  display: inline-flex;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: var(--ui-radius-tag);
  background: transparent;
  color: var(--ui-fg-subtle);
  cursor: pointer;
  outline: none;
  transition: background-color var(--ui-fast);
}
.ui-tree__toggle:hover { background: var(--ui-surface-2); color: var(--ui-fg); }
.ui-tree__toggle .ui-icon { transition: transform var(--ui-fast) var(--ui-ease); }
.ui-tree__toggle[aria-expanded="true"] .ui-icon { transform: rotate(90deg); }
.ui-tree__spacer { display: inline-block; width: 20px; flex-shrink: 0; }

/* ---------- Каркас: сайдбар, шапка, контент ---------- */

.ui-app { min-height: 100dvh; }
@media (min-width: 1024px) { .ui-app { display: grid; grid-template-columns: 232px minmax(0, 1fr); } }

.ui-sidebar { position: sticky; top: 0; display: none; height: 100dvh; flex-direction: column; border-right: 1px solid var(--ui-line); background: var(--ui-canvas); }
@media (min-width: 1024px) { .ui-sidebar { display: flex; } }
.ui-sidebar__brand { display: flex; height: 56px; flex-shrink: 0; align-items: center; gap: 8px; padding: 0 16px; color: var(--ui-fg); font-size: 14px; font-weight: 600; }
.ui-sidebar__body { min-height: 0; flex: 1; overflow-y: auto; padding: 8px; }
.ui-sidebar__foot { display: flex; flex-direction: column; gap: 8px; flex-shrink: 0; padding: 8px; border-top: 1px solid var(--ui-line); }

.ui-nav { display: flex; flex-direction: column; gap: 20px; }
.ui-nav__group { display: flex; flex-direction: column; gap: 2px; }
.ui-nav__label { padding: 0 10px 4px; color: var(--ui-fg-subtle); font-size: 12px; font-weight: 500; }
.ui-nav__item {
  display: flex;
  width: 100%;
  height: 32px;
  align-items: center;
  gap: 10px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--ui-radius-ctl);
  background: transparent;
  color: var(--ui-fg-muted);
  font: inherit;
  font-size: 13px;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  outline: none;
  transition: background-color var(--ui-fast) var(--ui-ease), color var(--ui-fast) var(--ui-ease), box-shadow var(--ui-fast) var(--ui-ease);
}
.ui-nav__item .ui-icon { color: var(--ui-fg-subtle); }
.ui-nav__item span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ui-nav__item:hover { background: var(--ui-surface-2); color: var(--ui-fg); }
.ui-nav__item[aria-current="page"] { background: var(--ui-surface); color: var(--ui-fg); font-weight: 500; box-shadow: var(--ui-shadow-1); }
.ui-nav__item[aria-current="page"] .ui-icon { color: var(--ui-fg); }
.ui-nav__item:disabled { cursor: not-allowed; opacity: 0.45; }

.ui-topbar { position: sticky; top: 0; z-index: 40; display: flex; height: 48px; align-items: center; gap: 8px; padding: 0 8px; border-bottom: 1px solid var(--ui-line); background: var(--ui-canvas); font-size: 14px; font-weight: 600; }
@media (min-width: 1024px) { .ui-topbar { display: none; } }

.ui-drawer { position: fixed; inset: 0; z-index: 1000; font-family: var(--ui-font); }
.ui-drawer[hidden] { display: none; }
.ui-drawer__overlay { position: absolute; inset: 0; background: var(--ui-overlay); animation: ui-fade var(--ui-enter) var(--ui-ease) both; }
.ui-drawer__panel { position: relative; display: flex; width: 264px; max-width: calc(100vw - 48px); height: 100%; flex-direction: column; border-right: 1px solid var(--ui-line); background: var(--ui-canvas); box-shadow: var(--ui-shadow-3); animation: ui-fade var(--ui-enter) var(--ui-ease) both; }

.ui-main { min-width: 0; padding: 24px 16px; }
@media (min-width: 640px) { .ui-main { padding: 24px; } }
@media (min-width: 1024px) { .ui-main { padding: 32px; } }
.ui-main__inner { width: 100%; max-width: 1280px; margin: 0 auto; }

.ui-page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 16px; margin-bottom: 24px; }
.ui-page-head__desc { margin-top: 4px; color: var(--ui-fg-muted); font-size: 13px; }
.ui-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.ui-stack { display: flex; flex-direction: column; gap: 16px; }
.ui-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

/* Секция сворачивается плавно. */
.ui-details { interpolate-size: allow-keywords; }
.ui-details::details-content { block-size: 0; overflow: hidden; opacity: 0; transition: block-size var(--ui-rise) var(--ui-ease), opacity var(--ui-enter) var(--ui-ease), content-visibility var(--ui-rise) allow-discrete; }
.ui-details[open]::details-content { block-size: auto; opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  .ui-body *, .ui-body *::before, .ui-body *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }
}
