/* © Егор — демо портфолио. */
:root, [data-theme="light"] {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --ink: #1a1f2e;
  --muted: #6b7280;
  --line: #e8eaee;
  --accent: #4f46e5;
  --accent-soft: #eef0ff;
  --good: #15803d;
  --warn: #b91c1c;
  --warn-soft: #fef2f2;
  --amber: #b45309;
  --amber-soft: #fffbeb;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, 0.10);
  --code-bg: #f3f4f6;
  --term-bg: #10141c;
  --btn-black: #17181c;
  --btn-black-text: #ffffff;
}

[data-theme="dark"] {
  --bg: #0f131c;
  --surface: #171d2b;
  --ink: #e8eaf0;
  --muted: #98a1b3;
  --line: #262e42;
  --accent: #7c86f8;
  --accent-soft: rgba(124, 134, 248, 0.14);
  --good: #34d399;
  --warn: #f87171;
  --warn-soft: rgba(248, 113, 113, 0.12);
  --amber: #fbbf24;
  --amber-soft: rgba(251, 191, 36, 0.12);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 1px 3px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.5);
  --code-bg: #1e2536;
  --term-bg: #0b0e15;
  --btn-black: #000000;
  --btn-black-text: #ffffff;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, "Roboto", sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.55;
  font-weight: 500;
  -webkit-font-smoothing: antialiased;
  transition: background 0.25s, color 0.25s;
}

/* Шапка: вкладки слева, бренд по центру, действия справа */
.topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 20px;
  padding: 14px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.tabs { display: flex; gap: 4px; justify-content: flex-start; flex-wrap: wrap; }
.tabs-right { justify-content: flex-end; }
.brand-center { display: flex; justify-content: center; }
.brand {
  font-size: 22px; font-weight: 800; letter-spacing: 0.2px;
  cursor: default; user-select: none;
}
.brand-link { cursor: pointer; }
.b-tip { color: var(--accent); }
.b-mark { color: var(--ink); transition: color 0.2s; }
.brand:hover .b-mark { color: var(--accent); }

.tab {
  border: none; background: transparent; padding: 10px 15px;
  border-radius: 9px; cursor: pointer; color: var(--muted);
  font-size: 15px; font-weight: 600; display: inline-flex; align-items: center; gap: 8px;
  transition: background 0.15s, color 0.15s;
}
.tab:hover { background: var(--bg); }
.tab.active { background: var(--accent-soft); color: var(--accent); }
.badge-count {
  display: none; align-items: center; justify-content: center;
  min-width: 20px; height: 20px; padding: 0 6px;
  background: var(--accent); color: #fff; border-radius: 20px;
  font-size: 12px; font-weight: 600;
}

.topbar-right { display: flex; align-items: center; justify-content: flex-end; gap: 12px; }

