/* le-os-admin-design · styles.css
   Тёплый stone, IBM Plex Sans телом + IBM Plex Mono акцентом, мягкие скругления,
   деликатные тени, цветные пилюли-статусы. Требует tokens.css.
   Имена классов совпадают с Jinja-шаблонами — не переименовывать. */

/* ── Reset / base ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background: var(--paper);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  font-weight: 400;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
form { margin: 0; }
input, textarea, select { font: inherit; color: inherit; }
code { font-family: var(--font-mono); font-size: 0.86em; background: var(--paper-mute); border: 1px solid var(--border-strong); border-radius: 4px; padding: 1px 6px; }
::selection { background: var(--ink); color: var(--fg-on-ink); }

/* тёплый плоский скроллбар */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #CEC9C1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--fg-muted); }
* { scrollbar-width: thin; scrollbar-color: #CEC9C1 transparent; }

.mono-dim { color: var(--fg-muted); font-family: var(--font-mono); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.caps { text-transform: uppercase; letter-spacing: var(--tracking-caps); }
.hide-sm { display: revert; }

/* ── Shell ────────────────────────────────────────────────────────── */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100vh;
  background: var(--sb-bg);   /* фон за скруглённым углом панели — цвет сайдбара */
  overflow: hidden;
  transition: grid-template-columns var(--dur-base) var(--ease-out);
}
.app.rail { grid-template-columns: var(--sidebar-rail) 1fr; }

/* ── Sidebar (дизайн-система 20.09.2026: барвинок, три группы, рейка) ──
   Цвета — только через --sb-*: сайдбар красится отдельно от бумаги панели.
   Кнопка сворачивания в шапке рядом с брендом (как в Claude и Cursor);
   свёрнутый — рейка со значками, подписи уезжают в тултипы, состояние
   помнит localStorage (admin.js, класс .rail на .app ставится в <head>,
   чтобы меню не прыгало при загрузке). */
.sidebar {
  display: flex;
  flex-direction: column;
  background: var(--sb-bg);
  padding: 14px 10px 12px;
  overflow-y: auto;
  overflow-x: hidden;
}
.brand {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 2px 16px 8px;
  min-height: 44px;
}
.brand-mark {
  background: var(--ink);
  color: var(--fg-on-ink);
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: var(--fs-xs);
  letter-spacing: 0.06em;
  padding: 5px 8px;
  border-radius: var(--radius-sm);
  flex: none;
}
.brand-txt { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; flex: 1; }
.brand-name { font-size: 13px; font-weight: 600; color: var(--sb-fg-strong); }
/* подпись под маркой — ссылка на телеграм-канал владельца; набор как у
   названия панели, которое она заменила */
.brand-host {
  font-size: 11.5px; font-weight: 600; letter-spacing: -0.015em;
  color: var(--sb-fg-strong); text-decoration: none;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: color var(--dur-fast) var(--ease-out);
}
.brand-host:hover, .brand-host:focus-visible { color: var(--ink); }
.brand-sub {   /* вход: подпись рядом с маркой */
  font-size: var(--fs-label);
  text-transform: uppercase;
  letter-spacing: var(--tracking-caps);
  color: var(--fg-label);
  font-weight: 600;
}
.rail-btn {
  margin-left: auto; width: 30px; height: 30px; flex: none;
  border: none; border-radius: var(--radius-sm); background: transparent; color: var(--sb-label);
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.rail-btn:hover { background: var(--sb-hover); color: var(--sb-fg-strong); }
.rail-btn svg { display: block; }

.nav { display: flex; flex-direction: column; gap: 1px; flex: 1; }
.nav-label {
  font-size: var(--fs-label);
  text-transform: uppercase;
  letter-spacing: var(--tracking-caps);
  color: var(--sb-label);
  padding: 14px 10px 5px;
  font-weight: 600;
  white-space: nowrap;
}
.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 7px 10px;
  border: none;
  border-radius: var(--radius);
  background: transparent;
  color: var(--sb-fg);
  text-align: left;
  font-size: 13.5px;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--dur-fast) var(--ease-out),
              color var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out);
}
.nav-item:hover { background: var(--sb-hover); color: var(--sb-fg-strong); }
.nav-item.active {
  background: var(--sb-active);
  color: var(--sb-active-fg);
  box-shadow: var(--shadow-nav);
  font-weight: 500;
}
.ni-icon { display: inline-flex; flex: none; width: 18px; height: 18px; align-items: center; justify-content: center; color: currentColor; }
.ni-label { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.ni-badge {
  margin-left: auto;
  flex: none;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: var(--radius-tag);
  background: var(--sb-badge-bg);
  color: var(--sb-badge-fg);
  font-variant-numeric: tabular-nums;
}
.ni-badge.alert { background: var(--warn-dot); color: var(--fg-on-ink); }
/* «● 2» у Офиса — сколько агентов работает; слово живёт в тултипе */
.ni-meta {
  margin-left: auto; display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; color: var(--sb-fg); font-variant-numeric: tabular-nums; white-space: nowrap;
}
.ni-meta[data-tip]::after { left: auto; right: 0; transform: translateX(0) translateY(3px); }
.ni-meta[data-tip]:hover::after, .ni-meta[data-tip]:focus-visible::after { transform: translateX(0) translateY(0); }

/* ── Сайдбар: второй уровень — агенты по кабинетам ──────────────────
   Отдельной страницы со списком агентов нет: список и есть это меню. */
.nav-group { display: flex; flex-direction: column; }
.nav-toggle { list-style: none; }
.nav-toggle::-webkit-details-marker { display: none; }
.nav-toggle .ni-caret {
  margin-left: auto; flex: none; display: inline-flex; color: var(--sb-label);
  transition: transform var(--dur-fast) var(--ease-out);
}
.nav-group[open] > .nav-toggle .ni-caret { transform: rotate(180deg); }
.nav-sub {
  display: flex; flex-direction: column; gap: 1px;
  margin: 2px 0 4px 18px; padding-left: 10px;
  border-left: 1px solid var(--sb-line);
}
.nav-dept {
  font-size: var(--fs-label); font-weight: 600; color: var(--sb-label);
  text-transform: uppercase; letter-spacing: var(--tracking-label);
  padding: 8px 8px 3px;
}
.nav-sub > .nav-dept:first-child { padding-top: 3px; }
.nav-agent {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 8px; border-radius: var(--radius-sm);
  color: var(--sb-fg); font-size: 13px; white-space: nowrap;
  transition: background var(--dur-fast) var(--ease-out),
              color var(--dur-fast) var(--ease-out);
}
.nav-agent:hover { background: var(--sb-hover); color: var(--sb-fg-strong); }
.nav-agent.active {
  background: var(--sb-active); color: var(--sb-active-fg); font-weight: 500;
  box-shadow: var(--shadow-nav);
}
.nav-agent .sdot { flex: none; }
.nav-agent.fired { color: var(--sb-label); }
.na-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.na-count {
  flex: none; font-family: var(--font-mono); font-size: 10px; font-weight: 600;
  padding: 1px 6px; border-radius: var(--radius-tag);
  background: var(--sb-badge-bg); color: var(--sb-badge-fg);
}
/* Отделы · Нанять · Уволенные — строка ссылок под списком агентов */
.nav-links { display: flex; flex-wrap: wrap; gap: 0 2px; padding: 4px 2px 0; }
.nav-links a, .nav-links summary {
  font-size: var(--fs-xs); color: var(--sb-label); padding: 3px 6px; border-radius: var(--radius-sm);
  white-space: nowrap; cursor: pointer; list-style: none;
}
.nav-links summary::-webkit-details-marker { display: none; }
.nav-links a:hover, .nav-links summary:hover { background: var(--sb-hover); color: var(--sb-fg-strong); }
.nav-links a.active { color: var(--sb-active-fg); font-weight: 500; }
.nav-fired { display: contents; }
.nav-fired > .nav-fired-list { flex-basis: 100%; display: flex; flex-direction: column; gap: 1px; }
.nav-err, .nav-empty { padding: 8px; font-size: var(--fs-xs); line-height: 1.5; }
.nav-err { color: var(--err); }
.nav-empty { color: var(--sb-label); }
.nav-empty code { font-size: 10px; padding: 1px 4px; }

.sidebar-foot {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--sb-line);
  display: flex; flex-direction: column; gap: 6px;
}
.sys-line { display: flex; align-items: center; gap: 7px; padding: 4px 10px; font-size: var(--fs-xs); color: var(--sb-fg); white-space: nowrap; }
.sys-line .mono { color: var(--sb-label); font-size: 10px; margin-left: auto; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
/* QR на телеграм-канал: ширина подобрана так, чтобы подвал не удлинял
   сайдбар — он по-прежнему умещается в экран без прокрутки. Подписи не
   нужны: имя канала стоит в шапке. */
.foot-qr {
  display: block;
  width: 100%; max-width: 104px;
  margin: 0 auto;
  padding: 7px;
  border-radius: var(--radius);
  background: var(--sb-active);
  border: 1px solid var(--sb-line);
  transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}
.foot-qr:hover, .foot-qr:focus-visible { border-color: var(--sb-fg); box-shadow: var(--shadow-card-hover); }
.foot-qr svg { display: block; width: 100%; height: auto; color: var(--sb-fg-strong); }

/* свёрнутый — узкая рейка со значками; подписи в тултипах справа */
.app.rail .sidebar { padding: 14px 8px 12px; }
.app.rail .brand { padding: 4px 0 12px; flex-direction: column; gap: 8px; align-items: center; }
.app.rail .brand .rail-btn { margin-left: 0; }
.app.rail .brand-txt, .app.rail .ni-label, .app.rail .ni-badge, .app.rail .ni-meta, .app.rail .ni-caret,
.app.rail .nav-sub, .app.rail .foot-qr, .app.rail .sys-line .mono, .app.rail .sys-line .t { display: none; }
.app.rail .nav-label { height: 1px; padding: 0; margin: 10px 8px 8px; background: var(--sb-line); overflow: hidden; font-size: 0; }
.app.rail .nav-item { justify-content: center; padding: 9px 0; }
.app.rail .nav-item[data-n]::after {
  content: ""; position: absolute; top: 6px; right: 9px; width: 6px; height: 6px; border-radius: 50%;
  background: var(--warn-dot); box-shadow: 0 0 0 2px var(--sb-bg);
}
.app.rail .sys-line { justify-content: center; padding: 4px 0; }
.app.rail .nav-group { display: contents; }
.app:not(.rail) .nav-item[data-tip]::after, .app:not(.rail) .nav-item[data-tip]::before { display: none; }
.app.rail .nav-item[data-tip]::after, .app.rail .rail-btn[data-tip]::after {
  left: calc(100% + 10px); top: 50%; transform: translateY(-50%) translateX(-3px);
}
.app.rail .nav-item[data-tip]:hover::after, .app.rail .nav-item[data-tip]:focus-visible::after,
.app.rail .rail-btn[data-tip]:hover::after, .app.rail .rail-btn[data-tip]:focus-visible::after { transform: translateY(-50%) translateX(0); }
.app.rail .nav-item[data-tip]::before, .app.rail .rail-btn[data-tip]::before { display: none; }
.app:not(.rail) .rail-btn[data-tip]::before { display: none; }
@media (prefers-reduced-motion: reduce) { .app { transition: none; } }

/* ── Main / topbar ────────────────────────────────────────────────── */
.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--paper-raised);
  border-radius: 12px 0 0 12px;
  box-shadow: var(--shadow-panel);
  overflow: hidden;
}
.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 28px;
  background: var(--paper-card);
  border-bottom: 1px solid var(--border);
  flex: none;
}
.crumb { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.crumb-title { font-size: 14.5px; font-weight: 600; color: var(--fg); }
.crumb-sub { font-size: 11px; color: var(--fg-label); margin-top: 1px; }
.topbar-spacer { flex: 1; }
.clock { font-size: 12px; color: var(--fg-faint); font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

.sys-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 11px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--ok-border);
  background: var(--ok-bg);
  font-size: var(--fs-xs);
  font-weight: 500;
  color: var(--ok);
}
.sys-pill .sdot { width: 7px; height: 7px; }
.sys-pill.warn { border-color: var(--warn-border); background: var(--warn-bg); color: var(--warn); }

