/* Токены взяты из макета «FusionAI Платформа» без изменений. */
:root {
  --bg: #fafafa; --panel: #ffffff; --panel2: #f2f2f4;
  --line: #e6e6e9; --line2: #d6d6dc;
  --text: #18181b; --muted: #6c6c76; --faint: #a1a1aa;
  --acc: #5bc501; --acc-ink: #3f8a00; --acc-soft: rgba(91, 197, 1, .13);
  --danger: #c9301c; --danger-soft: rgba(201, 48, 28, .09);
  --warn: #a26400; --warn-soft: rgba(162, 100, 0, .11);
  --on-acc: #0f2b00;
}
:root[data-theme="dark"] {
  --bg: #0f0f11; --panel: #18181b; --panel2: #1f1f24;
  --line: #292930; --line2: #3a3a44;
  --text: #f1f1f3; --muted: #8d8d98; --faint: #66666f;
  --acc: #6fdb12; --acc-ink: #8ce93a; --acc-soft: rgba(111, 219, 18, .15);
  --danger: #ff7a63; --danger-soft: rgba(255, 122, 99, .12);
  --warn: #e2a53c; --warn-soft: rgba(226, 165, 60, .13);
  --on-acc: #0f2b00;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text); font-size: 13.5px;
  font-family: 'Golos Text', system-ui, -apple-system, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--acc-ink); text-decoration: none; }
a:hover { color: var(--acc); }
input, button, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-thumb { background: var(--line2); border-radius: 8px; border: 3px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }
@keyframes sk { 0% { opacity: .35 } 50% { opacity: .75 } 100% { opacity: .35 } }
@keyframes spin { to { transform: rotate(360deg) } }
@keyframes tin { from { opacity: 0; transform: translateY(10px) } to { opacity: 1; transform: none } }
.mono { font-family: 'JetBrains Mono', ui-monospace, Menlo, monospace; }
.hide { display: none !important; }

/* ── каркас ───────────────────────────────────────────────────────────── */
.app { display: flex; height: 100vh; overflow: hidden; }
aside {
  width: 236px; flex: 0 0 236px; border-right: 1px solid var(--line);
  background: var(--panel); display: flex; flex-direction: column; height: 100%;
}
.brand { padding: 16px 14px 10px 16px; }
.brand .mark { font-size: 17px; font-weight: 800; letter-spacing: -.02em; }
.brand .mark span { color: var(--acc); }
.seg {
  margin-top: 10px; display: flex; gap: 2px; padding: 2px;
  background: var(--panel2); border-radius: 7px;
}
.seg > * {
  flex: 1; text-align: center; padding: 4px 0; border-radius: 5px;
  font-size: 11.5px; font-weight: 500; color: var(--muted); cursor: pointer;
  border: none; background: transparent;
}
.seg > .on {
  font-weight: 600; background: var(--panel); color: var(--text);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .06);
}
nav { flex: 1; overflow-y: auto; padding: 4px 8px 8px; display: flex; flex-direction: column; gap: 1px; }
.nav {
  display: flex; align-items: center; gap: 8px; height: 31px; padding: 0 8px;
  border: none; border-radius: 7px; background: transparent; cursor: pointer;
  font-weight: 500; color: var(--muted); width: 100%; text-align: left;
}
.nav:hover { background: var(--panel2); }
.nav .bar { width: 3px; height: 14px; border-radius: 2px; background: transparent; flex: none; }
.nav.on { background: var(--acc-soft); color: var(--text); }
.nav.on .bar { background: var(--acc); }
.nav .lbl { flex: 1; }
.nav .n { font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--faint); }
.nav .n.bad { color: var(--danger); font-weight: 500; }
.nav .n.warn { color: var(--warn); font-weight: 500; }
.navcap {
  margin: 14px 8px 6px 11px; font-size: 10.5px; font-weight: 600;
  letter-spacing: .06em; text-transform: uppercase; color: var(--faint);
}
.foot { border-top: 1px solid var(--line); padding: 10px 10px 12px; }
.who { display: flex; align-items: center; gap: 9px; padding: 6px; border-radius: 8px; }
.who .av {
  width: 28px; height: 28px; flex: 0 0 28px; border-radius: 50%;
  background: var(--acc-soft); color: var(--acc-ink); display: flex;
  align-items: center; justify-content: center; font-size: 11px; font-weight: 700;
}
.who .nm { font-size: 12.5px; font-weight: 600; }
.who .ttl { font-size: 11px; color: var(--muted); }

