* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font-sans); font-size: 15px; line-height: 1.3;
  background: hsl(var(--background)); color: hsl(var(--foreground));
  overflow-x: hidden;
}
.hidden { display: none !important; }
h1 { font-size: 30px; line-height: 1.1; font-weight: 700; margin: 0 0 6px; letter-spacing: -.01em; }
h2 { font-size: 20px; line-height: 1.2; font-weight: 500; margin: 0 0 12px; }
.muted { color: hsl(var(--muted-foreground)); margin: 0; }
.label {
  font-size: 12px; font-weight: 500; text-transform: uppercase;
  letter-spacing: .08em; color: hsl(var(--muted-foreground)); margin-bottom: 8px;
}

.card { background: hsl(var(--card)); color: hsl(var(--card-foreground)); border: 0; border-radius: var(--r-card); }

input, textarea {
  width: 100%; padding: 9px 15px; min-height: var(--ctrl-h);
  font: inherit; color: inherit; background: hsl(var(--surface));
  border: 1px solid hsl(var(--input)); border-radius: var(--r-btn); outline: none;
}
input::placeholder, textarea::placeholder { color: hsl(var(--subtle)); }
input:focus, textarea:focus, select:focus { border-color: hsl(var(--ring)); }
input:disabled, textarea:disabled, select:disabled { color: hsl(var(--muted-foreground)); opacity: .8; cursor: default; }
[aria-invalid="true"] { border-color: hsl(var(--error-line)); }
textarea { resize: vertical; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: var(--ctrl-h); padding: 0 20px; font: inherit; font-size: 15px; font-weight: 600; line-height: 1;
  color: hsl(var(--foreground)); background: hsl(var(--card));
  border: 1px solid hsl(var(--border)); border-radius: var(--r-btn); cursor: pointer;
}
.btn:hover { background: hsl(var(--accent)); border-color: hsl(var(--primary) / .4); }
.btn:active { background: hsl(var(--secondary)); }
.btn.primary { background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); border-color: transparent; }
.btn.primary:hover { background: hsl(var(--primary-hover)); }
.btn.primary:active { background: hsl(var(--primary-active)); }
.btn.danger { color: hsl(var(--destructive)); }
.btn:disabled { background: hsl(0 0% 93%); color: hsl(0 0% 83%); border-color: transparent; cursor: default; pointer-events: none; }
.dark .btn:disabled { background: hsl(var(--secondary)); color: hsl(var(--subtle)); }
.btn.ghost-dark { background: transparent; color: hsl(var(--side-fg)); border-color: hsl(0 0% 100% / .4); width: 100%; padding: 0 12px; }
.btn.ghost-dark:hover { background: hsl(0 0% 100% / .12); border-color: hsl(0 0% 100%); }
.btn.ghost-dark:active { background: hsl(0 0% 100% / .18); }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Вход */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: linear-gradient(180deg, hsl(var(--side-from)), hsl(var(--side-to))); }
.login-card { width: 100%; max-width: 400px; padding: 40px 32px; display: flex; flex-direction: column; gap: 12px; }
.error { color: hsl(var(--destructive)); min-height: 18px; font-size: 12px; }

/* Каркас */
.shell { display: flex; min-height: 100vh; }
.side {
  width: var(--side-w); flex-shrink: 0; background: linear-gradient(180deg, hsl(var(--side-from)), hsl(var(--side-to))); color: hsl(var(--side-fg));
  display: flex; flex-direction: column; padding: 16px 12px; gap: 20px;
  /* закреплено по высоте окна: «Выйти» всегда на виду, даже когда на странице много проектов */
  position: sticky; top: 0; height: 100vh; align-self: flex-start; overflow-y: auto;
}
.side { transition: width .18s; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; padding: 4px 8px; }
.dot { width: 12px; height: 12px; border-radius: 4px; background: #fff; }
.side nav { flex: 1; }
.side .label { color: hsl(0 0% 100% / .7); padding: 0 8px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--r-btn); cursor: pointer; font-weight: 500; }
.nav-item.active { background: #fff; color: hsl(var(--primary-active)); }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.top { height: var(--navbar-h); background: hsl(var(--card)); display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding: 0 24px; }
.content { padding: 30px 40px 40px; max-width: 1100px; width: 100%; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }

.date { font-size: 12px; color: hsl(var(--muted-foreground)); font-variant-numeric: tabular-nums; }
.status {
  font-size: 12px; font-weight: 500; letter-spacing: .02em; padding: 5px 12px;
  border-radius: var(--r-pill); border: 0; cursor: pointer; appearance: none; text-align: center;
  color: hsl(var(--warn)); background: hsl(var(--warn) / .14);
}
.status[data-s="НОВЫЙ"] { color: hsl(var(--accent-foreground)); background: hsl(var(--accent)); }
.dark .status[data-s="НОВЫЙ"] { background: hsl(var(--primary) / .2); }
.status[data-s="БОЕВОЙ"] { color: hsl(var(--ok)); background: hsl(var(--ok) / .14); }

/* Виджеты шапки */
.widgets { display: flex; gap: 10px 18px; margin-right: auto; }
.wgroup { display: flex; gap: 10px; cursor: pointer; border-radius: var(--r-btn); }
.wgroup:focus-visible { outline: 2px solid hsl(var(--primary)); outline-offset: 2px; }
.wgroup:hover .widget { filter: brightness(.96); }
.widget { display: flex; align-items: center; gap: 8px; height: var(--ctrl-h); padding: 0 12px; border-radius: var(--r-btn); background: hsl(var(--surface)); }
.widget .label { margin: 0; }
.widget b { font-size: 13px; font-weight: 600; min-width: 40px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.widget b.warn { color: hsl(var(--warn)); }
.widget b.bad { color: hsl(var(--bad)); }
.spark { width: 60px; height: 20px; stroke: hsl(var(--primary)); stroke-width: 1.5; fill: hsl(var(--primary) / .15); }
@media (max-width: 720px) { .spark { display: none; } .top { gap: 8px; } }

/* Статистика */
.period { width: auto; min-height: var(--ctrl-h); padding: 0 10px; font: inherit; color: inherit; background: hsl(var(--card)); border: 1px solid hsl(var(--input)); border-radius: var(--r-btn); }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; margin-bottom: 14px; }
.tile { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 120px; padding: 20px 12px; text-align: center; border: 0; border-radius: var(--r-card); background: hsl(var(--card)); container-type: inline-size; }
.tile .label { margin: 0; min-height: 2.5em; display: flex; align-items: center; justify-content: center; line-height: 1.25; white-space: pre-line; } /* подпись плитки занимает две строки (одна строка стоит по центру этого места), чтобы плитки в ряду были одинаковыми */
/* значение всегда в одну строку, по центру: размер шрифта зависит от ширины плитки и числа знаков (--n задаёт app.js) */
.tile b { display: block; max-width: 100%; white-space: nowrap; font-size: clamp(16px, calc(94cqw / (var(--n, 4) * .62)), 30px); line-height: 1.15; font-weight: 600; letter-spacing: -.02em; color: hsl(var(--primary)); font-variant-numeric: tabular-nums; }
.tile-note { font-size: 13px; color: hsl(var(--muted-foreground)); }
.chart-card { padding: 20px; margin-bottom: 14px; }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 140px; }
.bar { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; gap: 4px; }
.bar i { display: block; width: 100%; background: hsl(var(--primary)); border-radius: 6px 6px 0 0; min-height: 1px; }
.bar span { font-size: 10px; color: hsl(var(--muted-foreground)); white-space: nowrap; }
.bar em { font-style: normal; font-size: 11px; font-weight: 500; }

