/* =========================================================================
   Obsidra — панель. Одна таблица стилей на всю панель.
   Темы: светлая по умолчанию, тёмная — по системе или кнопке в меню
   (data-theme на <html> перекрывает систему). Цвета — только через переменные.
   ========================================================================= */

:root {
  --font: "Inter", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Roboto, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Consolas, monospace;

  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f8f9fb;          /* вложенные блоки: превью, формы правки */
  --surface-3: #eef0f4;          /* наведение */
  --input: #ffffff;
  --border: #e3e6ec;
  --border-strong: #cdd2dc;
  --text: #141821;
  --text-2: #394150;
  --muted: #526074;
  --primary: #6d4aff;            /* заливка главных кнопок */
  --primary-hover: #5b38f0;
  --on-primary: #ffffff;
  --accent: #5a36e6;             /* ссылки и выделение */
  --ok: #15803d;
  --ok-solid: #16a34a;
  --warn: #b45309;
  --warn-solid: #f59e0b;
  --danger: #dc2626;
  --sidebar: #ffffff;
  --sidebar-glass: rgba(255, 255, 255, .74);
  --overlay: rgba(15, 20, 30, .45);

  /* Палитра живых поверхностей; карточки сохраняют собственную заливку. */
  --flow-base: #eef1f8; --flow-cool: #b6c7e8; --flow-teal: #aedbd5;
  --flow-warm: #efc6b3; --flow-shine: #fffaf1; --flow-opacity: .55;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow: 0 1px 3px rgba(16, 24, 40, .07), 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-lg: 0 16px 40px rgba(16, 24, 40, .16);
  --ring: 0 0 0 3px color-mix(in srgb, var(--primary) 22%, transparent);

  /* ряды графиков и полосок */
  --series-1: #6d4aff;
  --series-2: #ea580c;
  --series-3: #8b5cf6;
  --grid: rgba(16, 24, 40, .07);

  /* уровни дерева меню */
  --lvl-device: #2563eb;
  --lvl-model: #7c3aed;
  --lvl-number: #0e8fa8;
  --lvl-question: #d97706;

  --radius: 12px;
  --radius-sm: 8px;
  --sb-w: 272px;
  --brand: #8f6bff;              /* фирменный фиолетовый Obsidra */
  --font-brand: "Jost", var(--font);
  --content-w: 1160px;

  /* ветвление дерева: отступ вложенности, вылет линии, подъём к соседу, точка соединения */
  --branch-indent: 26px;
  --branch-gap: 16px;
  --branch-rise: 10px;
  --branch-node: 22px;

  color-scheme: light;
  accent-color: var(--primary);
}

/* Тёмная тема: дважды одни и те же значения — для системной настройки и для выбора кнопкой. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #050506; --surface: #0a0a0c; --surface-2: #0d0d10; --surface-3: #17171c; --input: #0c0c0f;
    --border: #1c1c22; --border-strong: #2a2a32; --text: #ededef; --text-2: #d4d4d8; --muted: #a1a1aa;
    --primary: #8f6bff; --primary-hover: #a385ff; --on-primary: #050506; --accent: #ab92ff;
    --ok: #4cd38c; --ok-solid: #22a35a; --warn: #f0b04a; --warn-solid: #e09b2d; --danger: #ff4545;
    --sidebar: #050506; --overlay: rgba(0, 0, 0, .7);
    --sidebar-glass: transparent;
    --flow-base: #090e1b; --flow-cool: #283d73; --flow-teal: #125764;
    --flow-warm: #82454d; --flow-shine: #91cbd2; --flow-opacity: .65;
    --shadow-sm: none; --shadow: none; --shadow-lg: 0 18px 44px rgba(0, 0, 0, .7);
    --series-1: #8f6bff; --series-2: #f07a3a; --series-3: #a78bfa; --grid: rgba(255, 255, 255, .07);
    --lvl-device: #5b9cff; --lvl-model: #a98bff; --lvl-number: #2bc4cf; --lvl-question: #e0a83c;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #050506; --surface: #0a0a0c; --surface-2: #0d0d10; --surface-3: #17171c; --input: #0c0c0f;
  --border: #1c1c22; --border-strong: #2a2a32; --text: #ededef; --text-2: #d4d4d8; --muted: #a1a1aa;
  --primary: #8f6bff; --primary-hover: #a385ff; --on-primary: #050506; --accent: #ab92ff;
  --ok: #4cd38c; --ok-solid: #22a35a; --warn: #f0b04a; --warn-solid: #e09b2d; --danger: #ff4545;
  --sidebar: #050506; --overlay: rgba(0, 0, 0, .7);
  --sidebar-glass: transparent;
  --flow-base: #090e1b; --flow-cool: #283d73; --flow-teal: #125764;
  --flow-warm: #82454d; --flow-shine: #91cbd2; --flow-opacity: .65;
  --shadow-sm: none; --shadow: none; --shadow-lg: 0 18px 44px rgba(0, 0, 0, .7);
  --series-1: #8f6bff; --series-2: #f07a3a; --series-3: #a78bfa; --grid: rgba(255, 255, 255, .07);
  --lvl-device: #5b9cff; --lvl-model: #a98bff; --lvl-number: #2bc4cf; --lvl-question: #e0a83c;
  color-scheme: dark;
}

/* ===== Основа ===== */
*, *::before, *::after { box-sizing: border-box; }
/* Фон у html — без белой вспышки между страницами; место под полосу прокрутки
   держим всегда — короткие и длинные страницы не сдвигаются вбок. */
html { background: var(--bg); -webkit-text-size-adjust: 100%; }
/* Полосы прокрутки не показываем нигде — ни у страницы, ни у меню, списков и полей: прокрутка
   пальцем, колесом и тачпадом работает как обычно, просто без серых ползунков поверх интерфейса. */
* { scrollbar-width: none; }
*::-webkit-scrollbar { display: none; width: 0; height: 0; }
body {
  margin: 0;
  isolation: isolate;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  background: transparent;       /* фон — у html и в слоях ниже, иначе body закрыл бы рисунок */
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
/* Живое полотно находится за интерфейсом и не перехватывает жесты/клики. */
.fluid-background {
  position:fixed; inset:0; width:100%; height:100%; z-index:-1;
  pointer-events:none; opacity:var(--flow-opacity);
}
body.login-page .fluid-background { opacity:1; }
h1, h2, h3, h4 { line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; font-weight: 700; margin: 0 0 16px; }
h2 { font-size: 1.12rem; font-weight: 650; margin: 8px 0; }
h3 { font-size: 1rem; font-weight: 650; margin: 16px 0 6px; }
h4 { font-size: .78rem; margin: 12px 0 6px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
p { margin: 0 0 10px; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
code {
  font-family: var(--mono);
  background: var(--surface-3);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 6px;
  font-size: .84em;
  overflow-wrap: anywhere;
}
img { max-width: 100%; }
[hidden] { display: none !important; }

@keyframes expand-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

/* ===== Отзывчивость: касания, переходы между страницами, загрузка ===== */
/* Без голубой вспышки, которой мобильный браузер подсвечивает любое нажатие, — отклик даёт само
   нажатие ниже. manipulation — без задержки на ожидание двойного касания. */
html { -webkit-tap-highlight-color: transparent; }
a, button, summary, label, input[type="checkbox"] { touch-action: manipulation; }
button, a.btn-link, a.btn-sec, .seg a, .seg button { transition: transform .08s ease, background-color .12s, border-color .12s; }
button:active:not(:disabled), a.btn-link:active, a.btn-sec:active, .seg a:active, .seg button:active,
.icon-btn:active { transform: scale(.96); }
.sb-item:active, .tabbar a:active, .card-links a:active, .attn a:active, .recent a:active,
.palette-item:active, .backlink:active, details > summary:active { background: var(--surface-3); }

/* Переход между страницами (браузеры с View Transitions; остальные просто открывают страницу).
   Плавно перетекает только содержимое (main): старое и новое одной длительности — без провала
   яркости. Всё остальное, вместе с фоном, сменяется сразу: фон продолжается с того же кадра,
   а отдельный слой фона при переходе ложился бы поверх содержимого — страница мигала. */
@view-transition { navigation: none; }
main { view-transition-name: content; }
.sidebar { view-transition-name: sidebar; }
.appbar { view-transition-name: appbar; }
::view-transition-group(root), ::view-transition-group(appbar) { animation: none; }
::view-transition-old(root), ::view-transition-old(appbar), ::view-transition-old(sidebar) { display: none; }
::view-transition-new(root), ::view-transition-new(appbar), ::view-transition-new(sidebar) { animation: none; }
::view-transition-group(content) { animation-duration: .16s; }
::view-transition-group(sidebar) { animation-duration: .22s; }

/* Видимый фокус для клавиатуры */
a:focus-visible, button:focus-visible, summary:focus-visible,
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ===== Оболочка: боковое меню + содержимое ===== */
.app {
  display: grid; grid-template-columns: var(--sb-w) minmax(0, 1fr); min-height: 100vh; min-height: 100dvh;
  background: linear-gradient(to right, var(--sidebar-glass) calc(var(--sb-w) - 1px), var(--border) 0 var(--sb-w), transparent 0);
}
.main-col { min-width: 0; display: flex; flex-direction: column; }
main {
  width: 100%;
  max-width: var(--content-w);
  margin: 0 auto;
  padding: 30px 36px 110px;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: transparent;       /* цвет колонки задаёт .app — полупрозрачный, сквозь него виден фон */
  border-right: 1px solid var(--border);
  padding: 14px 12px max(14px, env(safe-area-inset-bottom));
}
.sb-head { display: flex; align-items: center; justify-content: space-between; padding: 2px 6px 8px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); font-weight: 750; font-size: 36px; line-height: 1; letter-spacing: -.025em; }
.brand-name { white-space: nowrap; }
.brand-dot { color: var(--accent); font-weight: 900; }
.brand:hover { text-decoration: none; }
.brand img { width: 30px; height: 30px; display: block; flex-shrink: 0; }
.sidebar .sb-close { display: none; }

.sb-nav { display: flex; flex-direction: column; gap: 14px; margin-top: 4px; }
.sb-group { display: flex; flex-direction: column; gap: 2px; }
.sb-caption {
  display: flex; align-items: center; gap: 7px;
  font-size: .78rem; font-weight: 650; letter-spacing: .01em;
  color: var(--muted); padding: 6px 10px 4px;
}
.sb-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.sb-dot.on { background: var(--ok-solid); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok-solid) 20%, transparent); }
.sb-item {
  display: flex; align-items: center; gap: 11px;
  min-height: 38px; padding: 7px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font: inherit; font-size: .92rem; font-weight: 520;
  background: none; border: 0; width: 100%; text-align: left; cursor: pointer;
  transition: background .12s, color .12s;
}
.sb-item:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.sb-item.current { background: color-mix(in srgb, var(--primary) 11%, transparent); color: var(--accent); font-weight: 620; }
.sb-item .ico { width: 18px; height: 18px; flex-shrink: 0; opacity: .85; }
.sb-item.current .ico { opacity: 1; }
.sb-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-count {
  margin-left: auto; flex-shrink: 0;
  font-size: .72rem; font-weight: 650; font-variant-numeric: tabular-nums;
  color: var(--muted); background: var(--surface-3);
  border-radius: 20px; padding: 1px 8px; min-width: 22px; text-align: center;
}
.sb-count.warn { color: #3a2500; background: var(--warn-solid); }
.sb-foot { margin-top: auto; padding-top: 10px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 2px; }

/* Выбор бота */
.bot-switch { position: relative; margin: 0 0 4px; }
.bot-switch > summary {
  list-style: none; cursor: pointer;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface-2);
}
.bot-switch > summary::-webkit-details-marker { display: none; }
.bot-switch > summary::before { content: none; }
.bot-switch > summary:hover { border-color: var(--border-strong); }
.bot-switch[open] > summary { border-color: var(--primary); box-shadow: var(--ring); }
.bot-switch-name { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.25; }
.bot-switch-name b { font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bot-switch-name small { color: var(--muted); font-size: .76rem; }
.bot-switch-chev { width: 16px; height: 16px; color: var(--muted); flex-shrink: 0; }
.bot-avatar {
  width: 30px; height: 30px; border-radius: 9px; flex-shrink: 0;
  display: grid; place-items: center;
  font-weight: 750; font-size: .9rem;
  color: var(--accent); background: color-mix(in srgb, var(--primary) 14%, transparent);
}
.bot-avatar.sm { width: 24px; height: 24px; border-radius: 7px; font-size: .78rem; }
.bot-menu {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 20;
  display: flex; flex-direction: column; gap: 2px; padding: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow-lg);
  animation: expand-in .14s ease both;
}
.bot-menu a {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 8px; color: var(--text); font-size: .9rem; font-weight: 520;
}
.bot-menu a:hover { background: var(--surface-3); text-decoration: none; }
.bot-menu a.current { color: var(--accent); font-weight: 620; }
.bot-menu-all { border-top: 1px solid var(--border); border-radius: 0 0 8px 8px !important; margin-top: 4px; color: var(--muted) !important; }
.bot-menu-all .ico { width: 18px; height: 18px; }

/* Переключатель темы: показываем то, на что он переключит */
.theme-ico-dark, .theme-ico-light { display: inline-flex; align-items: center; }
.theme-ico-light { display: none; }
:root[data-theme="dark"] .theme-ico-dark { display: none; }
:root[data-theme="dark"] .theme-ico-light { display: inline-flex; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-ico-dark { display: none; }
  :root:not([data-theme="light"]) .theme-ico-light { display: inline-flex; }
}
.theme-toggle .sb-label > span { display: inline; }
.theme-toggle .sb-label > .theme-ico-light { display: none; }
:root[data-theme="dark"] .theme-toggle .sb-label > .theme-ico-dark { display: none; }
:root[data-theme="dark"] .theme-toggle .sb-label > .theme-ico-light { display: inline; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .sb-label > .theme-ico-dark { display: none; }
  :root:not([data-theme="light"]) .theme-toggle .sb-label > .theme-ico-light { display: inline; }
}

.ico {
  width: 20px; height: 20px; flex-shrink: 0;
  fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon-btn {
  display: inline-grid; place-items: center;
  width: 42px; height: 42px; padding: 0;
  border-radius: 10px; border: 0; background: transparent; color: var(--text-2);
  cursor: pointer;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn .ico { width: 22px; height: 22px; }

.appbar { display: none; }
.sb-backdrop { display: none; }

/* ===== Мелочи ===== */
.muted { color: var(--muted); font-weight: normal; }
.center { text-align: center; }
.small { font-size: .82rem; }
.lead { color: var(--muted); font-size: .92rem; line-height: 1.55; margin: 0 0 16px; max-width: 760px; }
.empty { text-align: center; color: var(--muted); padding: 30px 12px; margin: 0; }
.crumbs { font-size: .88rem; margin: 0 0 10px; color: var(--muted); }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--accent); }
/* «← Раздел» над заголовком вложенной страницы */
.backlink {
  display: inline-flex; align-items: center; gap: 6px; margin: 0 0 6px -4px; padding: 3px 8px 3px 4px;
  border-radius: 8px; color: var(--muted); font-size: .86rem; font-weight: 600;
}
.backlink .ico { width: 16px; height: 16px; transition: transform .15s; }
.backlink:hover { color: var(--accent); background: var(--surface-3); text-decoration: none; }
.backlink:hover .ico { transform: translateX(-2px); }
.ai-head h1 { overflow-wrap: anywhere; }
.subhead { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-top: 8px; font-size: .86rem; }
.subhead .pill { font-size: .76rem; padding: 1px 10px 1px 8px; }
.upload-hint { font-size: .8rem; margin: 7px 0 0; }