/* Квадратные иконки-кнопки в шапке (дашборд, тема) */
.icon-btn {
  width: 38px; height: 38px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface);
  color: var(--muted); cursor: pointer;
  display: grid; place-items: center;
  transition: color 0.2s, border-color 0.2s, transform 0.05s, background 0.2s;
}
.icon-btn:hover { color: var(--accent); border-color: var(--accent); }
.icon-btn:active { transform: scale(0.95); }
.icon-btn.active { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.icon-btn:disabled { opacity: 0.5; cursor: default; }
.row-actions { display: inline-flex; gap: 8px; justify-content: flex-end; }
.row-actions .icon-btn { width: 34px; height: 34px; border-radius: 9px; }
[data-theme="light"] .icon-sun { display: none; }
[data-theme="light"] .icon-moon { display: block; }
[data-theme="dark"] .icon-sun { display: block; }
[data-theme="dark"] .icon-moon { display: none; }

/* Кнопки */
.btn {
  border: none; border-radius: 9px; padding: 10px 18px;
  font-size: 15px; font-weight: 700; cursor: pointer; text-decoration: none;
  display: inline-block;
  transition: filter 0.15s, background 0.15s, transform 0.05s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 4px 12px rgba(79, 70, 229, 0.22); }
.btn-primary:hover { filter: brightness(1.06); }
.btn-primary:disabled { opacity: 0.6; cursor: default; }
.btn-ghost { background: var(--surface); color: var(--ink); border: 1px solid var(--line); }
.btn-ghost:hover { background: var(--bg); }

/* Эффект волны на тексте кнопок */
.wave-btn .wave-letter { display: inline-block; will-change: transform; }
.wave-btn:hover .wave-letter { animation: waveRipple 0.55s ease; animation-delay: calc(var(--i) * 18ms); }
@keyframes waveRipple {
  0%, 100% { transform: translateY(0); }
  30% { transform: translateY(-3px); }
  60% { transform: translateY(1px); }
}
@media (prefers-reduced-motion: reduce) {
  .wave-btn .wave-letter { animation: none; }
}

.count { color: var(--muted); font-size: 14px; margin-left: auto; }

/* Крупные карточки статистики (во всю ширину) */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 14px;
  margin: 24px 32px 16px;
}
.stat-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px 20px;
  display: flex; flex-direction: column; gap: 4px;
  box-shadow: var(--shadow);
  transition: transform 0.12s, border-color 0.12s;
}
.stat-card:hover { transform: translateY(-2px); border-color: var(--accent); }
.stat-num { font-size: 28px; font-weight: 800; line-height: 1; color: var(--ink); }
.stat-label { font-size: 14px; color: var(--muted); font-weight: 600; }
.accuracy-panel {
  margin: 0 32px 12px;
  padding: 10px 18px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  color: var(--muted); font-size: 14px; display: none;
}
.accuracy-panel b { color: var(--accent); font-size: 16px; }

/* Панель управления журналом: поиск + фильтры + кнопки */
.toolbar-row {
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
  padding: 0 32px 18px;
}
.toolbar-row input[type="search"] {
  flex: 1; min-width: 220px; max-width: 360px; padding: 11px 16px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface);
  color: var(--ink); font-size: 15px; transition: border 0.15s, box-shadow 0.15s;
}
.toolbar-row input[type="search"]:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}
.toolbar-row select {
  padding: 11px 16px; border: 1px solid var(--line);
  border-radius: 10px; background: var(--surface); color: var(--ink); font-size: 15px;
  max-width: 300px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.toolbar-row .count { color: var(--muted); font-size: 14px; white-space: nowrap; }
.toolbar-row .count-left { margin-left: 0; }
.toolbar-actions { display: flex; gap: 10px; align-items: center; margin-left: auto; }

/* Кнопки журнала */
.btn-upload, .btn-export {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
}
.btn-upload:hover, .btn-export:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}
.btn-clear {
  background: var(--btn-black);
  color: var(--btn-black-text);
  border: 1px solid var(--btn-black);
}
.btn-clear:hover {
  background: var(--warn);
  border-color: var(--warn);
  color: #fff;
}

/* Пакетная панель в журнале */
.bulk-bar {
  display: none; gap: 12px; align-items: center;
  margin: 0 32px 12px; padding: 10px 16px;
  background: var(--accent-soft); border: 1px solid var(--accent);
  border-radius: 10px; font-size: 14px; flex-wrap: wrap;
}
.bulk-bar.visible { display: flex; }
.bulk-bar select {
  padding: 9px 14px; border: 1px solid var(--line); border-radius: 9px;
  background: var(--surface); color: var(--ink); font-size: 14px;
  max-width: 340px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#bulk-count { font-weight: 700; color: var(--accent); }
.td-check { width: 34px; text-align: center; }
.td-check input { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }

/* Превью документа в карточке */
.doc-preview-wrap { margin: 10px 0 14px; }
.doc-preview {
  width: 100%; max-height: 340px; object-fit: contain;
  border: 1px solid var(--line); border-radius: 10px; background: var(--bg);
}

/* Инструменты правил (экспорт/импорт) */
.rules-tools { display: flex; gap: 10px; margin: 0 0 16px; }

/* Предложения маркеров */
.suggest-block {
  background: var(--bg); border: 1px solid var(--line);
  border-radius: 10px; padding: 16px 18px; margin-bottom: 18px;
}
.suggest-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.suggest-block .sub { margin: 6px 0 10px; }
.suggest-row {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 8px 10px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px; margin-bottom: 6px;
  font-size: 14px;
}
.suggest-row .mono { font-size: 13px; color: var(--accent); }
.suggest-row .btn { padding: 6px 14px; font-size: 14px; margin-left: auto; }

/* Дашборд */
.page-title { margin: 0; font-size: 26px; font-weight: 800; }
.panel-head .sub { margin-top: 6px; }

.kpi-strip {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px;
  margin: 22px 32px 18px;
}
.kpi-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px 22px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 4px;
}
.kpi-value { font-size: 32px; font-weight: 800; line-height: 1; }
.kpi-label { font-size: 13.5px; color: var(--muted); }