/* Чат */
.chat { display: flex; flex-direction: column; height: calc(100vh - var(--navbar-h)); }
.chat-log { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.msg { max-width: 82%; padding: 10px 14px; border-radius: 16px; white-space: pre-wrap; word-break: break-word; line-height: 1.5; }
.msg.user { align-self: flex-end; background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); }
.msg.assistant { align-self: flex-start; background: hsl(var(--surface)); }
.msg.error { align-self: flex-start; color: hsl(var(--destructive)); background: hsl(var(--destructive) / .1); }
.msg.pending { color: hsl(var(--muted-foreground)); font-style: italic; }
.chat-form { display: flex; gap: 8px; margin-top: 12px; align-items: flex-end; }
.chat-form textarea { flex: 1; }

/* Пользователи */
.userbox { padding: 0 8px; text-align: center; }
.userbox .label { margin-bottom: 2px; padding: 0; } /* отступ уже есть у блока: иначе роль съезжает вправо от имени */
.me-name { font-weight: 600; word-break: break-all; }
.list { margin-bottom: 14px; }
.list .pad { padding: 14px 16px 6px; margin: 0; }
.urow { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-top: 1px solid hsl(var(--border)); flex-wrap: wrap; }
.urow .grow { flex: 1; min-width: 120px; font-weight: 500; }
.urow .sub { color: hsl(var(--muted-foreground)); font-size: 12px; }
.badge { font-size: 12px; padding: 4px 10px; border-radius: var(--r-pill); color: hsl(var(--accent-foreground)); background: hsl(var(--accent)); }
.dark .badge { background: hsl(var(--primary) / .2); }
.invite-result { padding: 14px 16px; margin-bottom: 14px; }
.invite-result code { display: block; margin: 8px 0; padding: 8px 10px; border-radius: var(--r-btn); background: hsl(var(--secondary)); word-break: break-all; font-family: var(--font-mono); font-size: 12px; }
.owner { font-size: 12px; padding: 3px 8px; border-radius: 8px; border: 1px solid hsl(var(--border)); background: transparent; color: hsl(var(--muted-foreground)); width: auto; min-height: 0; }