main { flex: 1; min-width: 0; display: flex; flex-direction: column; height: 100%; }
header.top {
  height: 52px; flex: 0 0 52px; border-bottom: 1px solid var(--line);
  background: var(--panel); display: flex; align-items: center; gap: 14px; padding: 0 20px;
}
header.top .h1 { font-size: 14.5px; font-weight: 650; letter-spacing: -.01em; }
header.top .h2 { font-size: 11.5px; color: var(--muted); }
.kbtn {
  display: flex; align-items: center; gap: 8px; height: 30px; padding: 0 10px;
  border: 1px solid var(--line); border-radius: 7px; cursor: pointer;
  color: var(--muted); font-size: 12.5px; background: var(--bg); white-space: nowrap;
}
.kbtn:hover { border-color: var(--line2); }
.kbd {
  font-family: 'JetBrains Mono', monospace; font-size: 10.5px;
  border: 1px solid var(--line); border-radius: 4px; padding: 1px 4px;
}
.body { flex: 1; overflow: auto; padding: 18px 20px 40px; }
.screen[hidden] { display: none; }

/* ── карточки ─────────────────────────────────────────────────────────── */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; }
.card.clip { overflow: hidden; }
.chead {
  display: flex; align-items: baseline; gap: 10px; padding: 13px 16px;
  border-bottom: 1px solid var(--line);
}
.chead .t { font-size: 13.5px; font-weight: 650; }
.chead .s { font-size: 11.5px; color: var(--muted); }
.cap {
  font-size: 11px; font-weight: 600; letter-spacing: .05em;
  text-transform: uppercase; color: var(--muted);
}
.grid2 { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 16px; max-width: 1320px; }

/* строка «требует внимания» */
.attn {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px;
  border-bottom: 1px solid var(--line); cursor: pointer; width: 100%;
  border-left: 3px solid var(--line2); background: transparent; text-align: left;
  color: inherit; border-top: none; border-right: none;
}
.attn:last-child { border-bottom: none; }
.attn:hover { background: var(--panel2); }
.attn.bad { border-left-color: var(--danger); background: var(--danger-soft); }
.attn.warn { border-left-color: var(--warn); }
.attn .t { font-weight: 600; font-size: 13.5px; }
.attn .s { font-size: 12px; color: var(--muted); margin-top: 2px; }
.attn .num { font-family: 'JetBrains Mono', monospace; font-size: 17px; font-weight: 600; }
.attn.bad .num { color: var(--danger); }
.attn.warn .num { color: var(--warn); }
.attn .arr { color: var(--faint); }

.kpi { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 8px; margin-top: 12px; }
.kpi .v { font-family: 'JetBrains Mono', monospace; font-size: 22px; font-weight: 600; line-height: 1; }
.kpi .l { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.mixrow {
  margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line);
  display: flex; gap: 14px; font-size: 11.5px; color: var(--muted); flex-wrap: wrap;
}
.mixrow span { font-family: 'JetBrains Mono', monospace; color: var(--text); }

.mv { display: flex; align-items: center; gap: 10px; padding: 9px 16px;
  border-bottom: 1px solid var(--line); cursor: pointer; width: 100%;
  background: transparent; border-left: none; border-right: none; border-top: none;
  color: inherit; text-align: left; }
.mv:hover { background: var(--panel2); }
.mv .av {
  width: 24px; height: 24px; flex: 0 0 24px; border-radius: 50%;
  background: var(--panel2); color: var(--muted); display: flex;
  align-items: center; justify-content: center; font-size: 10px; font-weight: 700;
}
.mv .nm { font-size: 12.5px; font-weight: 550; }
.mv .rl { font-size: 11px; color: var(--muted); }
.mv .dt { font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--faint); }

/* ── таблицы ──────────────────────────────────────────────────────────── */
.tbl { width: 100%; }
.tr { display: grid; align-items: center; border-bottom: 1px solid var(--line); }
.tr > div { padding: 10px 10px; min-width: 0; }
.tr.head {
  position: sticky; top: 0; background: var(--panel); z-index: 2;
  font-size: 10.5px; font-weight: 600; letter-spacing: .05em;
  text-transform: uppercase; color: var(--muted);
}
.tr.head > div { padding: 9px 10px; }
.tr.click { cursor: pointer; }
.tr.click:hover { background: var(--panel2); }
.sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.nm { font-weight: 550; }