.menu-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 34px; height: 34px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: transparent;
  cursor: pointer;
}

.content { flex: 1; overflow-y: auto; padding: 28px 32px; }
.section-enter { max-width: 920px; }
.section-enter.wide { max-width: 1060px; }  /* таблицы с раскрытием — крон */

/* ── Status dot (circle) ──────────────────────────────────────────── */
.sdot {
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--idle-dot);
  flex: none;
}
.sdot.ok   { background: var(--ok-dot); }
.sdot.warn { background: var(--warn-dot); }
.sdot.err  { background: var(--err); }
.sdot.info { background: var(--info); }
.sdot.idle { background: var(--idle-dot); }
.sdot.live { animation: sdot-pulse 1.8s var(--ease-out) infinite; }
@keyframes sdot-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

/* ── Точка направления ────────────────────────────────────────────────
   Цвет приходит инлайном переменной --c: ключей шесть, классов под каждый
   не заводим. Без --c точка серая — это «Без направления». Нужна экрану
   направлений, реестру проектов и списку встреч (срез 2), поэтому живёт
   здесь, а не в листе одного экрана. */
.ddot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--c, var(--idle-dot));
  flex: none;
}

/* ── Status pill (soft fill + colored text + dot) ─────────────────── */
.status-pill, .pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  font-size: var(--fs-xs);
  font-weight: 500;
  white-space: nowrap;
}
.status-pill.ok,   .pill.ok   { background: var(--ok-bg);   color: var(--ok); }
.status-pill.warn, .pill.warn { background: var(--warn-bg); color: var(--warn); }
.status-pill.err,  .pill.err  { background: var(--err-bg);  color: var(--err); }
.status-pill.info, .pill.info { background: var(--info-bg); color: var(--info); }
.status-pill.idle, .pill.idle { background: var(--idle-bg); color: var(--idle); }

/* Значком вместо слова — обе таблицы «Работ». Слово живёт в тултипе и в
   .sr-only внутри пилюли: глазами значок, скринридеру — текст. */
.status-pill.glyph {
  gap: 0;
  padding: 0;
  width: 22px; height: 22px;
  justify-content: center;
  border-radius: 50%;
}
.status-pill.glyph svg { display: block; fill: currentColor; stroke: none; }
.status-pill.glyph.ok svg { transform: translateX(0.5px); }  /* оптический центр треугольника */
.status-pill.glyph.warn { background: var(--warn-dot); color: var(--fg-on-ink); }

/* ── Grid ─────────────────────────────────────────────────────────── */
.grid { display: grid; gap: 12px; }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }

/* ── Card ─────────────────────────────────────────────────────────── */
.card {
  background: var(--paper-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.card + .card { margin-top: 16px; }
.card-pad { padding: 16px 20px; }
.card-pad.divider-top { border-top: 1px solid var(--border-faint); }

/* ── Block head (мелкая серая метка раздела) ──────────────────────── */
.block-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 26px 0 12px;
}
.block-head:first-child { margin-top: 0; }
.block-head .bh-title {
  font-size: var(--fs-label);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: var(--tracking-label);
  color: var(--fg-label);
}
.block-head .bh-title a:hover { color: var(--info); }
.block-head .bh-meta {
  font-size: var(--fs-xs);
  color: var(--fg-faint);
}
.block-head .bh-spacer { flex: 1; }

/* ── Stat (KPI) ───────────────────────────────────────────────────── */
.stat {
  background: var(--paper-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
}
.stat-label {
  font-size: var(--fs-label);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: var(--tracking-label);
  color: var(--fg-label);
  margin-bottom: 12px;
}
.stat-value {
  font-size: var(--fs-display);
  font-weight: 300;
  line-height: 1;
  color: var(--fg);
  font-variant-numeric: tabular-nums;
  display: flex;
  align-items: baseline;
  gap: 4px;
}
.stat-value.compact { font-size: var(--fs-h2); font-weight: 600; font-family: var(--font-mono); line-height: 1.3; }
.stat-value .unit { font-size: var(--fs-h2); color: var(--fg-muted); }
.stat-foot { font-size: var(--fs-xs); color: var(--fg-faint); margin-top: 10px; display: flex; gap: 6px; }
.stat-value.warn { color: var(--warn); }
.stat-delta.up   { color: var(--ok); }
.stat-delta.down { color: var(--err); }
.stat-delta.warn { color: var(--warn); }

/* ── Nav-card (плитка раздела на обзоре) ──────────────────────────── */
.nav-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--paper-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out);
}
.nav-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-card-hover); }
.nav-card .nc-title { font-size: 13.5px; font-weight: 500; color: var(--fg); }
.nav-card .nc-sub { font-size: 11.5px; color: var(--fg-label); }

/* ── Buttons ──────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius);
  background: var(--ink);
  color: var(--fg-on-ink);
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: background var(--dur-base) var(--ease-out),
              color var(--dur-base) var(--ease-out),
              border-color var(--dur-base) var(--ease-out),
              transform 160ms var(--ease-out);
}
.btn:hover { background: var(--ink-hover); }
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.sm { padding: 5px 12px; font-size: var(--fs-xs); border-radius: var(--radius-sm); }
.btn.ghost { background: transparent; border: 1px solid var(--border-strong); color: var(--fg-muted); }
.btn.ghost:hover { background: var(--paper-mute); color: var(--fg); }
.btn.danger { background: transparent; border: 1px solid var(--err-border); color: var(--err); }
.btn.danger:hover { background: var(--err-bg); border-color: rgba(220,38,38,.35); }
.btn-icon { display: inline-flex; }
/* Только значок: подпись уезжает в тултип (см. [data-tip] ниже). */
.btn.ico { width: 28px; height: 28px; padding: 0; gap: 0; justify-content: center; }
.btn.ico svg { display: block; }
/* Круглый «+» — добавление сущности (макрос i.plus в _icons.html). */
.btn.add { width: 28px; height: 28px; padding: 0; gap: 0; justify-content: center; border-radius: var(--radius-pill); flex: none; }
.btn.add svg { display: block; }
.btn.add:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.grid .btn.add { align-self: center; }

/* ── Table ────────────────────────────────────────────────────────── */
.tbl { width: 100%; border-collapse: collapse; }
.tbl thead th {
  text-align: left;
  font-size: var(--fs-label);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: var(--tracking-label);
  color: var(--fg-label);
  padding: 11px 18px;
  border-bottom: 1px solid var(--border-faint);
  white-space: nowrap;
}
.tbl thead th.num { text-align: right; }
.tbl tbody td {
  padding: 12px 18px;
  border-bottom: 1px solid var(--border-row);
  vertical-align: middle;
  font-size: var(--fs-sm);
}
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl tbody tr:hover { background: var(--row-hover); }
.tbl td.num { text-align: right; font-variant-numeric: tabular-nums; }
/* Правый отступ таблицы равен левому (18px): последний столбец ужимается
   по содержимому и прижат вправо, пустого хвоста справа не бывает. */
.tbl th.col-end, .tbl td.col-end { width: 1%; white-space: nowrap; text-align: right; }
/* Страница «Работы»: шапки столбцов по центру своей колонки. */
.jobs-page .tbl thead th { text-align: center; }

/* Столбец статуса: заголовка нет, ширина по значку. */
.tbl th.th-status, .tbl td.st {
  width: 1%; white-space: nowrap; text-align: center;
  padding-left: 12px; padding-right: 12px;
}

.svc-name { font-size: 13.5px; font-weight: 500; color: var(--fg); }
.svc-path { font-size: var(--fs-xs); color: var(--fg-label); }

/* ── Тег проекта .tg — один компонент на всю панель ───────────────────
   Сборка — window.projTag() в static/lib/tag.js. Рамка говорит, откуда
   проект: заливка — назначен рукой (fact), контур — по правилу (rule),
   пунктир индиго с искрой — догадка Клерка (guess), пустой пунктир —
   проекта нет (none), янтарь — спор правил (warn). Точка — направление
   проекта, рисуется всегда, когда направление есть. Модификаторы:
   .sm 18px / .lg 26px (обычный 22), .off — проект в архиве, .more —
   хвост «+N», .still — подпись без действия. Размер раньше звался .xs и
   сталкивался с одноимённой колонкой раскрытой строки в meetings.css. */
.tg { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px; border-radius: var(--radius-tag);
      border: 1px solid var(--border-strong); background: var(--paper-card); color: var(--fg-soft);
      font-family: var(--font-sans); font-size: var(--fs-xs); font-weight: 500; line-height: 1; white-space: nowrap; max-width: 100%;
      cursor: pointer; text-decoration: none;
      transition-property: background, color, border-color, box-shadow, transform;
      transition-duration: var(--dur-fast); transition-timing-function: var(--ease-out); }
.tg > span { overflow: hidden; text-overflow: ellipsis; max-width: 180px; }
.tg svg { flex: none; }
.tg:hover { box-shadow: var(--shadow-card-hover); color: var(--fg); }
.tg:not(.still):active { transform: scale(0.96); }
.tg:focus-visible { outline: 2px solid var(--info); outline-offset: 1px; }
.tg.fact { background: var(--ink); color: var(--fg-on-ink); border-color: var(--ink); }
.tg.fact:hover { background: var(--ink-hover); color: var(--fg-on-ink); }
.tg.rule { background: var(--paper-card); color: var(--fg-soft); border-color: var(--border-strong); }
.tg.guess { background: var(--accent-bg); color: var(--accent); border: 1px dashed var(--accent-line); }
.tg.none { background: transparent; color: var(--fg-muted); border: 1px dashed var(--border-strong); }
.tg.warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.tg.off { color: var(--fg-label); border-style: dashed; }
.tg.off > span { text-decoration: line-through; text-decoration-color: var(--fg-faint); }
.tg.more { color: var(--fg-muted); font-family: var(--font-mono); }
.tg.still { cursor: default; }
.tg.still:hover { box-shadow: none; color: inherit; }
.tg.sm { height: 18px; padding: 0 6px; }
.tg.lg { height: 26px; padding: 0 11px; font-size: var(--fs-sm); gap: 8px; }
.tg .ddot { width: 7px; height: 7px; }
.tg.lg .ddot { width: 8px; height: 8px; }
/* точка направления внутри тёмного тега: кольцо цветом бумаги, чтобы не тонула */
.tg.fact .ddot { box-shadow: 0 0 0 1.5px rgba(250, 250, 248, .9); }
.tg .n { font-family: var(--font-mono); font-size: 10.5px; opacity: .7; font-variant-numeric: tabular-nums; }
/* тумблер-имя в окне правила: нажатый — как тег «рукой» */
.tg[aria-pressed="true"] { background: var(--ink); color: var(--fg-on-ink); border-color: var(--ink); border-style: solid; }
@media (prefers-reduced-motion: reduce) { .tg { transition: none; } .tg:not(.still):active { transform: none; } }

