/* ============================================================
   Оценка профессиональных рисков — дизайн-система веб-версии
   Токены: инженерный стиль (охрана труда), поверх Bootstrap 5.
   Сигнатура: «риск-светофор» — цветовая индикация уровня риска.
   ============================================================ */

@font-face {
  font-family: 'Inter'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('/static/vendor/fonts/inter-latin-400-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+2000-206F;
}
@font-face {
  font-family: 'Inter'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('/static/vendor/fonts/inter-cyrillic-400-normal.woff2') format('woff2');
  unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'Inter'; font-style: normal; font-weight: 500; font-display: swap;
  src: url('/static/vendor/fonts/inter-latin-500-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+2000-206F;
}
@font-face {
  font-family: 'Inter'; font-style: normal; font-weight: 500; font-display: swap;
  src: url('/static/vendor/fonts/inter-cyrillic-500-normal.woff2') format('woff2');
  unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'Inter'; font-style: normal; font-weight: 600; font-display: swap;
  src: url('/static/vendor/fonts/inter-latin-600-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+2000-206F;
}
@font-face {
  font-family: 'Inter'; font-style: normal; font-weight: 600; font-display: swap;
  src: url('/static/vendor/fonts/inter-cyrillic-600-normal.woff2') format('woff2');
  unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

:root {
  --ink:        #1d2733;   /* основной текст */
  --ink-soft:   #5b6673;   /* вторичный текст */
  --canvas:     #eef1f5;   /* фон приложения */
  --surface:    #ffffff;   /* карточки/панели */
  --surface-2:  #f6f8fa;   /* вторичные панели, шапка таблицы */
  --hover:      #f2f5f8;   /* фон при наведении */
  --row-hover:  #fafbfc;   /* наведение на строку таблицы */
  --line:       #dfe4ea;   /* границы */
  --line-soft:  #edf0f3;   /* тонкие линии таблиц */
  --rail:       #298dcb;   /* сайдбар/шапка — фирменный синий */
  --rail-ink:   #ffffff;
  --accent:     #0e6e8c;   /* действия/ссылки: стальной сине-бирюзовый */
  --accent-ink: #0a566e;
  --risk-low:   #2a8a2a;   /* палитра риска — из core.calculations */
  --risk-mid:   #c98a1e;
  --risk-high:  #c04040;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 30, 44, .06), 0 4px 14px rgba(16, 30, 44, .05);
  --tbl-border: 1px;       /* толщина линий столбцов/строк — настраивается в «Оформлении» */
  --tbl-stripe: #f4f6f8;   /* цвет чётных строк при чередовании */
}

/* ── Тёмная тема: переопределяем токены; остальное наследуется ── */
html.theme-dark {
  --ink:        #e6ebf0;
  --ink-soft:   #9aa7b4;
  --canvas:     #0f151c;
  --surface:    #182029;
  --surface-2:  #1f2833;
  --hover:      #243040;
  --row-hover:  #1e2732;
  --line:       #2b3743;
  --line-soft:  #263039;
  --rail:       #0b1219;
  --rail-ink:   #aab6c2;
  --accent:     #38a9c9;
  --accent-ink: #55bcd9;
  --tbl-stripe: #1c2530;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 14px rgba(0,0,0,.35);
}
html.theme-dark .risk-mid  { background: #3a2f14; }
html.theme-dark .risk-high { background: #3a2020; }
html.theme-dark .risk-low  { background: #16301c; }
html.theme-dark .notice.ok { background: #16301c; }
html.theme-dark input, html.theme-dark select, html.theme-dark textarea {
  background: var(--surface-2); color: var(--ink); border-color: var(--line);
}
html.theme-dark .btn.gray { background: var(--surface-2); color: var(--ink); border-color: var(--line); }
html.theme-dark .btn.gray:hover { background: var(--hover); }

/* ВАЖНО: min-height, НЕ height! height:100% ограничивал высоту <html>/<body>
   ТОЧНО высотой окна просмотра, вместо того чтобы расти по содержимому —
   из-за этого на длинных страницах (например, РМ с полусотней опасностей)
   при активной прокрутке «прилипающие» элементы (шапка сайта, хлебные
   крошки, панель действий РМ, заголовок таблицы — все на position:sticky)
   в какой-то момент переставали быть прижатыми к верху и просто уезжали
   вместе со страницей, оставляя пустой провал наверху экрана. min-height
   даёт ТОТ ЖЕ эффект на коротких страницах (растягивает фон на весь экран),
   но не мешает контейнеру расти на длинных. */
html, body { min-height: 100%; }
body {
  font-family: 'Inter', -apple-system, 'Segoe UI', Arial, sans-serif;
  background: var(--canvas); color: var(--ink);
  font-size: 14px; letter-spacing: .002em;
}
h1, h2, h3, h4, .h4, .h5 { font-weight: 600; letter-spacing: -.012em; color: var(--ink); }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-ink); }

/* ── Каркас: верхняя навигация + дерево проекта слева ─────────── */
.topnav {
  background: var(--rail); color: var(--rail-ink);
  display: flex; align-items: center; gap: 4px;
  padding: 0 18px; height: 52px;
  position: sticky; top: 0; z-index: 1000;
}
.topnav .brand {
  display: flex; align-items: center; gap: 9px; color: #fff;
  font-weight: 600; font-size: 14px; margin-right: 18px; white-space: nowrap;
}
.topnav .brand .bi { font-size: 19px; color: #6fd0e8; }
.topnav a.nav-link {
  color: var(--rail-ink); font-size: 13.5px; padding: 6px 12px;
  border-radius: 7px; display: inline-flex; align-items: center; gap: 7px;
  white-space: nowrap;
}
.topnav a.nav-link:hover { color: #fff; background: rgba(255,255,255,.07); }
.topnav a.nav-link.active { color: #fff; background: rgba(111,208,232,.14); }
.topnav .spacer { flex: 1; }
.topnav .who { color: #fff; font-size: 13px; white-space: nowrap; }
.topnav .who a { color: var(--rail-ink); margin-left: 10px; }
.topnav .who a:hover { color: #fff; }

.subbar {
  min-height: 42px; background: var(--surface); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 6px 18px; position: sticky; top: 52px; z-index: 900;
}
.subbar .breadcrumb { margin: 0; font-size: 12.5px; --bs-breadcrumb-divider: '›'; flex-wrap: nowrap; }
.subbar .breadcrumb-item { max-width: 420px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
.subbar .breadcrumb-item a { display: inline-block; max-width: 100%; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
.subbar nav { min-width: 0; overflow: hidden; }
.subbar .toolbar { flex-shrink: 0; margin-left: auto; }

.content { padding: 18px; max-width: 1500px; width: 100%; margin: 0 auto; }

/* Двухколоночный режим: дерево проекта + рабочая область */
.workspace { display: flex; gap: 18px; align-items: flex-start; }
.tree {
  width: 272px; flex: 0 0 272px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  position: sticky; top: 106px;
  max-height: calc(100vh - 122px); overflow-y: auto;
  padding: 10px 8px; font-size: 13px;
}
.tree .tree-org {
  display: flex; align-items: center; gap: 8px; padding: 6px 10px 10px;
  font-weight: 600; border-bottom: 1px solid var(--line); margin-bottom: 6px;
  color: var(--ink);
}
.tree details { margin: 1px 0; }
.tree details > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 6px;
  padding: 5px 8px; border-radius: 7px; font-weight: 500; color: var(--ink);
}
.tree details > summary::-webkit-details-marker { display: none; }
.tree details > summary:hover { background: var(--hover); }
.tree details > summary .chev { transition: transform .12s ease; font-size: 11px; color: var(--ink-soft); }
.tree details[open] > summary .chev { transform: rotate(90deg); }
.tree .tree-count { margin-left: auto; color: var(--ink-soft); font-weight: 400; font-size: 11.5px; }
.tree a.tree-wp {
  display: flex; align-items: center; gap: 7px;
  padding: 4px 8px 4px 26px; border-radius: 7px; color: var(--ink);
}
.tree a.tree-wp:hover { background: var(--hover); }
.tree a.tree-wp.active { background: rgba(14,110,140,.10); color: var(--accent-ink); font-weight: 500; }
.tree .dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 8px; background: #cdd5dd; }
.tree .dot.st-assessed { background: #22c55e; }  /* совпадает с ●Оценены в фильтре */
.tree .dot.st-partial  { background: #e07b00; }  /* совпадает с ◑Не оценены в фильтре */
.tree .dot.st-empty    { background: #aaa; }     /* совпадает с ○Пустые в фильтре */
.tree .wp-num { color: var(--ink-soft); font-variant-numeric: tabular-nums; font-size: 11.5px; flex: 0 0 auto; white-space: nowrap; padding-right: 2px; }
.tree .tree-sub { margin-left: 14px; border-left: 1px solid #e7ebf0; padding-left: 4px; }
.tree .tree-foot { margin-top: 8px; padding: 8px 10px 2px; border-top: 1px solid var(--line); }
.workpane { flex: 1; min-width: 0; }

@media (max-width: 1000px) {
  .workspace { flex-direction: column; }
  .tree { position: static; width: 100%; flex: none; max-height: 300px; }
  .topnav { overflow-x: auto; }
}

/* ── Панели ────────────────────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px 20px; margin-bottom: 18px;
}
.card h2 { font-size: 16.5px; margin: 0 0 12px; }
.card h3 { font-size: 14.5px; }

/* Плитки-метрики */
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat .num { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat .lbl { font-size: 12px; color: var(--ink-soft); }

/* ── Таблицы ───────────────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; color: var(--ink); }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line-soft); font-size: 13.5px; vertical-align: middle; color: var(--ink); }
th { background: var(--surface-2); color: var(--ink-soft); font-weight: 500; font-size: 12px; letter-spacing: .02em; white-space: nowrap; }
tr:hover > td { background: var(--row-hover); }
td.num, .tnum { font-variant-numeric: tabular-nums; }

/* ── Риск-светофор (сигнатура) ─────────────────────────────────── */
.kb-badge { display:inline-flex; align-items:center; gap:6px; font-size:12px; font-weight:400; color:var(--kb-mark,#b5820a); margin-left:8px; }
.risk-badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 500; padding: 2px 9px 2px 7px;
  border-radius: 999px; white-space: nowrap;
}
.risk-badge::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.risk-low   { color: var(--risk-low);  background: #e6f4e6; }
.risk-mid   { color: #96660e;          background: #fbf1dd; }
.risk-high  { color: var(--risk-high); background: #f9e7e7; }
tr.rl-Высокий > td:first-child { box-shadow: inset 3px 0 0 var(--risk-high); }
tr.rl-Средний > td:first-child { box-shadow: inset 3px 0 0 var(--risk-mid); }
tr.rl-Низкий  > td:first-child { box-shadow: inset 3px 0 0 var(--risk-low); }

/* ── Кнопки (легаси-классы перекрашены под новую систему) ─────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--accent); color: #fff; border: 1px solid transparent;
  padding: 7px 14px; border-radius: 8px; font-size: 13.5px; font-weight: 500;
  cursor: pointer; text-decoration: none; line-height: 1.3;
}
.btn:hover { background: var(--accent-ink); color: #fff; }
.btn:focus-visible { outline: 2px solid #6fd0e8; outline-offset: 2px; }
.btn.green { background: #2f8a4c; } .btn.green:hover { background: #256e3c; }
.btn.red   { background: #c04040; } .btn.red:hover { background: #a03434; }
.btn.gray  {
  background: var(--surface); color: var(--ink); border-color: var(--line);
}
.btn.gray:hover { background: var(--hover); color: var(--ink); }
.btn.small { padding: 4px 10px; font-size: 12.5px; border-radius: 7px; }

input[type=text], input[type=password], input[type=number], select, textarea {
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px;
  font-size: 13.5px; font-family: inherit; background: var(--surface); color: var(--ink);
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(14,110,140,.12);
}

/* ── Служебные ─────────────────────────────────────────────────── */
.muted { color: var(--ink-soft); font-size: 12.5px; }
.error {
  color: #8a2626; background: #fdecec; border: 1px solid #f0c2c2;
  border-radius: 8px; padding: 9px 13px; margin-bottom: 14px; font-size: 13.5px;
}
.notice {
  background: #fff7e8; border: 1px solid #ecc98a; border-radius: 8px;
  padding: 10px 14px; margin-bottom: 16px; color: #7c5a10; font-size: 13.5px;
}
.notice.ok { background: #e9f5eb; border-color: #9ecfaa; color: #1f6b33; }

/* Подсказка мастера первого запуска ("сделай сам" на настоящем интерфейсе) */
.demo-hint {
  background: linear-gradient(135deg, #eef2fb, #f5eefb); border: 1px solid #b9c8ee;
  border-radius: 10px; margin-bottom: 16px; padding: 12px 16px;
}
.demo-hint-inner { display: flex; align-items: flex-start; gap: 10px; }
.demo-hint-inner > i { color: #5a4fc4; font-size: 17px; margin-top: 1px; flex-shrink: 0; }
.demo-hint-text { flex: 1; font-size: 13.5px; color: #2a2a5a; line-height: 1.5; }
.demo-hint-close {
  background: none; border: none; font-size: 18px; line-height: 1; color: #8a8ac0; cursor: pointer;
  padding: 0 4px; flex-shrink: 0;
}
.demo-hint-close:hover { color: #2a2a5a; }
html.theme-dark .demo-hint { background: linear-gradient(135deg, #1c2440, #2a1c40); border-color: #3a3a7a; }
html.theme-dark .demo-hint-text { color: #d0d0f5; }

/* ── Пошаговые подсказки демо-тура (demo-tour.js) ── */
.dt-overlay { position: fixed; inset: 0; background: rgba(10,12,20,.45); z-index: 9998; pointer-events: none; }
.dt-spot {
  position: relative; z-index: 9999;
  outline: 3px solid #5a4fc4; outline-offset: 3px; border-radius: 8px;
  box-shadow: 0 0 0 6000px rgba(10,12,20,.45);
  animation: dtPulse 1.6s ease-in-out infinite;
}
@keyframes dtPulse { 0%,100% { outline-color: #5a4fc4; } 50% { outline-color: #8a7fe0; } }
.dt-box {
  position: absolute; z-index: 10000; width: 300px; background: #fff; border-radius: 12px;
  box-shadow: 0 16px 40px -12px rgba(0,0,0,.4); padding: 14px 16px; font-size: 13.5px;
}
.dt-box.dt-above { transform: translateY(-100%) translateY(-16px); }
.dt-box-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.dt-box-dot { font-family: 'IBM Plex Mono', monospace; font-size: 11px; color: #5a4fc4; font-weight: 700; background: #eef2fb; padding: 2px 8px; border-radius: 20px; }
.dt-box-skip { background: none; border: none; color: #999; font-size: 11.5px; cursor: pointer; padding: 0; }
.dt-box-skip:hover { color: #666; }
.dt-box h4 { font-size: 14.5px; margin: 4px 0 6px; color: #1a1a3a; }
.dt-box p { margin: 0 0 12px; color: #444; line-height: 1.5; }
.dt-box-next { background: #5a4fc4; color: #fff; border: none; border-radius: 8px; padding: 8px 16px; font-size: 13px; font-weight: 600; cursor: pointer; width: 100%; }
.dt-box-next:hover { background: #4a3fb4; }
html.theme-dark .dt-box { background: #1c2233; }
html.theme-dark .dt-box h4 { color: #f0f0ff; }
html.theme-dark .dt-box p { color: #b8bdd0; }

.dt-replay-btn {
  position: fixed; bottom: 20px; right: 20px; z-index: 500;
  background: #5a4fc4; color: #fff; border: none; border-radius: 24px; padding: 10px 18px;
  font-size: 13px; font-weight: 600; cursor: pointer; box-shadow: 0 8px 20px -8px rgba(90,79,196,.6);
  display: none; align-items: center; gap: 7px;
}
.dt-replay-btn:hover { background: #4a3fb4; }

.dt-toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: #1a1a2e; color: #fff; padding: 12px 20px; border-radius: 10px; font-size: 13.5px;
  z-index: 10001; opacity: 0; transition: opacity .3s, transform .3s;
}
.dt-toast.in { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── «Книжка» — постраничный просмотр примеров документов (демо) ── */
.doc-book { position: relative; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #f3f3f3; margin-bottom: 14px; max-width: 100%; box-shadow: 0 10px 30px -14px rgba(0,0,0,.25); }
.doc-book-img { width: 100%; display: block; }
.doc-book-nav {
  position: absolute; top: 0; bottom: 0; width: 46px; display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,.72); border: none; cursor: pointer; font-size: 24px; color: #333; transition: background .15s;
}
.doc-book-nav:hover { background: rgba(255,255,255,.92); }
.doc-book-nav:disabled { opacity: .25; cursor: default; }
.doc-book-nav.prev { left: 0; }
.doc-book-nav.next { right: 0; }
.doc-book-counter {
  position: absolute; bottom: 6px; left: 50%; transform: translateX(-50%);
  background: rgba(20,20,30,.65); color: #fff; font-size: 11px; padding: 2px 9px; border-radius: 20px;
  font-family: 'IBM Plex Mono', monospace;
}
html.theme-dark .doc-book { background: #22262e; }

/* ── Модалка выбора (askChoice) — замена уродливых confirm() ── */
.choice-modal-backdrop {
  position: fixed; inset: 0; background: rgba(15,18,25,.5); z-index: 5000;
  align-items: center; justify-content: center;
}
.choice-modal {
  background: var(--surface, #fff); border-radius: 14px; padding: 24px 26px; max-width: 380px; width: 92%;
  position: relative; box-shadow: 0 20px 50px -15px rgba(0,0,0,.4);
}
.choice-modal-close {
  position: absolute; top: 10px; right: 12px; background: none; border: none; font-size: 20px;
  color: var(--muted, #8a94a3); cursor: pointer; line-height: 1;
}
.choice-modal-close:hover { color: var(--ink, #222); }
.choice-modal-title { font-size: 16.5px; margin: 0 0 8px; padding-right: 20px; }
.choice-modal-text { font-size: 13.5px; margin: 0 0 18px; line-height: 1.5; }
.choice-modal-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.choice-modal-actions .btn { flex: 1; min-width: 120px; justify-content: center; }
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 500; color: white; }
.badge.ok { background: #2f8a4c; } .badge.no { background: #8b95a1; } .badge.blocked { background: #c04040; }

.auth-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #14202b 0%, #1c3242 55%, #0e6e8c 130%);
}
.auth-box {
  width: 400px; max-width: 92vw; background: var(--surface);
  border-radius: 14px; padding: 28px 30px; box-shadow: 0 18px 50px rgba(5,15,25,.35);
}
.auth-box h2 { text-align: center; font-size: 17px; margin: 4px 0 18px; }
.auth-brand { text-align: center; color: var(--accent); font-size: 30px; }
/* ── Индикатор загрузки (полоска сверху при переходах/запросах) ── */
#loadingBar {
  position: fixed; top: 0; left: 0; height: 3px; width: 0%;
  background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 40%, #fff));
  z-index: 3000; opacity: 0; transition: width .3s ease, opacity .2s ease;
  pointer-events: none;
}
#loadingBar.active { opacity: 1; }

.form-row { margin-bottom: 12px; }
.form-row label { display: block; font-size: 12.5px; color: var(--ink-soft); margin-bottom: 4px; }
.form-row input, .form-row select { width: 100%; }

/* ── Показать/скрыть пароль (вход, регистрация) ── */
.pwd-wrap { position: relative; }
.pwd-wrap input { width: 100%; padding-right: 38px; }
.pwd-toggle {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer; padding: 6px;
  color: var(--ink-soft); line-height: 1; border-radius: 6px;
}
.pwd-toggle:hover { background: var(--hover); color: var(--ink); }

/* Инлайн-раскрытия вместо всплывающих окон */
details.inline-panel { margin: 6px 0; }
details.inline-panel > summary {
  cursor: pointer; list-style: none; display: inline-flex;
}
details.inline-panel > summary::-webkit-details-marker { display: none; }
details.inline-panel[open] > .panel-body {
  margin-top: 8px; padding: 12px; background: var(--surface-2);
  border: 1px solid var(--line); border-radius: 8px;
}

/* Дерево подразделений */
.dept-block {
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); padding: 14px 16px; margin: 12px 0;
}
.dept-block .dept-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.dept-block .dept-head h3 { margin: 0; font-size: 14.5px; display: flex; align-items: center; gap: 8px; }
.dept-count { color: var(--ink-soft); font-weight: 400; font-size: 12.5px; }
.dept-sub { margin-left: 22px; border-left: 2px solid #e7ebf0; padding-left: 14px; }

.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.org-tile { display: block; color: inherit; }
.org-tile .card { margin-bottom: 0; height: 100%; transition: border-color .12s ease, box-shadow .12s ease; }
.org-tile:hover .card { border-color: var(--accent); box-shadow: 0 6px 20px rgba(14,110,140,.13); }

/* Меню действий в дереве — видно при наведении, не перегружает */
.tree .tree-actions { margin-left: 4px; }
.tree .tree-dots {
  border: none; background: transparent; color: var(--ink-soft);
  padding: 0 4px; border-radius: 5px; opacity: 0; font-size: 13px;
}
.tree details > summary:hover .tree-dots { opacity: 1; }
.tree .tree-dots:hover { background: #e6ebf0; color: var(--ink); }

/* Галочки у мер и мест — компактные, по образцу настольной версии */
input.ichk { width: 13px; height: 13px; vertical-align: -2px; margin-right: 4px; accent-color: var(--accent); }

/* Меры управления — без маркеров-точек */
td ul { list-style: none; padding-left: 0 !important; margin: 0; }
td ul li { margin-bottom: 3px; }

/* Лёгкое разделение столбцов в таблицах */
/* Разделители столбцов — только по переключателю «Разделять столбцы»,
   цветом --line (виден и поверх зебры, в светлой и тёмной теме) */
html.colsep table th + th, html.colsep table td + td {
  border-left: var(--tbl-border) solid var(--line);
}
table th, table td { padding-left: 10px; padding-right: 10px; }

/* Дубликаты в дереве проекта */
.dup-banner { display:flex; align-items:center; gap:6px 8px; justify-content:space-between;
    flex-wrap:wrap;
    margin:0 6px 8px; padding:6px 10px; background:#fff4e5; border:1px solid #f0c890;
    border-radius:8px; color:#8a5000; font-size:12px; font-weight:600; }
.dup-banner .btn { flex-shrink:0; }
.dup-banner > span:first-child { min-width:0; overflow-wrap:break-word; }
.tree-wp .dup-mark { margin-left:auto; color:#c0392b; font-size:12px; flex-shrink:0; }
.tree.dup-only .tree-wp:not(.has-dup) { display:none; }
/* Отметка «заполнено из базы знаний» */
.tree a.tree-wp.from-kb { border-left: 3px solid var(--kb-mark, #b5820a); }
.tree-wp .kb-mark { margin-left:4px; color:#fff; background:var(--kb-mark,#b5820a); font-size:9px; font-weight:700; padding:0 3px; border-radius:3px; flex-shrink:0; }
.tree.kb-only .tree-wp:not(.from-kb) { display:none; }
/* Фильтр по статусу оценки */
.tree.stf-assessed .tree-wp:not(.st-assessed) { display:none; }
.tree.stf-partial  .tree-wp:not(.st-partial)  { display:none; }
.tree.stf-empty    .tree-wp:not(.st-empty)    { display:none; }
.tree-status-filter { display:flex; gap:4px; padding:0 6px 6px; flex-wrap:wrap; }
.tree-status-filter button { flex:1; font-size:10.5px; padding:2px 4px; border:1px solid var(--line); background:var(--surface); border-radius:5px; cursor:pointer; color:var(--ink-soft); white-space:nowrap; }
.tree-status-filter button.on { background:var(--accent); color:#fff; border-color:var(--accent); }
.tree-status-filter .stdot { font-size:11px; }
.stdot-assessed { color:#22c55e; } .stdot-partial { color:#e07b00; } .stdot-empty { color:#aaa; }

/* ── Логотип в шапке ── */
.brand-logo { height: 22px; width: 22px; vertical-align: -5px; margin-right: 4px; border-radius: 4px; }

/* ── Настраиваемое оформление таблиц (раздел «Оформление») ── */
th, td { border-bottom: var(--tbl-border) solid var(--line); }
table.grid, table.cols { border-collapse: collapse; }
/* вертикальные разделители столбцов, если включена ширина > 0 */
/* чередование строк «бело-серое» */
html.zebra tbody tr:nth-child(even) > td,
html.zebra table tr:nth-child(even) > td { background: var(--tbl-stripe); }
html.zebra table tr:hover > td { background: var(--hover); }

/* ── Заметнее инлайновые действия в таблицах опасностей (изменить/выбрать/+мера) ── */
.row-action {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; font-size: 12px; line-height: 1.4;
  border: 1px solid var(--line); border-radius: 6px;
  background: var(--surface-2); color: var(--accent-ink); font-weight: 500;
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
.row-action:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.row-action.add   { color: #256e3c; }
.row-action.add:hover { background: #2f8a4c; color: #fff; border-color: #2f8a4c; }

/* убрать маркер-треугольник у inline-панелей с кнопками (изменить/выбрать/+мера) */
details.inline-panel > summary { list-style: none; cursor: pointer; }
details.inline-panel > summary::-webkit-details-marker { display: none; }
details.inline-panel > summary::marker { content: ""; }

/* ── «Мои организации» — список с раскрытием ── */
.org-list { display: flex; flex-direction: column; gap: 6px; }
.org-row { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.org-row > summary {
  display: flex; align-items: center; gap: 14px; padding: 11px 16px; cursor: pointer;
  list-style: none;
}
.org-row > summary::-webkit-details-marker { display: none; }
.org-row > summary:hover { background: var(--hover); border-radius: var(--radius); }
.org-row-main { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.org-row-name { font-weight: 600; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.org-row-inn { font-size: 12px; }
.org-row-mini { font-size: 12.5px; white-space: nowrap; }
.org-row-chev { color: var(--ink-soft); transition: transform .15s ease; flex-shrink: 0; }
.org-row[open] > summary .org-row-chev { transform: rotate(180deg); }
.org-row[open] > summary { border-bottom: 1px solid var(--line); }
.org-row-body { padding: 14px 16px; }
@media (max-width: 640px) { .org-row-mini { display: none; } }

/* ── Карточки готовых тем и цвета («Оформление») ── */
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
/* Нативные <input type="color"> в браузере по умолчанию — острый
   прямоугольник, что не сочетается с общим скруглённым стилем сайта
   (карточки, кнопки — везде var(--radius)). Скругляем и добавляем рамку. */
input[type="color"] {
  border-radius: 8px; border: 1px solid var(--line); padding: 2px;
  background: var(--surface); cursor: pointer;
}
input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; border-radius: 6px; overflow: hidden; }
input[type="color"]::-webkit-color-swatch { border: none; border-radius: 6px; }
input[type="color"]::-moz-color-swatch { border: none; border-radius: 6px; }

.theme-card {
  text-align: left; padding: 0; border: 2px solid var(--line); border-radius: 12px;
  background: var(--surface); cursor: pointer; overflow: hidden; transition: border-color .12s, box-shadow .12s;
}
.theme-card:hover { border-color: var(--accent); }
.theme-card.active { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.theme-card-preview {
  position: relative; height: 96px; padding: 12px; background: #eef1f5;
  display: block; border-bottom: 1px solid var(--line);
}
.theme-card.dark .theme-card-preview { background: #0f151c; }
.theme-card-preview .tc-bar   { position:absolute; top:12px; left:12px; right:52px; height:10px; border-radius:4px; background:#cfd8e0; }
.theme-card.dark .theme-card-preview .tc-bar { background:#2b3743; }
.theme-card-preview .tc-line  { position:absolute; top:34px; left:12px; width:70px; height:8px; border-radius:4px; background:#d7dee5; }
.theme-card.dark .theme-card-preview .tc-line { background:#243040; }
.theme-card-preview .tc-accent{ position:absolute; top:52px; left:12px; right:52px; height:16px; border-radius:4px; background:var(--pa); opacity:.9; }
.theme-card-preview .tc-side  { position:absolute; top:34px; right:12px; width:30px; bottom:12px; border-radius:6px; background:#e5eaef; }
.theme-card.dark .theme-card-preview .tc-side { background:#1f2833; }
.theme-card-foot { display:flex; align-items:center; gap:7px; padding:9px 12px; font-size:13px; font-weight:500; color:var(--ink); background:var(--surface); }
.theme-card-foot .tc-dot { width:12px; height:12px; border-radius:50%; flex-shrink:0; }
.theme-card-foot .tc-active { margin-left:auto; font-size:11px; font-weight:600; color:var(--accent-ink); }
.theme-card.dark .theme-card-foot { background:#182029; color:#e6ebf0; }

/* логотип на экранах входа/регистрации */
.auth-brand .auth-logo { width: 56px; height: 56px; border-radius: 12px; box-shadow: 0 2px 8px rgba(16,30,44,.15); }

/* ── Тёмная тема: гарантируем читаемость текста, который красит Bootstrap ── */
html.theme-dark body,
html.theme-dark table, html.theme-dark td,
html.theme-dark .breadcrumb-item, html.theme-dark .breadcrumb-item.active,
html.theme-dark p, html.theme-dark li, html.theme-dark label,
html.theme-dark h1, html.theme-dark h2, html.theme-dark h3, html.theme-dark h4 { color: var(--ink); }
html.theme-dark th { color: var(--ink-soft); }
html.theme-dark .breadcrumb-item a, html.theme-dark a { color: var(--accent-ink); }
html.theme-dark .muted { color: var(--ink-soft); }
html.theme-dark .card { background: var(--surface); border-color: var(--line); }
html.theme-dark .subbar, html.theme-dark .topnav { background: var(--rail); }
html.theme-dark .notice.ok { background:#16301c; border-color:#2f6b3a; color:#8fd6a0; }
html.theme-dark .theme-card-preview { border-color: var(--line); }

/* ── Закреплённая панель действий (страница РМ, «меры без ответственного») ── */
.sticky-actions {
  /* top был равен top у .subbar (52px = только высота .topnav) — обе
     полосы «прилипали» на ОДНОЙ и той же высоте, и .subbar (z-index:900)
     перекрывала .sticky-actions (z-index:40) при прокрутке, из-за чего
     панель визуально «пропадала». Нужно опуститься НИЖЕ .subbar — под
     .topnav (52px) и .subbar (~68px) вместе. */
  position: sticky; top: 120px; z-index: 40;
  margin-bottom: 12px;
  box-shadow: 0 2px 8px rgba(16,30,44,.08);
}
html.theme-dark .sticky-actions { box-shadow: 0 2px 10px rgba(0,0,0,.5); }

/* ── Закреплённый заголовок таблицы опасностей (страница РМ) ──────────────
   Закрепляем на <th>, а не на <tr> — sticky на самой строке ненадёжно
   работает в части браузеров, а на отдельных ячейках — стабильно везде.
   top = высота .topnav (52) + .subbar (68) + .sticky-actions (~80) — то
   есть заголовок таблицы «прилипает» сразу под панелью действий РМ,
   которая сама уже прилипла под хлебными крошками. */
.sticky-thead th {
  position: sticky; top: var(--thead-top, 200px); z-index: 30;
  background: var(--surface); box-shadow: 0 1px 0 var(--line);
}
html.theme-dark .sticky-thead th { background: var(--surface); }
/* Скруглённые верхние углы карточки раньше держались на overflow:hidden —
   но overflow:hidden ломает position:sticky (обрезает элемент по границе
   контейнера при прокрутке), поэтому убрали его с карточки таблицы и
   скругляем угол персонально у крайних ячеек шапки. */
#risksTableCard { border-radius: var(--radius); }
.sticky-thead th:first-child { border-top-left-radius: var(--radius); }
.sticky-thead th:last-child { border-top-right-radius: var(--radius); }

/* ── Автоподбор ОК-016 в карточке РМ ── */
.ok016-suggest {
  position: absolute; left: 0; right: 0; top: 100%; z-index: 60;
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: var(--shadow); max-height: 280px; overflow-y: auto; margin-top: 2px;
}
.ok016-item { padding: 6px 12px; cursor: pointer; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ok016-item:hover { background: var(--hover); }

/* ── Тёмная тема: контраст кнопок и выпадающих меню ── */
/* на ярком акценте белый текст «замыливается» — делаем тёмный, чёткий */
html.theme-dark .btn { color: #0b1219; font-weight: 600; }
html.theme-dark .btn:hover { color: #0b1219; }
html.theme-dark .btn.green { background: #3fae63; color: #08160c; }
html.theme-dark .btn.green:hover { background: #4bbf70; }
html.theme-dark .btn.red { background: #d85a5a; color: #1a0808; }
html.theme-dark .btn.red:hover { background: #e46a6a; }
/* серые/вторичные — светлый текст на тёмном */
html.theme-dark .btn.gray { color: var(--ink); }
/* выпадающие меню Bootstrap */
html.theme-dark .dropdown-menu { background: var(--surface); border-color: var(--line); box-shadow: 0 6px 24px rgba(0,0,0,.5); }
html.theme-dark .dropdown-item { color: var(--ink); }
html.theme-dark .dropdown-item:hover, html.theme-dark .dropdown-item:focus { background: var(--hover); color: var(--ink); }
html.theme-dark .dropdown-divider { border-color: var(--line); }
html.theme-dark .badge.ok { background: #2f8a4c; color: #fff; }
/* активная кнопка навигации в подменю не должна быть блёклой */
html.theme-dark .subbar .btn { color: #0b1219; }
html.theme-dark .subbar .btn.gray { color: var(--ink); }

/* ── Тёмная тема: выпадающий автоподбор ОК-016 (читаемость) ── */
html.theme-dark .ok016-suggest { background: var(--surface-2); border-color: var(--line); box-shadow: 0 6px 24px rgba(0,0,0,.55); }
html.theme-dark .ok016-item { color: var(--ink); }
html.theme-dark .ok016-item:hover { background: var(--hover); }
html.theme-dark .ok016-item .muted { color: var(--ink-soft); }
/* поля ввода в тёмной теме — читаемый текст и плейсхолдеры */
html.theme-dark input::placeholder, html.theme-dark textarea::placeholder { color: #6b7885; }