.chip {
  display: inline-flex; align-items: center; gap: 4px; font-size: 10.5px;
  font-weight: 600; padding: 2px 7px; border-radius: 20px;
  background: var(--panel2); color: var(--muted); white-space: nowrap;
}
.chip.ok { background: var(--acc-soft); color: var(--acc-ink); }
.chip.bad { background: var(--danger-soft); color: var(--danger); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.emp {
  font-family: 'JetBrains Mono', monospace; font-size: 10px; font-weight: 700;
  border: 1px solid var(--line2); border-radius: 4px; padding: 1px 4px; color: var(--muted);
}

/* ── формы и кнопки ───────────────────────────────────────────────────── */
.i, input.i, select.i, textarea.i {
  width: 100%; padding: 6px 9px; background: var(--bg); border: 1px solid var(--line2);
  border-radius: 7px; outline: none; font-size: 13px;
}
.i:focus { border-color: var(--acc); }
.i.bad { border-color: var(--danger); }
textarea.i { resize: vertical; line-height: 1.5; }
label.f { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); }
.g { display: grid; gap: 12px; }
.fe { font-size: 11.5px; color: var(--danger); }

.btn {
  height: 30px; padding: 0 12px; border-radius: 7px; border: 1px solid transparent;
  background: var(--acc); color: var(--on-acc); font-weight: 600; cursor: pointer;
  font-size: 12.5px; white-space: nowrap;
}
.btn:hover { filter: brightness(1.06); }
.btn:disabled { opacity: .45; cursor: default; filter: none; }
.btn.g2 { background: var(--panel); border-color: var(--line2); color: var(--text); font-weight: 500; }
.btn.g2:hover { border-color: var(--text); filter: none; }
.btn.big { width: 100%; height: 36px; font-size: 13.5px; }
.btn.sm { height: 26px; padding: 0 9px; font-size: 12px; }
.search {
  height: 30px; padding: 0 10px; background: var(--bg); border: 1px solid var(--line);
  border-radius: 7px; outline: none; font-size: 12.5px;
}
.search:focus { border-color: var(--acc); }