/* ===== Сообщения на странице ===== */
.error, .flash, .hint {
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid;
  line-height: 1.5;
  animation: expand-in .2s ease both;
}
.error { color: var(--danger); background: color-mix(in srgb, var(--danger) 9%, transparent); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.flash { color: var(--ok); background: color-mix(in srgb, var(--ok-solid) 10%, transparent); border-color: color-mix(in srgb, var(--ok-solid) 35%, transparent); font-weight: 520; }
.hint {
  color: var(--text-2);
  background: color-mix(in srgb, var(--primary) 7%, var(--surface));
  border-color: color-mix(in srgb, var(--primary) 25%, transparent);
  margin: 12px 0 18px;
}
.hint b, .hint strong { color: var(--text); }

/* ===== Кнопки ===== */
button, .btn-link, a.btn-sec {
  font: inherit;
  font-size: .92rem;
  font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 38px;
  padding: 7px 16px;
  border-radius: 9px;
  border: 1px solid transparent;
  background: var(--primary);
  color: var(--on-primary);
  cursor: pointer;
  max-width: 100%;
  line-height: 1.3;
  text-align: center;
  overflow-wrap: anywhere;   /* длинная подпись («Заменить: …») переносится, а не распирает экран */
  text-decoration: none;
  transition: background .14s, border-color .14s, color .14s, box-shadow .14s, transform .08s;
}
button:hover, .btn-link:hover { background: var(--primary-hover); text-decoration: none; }
button:active, .btn-link:active { transform: translateY(1px); }
button:disabled { opacity: .55; cursor: default; transform: none; }
button .ico, .btn-link .ico { width: 18px; height: 18px; }

/* второстепенная: контур */
button.ghost, button.btn-sec, a.btn-sec, form.inline button, details.note-edit > summary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
  font-weight: 550;
  box-shadow: var(--shadow-sm);
}
button.ghost:hover, button.btn-sec:hover, a.btn-sec:hover, form.inline button:hover, details.note-edit > summary:hover {
  background: var(--surface-3);
  border-color: var(--border-strong);
  color: var(--text);
  text-decoration: none;
}
/* опасное действие: красный контур, заливка при наведении */
button.danger, form.inline button.danger {
  background: transparent;
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 45%, transparent);
  font-weight: 550;
  box-shadow: none;
}
button.danger:hover, form.inline button.danger:hover { background: var(--danger); border-color: var(--danger); color: #fff; }
/* подтверждающее действие */
button.btn-ok, button.ok, .stack button.ok, .note-foot form.inline button.btn-ok {
  background: var(--ok-solid); border-color: var(--ok-solid); color: #fff; font-weight: 600;
}
button.btn-ok:hover, button.ok:hover, .stack button.ok:hover { background: color-mix(in srgb, var(--ok-solid) 86%, #000); }
/* маленькая */
button.btn-sm, a.btn-sm, summary.btn-sm, .btn-sm { min-height: 32px; padding: 4px 12px; font-size: .86rem; border-radius: 8px; }
.btn-link, .draft-bar button, .chip, .seg a { white-space: nowrap; overflow-wrap: normal; }

/* ===== Поля ввода ===== */
input, textarea, select {
  font: inherit;
  font-size: .94rem;
  width: 100%;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  background: var(--input);
  color: var(--text);
  transition: border-color .14s, box-shadow .14s, background .14s;
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .85; }
input:hover, textarea:hover, select:hover { border-color: color-mix(in srgb, var(--border-strong) 60%, var(--text)); }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
textarea { resize: vertical; line-height: 1.5; min-height: 84px; }
select { cursor: pointer; }
input[type="file"] { padding: 7px 10px; font-size: .88rem; cursor: pointer; }
input[type="file"]::file-selector-button {
  font: inherit; font-weight: 550; margin-right: 10px; padding: 4px 12px;
  border-radius: 7px; border: 1px solid var(--border-strong); background: var(--surface-3); color: var(--text); cursor: pointer;
}
input[type="checkbox"], input[type="radio"] { width: auto; min-height: 0; }

.stack { display: flex; flex-direction: column; gap: 16px; }
.stack label, .stack-label {
  display: flex; flex-direction: column; gap: 6px;
  font-size: .88rem; color: var(--text-2); font-weight: 600;
}
.stack label input, .stack label textarea, .stack label select { font-weight: normal; color: var(--text); }
/* Пояснение под полем: мельче и спокойнее подписи, чтобы не спорить с ней */
.field-hint { display: block; font-size: .82rem; font-weight: 450; color: var(--muted); line-height: 1.5; }
.stack .form-section {
  margin: 8px 0 -4px; padding-top: 16px; border-top: 1px solid var(--border);
  font-size: .98rem; font-weight: 680; color: var(--text);
}
.form-panel, .bot-summary { max-width: 760px; }
.bot-summary { display: flex; align-items: flex-start; gap: 14px; }
.bot-summary-text { min-width: 0; }
.bot-summary-text .card-status { margin: 2px 0 8px; }
.bot-summary-text p { margin: 4px 0 0; overflow-wrap: anywhere; }
.stack button { align-self: flex-start; }
.stack .row { display: flex; gap: 8px; flex-wrap: wrap; }
.stack .row button { align-self: auto; }

form.inline { display: inline-flex; gap: 6px; align-items: center; width: auto; margin: 0; }
form.inline input { width: auto; min-width: 170px; min-height: 36px; padding: 6px 10px; }
form.inline button { min-height: 36px; padding: 5px 12px; }

.add-form { display: flex; gap: 8px; margin: 10px 0 4px; }
.add-form input {
  flex: 1; min-height: 36px; padding: 6px 12px; font-size: .9rem;
  background: transparent; border-style: dashed;
}
.add-form input:focus { background: var(--surface); border-style: solid; }
.add-form button {
  min-height: 36px; padding: 5px 14px; font-size: .88rem;
  background: transparent; color: var(--accent);
  border: 1px dashed color-mix(in srgb, var(--primary) 55%, transparent);
  box-shadow: none;
}
.add-form.panel { padding: 14px; }
.add-form button:hover { background: var(--primary); border-style: solid; border-color: var(--primary); color: var(--on-primary); }

.row-actions {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  margin: 6px 0 14px; padding-bottom: 14px;
  border-bottom: 1px dashed var(--border);
}

/* Переключатель (флажок в виде тумблера) */
input[type="checkbox"].switch {
  appearance: none; -webkit-appearance: none;
  width: 42px; height: 24px; min-height: 0; padding: 0;
  border-radius: 24px; border: 1px solid var(--border-strong);
  background: var(--surface-3);
  position: relative; cursor: pointer; flex-shrink: 0;
  transition: background .15s, border-color .15s;
}
input[type="checkbox"].switch::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 18px; height: 18px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .3);
  transition: transform .16s ease;
}
input[type="checkbox"].switch:checked { background: var(--ok-solid); border-color: var(--ok-solid); }
input[type="checkbox"].switch:checked::after { transform: translateX(18px); }

.switch-row { display: flex; gap: 14px; align-items: flex-start; padding: 14px 0; border-top: 1px solid var(--border); cursor: pointer; }
.switch-row:first-of-type { border-top: none; padding-top: 4px; }
.stack label.switch-row { flex-direction: row; align-items: flex-start; gap: 14px; font-weight: normal; color: var(--text); font-size: .95rem; }
.switch-row b { display: block; margin-bottom: 2px; font-weight: 620; }
.switch-row .muted { font-size: .86rem; line-height: 1.5; }

.fields-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; }
.fields-grid > label { display: grid; grid-row: span 3; grid-template-rows: subgrid; row-gap: 5px; align-content: start; }
.fields-grid > label > input, .fields-grid > label > select { align-self: start; }
.stack .fields-grid label { font-size: .86rem; }

/* Счётчик длины сообщения (лимит Telegram — 4096) */
.char-counter { align-self: flex-end; font-size: .76rem; font-weight: 500; color: var(--muted); font-variant-numeric: tabular-nums; }
.char-counter.warn { color: var(--warn); }
.char-counter.over { color: var(--danger); font-weight: 700; }

/* Поле с несохранёнными правками и панель «Сохранить / Отменить» */
input.draft, textarea.draft, select.draft {
  border-color: var(--warn-solid);
  background: color-mix(in srgb, var(--warn-solid) 8%, var(--input));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--warn-solid) 16%, transparent);
}
.draft-bar {
  position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom));
  transform: translate(-50%, 110px);
  display: flex; gap: 14px; align-items: center;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 14px;
  padding: 10px 12px 10px 18px;
  box-shadow: var(--shadow-lg);
  opacity: 0; pointer-events: none;
  transition: transform .3s cubic-bezier(.3, 1.2, .4, 1), opacity .25s;
  z-index: 150; font-size: .92rem; font-weight: 550;
}
.draft-bar.visible { transform: translate(-50%, 0); opacity: 1; pointer-events: auto; }
.draft-bar button { min-height: 36px; padding: 6px 14px; }
.draft-bar button.clear { background: transparent; color: var(--text); border-color: var(--border-strong); }
.draft-bar button.clear:hover { border-color: var(--danger); color: var(--danger); background: transparent; }

.sticky-actions {
  position: sticky; bottom: max(12px, env(safe-area-inset-bottom)); z-index: 50;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 10px 14px; margin-top: 14px; box-shadow: var(--shadow-lg);
}

/* Загрузка файлов */
.upload {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  margin-top: 10px; padding: 10px;
  background: var(--surface-2); border: 1px dashed var(--border-strong); border-radius: 10px;
}
.upload input[type="file"] { width: auto; flex: 1; min-width: 200px; border: none; background: none; }
.upload select { width: auto; }
.upload-row { display: grid; grid-template-columns: minmax(180px, 1fr) minmax(200px, 1.2fr) auto; gap: 10px; align-items: end; }
.upload-row label { display: flex; flex-direction: column; gap: 6px; font-size: .86rem; color: var(--text-2); font-weight: 600; }

/* ===== Карточки и панели ===== */
.panel, .card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.panel { padding: 20px 22px; margin: 16px 0; }
.panel > h2:first-child, .panel > .panel-title:first-child { margin-top: 0; }
.panel-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.panel-title h2 { margin: 0; }
.panel-note { margin: -2px 0 12px; font-size: .86rem; line-height: 1.5; color: var(--muted); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; margin: 16px 0; }
.card { padding: 18px 20px; min-width: 0; transition: border-color .15s, box-shadow .15s; }
.card h2 { margin: 0 0 6px; }
.card:hover { border-color: var(--border-strong); }
.columns { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.columns > * { min-width: 0; }   /* длинная строка без переносов не распирает сетку */
.columns > .panel { margin: 0; }

/* Плитки чисел; плитки исходов — ссылки на отфильтрованные диалоги */
a.card { color: var(--muted); display: block; }
a.card:hover { text-decoration: none; border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.tone-ok .big, .bot-kpis .tone-ok b { color: var(--ok); }
.tone-err .big, .bot-kpis .tone-err b { color: var(--danger); }
.tone-warn .big, .bot-kpis .tone-warn b { color: var(--warn); }
.outcome-cards { margin-bottom: 10px; }
.stats-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.stats-cards .card {
  padding: 16px 16px 14px; text-align: left; color: var(--muted); font-size: .84rem; line-height: 1.35;
}
.stats-cards .big {
  display: block; font-size: 1.85rem; font-weight: 720; color: var(--text);
  letter-spacing: -.02em; line-height: 1.15; margin-bottom: 4px; white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.stats-cards .card .sub { display: block; font-size: .76rem; margin-top: 3px; }
/* Изменение к прошлому периоду под числом */
.delta { display: block; width: fit-content; margin-top: 6px; padding: 1px 7px; border-radius: 20px;
  font-size: .72rem; font-weight: 650; color: var(--muted); background: var(--surface-3); white-space: nowrap; }
.delta.good { color: var(--ok); background: color-mix(in srgb, var(--ok-solid) 13%, transparent); }
.delta.bad { color: var(--danger); background: color-mix(in srgb, var(--danger) 11%, transparent); }
.kpi .delta { margin-top: 4px; white-space: normal; max-width: 100%; line-height: 1.3; }

/* Сворачиваемая панель */
.panel.collapsible { padding: 0; overflow: hidden; }
.panel.collapsible > summary { padding: 15px 20px; font-size: 1.02rem; font-weight: 650; }
.panel.collapsible > .panel-body { padding: 2px 20px 20px; }
.panel.collapsible > .panel-body > .panel-note { margin-top: 0; }
.panel.collapsible > summary .tree-meta { font-weight: 500; }

/* ===== Значки состояния ===== */
.pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 3px 11px 3px 9px; border-radius: 20px;
  font-size: .8rem; font-weight: 620; border: 1px solid transparent; vertical-align: middle; white-space: nowrap;
}
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.pill.ok   { color: var(--ok);     background: color-mix(in srgb, var(--ok-solid) 12%, transparent); border-color: color-mix(in srgb, var(--ok-solid) 30%, transparent); }
.pill.warn { color: var(--warn);   background: color-mix(in srgb, var(--warn-solid) 13%, transparent); border-color: color-mix(in srgb, var(--warn-solid) 35%, transparent); }
.pill.err  { color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, transparent); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.pill-note { font-size: .78rem; color: var(--muted); cursor: help; white-space: nowrap; }
.pill.off { color: var(--muted); background: var(--surface-3); border-color: var(--border); }
.card-status { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 14px 0; }

.badge {
  display: inline-flex; align-items: center;
  background: var(--surface-3); color: var(--muted);
  border-radius: 20px; padding: 1px 9px;
  font-size: .76rem; font-weight: 550; white-space: nowrap;
}
.badge.warn { color: var(--warn); background: color-mix(in srgb, var(--warn-solid) 14%, transparent); }
.tab-count {
  font-size: .72rem; font-weight: 650; color: var(--muted);
  background: var(--surface-3); border-radius: 10px; padding: 1px 7px;
}
.tab-count.warn { color: #3a2500; background: var(--warn-solid); }

/* ===== Таблицы ===== */
table { border-collapse: collapse; width: 100%; font-size: .92rem; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 620; font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; }
tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--surface-2); }

/* Полоски, воронка, разрезы статистики */
.bar-track { display: block; height: 8px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.bar-fill { display: block; height: 100%; min-width: 4px; border-radius: 4px; background: var(--series-1); }
.funnel { display: flex; flex-direction: column; gap: 14px; }
.funnel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 6px; }
.funnel-title { font-size: .9rem; color: var(--text-2); }
.funnel-value { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.breakdown { table-layout: auto; }
table.breakdown th { white-space: nowrap; }
table.breakdown td { vertical-align: middle; }
.br-label { min-width: 0; }
.br-name { display: block; }
.br-sub { display: block; font-size: .78rem; color: var(--muted); margin-top: 2px; }
.br-bar { width: 32%; min-width: 90px; }
.br-num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; width: 1%; }
th.br-num { text-align: right; }
.chart-box { position: relative; height: 300px; }

/* Период статистики: готовые кнопки, свои даты и шаг «раньше/позже» */
.period-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin: 4px 0 8px; }
.range-form { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 0; }
.range-field { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: .86rem; }
.range-field input {
  width: auto; min-height: 36px; padding: 5px 10px; font-size: .9rem; font-variant-numeric: tabular-nums;
}
.range-step { width: 36px; height: 36px; border: 1px solid var(--border); background: var(--surface); }
.range-step .ico { width: 18px; height: 18px; }
.range-step.disabled { opacity: .35; pointer-events: none; }
.period-title { margin: 0 0 16px; font-size: 1.02rem; font-weight: 650; }

/* Помощник на странице статистики */
.ai-stats .kpis, .kpis.ai-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px;
  margin-bottom: 16px; }
.kpi {
  display: flex; flex-direction: column; gap: 3px; padding: 12px 14px; border-radius: 11px;
  background: var(--surface-2); border: 1px solid var(--border); min-width: 0;
}
.kpi b { font-size: 1.55rem; font-weight: 720; letter-spacing: -.02em; line-height: 1.15; font-variant-numeric: tabular-nums; }
.kpi span { font-size: .8rem; color: var(--muted); line-height: 1.35; }
.kpi.ok b { color: var(--ok); }
.kpi.warn b { color: var(--warn); }
.outcome-bar { display: flex; height: 12px; border-radius: 6px; overflow: hidden; background: var(--surface-3); gap: 2px; }
.outcome-bar > span { display: block; min-width: 3px; }
.o-answered { background: var(--ok-solid); }
.o-escalated { background: var(--series-1); }
.o-no_answer { background: var(--warn-solid); }
.o-other_device { background: var(--border-strong); }
.o-errors { background: var(--danger); }
.outcome-legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 10px 0 0; padding: 0; list-style: none; font-size: .84rem; color: var(--text-2); }
.outcome-legend li { display: inline-flex; align-items: center; gap: 7px; }
.outcome-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.outcome-legend b { font-variant-numeric: tabular-nums; }
.ai-staff { margin: 12px 0 0; font-size: .84rem; }
.funnel-ai { margin-top: 4px; padding-top: 14px; border-top: 1px dashed var(--border-strong); }
.funnel-ai .funnel-title { display: inline-flex; align-items: center; gap: 7px; }
.funnel-ai .funnel-title .ico { width: 16px; height: 16px; color: var(--series-3); }
.funnel-ai .bar-fill { background: var(--series-3); }
td.br-ai, th.br-ai { color: var(--series-3); }
.stats-footnote { font-size: .8rem; margin: 6px 2px 0; line-height: 1.5; color: var(--muted); }

/* Выбор периода */
.period-picker { margin: 4px 0 18px; display: flex; gap: 8px 12px; align-items: center; flex-wrap: wrap; color: var(--muted); font-size: .9rem; }
.period-label { font-weight: 550; }
.seg {
  display: inline-flex; gap: 2px; padding: 3px;
  background: var(--surface-3); border: 1px solid var(--border); border-radius: 11px;
}
.seg a {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 30px; padding: 4px 13px; border-radius: 8px;
  color: var(--muted); font-size: .86rem; font-weight: 580; white-space: nowrap;
}
.seg a:hover { color: var(--text); text-decoration: none; }
.seg a.current { background: var(--surface); color: var(--text); font-weight: 650; box-shadow: var(--shadow); }
.chip, button.chip {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 32px; padding: 4px 13px;
  border-radius: 20px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text-2);
  font-size: .86rem; font-weight: 550; white-space: nowrap; cursor: pointer;
  box-shadow: none; transform: none;
}
.chip:hover, button.chip:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.chip.current, button.chip[aria-pressed="true"] {
  background: var(--text); border-color: var(--text); color: var(--bg); font-weight: 620;
}
.period-since { font-size: .86rem; }