.dash-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 18px;
  margin: 0 32px 40px;
}
.dash-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 22px 24px; box-shadow: var(--shadow);
}
.dash-card h3 { margin: 0 0 16px; font-size: 16px; font-weight: 700; }

/* горизонтальные бары по типам */
.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.bar-label { flex: 0 0 190px; font-size: 13.5px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { flex: 1; height: 12px; background: var(--bg); border-radius: 6px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 6px; transition: width 0.4s ease; }
.bar-num { flex: 0 0 34px; text-align: right; font-weight: 700; font-size: 14px; }
.bar-pct { flex: 0 0 44px; text-align: right; font-size: 12px; color: var(--muted); }

/* статусы: кольцо с центром + легенда с процентами */
.dash-status-wrap { display: flex; align-items: center; gap: 30px; flex-wrap: wrap; }
.donut-wrap { position: relative; width: 150px; height: 150px; flex: 0 0 auto; }
.donut { width: 150px; height: 150px; border-radius: 50%; }
.donut::after {
  content: ""; position: absolute; inset: 34px; border-radius: 50%;
  background: var(--surface);
}
.donut-center {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2px;
}
.donut-center b { font-size: 26px; font-weight: 800; color: var(--ink); }
.donut-center span { font-size: 12px; color: var(--muted); }
.dash-legend { display: flex; flex-direction: column; gap: 9px; flex: 1; min-width: 200px; }
.legend-row { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink); }
.legend-dot { width: 12px; height: 12px; border-radius: 4px; flex: 0 0 auto; }
.legend-name { flex: 1; }
.legend-row b { font-weight: 700; }
.legend-pct { flex: 0 0 40px; text-align: right; font-size: 12px; color: var(--muted); }

/* динамика по дням */
.day-bars {
  display: flex; align-items: flex-end; gap: 6px; height: 150px;
}
.day-col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; gap: 4px; }
.day-fill { width: 100%; background: var(--accent); border-radius: 4px 4px 0 0; min-height: 2px; transition: height 0.4s ease; }
.day-label { font-size: 10px; color: var(--muted); text-align: center; }

@media (max-width: 900px) {
  .dash-grid { grid-template-columns: 1fr; }
  .kpi-strip { grid-template-columns: repeat(2, 1fr); }
}

/* Таблицы */
.table-wrap {
  margin: 0 32px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius);
  overflow-x: auto; overflow-y: hidden; box-shadow: var(--shadow);
}
table.journal { width: 100%; border-collapse: collapse; }

/* ИИ-чек: таблица широкая (7 колонок) — ужимаем, чтобы влезала на ноутбук */
#view-ai-check table.journal { min-width: 980px; }
#view-ai-check table.journal th,
#view-ai-check table.journal td { padding: 10px 12px; }
#view-ai-check td:first-child {
  max-width: 240px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#view-ai-check td.mono {
  max-width: 140px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#view-ai-check td select { max-width: 165px; }