.row-actions { display: inline-flex; gap: 6px; align-items: center; justify-content: flex-end; }
.row-actions form { display: inline; margin: 0; }

/* ── Inputs / field / segment ─────────────────────────────────────── */
.field {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--paper-raised);
  padding: 8px 12px;
}
.field:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }
.field input, .field select {
  border: none; background: transparent; outline: none;
  font-size: var(--fs-sm); min-width: 0; width: 100%;
}
.field .field-icon { color: var(--fg-faint); display: inline-flex; }
.field input::placeholder { color: var(--fg-label); }

.check-row { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; }
/* тумблер: реальный input[type=checkbox] остаётся в разметке и работает как обычно
   (нужен POST-обработчику), просто визуально скрыт — растянут прозрачным поверх
   дорожки. Вид переключает :checked + .switch-track, JS не участвует. */
.check-row .switch { position: relative; display: inline-flex; flex: none; margin-top: 2px; }
.check-row .switch input[type="checkbox"] {
  position: absolute; inset: 0; margin: 0; width: 34px; height: 20px;
  opacity: 0; cursor: pointer;
}
.check-row .switch-track {
  display: inline-flex; align-items: center; flex: none;
  width: 34px; height: 20px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  background: var(--paper-mute);
  transition: background var(--dur-base) var(--ease-out), border-color var(--dur-base) var(--ease-out);
}
.check-row .switch-thumb {
  width: 14px; height: 14px; margin-left: 3px;
  border-radius: 50%;
  background: var(--fg-muted);
  transition: transform var(--dur-base) var(--ease-out), background var(--dur-base) var(--ease-out);
}
.check-row .switch input:checked + .switch-track { background: var(--ink); border-color: var(--ink); }
.check-row .switch input:checked + .switch-track .switch-thumb { transform: translateX(14px); background: var(--fg-on-ink); }
.check-row .switch input:focus-visible + .switch-track { outline: 2px solid var(--fg); outline-offset: 2px; }
.check-row .check-text { display: flex; flex-direction: column; gap: 2px; }
.check-row .check-label { font-size: var(--fs-sm); color: var(--fg); font-weight: 500; }
.check-row .check-sub { font-size: 12.5px; color: var(--fg-label); line-height: 1.5; }
.check-row .check-sub code { font-size: 0.92em; }

.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius); overflow: hidden; }
.seg button, .seg a {
  padding: 7px 13px; background: transparent; border: none; cursor: pointer;
  font-size: var(--fs-xs); color: var(--fg-muted);
  text-decoration: none; display: inline-flex; align-items: center;
}
/* делитель по соседству, а не button + button: во вкладках встреч живые
   разделы — ссылки, заглушенные будущие — кнопки. */
.seg > * + * { border-left: 1px solid var(--border-strong); }
.seg button.active, .seg a.active { background: var(--ink); color: var(--fg-on-ink); }

/* ── Empty / hint ─────────────────────────────────────────────────── */
.empty { text-align: center; color: var(--fg-label); padding: 40px 16px; font-size: var(--fs-sm); }
.hint { font-size: 12.5px; color: var(--fg-label); line-height: 1.55; margin: 0 0 16px; }
.hint code { font-size: 0.92em; }

/* ── Confirm modal ────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(28,25,23,.38);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal-backdrop[hidden] { display: none; }
.confirm-modal {
  background: var(--paper-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%; max-width: 440px;
  padding: 22px;
  box-shadow: var(--shadow-modal);
  animation: modal-in var(--dur-base) var(--ease-out);
}
@keyframes modal-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.confirm-title { font-size: var(--fs-h2); font-weight: 600; }
.confirm-sub { font-size: var(--fs-sm); color: var(--fg-muted); margin-top: 2px; }
.confirm-lines { margin: 14px 0; border-top: 1px solid var(--border-faint); border-bottom: 1px solid var(--border-faint); }
.confirm-lines .kv { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border-faint); font-size: var(--fs-sm); }
.confirm-lines .kv:last-child { border-bottom: none; }
.confirm-lines .kv .k { color: var(--fg-muted); }
.confirm-claudemd {
  font-size: var(--fs-xs); color: var(--fg-muted);
  border-left: 2px solid var(--info); padding-left: 10px; margin: 12px 0;
}
.confirm-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* ── Reschedule picker ────────────────────────────────────────────── */
.rs-seg { display: flex; margin: 16px 0 4px; }
.rs-seg button { flex: 1; cursor: pointer; }
.rs-pane[hidden] { display: none; }
.rs-pane { padding: 10px 0 2px; }
.rs-row { display: flex; align-items: center; gap: 12px; padding: 7px 0; }
.rs-label { width: 56px; font-size: var(--fs-sm); color: var(--fg-muted); flex: none; }
.rs-time { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-sm); }
.rs-time input {
  width: 54px; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--paper-raised);
  padding: 7px 8px; font-size: var(--fs-sm); outline: none; text-align: center;
}
.rs-time input:focus { border-color: var(--fg); }
.rs-days { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.rs-day {
  display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--border-strong);
  border-radius: var(--radius-tag); padding: 5px 9px; font-size: var(--fs-xs);
  cursor: pointer; -webkit-user-select: none; user-select: none;
}
.rs-day input { margin: 0; }
.rs-hint { font-size: var(--fs-xs); color: var(--fg-label); margin-top: 4px; }

/* ── Toasts ───────────────────────────────────────────────────────── */
.toast-wrap {
  position: fixed; right: 18px; bottom: 18px; z-index: 200;
  display: flex; flex-direction: column; gap: 8px; align-items: flex-end;
}
.toast {
  background: var(--fg); color: var(--fg-on-ink);
  border-radius: var(--radius); padding: 11px 15px;
  font-size: var(--fs-sm);
  display: flex; align-items: center; gap: 8px;
  box-shadow: var(--shadow-modal);
  animation: toast-in var(--dur-base) var(--ease-out);
}
.toast.err { border-left: 2px solid var(--err-dot); }
.toast.ok  { border-left: 2px solid var(--ok-dot); }
@keyframes toast-in { from { opacity: 0; transform: translateX(8px); } to { opacity: 1; transform: none; } }

/* ── Section enter ────────────────────────────────────────────────── */
.section-enter { animation: section-enter var(--dur-base) var(--ease-out); }
@keyframes section-enter { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ── Login ────────────────────────────────────────────────────────── */
.login-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; background: var(--paper); }
.login-card { width: 100%; max-width: 380px; }
.login-card .brand { justify-content: center; padding: 18px 20px; margin: 0; border-bottom: 1px solid var(--border-faint); }
.login-body { padding: 22px 20px; display: flex; flex-direction: column; gap: 14px; }
.login-form { display: flex; flex-direction: column; gap: 12px; }
.login-lead { font-size: var(--fs-sm); color: var(--fg-soft); line-height: 1.6; }
.login-card .field input { text-align: center; letter-spacing: 0.18em; }
.login-err { font-size: var(--fs-sm); color: var(--err); background: var(--err-bg); border-radius: var(--radius); padding: 8px 12px; }
.login-card .btn { justify-content: center; width: 100%; }