/* Эксплорер файлов */
.fx-card { width: 100%; max-width: 980px; height: min(86vh, 720px); padding: 18px; display: flex; flex-direction: column; gap: 12px; border-radius: var(--r-card); }
.fx-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.fx-head h2 { margin: 0; font-family: var(--font-mono); font-size: 15px; word-break: break-all; }
.fx-body { flex: 1; display: flex; gap: 12px; min-height: 0; }
.fx-tree { width: 260px; flex-shrink: 0; overflow: auto; background: hsl(var(--surface)); border: 0; border-radius: var(--r-card); padding: 6px; }
.fx-item { display: block; width: 100%; text-align: left; padding: 5px 8px; border: 0; border-radius: 7px; background: transparent; color: inherit; font-family: var(--font-mono); font-size: 12px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fx-item:hover { background: hsl(var(--secondary)); }
.fx-item.active { background: hsl(var(--card)); color: hsl(var(--accent-foreground)); }
.fx-item.dir { color: hsl(var(--muted-foreground)); cursor: default; }
.fx-view { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.fx-path { font-family: var(--font-mono); font-size: 12px; color: hsl(var(--muted-foreground)); word-break: break-all; }
.fx-editor { flex: 1; font-family: var(--font-mono); font-size: 12.5px; line-height: 1.5; resize: none; white-space: pre; overflow: auto; }
.fx-empty { padding: 12px; color: hsl(var(--muted-foreground)); font-size: 13px; }
@media (max-width: 720px) { .fx-body { flex-direction: column; } .fx-tree { width: 100%; max-height: 30%; } }

.fullw { width: 100%; }
.tdesc { font-size: 13px; min-height: 18px; margin-top: -4px; }
.badge.secret { margin-left: 6px; }

/* Модалка */
.modal { position: fixed; inset: 0; background: hsl(0 0% 0% / .5); display: grid; place-items: center; padding: 16px; z-index: 10; }
.modal-card { max-height: calc(100vh - 32px); overflow-y: auto; width: 100%; max-width: 460px; padding: 30px; border-radius: var(--r-card); display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; justify-content: flex-end; gap: 8px; }



/* ---- Меню: значки, свёрнутый «рельс» на компьютере, выезжающее меню на телефоне ---- */
.brand-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.icon-btn { display: inline-grid; place-items: center; width: 30px; height: 30px; padding: 0; border: 1px solid transparent; border-radius: 8px; background: transparent; color: inherit; cursor: pointer; flex-shrink: 0; }
.icon-btn:hover { background: hsl(0 0% 100% / .14); }
.top .icon-btn { width: var(--ctrl-h); height: var(--ctrl-h); border-color: hsl(var(--border)); color: hsl(var(--foreground)); }
.top .icon-btn:hover { background: hsl(var(--secondary)); }
.rail-toggle svg { transition: transform .18s; }
.burger { display: none; }
.backdrop { position: fixed; inset: 0; background: hsl(0 0% 0% / .5); z-index: 25; }
.nav-item { transition: background-color .15s, color .15s; }
.nav-item:hover { background: hsl(0 0% 100% / .12); }
.nav-item.active:hover { background: #fff; }
.nav-item:focus-visible, .icon-btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.top .icon-btn:focus-visible, .content :focus-visible { outline-color: hsl(var(--primary)); }
.nav-item svg, .btn.ghost-dark svg { flex-shrink: 0; }
.btn.ghost-dark { gap: 8px; }

@media (min-width: 721px) {
  html.rail .side { width: var(--side-cw); padding-left: 10px; padding-right: 10px; }
  html.rail .side .t, html.rail .side .label, html.rail .userbox { display: none; }
  html.rail .brand-row { flex-direction: column; gap: 12px; }
  html.rail .brand { padding: 4px 0; }
  html.rail .nav-item { justify-content: center; padding: 10px 0; }
  html.rail .btn.ghost-dark { padding: 0; }
  html.rail .rail-toggle svg { transform: rotate(180deg); }
}

/* ---- Диалоги и уведомления ---- */
.dlg { z-index: 60; }
.dlg-msg { margin: 0; line-height: 1.5; white-space: pre-line; }
.btn.danger-fill { background: hsl(var(--destructive)); color: #fff; border-color: transparent; }
.btn.danger-fill:hover { filter: brightness(1.08); }
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 70; display: flex; flex-direction: column; gap: 8px; max-width: min(360px, calc(100vw - 32px)); }
.toast { background: hsl(var(--foreground)); color: hsl(var(--background)); border: 0; border-radius: var(--r-card); padding: 10px 14px; animation: slidein .18s ease-out; }
.toast.error { background: hsl(var(--destructive)); color: #fff; }

/* ---- Пустые состояния, «Показать ещё» ---- */
.empty { padding: 32px 20px; background: hsl(var(--card)); border: 0; border-radius: var(--r-card); text-align: center; }
.empty p { margin: 0 0 12px; }
.more { display: block; margin: 14px auto; }
.list .more { margin: 10px 16px 14px; }

/* ---- Плавные переходы состояний (120–200 мс); без бесконечной декоративной анимации ---- */
.btn, .icon-btn, input, textarea, select { transition: border-color .15s, background-color .15s, color .15s, filter .15s, box-shadow .15s; }
.modal { animation: fadein .15s ease-out; }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
@keyframes slidein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* ---- Телефон: меню выезжает поверх содержимого по кнопке в шапке ---- */
@media (max-width: 720px) {
  .side { position: fixed; top: 0; bottom: 0; left: 0; z-index: 30; width: min(var(--side-w), 86vw); overflow-y: auto; transform: translateX(-100%); visibility: hidden; transition: transform .18s, visibility 0s .18s; }
  html.drawer-open .side { transform: none; visibility: visible; transition: transform .18s; }
  .rail-toggle { display: none; }
  .burger { display: inline-grid; }
  .content { padding: 20px 16px 30px; }
  .chat { height: auto; min-height: 70vh; }
  .top { height: auto; min-height: var(--navbar-h); padding: 10px 16px; flex-wrap: wrap; gap: 8px; }
  .burger { order: 1; margin-right: auto; }
  #theme-btn { order: 2; }
  .widgets { order: 3; width: 100%; margin-right: 0; }
  .widgets { flex-wrap: wrap; gap: 6px 12px; }
  .wgroup { gap: 6px; flex-wrap: wrap; max-width: 100%; }
  .widget b { min-width: 0; }
  .widget { padding: 0 8px; }
  .widget .label { letter-spacing: .06em; }
  .row { flex-wrap: wrap; }
  .urow { padding: 10px 12px; }
  .msg { max-width: 94%; }
}


/* ================= Экран проектов: разделы, фильтры, папки, таблица ================= */
.content.wide { max-width: 1400px; }

.tabs { display: inline-flex; max-width: 100%; gap: 4px; padding: 4px; margin-bottom: 20px; overflow-x: auto; background: hsl(var(--card)); border-radius: var(--r-card); }
.tab { display: inline-flex; align-items: center; gap: 8px; padding: 10px 18px; font: inherit; font-weight: 500; color: hsl(var(--foreground)); background: transparent; border: 0; border-radius: var(--r-btn); cursor: pointer; white-space: nowrap; transition: color .15s, background-color .15s; }
.tab:hover { background: hsl(var(--accent)); color: hsl(var(--accent-foreground)); }
.tab.active { background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); }
.tab:focus-visible { outline: 2px solid hsl(var(--primary)); outline-offset: 2px; }
.cnt { font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: var(--r-pill); background: hsl(var(--surface)); color: hsl(var(--muted-foreground)); font-variant-numeric: tabular-nums; }
.tab.active .cnt { background: hsl(0 0% 100% / .22); color: #fff; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.filters input[type=search] { width: 280px; max-width: 100%; }
.filters input, .filters .period, .msel summary { background: hsl(var(--card)); }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: hsl(var(--muted-foreground)); cursor: pointer; }
.check input { width: auto; min-height: 0; }
.msel { position: relative; }
.msel summary { list-style: none; display: inline-flex; align-items: center; min-height: var(--ctrl-h); padding: 0 12px; font-size: 14px; font-weight: 500; background: hsl(var(--card)); border: 1px solid hsl(var(--input)); border-radius: var(--r-btn); cursor: pointer; user-select: none; transition: border-color .15s; }
.msel summary::-webkit-details-marker { display: none; }
.msel summary::after { content: '▾'; margin-left: 8px; color: hsl(var(--muted-foreground)); }
.msel[open] summary, .msel summary:hover { border-color: hsl(var(--primary) / .45); }
.msel.active summary { border-color: hsl(var(--primary)); background: hsl(var(--accent)); color: hsl(var(--accent-foreground)); }
.msel-list { position: absolute; z-index: 12; top: calc(100% + 4px); left: 0; min-width: 200px; max-height: 280px; overflow: auto; padding: 6px; background: hsl(var(--popover, var(--card))); border: 1px solid hsl(var(--border)); border-radius: var(--r-card); }
.msel-list label { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 7px; font-size: 13px; cursor: pointer; }
.msel-list label:hover { background: hsl(var(--secondary)); }
.msel-list input { width: auto; min-height: 0; }
.msel-list .clear { width: 100%; margin-top: 4px; }

.proj-layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 16px; align-items: start; }
.proj-layout.nofolders { grid-template-columns: minmax(0, 1fr); }
.proj-layout.nofolders .folders { display: none; }

.folders { border: 0; border-radius: var(--r-card); background: hsl(var(--card)); padding: 16px; }
.folders-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.folders-head .label { margin: 0; }
.fitem { display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 10px; border: 0; border-radius: var(--r-btn); background: transparent; color: inherit; font: inherit; font-size: 14px; text-align: left; cursor: pointer; transition: background-color .15s; }
.fitem:hover { background: hsl(var(--secondary)); }
.fitem.active { background: hsl(var(--accent)); color: hsl(var(--accent-foreground)); font-weight: 600; }
.fitem:focus-visible { outline: 2px solid hsl(var(--primary)); outline-offset: -2px; }
.fitem .fname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fdot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.fold { width: 18px; height: 18px; flex-shrink: 0; display: inline-grid; place-items: center; border: 0; background: transparent; color: hsl(var(--muted-foreground)); cursor: pointer; border-radius: 5px; padding: 0; }
.fold:hover { background: hsl(var(--secondary)); }
.fold svg { width: 12px; height: 12px; transition: transform .15s; }
.fold.closed svg { transform: rotate(-90deg); }
.fspace { width: 18px; flex-shrink: 0; }
.folder-tools { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 10px; padding-top: 10px; border-top: 1px solid hsl(var(--border)); }

.tablewrap { overflow-x: auto; border: 0; border-radius: var(--r-card); background: hsl(var(--card)); }
.ptable { width: 100%; border-collapse: collapse; min-width: 720px; }
.ptable th:first-child, .ptable td:first-child { padding-left: 20px; }
.ptable th:last-child, .ptable td:last-child { padding-right: 20px; }
.ptable th { text-align: left; padding: 14px 12px; font-size: 12px; font-weight: 500; text-transform: uppercase; letter-spacing: .08em; color: hsl(var(--subtle)); border-bottom: 1px solid hsl(var(--border)); white-space: nowrap; }
.ptable td { padding: 14px 12px; border-bottom: 1px solid hsl(var(--border)); vertical-align: middle; }
.ptable tbody tr:last-child td { border-bottom: 0; }
.ptable tbody tr { transition: background-color .15s; }
.ptable tbody tr:hover { background: hsl(var(--surface)); }
/* ширины колонок — классами, а не порядковыми номерами: состав колонок меняется, номера съезжают молча */
.col-owner { width: 110px; }
.col-status { width: 120px; }
.col-date { width: 96px; }
.col-actions { width: 232px; }
.col-mod { width: 104px; }
td.col-date, td.col-mod { font-size: 13px; color: hsl(var(--muted-foreground)); font-variant-numeric: tabular-nums; }
td.col-mod .mtime { font-size: 12px; color: hsl(var(--subtle)); }
/* проект сейчас открыт в редакторе VS Code: значок рядом с названием */
.badge.busy { display: inline-flex; align-items: center; gap: 6px; margin-left: 8px; font-size: 11px; font-weight: 500; vertical-align: 2px; color: hsl(var(--warn)); background: hsl(var(--warn) / .13); }
.badge.busy::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; animation: busy-pulse 1.8s ease-in-out infinite; }
@keyframes busy-pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .badge.busy::before { animation: none; } }

.pname { font-size: 16px; font-weight: 600; word-break: break-word; }
.pdesc { color: hsl(var(--muted-foreground)); font-size: 13.5px; margin-top: 6px; word-break: break-word; white-space: pre-line; }
.pdesc .plink { color: hsl(var(--primary)); text-decoration: underline; }
.ptags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 10px; }
.ptags .badge { font-size: 10px; }
.ptags a.badge { text-decoration: none; }
.pin { color: hsl(var(--primary)); margin-right: 4px; }

.rowbtns { display: flex; gap: 4px; flex-wrap: wrap; width: 204px; }
.ib { display: inline-grid; place-items: center; width: 30px; height: 30px; padding: 0; border: 1px solid hsl(var(--border)); border-radius: 8px; background: transparent; color: hsl(var(--muted-foreground)); cursor: pointer; transition: color .15s, border-color .15s, background-color .15s; }
.ib svg { width: 17px; height: 17px; }
.ib:hover { color: hsl(var(--accent-foreground)); background: hsl(var(--accent)); border-color: hsl(var(--primary) / .4); }
.ib.on { color: hsl(var(--primary-foreground)); background: hsl(var(--primary)); border-color: transparent; }
.ib.danger:hover { color: hsl(var(--destructive)); border-color: hsl(var(--destructive) / .5); }
.ib:focus-visible { outline: 2px solid hsl(var(--primary)); outline-offset: 2px; }
.ptable select.status, .ptable select.owner { min-height: 0; }
.badge.warn { color: hsl(var(--warn)); background: hsl(var(--warn) / .13); }
.badge.blue { color: hsl(var(--blue)); background: hsl(var(--blue) / .13); }

