/* © 2026 Сергеев Антон Валентинович. Все права защищены. */
/* Единая система оформления приложений платформы (портал, Проверка РД, ППР).
   Типографика: системный гротеск; шкала 12/14/16/20/26. Интервалы: 4/8/12/16/24/32.
   Статусы различаются значком и словом, а не только цветом. Контраст текста ≥ 4.5:1. */
:root {
  --ink: #111821;      /* фирменный --surface-solid */
  --ink-2: #44506a;
  --ink-3: #5d6880;
  --line: #d8dde6;
  --bg: #f5f7fa;
  --card: #ffffff;
  --accent: #0b5f7c;   /* производный от фирменного #66d8f5, затемнён для контраста на белом (7,1:1) */
  --accent-ink: #ffffff;
  --accent-soft: #e3f5fb;
  --ok: #17703a;  --ok-bg: #e5f4ea;
  --warn: #8a5300; --warn-bg: #fff3dc;
  --bad: #b3261e; --bad-bg: #fde8e6;
  --info: #24527a; --info-bg: #e7f0f8;
  --focus: #c7a36b;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  --font: "Inter", "Segoe UI", "Roboto", "DejaVu Sans", Arial, sans-serif;
  --mono: "JetBrains Mono", "DejaVu Sans Mono", Consolas, monospace;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.5 var(--font); color: var(--ink); background: var(--bg); }