/* ── Контекст: сворачиваемые редактируемые документы ─────────────── */
.doc-card { margin-bottom: 8px; padding: 0; }
.doc-summary {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 20px; cursor: pointer; list-style: none; -webkit-user-select: none; user-select: none;
}
.doc-summary::-webkit-details-marker { display: none; }
.doc-summary:hover { background: var(--row-hover); }
.doc-caret { display: inline-flex; color: var(--fg-faint); transition: transform 0.15s ease; flex: none; }
.doc-card[open] .doc-caret { transform: rotate(180deg); }
.doc-titles { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.doc-title { font-size: 13.5px; font-weight: 500; color: var(--fg); }
.doc-meta { margin-top: 2px; font-size: var(--fs-xs); color: var(--fg-label); }
.doc-body { padding: 16px 20px; border-top: 1px solid var(--border-faint); }
.doc-actions { display: flex; gap: 8px; margin-top: 14px; }
.doc-textarea {
  width: 100%; box-sizing: border-box; min-height: 320px; resize: vertical;
  padding: 12px 14px;
  font-family: var(--font-mono); font-size: 12.5px; line-height: 1.65;
  color: var(--fg-soft); background: var(--paper-raised); border: 1px solid var(--border-strong);
  border-radius: var(--radius); tab-size: 2;
}
.doc-textarea:focus { outline: none; border-color: var(--fg); }

/* ── Обучение: дифф предложения ───────────────────────────────────── */
.lr-diff { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 2px 0 14px; }
.lr-side { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.lr-side .caps { font-size: var(--fs-label); color: var(--fg-label); }
.lr-code {
  margin: 0; padding: 10px 12px; border-radius: var(--radius);
  font-family: var(--font-mono); font-size: 12.5px; line-height: 1.55;
  white-space: pre-wrap; word-break: break-word;
}
.lr-old { background: var(--paper-mute); border: 1px solid var(--border-strong); color: var(--fg-soft); }
.lr-new { background: var(--ok-bg); border: 1px solid var(--ok-border); color: var(--fg); }

/* ── Крон: раскрытие описания джобы ───────────────────────────────── */
.tbl-wrap { overflow-x: auto; }
/* Тултипы кнопок выходят за пределы строки, а overflow-x: auto режет и по
   вертикали. На широком экране горизонтальная прокрутка таблице не нужна —
   там снимаем обрезку, на узком тултип уступает прокрутке. */
@media (min-width: 860px) {
  .card, .tbl-wrap { overflow: visible; }
}

/* Название работы + технический слаг под ним (тумблер «Имена работ»). */
.job-title { display: flex; flex-direction: column; gap: 1px; }
.job-slug { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--fg-label); display: none; }
.jobs-slugs .job-slug { display: block; }

/* «Кто выполняет»: у крон-работы агента нет, стоит серая плашка. */
.who-tag {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: var(--radius-tag);
  background: var(--tag-bg); color: var(--tag-fg);
  font-size: var(--fs-xs); white-space: nowrap;
}
.who-tag.root { background: var(--warn-bg); color: var(--warn); }

/* Полоска с тумблером над таблицей: шапки блока у крон-работ нет — её
   заголовок повторял подзаголовок страницы, а счётчик паузы живёт в
   сайдбаре (.ni-badge.alert). */
.jobs-bar { display: flex; justify-content: flex-end; margin: 0 0 10px; }

/* Тумблер — разметка эталонного <Toggle> из дизайн-системы: сам переключатель
   это button.toggle с aria-pressed, включённый красится в --ok. */
.toggle {
  position: relative; flex: none;
  width: 28px; height: 16px; padding: 0; border: none;
  border-radius: var(--radius-pill);
  background: var(--border-strong);
  cursor: pointer;
  transition: background var(--dur-base) var(--ease-out);
}
.toggle::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--paper-card); box-shadow: 0 1px 2px rgba(0,0,0,.2);
  transition: transform var(--dur-base) var(--ease-out);
}
.toggle.on { background: var(--ok); }
.toggle.on::after { transform: translateX(12px); }
.toggle:focus-visible { outline: 2px solid var(--fg); outline-offset: 2px; }
/* Тумблер с подписью рядом. */
.toggle-field {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: var(--fs-xs); color: var(--fg-muted);
  user-select: none;
}

/* Тултип: подпись кнопки, у которой её отобрали. Ловится и с клавиатуры —
   :focus-visible, а не только :hover. */
[data-tip] { position: relative; }
[data-tip]::after {
  content: attr(data-tip);
  position: absolute; bottom: calc(100% + 8px); left: 50%;
  transform: translateX(-50%) translateY(3px);
  padding: 4px 9px; border-radius: var(--radius-sm);
  background: var(--fg); color: var(--fg-on-ink);
  font-family: var(--font-sans); font-size: var(--fs-xs); font-weight: 500;
  line-height: 1.4; white-space: nowrap;
  letter-spacing: 0; text-transform: none; text-align: left;
  opacity: 0; pointer-events: none; z-index: 20;
  transition: opacity var(--dur-fast) var(--ease-out),
              transform var(--dur-fast) var(--ease-out);
}
[data-tip]::before {
  content: ''; position: absolute; bottom: calc(100% + 3px); left: 50%;
  transform: translateX(-50%);
  border: 4px solid transparent; border-top-color: var(--fg);
  opacity: 0; pointer-events: none; z-index: 20;
  transition: opacity var(--dur-fast) var(--ease-out);
}
[data-tip]:hover::after, [data-tip]:focus-visible::after {
  opacity: 1; transform: translateX(-50%) translateY(0);
}
[data-tip]:hover::before, [data-tip]:focus-visible::before { opacity: 1; }

.job-row { cursor: pointer; }
.job-row:focus-visible { outline: 2px solid var(--fg); outline-offset: -2px; }
.job-row.open > td { border-bottom-color: transparent; background: var(--row-hover); }
.job-name-cell { display: inline-flex; align-items: center; gap: 8px; }
.job-caret { display: inline-flex; color: var(--fg-faint); flex: none; transition: transform var(--dur-fast) var(--ease-out); }
.job-row.open .job-caret { transform: rotate(180deg); color: var(--fg-muted); }
.job-detail > td { padding: 0 18px 16px; background: var(--row-hover); border-bottom: 1px solid var(--border-row); }
.jd-wrap { margin-left: 4px; padding: 2px 0 2px 14px; border-left: 2px solid var(--border-strong);
           animation: jd-in var(--dur-base) var(--ease-out); }
.jd-desc { margin: 0 0 12px; max-width: 68ch; font-size: var(--fs-sm); line-height: 1.6; color: var(--fg-soft); }
.jd-kv { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 6px 14px; margin: 0; }
.jd-kv > div { display: contents; }
.jd-kv dt { padding-top: 2px; font-size: var(--fs-label); text-transform: uppercase;
            letter-spacing: var(--tracking-label); color: var(--fg-label); }