/* ── состояния ────────────────────────────────────────────────────────── */
.blank { padding: 64px 20px; text-align: center; }
.blank .sq { width: 38px; height: 38px; border-radius: 10px; border: 1px dashed var(--line2); margin: 0 auto 14px; }
.blank .t { font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.blank .d { font-size: 12.5px; color: var(--muted); line-height: 1.55; max-width: 40ch; margin: 0 auto 14px; }
.sk { background: var(--panel2); border-radius: 5px; height: 11px; animation: sk 1.2s ease-in-out infinite; }
.spin { width: 14px; height: 14px; border: 2px solid var(--line2); border-top-color: var(--acc);
  border-radius: 50%; animation: spin .7s linear infinite; display: block; flex: none; }
.bar { height: 4px; border-radius: 2px; background: var(--panel2); overflow: hidden; width: 96px; }
.bar i { display: block; height: 100%; background: var(--acc); }
.bar.late i { background: var(--warn); }

/* ── чек-лист ─────────────────────────────────────────────────────────── */
.step { display: flex; align-items: flex-start; gap: 10px; padding: 9px 12px;
  border-bottom: 1px solid var(--line); cursor: pointer; }
.step:hover { background: var(--panel2); }
.step.auto { cursor: default; }
.step input { margin-top: 2px; accent-color: var(--acc); }
.step .t { font-size: 13px; }
.step .m { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.step.late .t { color: var(--warn); }
.tag-auto { font-family: 'JetBrains Mono', monospace; font-size: 9.5px; font-weight: 700;
  letter-spacing: .04em; color: var(--acc-ink); background: var(--acc-soft);
  border-radius: 4px; padding: 1px 5px; }

/* ── матрица доступов ─────────────────────────────────────────────────── */
.mwrap { overflow: auto; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
table.mx { border-collapse: separate; border-spacing: 0; font-size: 12px; }
table.mx th, table.mx td { border-bottom: 1px solid var(--line); padding: 0; }
table.mx thead th {
  position: sticky; top: 0; z-index: 3; background: var(--panel);
  height: 128px; vertical-align: bottom; padding-bottom: 8px;
}
table.mx thead th span {
  display: block; writing-mode: vertical-rl; transform: rotate(180deg);
  white-space: nowrap; font-size: 11px; font-weight: 500; color: var(--muted);
  max-height: 112px; overflow: hidden;
}
table.mx .who2 {
  position: sticky; left: 0; z-index: 2; background: var(--panel);
  text-align: left; padding: 7px 12px; min-width: 210px;
  border-right: 1px solid var(--line);
}
table.mx thead .who2 { z-index: 4; }
.cell { text-align: center; width: 32px; }
.dot {
  width: 18px; height: 18px; border-radius: 5px; border: 1px solid var(--line2);
  background: transparent; cursor: pointer; padding: 0; line-height: 1;
  font-size: 10px; color: transparent;
}
.dot.on { background: var(--acc); border-color: var(--acc); color: var(--on-acc); }
.dot.risk { background: var(--danger); border-color: var(--danger); color: #fff; }
.dot:hover { border-color: var(--acc); }
.legend { display: flex; gap: 16px; align-items: center; font-size: 11.5px; color: var(--muted); margin-top: 10px; flex-wrap: wrap; }
.legend i { width: 12px; height: 12px; border-radius: 4px; display: inline-block; vertical-align: -2px; margin-right: 5px; }

/* ── дерево ───────────────────────────────────────────────────────────── */
.tree, .tree ul { list-style: none; margin: 0; padding: 0; }
.tree ul { padding-left: 16px; border-left: 1px solid var(--line); margin-left: 8px; }
.tree li { margin: 1px 0; }
.node { display: flex; align-items: center; gap: 8px; padding: 4px 8px; border-radius: 6px; cursor: pointer; }
.node:hover { background: var(--panel2); }
.node.orphan { background: var(--warn-soft); }

/* ── модалка и уведомления ────────────────────────────────────────────── */
.modal { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center;
  justify-content: center; padding: 20px; background: rgba(10, 11, 13, .5); }
.modal[hidden] { display: none; }
.modal .box { background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 20px; max-width: 480px; width: 100%; max-height: 84vh; overflow: auto;
  animation: tin .16s ease; }
.modal .box h3 { margin: 0 0 12px; font-size: 15px; font-weight: 650; }

.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 70; display: flex;
  flex-direction: column; gap: 8px; align-items: flex-end; }
.toast {
  display: flex; align-items: center; gap: 12px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 9px; padding: 10px 14px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .12); animation: tin .18s ease; max-width: 380px;
}
.toast .t { font-size: 12.5px; font-weight: 550; }
.toast .s { font-size: 11.5px; color: var(--muted); }
.toast.bad { border-color: var(--danger); }

.pal { position: fixed; inset: 0; z-index: 80; background: rgba(10, 11, 13, .45);
  display: flex; align-items: flex-start; justify-content: center; padding-top: 14vh; }
.pal[hidden] { display: none; }
.pal .box { width: 100%; max-width: 520px; background: var(--panel);
  border: 1px solid var(--line2); border-radius: 12px; overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .28); }
.pal input { width: 100%; height: 44px; padding: 0 16px; border: none;
  border-bottom: 1px solid var(--line); background: transparent; outline: none; font-size: 14px; }
.pal .row { display: flex; align-items: center; gap: 10px; padding: 9px 16px; cursor: pointer; }
.pal .row.on, .pal .row:hover { background: var(--panel2); }

/* ── хранилище паролей ────────────────────────────────────────────────── */
.vwrap { display: grid; grid-template-columns: 236px minmax(0, 1fr); gap: 16px; align-items: start; }
.vitem { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border: none;
  border-radius: 7px; background: transparent; cursor: pointer; width: 100%;
  text-align: left; font-size: 13px; color: var(--text); }
.vitem:hover { background: var(--panel2); }
.vitem.on { background: var(--acc-soft); }
.vitem .n { margin-left: auto; font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--faint); }
.secret { font-family: 'JetBrains Mono', monospace; letter-spacing: .04em; }
.meter { height: 4px; border-radius: 2px; background: var(--panel2); overflow: hidden; }
.meter i { display: block; height: 100%; }
.s1 { background: var(--danger); width: 25%; }
.s2 { background: var(--warn); width: 50%; }
.s3 { background: #8ab800; width: 75%; }
.s4 { background: var(--acc); width: 100%; }
.lockpad { max-width: 420px; margin: 48px auto; text-align: center; }
.note { font-size: 12px; color: var(--muted); line-height: 1.55; }

@media (max-width: 900px) {
  aside { display: none; }
  .grid2, .vwrap { grid-template-columns: 1fr; }
  .body { padding: 14px 14px 40px; }
  header.top { padding: 0 14px; }
}