/* Поиск и фильтры списков */
.toolbar { display: flex; gap: 8px 12px; align-items: center; flex-wrap: wrap; margin: 0 0 16px; }
.search { flex: 1 1 260px; min-width: 0; position: relative; display: block; }
.search input { padding-left: 36px; }
.search::before {
  content: ""; position: absolute; left: 12px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%);
  background: var(--muted); pointer-events: none;
  -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='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-3.5-3.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='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-3.5-3.5'/%3E%3C/svg%3E") center / contain no-repeat;
}
.chips { display: inline-flex; gap: 6px; flex-wrap: wrap; align-items: center; }

/* ===== Главная: боты и резервная копия ===== */
.bot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; margin-bottom: 16px; }
.bot-grid > .panel { margin: 0; }
.bot-card { display: flex; flex-direction: column; }
.bot-card-head { display: flex; align-items: center; gap: 14px; }
.bot-card-title { min-width: 0; }
.bot-card-title h2 { margin: 0 0 2px; font-size: 1.12rem; }
.bot-card-title .muted { font-size: .84rem; overflow-wrap: anywhere; }
.bot-card h2 a { color: var(--text); }
.bot-card h2 a:hover { color: var(--accent); text-decoration: none; }
.bot-avatar.lg { width: 44px; height: 44px; border-radius: 12px; font-size: 1.2rem; }
/* Главная: обращения за неделю с исходами — чтобы видеть «всё ли в порядке» без переходов */
.bot-card { min-width: 0; }   /* плитки с цифрами не должны растягивать карточку шире экрана */
.bot-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 0 0 8px; }
.bot-kpis a {
  display: block; padding: 10px 12px; border-radius: 10px; background: var(--surface-2);
  color: var(--muted); font-size: .74rem; line-height: 1.3;
}
.bot-kpis a:hover { background: var(--surface-3); text-decoration: none; color: var(--text); }
.bot-kpis a { min-width: 0; overflow-wrap: anywhere; }
.bot-kpis b { display: block; font-size: 1.3rem; font-weight: 720; color: var(--text); letter-spacing: -.02em;
  font-variant-numeric: tabular-nums; margin-bottom: 2px; }
.bot-today { margin: 0 0 6px; font-size: .82rem; }
.card-links {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 6px;
  margin-top: auto; padding-top: 14px; border-top: 1px solid var(--border);
}
.card-links a {
  display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-radius: 9px;
  color: var(--text-2); font-weight: 560; font-size: .9rem;
}
.card-links a .ico { width: 18px; height: 18px; color: var(--muted); }
.card-links a:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.card-links a:hover .ico { color: var(--accent); }
.backup-panel { display: flex; align-items: center; gap: 16px; }
.backup-panel > div { flex: 1; min-width: 0; }
.backup-panel h2 { margin: 0 0 4px; }
.backup-panel p { margin: 0; max-width: 640px; }
.backup-ico {
  width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; flex-shrink: 0;
  color: var(--ok); background: color-mix(in srgb, var(--ok-solid) 13%, transparent);
}

/* Пояснение «как это работает» — свёрнуто, чтобы не отодвигать работу вниз */
details.help { margin: -4px 0 16px; max-width: 820px; }
details.help > summary {
  display: inline-flex; flex-wrap: nowrap; padding: 4px 8px 4px 2px; border-radius: 8px;
  color: var(--muted); font-size: .88rem; font-weight: 560;
}
details.help > summary:hover { background: none; color: var(--text); }
details.help > p { margin: 6px 0 0; padding: 12px 14px; border-radius: 10px; background: var(--surface-2);
  border: 1px solid var(--border); color: var(--text-2); font-size: .9rem; line-height: 1.55; }

/* ===== Дерево меню ===== */
details > summary {
  cursor: pointer; padding: 11px 15px; font-weight: 600; user-select: none;
  display: flex; align-items: center; gap: 9px;
  list-style: none; transition: background .12s;
}
details > summary::-webkit-details-marker { display: none; }
details > summary::before {
  content: ""; width: 7px; height: 7px; flex-shrink: 0; margin: 0 3px 0 1px;
  border-right: 1.8px solid var(--muted); border-bottom: 1.8px solid var(--muted);
  transform: rotate(-45deg); transition: transform .15s;
}
details[open] > summary::before { transform: rotate(45deg); }
details > summary:hover { background: var(--surface-2); }

details.device, details.model, details.number, details.question {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 11px; margin: 10px 0; box-shadow: var(--shadow-sm);
  position: relative;          /* якорь для линии ветки */
}
/* overflow: hidden здесь нельзя: линии ветвления рисуются левее карточки. Фон summary скругляем явно. */
details:not(.panel) > summary { border-radius: 10px 10px 0 0; }
details:not(.panel):not([open]) > summary { border-radius: 10px; }
details.device   { border-left: 3px solid var(--lvl-device); box-shadow: var(--shadow); }
details.model    { border-left: 3px solid var(--lvl-model);    --branch: var(--lvl-model); }
details.number   { border-left: 3px solid var(--lvl-number);   --branch: var(--lvl-number); }
details.question { border-left: 3px solid var(--lvl-question); --branch: var(--lvl-question); }
details.model, details.number, details.question { margin-left: var(--branch-indent); }
/* Ветвление: ::before — скруглённое колено к карточке, ::after — вертикаль к следующему соседу;
   у последнего соседа вертикаль обрывается, получается «└». */
details.model::before, details.number::before, details.question::before,
details.model::after,  details.number::after,  details.question::after {
  content: ""; position: absolute; left: calc(-1 * var(--branch-gap));
  border-left: 2px solid var(--branch); pointer-events: none; opacity: .75;
}
details.model::before, details.number::before, details.question::before {
  top: calc(-1 * var(--branch-rise)); width: var(--branch-gap);
  height: calc(var(--branch-rise) + var(--branch-node));
  border-bottom: 2px solid var(--branch); border-bottom-left-radius: 9px;
}
details.model::after, details.number::after, details.question::after {
  top: var(--branch-node); bottom: calc(-1 * var(--branch-rise) - 2px);
}
details.model:last-of-type::after, details.number:last-of-type::after, details.question:last-of-type::after { display: none; }
details.question > summary { font-weight: 520; }
details .level-body, details .question-body { padding: 6px 16px 16px; }