.jd-kv dd { margin: 0; font-size: 12.5px; color: var(--fg-muted); overflow-wrap: anywhere; }
.jd-kv dd.mono { font-family: var(--font-mono); }
@keyframes jd-in { from { opacity: 0; transform: translateY(-3px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .jd-wrap { animation: none; }
  .job-caret { transition: none; }
  .toggle, .toggle::after { transition: none; }
  [data-tip]::after, [data-tip]::before { transition: none; }
  [data-tip]:hover::after, [data-tip]:focus-visible::after { transform: translateX(-50%); }
}

/* ── Интеграции: секреты ──────────────────────────────────────────── */
.secret-group { margin-bottom: 18px; }
.secret-group:last-of-type { margin-bottom: 0; }
.secret-group-title {
  font-size: var(--fs-label); font-weight: 600; text-transform: uppercase;
  letter-spacing: var(--tracking-label); color: var(--fg-label); margin: 0 0 10px;
}
.secret-row { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.secret-label { width: 210px; flex: none; font-size: var(--fs-sm); font-weight: 500; color: var(--fg); }
.secret-input {
  flex: 1; border: 1px solid var(--border-strong); border-radius: var(--radius);
  padding: 8px 12px; font-family: var(--font-mono); font-size: 12.5px;
  background: var(--paper-raised); color: var(--fg); outline: none;
}
.secret-input:focus { border-color: var(--fg); }
.form-actions { margin-top: 20px; display: flex; justify-content: flex-end; }
.auth-none { color: var(--fg-faint); font-style: normal; }

/* ── MCP: заметка о проблеме и ряд полей формы ────────────────────── */
.row-note { margin-top: 6px; padding-left: 9px; border-left: 2px solid var(--warn);
            font-size: var(--fs-xs); color: var(--fg-muted); line-height: 1.5; }
.row-note.err { border-left-color: var(--err); }

/* ── Обучение: карточка-уведомление после решения (?ok=) — тот же приём,
   левый бордер цветом статуса, что и .row-note, но на уровне карточки ── */
.notice-warn { border-left: 2px solid var(--warn); }
.notice-err  { border-left: 2px solid var(--err); }
.form-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.form-row .field { flex: 1; min-width: 180px; }
.form-row .field.grow { flex: 2.2; }

/* ── markdown-проза ──────────────────────────────────────────────── */
.md { font-size: var(--fs-sm); line-height: 1.65; color: var(--fg-soft); }
.md > :first-child { margin-top: 0; }
.md h2 { font-size: var(--fs-h2); font-weight: 600; color: var(--fg); margin: 20px 0 8px; }
.md h3 { font-size: var(--fs-body); font-weight: 600; color: var(--fg); margin: 16px 0 6px; }
.md h4 { font-size: var(--fs-label); font-weight: 600; color: var(--fg-label); margin: 12px 0 4px; text-transform: uppercase; letter-spacing: var(--tracking-label); }
.md p { margin: 8px 0; }
.md ul { list-style: none; margin: 6px 0; padding-left: 14px; }
.md li { position: relative; padding-left: 12px; margin: 3px 0; }
.md li::before { content: "·"; position: absolute; left: 0; color: var(--fg-label); }
.md ul ul { margin: 3px 0; padding-left: 6px; }
.md strong { font-weight: 600; color: var(--fg); }
.md em { font-style: italic; color: var(--fg-muted); }
.md code { font-size: 0.92em; }
.md a { color: var(--info); text-decoration: underline; text-underline-offset: 2px; }
.md a:hover { opacity: 0.75; }
.md hr { border: 0; border-top: 1px solid var(--border-faint); margin: 16px 0; }
.md pre {
  font-family: var(--font-mono); font-size: 12.5px; line-height: 1.65;
  color: var(--fg-soft); white-space: pre-wrap; margin: 0;
}

/* ── Responsive (≤900px → drawer) ─────────────────────────────────── */
@media (max-width: 900px) {
  .app, .app.rail { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 0; z-index: 60;
    width: var(--sidebar-w); height: 100vh;
    background: var(--sb-bg);
    box-shadow: 1px 0 12px rgba(0,0,0,.12);
    transform: translateX(-100%);
    transition: transform var(--dur-base) var(--ease-out);
  }
  .app.drawer-open .sidebar { transform: none; }
  .app.drawer-open::after {
    content: ""; position: fixed; inset: 0; z-index: 50;
    background: rgba(28,25,23,.30);
  }
  .main { border-radius: 0; box-shadow: none; }
  .menu-btn { display: inline-flex; }
  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; }
  .hide-sm { display: none !important; }
  .content { padding: 18px 16px; }
  .secret-row { flex-wrap: wrap; }
  .secret-label { width: auto; }
  .lr-diff { grid-template-columns: 1fr; }
}

/* ── Агенты: карточка (срез 18) ────────────────────────────────────── */
.agent-head { display: flex; align-items: center; gap: 22px; }
.agent-head .doc-titles { flex: 1; }
.agent-pills { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.agent-claims { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: var(--fs-sm); }

/* Портрет — спрайт из офиса, без подложки: фон карточки и есть фон. */
.agent-portrait {
  flex: none; width: 99px;
  display: flex; align-items: flex-end; justify-content: center;
}
.agent-portrait img {
  width: 99px; height: 177px;
  image-rendering: pixelated; image-rendering: crisp-edges;
  transform-origin: 50% 100%;
}
.agent-portrait.empty {
  height: 177px; flex-direction: column; justify-content: center; gap: 8px;
  padding: 12px 8px; text-align: center;
  border: 1px dashed var(--border-strong); border-radius: var(--radius-lg);
}
.ap-glyph { font-size: 28px; font-weight: 600; color: var(--fg-faint); font-family: var(--font-mono); line-height: 1; }
.ap-note { font-size: var(--fs-xs); color: var(--fg-label); line-height: 1.4; }
.ap-note code { font-size: 10px; padding: 1px 4px; }

/* Приход: подпрыгнул, приземлился, качнулся и встал. Один раз при
   открытии карточки — постоянного движения на странице нет. */
.agent-portrait.play { animation: agent-enter 640ms var(--ease-out) both; }
@keyframes agent-enter {
  0%   { opacity: 0; transform: translateY(14px) scale(1.10, 0.86); }
  35%  { opacity: 1; transform: translateY(-11px) scale(0.94, 1.09); }
  62%  { transform: translateY(0) scale(1.06, 0.93); }
  82%  { transform: translateY(-3px) scale(0.99, 1.02); }
  100% { transform: translateY(0) scale(1, 1); }
}
.agent-portrait:hover img { animation: agent-hop 420ms var(--ease-out); }
@keyframes agent-hop {
  0%   { transform: translateY(0) scale(1, 1); }
  30%  { transform: translateY(-7px) scale(0.96, 1.05); }
  70%  { transform: translateY(0) scale(1.05, 0.95); }
  100% { transform: translateY(0) scale(1, 1); }
}
@media (prefers-reduced-motion: reduce) {
  .agent-portrait, .agent-portrait img, .agent-portrait:hover img { animation: none !important; }
}

/* ── Раздел «Система»: редизайн 20.09.2026 (макет утверждён владельцем) ──
   Список-таблица на гриде: те же шапки и строки, что у .tbl, но на телефоне
   складывается в карточки, а не уезжает за край. Страницы раздела идут во
   всю ширину контента — отступ справа такой же, как слева. */
.section-enter.full { max-width: none; }
.ls { --cols: 1fr; }
.ls-row { display: grid; grid-template-columns: var(--cols); gap: 14px; align-items: center;
  padding: 11px 18px; border-bottom: 1px solid var(--border-row); min-width: 0; }
.ls-row:last-child { border-bottom: none; }
.ls-row:hover { background: var(--row-hover); }
.ls-row[hidden] { display: none; }
.ls-head { padding: 9px 18px; border-bottom: 1px solid var(--border-faint);
  font-size: var(--fs-label); font-weight: 600; text-transform: uppercase;
  letter-spacing: var(--tracking-label); color: var(--fg-label); }
.ls-head:hover { background: transparent; }
.ls-group { display: flex; align-items: baseline; gap: 8px; padding: 8px 18px 6px;
  background: var(--paper-mute); border-bottom: 1px solid var(--border-faint);
  font-size: var(--fs-label); font-weight: 600; text-transform: uppercase;
  letter-spacing: var(--tracking-label); color: var(--fg-label); }
.ls-group[hidden] { display: none; }
.ls-group .n { font-weight: 400; letter-spacing: 0; text-transform: none; color: var(--fg-faint); }
.ls-row .r { text-align: right; justify-self: end; display: inline-flex; gap: 6px; align-items: center; }
.ls-row .cell { min-width: 0; }
.ls-row .sub { display: block; font-size: var(--fs-xs); color: var(--fg-label); margin-top: 1px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ls-row .sub.mono { font-family: var(--font-mono); }
.ls-row .sub.wrap { white-space: normal; }
.ls-row .sub.ok { color: var(--ok); } .ls-row .sub.warn { color: var(--warn); }
.ls-detail { padding: 0 18px 16px; background: var(--row-hover); border-bottom: 1px solid var(--border-row); }
.ls-detail[hidden] { display: none; }
.ls-detail .form-row { padding-top: 12px; }
.ls-row.exp { cursor: pointer; }
.ls-row.exp:focus-visible { outline: 2px solid var(--fg); outline-offset: -2px; }
.ls-row.exp.open { background: var(--row-hover); border-bottom-color: transparent; }

/* полоса отборов над списком — чипы .tg со счётчиком */
.bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 0 0 12px; }
.bar .sp { flex: 1; }
.bar .tg { border: 1px solid transparent; background: var(--tag-bg); color: var(--tag-fg);
  font-size: var(--fs-xs); cursor: pointer; font-family: inherit; }
.bar .tg b { font-weight: 500; color: var(--fg-faint); }
.bar .tg.on { background: var(--ink); color: var(--fg-on-ink); } .bar .tg.on b { color: rgba(255,255,255,.7); }

/* расписание — чип-кнопка с часами, открывает пикер */
.sched { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px 3px 7px;
  border: 1px solid transparent; border-radius: var(--radius-sm); background: transparent;
  color: var(--fg-soft); font-family: var(--font-mono); font-size: var(--fs-xs); cursor: pointer; white-space: nowrap; }
.sched svg { color: var(--fg-faint); }
.sched:hover { border-color: var(--border-strong); background: var(--paper-card); color: var(--fg); }
.sched:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* состояние работы — тумблер с подписью; включённый — мох, как .toggle.on */
.st-tg { display: inline-flex; align-items: center; gap: 8px; font-size: var(--fs-xs); color: var(--fg-muted); }
.st-tg form { display: inline-flex; }
.ls-row.paused .cell.primary { opacity: .72; }
.who { display: inline-flex; align-items: center; gap: 6px; }
.who .av { width: 18px; height: 18px; border-radius: 50%; background: var(--accent-bg); color: var(--accent);
  font-size: 10px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); flex: none; }
.who .av.sys { background: var(--paper-mute); color: var(--fg-label); }
.who a:hover { color: var(--accent); }
.ls .job-slug { display: none; }
.jobs-slugs .ls .job-slug { display: inline; }

.btn.ico { width: 32px; height: 32px; }
.btn.ico[data-tip]::after { white-space: nowrap; }
.btn.ico.quiet { border-color: transparent; color: var(--fg-faint); }
.btn.ico.quiet:hover { border-color: var(--border-strong); color: var(--err); background: var(--err-bg); }

/* очередь обучения — карточки одного скелета: шапка, тело, подвал с действиями */
.q-card { padding: 0; }
.q-head { display: flex; align-items: flex-start; gap: 12px; padding: 14px 20px 12px; }
.q-head .doc-titles { flex: 1; }
.q-kind { flex: none; margin-top: 2px; font-size: var(--fs-xs); }
.q-body { padding: 0 20px 14px; }
.q-body .lr-diff { margin-bottom: 10px; }
.q-body .hint { margin-bottom: 10px; }
.ev { margin: 0 0 4px; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 5px; }
.ev li { font-size: 12.5px; color: var(--fg-soft); line-height: 1.5; padding-left: 10px; border-left: 2px solid var(--border-strong); }
.ev li b { font-weight: 500; color: var(--fg); font-family: var(--font-mono); font-size: 11.5px; margin-right: 6px; }
.ev li i { color: var(--fg-label); font-style: normal; }
.q-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 12px 20px;
  border-top: 1px solid var(--border-faint); background: var(--paper-raised);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.q-foot .sp { flex: 1; }
.q-foot .hint { margin: 0; }
.q-foot form { display: inline-flex; }
.q-more { padding: 12px 20px; border-top: 1px solid var(--border-faint); }
.q-more[hidden] { display: none; }
.q-more .form-row { margin: 0; }
.q-more .doc-textarea { width: 100%; margin-top: 6px; }
.md-prev { font-size: var(--fs-sm); color: var(--fg-soft); line-height: 1.6; max-height: 5.5em; overflow: hidden; position: relative; }
.md-prev::after { content: ""; position: absolute; inset: auto 0 0 0; height: 2.2em; background: linear-gradient(transparent, var(--paper-card)); }
.md-prev.open { max-height: none; } .md-prev.open::after { display: none; }
.lnk { background: none; border: none; padding: 0; color: var(--accent); font-size: var(--fs-xs); cursor: pointer;
  text-decoration: underline; text-underline-offset: 2px; font-family: inherit; }
.q-empty { padding: 26px 20px; text-align: center; color: var(--fg-label); font-size: var(--fs-sm); }
.q-empty small { display: block; margin-top: 3px; color: var(--fg-faint); font-size: var(--fs-xs); }
.notice { padding: 10px 14px; margin-bottom: 12px; font-size: var(--fs-sm); color: var(--fg-soft); }

/* гости: проекты чипами, «+ проект» пунктиром */
.proj { display: inline-flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.proj .tg { cursor: default; }
.proj .tg em { font-style: normal; color: var(--fg-faint); margin-left: 4px; }
.proj .tg .btn { width: 18px; height: 18px; border: none; margin-right: -4px; }
.proj form { display: inline-flex; }
.tg.addp { border: 1px dashed var(--border-strong); background: transparent; color: var(--fg-muted); cursor: pointer; font-family: inherit; }
.tg.addp:hover { color: var(--fg); border-color: var(--fg-muted); }
.note { display: flex; gap: 8px; align-items: flex-start; padding: 8px 10px; border-left: 2px solid var(--warn); background: var(--warn-bg);
  color: var(--warn); font-size: var(--fs-xs); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; margin: 0 0 10px; }
.note.info { border-left-color: var(--accent); background: var(--accent-bg); color: var(--accent); }

/* интеграции: меню «⋯», карточки ключей, полоса сохранения */
.menu-wrap { position: relative; }
.menu { position: absolute; right: 0; top: calc(100% + 4px); z-index: 20; min-width: 200px; padding: 4px;
  background: var(--paper-card); border: 1px solid var(--border-strong); border-radius: var(--radius); box-shadow: var(--shadow-modal); }
.menu[hidden] { display: none; }
.menu button, .menu a { display: flex; width: 100%; gap: 8px; align-items: center; padding: 7px 10px; border: none; background: none;
  border-radius: var(--radius-sm); font-size: var(--fs-sm); color: var(--fg-soft); cursor: pointer; text-align: left; font-family: inherit; }
.menu button:hover, .menu a:hover { background: var(--paper-mute); color: var(--fg); }
.menu button.danger { color: var(--err); }
.menu hr { border: 0; border-top: 1px solid var(--border-faint); margin: 4px 0; }
.menu form { margin: 0; }
.sec-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.sec-grid .card { margin: 0; }
.sec-title { padding: 12px 18px 8px; font-size: var(--fs-label); font-weight: 600; text-transform: uppercase;
  letter-spacing: var(--tracking-label); color: var(--fg-label); }
.sec-row { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 10px; align-items: center; padding: 9px 18px; border-top: 1px solid var(--border-row); }
.sec-row > span:first-child { display: flex; flex-direction: column; min-width: 0; }
.sec-row .lbl { font-size: var(--fs-sm); font-weight: 500; }
.sec-row .val { display: inline-flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 1px; font-size: var(--fs-xs); color: var(--fg-label); }
.sec-row .val code { font-size: 11px; }
.sec-edit { grid-column: 1 / -1; display: flex; gap: 8px; align-items: center; }
.sec-edit[hidden] { display: none; }
.sec-edit .field { flex: 1; }
.savebar { position: sticky; bottom: 0; margin-top: 14px; display: flex; align-items: center; gap: 12px; padding: 10px 16px;
  background: var(--paper-card); border: 1px solid var(--border-strong); border-radius: var(--radius-lg); box-shadow: var(--shadow-modal); }
.savebar[hidden] { display: none; }
.savebar .sp { flex: 1; }
.savebar .t { font-size: var(--fs-sm); color: var(--fg-soft); }
.tok { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 12px; align-items: center; padding: 14px 20px; }
.tok .big { font-size: var(--fs-h2); font-weight: 500; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.tok .big code { font-size: 12.5px; }
.tok .big .sub { font-size: var(--fs-sm); color: var(--fg-label); }
.steps { margin: 12px 0 0; padding-left: 18px; font-size: 12.5px; color: var(--fg-soft); line-height: 1.6; }
.steps code { font-size: .92em; }
.tab[hidden] { display: none; }

/* настройки: строка с тумблером, сохраняется сразу */
.set-row { display: grid; grid-template-columns: 34px minmax(0,1fr) auto; gap: 12px; align-items: flex-start;
  padding: 14px 20px; border-top: 1px solid var(--border-row); cursor: pointer; }
.set-row:first-child { border-top: none; }
.set-row .saved { font-size: var(--fs-xs); color: var(--fg-faint); white-space: nowrap; padding-top: 3px; }

@media (max-width: 720px) {
  .ls-head { display: none; }
  .ls-row { grid-template-columns: 1fr auto; row-gap: 8px; padding: 12px 14px; }
  .ls-row > .cell.primary { grid-column: 1; }
  .ls-row > .cell.wide { grid-column: 1 / -1; }
  .ls-row > .r { grid-row: 1; grid-column: 2; }
  .sec-grid { grid-template-columns: 1fr; }
  .tok { grid-template-columns: 1fr; }
  .q-head, .q-body, .q-foot, .q-more { padding-inline: 14px; }
}

/* ── Раздел «Знания»: Библиотека, Контакты, Контекст — редизайн 21.09.2026
      (те же правила, что у «Системы»; макет утверждён владельцем) ── */
.bar a.tg { text-decoration: none; }
.bar .div { width: 1px; height: 18px; background: var(--border-strong); margin: 0 4px; }
.bar .field select, .bar .field input { min-width: 150px; }
.ls .num { font-variant-numeric: tabular-nums; text-align: right; }
.ls .date { font-variant-numeric: tabular-nums; color: var(--fg-soft); font-size: var(--fs-sm); }
.ls .faint { color: var(--fg-faint); }
.ls .tags { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.ls-row .svc-name a { color: inherit; text-decoration: none; }
.ls-row .svc-name a:hover { color: var(--accent); }
.ls-row .mtg a { color: var(--fg-soft); }
.ls-row .mtg a:hover { color: var(--accent); }
.ls-row.closed .cell.primary { opacity: .7; }
.ls-row .r form { display: inline-flex; }
.ls-group .ico-in { margin-left: auto; display: inline-flex; }
.ls-group .ico-in form { display: inline-flex; }
.ls-group .btn.ico { width: 24px; height: 24px; }
.due-over { color: var(--err); font-weight: 500; }
.kind { font-size: var(--fs-xs); color: var(--fg-label); border: 1px solid var(--border-row);
  border-radius: var(--radius-sm); padding: 0 6px; white-space: nowrap; }
.more-filters { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 12px; }
.more-filters[hidden] { display: none; }
.res { list-style: none; margin: 0; padding: 0; }
.res li { padding: 12px 18px; border-bottom: 1px solid var(--border-row); cursor: pointer; }
.res li:last-child { border-bottom: none; }
.res li:hover { background: var(--row-hover); }
.res li.dim { opacity: .7; }
.res .h { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.res .h .t { font-weight: 500; }
.res .h .p { font-size: var(--fs-xs); color: var(--fg-label); }
.res .h .sp { flex: 1; }
.res .h .date { font-variant-numeric: tabular-nums; color: var(--fg-soft); font-size: var(--fs-sm); }
.res .s { margin-top: 4px; font-size: var(--fs-sm); color: var(--fg-soft); line-height: 1.55; }
.res mark { background: var(--warn-bg); color: inherit; }
.res .around { margin-top: 8px; padding-left: 10px; border-left: 2px solid var(--border-strong);
  white-space: pre-wrap; font-size: var(--fs-sm); color: var(--fg-label); }
.add-card { margin-bottom: 14px; }
.add-card[hidden] { display: none; }
.add-card .grid { gap: 10px; }
.add-card .foot { display: flex; gap: 8px; margin-top: 12px; }
.detail-form { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 10px; padding-top: 12px; }
.detail-form .foot, .add-card .foot { grid-column: 1 / -1; }
.detail-form .foot { display: flex; gap: 8px; }
.span-rest { grid-column: 2 / -1; }
.where { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: var(--fs-xs); color: var(--fg-label); margin-top: 12px; }
.where b { font-weight: 600; color: var(--fg-soft); }
.where a { color: inherit; }
.doc-path { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--fg-faint); margin-bottom: 10px; }
.imp-kv { margin: 0 0 14px; grid-template-columns: 136px minmax(0, 1fr); }
.imp-list { margin: 4px 0 0; padding-left: 18px; font-size: var(--fs-xs); font-family: var(--font-mono); }
.note[hidden] { display: none; }
.note .btn { margin: -4px 0; flex: none; }
.note .grow { flex: 1; }
@media (max-width: 720px) {
  .detail-form { grid-template-columns: 1fr; }
  .span-rest { grid-column: auto; }
  .bar .div { display: none; }
  .bar .field { flex: 1 1 140px; }
  .bar .field select, .bar .field input { min-width: 0; }
  .ls .num { text-align: left; }
  .ls-row > span:empty { display: none; }
}

/* Плашка публичного демо (os-demo): рендерится только с AI_OS_DEMO=1 */
.demo-bar { padding: 6px 16px; font-size: var(--fs-sm); line-height: 1.4;
  background: var(--accent-bg); color: var(--fg);
  border-bottom: 1px solid var(--border); }