.tlist { display: grid; gap: 10px; }
.trow { display: flex; align-items: center; gap: 16px; padding: 20px; border: 0; border-radius: var(--r-card); background: hsl(var(--card)); flex-wrap: wrap; }
.trow .tinfo { flex: 1; min-width: 240px; }
.trow .ttitle { font-size: 18px; font-weight: 500; }
.trow .tdesc { color: hsl(var(--muted-foreground)); font-size: 13px; margin-top: 2px; }

.chat-context { display: flex; align-items: center; gap: 10px; margin: 4px 0 0; font-size: 13px; }
.chat-context #chat-context-name { font-weight: 600; }

/* цвета папок */
.c-orange { background: hsl(var(--primary)); }
.c-blue { background: hsl(var(--blue)); }
.c-purple { background: hsl(var(--purple)); }
.c-teal { background: hsl(var(--teal)); }
.c-green { background: hsl(var(--ok)); }
.c-red { background: hsl(var(--destructive)); }
.c-gray { background: hsl(var(--muted-foreground)); }

/* поля форм в диалогах */
.dlg-fields { display: flex; flex-direction: column; gap: 14px; }
.fld { display: flex; flex-direction: column; gap: 6px; }
.fld .label { margin: 0; }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.sw { width: 26px; height: 26px; border-radius: 8px; border: 2px solid transparent; cursor: pointer; padding: 0; transition: transform .15s, border-color .15s; }
.sw:hover { transform: scale(1.1); }
.sw.on { border-color: hsl(var(--foreground)); outline: 2px solid hsl(var(--card)); outline-offset: -4px; }
.sw:focus-visible { outline: 2px solid hsl(var(--primary)); outline-offset: 2px; }
.opts { display: flex; flex-direction: column; gap: 2px; }
.opts.scroll { max-height: 220px; overflow: auto; background: hsl(var(--surface)); border-radius: var(--r-btn); padding: 4px; }
.opt { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 7px; cursor: pointer; }
.opt:hover { background: hsl(var(--accent)); }
.opt input { width: auto; min-height: 0; }

@media (max-width: 900px) {
  .proj-layout { grid-template-columns: minmax(0, 1fr); }
  .folders { order: -1; }
}
@media (max-width: 720px) {
  .filters input[type=search] { width: 100%; }
  .ptable { min-width: 720px; }
}

.frow { display: flex; align-items: center; gap: 2px; }
.frow .fitem { width: auto; flex: 1; min-width: 0; }
.ib:disabled { opacity: .35; cursor: default; pointer-events: none; }

.btn.small { min-height: 32px; padding: 0 14px; font-size: 13px; border-radius: 8px; }