.tree-toolbar { display: flex; gap: 8px; align-items: center; margin: 14px 0 6px; flex-wrap: wrap; }
.tree-search { flex: 1; min-width: 220px; }
.tree-empty { color: var(--muted); padding: 14px 2px; }
.tree-name { font-weight: 620; }
.tree-meta { margin-left: auto; font-size: .78rem; font-weight: 500; color: var(--muted); white-space: nowrap; flex-shrink: 0; }
.rename-form { margin: 0 0 14px; clear: both; }
/* Действия над узлом — компактная панель справа, а не отдельная строка */
.level-body > .node-actions {
  float: right; margin: 8px 0 6px 16px; padding: 0; border: 0; gap: 4px;
}
.level-body > .node-actions + .rename-form:not([hidden]) { padding-top: 6px; }
.level-body::after { content: ""; display: block; clear: both; }
.node-actions button.btn-sm .ico { width: 15px; height: 15px; margin-right: 6px; }
.node-actions form.inline { gap: 4px; }
button.btn-icon, form.inline button.btn-icon {
  min-height: 32px; width: 32px; padding: 0; display: inline-grid; place-items: center; border-radius: 8px;
}
button.btn-icon .ico { width: 16px; height: 16px; }
.node-actions button.danger { background: transparent; color: var(--danger); border: 1px solid var(--border-strong); box-shadow: none; }
.node-actions button.danger:hover { background: var(--danger); border-color: var(--danger); color: #fff; }

/* Перетаскивание вопросов */
.drag-handle { flex-shrink: 0; cursor: grab; color: var(--muted); font-size: 1.05rem; line-height: 1; letter-spacing: -1px; padding: 0 2px; touch-action: none; }
.drag-handle:hover { color: var(--accent); }
.drag-handle:active { cursor: grabbing; }
.q-list { min-height: 4px; }
.q-list.is-empty {
  min-height: 44px; display: flex; align-items: center; justify-content: center; margin: 4px 0;
  border: 1px dashed var(--border-strong); border-radius: 9px; color: var(--muted); font-size: .85rem;
}
.q-list.is-empty::before { content: "Перетащите сюда вопрос или добавьте новый"; }
.q-ghost { opacity: .4; }
.q-chosen { border-left-color: var(--primary); box-shadow: 0 0 0 2px var(--primary); }
.q-new { animation: q-appear .25s ease both; }
@keyframes q-appear { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.q-removing { animation: q-vanish .2s ease forwards; overflow: hidden; pointer-events: none; }
@keyframes q-vanish {
  from { opacity: 1; transform: none; max-height: 800px; }
  to   { opacity: 0; transform: translateX(-12px); max-height: 0; margin: 0; padding: 0; border-width: 0; }
}

/* Вложения ответа */
.attachments { margin-top: 14px; }
.att-row { display: flex; gap: 9px; align-items: center; padding: 6px 0; flex-wrap: wrap; }
.att-kind {
  font-size: .68rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted);
  border: 1px solid var(--border-strong); border-radius: 5px; padding: 1px 6px; flex-shrink: 0;
}

/* Предпросмотр экрана бота, как в Telegram */
.tg-preview { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 12px; margin-bottom: 4px; }
.tg-bubble {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px 12px 12px 4px; padding: 8px 12px; font-size: .9rem;
  display: inline-block; max-width: 100%; white-space: pre-wrap; overflow-wrap: anywhere;
}
.tg-keyboard { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.tg-btn {
  flex: 1 1 calc(50% - 5px); min-width: 0; text-align: center;   /* по две кнопки в ряд, как в боте */
  background: var(--surface); border: 1px solid var(--border); border-radius: 9px;
  padding: 7px 10px; font-size: .85rem; color: var(--accent); overflow-wrap: anywhere;
}
.tg-btn-wide { flex-basis: 100%; }
.tg-btn-back { color: var(--muted); }

/* «Тексты бота»: живой предпросмотр экрана рядом с формой */
.messages-layout { display: block; }
.tg-live { margin: -4px 0 4px; }
.tg-live-head { font-size: .82rem; font-weight: 650; color: var(--text-2); margin-bottom: 6px; }
.tg-live-note { font-size: .76rem; margin: 6px 0 0; }
.tg-phone {
  padding: 14px; border-radius: 14px;
  background: linear-gradient(160deg, color-mix(in srgb, var(--series-1) 9%, var(--surface-2)),
                              color-mix(in srgb, var(--ok-solid) 7%, var(--surface-2)));
}
.tg-phone .tg-bubble { box-shadow: var(--shadow-sm); line-height: 1.45; }
@media (min-width: 1100px) {
  .messages-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
  .messages-layout > .panel { margin: 0; }
  .tg-live { position: sticky; top: 20px; margin: 0; }
}

/* ===== ИИ-помощник ===== */
.ai-head { margin: 0 0 18px; }
.ai-head h1 { margin: 0; }
.eyebrow {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  font-size: .82rem; font-weight: 620; color: var(--muted); margin-bottom: 6px;
}
.eyebrow .pill { font-size: .74rem; padding: 1px 10px 1px 8px; }
.tabs { display: none; }   /* разделы помощника — в боковом меню */
.status-strip { display: flex; align-items: center; gap: 12px 22px; flex-wrap: wrap; }
.status-strip .today { font-size: 1rem; white-space: nowrap; }
.status-strip .today b { font-size: 1.35rem; }
.status-strip .bar-track { flex: 1 1 180px; min-width: 140px; }
.status-strip .models { font-size: .84rem; color: var(--muted); }
.status-strip .money { font-size: .92rem; white-space: nowrap; }
.status-strip .money b { font-size: 1.1rem; }

/* «Требует внимания» */
.attn { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; list-style: none; }
.attn a {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 13px; border-radius: 10px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text); font-weight: 520;
}
.attn a:hover { border-color: var(--border-strong); background: var(--surface-3); text-decoration: none; }
.attn a.warn { border-color: color-mix(in srgb, var(--warn-solid) 45%, transparent); background: color-mix(in srgb, var(--warn-solid) 7%, var(--surface)); }
.attn a.err { border-color: color-mix(in srgb, var(--danger) 40%, transparent); background: color-mix(in srgb, var(--danger) 6%, var(--surface)); }
.attn .ico { color: var(--muted); }
.attn a.warn .ico { color: var(--warn); }
.attn a.err .ico { color: var(--danger); }
.attn .ico.go { margin-left: auto; width: 17px; height: 17px; color: var(--muted); transition: transform .15s; }
.attn a:hover .ico.go { transform: translateX(2px); }
.all-good { display: flex; align-items: center; gap: 10px; color: var(--ok); margin: 4px 0; font-weight: 550; }

/* Последние диалоги */
.recent { display: flex; flex-direction: column; margin: 0; padding: 0; list-style: none; }
.recent a {
  display: grid; grid-template-columns: 32px 1fr auto; gap: 11px; align-items: center;
  padding: 9px 6px; color: var(--text); border-top: 1px solid var(--border);
}
.recent li:first-child a { border-top: none; }
.recent a > span { min-width: 0; }
.recent a:hover { background: var(--surface-2); text-decoration: none; border-radius: 9px; }
.recent .who { font-weight: 620; font-size: .9rem; }
.recent .what { display: block; font-size: .82rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent .when { font-size: .76rem; color: var(--muted); text-align: right; white-space: nowrap; }

/* Диалоги: карточка и переписка в виде чата */
.avatar {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center; font-weight: 700; font-size: .88rem;
  color: var(--accent); background: color-mix(in srgb, var(--primary) 13%, transparent);
}
details.dlg { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  margin: 0 0 12px; box-shadow: var(--shadow-sm); overflow: hidden; }
details.dlg[data-outcome="handed"] { --dialogue-tone: var(--warn-solid); }
details.dlg[data-outcome="solved"] { --dialogue-tone: var(--ok-solid); }
details.dlg[data-outcome="failed"], details.dlg[data-outcome="limited"], details.dlg[data-outcome="error"] { --dialogue-tone: var(--danger); }
details.dlg[data-outcome]:not([data-outcome="open"]):not([data-outcome="none"]) {
  background: color-mix(in srgb, var(--dialogue-tone) 9%, var(--surface));
  border-color: color-mix(in srgb, var(--dialogue-tone) 45%, var(--border));
}
details.dlg > summary { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto;
  gap: 7px 14px; align-items: start; padding: 18px 20px; font-weight: normal; border-radius: var(--radius); }
details.dlg > summary::before { content: none; }
details.dlg > summary:hover { background: var(--surface-2); }
details.dlg[data-outcome]:not([data-outcome="open"]):not([data-outcome="none"]) > summary:hover {
  background: color-mix(in srgb, var(--dialogue-tone) 13%, var(--surface));
}
details.dlg[open] > summary { border-bottom: 1px solid var(--border); border-radius: 0; }
.dlg > summary .avatar { width: 40px; height: 40px; grid-row: 1 / 3; align-self: start; }
.dlg-main { min-width: 0; display: grid; gap: 4px; }
.dlg-who { display: flex; align-items: baseline; flex-wrap: wrap; gap: 5px 9px; line-height: 1.35; }
.dlg-nick { font-weight: 650; }
.dlg-name { color: var(--text-2); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; max-width: 100%; }
.dlg-nick + .dlg-name { color: var(--muted); font-size: .84rem; }
.dlg-staff { font-size: .67rem; letter-spacing: .05em; font-weight: 650; color: var(--accent); }
.dlg-device { color: var(--muted); opacity: .72; font-size: .8rem; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.dlg-date { display: flex; align-items: center; gap: 14px; color: var(--muted); font-size: .75rem; white-space: nowrap; }
.dlg-date-text { opacity: .75; }
.dlg-chevron { display: inline-flex; color: var(--muted); }
.dlg-chevron svg { width: 14px; height: 14px; }
.dlg[open] .dlg-chevron { transform: rotate(90deg); }
.dlg-preview { grid-column: 2 / -1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  color: var(--text-2); opacity: .74; font-size: .86rem; line-height: 1.5; }
.dlg-footer { grid-column: 2 / -1; display: flex; justify-content: space-between; flex-wrap: wrap; gap: 6px 20px; padding-top: 5px; }
.dlg-facts, .dlg-results { display: flex; align-items: baseline; flex-wrap: wrap; gap: 5px 14px; font-size: .73rem; color: var(--muted); }
.dlg-facts { opacity: .72; }
.dlg-facts > span + span::before { content: "·"; margin-right: 14px; opacity: .6; }
.dlg-results { margin-left: auto; justify-content: flex-end; }
/* Одна метка исхода на карточке; подробности — первой строкой внутри переписки */
.dlg-outcome { font-size: .7rem; padding: 1px 9px 1px 7px; gap: 6px; letter-spacing: .02em; }
.dlg-outcome::before { width: 6px; height: 6px; }
.dlg-date .dlg-outcome { margin-right: -4px; }
.dlg-details { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: -6px 0 -2px; font-size: .76rem; color: var(--muted); }
.dlg-details > span + span::before { content: "·"; margin-right: 14px; opacity: .6; }
.dialogue-corrected, .dlg-result-ok { color: var(--ok); }
.dialogue-corrected { font-size: .69rem; font-weight: 650; letter-spacing: .045em; }
.dialogue-new, .dlg-result-warn { color: var(--warn); }
.dlg-result-error { color: var(--danger); }
.chat { padding: 22px 24px; display: flex; flex-direction: column; gap: 16px; background: var(--surface-2); }
.chat-loading { margin: 0; font-size: .86rem; }
.chat-day { align-self: center; font-size: .72rem; color: var(--muted); padding: 3px 0; }
.msg { max-width: min(80%, 720px); min-width: 0; padding: 13px 16px; border-radius: 14px; font-size: .9rem; line-height: 1.6; }
.msg-heading { display: flex; align-items: baseline; gap: 10px; margin-bottom: 7px; color: var(--muted); font-size: .68rem; }
.msg-heading > span:first-child { font-weight: 650; letter-spacing: .02em; }
.msg-heading > time { margin-left: auto; }
.survey-buttons { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.survey-button { padding: 6px 10px; border: 1px solid var(--border-strong); border-radius: 8px; color: var(--muted); font-size: .8rem; }
.msg-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-in { align-self: flex-start; background: var(--surface); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.msg-out { align-self: flex-end; background: color-mix(in srgb, var(--primary) 6%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--primary) 18%, var(--border)); border-bottom-right-radius: 4px; }
.msg-out.bad { border-color: color-mix(in srgb, var(--warn-solid) 35%, var(--border)); }
.dlg[data-outcome="handed"] .msg-out.bad,
.dlg[data-outcome="solved"] .msg-out,
.dlg[data-outcome="failed"] .msg-out,
.dlg[data-outcome="limited"] .msg-out,
.dlg[data-outcome="error"] .msg-out {
  background: color-mix(in srgb, var(--dialogue-tone) 10%, var(--surface));
  border-color: color-mix(in srgb, var(--dialogue-tone) 45%, var(--border));
}
.msg.current { box-shadow: 0 0 0 2px var(--primary); }
.msg-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 5px 12px; margin-top: 8px; font-size: .72rem; color: var(--muted); }
.msg-meta > a { margin-left: auto; }
.msg-meta .pill { padding: 0; border: 0; background: transparent; font-size: .69rem; }
.msg-meta .pill::before { display: none; }
.msg-debug { margin: 0; font-size: .7rem; color: var(--muted); }
.msg-debug > summary { padding: 0; gap: 5px; min-height: 18px; line-height: 1.5;
  font-size: inherit; font-weight: normal; }
.msg-debug[open] { flex-basis: 100%; order: 2; }
.msg-debug > p { margin: 8px 0 0; }
.msg-photos { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.msg-photos a { display: block; border-radius: 8px; overflow: hidden; background: var(--surface-3); }
.msg-photos img { display: block; max-width: 260px; max-height: 280px; width: auto; height: auto; }
.msg-photos img.broken { width: 160px; height: 60px; }
.msg-note { margin-top: 10px; padding: 8px 10px; border-left: 2px solid var(--border-strong); border-radius: 3px;
  font-size: .78rem; color: var(--muted); overflow-wrap: anywhere; }
.msg-note > summary { font-size: inherit; font-weight: 500; }
.msg-note .msg-text { margin-top: 6px; }
.client-attachment { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; margin: 8px 0;
  background: var(--surface-2); max-width: 420px; }
.client-attachment img { display: block; max-width: 100%; max-height: 320px; width: auto; height: auto; margin: auto; }
.client-image-link { display: block; background: var(--surface-3); }
.client-image-link.media-unavailable::after { content: "Фото недоступно — можно попробовать скачать файл ниже";
  display: block; padding: 12px; font-size: .76rem; color: var(--muted); }
.client-attachment video { display: block; width: 100%; max-height: 320px; background: #101318; }
.client-attachment audio { display: block; width: 100%; min-width: 0; max-width: 100%; padding: 6px; }
.client-file-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; }
.client-file-icon { color: var(--accent); flex: 0 0 auto; display: flex; }
.client-file-icon .ico { width: 18px; height: 18px; }
.client-file-info { display: grid; min-width: 0; flex: 1; line-height: 1.4; }
.client-file-info b { font-size: .8rem; font-weight: 550; overflow-wrap: anywhere; }
.client-file-info small { color: var(--muted); font-size: .7rem; }
.client-file-download { font-size: .73rem; flex: 0 0 auto; }
.client-attachment .msg-note { margin: 0 10px 10px; }
@media (max-width: 650px) {
  details.dlg > summary { grid-template-columns: 34px minmax(0, 1fr); gap: 7px 10px; padding: 15px 14px; }
  .dlg > summary .avatar { width: 34px; height: 34px; }
  .dlg-date { grid-column: 2; grid-row: 2; gap: 7px; font-size: .69rem; }
  .dlg-date .dlg-chevron { margin-left: auto; }
  .dlg-preview, .dlg-footer { grid-column: 1 / -1; }
  .dlg-preview { padding-top: 3px; }
  .dlg-footer { gap: 8px; }
  .dlg-results { margin-left: 0; justify-content: flex-start; width: 100%; }
  .dlg-facts, .dlg-results { gap: 5px 10px; }
  .dlg-facts > span + span::before { margin-right: 10px; }
  .chat { padding: 14px; gap: 14px; }
  .msg { max-width: 96%; padding: 11px 13px; }
  .client-file-row { padding: 9px; gap: 8px; flex-wrap: wrap; }
  .client-file-info { min-width: 100px; }
}
.msg-codes { margin-top: 10px; padding-top: 8px; border-top: 1px dashed color-mix(in srgb, var(--primary) 30%, transparent); }
.msg-codes-title { font-size: .78rem; color: var(--muted); margin-bottom: 6px; }
.msg-codes-list { display: flex; flex-wrap: wrap; gap: 8px; }
/* Коды настроек, как их видел клиент: картинка на белом в любой теме */
.code-sent { margin: 0; width: 150px; background: #fff; border: 1px solid var(--border); border-radius: 9px; overflow: hidden; }
.code-sent img { display: block; width: 100%; height: 90px; object-fit: contain; padding: 6px; }
.code-sent figcaption { padding: 5px 7px; font-size: .75rem; line-height: 1.3; color: #333; background: #f2f4f8; }
.code-sent.no-image { width: auto; max-width: 260px; }
.chat-sep {
  align-self: center; font-size: .75rem; color: var(--muted);
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 2px 10px;
}

/* Заметки */
.note-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 18px; margin: 0 0 12px; box-shadow: var(--shadow-sm);
}
.note-card.has-warn { border-left: 3px solid var(--warn-solid); }
.note-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-bottom: 9px; font-size: .8rem; }
.scope { font-size: .76rem; font-weight: 620; padding: 2px 9px; border-radius: 20px; border: 1px solid; white-space: nowrap; }
.scope-n { color: var(--lvl-number); border-color: color-mix(in srgb, var(--lvl-number) 40%, transparent); background: color-mix(in srgb, var(--lvl-number) 8%, transparent); }
.scope-m { color: var(--lvl-model); border-color: color-mix(in srgb, var(--lvl-model) 40%, transparent); background: color-mix(in srgb, var(--lvl-model) 8%, transparent); }
.scope-d { color: var(--lvl-device); border-color: color-mix(in srgb, var(--lvl-device) 40%, transparent); background: color-mix(in srgb, var(--lvl-device) 8%, transparent); }
.scope-b { color: var(--warn); border-color: color-mix(in srgb, var(--warn-solid) 40%, transparent); background: color-mix(in srgb, var(--warn-solid) 9%, transparent); }
.note-text { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.55; font-size: .93rem; }
/* Строки «Ключ: значение» — ключ выделен */
.note-text.kv { white-space: normal; }
.kv-line { display: block; white-space: pre-wrap; }
.kv-line:empty { height: .55em; }
.kv-key { font-weight: 650; color: var(--text); margin-right: 2px; }
.note-warn, .note-codes {
  display: flex; align-items: flex-start; gap: 9px;
  margin: 10px 0 0; padding: 8px 11px; border-radius: 9px;
  font-size: .84rem; line-height: 1.5;
}
.note-warn { color: var(--warn); background: color-mix(in srgb, var(--warn-solid) 9%, transparent); }
.note-codes { color: var(--text-2); background: var(--surface-2); border: 1px solid var(--border); }
.note-warn > .ico, .note-codes > .ico { width: 16px; height: 16px; margin-top: 2px; }
.note-codes > .ico { color: var(--muted); }
.note-review.note-codes > .ico { color: var(--accent); }
.note-suggest { flex-wrap: wrap; align-items: center; }
.note-suggest > span { flex: 1 1 200px; }
.note-foot { display: flex; align-items: center; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.note-foot .ico { width: 15px; height: 15px; }
details.note-edit > summary .ico { margin-right: 6px; }
.note-foot button.danger.btn-icon { background: transparent; color: var(--danger); border: 1px solid var(--border-strong); box-shadow: none; }
.note-foot button.danger.btn-icon:hover { background: var(--danger); border-color: var(--danger); color: #fff; }
.note-foot .push-right { margin-left: auto; }
details.note-edit > summary {
  display: inline-flex; min-height: 32px; padding: 4px 12px; font-size: .86rem; border: 1px solid var(--border-strong); border-radius: 8px;
}
details.note-edit > summary::before { content: none; }
details.note-edit[open] { flex-basis: 100%; order: 10; }
details.note-edit[open] > summary { color: var(--accent); border-color: var(--primary); }
.note-edit-form { margin-top: 10px; padding: 14px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 11px; }

/* Импорт переписок */
.howto { margin: 8px 0 14px; }
.howto summary { cursor: pointer; color: var(--accent); padding: 0; font-weight: 600; }
.howto summary::before { content: none; }
.howto summary:hover { background: none; text-decoration: underline; }
.howto ol { margin: 8px 0 0; padding-left: 20px; line-height: 1.6; }
.import-actions { white-space: nowrap; text-align: right; }
.import-actions form + form { margin-left: 6px; }

/* Коды настроек */
.source-card { display: grid; grid-template-columns: 1fr auto; gap: 10px 18px; align-items: center; }
.source-card h3 { margin: 0 0 2px; font-size: 1rem; }
.source-card .facts { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: .84rem; color: var(--muted); margin-top: 6px; }
.source-card .actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.progress { height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; margin-top: 8px; max-width: 420px; }
.progress > span { display: block; height: 100%; background: var(--primary); border-radius: 3px; }
.menu-files { border: 0; padding: 0; margin: 12px 0 0; }
.menu-files legend { font-weight: 700; font-size: .9rem; margin-bottom: 4px; }
.menu-file { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; padding: 7px 9px; border-radius: 8px; font-size: .88rem; cursor: pointer; }
.menu-file:hover { background: var(--surface-2); }
.menu-file input { margin: 0; width: auto; flex: none; }
.menu-sheets { margin: 2px 0 0 8px; }
.menu-sheets summary { cursor: pointer; font-size: .84rem; color: var(--muted); padding: 4px 0; }
.menu-file .mf-name { font-weight: 600; overflow-wrap: anywhere; }
.menu-file .muted { font-size: .8rem; }
.menu-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-top: 14px; }
.menu-actions .muted { font-size: .8rem; }
.group-suggest {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px;
  padding: 9px 12px; margin-top: 8px;
  border: 1px dashed color-mix(in srgb, var(--warn-solid) 50%, transparent); border-radius: 10px; font-size: .88rem;
}
.code-group { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; padding: 8px 0; border-top: 1px solid var(--border); }
.code-group .chip { display: inline-flex; align-items: center; gap: 6px; }
.code-group .chip form { display: inline; margin: 0; }
.chip-x { min-height: 0; padding: 0 4px; background: none; border: 0; color: var(--muted); font-size: .8rem; cursor: pointer; box-shadow: none; }
.chip-x:hover { color: var(--danger); background: none; }
.group-add { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin-top: 14px; }
.group-add select { flex: 1 1 220px; width: auto; }
.code-row { display: grid; grid-template-columns: 150px 1fr auto; gap: 16px; align-items: center; padding: 11px 0; border-top: 1px solid var(--border); }
.code-row:first-child { border-top: none; }
.code-img {
  display: grid; place-items: center; width: 150px; height: 92px; padding: 6px;
  background: #fff; border: 1px solid var(--border); border-radius: 9px; cursor: zoom-in;
  transition: border-color .15s, box-shadow .15s;
}
.code-img:hover { border-color: var(--primary); box-shadow: var(--ring); }
.code-img { overflow: hidden; }
/* Картинки кодов маленькие (как в инструкции): растягиваем на всю рамку без размытия —
   коды чёрно-белые, чёткие пиксели им не вредят, а сканеру с экрана помогают. */
.code-row img { display: block; width: 100%; height: 78px; object-fit: contain; image-rendering: pixelated; }
.code-row .meta { font-size: .76rem; color: var(--muted); margin-top: 4px; display: flex; gap: 8px; flex-wrap: wrap; }
.code-row.off img, .code-row.off input[type="text"] { opacity: .5; }

/* Фото устройств */
.coverage { display: flex; align-items: center; gap: 16px; padding: 16px 20px; }
.cov-ico, .kb-ico {
  width: 42px; height: 42px; border-radius: 12px; flex-shrink: 0; display: grid; place-items: center;
  color: var(--ok); background: color-mix(in srgb, var(--ok-solid) 13%, transparent);
}
.cov-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 9px; }
.cov-pct { font-size: 1.5rem; font-weight: 720; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.coverage .bar-fill { background: linear-gradient(90deg, var(--ok-solid), color-mix(in srgb, var(--ok-solid) 70%, #7dd3a8)); }
.tip {
  display: flex; align-items: flex-start; gap: 10px; max-width: 820px;
  margin: 0 0 16px; padding: 11px 14px; border-radius: 11px;
  background: color-mix(in srgb, var(--primary) 7%, var(--surface)); border: 1px solid color-mix(in srgb, var(--primary) 22%, transparent);
  color: var(--text-2); font-size: .88rem; line-height: 1.5;
}
.tip > .ico { color: var(--accent); width: 18px; height: 18px; margin-top: 1px; }
.photo-models h3 { margin: 16px 0 8px; font-size: .95rem; color: var(--lvl-model); }
.photo-models h3:first-child { margin-top: 4px; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.photo-card {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 11px 12px 12px; scroll-margin-top: 90px;
  cursor: pointer; transition: box-shadow .15s, border-color .15s, background .15s;
}
.photo-card.missing { border-style: dashed; border-color: var(--border-strong); }
.photo-card:target, .photo-card.selected { box-shadow: 0 0 0 2px var(--primary); border-color: var(--primary); }
.photo-card:focus { outline: none; }
.photo-card.drop { border-color: var(--primary); border-style: solid; background: color-mix(in srgb, var(--primary) 8%, var(--surface)); }
.photo-card.busy { opacity: .55; pointer-events: none; }
.photo-card.pending { border-color: var(--warn-solid); border-style: dashed; }
.photo-card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; font-weight: 620; }
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; }
.thumb { position: relative; width: 76px; height: 76px; margin: 0; border-radius: 9px; overflow: hidden; background: #fff; border: 1px solid var(--border); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb form { position: absolute; top: 4px; right: 4px; }
.thumb button {
  width: 24px; height: 24px; min-height: 0; padding: 0; border-radius: 50%;
  background: rgba(0, 0, 0, .7); color: #fff; font-size: .72rem; line-height: 24px; border: none;
}
.thumb button:hover { background: var(--danger); }
.thumb-add {
  width: 76px; height: 76px; border: 1px dashed color-mix(in srgb, var(--primary) 55%, transparent); border-radius: 9px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--accent); cursor: pointer; font-size: .74rem; font-weight: 600; text-align: center;
}
.thumb-add .ico { width: 22px; height: 22px; }
.thumb-add:hover { background: color-mix(in srgb, var(--primary) 8%, transparent); }
.thumb-add input { display: none; }
.thumb-add.busy { opacity: .6; pointer-events: none; }
.paste-hint { display: none; margin-top: 8px; font-size: .78rem; color: var(--accent); }
.photo-card.selected .paste-hint { display: block; }

/* Кнопка занята, пока страница отвечает на отправку формы */
@keyframes spin { to { transform: rotate(360deg); } }
button.is-busy { cursor: progress; opacity: .85; }
button.is-busy::before {
  content: ""; display: inline-block; flex-shrink: 0; width: 14px; height: 14px; margin-right: 8px;
  border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%;
  animation: spin .7s linear infinite; vertical-align: -2px;
}
button.btn-icon.is-busy::before { margin: 0; }
button.btn-icon.is-busy > .ico { display: none; }

/* Всплывающие уведомления «Сохранено» */
.toasts {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 170;
  bottom: calc(max(20px, env(safe-area-inset-bottom)) + var(--toast-lift, 0px));
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  width: max-content; max-width: min(560px, calc(100vw - 24px)); pointer-events: none;
}
.toast {
  pointer-events: auto; display: flex; align-items: flex-start; gap: 10px;
  padding: 11px 10px 11px 14px; border-radius: 12px;
  background: var(--surface); border: 1px solid color-mix(in srgb, var(--ok-solid) 40%, var(--border));
  box-shadow: var(--shadow-lg); color: var(--text); font-size: .9rem; line-height: 1.45;
  animation: toast-up .22s ease both;
}
.toast > .ico { width: 18px; height: 18px; color: var(--ok); margin-top: 1px; }
.toast > span { flex: 1; min-width: 0; }
.toast.leaving { opacity: 0; transform: translateY(8px); transition: opacity .2s, transform .2s; }
.toast-close {
  min-height: 0; width: 26px; height: 26px; padding: 0; margin: -3px 0 -3px 4px; border: 0; border-radius: 7px;
  background: none; box-shadow: none; color: var(--muted); font-size: 1.15rem; line-height: 1;
}
.toast-close:hover { background: var(--surface-3); color: var(--text); }
@keyframes toast-up { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* Выбор нескольких заметок */
.note-pick { display: inline-flex; align-items: center; margin: -4px 2px -4px -2px; padding: 4px; cursor: pointer; }
.note-pick input { width: 18px; height: 18px; margin: 0; cursor: pointer; }
.note-card.picked { border-color: var(--primary); box-shadow: var(--ring); }
/* Центр — через margin: auto, а не transform: анимация появления сама меняет transform. */
.bulk-bar {
  position: fixed; left: 0; right: 0; margin-inline: auto; z-index: 165;
  bottom: max(18px, env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: center;
  width: max-content; max-width: calc(100vw - 24px); padding: 10px 12px; margin-block: 0;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 14px; box-shadow: var(--shadow-lg);
  animation: toast-up .2s ease both;
}
.bulk-count { font-size: .9rem; margin-right: 4px; white-space: nowrap; }
.bulk-actions { display: inline-flex; gap: 8px; }
@media (min-width: 961px) { .bulk-bar { left: var(--sb-w); } }

/* Общий поиск: кнопка в меню и окно поверх страницы */
.sb-search {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 38px; margin: 0 0 2px; padding: 7px 10px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); box-shadow: none;
  color: var(--muted); font: inherit; font-size: .9rem; font-weight: 520; cursor: pointer; text-align: left;
}
.sb-search:hover { border-color: var(--border-strong); color: var(--text); background: var(--surface-2); }
.sb-search .ico { width: 17px; height: 17px; }
.sb-search span { flex: 1; }
kbd {
  font-family: var(--font); font-size: .7rem; font-weight: 650; color: var(--muted);
  padding: 1px 6px; border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 6px; background: var(--surface);
}
dialog.palette {
  width: min(640px, calc(100vw - 24px)); max-height: min(560px, 80dvh); margin: 12vh auto auto; padding: 0;
  border: 1px solid var(--border-strong); border-radius: 16px; background: var(--surface); color: var(--text);
  box-shadow: var(--shadow-lg); overflow: hidden;
}
dialog.palette[open] { animation: toast-up .16s ease both; }
dialog.palette::backdrop { background: var(--overlay); backdrop-filter: blur(2px); }
.palette-box { display: flex; flex-direction: column; max-height: inherit; }
.palette-field { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.palette-field .ico { width: 20px; height: 20px; color: var(--muted); }
.palette-field input { border: 0; background: transparent; padding: 6px 0; min-height: 0; font-size: 1.05rem; box-shadow: none; }
.palette-field input:focus { outline: none; box-shadow: none; }
.palette-list { overflow-y: auto; padding: 6px 8px 10px; overscroll-behavior: contain; }
.palette-group { padding: 10px 10px 4px; font-size: .74rem; font-weight: 700; color: var(--muted); }
.palette-item {
  display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 10px; color: var(--text);
}
.palette-item:hover { text-decoration: none; }
.palette-item[aria-selected="true"] { background: color-mix(in srgb, var(--primary) 11%, transparent); }
.palette-item > .ico { width: 18px; height: 18px; color: var(--muted); }
.pi-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.pi-title { font-weight: 560; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pi-sub { font-size: .8rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pi-kind { flex-shrink: 0; font-size: .72rem; color: var(--muted); padding: 1px 8px; border-radius: 20px; background: var(--surface-3); }
.palette-empty { margin: 0; padding: 22px 12px; text-align: center; color: var(--muted); }
.palette-foot { display: flex; gap: 16px; padding: 9px 16px; border-top: 1px solid var(--border); font-size: .76rem; color: var(--muted); }
.palette-foot kbd { margin-right: 3px; }

/* «Показать ещё» под длинным списком */
.show-more { display: block; width: 100%; margin: 4px 0 12px; }

/* Панель «Фото для … — загружу через 4 с»: пауза, чтобы отменить не то фото */
.upload-toast {
  position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 160;
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 10px 12px; box-shadow: var(--shadow-lg); max-width: calc(100vw - 24px);
  animation: toast-in .2s ease both;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }
.upload-toast .mini { display: flex; gap: 6px; flex-shrink: 0; }
.upload-toast .mini img { width: 48px; height: 48px; object-fit: cover; border-radius: 7px; background: #fff; display: block; }
.upload-toast .txt { display: flex; flex-direction: column; gap: 2px; font-size: .9rem; min-width: 0; }
.upload-toast .count { color: var(--warn); font-size: .8rem; font-variant-numeric: tabular-nums; }

/* ===== Вкладки страницы ===== */
.tabbar {
  display: flex; gap: 4px; margin: 0 0 18px; border-bottom: 1px solid var(--border);
  overflow-x: auto; scrollbar-width: none;
}
.tabbar::-webkit-scrollbar { display: none; }
.tabbar a {
  display: inline-flex; align-items: center; gap: 8px; flex-shrink: 0;
  padding: 10px 14px 11px; margin-bottom: -1px;
  color: var(--muted); font-weight: 600; font-size: .93rem; white-space: nowrap;
  border-bottom: 2px solid transparent; border-radius: 8px 8px 0 0;
}
.tabbar a:hover { color: var(--text); background: var(--surface-3); text-decoration: none; }
.tabbar a.current { color: var(--text); border-bottom-color: var(--primary); }
.tab-n {
  display: inline-block; min-width: 22px; padding: 1px 7px; border-radius: 20px; text-align: center;
  font-size: .74rem; font-weight: 700; font-variant-numeric: tabular-nums;
  color: var(--muted); background: var(--surface-3);
}
.tab-n.warn { color: #3a2500; background: var(--warn-solid); }
.tabbar a.current .tab-n:not(.warn) { color: var(--accent); background: color-mix(in srgb, var(--primary) 14%, transparent); }
.panel-title h2 .tab-n { margin-left: 4px; }

/* Фильтры: те же сегменты, что у периода, только кнопками */
.seg button {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 30px; padding: 4px 13px; border-radius: 8px; border: 0;
  background: transparent; color: var(--muted); box-shadow: none;
  font: inherit; font-size: .86rem; font-weight: 580; white-space: nowrap; cursor: pointer; transform: none;
}
.seg button:hover { background: transparent; color: var(--text); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); font-weight: 650; box-shadow: var(--shadow); }

/* Заголовок панели со значком */
.panel-title h2 { display: flex; align-items: center; gap: 9px; }
.panel-title h2 > .ico { width: 19px; height: 19px; color: var(--muted); }
.panel-title > a { display: inline-flex; align-items: center; gap: 6px; font-size: .88rem; font-weight: 600; }
.panel-title > a .ico { width: 16px; height: 16px; }

/* Паспорта: строка на номер, раскрывается по нажатию */
.pp-device h2 { margin-bottom: 4px; }
.pp-model h3 { margin: 16px 0 8px; font-size: .95rem; color: var(--lvl-model); }
details.pp-row {
  border: 1px solid var(--border); border-radius: 11px; margin: 0 0 8px; background: var(--surface);
  scroll-margin-top: 90px;
}
details.pp-row.pp-proposed { border-left: 3px solid var(--warn-solid); }
details.pp-row.pp-missing { border-style: dashed; background: transparent; }
details.pp-row:target { box-shadow: 0 0 0 2px var(--primary); }
details.pp-row > summary {
  display: grid; grid-template-columns: auto auto auto minmax(0, 1fr) auto; gap: 6px 12px; align-items: center;
  padding: 11px 14px; font-weight: normal; border-radius: 11px;
}
details.pp-row[open] > summary { border-bottom: 1px solid var(--border); border-radius: 11px 11px 0 0; }
.pp-name { font-weight: 650; white-space: nowrap; }
.pp-snippet { min-width: 0; color: var(--muted); font-size: .86rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pp-meta { grid-column: -2 / -1; font-size: .78rem; color: var(--muted); white-space: nowrap; }
details.pp-row[open] .pp-snippet { display: none; }
.pp-body { padding: 14px 16px 16px; }
.pp-body > .note-edit-form { margin-top: 0; }

/* Файлы с кодами: список строк вместо стопки карточек */
.sources-panel .search { margin: 0 0 10px; max-width: 420px; }
.src-list { display: flex; flex-direction: column; }
.src-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 8px 22px; align-items: center;
  padding: 12px 4px; border-top: 1px solid var(--border);
}
.src-list > .src-row:first-child { border-top: 0; }
.src-name { font-weight: 620; color: var(--text); overflow-wrap: anywhere; }
.src-name:hover { color: var(--accent); }
.src-sub { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-top: 5px; font-size: .82rem; color: var(--muted); }
.src-sub .pill { font-size: .74rem; padding: 1px 10px 1px 8px; }
.src-facts { display: flex; gap: 4px 16px; flex-wrap: wrap; justify-content: flex-end; font-size: .84rem; color: var(--muted); white-space: nowrap; }
.src-facts b { color: var(--text); font-variant-numeric: tabular-nums; }
.src-actions { display: flex; gap: 6px; align-items: center; justify-content: flex-end; }
.src-actions a.btn-sec .ico { width: 15px; height: 15px; margin-left: 4px; }
.src-actions button.danger.btn-icon { background: transparent; color: var(--danger); border: 1px solid var(--border-strong); box-shadow: none; }
.src-actions button.danger.btn-icon:hover { background: var(--danger); border-color: var(--danger); color: #fff; }
.src-row .progress { max-width: 360px; }

/* Пакет знаний */
.kb-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; margin: 0 0 14px; }
.kb-grid > .panel { margin: 0; }
.kb-card { display: flex; flex-direction: column; }
.kb-card .kb-ico { margin-bottom: 12px; }
.kb-ico.import { color: var(--accent); background: color-mix(in srgb, var(--primary) 13%, transparent); }
.kb-card h2 { margin: 0 0 6px; }
.kb-card > p { font-size: .9rem; }
.kb-action { align-self: flex-start; margin-top: auto; display: inline-flex; align-items: center; gap: 8px; }
.kb-action .ico, .kb-card button .ico { width: 17px; height: 17px; }
.kb-card button { display: inline-flex; align-items: center; gap: 8px; }
.stack label.check-row { flex-direction: row; align-items: flex-start; gap: 10px; font-weight: 450; font-size: .9rem; color: var(--text); }
.check-row input { margin-top: 3px; }
.kb-facts { margin: 4px 0 10px; padding-left: 20px; color: var(--text-2); }
.kb-report pre { max-height: 420px; overflow: auto; font-size: .78rem; }

/* ===== Вход ===== */
.login-page {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; min-height: 100dvh; padding: 20px;
  overflow: hidden;
}
.login-card {
  position: relative;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  -webkit-backdrop-filter: blur(20px) saturate(150%); backdrop-filter: blur(20px) saturate(150%);
  border: 1px solid color-mix(in srgb, var(--border-strong) 60%, transparent); border-radius: 20px;
  padding: 34px 34px 30px; width: 100%; max-width: 380px;
  display: flex; flex-direction: column; gap: 14px;
  box-shadow: var(--shadow-lg);
}
.login-logo { width: 56px; height: 56px; margin: 0 auto 2px; filter: drop-shadow(0 8px 18px color-mix(in srgb, var(--primary) 45%, transparent)); }
.login-card h1 { margin: 0; text-align: center; font-size: 1.35rem; }
.login-card p { margin: -6px 0 6px; }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-size: .88rem; color: var(--text-2); font-weight: 600; }
.login-card button { margin-top: 6px; min-height: 44px; font-size: .96rem; }

/* Личный пароль: у вложенной формы собственная сетка и ритм отступов. */
.first-password-page { overflow-x: hidden; overflow-y: auto; padding: 24px 16px; }
.login-card.password-card { max-width: 440px; padding: 32px; gap: 24px; margin: auto; }
.password-header { display: grid; justify-items: center; gap: 12px; text-align: center; }
.password-header .login-logo { margin: 0 0 4px; display: block; }
.password-card h1 { font-size: 1.45rem; line-height: 1.25; text-wrap: balance; }
.password-card .password-header p { margin: 0; font-size: .9rem; line-height: 1.6; overflow-wrap: anywhere; }
.password-form { display: grid; gap: 20px; }
.password-field { display: grid; gap: 8px; min-width: 0; }
.password-card label { gap: 0; }
.password-field input { width: 100%; min-width: 0; min-height: 48px; font-size: 16px; }
.password-rules { display: grid; gap: 8px; margin: 0; padding: 12px 14px; list-style: none;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2);
  color: var(--muted); font-size: .82rem; line-height: 1.45; }
.password-rules li { display: flex; align-items: center; gap: 9px; }
.password-rule-mark { width: 14px; height: 14px; flex: 0 0 14px; border: 1px solid var(--border-strong); border-radius: 50%; position: relative; }
.password-rules .is-met { color: var(--ok); }
.is-met .password-rule-mark { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, transparent); }
.is-met .password-rule-mark::after { content: ""; position: absolute; width: 6px; height: 3px; top: 3px; left: 3px;
  border-left: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(-45deg); }
.password-card p.password-match, .password-match { margin: 0; min-height: 20px; color: var(--muted); font-size: .8rem; line-height: 1.5; }
.password-match.is-met { color: var(--ok); }
.password-match.is-mismatch { color: var(--danger); }
.password-card p.password-note { margin: -4px 0 0; font-size: .8rem; line-height: 1.5; color: var(--muted); }
.password-card .password-form > button { margin: 0; width: 100%; min-height: 48px; }
.password-card p.password-error { margin: 0; padding: 12px 14px; font-size: .88rem; border-radius: 10px;
  color: var(--danger); background: color-mix(in srgb, var(--danger) 8%, var(--surface)); border: 1px solid color-mix(in srgb, var(--danger) 25%, var(--border)); }
.password-footer { border-top: 1px solid var(--border); padding-top: 12px; margin-top: -4px; text-align: center; }
.password-card .password-exit { margin: 0; padding: 8px 12px; width: auto; min-height: 40px;
  color: var(--muted); background: transparent; border: 0; box-shadow: none; font-size: .85rem; }
.password-card .password-exit:hover { color: var(--text); background: var(--surface-3); }
@media (max-width: 480px) {
  .login-card.password-card { padding: 26px 22px 18px; gap: 22px; }
}

/* ===== Страница ошибки ===== */
.error-page { text-align: center; padding: 48px 20px; }
.error-code { font-size: 3.4rem; font-weight: 800; color: var(--accent); line-height: 1; letter-spacing: -.03em; }
.error-page h1 { margin: 10px 0 10px; }
.error-page p { margin: 0 0 18px; }
.error-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* =========================================================================
   Узкие экраны. Медиазапрос не добавляет специфичности, поэтому все
   переопределения собраны здесь, в конце файла.
   ========================================================================= */
@media (max-width: 1100px) {
  main { padding: 26px 26px 110px; }
}

/* Планшет и телефон: меню выезжает слева по кнопке из верхней панели */
@keyframes mobile-page-out { from { opacity: 1; } to { opacity: 0; } }
@keyframes mobile-page-in { from { opacity: 0; } to { opacity: 1; } }

@media (max-width: 960px) {
  /* The offscreen drawer is not part of the page transition. */
  .sidebar { view-transition-name: none; }
  /* Crossfade without stretching a long page into the destination's geometry. */
  ::view-transition-group(content) { animation: none; }
  ::view-transition-old(content) { animation: mobile-page-out .16s ease-out both; }
  ::view-transition-new(content) { animation: mobile-page-in .16s ease-out both; }
  .app { display: block; background: none; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 210;
    width: min(304px, 86vw);
    transform: translateX(-104%);
    transition: transform .26s cubic-bezier(.2, .8, .2, 1), box-shadow .26s;
    padding-top: max(14px, env(safe-area-inset-top));
    border-right: 1px solid var(--border);
    background: var(--sidebar);
    touch-action: pan-y pinch-zoom;
  }
  body.menu-open { overflow: hidden; }
  body.menu-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  .sidebar .sb-close { display: inline-grid; }
  .sb-backdrop {
    display: block; position: fixed; inset: 0; z-index: 200;
    background: var(--overlay); opacity: 0; pointer-events: none; transition: opacity .2s;
  }
  body.menu-open .sb-backdrop { opacity: 1; pointer-events: auto; }
  .appbar {
    display: flex; align-items: center; gap: 4px;
    position: sticky; top: 0; z-index: 100;
    min-height: 56px; padding: env(safe-area-inset-top) 6px 0;
    background: color-mix(in srgb, var(--bg) 82%, transparent);
    -webkit-backdrop-filter: saturate(1.6) blur(14px); backdrop-filter: saturate(1.6) blur(14px);
    border-bottom: 1px solid var(--border);
  }
  .appbar-title { flex: 1; min-width: 0; font-weight: 650; font-size: 1rem; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

@media (max-width: 640px) {
  body { font-size: 15px; }
  main { padding: 16px 14px 120px; }
  h1 { font-size: 1.35rem; margin-bottom: 12px; }
  h2 { font-size: 1.05rem; }
  /* 16 px в полях — иначе iPhone приближает страницу при вводе */
  input, textarea, select { font-size: 16px; }

  .panel { padding: 16px; margin: 12px 0; border-radius: 12px; }
  .card { padding: 16px; }
  .cards { grid-template-columns: 1fr; gap: 12px; }
  .columns { grid-template-columns: 1fr; gap: 12px; }
  .stats-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stats-cards .card { padding: 13px 13px 12px; font-size: .8rem; }
  .stats-cards .big { font-size: 1.5rem; }
  .chart-box { height: 240px; }
  .period-picker { margin-bottom: 14px; }
  .period-label { display: none; }
  .period-bar > .seg { flex: 1 1 100%; }
  .period-bar > .seg a { flex: 1; padding: 4px 4px; font-size: .82rem; }
  .range-form { flex: 1 1 100%; display: grid; grid-template-columns: 40px 1fr 1fr 40px; gap: 6px; align-items: end; }
  .range-form .range-step { width: 40px; height: 44px; }
  .range-field { display: flex; flex-direction: column; align-items: stretch; gap: 2px; font-size: .74rem; }
  .range-field input { width: 100%; min-width: 0; padding: 6px 8px; }
  .range-form button { grid-column: 1 / -1; width: 100%; }
  .ai-stats .kpis { grid-template-columns: 1fr 1fr; gap: 8px; }
  .kpi { padding: 10px 12px; }
  .kpi b { font-size: 1.3rem; }
  .toolbar > .seg { flex: 1 1 100%; flex-wrap: wrap; }
  .toolbar > .seg > * { flex: 1 0 auto; }
  .coverage { padding: 14px 16px; gap: 12px; }
  .cov-ico { display: none; }
  .cov-pct { font-size: 1.25rem; }
  details.pp-row > summary { grid-template-columns: auto minmax(0, 1fr) auto; padding: 11px 12px; }
  .pp-name { white-space: normal; }
  .pp-snippet { grid-column: 2 / -1; grid-row: 2; }
  .pp-meta { display: none; }
  .pp-body { padding: 12px; }
  .src-row { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "main main" "facts actions"; gap: 8px 12px; }
  .src-main { grid-area: main; }
  .src-facts { grid-area: facts; justify-content: flex-start; gap: 2px 12px; font-size: .8rem; }
  .src-actions { grid-area: actions; align-self: end; }
  .sources-panel .search { max-width: none; }
  /* Вкладки шире экрана прокручиваются; затухание справа подсказывает, что там есть ещё */
  .tabbar {
    margin-left: -14px; margin-right: -14px; padding: 0 28px 0 10px;
    -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 30px), transparent);
            mask-image: linear-gradient(90deg, #000 calc(100% - 30px), transparent);
  }
  .tabbar a { padding: 10px 9px 11px; gap: 6px; font-size: .9rem; }
  .toasts { width: calc(100vw - 24px); }
  .bulk-bar { width: calc(100vw - 24px); }
  dialog.palette { margin-top: max(10px, env(safe-area-inset-top)); max-height: calc(100dvh - 24px); }
  .palette-foot { display: none; }
  .palette-field input { font-size: 16px; }
  .bulk-actions { margin-left: auto; }
  .toast { width: 100%; }
  .hide-sm { display: none; }
  .lead.clamped {
    display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-clamp: 3;
    overflow: hidden; margin-bottom: 2px;
  }
  .lead-more {
    min-height: 32px; padding: 4px 0; margin: 0 0 10px; border: 0; background: none; box-shadow: none;
    color: var(--accent); font-size: .88rem; font-weight: 600;
  }
  .lead-more:hover { background: none; text-decoration: underline; }
  .seg { flex: 1 1 100%; }
  .seg a { flex: 1; padding: 4px 6px; }
  .panel.collapsible > summary { padding: 14px 16px; }
  .panel.collapsible > .panel-body { padding: 2px 16px 16px; }

  /* Дерево: ветвление уже, кнопки строк переносятся */
  :root { --branch-indent: 15px; --branch-gap: 10px; }
  details > summary { padding: 12px; flex-wrap: wrap; }
  details .level-body, details .question-body { padding: 6px 10px 14px; }
  .tree-meta { margin-left: 0; flex-basis: 100%; padding-left: 20px; }
  .tree-toolbar { gap: 6px; }
  .tree-search { flex: 1 1 100%; min-width: 0; }
  .tree-toolbar button { flex: 1 1 calc(50% - 3px); }
  form.inline { flex-wrap: wrap; }
  .rename-form { width: 100%; }
  form.inline input { min-width: 0; flex: 1 1 140px; }
  .row-actions { gap: 6px; }
  .add-form { flex-wrap: wrap; }
  .add-form input, .add-form button { flex: 1 1 100%; }
  .level-body > .node-actions { float: none; margin: 6px 0 10px; }
  .upload input[type="file"], .upload select, .upload button { width: 100%; min-width: 0; flex: 1 1 100%; }
  .upload-row { grid-template-columns: 1fr; }

  /* Таблица шире экрана прокручивается внутри себя, а не всей страницей */
  table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  /* Панель не раздувается под минимальную ширину таблицы, а страницу нельзя утянуть вбок */
  .panel, .ai-page, main { min-width: 0; max-width: 100%; }
  body { overflow-x: hidden; }
  .pyrus-log th, .pyrus-log td.nowrap { white-space: normal; }
  .br-bar { display: none; }

  .backup-panel { flex-wrap: wrap; }
  .backup-panel .btn-link, .backup-panel button { width: 100%; }
  .bot-grid { grid-template-columns: 1fr; gap: 12px; }
  .card-links { grid-template-columns: 1fr 1fr; }
  .toolbar .seg { flex: 1 1 100%; }
  .toolbar .seg a { flex: 1; padding: 4px 6px; }
  .stack button, .login-card button { width: 100%; align-self: stretch; }
  .stack .row button { width: auto; flex: 1 1 auto; }

  /* Панели внизу экрана — почти во всю ширину */
  .draft-bar { left: 12px; right: 12px; transform: translateY(120px); justify-content: space-between; padding: 10px 12px; }
  .draft-bar.visible { transform: translateY(0); }
  .upload-toast { left: 12px; right: 12px; transform: none; flex-wrap: wrap; animation: none; }

  /* ИИ-помощник */
  .ai-head { margin-bottom: 14px; }
  .msg-photos img { max-width: 100%; }
  .note-card { padding: 13px; }
  .note-foot .push-right { margin-left: 0; }
  .source-card { grid-template-columns: 1fr; }
  .source-card .actions { justify-content: flex-start; }
  /* Картинка и переключатель — сверху, подпись — во всю ширину под ними */
  .code-row { grid-template-columns: auto 1fr auto; grid-template-areas: "img . sw" "cap cap cap"; gap: 10px; }
  .code-row > .code-img { grid-area: img; width: 120px; height: 80px; }
  .code-row > .switch { grid-area: sw; align-self: start; }
  .code-row > div { grid-area: cap; }
  .code-row img { height: 66px; }
  .fields-grid { grid-template-columns: 1fr; }
  .photo-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
  .recent a { grid-template-columns: 32px 1fr; }
  .recent .when { grid-column: 2; text-align: left; }
  .import-actions { white-space: normal; text-align: left; }
  .login-card { padding: 28px 22px 24px; }
}

/* Пальцем по экрану — крупнее цели нажатия */
@media (pointer: coarse) {
  .sb-item { min-height: 46px; }
  button, .btn-link, a.btn-sec { min-height: 44px; }
  button.btn-sm, a.btn-sm, .btn-sm, form.inline button, details.note-edit > summary { min-height: 40px; }
  .seg a { min-height: 36px; }
  button.btn-icon, form.inline button.btn-icon { width: 40px; min-height: 40px; }
  .chip, button.chip { min-height: 38px; }
  .chip-x, .thumb button { min-height: 0; }
  input, select { min-height: 44px; }
}

/* Уважение к системной настройке «меньше движения» */
@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
  html { scroll-behavior: auto; }
}

/* Review state is separate from the client's outcome. */
.dialogue-status-row { display:flex; flex-wrap:wrap; align-items:center; gap:8px 16px; padding:8px 12px; margin-bottom:18px; }
.dialogue-status-primary { display:flex; align-items:center; gap:8px; min-width:0; }
.dialogue-clock { display:flex; flex-wrap:wrap; align-items:center; gap:4px 8px; min-width:0; }
.dialogue-clock span { color:var(--muted); font-size:.85rem; }
.dialogue-clock b { white-space:nowrap; font-size:.95rem; }
.dialogue-updated { margin-left:auto; }
button.dialogue-refresh { width:32px; min-height:32px; padding:0; flex-shrink:0; }
.dialogue-bot-filter { display:flex; align-items:center; gap:8px; margin:0; }
.dashboard-heading { display:flex; justify-content:space-between; align-items:center; gap:16px; flex-wrap:wrap; margin-bottom:24px; }
.dashboard-heading h1 { margin:0; }
.dialogue-bot-filter select { width:auto; max-width:240px; margin:0; }
.dlg-bot { color:var(--accent); font-size:.75rem; font-weight:500; }
@media(max-width:600px) {
  .dialogue-bot-filter { width:100%; }
  .dialogue-bot-filter select { flex:1; min-width:0; max-width:none; }
}
button.dialogue-refresh .ico { width:18px; height:18px; }
.dialogue-refresh .refresh-spinner { display:none; }
.dialogue-refresh[aria-busy="true"] .refresh-symbol { display:none; }
.dialogue-refresh[aria-busy="true"] .refresh-spinner { display:block; animation:refresh-spin .8s linear infinite; }
@keyframes refresh-spin { to { transform:rotate(360deg); } }
.dialogue-refresh-error { flex-basis:100%; font-size:.85rem; color:var(--danger); }
.dialogue-refresh-error:empty { display:none; }
@media (max-width:600px) {
  .dialogue-status-primary { width:100%; }
  .dialogue-status-primary .dialogue-clock { flex:1; }
  .dialogue-updated { margin-left:0; }
  button.dialogue-refresh { width:44px; min-height:44px; }
}
.avatar { position:relative; overflow:hidden; }
.avatar img { position:absolute; inset:0; width:100%; height:100%; object-fit:cover; border-radius:inherit; }

/* Reviewed procedures and offline quality lab; inherit existing themes and navigation. */
.quality-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.quality-grid .panel { margin: 0; }
.quality-card, .quality-case { min-width: 0; }
.quality-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; }
.quality-toolbar h2 { flex: 1 1 200px; margin: 0; }
.quality-select { flex: 1 1 300px; min-width: 0; display: grid; gap: 8px; }
.quality-select select { width: 100%; min-width: 0; }
.quality-source { overflow-wrap: anywhere; font-size: .86rem; }
.quality-case > summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.quality-turn { border-top: 1px solid var(--border); margin-top: 16px; padding-top: 12px; }
.quality-question { white-space: pre-wrap; color: var(--muted); }
.quality-reply { padding: 14px 16px; border: 1px solid var(--border); border-radius: 12px;
  background: var(--surface-2); white-space: pre-wrap; overflow-wrap: anywhere; }
@media (max-width: 1000px) { .quality-grid { grid-template-columns: minmax(0, 1fr); } }

/* Единое рабочее пространство профиля, сотрудников и журнала. */
.access-workspace { max-width: 1160px; margin: 0 auto; }
.workspace-nav { display: flex; gap: 5px; width: max-content; max-width: 100%; overflow-x: auto; margin: 0 0 28px;
  padding: 5px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.workspace-nav a { display: flex; align-items: center; padding: 8px 14px; min-height: 40px; color: var(--muted);
  border-radius: 8px; font-size: .87rem; white-space: nowrap; font-weight: 600; text-decoration: none; }
.workspace-nav a.active { color: var(--accent); background: color-mix(in srgb, var(--primary) 12%, var(--surface)); }
.workspace-nav a:hover { color: var(--text); }
.access-heading { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin: 0 0 26px; }
.access-heading h1 { margin: 0 0 8px; font-size: 1.8rem; }
.access-heading p { margin: 0; color: var(--muted); font-size: .9rem; }
.access-heading p.access-eyebrow { margin: 0 0 8px; font-size: .72rem; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--accent); }
.access-heading .btn-link, .access-heading .btn-sec { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; white-space: nowrap; }
.access-heading .ico { width: 18px; height: 18px; }
.identity-banner { display: flex; align-items: center; gap: 18px; padding: 22px 24px; margin: 0 0 24px;
  border: 1px solid var(--border); border-radius: 16px; background: color-mix(in srgb, var(--surface) 96%, transparent); }
.identity-banner > div:not(.identity-avatar) { min-width: 0; }
.identity-banner h2, .identity-banner h1 { margin: 0 0 4px; font-size: 1.3rem; overflow-wrap: anywhere; }
.identity-banner p { margin: 0; font-size: .87rem; color: var(--muted); overflow-wrap: anywhere; }
.identity-banner > .access-role, .employee-banner > .employee-badges { margin-left: auto; }
.identity-avatar { width: 54px; height: 54px; flex: 0 0 54px; display: grid; place-items: center; border-radius: 15px;
  background: color-mix(in srgb, var(--primary) 15%, var(--surface)); color: var(--accent); font-weight: 700; font-size: 1.25rem; }
.identity-avatar.small { width: 42px; height: 42px; flex-basis: 42px; border-radius: 12px; font-size: 1rem; }
.access-role { display: inline-flex; align-items: center; width: max-content; max-width: 100%; font-size: .76rem; font-weight: 600;
  color: var(--text-2); background: var(--surface-3); padding: 5px 9px; border-radius: 6px; }
.access-status { display: inline-flex; align-items: center; gap: 6px; font-size: .76rem; line-height: 1.4; }
.access-status::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; flex: 0 0 5px; }
.access-status.ok { color: var(--ok); }.access-status.warn { color: var(--warn); }.access-status.error { color: var(--danger); }
.access-tabs { display: flex; gap: 22px; overflow-x: auto; margin: 0 0 24px; border-bottom: 1px solid var(--border); }
.access-tabs a { display: inline-flex; align-items: center; gap: 7px; padding: 0 0 13px; border-bottom: 2px solid transparent;
  color: var(--muted); white-space: nowrap; text-decoration: none; font-size: .9rem; font-weight: 600; }
.access-tabs a.active { border-color: var(--primary); color: var(--accent); }
.access-tabs a span { padding: 1px 6px; border-radius: 5px; background: var(--surface-3); font-size: .73rem; }
.access-columns { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 22px; align-items: start; }
.access-panel { min-width: 0; padding: 24px; border: 1px solid var(--border); border-radius: 14px;
  background: color-mix(in srgb, var(--surface) 97%, transparent); }
.access-panel h2 { margin: 0 0 10px; font-size: 1.05rem; }.access-panel h3 { font-size: .92rem; }
.access-narrow { max-width: 680px; margin-left: auto; margin-right: auto; }
.access-section-head { display: flex; align-items: start; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.access-section-head h2 { margin-bottom: 6px; }.access-section-head p { margin: 0; color: var(--muted); font-size: .86rem; line-height: 1.55; }
.access-form { display: grid; gap: 18px; min-width: 0; }
.account-delete-panel { margin-top: 22px; }
.account-delete-panel .access-form { max-width: 560px; margin-top: 18px; }
.access-form label:not(.access-check), .access-filters label { display: flex; flex-direction: column; gap: 8px; color: var(--text-2); font-size: .85rem; font-weight: 600; min-width: 0; }
.access-form input:not([type=checkbox]), .access-form select, .access-filters input, .access-filters select { width: 100%; min-width: 0; min-height: 44px; }
.access-form p.access-help, .access-help { margin: -6px 0 0; color: var(--muted); font-size: .8rem; font-weight: 400; line-height: 1.55; }
.access-form-actions { display: flex; align-items: center; gap: 18px; padding-top: 3px; }
.access-form-actions button { min-height: 44px; }.access-form-actions a { font-size: .85rem; }
.access-field-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.access-capabilities { list-style: none; padding: 0; margin: 22px 0; display: grid; gap: 16px; font-size: .88rem; }
.access-capabilities li { display: flex; align-items: start; gap: 10px; line-height: 1.55; }.access-capabilities .ico { color: var(--accent); width: 18px; height: 18px; margin-top: 2px; }
.access-text-link { display: flex; align-items: center; gap: 8px; border-top: 1px solid var(--border); padding-top: 18px; font-size: .86rem; }
.access-text-link .ico { margin-left: auto; width: 16px; height: 16px; }
.access-notice { margin: 0 0 20px; border: 1px solid var(--border); border-radius: 10px; padding: 12px 16px; font-size: .88rem; }
.access-notice.ok { color: var(--ok); background: color-mix(in srgb, var(--ok) 6%, var(--surface)); }
.access-notice.error { color: var(--danger); background: color-mix(in srgb, var(--danger) 7%, var(--surface)); }
.access-metrics { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 12px; margin: 0 0 22px; }
.access-metrics > div { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 17px 18px;
  border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.access-metrics span { color: var(--muted); font-size: .78rem; max-width: 115px; }.access-metrics strong { font-size: 1.5rem; letter-spacing: -.04em; }
.access-filters { display: flex; align-items: end; flex-wrap: wrap; gap: 12px; padding: 18px; margin: 0 0 22px;
  border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.access-filters label { flex: 1 1 140px; }.access-filters label.access-search { flex: 2 1 220px; }
.access-filters button { min-height: 44px; }.access-filter-reset { align-self: end; padding-bottom: 12px; font-size: .85rem; }
.access-list-heading { display: flex; justify-content: space-between; gap: 12px; margin: 0 0 12px; font-size: .76rem; color: var(--muted); }
.employee-list { display: grid; gap: 10px; }
.employee-row { display: grid; grid-template-columns: 42px minmax(150px,1fr) minmax(150px,1fr) minmax(140px,auto) 18px; align-items: center;
  gap: 18px; padding: 18px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); text-decoration: none; }
.employee-row:hover { border-color: var(--border-strong); background: var(--surface-2); text-decoration: none; }
.employee-identity { display: grid; gap: 5px; min-width: 0; }.employee-identity b { font-size: .94rem; overflow-wrap: anywhere; }
.employee-identity span { color: var(--muted); font-size: .79rem; overflow-wrap: anywhere; }
.employee-badges { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; min-width: 0; }
.employee-activity { display: grid; gap: 5px; text-align: right; font-size: .76rem; color: var(--text-2); }.employee-activity small { font-size: .73rem; color: var(--muted); }
.employee-row > .ico { width: 18px; height: 18px; color: var(--muted); }
.access-pagination { display: flex; justify-content: center; align-items: center; gap: 18px; margin: 24px 0; font-size: .85rem; }
.access-empty { text-align: center; padding: 38px 20px; border: 1px dashed var(--border-strong); border-radius: 12px; color: var(--muted); }
.access-empty h2 { color: var(--text); font-size: 1rem; margin-top: 0; }.access-empty p { font-size: .88rem; }
.access-role-guide { margin-top: 24px; font-size: .84rem; }.access-role-guide > summary { color: var(--muted); cursor: pointer; }
.role-cards { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 16px; margin-top: 16px; }
.role-cards section { padding: 18px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; }.role-cards h3 { margin: 0 0 12px; }
.role-cards ul { margin: 0; padding-left: 18px; display: grid; gap: 10px; color: var(--muted); }
.access-back { display: inline-flex; align-items: center; gap: 7px; font-size: .85rem; color: var(--muted); margin-bottom: 20px; }.access-back .ico { width: 17px; height: 17px; }
.access-facts { display: grid; gap: 14px; margin: 18px 0; font-size: .84rem; }.access-facts > div { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.access-facts dt { color: var(--muted); }.access-facts dd { margin: 0; overflow-wrap: anywhere; }
.access-check { display: flex; align-items: start; gap: 12px; padding: 14px; border: 1px solid var(--border); border-radius: 10px; }
.access-check input { margin-top: 3px; }.access-check span { display: grid; gap: 6px; }.access-check b { font-size: .86rem; }.access-check small { color: var(--muted); font-size: .8rem; font-weight: 400; }
.access-reauth { border-top: 1px solid var(--border); padding-top: 18px; margin-top: 2px; }.access-reauth p { margin: 8px 0 0; color: var(--muted); font-size: .78rem; }
.access-field-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.access-small-action { background: transparent; color: var(--accent); border: 0; border-radius: 5px; box-shadow: none; padding: 4px 6px; min-height: 30px; font-size: .8rem; }
.access-small-action:hover { background: var(--surface-3); }
.access-password-input { display: flex; align-items: center; gap: 5px; border: 1px solid var(--border-strong); border-radius: 9px; padding-right: 6px; background: var(--input); }
.access-password-input:focus-within { border-color: var(--primary); box-shadow: var(--ring); }.access-password-input input { border: 0; box-shadow: none; background: transparent; flex: 1; }
.access-password-input input:focus { box-shadow: none; }.access-password-input button { flex: 0 0 auto; }
.access-onboarding { border-top: 1px solid var(--border); margin-top: 22px; padding-top: 16px; }.access-onboarding h3 { margin-top: 0; }.access-onboarding ol { padding-left: 18px; margin-bottom: 0; display: grid; gap: 12px; font-size: .85rem; color: var(--muted); }
.access-sessions { display: grid; gap: 0; }.access-session { display: flex; align-items: start; gap: 14px; padding: 18px 0; border-top: 1px solid var(--border); }
.access-session-body { flex: 1; min-width: 0; }.access-session-icon { width: 38px; height: 38px; flex: 0 0 38px; background: var(--surface-3); border-radius: 10px; display: grid; place-items: center; color: var(--muted); }
.access-session-title { display: flex; flex-wrap: wrap; gap: 9px; align-items: center; font-size: .88rem; }.access-session p { color: var(--muted); font-size: .79rem; margin: 7px 0 4px; }
.access-session small { color: var(--muted); font-size: .75rem; }.access-technical { margin-top: 10px; font-size: .76rem; }.access-technical summary { color: var(--muted); cursor: pointer; }.access-technical p { overflow-wrap: anywhere; font-size: .76rem; }
.access-session-revoke { padding-top: 18px; border-top: 1px solid var(--border); }
.access-activity-row { display: grid; grid-template-columns: 8px minmax(0,1fr) auto; align-items: start; gap: 14px; padding: 17px 0; border-top: 1px solid var(--border); font-size: .86rem; }
.activity-dot { width: 7px; height: 7px; margin-top: 7px; border-radius: 50%; background: var(--muted); }.activity-dot.ok { background: var(--ok); }.activity-dot.denied { background: var(--warn); }.activity-dot.error { background: var(--danger); }
.access-activity-row p { margin: 6px 0 0; color: var(--muted); font-size: .78rem; overflow-wrap: anywhere; }.access-activity-row time { font-size: .75rem; color: var(--muted); }
.audit-workspace-filters { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); }
.access-filter-actions { grid-column: 1 / -1; display: flex; align-items: center; gap: 18px; padding-top: 4px; }.access-filter-actions a { font-size: .83rem; }
.audit-timeline { padding: 0 22px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; }
.audit-event { display: grid; grid-template-columns: 8px minmax(0,1fr) auto; gap: 16px; padding: 20px 0; border-bottom: 1px solid var(--border); }.audit-event:last-child { border: 0; }
.audit-event-heading { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; font-size: .89rem; }.audit-event p { display: flex; flex-wrap: wrap; gap: 9px; margin: 8px 0 0; font-size: .8rem; }.audit-event p span { color: var(--muted); overflow-wrap: anywhere; }
.audit-event time { color: var(--muted); font-size: .75rem; white-space: nowrap; }.audit-event .access-facts { padding: 12px; background: var(--surface-2); border-radius: 8px; margin: 10px 0 0; font-size: .78rem; }
@media(max-width:1000px) {
  .employee-row { grid-template-columns: 42px minmax(0,1fr) minmax(120px,auto) 18px; gap: 12px; }
  .employee-badges { grid-column: 2 / 4; grid-row: 2; }.employee-row > .ico { grid-column: 4; grid-row: 1; }
  .employee-activity { grid-column: 3; grid-row: 1; }.access-metrics > div { align-items: start; flex-direction: column; }
}
@media(max-width:700px) {
  .workspace-nav { margin-bottom: 22px; width: 100%; }.workspace-nav a { flex: 1 1 0; justify-content: center; padding: 8px 6px; font-size: .79rem; white-space: normal; text-align: center; }
  .access-heading { align-items: start; flex-direction: column; gap: 18px; margin-bottom: 22px; }.access-heading h1 { font-size: 1.55rem; }.access-heading p { font-size: .85rem; }
  .access-heading > .btn-link, .access-heading > .btn-sec { width: 100%; }
  .identity-banner { display: grid; grid-template-columns: 54px minmax(0,1fr); padding: 18px; gap: 10px 12px; }
  .identity-banner > .identity-avatar { grid-row: 1 / 3; }.identity-banner > .access-role, .employee-banner > .employee-badges { grid-column: 2; margin-left: 0; }
  .employee-banner > .employee-badges { padding-left: 0; }.access-columns { grid-template-columns: minmax(0,1fr); gap: 18px; }
  .access-panel { padding: 20px; }.access-section-head { flex-direction: column; }
  .access-tabs { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 0 16px; overflow: visible; border-bottom: 0; }
  .access-tabs a { font-size: .83rem; padding: 12px 0; border-bottom: 1px solid var(--border); }.access-tabs a.active { border-bottom: 2px solid var(--primary); }
  .access-metrics { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; }.access-metrics > div { padding: 14px; flex-direction: row; }.access-metrics strong { font-size: 1.35rem; }
  .access-filters { padding: 14px; }.access-filters label { flex: 1 1 calc(50% - 6px); }.access-filters label.access-search { flex: 1 1 100%; }
  .access-filters > button { flex: 1; }.access-list-heading > span:last-child { display: none; }
  .employee-row { grid-template-columns: 38px minmax(0,1fr) 18px; gap: 12px; padding: 16px; }.employee-row .identity-avatar { width: 38px; height: 38px; }
  .employee-row > .ico { grid-column: 3; }.employee-badges { grid-column: 2 / 4; grid-row: 2; }.employee-activity { grid-column: 2 / 4; grid-row: 3; text-align: left; display: flex; flex-wrap: wrap; gap: 8px; }
  .employee-identity b { font-size: .89rem; }.role-cards { grid-template-columns: minmax(0,1fr); }.access-field-pair { grid-template-columns: minmax(0,1fr); }
  .access-form-actions { flex-wrap: wrap; }.access-form-actions button { flex: 1 1 100%; }.access-form-actions a { width: 100%; text-align: center; }
  .access-session { flex-wrap: wrap; }.access-session > form { margin-left: 52px; }.access-activity-row { grid-template-columns: 8px minmax(0,1fr); }
  .access-activity-row time { grid-column: 2; }.audit-workspace-filters { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .audit-workspace-filters .access-search, .audit-workspace-filters label:nth-of-type(4) { grid-column: 1 / -1; }
  .access-filter-actions { flex-wrap: wrap; }.access-filter-actions button { width: 100%; }.audit-timeline { padding: 0 16px; }
  .audit-event { grid-template-columns: 8px minmax(0,1fr); gap: 8px 12px; }.audit-event time { grid-column: 2; grid-row: 1; }.audit-event .activity-dot { grid-row: 2; }.audit-event-body { grid-column: 2; grid-row: 2; }
  .access-form input:not([type=checkbox]), .access-form select, .access-filters input, .access-filters select { font-size: 16px; }
}
.sb-foot form { margin: 0; }
.sb-foot form button { width: 100%; text-align: left; }

/* Фильтр по исходу на узком экране: одна прокручиваемая строка вместо обрезанных чипов */
@media (max-width: 960px) {
  .seg.seg-scroll { flex-wrap: nowrap; justify-content: flex-start; max-width: 100%;
    overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .seg.seg-scroll::-webkit-scrollbar { display: none; }
  .seg.seg-scroll > a { flex: 0 0 auto; }
}

/* Переключатель страниц внутри раздела бокового меню (_subnav.html) */
.subnav { margin: 0 0 18px; max-width: 100%; }
.subnav a { gap: 6px; }
.subnav .tab-n { min-width: 18px; padding: 0 6px; font-size: .7rem; }
.ai-head + .subnav { margin-top: -4px; }
h1 + .subnav { margin-top: 2px; }

/* ===== Очередь разбора: одно обращение на экран ===== */
.review-head { display: flex; justify-content: space-between; align-items: center; gap: 10px 18px; flex-wrap: wrap; }
.review-title { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; }
.review-title .muted { font-size: .88rem; }
.review-nav { display: flex; align-items: center; gap: 8px; }
.review-counter { min-width: 64px; text-align: center; font-weight: 650; font-variant-numeric: tabular-nums; }
.review-nav button { min-width: 36px; font-size: 1.05rem; line-height: 1; }
.review-actions { display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap; margin: 0 0 10px; }
.review-actions .dlg-bot { margin-left: auto; }
.review-item .dlg { margin-bottom: 0; }
.review-link { margin-left: auto; }
@media (max-width: 960px) { .review-link { margin-left: 0; } }

/* ===== Обзор: экономика помощника ===== */
.economy { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 18px 24px; align-items: center; }
.economy-kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.economy-chart { position: relative; height: 132px; min-width: 0; }
.economy-empty { position: absolute; inset: 0; display: grid; place-items: center; margin: 0; font-size: .86rem; }
@media (max-width: 960px) { .economy { grid-template-columns: 1fr; } }
@media (max-width: 480px) { .economy-kpis { grid-template-columns: 1fr 1fr; } }

/* ===== Настройки помощника: группы полей и подсказки «?» ===== */
.fields-grid > .field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.fields-grid > .field > label { font-size: .86rem; }
.field-title { font-weight: 600; font-size: .86rem; }
.field-help { font-size: .84rem; align-self: flex-start; }
.field-help > summary { display: inline-flex; align-items: center; gap: 7px; padding: 2px 8px 2px 2px; border-radius: 8px;
  color: var(--accent); font-weight: 560; list-style: none; cursor: pointer; }
.field-help > summary::-webkit-details-marker { display: none; }
.field-help > summary::before, .field-help[open] > summary::before { content: "?"; width: 17px; height: 17px; margin: 0;
  border-radius: 50%; display: inline-grid; place-items: center; font-size: .72rem; font-weight: 700; line-height: 1;
  border: 1.5px solid currentColor; transform: none; }
.field-help > summary:hover { background: color-mix(in srgb, var(--primary) 8%, transparent); }
.field-help > p { margin: 6px 0 0; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text-2); line-height: 1.5; max-width: 640px; }
.env-budgets { margin: 0; display: grid; gap: 6px; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); }
.env-budgets > div { display: flex; justify-content: space-between; gap: 12px; font-size: .88rem; }
.env-budgets dt { color: var(--muted); }
.env-budgets dd { margin: 0; font-weight: 600; text-align: right; }

/* =========================================================================
   Obsidra: шрифты, шапка, разделы и их оттенки, стартовая страница.
   Шрифты лежат в панели (политика безопасности не пускает чужие сайты).
   ========================================================================= */
@font-face { font-family: "Inter"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url("/static/fonts/inter-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url("/static/fonts/inter-cyrillic.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Jost"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url("/static/fonts/jost-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Jost"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url("/static/fonts/jost-cyrillic.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }

/* Оттенок раздела: знак в шапке, активный пункт слева, переключатель бота. */
.app { --tint: var(--brand); }
.app[data-module="bots"] { --tint: #7e89ff; }
.app[data-module="pyrus"] { --tint: #5aaeff; }
.app[data-module="assistant"] { --tint: #a57bff; }
.app[data-module="finance"] { --tint: #4fd1a5; }
.app[data-module="sites"] { --tint: #ffb066; }
.app[data-module="admin"] { --tint: #ff5c6c; }
/* Все акценты раздела используют одну палитру; цвета исходов и предупреждений независимы. */
.app {
  --primary: color-mix(in srgb, var(--tint) 72%, #000);
  --primary-hover: color-mix(in srgb, var(--primary) 86%, #000);
  --accent: var(--primary);
  --series-1: var(--tint);
}
:root[data-theme="dark"] .app {
  --primary: var(--tint);
  --primary-hover: color-mix(in srgb, var(--tint) 80%, #fff);
  --accent: color-mix(in srgb, var(--tint) 78%, #fff);
}
[data-module="bots"] { --m: #7e89ff; }
[data-module="pyrus"] { --m: #5aaeff; }
[data-module="assistant"] { --m: #a57bff; }
[data-module="finance"] { --m: #4fd1a5; }
[data-module="sites"] { --m: #ffb066; }
[data-module="admin"] { --m: #ff5c6c; }

/* Логотип: знак вместо заглавной «O», размеры в долях шрифта. */
.wordmark { display: inline-flex; align-items: baseline; line-height: 1; white-space: nowrap; font-family: var(--font-brand); font-weight: 600; letter-spacing: .02em; }
.wordmark-o { width: .891em; height: .96em; flex: none; overflow: visible; margin-right: .03em; }
.wm-ring { fill: none; stroke: var(--tint, var(--brand)); stroke-width: 6; }
.wm-ring.bold { stroke-width: 7; }
.wm-nub { fill: var(--tint, var(--brand)); }
.brand-mark { width: 40px; height: 40px; overflow: visible; }

/* Каркас: шапка сверху, под ней колонка раздела и содержимое. */
.app { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; background: none; }
.topbar {
  view-transition-name: appbar;
  position: sticky; top: 0; z-index: 100;
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(120px, 360px) minmax(100px, max-content); align-items: center; gap: 16px;
  height: calc(60px + env(safe-area-inset-top)); min-height: 60px; padding: env(safe-area-inset-top) 20px 0;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(14px); backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--border);
}
.tb-left {
  display: flex; align-items: center; gap: .35em; min-width: 0; height: 40px;
  font-family: var(--font-brand); font-size: 26px; font-weight: 600; letter-spacing: .02em; line-height: 1; color: var(--text);
}
.tb-menu { align-self: center; display: none; margin-right: 2px; }
.tb-home { color: var(--text); flex: 0 0 auto; display: inline-flex; align-items: center; line-height: 1; }
.tb-menu-placeholder { visibility: hidden; pointer-events: none; }
.tb-home:hover { text-decoration: none; }
.tb-sep { width: .42em; height: .66em; flex-shrink: 0; fill: none; stroke: var(--text); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.tb-module { position: relative; min-width: 0; }
.tb-module > summary {
  list-style: none; cursor: pointer; display: inline-flex; align-items: baseline; gap: .25em;
  padding: 8px 4px; border-radius: 8px; color: var(--text); white-space: nowrap;
  font-family: var(--font); font-size: .86em; font-weight: 500; letter-spacing: -.01em;
}
.tb-module > summary { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.tb-module > summary::-webkit-details-marker { display: none; }
.tb-module > summary::before { content: none; }
.tb-module > summary:hover { background: var(--surface-3); }
.tb-caret { width: .55em; height: .55em; color: var(--muted); stroke-width: 2.4; }
.tb-module-menu {
  position: absolute; top: calc(100% + 8px); left: 0; z-index: 150; min-width: 250px;
  display: flex; flex-direction: column; gap: 2px; padding: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg);
  font-family: var(--font); font-size: 15px; font-weight: 500; letter-spacing: 0; line-height: 1.4;
  animation: expand-in .14s ease both;
}
.tb-module-menu a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--text-2); }
.tb-module-menu a:hover, .tb-module-menu a.current { background: var(--surface-3); color: var(--text); text-decoration: none; }
.tb-module-menu .mod-ico { display: inline-grid; place-items: center; color: var(--m); }
.tb-module-menu .ico { width: 18px; height: 18px; }
.tb-module-all { border-top: 1px solid var(--border); margin-top: 4px; border-radius: 0 0 8px 8px !important; color: var(--muted) !important; }
.tb-center { display: flex; justify-content: center; min-width: 0; }
.tb-search {
  display: flex; align-items: center; gap: 10px; width: 100%; max-width: 520px; min-height: 40px; padding: 0 16px;
  border-radius: 999px; border: 1px solid var(--border); background: var(--surface-2); color: var(--muted);
  font: inherit; font-size: 14px; text-align: left; cursor: pointer;
}
.tb-search:hover { border-color: var(--border-strong); color: var(--text-2); }
.tb-search .ico { width: 16px; height: 16px; }
.tb-search span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tb-right { display: flex; justify-content: flex-end; min-width: 0; }
.tb-profile { display: flex; align-items: center; gap: 12px; min-width: 0; padding: 4px 8px 4px 4px; border-radius: 12px; color: var(--text); }
.tb-profile:hover { background: var(--surface-3); text-decoration: none; }
.tb-avatar { width: 34px; height: 34px; flex-shrink: 0; border-radius: 50%; background: var(--surface-3); display: grid; place-items: center; font-size: 13px; font-weight: 600; }
.tb-who { display: flex; flex-direction: column; gap: 1px; min-width: 0; line-height: 1.25; }
.tb-who b { font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tb-who small { font-size: 12px; color: var(--muted); white-space: nowrap; }

.shell { flex: 1; display: grid; grid-template-columns: var(--sb-w) minmax(0, 1fr); }
.app.no-sidebar .shell { grid-template-columns: minmax(0, 1fr); }
main { padding: 32px 40px 110px; }

/* Колонка раздела: крупные пункты, иконки в цвет текста, активный — в оттенке раздела. */
.sb-head { padding: 0 10px 4px; }
.sb-module { font-size: 12px; font-weight: 500; color: var(--muted); }
.sb-nav { margin-top: 0; }
.sb-item { min-height: 42px; padding: 0 12px; gap: 12px; border-radius: 9px; color: var(--muted); font-size: 15px; font-weight: 450; }
.sb-item .ico { width: 20px; height: 20px; opacity: 1; stroke-width: 1.75; }
.sb-item:hover { color: var(--text); background: var(--surface-3); }
.sb-item.current { color: var(--text); background: color-mix(in srgb, var(--tint) 14%, transparent); font-weight: 500; }
.sb-item.current .ico { color: var(--tint); }
.sb-foot { border-top-color: var(--border); }
.bot-switch > summary { background: var(--surface-2); border-color: var(--border); }
.bot-switch[open] > summary { border-color: var(--tint); box-shadow: 0 0 0 3px color-mix(in srgb, var(--tint) 18%, transparent); }
.bot-avatar { color: var(--tint, var(--accent)); background: color-mix(in srgb, var(--tint, var(--primary)) 16%, transparent); }

@media (min-width: 961px) {
  .sidebar { position: sticky; top: 60px; height: calc(100vh - 60px); height: calc(100dvh - 60px); padding: 18px 14px 14px; gap: 8px; }
}
@media (max-width: 960px) {
  .shell { display: block; }
  .topbar { grid-template-columns: minmax(0, 1fr) auto; gap: 8px; height: calc(56px + env(safe-area-inset-top)); min-height: 56px; padding: env(safe-area-inset-top) 10px 0 6px; }
  .tb-left { font-size: 21px; }
  .tb-menu { display: inline-grid; }
  .tb-center, .tb-who { display: none; }
  .tb-profile { padding: 4px; }
  .sidebar { padding-top: max(16px, env(safe-area-inset-top)); }
  main { padding: 20px 16px 120px; }
}

/* Стартовая: кнопки разделов и сводка проблем. */
.home { max-width: 1080px; margin: 0 auto; display: flex; flex-direction: column; gap: 48px; padding-top: 24px; }
.home-greet { margin: 0 0 24px; font-size: 26px; font-weight: 600; letter-spacing: -.02em; }
.module-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; }
.module-btn {
  display: flex; align-items: center; gap: 14px; min-height: 84px; padding: 0 18px; border-radius: 16px;
  color: var(--text); background: color-mix(in srgb, var(--m) 7%, var(--bg));
  border: 1px solid color-mix(in srgb, var(--m) 22%, transparent);
  transition: border-color .15s, background .15s;
}
.module-btn:hover { text-decoration: none; background: color-mix(in srgb, var(--m) 11%, var(--bg)); border-color: color-mix(in srgb, var(--m) 45%, transparent); }
.mod-circle { width: 40px; height: 40px; flex-shrink: 0; border-radius: 50%; display: grid; place-items: center;
  color: var(--m); background: color-mix(in srgb, var(--m) 18%, transparent); }
.mod-circle .ico { width: 20px; height: 20px; }
.module-btn b { font-size: 16px; font-weight: 600; }
.mod-dot { margin-left: auto; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); }
.problems-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.problems-head h2 { margin: 0; font-size: 16px; font-weight: 600; }
.problem-list { border: 1px solid var(--border); border-radius: 14px; background: var(--surface); }
.problem { display: flex; align-items: center; gap: 16px; padding: 16px 20px; color: var(--text); }
.problem + .problem { border-top: 1px solid var(--border); }
.problem:hover { text-decoration: none; background: var(--surface-2); }
.problem-dot { width: 8px; height: 8px; flex-shrink: 0; border-radius: 50%; background: var(--danger); }
.problem-dot.calm { background: var(--muted); }
.problem-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.problem-text b { font-weight: 500; }
.problem-text small { font-size: 13px; color: var(--muted); }
.mod-pill { font-size: 12px; font-weight: 500; white-space: nowrap; color: var(--m); background: color-mix(in srgb, var(--m) 16%, transparent); border-radius: 999px; padding: 4px 10px; }
.problems-empty { padding: 18px 20px; color: var(--muted); }
.home-extra { display: flex; flex-direction: column; gap: 12px; }

/* Финансы: раздел в работе. */
.soon { max-width: 720px; }
.soon-badge { display: inline-block; font-size: 12px; font-weight: 600; color: var(--m); background: color-mix(in srgb, var(--m) 16%, transparent); border-radius: 999px; padding: 3px 10px; margin-bottom: 12px; }

/* Вход */
.login-card .login-wordmark { margin: 0 0 4px; text-align: center; font-size: 44px; line-height: 1.1; }

/* =========================================================================
   Obsidra: внутренности страниц в одном стиле с макетом — тонкие рамки без теней, спокойные заголовки,
   круглые переключатели в оттенке раздела, таблицы без заглавных подписей. Только переопределения:
   разметка страниц не меняется.
   ========================================================================= */
:root { --radius: 14px; --radius-sm: 9px; }

h1 { font-size: 1.45rem; font-weight: 600; letter-spacing: -.02em; }
h2 { font-size: 1rem; font-weight: 600; letter-spacing: -.01em; }
h3 { font-size: .95rem; font-weight: 600; }
.eyebrow { font-size: .8rem; font-weight: 500; color: var(--muted); letter-spacing: 0; text-transform: none; }
.lead { color: var(--muted); }

/* Панели и карточки: плоские, тонкая рамка, без тени. */
.panel, .card { background: var(--surface); border: 1px solid var(--border); box-shadow: none; }
.panel { padding: 20px 22px; border-radius: 14px; }
.card { border-radius: 12px; }
.card:hover, a.card:hover { border-color: var(--border-strong); box-shadow: none; }
.panel.collapsible > summary { font-size: .98rem; font-weight: 600; }
.stats-cards { gap: 10px; }
.stats-cards .card { padding: 16px 16px 14px; font-size: .82rem; }
.stats-cards .big { font-size: 1.7rem; font-weight: 600; }
.kpi { background: var(--surface); border-color: var(--border); border-radius: 12px; }
.kpi b { font-size: 1.4rem; font-weight: 600; }
.delta { font-weight: 600; }

/* Кнопки: главная — фирменная заливка, второстепенная — контур, всё на 10 px скругления. */
button, .btn-link, a.btn-sec { border-radius: 10px; font-weight: 600; box-shadow: none; }
button.ghost, button.btn-sec, a.btn-sec, form.inline button, details.note-edit > summary {
  background: transparent; border-color: var(--border-strong); color: var(--text); font-weight: 500; box-shadow: none;
}
button.ghost:hover, button.btn-sec:hover, a.btn-sec:hover, form.inline button:hover, details.note-edit > summary:hover {
  background: var(--surface-3); border-color: var(--border-strong);
}
button.btn-sm, a.btn-sm, summary.btn-sm, .btn-sm { border-radius: 9px; }

/* Переключатели периода и подстраниц: круглые, активный — в оттенке раздела. */
.seg { background: transparent; border: 1px solid var(--border); border-radius: 999px; padding: 3px; }
.seg a, .seg button { border-radius: 999px; font-weight: 500; color: var(--muted); }
.seg a.current { background: color-mix(in srgb, var(--tint, var(--brand)) 22%, transparent); color: var(--text); font-weight: 600; box-shadow: none; }
.chip, button.chip { border-radius: 999px; border-color: var(--border); font-weight: 500; }
.chip.current, button.chip[aria-pressed="true"] {
  background: color-mix(in srgb, var(--tint, var(--brand)) 22%, transparent);
  border-color: color-mix(in srgb, var(--tint, var(--brand)) 45%, transparent); color: var(--text);
}

/* Поля ввода */
input, textarea, select { background: var(--input); border-color: var(--border); border-radius: 10px; }
input:hover, textarea:hover, select:hover { border-color: var(--border-strong); }
input:focus, textarea:focus, select:focus {
  border-color: var(--tint, var(--brand)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--tint, var(--brand)) 18%, transparent);
}

/* Таблицы: подписи столбцов обычным регистром, ряды с тонкими разделителями. */
th { font-size: .8rem; font-weight: 500; text-transform: none; letter-spacing: 0; color: var(--muted); }
th, td { padding: 11px 12px; border-bottom-color: var(--border); }
tbody tr:hover td { background: var(--surface-2); }

/* Значки состояния и подсказки */
.pill { font-weight: 500; border-color: transparent; padding: 2px 10px 2px 8px; }
.badge { font-weight: 500; }
.hint {
  background: color-mix(in srgb, var(--tint, var(--brand)) 7%, var(--surface));
  border-color: color-mix(in srgb, var(--tint, var(--brand)) 25%, transparent);
}
.error, .flash, .hint { border-radius: 12px; }

/* Раскрывающиеся блоки и прочее */
details > summary::before { opacity: .7; }
.backlink:hover { color: var(--text); }
.tabbar a.current { color: var(--text); }

/* =========================================================================
   Obsidra: экран входа — слева логотип, фраза и разделы, справа карточка; на фоне большой знак и свечение.
   ========================================================================= */
body.obsidra-login { --tint: var(--brand); display: flex; flex-direction: column; align-items: stretch; justify-content: center;
  min-height: 100vh; min-height: 100dvh; padding: 32px 24px 20px; overflow-x: hidden; overflow-y: auto; background: var(--bg); }
.login-glow { position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(42% 46% at 26% 42%, color-mix(in srgb, var(--brand) 16%, transparent), transparent 70%),
    radial-gradient(30% 34% at 80% 70%, color-mix(in srgb, var(--brand) 7%, transparent), transparent 70%); }
.login-shell { flex: 1; width: 100%; max-width: 1040px; margin: 0 auto; display: grid;
  grid-template-columns: minmax(0, 1fr) 380px; align-items: center; gap: 64px; }
.login-brand { position: relative; display: flex; flex-direction: column; gap: 22px; min-width: 0; }
.login-watermark { position: absolute; z-index: -1; width: 420px; height: 420px; left: -70px; top: 50%;
  transform: translateY(-55%); opacity: .07; pointer-events: none; }
.obsidra-login .login-wordmark { margin: 0; font-size: 72px; line-height: 1; text-align: left; }
.login-tagline { margin: 0; max-width: 460px; font-size: 18px; line-height: 1.5; color: var(--text-2); }
.login-modules { list-style: none; margin: 8px 0 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, max-content)); gap: 10px 22px; }
.login-modules li { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--muted); white-space: nowrap; }
.login-modules .mod-circle { width: 32px; height: 32px; }
.login-modules .mod-circle .ico { width: 16px; height: 16px; }
.obsidra-login .login-card { max-width: 380px; padding: 30px 30px 28px; gap: 16px; border-radius: 18px;
  background: color-mix(in srgb, var(--surface) 88%, transparent); border-color: var(--border); box-shadow: 0 30px 80px rgba(0, 0, 0, .55); }
.login-card-head h2 { margin: 0 0 4px; font-size: 22px; font-weight: 600; text-align: left; }
.login-card-head p { margin: 0; font-size: 14px; }
.obsidra-login .login-card label { font-weight: 500; color: var(--text-2); }
.obsidra-login .login-card button { margin-top: 4px; min-height: 46px; border-radius: 12px; font-size: 15px; }
.login-foot { margin-top: 24px; text-align: center; font-size: 12px; color: var(--muted); letter-spacing: .04em; }
@media (max-width: 860px) {
  body.obsidra-login { justify-content: flex-start; padding-top: 40px; }
  .login-shell { grid-template-columns: minmax(0, 1fr); gap: 32px; justify-items: center; }
  .login-brand { align-items: center; text-align: center; }
  .obsidra-login .login-wordmark { font-size: 52px; text-align: center; }
  .login-tagline { font-size: 16px; }
  .login-modules { display: none; }
  .login-watermark { width: 300px; height: 300px; left: 50%; transform: translate(-50%, -55%); }
  .obsidra-login .login-card { width: 100%; }
}
