/* 1C Meta Hub — интерфейс. Токены цветов: светлая и тёмная темы. */
:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #eef2f6;
  --text: #0f172a;
  --text-2: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --accent: #15803d;
  --accent-hover: #166534;
  --accent-soft: #dcfce7;
  --accent-text: #14532d;
  --on-accent: #ffffff;
  --info: #1d4ed8;
  --info-soft: #dbeafe;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --violet: #6d28d9;
  --violet-soft: #ede9fe;
  --sidebar: #0f172a;
  --sidebar-text: #cbd5e1;
  --sidebar-muted: #64748b;
  --sidebar-active: #1e293b;
  --code-bg: #fbfcfd;
  --code-line: #94a3b8;
  --hl-kw: #b91c1c;
  --hl-str: #15803d;
  --hl-com: #64748b;
  --hl-num: #1d4ed8;
  --hl-pre: #7c3aed;
  --hl-ann: #b45309;
  --add-bg: #e9f9ee;
  --add-strong: #c7f0d4;
  --del-bg: #fdecec;
  --del-strong: #f8cfcf;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .08);
  --shadow-lg: 0 10px 30px rgba(15, 23, 42, .18);
  --radius: 10px;
  --radius-sm: 6px;
  --font: "Fira Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "Fira Code", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0b1120;
  --surface: #111827;
  --surface-2: #0f172a;
  --surface-3: #1e293b;
  --text: #f1f5f9;
  --text-2: #cbd5e1;
  --muted: #94a3b8;
  --line: #1f2a3c;
  --line-strong: #334155;
  --accent: #22c55e;
  --accent-hover: #4ade80;
  --accent-soft: #14361f;
  --accent-text: #86efac;
  --on-accent: #052e16;
  --info: #60a5fa;
  --info-soft: #172554;
  --warn: #fbbf24;
  --warn-soft: #3b2a06;
  --danger: #f87171;
  --danger-soft: #3b1111;
  --violet: #a78bfa;
  --violet-soft: #2e1f5e;
  --sidebar: #070b15;
  --sidebar-text: #cbd5e1;
  --sidebar-muted: #64748b;
  --sidebar-active: #172033;
  --code-bg: #0d1424;
  --code-line: #475569;
  --hl-kw: #f472b6;
  --hl-str: #86efac;
  --hl-com: #64748b;
  --hl-num: #93c5fd;
  --hl-pre: #c4b5fd;
  --hl-ann: #fcd34d;
  --add-bg: #0f2a1a;
  --add-strong: #164a2b;
  --del-bg: #2e1216;
  --del-strong: #4f1a21;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, .55);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased;
}
a { color: var(--info); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
code, pre, .mono { font-family: var(--mono); font-size: 13px; }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
svg.i.sm { width: 15px; height: 15px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.grow { flex: 1; min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---------------------------------------------------------------- layout */
.layout { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--sidebar); color: var(--sidebar-text); display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; padding: 16px 12px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.brand-logo {
  width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center;
  background: linear-gradient(135deg, #22c55e, #15803d); color: #fff; font: 700 13px var(--mono);
}
.brand-name { font-weight: 650; color: #fff; font-size: 15px; line-height: 1.2; }
.brand-sub { font-size: 12px; color: var(--sidebar-muted); }
.nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.nav-section { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--sidebar-muted); padding: 14px 10px 6px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px;
  color: var(--sidebar-text); text-decoration: none; font-size: 14px; transition: background .15s, color .15s;
}
.nav a:hover { background: var(--sidebar-active); color: #fff; }
.nav a.active { background: var(--sidebar-active); color: #fff; box-shadow: inset 3px 0 0 #22c55e; }
.nav a .badge { margin-left: auto; }
.sidebar-foot { margin-top: auto; border-top: 1px solid #1e293b; padding-top: 12px; display: grid; gap: 8px; }
.me { display: flex; align-items: center; gap: 10px; padding: 4px 6px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; background: #1e293b; color: #e2e8f0;
  display: grid; place-items: center; font-weight: 600; font-size: 13px; flex: none;
}
.me-name { color: #fff; font-size: 14px; }
.me-role { font-size: 12px; color: var(--sidebar-muted); }
.foot-actions { display: flex; gap: 6px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 8px;
  background: transparent; border: 1px solid transparent; color: inherit; cursor: pointer; transition: background .15s;
}
.sidebar .icon-btn { color: var(--sidebar-text); border-color: #1e293b; }
.sidebar .icon-btn:hover { background: var(--sidebar-active); color: #fff; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 16px 28px; border-bottom: 1px solid var(--line);
  background: var(--surface); position: sticky; top: 0; z-index: 5;
}
.topbar h1 { font-size: 19px; font-weight: 650; margin: 0; }
.topbar .sub { color: var(--muted); font-size: 13px; }
.topbar .actions { margin-left: auto; display: flex; gap: 8px; align-items: center; min-width: 0; }
.menu-btn { display: none; }
.content { padding: 24px 28px 48px; display: grid; gap: 20px; align-content: start; }
.content.full { padding: 0; height: calc(100vh - 69px); }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 264px; z-index: 50; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; box-shadow: var(--shadow-lg); }
  .menu-btn { display: inline-grid; }
  .topbar { padding: 12px 16px; flex-wrap: wrap; }
  .topbar .actions { min-width: 0; max-width: 100%; flex-wrap: wrap; }
  .topbar .actions .select { max-width: 100% !important; min-width: 0; }
  .content { padding: 16px; }
  .content.full { height: auto; }
}

/* ---------------------------------------------------------------- базовые элементы */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-h { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.card-h h2 { font-size: 15px; margin: 0; font-weight: 600; }
.card-h .actions { margin-left: auto; display: flex; gap: 8px; }
.card-b { padding: 16px 18px; }
.card-b.flush { padding: 0; }

.btn {
  display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); cursor: pointer;
  font-size: 14px; font-weight: 500; white-space: nowrap; transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { background: var(--surface-3); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-3); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn:disabled { opacity: .55; cursor: default; }
.btn .spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.input, .select, .textarea {
  height: 36px; padding: 0 11px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); min-width: 0; transition: border-color .15s, box-shadow .15s;
}
.textarea { height: auto; padding: 8px 11px; resize: vertical; font-family: var(--mono); font-size: 13px; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field { display: grid; gap: 5px; align-content: start; }
.field > span { font-size: 13px; font-weight: 500; color: var(--text-2); }
.field small { color: var(--muted); font-size: 12px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 14px; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }
.search-box { position: relative; display: flex; align-items: center; }
.search-box svg { position: absolute; left: 10px; color: var(--muted); pointer-events: none; }
.search-box .input { padding-left: 34px; width: 100%; }

.badge {
  display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 11px;
  font-size: 12px; font-weight: 500; background: var(--surface-3); color: var(--text-2); white-space: nowrap;
}
.badge.green { background: var(--accent-soft); color: var(--accent-text); }
.badge.blue { background: var(--info-soft); color: var(--info); }
.badge.amber { background: var(--warn-soft); color: var(--warn); }
.badge.red { background: var(--danger-soft); color: var(--danger); }
.badge.violet { background: var(--violet-soft); color: var(--violet); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: currentColor; }

.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em;
  padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap;
}
.table td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: var(--surface-2); }
.table .actions { display: flex; gap: 4px; justify-content: flex-end; }

.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty svg.i { width: 36px; height: 36px; color: var(--line-strong); margin-bottom: 8px; }
.empty h3 { margin: 4px 0; color: var(--text); font-size: 16px; font-weight: 600; }

/* ---------------------------------------------------------------- обзор */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; }
.stat { padding: 16px 18px; display: flex; gap: 14px; align-items: center; }
.stat-ic { width: 42px; height: 42px; border-radius: 10px; display: grid; place-items: center; flex: none; }
.stat-ic.green { background: var(--accent-soft); color: var(--accent); }
.stat-ic.blue { background: var(--info-soft); color: var(--info); }
.stat-ic.violet { background: var(--violet-soft); color: var(--violet); }
.stat-ic.amber { background: var(--warn-soft); color: var(--warn); }
.stat-v { font-size: 24px; font-weight: 650; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-l { font-size: 13px; color: var(--muted); }
.cols-2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; align-items: start; }
@media (max-width: 1100px) { .cols-2 { grid-template-columns: 1fr; } }

.client-block { padding: 14px 18px; border-bottom: 1px solid var(--line); }
.client-block:last-child { border-bottom: 0; }
.client-title { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.ib-row {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; margin-top: 8px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--surface-2); cursor: pointer; transition: border-color .15s, background .15s;
}
.ib-row:hover { border-color: var(--accent); }
.ib-code { font-family: var(--mono); font-size: 13px; color: var(--text-2); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: flex; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--line); }
.timeline li:last-child { border-bottom: 0; }
.tl-ic { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; flex: none; }
.tl-ic.ready { background: var(--accent-soft); color: var(--accent); }
.tl-ic.failed { background: var(--danger-soft); color: var(--danger); }
.tl-ic.processing, .tl-ic.received { background: var(--warn-soft); color: var(--warn); }
.tl-msg { font-size: 13px; color: var(--text-2); word-break: break-word; }

/* ---------------------------------------------------------------- загрузка */
.dropzone {
  border: 2px dashed var(--line-strong); border-radius: var(--radius); padding: 28px; text-align: center;
  background: var(--surface-2); cursor: pointer; transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone svg.i { width: 34px; height: 34px; color: var(--accent); }
.dropzone .dz-title { font-weight: 600; margin-top: 6px; }
.dropzone .dz-file { margin-top: 8px; font-family: var(--mono); font-size: 13px; }
.progress { height: 8px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); width: 0; transition: width .2s; }
.seg { display: inline-flex; justify-self: start; width: fit-content; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 0 14px; height: 34px; cursor: pointer; font-size: 14px; }
.seg button + button { border-left: 1px solid var(--line-strong); }
.seg button.on { background: var(--accent); color: var(--on-accent); }

/* ---------------------------------------------------------------- обозреватель */
.browser { display: grid; grid-template-columns: 300px 1fr; height: 100%; min-height: 0; }
.browser-side { border-right: 1px solid var(--line); background: var(--surface); display: flex; flex-direction: column; min-height: 0; }
.browser-side .top { padding: 12px; border-bottom: 1px solid var(--line); display: grid; gap: 8px; }
.tree { overflow-y: auto; flex: 1; padding: 6px 0 20px; }
.tree-type {
  display: flex; align-items: center; gap: 6px; width: 100%; padding: 6px 12px; border: 0; background: none;
  cursor: pointer; text-align: left; font-size: 14px; color: var(--text); font-weight: 500;
}
.tree-type:hover { background: var(--surface-3); }
.tree-type .chev { transition: transform .15s; color: var(--muted); }
.tree-type.open .chev { transform: rotate(90deg); }
.tree-type .count { margin-left: auto; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.tree-items { padding: 2px 0 6px; }
.tree-item {
  display: block; width: 100%; padding: 5px 12px 5px 34px; border: 0; background: none; cursor: pointer; text-align: left;
  font-size: 13.5px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tree-item:hover { background: var(--surface-3); color: var(--text); }
.tree-item.active { background: var(--accent-soft); color: var(--accent-text); font-weight: 500; }
.tree-item .ext { color: var(--violet); font-size: 11px; margin-left: 4px; }
.browser-main { min-width: 0; overflow-y: auto; background: var(--bg); }
.browser-main .pad { padding: 20px 24px 40px; display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
@media (max-width: 900px) {
  .browser { grid-template-columns: 1fr; }
  .browser-side { max-height: 45vh; border-right: 0; border-bottom: 1px solid var(--line); }
}

.obj-head { display: flex; gap: 14px; align-items: flex-start; }
.obj-type { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--accent); }
.obj-title { font-size: 22px; font-weight: 650; margin: 2px 0; word-break: break-word; }
.obj-syn { color: var(--muted); }
.hints { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.hint {
  display: inline-flex; align-items: center; gap: 6px; font-family: var(--mono); font-size: 12.5px; padding: 4px 8px;
  border-radius: 6px; background: var(--surface-3); border: 1px solid var(--line); cursor: pointer;
}
.hint:hover { border-color: var(--accent); }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab {
  padding: 10px 14px; border: 0; background: none; cursor: pointer; color: var(--muted); font-weight: 500;
  border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; font-size: 14px;
}
.tab:hover { color: var(--text); }
.tab.on { color: var(--text); border-bottom-color: var(--accent); }
.tab .badge { margin-left: 6px; height: 19px; font-size: 11px; }

.fields .f-row { display: grid; grid-template-columns: minmax(180px, 1fr) minmax(180px, 1.3fr) minmax(0, 1fr); gap: 12px; padding: 8px 18px; border-bottom: 1px solid var(--line); font-size: 14px; }
.fields .f-row:last-child { border-bottom: 0; }
.fields .f-row.head { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; background: var(--surface-2); }
.fields .f-name { font-weight: 500; word-break: break-word; }
.fields .f-type { font-family: var(--mono); font-size: 12.5px; color: var(--info); word-break: break-word; }
.fields .f-syn { color: var(--muted); word-break: break-word; }
.fields .f-row.sub .f-name { padding-left: 18px; position: relative; }
.fields .f-row.sub .f-name::before { content: ""; position: absolute; left: 4px; top: 50%; width: 8px; border-top: 1px solid var(--line-strong); }
.fields .group-h { padding: 10px 18px; background: var(--surface-2); border-bottom: 1px solid var(--line); font-weight: 600; font-size: 14px; display: flex; gap: 8px; align-items: center; }
@media (max-width: 700px) { .fields .f-row { grid-template-columns: 1fr; gap: 2px; } .fields .f-row.head { display: none; } }

.kv { display: grid; grid-template-columns: minmax(160px, 240px) 1fr; }
.kv > div { padding: 8px 18px; border-bottom: 1px solid var(--line); font-size: 14px; word-break: break-word; }
.kv > div:nth-child(odd) { color: var(--muted); }

.mod-list { display: grid; gap: 8px; }
.mod-item {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); cursor: pointer; transition: border-color .15s;
}
.mod-item:hover { border-color: var(--accent); }

/* код */
.code-wrap { display: grid; grid-template-columns: 1fr 280px; gap: 0; min-height: 0; }
@media (max-width: 1200px) { .code-wrap { grid-template-columns: 1fr; } .outline { max-height: 300px; } }
.code-toolbar { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--surface-2); flex-wrap: wrap; }
.code {
  margin: 0; background: var(--code-bg); overflow: auto; font: 13px/1.6 var(--mono); max-height: calc(100vh - 260px);
  counter-reset: none; tab-size: 4;
}
.code .ln { display: flex; }
.code .ln > i {
  font-style: normal; flex: none; width: 58px; padding-right: 14px; text-align: right; color: var(--code-line);
  user-select: none; position: sticky; left: 0; background: var(--code-bg);
}
.code .ln > span { white-space: pre; padding-right: 20px; }
.code .ln.hl { background: var(--warn-soft); }
.code .ln.hl > i { background: var(--warn-soft); color: var(--warn); }
.tk-kw { color: var(--hl-kw); font-weight: 500; }
.tk-str { color: var(--hl-str); }
.tk-com { color: var(--hl-com); font-style: italic; }
.tk-num { color: var(--hl-num); }
.tk-pre { color: var(--hl-pre); }
.tk-ann { color: var(--hl-ann); }
.outline { border-left: 1px solid var(--line); background: var(--surface); display: flex; flex-direction: column; min-height: 0; max-height: calc(100vh - 260px); }
.outline .top { padding: 10px; border-bottom: 1px solid var(--line); }
.outline ul { list-style: none; margin: 0; padding: 4px 0; overflow-y: auto; }
.outline li button {
  display: flex; gap: 6px; align-items: center; width: 100%; border: 0; background: none; text-align: left; cursor: pointer;
  padding: 5px 12px; font-size: 13px; color: var(--text-2);
}
.outline li button:hover { background: var(--surface-3); color: var(--text); }
.outline .region { padding: 8px 12px 2px; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.m-ic { width: 16px; height: 16px; border-radius: 4px; font: 700 10px/16px var(--mono); text-align: center; flex: none; }
.m-ic.f { background: var(--info-soft); color: var(--info); }
.m-ic.p { background: var(--violet-soft); color: var(--violet); }
.exp { color: var(--accent); font-size: 11px; font-weight: 600; margin-left: auto; }

/* результаты поиска */
.results { display: grid; }
.result { display: flex; gap: 12px; padding: 10px 18px; border-bottom: 1px solid var(--line); cursor: pointer; }
.result:hover { background: var(--surface-2); }
.result:last-child { border-bottom: 0; }
.result .r-title { font-weight: 500; word-break: break-word; }
.result .r-sub { font-size: 13px; color: var(--muted); word-break: break-word; }
.result .r-code { font-family: var(--mono); font-size: 12.5px; color: var(--text-2); white-space: pre-wrap; word-break: break-word; }

/* markdown (вывод инструментов) */
.md { font-size: 14px; line-height: 1.6; word-break: break-word; }
.md h1 { font-size: 19px; margin: 0 0 10px; }
.md h2 { font-size: 16px; margin: 18px 0 8px; padding-top: 10px; border-top: 1px solid var(--line); }
.md h3 { font-size: 14px; margin: 14px 0 6px; }
.md ul { margin: 4px 0; padding-left: 20px; }
.md li { margin: 2px 0; }
.md p { margin: 6px 0; }
.md code { background: var(--surface-3); padding: 1px 5px; border-radius: 4px; font-size: 12.5px; }
.md pre { background: var(--code-bg); border: 1px solid var(--line); border-radius: 8px; padding: 12px; overflow-x: auto; }
.md pre code { background: none; padding: 0; }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }

pre.block {
  margin: 0; padding: 12px 14px; background: var(--code-bg); border: 1px solid var(--line); border-radius: 8px;
  overflow-x: auto; white-space: pre-wrap; word-break: break-all; position: relative;
}
.copy-row { display: flex; gap: 8px; align-items: flex-start; }
.copy-row pre.block { flex: 1; }

/* ---------------------------------------------------------------- модалки и уведомления */
.modal-back {
  position: fixed; inset: 0; background: rgba(2, 6, 23, .55); display: grid; place-items: center; z-index: 100;
  padding: 16px; animation: fade .15s;
}
.modal { background: var(--surface); border-radius: 12px; box-shadow: var(--shadow-lg); width: min(560px, 100%); max-height: 90vh; overflow-y: auto; animation: pop .18s; }
.modal-h { display: flex; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-h h3 { margin: 0; font-size: 16px; font-weight: 600; }
.modal-h .icon-btn { margin-left: auto; }
.modal-b { padding: 18px 20px; display: grid; gap: 14px; }
.modal-f { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 12px 12px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }

.toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 200; }
.toast {
  display: flex; gap: 10px; align-items: flex-start; min-width: 260px; max-width: 420px; padding: 12px 14px;
  background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 8px;
  box-shadow: var(--shadow-lg); font-size: 14px; animation: pop .18s;
}
.toast.err { border-left-color: var(--danger); }

.check-list { display: grid; gap: 6px; max-height: 220px; overflow-y: auto; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; }
.alert { display: flex; gap: 10px; padding: 12px 14px; border-radius: 8px; font-size: 14px; }
.alert.warn { background: var(--warn-soft); color: var(--warn); }
.alert.info { background: var(--info-soft); color: var(--info); }
.steps { counter-reset: s; list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.steps > li { counter-increment: s; display: grid; grid-template-columns: 30px 1fr; gap: 12px; }
.steps > li::before {
  content: counter(s); width: 28px; height: 28px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-text);
  display: grid; place-items: center; font-weight: 600; font-size: 13px;
}
.dl-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }
.dl { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; background: var(--surface); }
.dl:hover { border-color: var(--accent); }

/* ---------------------------------------------------------------- вход */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 16px; background:
  radial-gradient(1200px 600px at 10% -10%, rgba(34, 197, 94, .12), transparent 60%),
  radial-gradient(900px 500px at 110% 110%, rgba(59, 130, 246, .10), transparent 60%), var(--bg); }
.login-card { width: min(420px, 100%); padding: 28px; }
.login-card .brand { padding: 0 0 18px; }
.login-card .brand-name { color: var(--text); }
.login-card h1 { font-size: 20px; margin: 0 0 4px; }

/* ---------------------------------------------------------------- сравнение */
.diff-layout { display: grid; grid-template-columns: 360px 1fr; gap: 16px; align-items: start; }
@media (max-width: 1100px) { .diff-layout { grid-template-columns: 1fr; } }
.diff-list { position: sticky; top: 90px; max-height: calc(100vh - 110px); display: flex; flex-direction: column; }
.diff-list .top { padding: 12px; border-bottom: 1px solid var(--line); display: grid; gap: 8px; }
.diff-items { overflow-y: auto; }
.diff-group { padding: 8px 14px 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: var(--surface-2); border-bottom: 1px solid var(--line); position: sticky; top: 0; }
.diff-item { display: flex; gap: 8px; align-items: flex-start; width: 100%; padding: 8px 14px; border: 0; border-bottom: 1px solid var(--line); background: none; cursor: pointer; text-align: left; }
.diff-item:hover { background: var(--surface-2); }
.diff-item.active { background: var(--accent-soft); }
.diff-item .nm { font-size: 14px; font-weight: 500; word-break: break-word; }
.diff-item .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.st { width: 20px; height: 20px; border-radius: 5px; display: grid; place-items: center; font: 700 12px var(--mono); flex: none; margin-top: 1px; }
.st.added { background: var(--accent-soft); color: var(--accent); }
.st.removed { background: var(--danger-soft); color: var(--danger); }
.st.changed { background: var(--warn-soft); color: var(--warn); }
.meta-table td { font-size: 13.5px; }
.meta-table .was { color: var(--danger); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--danger) 40%, transparent); word-break: break-word; }
.meta-table .now { color: var(--accent); word-break: break-word; }
.mod-card { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--surface); }
.mod-card + .mod-card { margin-top: 12px; }
.mod-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: var(--surface-2); border-bottom: 1px solid var(--line); cursor: pointer; flex-wrap: wrap; }
.mod-head .cnt { font: 500 12.5px var(--mono); }
.mod-head .cnt .p { color: var(--accent); } .mod-head .cnt .m { color: var(--danger); }
.meth { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 14px; border-bottom: 1px solid var(--line); font-size: 13px; }
.diff-code { margin: 0; overflow-x: auto; font: 12.5px/1.55 var(--mono); background: var(--code-bg); max-height: 70vh; overflow-y: auto; }
.diff-code table { border-collapse: collapse; width: 100%; }
.diff-code td { padding: 0 8px; white-space: pre; vertical-align: top; }
.diff-code td.no { width: 1%; text-align: right; color: var(--code-line); user-select: none; padding: 0 6px; }
.diff-code td.sg { width: 1%; user-select: none; color: var(--muted); padding: 0 4px; }
.diff-code tr.add td { background: var(--add-bg); } .diff-code tr.add td.sg { color: var(--accent); }
.diff-code tr.del td { background: var(--del-bg); } .diff-code tr.del td.sg { color: var(--danger); }
.diff-code tr.add td.no { background: var(--add-strong); } .diff-code tr.del td.no { background: var(--del-strong); }
.diff-code tr.sep td { background: var(--surface-3); color: var(--muted); text-align: center; font-size: 12px; padding: 2px; }
.pill-filter { display: flex; flex-wrap: wrap; gap: 6px; }
.pill-filter button { border: 1px solid var(--line-strong); background: var(--surface); border-radius: 14px; height: 28px; padding: 0 10px; font-size: 13px; cursor: pointer; }
.pill-filter button.on { background: var(--text); color: var(--surface); border-color: var(--text); }
.diff-layout > * { min-width: 0; }
.cols-2 > *, .browser > * { min-width: 0; }
.content > * { min-width: 0; }