/* ================= База знаний ================= */
.kb-layout { display: grid; grid-template-columns: minmax(260px, 340px) minmax(0, 1fr); gap: 16px; align-items: start; }
.kb-left { min-width: 0; }
.kb-filters input[type=search] { flex: 1; min-width: 0; width: auto; }
.kb-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.kb-tag { font: inherit; font-size: 13px; padding: 4px 12px; border-radius: var(--r-pill); border: 0; background: hsl(var(--card)); color: hsl(var(--muted-foreground)); cursor: pointer; transition: border-color .15s, background-color .15s; }
.kb-tag:hover { background: hsl(var(--accent)); color: hsl(var(--accent-foreground)); }
.kb-tag.on { background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); }
.kb-doc .kb-tag { background: hsl(var(--surface)); }
.kb-tag.static { cursor: default; }
.kb-list { display: flex; flex-direction: column; gap: 8px; }
.kb-item { display: block; width: 100%; text-align: left; font: inherit; color: inherit; padding: 16px 20px; border: 1px solid transparent; border-radius: var(--r-card); background: hsl(var(--card)); cursor: pointer; transition: border-color .15s, background-color .15s; }
.kb-item:hover { background: hsl(var(--accent)); }
.kb-item.active { border-color: hsl(var(--primary)); background: hsl(var(--accent)); }
.kb-item:focus-visible { outline: 2px solid hsl(var(--primary)); outline-offset: 1px; }
.kb-item .kt { font-size: 16px; font-weight: 500; overflow-wrap: anywhere; }
.kb-item .ks { font-size: 14px; color: hsl(var(--muted-foreground)); margin-top: 3px; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.kb-item .km { font-size: 12px; color: hsl(var(--muted-foreground)); margin-top: 6px; display: flex; flex-wrap: wrap; gap: 4px 10px; }
.kb-item mark, .kb-doc mark { background: hsl(var(--primary) / .22); color: inherit; border-radius: 3px; padding: 0 1px; }

.kb-doc { padding: 30px; min-height: 240px; min-width: 0; }
.kb-doc .kb-head { display: flex; flex-wrap: wrap; gap: 8px; justify-content: space-between; align-items: flex-start; margin-bottom: 6px; }
.kb-doc h2 { margin: 0; font-size: 26px; line-height: 1.15; overflow-wrap: anywhere; }
.kb-doc .kb-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.kb-meta { font-size: 13px; color: hsl(var(--muted-foreground)); display: flex; flex-wrap: wrap; gap: 4px 12px; margin-bottom: 10px; }
.kb-back { display: none; margin-bottom: 10px; }
.kb-form { display: flex; flex-direction: column; gap: 10px; }
.kb-form textarea { min-height: 340px; font-family: var(--font-mono); font-size: 13px; line-height: 1.55; resize: vertical; }
.kb-form .kb-row { display: flex; flex-wrap: wrap; gap: 8px; }
.kb-form .kb-row > * { flex: 1; min-width: 160px; }
.kb-form .hint { font-size: 13px; color: hsl(var(--muted-foreground)); }

/* показ Markdown */
.md { line-height: 1.65; overflow-wrap: anywhere; }
.md > :first-child { margin-top: 0; }
.md h1, .md h2, .md h3, .md h4, .md h5, .md h6 { margin: 1.3em 0 .5em; line-height: 1.25; }
.md h1 { font-size: 26px; font-weight: 700; } .md h2 { font-size: 22px; } .md h3 { font-size: 18px; } .md h4, .md h5, .md h6 { font-size: 14.5px; }
.md p { margin: .6em 0; }
.md ul, .md ol { margin: .6em 0; padding-left: 1.5em; }
.md li { margin: .2em 0; }
.md code { font-family: var(--font-mono); font-size: .88em; padding: 1px 6px; border-radius: 6px; background: hsl(var(--surface)); }
.md pre { margin: .8em 0; padding: 14px 16px; border-radius: 15px; background: hsl(var(--surface)); overflow: auto; }
.md pre code { padding: 0; background: transparent; font-size: 12.5px; line-height: 1.5; }
.md blockquote { margin: .8em 0; padding: 2px 16px; border-left: 3px solid hsl(var(--primary)); color: hsl(var(--muted-foreground)); }
.md hr { border: 0; border-top: 1px solid hsl(var(--border)); margin: 1.2em 0; }
.md a { color: hsl(var(--primary)); text-decoration: underline; text-underline-offset: 2px; }

@media (max-width: 900px) {
  .kb-layout { grid-template-columns: minmax(0, 1fr); }
  .kb-layout.open .kb-left { display: none; }
  .kb-layout:not(.open) .kb-doc { display: none; }
  .kb-back { display: inline-flex; }
}


/* ================= Фирменный слой (DESIGN-SYSTEM.md) ================= */
/* дескриптор над заголовком: «• проекты». Рукописный шрифт концепции подключается через --font-hand */
.descr { display: flex; width: fit-content; align-items: center; gap: 6px; margin-bottom: 8px; font-family: var(--font-hand); font-size: 15px; font-weight: 500; color: hsl(var(--primary)); }
.descr::before { content: ''; flex: none; width: 7px; height: 7px; border-radius: 50%; background: currentColor; } /* кружок перед подписью раздела: всегда круглый, не сжимается рядом с текстом */
.login-card .descr { margin-bottom: 0; }
@media (max-width: 767px) {
  :root { --r-card: 15px; }
  h1 { font-size: 26px; }
  .tab { padding: 9px 14px; }
  .modal-card { padding: 20px; }
  .kb-doc { padding: 20px; }
}
.urow .btn { min-height: 32px; padding: 0 14px; font-size: 13px; border-radius: 8px; }

/* Вход через Битрикс24 */
.login-card .btn { width: 100%; text-decoration: none; }
.b24-note { padding: 0 16px 10px; font-size: 14px; }
.b24-form { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 16px 14px; }
.b24-form > input { flex: 1; min-width: 220px; }
.ib.publish-btn.on { color: hsl(var(--primary-foreground)); background: hsl(var(--primary)); border-color: transparent; }
.ib.editor-btn:hover { color: hsl(var(--primary-foreground)); background: hsl(var(--primary)); border-color: transparent; }

/* Правки файлов из чата */
.chat-edits { margin: 6px 0 0; }
.msg.has-edits { max-width: 100%; width: 100%; }
.msg .edits { white-space: normal; margin-top: 10px; display: flex; flex-direction: column; gap: 10px; }
.edits-bar { display: flex; gap: 8px; }
.edit-card { background: hsl(var(--card)); border-radius: var(--r-card); padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; border: 1px solid hsl(var(--border)); }
.edit-card.st-pending { border-color: hsl(var(--primary) / .5); }
.edit-card.st-applied { border-color: hsl(var(--ok) / .5); }
.edit-card.st-failed, .edit-card.st-stale { border-color: hsl(var(--destructive) / .4); }
.edit-card.st-rejected, .edit-card.st-undone { opacity: .75; }
.edit-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; }
.edit-path { font-family: var(--font-mono); font-size: 13px; font-weight: 600; overflow-wrap: anywhere; }
.edit-stat { font-family: var(--font-mono); font-size: 12px; color: hsl(var(--muted-foreground)); }
.edit-status { margin-left: auto; font-size: 13px; color: hsl(var(--muted-foreground)); }
.st-applied .edit-status { color: hsl(var(--ok)); }
.st-failed .edit-status, .st-stale .edit-status { color: hsl(var(--destructive)); }
.diff { font-family: var(--font-mono); font-size: 12.5px; line-height: 1.5; border-radius: 10px; background: hsl(var(--surface)); overflow-x: auto; max-height: 320px; overflow-y: auto; }
.dr { display: flex; white-space: pre; min-width: max-content; padding: 0 10px; }
.dm { width: 16px; flex-shrink: 0; user-select: none; color: hsl(var(--muted-foreground)); }
.dr-add { background: hsl(var(--ok) / .16); }
.dr-del { background: hsl(var(--destructive) / .14); }
.dr-add .dm { color: hsl(var(--ok)); }
.dr-del .dm { color: hsl(var(--destructive)); }
.dr-gap { color: hsl(var(--muted-foreground)); font-style: italic; }
.edit-note { font-size: 13px; color: hsl(var(--muted-foreground)); white-space: normal; }
.edit-error { font-size: 13px; color: hsl(var(--destructive)); white-space: normal; }
.edit-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* Страница «Помощь» */
.help { max-width: 860px; }
.help-toc { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 20px; }
.help-toc a { padding: 6px 12px; border-radius: 999px; background: hsl(var(--card)); color: inherit; text-decoration: none; font-size: 13px; }
.help-toc a:hover, .help-toc a:focus-visible { outline: 2px solid hsl(var(--ring, var(--primary))); }
.help-sec { padding: 20px 24px; margin: 0 0 16px; scroll-margin-top: 16px; }
.help-sec h2 { margin: 0 0 12px; font-size: 18px; }
.help-sec p, .help-sec li { line-height: 1.55; }
.help-sec ol, .help-sec ul { padding-left: 22px; margin: 8px 0 12px; }
.help-note { color: hsl(var(--muted-foreground)); font-size: 14px; }
.help-table { width: 100%; border-collapse: collapse; margin: 0 0 12px; }
.help-table th, .help-table td { text-align: left; vertical-align: top; padding: 8px 10px; border-bottom: 1px solid hsl(var(--border, var(--muted))); }
.help-table td:first-child { white-space: nowrap; }
.help code { background: hsl(var(--muted)); padding: 1px 5px; border-radius: 4px; font-size: .92em; }
/* Общий раздел «База знаний»: вкладки и строка про найденное в соседней вкладке */
.help-sec.nohit, .help-toc a.nohit { display: none; }
.kb-tabs { margin-bottom: 14px; }
.kb-hit { margin: 6px 0 12px; font-size: 14px; }
.kb-hit a { color: hsl(var(--primary)); }
@media (max-width: 640px) { .help-sec { padding: 16px; } .help-table td:first-child { white-space: normal; } .help-table th, .help-table td { overflow-wrap: anywhere; } }

/* Выпадающие списки в шапке страницы: вместе, справа, переносятся на узких экранах */
.head-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-left: auto; }
.head-tools .msel-list { left: auto; right: 0; min-width: 160px; }
.head-tools .msel:first-child .msel-list { left: auto; }
.msel-list input[type=radio] { accent-color: hsl(var(--primary)); }
@media (max-width: 640px) { .head-tools { width: 100%; margin-left: 0; } .head-tools .msel { flex: 1 1 140px; } .head-tools .msel summary { width: 100%; justify-content: space-between; } }

/* Статистика: Claude по проектам */
.proj-stats-note { margin: 4px 0 12px; font-size: 13px; }
.proj-stats td.num, .proj-stats th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
#proj-stats-card .ptable { min-width: 0; }

/* База знаний: корзина */
.kb-trash { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.kb-trash-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; border-radius: var(--r-btn); background: hsl(var(--muted) / .5); }
.kb-trash-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.kb-trash-info b { overflow-wrap: anywhere; }
.kb-trash-info .muted { font-size: 13px; }
@media (max-width: 640px) { .kb-trash-row { flex-direction: column; align-items: stretch; } }

/* Единые выпадающие списки (frontend/js/select.js): тот же вид, что у фильтров проектов */
.ssel-native { display: none !important; }
.ssel .msel-list { position: fixed; z-index: 1000; right: auto; bottom: auto; box-shadow: 0 8px 24px hsl(0 0% 0% / .12); }
.ssel.fullw { display: block; width: 100%; }
.ssel.fullw summary { display: flex; justify-content: space-between; width: 100%; }
.ssel summary { max-width: 100%; }
.ssel.disabled summary { opacity: .6; cursor: default; }
.ssel .msel-list label:has(input:checked) { background: hsl(var(--accent)); color: hsl(var(--accent-foreground)); }
.ssel .msel-list input[type=radio] { accent-color: hsl(var(--primary)); }
.ssel .msel-list label { white-space: nowrap; }
/* компактные варианты в таблице проектов: статус-таблетка и автор */
.ssel-status summary.status { min-height: 0; padding: 5px 12px; font-size: 12px; font-weight: 500; letter-spacing: .02em; border: 0; border-radius: var(--r-pill); color: hsl(var(--warn)); background: hsl(var(--warn) / .14); }
.ssel-status summary.status[data-s="НОВЫЙ"] { color: hsl(var(--accent-foreground)); background: hsl(var(--accent)); }
.dark .ssel-status summary.status[data-s="НОВЫЙ"] { background: hsl(var(--primary) / .2); }
.ssel-status summary.status[data-s="БОЕВОЙ"] { color: hsl(var(--ok)); background: hsl(var(--ok) / .14); }
.ssel-status summary::after, .ssel-owner summary::after { margin-left: 6px; font-size: 11px; color: inherit; opacity: .7; }
.ssel-owner summary { min-height: 0; padding: 3px 8px; font-size: 12px; font-weight: 400; border-radius: 8px; background: transparent; color: hsl(var(--muted-foreground)); border-color: hsl(var(--border)); }