/* ручной ввод недостающих полей в ИИ-чеке */
#view-ai-check .fields-btn { padding: 2px 8px; font-size: 12px; margin-left: 6px; }
tr.fields-row { cursor: default; }
tr.fields-row td { background: var(--accent-soft); }
.fields-edit { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 6px 2px; }
.field-edit { display: inline-flex; align-items: center; gap: 6px; }
.field-edit input {
  min-width: 220px; padding: 8px 10px; font-size: 14px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--ink);
}
/* эталоны */
.ref-form { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 10px 0; }
#ref-type { max-width: 340px; }
.ref-form select { flex: 0 1 320px; min-width: 200px; }
.ref-tools { display: flex; gap: 10px; flex-wrap: wrap; margin: 0 0 14px; }
#view-references .settings-card { max-width: 1100px; }
.ref-pick { cursor: pointer; user-select: none; display: inline-flex; align-items: center; gap: 8px; }
#ref-file-name { max-width: 420px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; vertical-align: middle; }
#ref-file-name.filled { color: var(--ink); font-weight: 600; }
.ref-form.dragover { outline: 2px dashed var(--accent); outline-offset: 6px; border-radius: 10px; }
#view-references table td.mono {
  max-width: 220px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
table.journal th, table.journal td {
  text-align: left; padding: 14px 20px;
  border-bottom: 1px solid var(--line);
}
table.journal th { color: var(--muted); font-weight: 600; font-size: 13px; text-transform: uppercase; letter-spacing: 0.4px; }
table.journal td { font-size: 15px; }
table.journal tbody tr { cursor: pointer; transition: background 0.1s; }
table.journal tbody tr:hover { background: var(--accent-soft); }
table.journal tbody tr:last-child td { border-bottom: none; }
.empty { text-align: center; color: var(--muted); padding: 44px; cursor: default; }
.mono { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 13px; }
.td-right { text-align: right; }

/* Бейджи статусов */
.badge {
  display: inline-block; padding: 4px 12px; border-radius: 20px;
  font-size: 13px; font-weight: 600;
}
.badge.ok { background: rgba(21, 128, 61, 0.12); color: var(--good); }
.badge.manual { background: var(--accent-soft); color: var(--accent); }
.badge.error { background: var(--warn-soft); color: var(--warn); }
.badge.pending { background: var(--amber-soft); color: var(--amber); }
.badge.dup { background: var(--code-bg); color: var(--muted); }

/* Заголовки панелей */
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  padding: 28px 32px 12px;
}
.panel-head .sub { margin: 0; color: var(--muted); max-width: 720px; }
.logs-actions { display: flex; gap: 10px; align-items: center; }
.logs-actions select {
  padding: 10px 14px; border: 1px solid var(--line); border-radius: 9px;
  background: var(--surface); color: var(--ink); font-size: 14px;
}