/* ---------------------------------------------------------------- форма 1С («Такси»), приблизительно */
.f1c-wrap { background: #e6e6e6; padding: 16px; border-radius: 8px; overflow: auto; max-height: 75vh; }
.f1c {
  --c-text: #333; --c-border: #b5b5b5; --c-title: #4d4d4d; --c-link: #0066cc; --c-head: #f2f2f2;
  font: 13px/1.35 Arial, "Helvetica Neue", Helvetica, sans-serif; color: var(--c-text); background: #fff;
  border: 1px solid #a8a8a8; border-radius: 3px; box-shadow: 0 2px 10px rgba(0,0,0,.18); min-width: 640px; max-width: 1100px; margin: 0 auto;
}
.f1c * { box-sizing: border-box; }
.f1c-title { display: flex; align-items: center; gap: 8px; padding: 9px 12px 8px; font-size: 17px; color: #4d4d4d; border-bottom: 1px solid #e8e8e8; }
.f1c-title .star { color: #c0c0c0; font-size: 16px; }
.f1c-title .wbtn { margin-left: auto; display: flex; gap: 10px; color: #999; font-size: 15px; }
.f1c-body { padding: 8px 12px 14px; display: flex; flex-direction: column; gap: 6px; }
.f1c-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; padding: 4px 0; }
.f1c-btn {
  display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 10px; border: 1px solid #a9a9a9; border-radius: 2px;
  background: linear-gradient(#fff, #ececec); color: #333; font: inherit; white-space: nowrap; cursor: default;
}
.f1c-btn.def { background: linear-gradient(#ffe57f, #fbd24b); border-color: #d1a92f; font-weight: bold; }
.f1c-btn.more::after { content: " ▾"; color: #777; font-size: 10px; }
.f1c-btn.pic { padding: 0 6px; min-width: 24px; justify-content: center; }
.f1c-row { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: flex-start; }
.f1c-col { display: flex; flex-direction: column; gap: 6px; }
.f1c-grp > .gt { font-weight: bold; color: #4d4d4d; margin: 4px 0 2px; }
.f1c-grp.strong { border: 1px solid #d3d3d3; padding: 6px 8px; }
.f1c-grp.normal { border-top: 1px solid #e3e3e3; padding-top: 4px; }
.f1c-grp.coll > .gt::before { content: "▾ "; color: #888; }
.f1c-field { display: flex; align-items: center; gap: 6px; min-height: 24px; }
.f1c-field.top { flex-direction: column; align-items: stretch; gap: 2px; }
.f1c-field .lb { color: #4d4d4d; white-space: nowrap; }
.f1c-field .lb::after { content: ":"; }
.f1c-inp {
  display: flex; align-items: center; height: 22px; min-width: 120px; border: 1px solid var(--c-border); border-radius: 2px; background: #fff;
  padding: 0 4px; color: #999; font-size: 12px; overflow: hidden;
}
.f1c-inp.ml { height: 50px; align-items: flex-start; padding-top: 3px; }
.f1c-inp.ro { background: #f7f7f7; }
.f1c-inp .sp { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.f1c-inp .bt { color: #777; margin-left: 4px; font-size: 11px; border-left: 1px solid #e0e0e0; padding-left: 4px; }
.f1c-cb { width: 14px; height: 14px; border: 1px solid #8f8f8f; border-radius: 2px; background: #fff; flex: none; }
.f1c-rb { width: 14px; height: 14px; border: 1px solid #8f8f8f; border-radius: 50%; background: #fff; flex: none; }
.f1c-rb.on { box-shadow: inset 0 0 0 3px #fff; background: #555; }
.f1c-label { color: #4d4d4d; }
.f1c-label.link, .f1c-field .val.link { color: var(--c-link); text-decoration: underline dotted; }
.f1c-label.bold { font-weight: bold; }
.f1c-pic { width: 16px; height: 16px; border-radius: 3px; background: #d9d9d9; display: inline-block; }
.f1c-tabs { border: 1px solid #d3d3d3; border-radius: 2px; }
.f1c-tabs .tabs1c { display: flex; flex-wrap: wrap; background: #f4f4f4; border-bottom: 1px solid #d3d3d3; }
.f1c-tabs .tab1c { padding: 5px 12px; border-right: 1px solid #ddd; color: #4d4d4d; cursor: pointer; }
.f1c-tabs .tab1c.on { background: #fff; font-weight: bold; margin-bottom: -1px; border-bottom: 1px solid #fff; }
.f1c-tabs .pg { padding: 8px; display: none; flex-direction: column; gap: 6px; }
.f1c-tabs .pg.on { display: flex; }
.f1c-table { border: 1px solid #b5b5b5; width: 100%; overflow: auto; }
.f1c-table table { border-collapse: collapse; width: 100%; }
.f1c-table th { background: var(--c-head); font-weight: normal; color: #4d4d4d; text-align: left; padding: 3px 6px; border-right: 1px solid #d9d9d9; border-bottom: 1px solid #c9c9c9; white-space: nowrap; }
.f1c-table td { height: 22px; border-right: 1px solid #ececec; border-bottom: 1px solid #ececec; padding: 0 6px; }
.f1c-table tr:nth-child(even) td { background: #fafafa; }
.f1c-table th.n, .f1c-table td.n { width: 30px; text-align: right; color: #888; }
.f1c-box { border: 1px solid #c9c9c9; background: repeating-linear-gradient(45deg, #fafafa, #fafafa 8px, #f2f2f2 8px, #f2f2f2 16px); color: #888; display: grid; place-items: center; min-height: 80px; }
.f1c .hid { opacity: .45; outline: 1px dashed #d08; outline-offset: 1px; }
.f1c-stretch { flex: 1 1 auto; }
.f1c-col, .f1c-row > *, .f1c-tabs .pg, .f1c-grp { min-width: 0; }
.f1c-tabs { overflow: hidden; }

/* подсветка изменений в формах */
.f1c .d-added { outline: 2px solid #22c55e !important; outline-offset: 1px; background-color: rgba(34, 197, 94, .14) !important; }
.f1c .d-removed { outline: 2px solid #ef4444 !important; outline-offset: 1px; background-color: rgba(239, 68, 68, .12) !important; }
.f1c .d-changed { outline: 2px solid #f59e0b !important; outline-offset: 1px; background-color: rgba(245, 158, 11, .16) !important; }
.f1c .d-moved { outline: 2px dashed #f59e0b !important; outline-offset: 1px; }
.f1c .d-attr { outline: 2px dashed #3b82f6 !important; outline-offset: 1px; background-color: rgba(59, 130, 246, .10) !important; }
.legend { display: inline-flex; flex-wrap: wrap; gap: 12px; font-size: 13px; color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 16px; height: 12px; border-radius: 2px; display: inline-block; }
.legend i.d-added { background: rgba(34, 197, 94, .25); border: 2px solid #22c55e; }
.legend i.d-removed { background: rgba(239, 68, 68, .2); border: 2px solid #ef4444; }
.legend i.d-changed { background: rgba(245, 158, 11, .25); border: 2px solid #f59e0b; }
.legend i.d-moved { border: 2px dashed #f59e0b; }
.legend i.d-attr { background: rgba(59, 130, 246, .15); border: 2px dashed #3b82f6; }
.fd-grid { display: grid; gap: 12px; }
.fd-grid.two { grid-template-columns: 1fr 1fr; }
@media (max-width: 1100px) { .fd-grid.two { grid-template-columns: 1fr; } }
.fd-col { min-width: 0; }
.fd-h { font-weight: 600; font-size: 13px; margin-bottom: 6px; color: var(--text-2); }
.f1c-wrap.compact { padding: 8px; max-height: 70vh; }
.f1c-wrap.compact .f1c { min-width: 0; zoom: .82; }

/* ---------------------------------------------------------------- макеты: табличный документ */
.mxl-wrap { overflow: auto; max-height: 72vh; background: #fff; border: 1px solid #cfcfcf; border-radius: 4px; }
.mxl { border-collapse: collapse; table-layout: fixed; font: 13.3px Arial, sans-serif; color: #000; background: #fff; }
.mxl td { border: 1px solid #ececec; padding: 1px 3px; overflow: hidden; text-overflow: clip; line-height: 1.25; }
.mxl .mxl-hdr th { position: sticky; top: 0; background: #f0f0f0; color: #666; font-weight: normal; font-size: 11px; border: 1px solid #d6d6d6; height: 18px; z-index: 1; }
.mxl td.mxl-rn { background: #f0f0f0; color: #777; font-size: 11px; text-align: right; border-color: #d6d6d6; }
.mxl .mxl-area { background: #fafafa; border: 0; border-right: 1px solid #d6d6d6; padding: 0; }
.mxl td.mxl-area { vertical-align: top; }
.mxl td.mxl-area.in { box-shadow: inset 3px 0 0 #5b8def; background: #f3f7fd; }
.mxl td.mxl-area span { display: block; padding: 1px 6px; color: #33518a; font-size: 11px; white-space: normal; line-height: 1.2; }
.mxl-par { color: #1f5bb5; background: #eaf1fd; border-radius: 2px; }
.mxl tr.mx-added td:not(.mxl-area) { background: #dcfce7 !important; }
.mxl tr.mx-removed td:not(.mxl-area) { background: #fee2e2 !important; }
.mxl td.mx-changed { background: #fef3c7 !important; outline: 2px solid #f59e0b; outline-offset: -2px; }
.mxl tr.mx-added td.mxl-rn { color: #15803d; font-weight: bold; }
.mxl tr.mx-removed td.mxl-rn { color: #dc2626; font-weight: bold; }
.tpl-html { width: 100%; height: 65vh; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.mxl.no-areas .mxl-area { display: none; }

/* история объекта */
.hist { position: relative; display: grid; gap: 0; }
.hist-row { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0 10px 4px; border-bottom: 1px solid var(--line); position: relative; }
.hist-row:last-child { border-bottom: 0; }
.hist-dot { width: 12px; height: 12px; border-radius: 50%; margin-top: 5px; flex: none; background: var(--line-strong); box-shadow: 0 0 0 3px var(--surface); }
.hist-dot.changed { background: #f59e0b; } .hist-dot.added { background: #22c55e; } .hist-dot.removed { background: #ef4444; }
.hist-row.same, .hist-row.absent { opacity: .7; }

/* визуальный diff описания объекта */
.sd .sd-row { display: grid; grid-template-columns: 22px minmax(170px, 1fr) minmax(170px, 1.2fr) minmax(0, 1.2fr) 110px; gap: 10px; padding: 7px 18px 7px 12px; border-bottom: 1px solid var(--line); font-size: 14px; align-items: start; }
.sd .sd-row.head { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; background: var(--surface-2); padding-top: 5px; padding-bottom: 5px; }
.sd .sd-row.sub .sd-name { padding-left: 18px; position: relative; }
.sd .sd-row.sub .sd-name::before { content: ""; position: absolute; left: 4px; top: 50%; width: 8px; border-top: 1px solid var(--line-strong); }
.sd .sd-name { font-weight: 500; word-break: break-word; }
.sd .sd-type { font-size: 12.5px; color: var(--info); word-break: break-word; }
.sd .sd-syn { color: var(--muted); word-break: break-word; }
.sd .sd-flags { font-size: 12px; color: var(--muted); }
.sd .sd-sign { font: 700 13px var(--mono); text-align: center; }
.sd .sd-row.added { background: color-mix(in srgb, #22c55e 13%, transparent); } .sd .sd-row.added .sd-sign { color: #16a34a; }
.sd .sd-row.removed { background: color-mix(in srgb, #ef4444 11%, transparent); } .sd .sd-row.removed .sd-sign { color: #dc2626; }
.sd .sd-row.removed .sd-name, .sd .sd-row.removed .sd-type, .sd .sd-row.removed .sd-syn { text-decoration: line-through; opacity: .75; }
.sd .sd-row.changed { background: color-mix(in srgb, #f59e0b 14%, transparent); } .sd .sd-row.changed .sd-sign, .sd .sd-ts.inner .sd-sign, .sd .sd-ts.changed .sd-sign { color: #d97706; }
.sd .sd-ts.added { background: color-mix(in srgb, #22c55e 18%, var(--surface-2)); } .sd .sd-ts.removed { background: color-mix(in srgb, #ef4444 15%, var(--surface-2)); text-decoration: line-through; }
.sd .sd-ts.changed, .sd .sd-ts.inner { background: color-mix(in srgb, #f59e0b 14%, var(--surface-2)); }
.sd s.was { color: var(--danger); } .sd b.now { color: var(--accent); font-weight: 600; }
.sd-chip.added { background: color-mix(in srgb, #22c55e 22%, transparent); color: #15803d; }
.sd-chip.removed { background: color-mix(in srgb, #ef4444 18%, transparent); color: #b91c1c; text-decoration: line-through; }
@media (max-width: 800px) { .sd .sd-row { grid-template-columns: 22px 1fr; } .sd .sd-row > div:nth-child(n+3) { grid-column: 2; } .sd .sd-row.head { display: none; } }
.sd .group-h { padding: 10px 18px; background: var(--surface-2); border-bottom: 1px solid var(--line); font-weight: 600; font-size: 14px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.sd .chips { padding: 10px 18px; }

.task-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.task-tile { display: grid; gap: 2px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 8px; color: var(--text); text-decoration: none !important; background: var(--surface-2); }
.task-tile b { font-size: 22px; font-variant-numeric: tabular-nums; }
.task-tile span { font-size: 13px; color: var(--muted); }
.task-tile:hover { border-color: var(--accent); }
.task-tile.amber b { color: var(--warn); } .task-tile.violet b { color: var(--violet); } .task-tile.green b { color: var(--accent); }
.task-tile.red b { color: var(--danger); } .task-tile.blue b { color: var(--info); }
.diff-layout.single { grid-template-columns: minmax(0, 1fr); } .diff-layout.single .diff-list { display: none; }
#srcView { margin-top: 0; }

/* ---------- задача: общение и технический журнал ---------- */
.chat { max-height: 560px; overflow-y: auto; overscroll-behavior: contain; padding: 14px 18px; display: flex; flex-direction: column; gap: 10px; }
.cmsg { max-width: 88%; border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; background: var(--surface-2); }
.cmsg-me { align-self: flex-end; border-bottom-right-radius: 4px; }
.cmsg-bot { align-self: flex-start; border-bottom-left-radius: 4px; background: var(--info-soft); border-color: transparent; }
.cmsg-h { display: flex; gap: 6px; align-items: center; font-size: 12.5px; margin-bottom: 4px; }
.cmsg-b { font-size: 14px; line-height: 1.5; overflow-wrap: anywhere; }
.cmsg-b > :first-child { margin-top: 0; }
.cmsg-b > :last-child { margin-bottom: 0; }
.cmsg-b pre { max-width: 100%; overflow: auto; }
.chat-status { align-self: center; max-width: 92%; font-size: 12.5px; color: var(--muted); text-align: center; }
.chat-status > svg { vertical-align: -2px; margin-right: 4px; }
.chat-status b { color: var(--text-2); font-weight: 600; }
.chat-status-note { margin-top: 6px; text-align: left; color: var(--text-2); font-size: 13.5px; background: var(--warn-soft); border-radius: 8px; padding: 6px 10px; }
.chat-status-note > :first-child { margin-top: 0; }
.chat-status-note > :last-child { margin-bottom: 0; }
.chat-wait { align-self: flex-start; display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--muted); padding: 4px 2px; }
.chat-wait svg { animation: spin 1s linear infinite; }
details.tech > summary { cursor: pointer; list-style: none; }
details.tech > summary::-webkit-details-marker { display: none; }
details.tech > summary > svg:last-child { margin-left: auto; transition: transform .2s; }
details.tech[open] > summary > svg:last-child { transform: rotate(90deg); }
details.tech:not([open]) > summary { border-bottom: 0; }
@media (prefers-reduced-motion: reduce) { .chat-wait svg { animation: none; } }
.msg-files { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.msg-files:empty { display: none; }
.msg-file { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 4px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); font-size: 12.5px; cursor: pointer; }
.msg-file > span:first-of-type { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.msg-file:hover { border-color: var(--line-strong); }
.msg-file.pending { cursor: default; }
.msg-file .icon-btn { width: 22px; height: 22px; }
.textarea.drop { outline: 2px dashed var(--accent); outline-offset: 2px; }

/* ---------- состояние исполнителя ---------- */
.worker-panel { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; margin-bottom: 16px; font-size: 14px; }
.slots { display: inline-flex; gap: 4px; }
.slot { width: 14px; height: 14px; border-radius: 4px; border: 1.5px solid var(--line-strong); }
.slot.busy { background: var(--accent); border-color: var(--accent); }

/* ---------- расширения в обозревателе ---------- */
.f-row.f-ext { background: var(--violet-soft); }
.tree-item .ext + .ext { margin-left: 6px; }
.code .ln.ln-ext { background: color-mix(in srgb, var(--violet-soft) 55%, transparent); box-shadow: inset 3px 0 0 var(--violet); }
.code .ln.ln-sec span { color: var(--violet); font-weight: 600; }
.outline .exp.ext { color: var(--violet); background: var(--violet-soft); }
.outline .region.ext { color: var(--violet); }
/* карточка объекта на узких экранах: ничего не обрезается */
.obj-head > .grow { min-width: 0; }
.hints .hint { max-width: 100%; overflow-wrap: anywhere; white-space: normal; }
@media (max-width: 600px) { .obj-head { flex-direction: column-reverse; gap: 8px; } }
.tree-type.tree-ext { color: var(--violet); }
.tree-type.tree-sub { padding-left: 26px; font-weight: 500; }
[data-ext] .tree-item { padding-left: 44px; }
/* домашняя панель базы: список расширений свёрнут */
.ext-list { margin-top: 14px; border: 1px solid var(--line); border-radius: 10px; }
.ext-list > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px; padding: 10px 12px; font-weight: 600; color: var(--violet); }
.ext-list > summary::-webkit-details-marker { display: none; }
.ext-list > summary > svg:first-child { transition: transform .2s; }
.ext-list[open] > summary > svg:first-child { transform: rotate(90deg); }
.ext-rows { border-top: 1px solid var(--line); max-height: 420px; overflow-y: auto; }
.ext-row { display: flex; align-items: center; gap: 8px; padding: 6px 12px; font-size: 13.5px; flex-wrap: wrap; }
.ext-row + .ext-row { border-top: 1px solid var(--line); }
.ext-row .ellipsis { max-width: 320px; }
/* плитки статистики: длинные имена типов переносятся, а не вылезают */
.stat > div { min-width: 0; }
.stat-l { overflow-wrap: anywhere; }
/* ошибки */
.err-text { font-size: 13px; margin-top: 2px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
tr.sel td { background: var(--accent-soft); }
/* база знаний */
.kb-src { display: flex; gap: 6px; align-items: center; padding-right: 10px; }
.kb-src .count { margin-left: auto; font-size: 11px; color: var(--muted); }
.kb-results { display: grid; }
.kb-hit { display: block; padding: 10px 18px; border-top: 1px solid var(--line); color: inherit; text-decoration: none; }
.kb-hit:hover { background: var(--surface-2); }
.kb-snip { font-size: 13px; margin-top: 3px; overflow-wrap: anywhere; }
.kb-doc { display: grid; grid-template-columns: minmax(220px, 340px) minmax(0, 1fr); height: 100%; min-height: 0; }
.kb-toc { overflow-y: auto; border-right: 1px solid var(--line); padding: 8px 0; background: var(--surface); }
.kb-toc-i { display: block; padding: 3px 12px; font-size: 13px; color: var(--text-2); text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kb-toc-i:hover { background: var(--surface-2); }
.kb-toc-i.active { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.kb-toc-i.lv1 { font-weight: 700; } .kb-toc-i.lv2 { padding-left: 16px; font-weight: 600; } .kb-toc-i.lv3 { padding-left: 26px; }
.kb-toc-i.lv4 { padding-left: 36px; } .kb-toc-i.lv5 { padding-left: 46px; } .kb-toc-i.lv6 { padding-left: 56px; }
.kb-sec { overflow-y: auto; min-width: 0; }
.kb-text { font-size: 14px; line-height: 1.55; overflow-wrap: anywhere; white-space: normal; }
@media (max-width: 900px) { .kb-doc { grid-template-columns: 1fr; } .kb-toc { max-height: 40vh; border-right: 0; border-bottom: 1px solid var(--line); } }
/* дерево документации */
.kb-toc-top { position: sticky; top: 0; background: var(--surface); padding: 8px; border-bottom: 1px solid var(--line); z-index: 1; }
.kb-tree { list-style: none; margin: 0; padding: 0 0 0 10px; }
#kbToc > .kb-tree { padding: 6px 4px 20px; }
.kb-tree li > .kb-tree { display: none; }
.kb-tree li.open > .kb-tree { display: block; }
.kb-tree li { display: block; }
.kb-tree li > * { vertical-align: middle; }
.kb-tg, .kb-tg-sp { display: inline-grid; place-items: center; width: 20px; height: 20px; border: 0; background: none; padding: 0; cursor: pointer; color: var(--muted); }
.kb-tg svg { transition: transform .15s; }
li.open > .kb-tg svg { transform: rotate(90deg); }
.kb-node { display: inline-block; max-width: calc(100% - 60px); padding: 2px 6px; border-radius: 6px; font-size: 13px; color: var(--text-2); text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.kb-node:hover { background: var(--surface-2); }
.kb-node.folder { font-weight: 600; color: var(--text); }
.kb-node.active { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.kb-cnt { font-size: 11px; color: var(--muted); margin-left: 2px; }
.kb-kids { display: flex; flex-wrap: wrap; gap: 6px; }
.kb-kids a { font-size: 13px; padding: 3px 8px; border: 1px solid var(--line); border-radius: 6px; text-decoration: none; color: var(--text-2); }
.kb-kids a:hover { border-color: var(--accent); color: var(--accent-text); }

/* ================================================================ мобильная версия */
@media (max-width: 640px) {
  body { -webkit-text-size-adjust: 100%; }
  .topbar { gap: 8px; }
  .topbar h1 { font-size: 17px; }
  .topbar .sub { font-size: 12px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .topbar .actions { width: 100%; margin-left: 0; }
  .topbar .actions > .select, .topbar .actions > .btn.primary { flex: 1; }
  .content { padding: 12px; gap: 14px; }
  .card-h { padding: 12px 14px; flex-wrap: wrap; }
  .card-h .actions { width: 100%; margin-left: 0; }
  .card-h .actions .search-box { flex: 1; }
  .card-b { padding: 14px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat { padding: 12px; gap: 10px; }
  .stat-v { font-size: 20px; }

  /* таблицы-списки → карточки */
  table.stackable, table.stackable tbody, table.stackable tr, table.stackable td { display: block; width: 100%; }
  table.stackable thead { display: none; }
  table.stackable tr { padding: 10px 14px; border-bottom: 1px solid var(--line); }
  table.stackable td { border: 0 !important; padding: 3px 0 !important; max-width: none !important; white-space: normal !important; }
  table.stackable td[data-label]:not(:first-child)::before {
    content: attr(data-label); display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 1px;
  }
  table.stackable td:empty { display: none; }
  table.stackable td.nowrap { white-space: normal; }

  /* обозреватель: карточка объекта, вкладки, код */
  .browser-main .pad { padding: 12px; gap: 12px; }
  .browser-side { max-height: 38vh; }
  .obj-title { font-size: 19px; }
  .hint { font-size: 11.5px; }
  .code-toolbar { flex-wrap: wrap; gap: 6px; padding: 8px 10px; }
  .code-toolbar .btn { flex: 1 1 auto; }
  .code { font-size: 12px; max-height: 60vh; }
  .outline { max-height: 45vh; border-left: 0; border-top: 1px solid var(--line); }
  .outline li button { flex-wrap: wrap; }
  .outline .exp { white-space: normal; }

  /* задача: чат, панели */
  .cmsg { max-width: 100%; }
  .worker-panel { font-size: 13px; }
  .task-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  /* окна на весь экран */
  .modal-back { padding: 0; align-items: stretch; }
  .modal { width: 100% !important; max-height: 100vh; height: 100%; border-radius: 0; }

  /* база знаний, ошибки */
  .kb-toc { max-height: 45vh; }
  .kb-sec.pad { padding: 12px; }
  .err-text { -webkit-line-clamp: 3; }
  .chips { flex-wrap: wrap; }

  /* сравнение */
  .diff-layout { gap: 12px; }
  .legend { flex-wrap: wrap; }
}
/* любые сетки контента не шире экрана */
.content { grid-template-columns: minmax(0, 1fr); }
.card { min-width: 0; }

@media (max-width: 640px) {
  .kv { grid-template-columns: minmax(0, 1fr) !important; }
  .kv > div:nth-child(odd) { padding-bottom: 0 !important; border-bottom: 0 !important; font-weight: 600; }
  .kv code, .kv pre { white-space: pre-wrap; word-break: break-word; }
  .copy-row { flex-direction: column; align-items: stretch; }
  .copy-row pre.block { min-width: 0; white-space: pre-wrap; word-break: break-all; }
}

details.card-sub { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
details.card-sub > summary { cursor: pointer; list-style-position: inside; }

pre, code, .mono { font-variant-ligatures: none; font-feature-settings: "liga" 0, "calt" 0; }

/* проекты */
.proj-src { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 16px; align-items: start; }
.proj-files { position: sticky; top: 90px; }
.proj-file-list { max-height: calc(100vh - 220px); overflow-y: auto; border-top: 1px solid var(--line); }
.pf { display: flex; justify-content: space-between; gap: 8px; width: 100%; padding: 7px 12px; border: 0; border-bottom: 1px solid var(--line);
  background: none; text-align: left; cursor: pointer; font-size: 13px; color: var(--text); }
.pf .mono { word-break: break-all; }
.pf .muted { flex-shrink: 0; font-size: 12px; }
.pf:hover { background: var(--surface-2); }
.pf.on { background: var(--accent-soft); }
.chg-list { display: grid; gap: 2px; }
.chg-item { display: flex; gap: 8px; align-items: center; padding: 5px 8px; border: 0; border-radius: 6px; background: none; cursor: pointer;
  text-align: left; font-size: 13px; color: var(--text); }
.chg-item .mono { word-break: break-all; }
.chg-item:hover { background: var(--surface-2); }
.code.udiff { max-height: 70vh; margin: 0; }
.code .ln.ln-add { background: color-mix(in srgb, #22c55e 16%, transparent); }
.code .ln.ln-del { background: color-mix(in srgb, #ef4444 16%, transparent); }
.code .ln.ln-hunk span { color: var(--accent); }
.code .ln.ln-head span { color: var(--muted); }
@media (max-width: 900px) {
  .proj-src { grid-template-columns: minmax(0, 1fr); }
  .proj-files { position: static; }
  .proj-file-list { max-height: 40vh; }
}