/* Кружки внутри панели списка не наследуют правила полей форм (ширина, растяжение) */
.ssel .msel-list input[type=radio] { flex: none; width: auto; min-width: 0; min-height: 0; margin: 0; }
.ssel .msel-list label { justify-content: flex-start; text-align: left; }

/* Таблицы в заметках базы знаний */
.md-table-wrap { overflow-x: auto; margin: 12px 0; }
.md-table { border-collapse: collapse; min-width: 100%; font-size: 14px; }
.md-table th, .md-table td { text-align: left; vertical-align: top; padding: 8px 12px; border-bottom: 1px solid hsl(var(--border)); }
.md-table th { font-size: 12px; letter-spacing: .04em; text-transform: uppercase; color: hsl(var(--muted-foreground)); font-weight: 600; white-space: nowrap; }
.md-table td:first-child { white-space: nowrap; font-weight: 500; }

/* Git в списке проектов и окне «Файлы» */
.badge.git.ok { text-decoration: none; }
.badge.git.pending, .badge.git.new { opacity: .8; }
.fx-git { margin-top: 6px; font-size: 12px; color: hsl(var(--muted-foreground)); display: flex; flex-direction: column; gap: 2px; }
.fx-git .warn { color: hsl(var(--warn)); }
.fx-git a { color: inherit; }

/* Архив проектов */
.arch-card { width: min(760px, calc(100vw - 32px)); max-height: calc(100vh - 48px); overflow: auto; padding: 20px 24px; }
.arch-note { margin: 4px 0 0; font-size: 13px; }
.arch-list { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.arch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; border-radius: var(--r-btn); background: hsl(var(--muted) / .5); }
.arch-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.arch-info b { overflow-wrap: anywhere; }
.arch-info .muted { font-size: 13px; }
.arch-btns { display: flex; gap: 8px; flex-shrink: 0; }
@media (max-width: 640px) { .arch-row { flex-direction: column; align-items: stretch; } .arch-btns { justify-content: flex-end; } }
.arch-card .fx-head { flex-wrap: nowrap; }
.arch-card .fx-head .btn { flex-shrink: 0; }
.arch-card .fx-head > div { min-width: 0; }

/* Шкала окна контекста в чате */
.ctx-gauge { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.ctx-gauge .label { margin: 0; white-space: nowrap; }
.ctx-bar { flex: 1; height: 6px; border-radius: 3px; background: hsl(var(--surface)); overflow: hidden; }
.ctx-bar span { display: block; height: 100%; min-width: 2px; background: hsl(var(--primary)); transition: width .2s; }
.ctx-gauge.warn .ctx-bar span { background: hsl(var(--warn)); }
.ctx-gauge.bad .ctx-bar span { background: hsl(var(--bad)); }
@media (prefers-reduced-motion: reduce) { .ctx-bar span { transition: none; } }

/* Настройки чата и вложения */
.chat-opts { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; margin-top: 12px; }
.chat-opt { display: flex; flex-direction: column; gap: 4px; }
.chat-opt .label { margin: 0; }
.chat-opt select { min-width: 150px; }
.chat-files { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; height: 28px; padding: 0 4px 0 10px; border-radius: var(--r-badge, 6px); background: hsl(var(--primary) / .12); font-size: 13px; }
.chip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }
.chip-size { color: hsl(var(--muted-foreground)); font-size: 12px; }
.chip-x { width: 22px; height: 22px; border: 0; border-radius: 6px; background: transparent; color: inherit; font-size: 16px; line-height: 1; cursor: pointer; }
.chip-x:hover, .chip-x:focus-visible { background: hsl(var(--primary) / .2); }
.chat-form.drag textarea { outline: 2px dashed hsl(var(--primary)); outline-offset: 2px; }
.cs-checks { display: flex; flex-wrap: wrap; gap: 8px 16px; }