/* Терминал (логи) */
.terminal-wrap { margin: 0 32px 32px; }
.terminal {
  background: var(--term-bg); color: #c7d0dd;
  border-radius: var(--radius);
  height: 560px; overflow-y: auto;
  padding: 18px 22px;
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 13.5px; line-height: 1.7;
  border: 1px solid var(--line);
}
.term-line { white-space: pre-wrap; word-break: break-word; }
.term-time { color: #5c6675; }
.term-level { display: inline-block; width: 52px; font-weight: 700; }
.term-level.INFO { color: #4ade80; }
.term-level.WARN { color: #fbbf24; }
.term-level.ERROR { color: #f87171; }
.term-level.CRIT { color: #ff6b6b; font-weight: 800; }
.term-level.DEBUG { color: #8a93a6; }
.term-empty { color: #5c6675; text-align: center; padding: 40px; }
.terminal::-webkit-scrollbar { width: 10px; }
.terminal::-webkit-scrollbar-thumb { background: #2c3547; border-radius: 6px; }

/* Настройки */
.view { display: none; }
.view.active { display: block; }
.settings-card {
  max-width: 560px; margin: 32px auto;
  background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 32px; box-shadow: var(--shadow);
}
.settings-card h2, .rules-card h2 { margin-top: 0; font-size: 20px; font-weight: 700; }

/* Блок резервной копии: слева текст, справа вся половина — кнопка */
.backup-card {
  margin: 0 auto 32px; max-width: 760px;
  display: flex; gap: 24px; align-items: stretch;
}
.backup-left { flex: 1; min-width: 0; }
.backup-left h2 { margin-top: 0; font-size: 20px; font-weight: 700; }
.backup-left .sub { color: var(--muted); font-size: 14px; margin: 6px 0 0; }
.backup-action {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 8px;
  background: var(--accent-soft); border: 1px dashed var(--accent);
  border-radius: var(--radius); color: var(--accent);
  font-size: 16px; font-weight: 700; cursor: pointer; padding: 24px;
  transition: background 0.15s, color 0.15s, transform 0.1s, box-shadow 0.15s;
}
.backup-action:hover {
  background: var(--accent); color: #fff;
  transform: translateY(-2px); box-shadow: var(--shadow-lg);
}
.backup-action:active { transform: translateY(0); }
.backup-action small { font-size: 12px; font-weight: 500; opacity: 0.8; }
@media (max-width: 640px) {
  .backup-card { flex-direction: column; }
}

/* строка с инпутом и кнопкой (модель ИИ) */
.inline-row { display: flex; gap: 8px; margin-top: 8px; }
.inline-row input { flex: 1; }
.model-pick { margin-top: 8px !important; }
.settings-card label { display: block; margin-bottom: 18px; font-size: 14px; color: var(--muted); }
.settings-card input[type="text"],
.settings-card input[type="number"],
.settings-card select {
  width: 100%; margin-top: 8px; padding: 11px 14px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--bg);
  color: var(--ink); font-size: 15px; transition: border 0.15s, box-shadow 0.15s, background 0.15s;
}
.settings-card input:focus, .settings-card select:focus {
  outline: none; border-color: var(--accent); background: var(--surface);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.10);
}
.settings-card label.check { display: flex; align-items: center; gap: 10px; color: var(--ink); font-size: 15px; }
.settings-card label.check input { margin: 0; width: 18px; height: 18px; accent-color: var(--accent); }
.form-actions { margin-top: 10px; display: flex; align-items: center; gap: 12px; }
.form-actions .btn-primary { margin-left: auto; }

/* Папки сканирования */
.field-title { font-size: 14px; color: var(--muted); margin: 6px 0 10px; font-weight: 600; }
.folder-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; background: var(--bg); border-radius: 9px;
  margin-bottom: 8px; font-size: 14px;
}
.folder-row .path { flex: 1; word-break: break-all; }
.folder-del {
  border: none; background: transparent; color: var(--muted);
  cursor: pointer; font-size: 20px; line-height: 1; border-radius: 6px;
}
.folder-del:hover { color: var(--warn); background: var(--warn-soft); }
.add-folder { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 6px; }
.add-folder input { flex: 1; }
.add-folder-btn { margin-top: 8px; padding: 11px 18px; }

/* Редактор правил */
.rules-card {
  max-width: 960px; margin: 0 auto 48px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 32px; box-shadow: var(--shadow);
}
.rules-card .sub { color: var(--muted); margin: 6px 0 18px; font-size: 14px; }
.rule-form { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.rule-form input[type="text"] { flex: 2; min-width: 260px; }
.rule-form input[type="number"] { width: 90px; }
.rule-form select, .rule-form input {
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px;
  background: var(--bg); color: var(--ink); font-size: 14px;
}
.rule-form select:focus, .rule-form input:focus {
  outline: none; border-color: var(--accent); background: var(--surface);
}
.rules-table { margin: 0; }
.rules-table .pat { max-width: 320px; word-break: break-all; font-size: 13px; }
tr.rule-off td { opacity: 0.45; }
.switch input { width: 17px; height: 17px; accent-color: var(--accent); cursor: pointer; }

/* Карточка документа */
#detail-card { margin: 24px 32px; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.dpanel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow);
}
.dpanel h3 { margin-top: 0; font-size: 17px; font-weight: 700; }
.kv { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 9px 0; border-bottom: 1px dashed var(--line); }
.kv span:first-child { color: var(--muted); }
.kv span:last-child { text-align: right; }
.expl { margin: 8px 0; padding-left: 16px; font-size: 15px; }
.correct-form { display: flex; gap: 12px; margin-top: 18px; flex-wrap: wrap; }
.correct-form select { padding: 10px 14px; border: 1px solid var(--line); border-radius: 9px; font-size: 15px; background: var(--bg); color: var(--ink); }

/* Карточка документа: отступы от шапки и края, кнопка «К журналу» */
#view-detail { padding: 28px 32px 44px; }
#view-detail .btn-ghost { margin-bottom: 20px; }

/* Просмотр текста документа */
.text-preview {
  margin-top: 10px;
  max-height: 420px; overflow-y: auto;
  background: var(--bg); border: 1px solid var(--line);
  border-radius: 10px; padding: 16px 18px;
  white-space: pre-wrap; word-break: break-word;
  font-size: 14px; line-height: 1.6;
}
mark {
  background: var(--accent-soft); color: var(--accent);
  border-radius: 3px; padding: 0 3px; font-weight: 600;
}
.muted { color: var(--muted); font-weight: 400; font-size: 13px; }

/* Документация (wiki) */
.docs-layout {
  display: grid; grid-template-columns: minmax(0, 1fr) 260px;
  gap: 32px; padding: 32px; align-items: start;
}
.docs {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 40px 48px; box-shadow: var(--shadow);
  max-width: 900px;
}
.docs h1 { font-size: 28px; margin-top: 0; }
.docs h2 {
  font-size: 20px; margin-top: 36px; padding-top: 20px;
  border-top: 1px solid var(--line);
  scroll-margin-top: 90px;
}
.docs h1 { scroll-margin-top: 90px; }
.docs .lead { font-size: 17px; color: var(--muted); }
.docs p, .docs li { line-height: 1.65; }
.docs code {
  background: var(--code-bg); border-radius: 5px;
  padding: 2px 7px; font-size: 13.5px;
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
}
.docs .tree {
  background: var(--term-bg); color: #c7d0dd;
  border: 1px solid var(--line); border-radius: 10px;
  padding: 20px 24px; overflow-x: auto;
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 13px; line-height: 1.6;
}
.docs b { font-weight: 700; }
.toc {
  position: sticky; top: 90px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px;
  display: flex; flex-direction: column; gap: 2px;
  max-height: calc(100vh - 120px); overflow-y: auto;
}
.toc-title { font-size: 13px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); margin: 0 0 10px; font-weight: 700; }
.toc a {
  color: var(--ink); text-decoration: none; font-size: 14px;
  padding: 6px 10px; border-radius: 7px; border-left: 2px solid transparent;
}
.toc a:hover { background: var(--accent-soft); color: var(--accent); }
@media (max-width: 1100px) {
  .docs-layout { grid-template-columns: 1fr; }
  .toc { display: none; }
}

/* Главная страница */
.feature-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin: 36px auto 64px;
  max-width: 900px;
  padding: 0 32px;
}
.feature-card {
  display: flex; align-items: center; gap: 18px; text-align: left;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 22px 24px;
  cursor: pointer; font: inherit; color: inherit;
  box-shadow: var(--shadow);
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.feature-card:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
  box-shadow: var(--shadow-lg);
}
.fc-icon {
  flex: 0 0 auto; width: 46px; height: 46px;
  display: grid; place-items: center; border-radius: 12px;
  background: var(--accent-soft); color: var(--accent);
}
.fc-journal .fc-icon { color: #2563eb; }
.fc-ai .fc-icon { color: #d97706; }
.fc-analytics .fc-icon { color: #0891b2; }
.fc-settings .fc-icon { color: #059669; }
.fc-logs .fc-icon { color: #dc2626; }
.fc-docs .fc-icon { color: #7c3aed; }
.fc-body { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.fc-title { font-size: 17px; font-weight: 700; margin-bottom: 4px; }
.fc-desc { font-size: 14px; color: var(--muted); line-height: 1.5; }
.fc-arrow { color: var(--muted); font-size: 20px; transition: transform 0.15s, color 0.15s; }
.feature-card:hover .fc-arrow { transform: translateX(4px); color: var(--accent); }
@media (max-width: 760px) {
  .feature-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(3, 1fr); }
}

/* Toast */
.toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%) translateY(10px);
  background: var(--ink); color: var(--bg); padding: 13px 22px; border-radius: 11px;
  font-size: 15px; opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s;
  box-shadow: var(--shadow-lg);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* =========================================================================
   Демо-слой портфолио: воздушные блоки без рамок.
   Снимаются только контурные рамки; мягкие скругления и тени сохраняются,
   элементы управления (инпуты, селекты, кнопки) сохраняют свои границы.
   ========================================================================= */
.stat-card, .accuracy-panel, .bulk-bar, .suggest-block, .suggest-row,
.kpi-card, .dash-card, .table-wrap, .terminal, .settings-card, .rules-card,
.dpanel, .text-preview, .docs, .docs .tree, .toc, .feature-card,
.doc-preview, .backup-action {
  border: none;
  box-shadow: var(--shadow);
}
.feature-card:hover {
  transform: translateY(-3px);
  background: var(--accent-soft);
  box-shadow: var(--shadow-lg);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.backup-action:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.icon-btn:hover, .icon-btn.active { border-color: var(--line); }

/* демо-лента над шапкой */
.demo-ribbon {
  background: var(--accent-soft); color: var(--accent);
  text-align: center; font-size: 12.5px; font-weight: 600;
  letter-spacing: 0.02em; padding: 6px 14px;
}

/* выбор демо-документа в журнале */
#demo-doc {
  padding: 11px 16px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--ink); font-size: 15px;
  max-width: 300px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* панель «Обмен с 1С» в карточке — на всю ширину сетки */
.exchange-panel { grid-column: 1 / -1; }

/* длинные строки (GUID, пути, типы) не распирают карточку и сетку */
.detail-grid > * { min-width: 0; }
.dpanel { min-width: 0; }
.kv span { min-width: 0; overflow-wrap: anywhere; }
.correct-form select { flex: 1 1 220px; max-width: 100%; min-width: 0; }
.toolbar-row select, #demo-doc, .row-actions select { min-width: 0; }
.dpanel .tree {
  background: var(--term-bg); color: #c7d0dd;
  padding: 16px 18px; overflow-x: auto; margin: 8px 0 0;
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 12.5px; line-height: 1.6;
  white-space: pre-wrap; word-break: break-word;
}

/* адаптив: карточка в одну колонку, компактные отступы на мобильных */
@media (max-width: 900px) {
  .detail-grid { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  .topbar { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 14px; }
  .brand-center { order: -1; flex: 1 1 100%; justify-content: flex-start; }
  .topbar-right { margin-left: auto; gap: 8px; flex-wrap: wrap; }
  .tab { padding: 8px 10px; font-size: 14px; }
  .icon-btn { width: 34px; height: 34px; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); margin: 16px 14px 12px; gap: 10px; }
  .accuracy-panel { margin: 0 14px 10px; }
  .toolbar-row { padding: 0 14px 14px; gap: 8px; }
  .toolbar-row input[type="search"] { min-width: 0; max-width: none; flex: 1 1 100%; }
  .toolbar-row select, #demo-doc { width: 100%; max-width: 100%; flex: 1 1 100%; }
  .toolbar-actions { margin-left: 0; flex-wrap: wrap; width: 100%; }
  .bulk-bar { margin: 0 14px 10px; }
  .table-wrap { margin: 0 14px; }
  #view-detail { padding: 18px 14px 32px; }
  #detail-card { margin: 16px 0; }
  .terminal-wrap { margin: 0 14px 20px; }
  .docs-layout { padding: 18px 14px; }
  .docs { padding: 24px 18px; }
  .settings-card { margin: 20px 14px; padding: 22px 18px; }
  .rules-card { margin: 0 14px 28px; padding: 22px 18px; }
  .feature-grid { padding: 0 14px; margin: 20px auto 36px; }
  .kpi-strip { margin: 16px 14px 12px; gap: 10px; }
  .dash-grid { margin: 0 14px 24px; }
  .panel-head { margin-left: 14px; margin-right: 14px; }
}