h1 { font-size: 26px; line-height: 1.25; margin: 0 0 8px; }
h2 { font-size: 20px; line-height: 1.3; margin: 24px 0 8px; }
h3 { font-size: 16px; margin: 16px 0 6px; }
p { margin: 0 0 12px; }
a { color: var(--accent); }
small, .muted { color: var(--ink-3); }
code, .mono { font-family: var(--mono); font-size: 13px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* Каркас приложения: фирменная панель (sticky) → заголовок приложения → боковая навигация + содержимое */
.appbar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 20px; background: var(--card); border-bottom: 1px solid var(--line);
  position: sticky; top: var(--ap-bar-h, 0px); z-index: 50;
}
.appbar .title { font-weight: 700; font-size: 17px; }
.appbar .title a { color: inherit; text-decoration: none; }
.appbar .ctx { color: var(--ink-2); font-size: 14px; display: inline-block; max-width: min(40vw, 420px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
.appbar .grow { flex: 1; }
.shell { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: calc(100vh - var(--ap-bar-h, 48px) - 52px); }
.side { border-right: 1px solid var(--line); background: var(--card); padding: 12px 8px; }
.side a { display: flex; gap: 8px; align-items: center; padding: 8px 12px; border-radius: 6px; color: var(--ink); text-decoration: none; }
.side a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.side a:hover { background: #eef1f6; }
.side .sep { margin: 12px 12px 4px; font-size: 12px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .04em; }
main { padding: 24px; max-width: 1280px; width: 100%; }
@media (max-width: 640px) {
  .appbar { position: static; padding: 8px 12px; gap: 8px; }
  .appbar .btn, .appbar button { min-height: 34px; padding: 4px 10px; font-size: 14px; }
  h1 { font-size: 22px; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; align-content: start; }
  .side { border-right: 0; border-bottom: 1px solid var(--line); display: flex; align-items: center; overflow-x: auto; padding: 6px; }
  .side .sep { display: none; }
  .side a { white-space: nowrap; }
  main { padding: 16px; }
}

/* Карточки и сетки */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 20px; box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.grid { display: grid; gap: 16px; }
.grid.c2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid.c4 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.stack > * + * { margin-top: 12px; }

/* Кнопки: одно основное действие на экране — .primary */
button, .btn {
  font: inherit; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 8px 16px; border-radius: 6px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink); text-decoration: none;
}
button:hover, .btn:hover { border-color: #b6bfcd; }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.primary:hover, .btn.primary:hover { filter: brightness(1.07); }
button.danger { color: var(--bad); }
button.link { border: 0; background: none; color: var(--accent); padding: 0 4px; min-height: auto; font-weight: 500; }
button:disabled { opacity: .55; cursor: not-allowed; }

/* Формы */
label { display: block; font-weight: 600; font-size: 14px; margin: 12px 0 4px; }
.hint { font-weight: 400; font-size: 13px; color: var(--ink-3); display: block; margin-top: 2px; }
input, select, textarea {
  font: inherit; width: 100%; max-width: 640px; min-height: 40px;
  padding: 8px 10px; border: 1px solid #b9c1ce; border-radius: 6px; background: #fff; color: var(--ink);
}
textarea { min-height: 96px; }
input[type=checkbox], input[type=radio] { width: auto; min-height: auto; }
.field-error { color: var(--bad); font-size: 13px; margin-top: 4px; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; margin: 12px 0; }
legend { font-weight: 700; padding: 0 6px; }
details.more > summary { cursor: pointer; color: var(--accent); font-weight: 600; margin: 8px 0; }

/* Таблицы */
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid #e7eaf0; vertical-align: top; }
th { background: #f0f3f7; font-weight: 600; position: sticky; top: 0; }
tr:hover td { background: #fafbfd; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Статусы: значок + слово + цвет */
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; border: 1px solid transparent; white-space: nowrap; }
.badge::before { font-weight: 700; }
.badge.ok { background: var(--ok-bg); color: var(--ok); border-color: #b6dcc3; }
.badge.ok::before { content: "✓"; }
.badge.warn { background: var(--warn-bg); color: var(--warn); border-color: #f0d199; }
.badge.warn::before { content: "!"; }
.badge.bad { background: var(--bad-bg); color: var(--bad); border-color: #f2b8b3; }
.badge.bad::before { content: "✕"; }
.badge.info { background: var(--info-bg); color: var(--info); border-color: #bcd3e8; }
.badge.info::before { content: "i"; }
.badge.na { background: #eef0f3; color: var(--ink-2); border-color: #d5d9e0; }
.badge.na::before { content: "?"; }

/* Пустые состояния и подсказки */
.empty { text-align: center; padding: 32px 16px; color: var(--ink-2); }
.empty h3 { color: var(--ink); }
.callout { border-left: 4px solid var(--info); background: var(--info-bg); padding: 10px 14px; border-radius: 4px; }
.callout.warn { border-color: var(--warn); background: var(--warn-bg); }
.callout.bad { border-color: var(--bad); background: var(--bad-bg); }
.term { border-bottom: 1px dotted var(--ink-3); cursor: help; }

/* Мастер: шаги */
.steps { display: flex; gap: 0; list-style: none; padding: 0; margin: 0 0 16px; flex-wrap: wrap; }
.steps li { display: flex; align-items: center; gap: 8px; padding: 6px 12px 6px 0; color: var(--ink-3); font-size: 14px; }
.steps li .n { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; border: 2px solid currentColor; font-weight: 700; font-size: 13px; }
.steps li[aria-current="step"] { color: var(--accent); font-weight: 700; }
.steps li.done { color: var(--ok); }
.steps li.done .n::after { content: "✓"; }
.steps li.done .n span { display: none; }
.steps li + li::before { content: ""; width: 20px; height: 2px; background: var(--line); margin-right: 4px; }

/* Ход длительной операции */
.progress { border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); padding: 12px 16px; }
.progress .stage { font-weight: 600; }
.progress .bar { height: 8px; background: #e7eaf0; border-radius: 4px; overflow: hidden; margin: 8px 0; }
.progress .bar > i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .3s; }
.progress .bar.indet > i { width: 30%; animation: indet 1.4s infinite ease-in-out; }
@keyframes indet { from { margin-left: -30%; } to { margin-left: 100%; } }
@media (prefers-reduced-motion: reduce) { .progress .bar.indet > i { animation: none; width: 100%; opacity: .4; } }

/* Уведомления: ниже фирменной панели, не перекрывают её */
.toast-area { position: fixed; right: 16px; bottom: 84px; z-index: 60; display: grid; gap: 8px; max-width: min(520px, calc(100vw - 32px)); }
.toast { background: var(--ink); color: #fff; padding: 10px 14px; border-radius: 6px; box-shadow: var(--shadow); display: flex; gap: 12px; align-items: center; }
.toast button { min-height: 28px; min-width: 28px; padding: 2px 10px; background: transparent; color: #fff; border-color: #6b7690; }

/* Модальное окно начинается ниже фирменной панели */
.modal { position: fixed; left: 0; right: 0; bottom: 0; top: var(--ap-bar-h, 0px); background: rgba(16,24,40,.45); display: grid; place-items: center; z-index: 70; padding: 16px; }
.modal[hidden] { display: none; }
.modal .box { background: var(--card); border-radius: var(--radius); max-width: 720px; width: 100%; max-height: 100%; overflow: auto; padding: 20px 24px; }

/* Просмотр листа с выделением замечаний */
.viewer { position: relative; background: #3b4252; border-radius: var(--radius); overflow: auto; max-height: 75vh; }
.viewer .page { position: relative; margin: 12px auto; width: fit-content; }
.viewer img { display: block; max-width: none; background: #fff; }
.viewer .hl { position: absolute; border: 3px solid var(--bad); background: rgba(179,38,30,.12); border-radius: 2px; }
.viewer .hl.warn { border-color: #d98a00; background: rgba(217,138,0,.12); }
.viewer .hl.active { box-shadow: 0 0 0 4px rgba(240,164,0,.7); }
.viewer .hl .tag { position: absolute; top: -22px; left: -3px; background: var(--bad); color: #fff; font-size: 11px; font-weight: 700; padding: 1px 5px; border-radius: 3px; white-space: nowrap; }
.viewer.full { position: fixed; left: 0; right: 0; bottom: 0; top: var(--ap-bar-h, 32px); max-height: none; z-index: 65; border-radius: 0; }
.viewer-tools { position: sticky; top: 0; left: 0; z-index: 2; display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 8px; background: rgba(17,24,33,.9); align-items: center; }
.viewer-tools button { min-height: 32px; padding: 4px 10px; background: #fff; white-space: nowrap; font-size: 13px; }
.viewer-tools .zoomlbl { color: #fff; font-size: 13px; white-space: nowrap; }
.split { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); gap: 16px; align-items: start; }
.split > * { min-width: 0; }
@media (max-width: 1100px) { .split { grid-template-columns: minmax(0, 1fr); } }

/* Подсказка к результату: обращение к Apollonian — спокойно, не мешает основным действиям */
.ap-help { border: 1px dashed #b8c3d6; border-radius: var(--radius); padding: 12px 16px; background: #fbfcfe; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; font-size: 14px; }
.ap-help .t { flex: 1 1 260px; color: var(--ink-2); }
.ap-help a { font-weight: 600; }

/* Публичные страницы портала */
.hero { padding: 32px 24px 8px; max-width: 1200px; margin: 0 auto; }
.hero h1 { font-size: 30px; }
.hero p.lead { font-size: 17px; color: var(--ink-2); max-width: 70ch; }
.dirs { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); padding: 16px 24px; max-width: 1200px; margin: 0 auto; }
.dir { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; display: flex; flex-direction: column; gap: 8px; }
.dir h2 { margin: 0; font-size: 19px; }
.dir ul { margin: 0; padding-left: 18px; color: var(--ink-2); font-size: 14px; }
.dir .go { margin-top: auto; }
.page-narrow { max-width: 460px; margin: 32px auto; padding: 0 16px; }
.footer { color: var(--ink-3); font-size: 13px; padding: 24px; text-align: center; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media print { .appbar, .side, .ap-help, .toast-area { display: none !important; } main { padding: 0; } }

/* Зона загрузки файлов */
.drop { border: 2px dashed #b9c1ce; border-radius: 8px; padding: 20px; text-align: center; background: #fbfcfe; }
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