/* Каталог навыков */
.sk-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.sk-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 14px; border-radius: var(--r-card); background: hsl(var(--card)); border: 1px solid hsl(var(--border)); }
.sk-info { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.sk-name { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-weight: 600; overflow-wrap: anywhere; }
.sk-name .badge { font-weight: 400; }
.sk-desc { margin: 0; font-size: 14px; color: hsl(var(--muted-foreground)); overflow-wrap: anywhere; }
.sk-meta { font-size: 12px; color: hsl(var(--muted-foreground)); }
.sk-btns { display: flex; gap: 8px; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; }
.sk-descr { margin: 10px 0 0; overflow-wrap: anywhere; }
.sk-actions { justify-content: flex-start; flex-wrap: wrap; margin-top: 12px; }
.sk-warn { margin-top: 12px; padding: 10px 12px; border-radius: var(--r-btn); background: hsl(var(--warn) / .12); font-size: 13px; }
.sk-h { margin: 18px 0 8px; font-size: 14px; }
.sk-files { display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.sk-file { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; }
.sk-file span:first-child { font-family: var(--mono, monospace); overflow-wrap: anywhere; }
.sk-md { margin: 0; padding: 12px; max-height: 260px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; border-radius: var(--r-btn); background: hsl(var(--muted) / .5); font-size: 13px; }
.sk-limits { font-size: 12px; margin: 0; }
.sk-projects { max-height: 280px; overflow: auto; }
.sk-result { padding: 10px 12px; border-radius: var(--r-btn); background: hsl(var(--ok) / .12); font-size: 13px; overflow-wrap: anywhere; }
.sk-result.err { background: hsl(var(--destructive) / .1); color: hsl(var(--destructive)); }
@media (max-width: 640px) { .sk-row { flex-direction: column; align-items: stretch; } .sk-btns { justify-content: flex-end; } }
.sk-source { margin-top: 10px; font-size: 13px; color: hsl(var(--muted-foreground)); overflow-wrap: anywhere; }
.sk-source a { color: inherit; text-decoration: underline; }
.sk-install { white-space: pre-wrap; max-height: 200px; }
.sk-install:empty { display: none; }
.sk-how { margin: 8px 0 0; font-size: 13px; }
.sk-gh-form { display: flex; gap: 8px; margin-top: 14px; }
.sk-gh-form input { flex: 1; min-width: 0; }
.sk-gh-head { margin: 14px 0 6px; font-size: 14px; overflow-wrap: anywhere; }
.sk-gh-all { margin: 4px 0 8px; }
.sk-cand { cursor: pointer; justify-content: flex-start; align-items: flex-start; }
.sk-cand input { width: auto; min-height: 0; margin-top: 4px; flex-shrink: 0; }
#sk-gh-found .arch-list { max-height: 320px; overflow: auto; }
#sk-gh-found > input[type=text] { margin-top: 10px; width: 100%; }
#sk-gh-found .row { margin-top: 10px; }
#sk-gh-result { margin-top: 12px; display: flex; flex-direction: column; gap: 4px; }
#sk-info-form textarea { resize: vertical; }
@media (max-width: 640px) { .sk-gh-form { flex-direction: column; } }
.sk-cats { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.sk-chip { min-height: 30px; padding: 0 12px; border: 1px solid hsl(var(--border)); border-radius: var(--r-btn); background: hsl(var(--card)); color: inherit; font: inherit; font-size: 13px; cursor: pointer; }
.sk-chip:hover { border-color: hsl(var(--primary) / .45); }
.sk-chip[aria-pressed="true"] { background: hsl(var(--primary) / .1); border-color: hsl(var(--primary) / .45); }
.sk-chip .n { margin-left: 6px; color: hsl(var(--muted-foreground)); font-variant-numeric: tabular-nums; }
.sk-trash-btns { display: flex; gap: 8px; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; }
.sk-gh-catlabel { margin: 10px 0 4px; display: block; }
#sk-cats-list .arch-row input { flex: 1; min-width: 0; }
#sk-cats-list .arch-info { flex: 1; }
#sk-cats-form { margin-top: 14px; }
.arch-card .fx-head .sk-trash-btns .btn { flex-shrink: 0; }
/* Строка настроек чата: все элементы одной высоты (как поля ввода, 40 px) */
.chat-opts .btn, .chat-opts .btn.small, .chat-opts .msel summary { height: var(--ctrl-h); min-height: var(--ctrl-h); box-sizing: border-box; padding-top: 0; padding-bottom: 0; font-size: 14px; border-radius: var(--r-btn); }
.chat-opts .btn, .chat-opts .btn.small { padding-left: 16px; padding-right: 16px; display: inline-flex; align-items: center; justify-content: center; }
.chat-opts { position: relative; }
.chat-pop { position: absolute; left: 0; bottom: calc(100% + 6px); z-index: 30; width: min(520px, 100%); max-height: 340px; overflow: auto; padding: 10px; border-radius: var(--r-card); background: hsl(var(--card)); border: 1px solid hsl(var(--border)); display: flex; flex-direction: column; gap: 6px; }
.chat-pop h3 { margin: 8px 0 2px; font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: hsl(var(--muted-foreground)); }
.chat-pop input[type=search] { width: 100%; }
.chat-pop .pop-note { margin: 0; font-size: 12px; color: hsl(var(--muted-foreground)); overflow-wrap: anywhere; }
.pop-item { display: flex; align-items: flex-start; gap: 8px; width: 100%; padding: 6px 8px; border: 0; border-radius: 8px; background: transparent; color: inherit; font: inherit; font-size: 14px; text-align: left; cursor: pointer; }
.pop-item:hover, .pop-item:focus-visible { background: hsl(var(--primary) / .1); outline: none; }
.pop-item .pn { font-weight: 600; overflow-wrap: anywhere; }
.pop-item .pd { display: block; font-size: 12px; font-weight: 400; color: hsl(var(--muted-foreground)); overflow-wrap: anywhere; }
.pop-item input { width: auto; min-height: 0; margin-top: 3px; flex-shrink: 0; }
.chat-opts .btn.on { border-color: hsl(var(--primary) / .45); background: hsl(var(--primary) / .1); }
.pop-item.off { opacity: .5; cursor: not-allowed; }
.pop-item.off:hover { background: transparent; }
.msg.local { border: 1px dashed hsl(var(--border)); background: transparent; color: hsl(var(--muted-foreground)); }
.sk-reco { margin: 8px 0 0; }
.sk-reco .btn { margin: 0 4px; }
.sk-gh-portal { display: flex; margin-top: 10px; align-items: flex-start; }

/* другие нейросети в чате */
.msg-engine { margin-top: 6px; font-size: 12px; font-style: normal; }
.chat-engine-note { margin: 4px 0; font-size: 13px; }
.cs-engine { border: 1px solid hsl(var(--border)); border-radius: 10px; padding: 8px 12px 12px; margin: 8px 0; display: grid; gap: 6px; }
.cs-engine legend { font-weight: 600; padding: 0 6px; }
.cs-engine textarea, .cs-engine input[type=text], .cs-engine input[type=number] { width: 100%; box-sizing: border-box; font: inherit; }
.cs-engine .ce-key, .cs-engine p { margin: 0; font-size: 13px; }
.eng-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.eng-head h2 { margin: 0; }
.eng-state { font-size: 12px; padding: 2px 10px; border-radius: 999px; background: hsl(var(--surface)); }
.eng-state.ok { background: hsl(var(--primary) / .15); }
.eng-state.warn { background: hsl(40 90% 50% / .2); }
#view-engines .card { margin-bottom: 14px; }
#view-engines .cs-engine { border-radius: 14px; }
.ce-warn { margin: 0; font-size: 13px; padding: 8px 12px; border-radius: 10px; background: hsl(40 90% 50% / .15); }
.ce-login { padding: 10px 12px; border-radius: 10px; background: hsl(var(--surface)); display: grid; gap: 6px; }
.ce-login p { margin: 0; }
.ce-code { font-size: 22px; letter-spacing: .12em; font-family: ui-monospace, monospace; }
.ce-roles { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }
.tok-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.tok-sub { margin-top: 18px; }
.tok-total td { font-weight: 600; }
.tok-help { margin-top: 14px; font-size: 13px; }
.tok-help summary { cursor: pointer; color: var(--muted, inherit); }
.tok-help p { margin: 8px 0 0; line-height: 1.5; }

/* Время по проектам: строки проектов выделены, чаты внутри проекта приглушены и сдвинуты */
#time-projects tr.time-proj td { font-weight: 600; }
#time-projects tr.time-chat td { color: var(--muted, #6b7280); }

/* Экран «Статистика»: на всю ширину, таблицы без горизонтальной прокрутки на обычных экранах (на узких подписи столбцов переносятся, а прокрутка остаётся запасной) */
#view-stats { max-width: none; }
#view-stats .ptable { min-width: 0; }
#view-stats .ptable th, #view-stats .ptable td { padding: 12px 8px; }
#view-stats .ptable th { white-space: normal; line-height: 1.25; }
#view-stats .ptable td { overflow-wrap: anywhere; }
#view-stats .proj-stats td.num { overflow-wrap: normal; }
#time-projects tr.time-chat td:first-child { white-space: pre-wrap; }
#view-stats .bars.dense { gap: 1px; }
#view-stats .bars.dense .bar span { font-size: 9px; overflow: visible; }

/* Окно «Нагрузка сервера» (по нажатию на панель CPU / CLAUDE / MEM) */
.srv-card { max-width: 560px; padding: 0; gap: 0; }
.srv-head { display: flex; align-items: center; justify-content: space-between; padding: 20px 28px; border-bottom: 1px solid hsl(var(--border)); }
.srv-head h2 { margin: 0; font-family: var(--font-mono); font-size: 14px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.srv-x { display: inline-grid; place-items: center; width: 34px; height: 34px; padding: 0; border: 1px solid hsl(var(--border)); border-radius: 10px; background: transparent; color: inherit; cursor: pointer; }
.srv-x:hover { background: hsl(var(--surface)); }
.srv-x svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.srv-rows { display: flex; flex-direction: column; gap: 14px; padding: 22px 28px 8px; }
.srv-row { display: grid; grid-template-columns: 92px 1fr auto; align-items: center; gap: 16px; font-size: 14px; }
.ai-rows .srv-row { grid-template-columns: 140px 1fr auto; }
.srv-bar { height: 8px; border-radius: 4px; background: hsl(var(--surface)); overflow: hidden; }
.srv-bar i { display: block; height: 100%; min-width: 3px; border-radius: 4px; background: hsl(var(--ok)); transition: width .3s; }
.srv-bar i.warn { background: hsl(var(--warn)); }
.srv-bar i.bad { background: hsl(var(--bad)); }
.srv-val { min-width: 120px; text-align: right; color: hsl(var(--muted-foreground)); font-variant-numeric: tabular-nums; white-space: nowrap; }
.srv-foot { margin: 0; padding: 8px 28px 22px; font-size: 13px; color: hsl(var(--muted-foreground)); }
@media (max-width: 480px) { .srv-row, .ai-rows .srv-row { grid-template-columns: 78px 1fr; } .srv-val { grid-column: 1 / -1; text-align: left; margin-top: -6px; } .srv-head, .srv-rows, .srv-foot { padding-left: 18px; padding-right: 18px; } }

/* ---- Логотип: LYSENKO LAB + рукописная подпись «vibe portal» (как на academy.lysenkolab.ru) ---- */
.lp-brand { line-height: 1; }
.lp-brand .name { display: block; font-family: var(--font-sans); font-size: 26px; font-weight: 500; line-height: 1.05; letter-spacing: -.5px; text-transform: uppercase; }
.lp-brand .sub { display: block; margin-top: 6px; font-family: var(--font-brand); font-size: 18px; font-weight: 400; line-height: 1; text-transform: none; }
.login-card .lp-brand { padding-bottom: 10px; color: hsl(var(--foreground)); }
.login-card .lp-brand .sub { color: hsl(var(--accent-foreground)); }
/* в боковом меню: белый текст на фиолетовом, размер поменьше, чтобы влезло рядом с кнопкой сворачивания */
.side .brand.lp-brand { display: block; padding: 4px 8px; font-weight: 400; }
.side .lp-brand .name { font-size: 20px; letter-spacing: -.3px; }
.side .lp-brand .sub { margin-top: 4px; font-size: 16px; color: hsl(0 0% 100% / .88); }
@media (min-width: 721px) {
  /* свёрнутое меню: остаётся одна буква L */
  html.rail .side .brand.lp-brand { padding: 4px 0; text-align: center; }
  html.rail .side .lp-brand .sub { display: none; }
  html.rail .side .lp-brand .name { font-size: 0; }
  html.rail .side .lp-brand .name::first-letter { font-size: 26px; }
}

/* Сервер: вкладки «Доступность / Копии / Диск» */
#view-server .tabs { margin-bottom: 14px; }
.pane-tools { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 0 0 14px; }
.pane-tools .msel-list { left: 0; right: auto; min-width: 160px; }
#view-server .proj-stats td { vertical-align: top; overflow-wrap: anywhere; }
#view-server .proj-stats td.num { overflow-wrap: normal; }
#view-server tr.child td:first-child { padding-left: 36px; }
#view-server tr.child { background: hsl(var(--accent) / .35); }
.dtoggle { width: 24px; height: 24px; padding: 0; font: inherit; line-height: 1; color: hsl(var(--primary)); background: transparent; border: 0; border-radius: 6px; cursor: pointer; }
.dtoggle:hover { background: hsl(var(--accent)); }
.dtoggle:focus-visible { outline: 2px solid hsl(var(--primary)); outline-offset: 1px; }
.tag-clean { display: inline-block; margin-left: 4px; padding: 1px 8px; font-style: normal; font-size: 12px; color: hsl(var(--ok)); background: hsl(var(--ok) / .12); border-radius: var(--r-pill); white-space: nowrap; }
.bk-pre { margin: 12px 0 0; padding: 12px; max-height: 320px; overflow: auto; font-size: 12px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; background: hsl(var(--accent) / .35); border-radius: var(--r-btn); }
#bk-log summary { cursor: pointer; font-weight: 500; }
.diskchart { position: relative; height: 200px; margin: 8px 0 26px 64px; }
.diskchart svg { display: block; width: 100%; height: 100%; overflow: visible; border-left: 1px solid hsl(var(--border)); border-bottom: 1px solid hsl(var(--border)); }
.dc-line { fill: none; stroke: hsl(var(--primary)); stroke-width: 2; stroke-linejoin: round; }
.dc-area { fill: hsl(var(--primary) / .12); stroke: none; }
.diskchart span { position: absolute; font-size: 12px; color: hsl(var(--muted-foreground)); white-space: nowrap; }
.dc-max { left: -64px; top: -2px; } .dc-min { left: -64px; bottom: -2px; }
.dc-from { left: 0; bottom: -22px; } .dc-to { right: 0; bottom: -22px; }
@media (max-width: 640px) { .diskchart { margin-left: 54px; } .dc-max, .dc-min { left: -54px; } .dc-from { max-width: 48%; overflow: hidden; } .dc-to { max-width: 48%; overflow: hidden; } }
#disk-dirs td:first-child { white-space: nowrap; }

/* Доступы (суперадмин) */
.ac-notes { padding: 14px 20px; margin: 0 0 14px; }
.ac-engines { margin: 28px 0 14px; }
.ac-sec { margin: 0 0 6px; font-size: 20px; }
.ac-notes p { margin: 4px 0; font-size: 14px; line-height: 1.5; }
.ac-group { padding: 0; margin: 0 0 16px; overflow: hidden; }
.ac-head { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; padding: 16px 20px 4px; }
.ac-head h2 { margin: 0; font-size: 17px; }
.ac-file { margin-left: auto; font-size: 12px; }
.ac-gnote { margin: 2px 20px 10px; font-size: 14px; }
.ac-st.ok { background: hsl(142 60% 90%); color: hsl(142 70% 20%); }
.ac-st.warn { background: hsl(38 90% 88%); color: hsl(30 80% 22%); }
.ac-st.off { background: hsl(var(--muted)); color: hsl(var(--muted-foreground)); }
.dark .ac-st.ok { background: hsl(142 40% 20%); color: hsl(142 60% 80%); }
.dark .ac-st.warn { background: hsl(38 50% 20%); color: hsl(38 80% 80%); }
.ac-row { display: grid; grid-template-columns: minmax(220px, 1fr) minmax(0, 1.2fr) auto; align-items: center; gap: 12px 16px; padding: 12px 20px; border-top: 1px solid hsl(var(--border)); }
.ac-name { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ac-name code { font-weight: 600; font-size: 13px; word-break: break-all; }
.ac-name .muted { font-size: 13px; }
.ac-val { min-width: 0; font-size: 14px; overflow-wrap: anywhere; }
.ac-mask, .ac-plain { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
.ac-sub { font-size: 12px; margin-top: 2px; }
.ac-problem { color: hsl(0 70% 42%); font-size: 13px; margin-top: 2px; }
.dark .ac-problem { color: hsl(0 80% 72%); }
.ac-pending { color: hsl(30 80% 35%); font-size: 12px; margin-top: 2px; }
.dark .ac-pending { color: hsl(38 80% 72%); }
.ac-act { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.ac-act .btn { min-height: 32px; padding: 0 14px; font-size: 13px; border-radius: 8px; }
@media (max-width: 720px) { .ac-row { grid-template-columns: 1fr; padding: 12px 16px; } .ac-act { justify-content: flex-start; } .ac-head { padding: 14px 16px 4px; } .ac-file { margin-left: 0; } .ac-gnote { margin: 2px 16px 10px; } }

/* Права (матрица групп) */
.pm-group { padding: 0; margin: 0 0 16px; overflow: hidden; }
.pm-head { padding-bottom: 12px; }
.pm-name { font: inherit; font-weight: 600; font-size: 17px; min-width: 200px; max-width: 320px; }
.pm-row { display: grid; grid-template-columns: 200px 1fr; gap: 8px 16px; align-items: center; padding: 10px 20px; border-top: 1px solid hsl(var(--border)); }
.pm-sec { font-weight: 500; }
.pm-acts { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.pm-act { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; cursor: pointer; }
.pm-act.off { color: hsl(var(--muted-foreground)); opacity: .55; cursor: not-allowed; }
.pm-act input { accent-color: hsl(var(--primary)); width: 16px; height: 16px; }
.pm-foot { display: flex; flex-wrap: wrap; gap: 8px; padding: 14px 20px; border-top: 1px solid hsl(var(--border)); }
@media (max-width: 720px) { .pm-row { grid-template-columns: 1fr; padding: 10px 16px; } .pm-foot { padding: 12px 16px; } .pm-name { min-width: 0; width: 100%; max-width: none; } }

.ac-st.bad { background: hsl(0 80% 92%); color: hsl(0 70% 32%); }
.dark .ac-st.bad { background: hsl(0 45% 22%); color: hsl(0 80% 82%); }
.ac-test { margin-left: 4px; min-height: 30px; padding: 0 12px; font-size: 13px; border-radius: 8px; }
.ac-conn { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 10px; padding: 4px 20px 12px; }
.ac-conn-text { font-size: 13px; overflow-wrap: anywhere; flex: 1 1 280px; }
@media (max-width: 720px) { .ac-conn { padding: 4px 16px 12px; } }
