/* ============================================================
   SIMPLY SECURE — Рабочий список (SSTable)
   Универсальный компонент: сохранённые представления, фасеты,
   поиск, сортировка, группировка, выбор строк, шторка деталей.
   Токены — из styles.css, базовая таблица — .dtable из dashboard.css.
   ============================================================ */

/* ============================================================
   Мобильная навигация: до 920px сайдбар уезжает за экран
   и открывается кнопкой в топбаре (раньше он просто исчезал).
   ============================================================ */
.nav-toggle {
  display: none; width: 38px; height: 38px; flex-shrink: 0; border-radius: 10px;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--text-2);
  place-items: center; cursor: pointer;
}
.nav-toggle svg { width: 18px; height: 18px; }
.nav-toggle:hover { border-color: var(--accent-line); color: var(--text); }
.nav-scrim { display: none; }

@media (max-width: 920px) {
  .nav-toggle { display: grid; }
  .app { grid-template-columns: 1fr; }
  .sidebar {
    display: flex; position: fixed; top: 0; bottom: 0; left: 0; width: 264px; z-index: 300;
    background: var(--bg-grad); transform: translateX(-100%);
    transition: transform .24s cubic-bezier(.32,.72,.32,1);
  }
  body.nav-open .sidebar { transform: none; box-shadow: 24px 0 60px rgba(0,0,0,.5); }
  body.nav-open .nav-scrim {
    display: block; position: fixed; inset: 0; z-index: 290;
    background: rgba(0,0,0,.5); backdrop-filter: blur(2px);
  }
  .rescan-bar { left: 0; }
}

/* ---------------- Каркас ---------------- */
.dt { display: flex; flex-direction: column; gap: 14px; }
.dt-layout { display: grid; grid-template-columns: 246px minmax(0, 1fr); gap: 18px; align-items: start; }
.dt.facets-off .dt-layout { grid-template-columns: minmax(0, 1fr); }
.dt.facets-off .dt-facets { display: none; }
.dt-main { min-width: 0; display: flex; flex-direction: column; gap: 12px; }

/* ---------------- Сохранённые представления ---------------- */
.dt-views { display: flex; align-items: center; gap: 4px; border-bottom: 1px solid var(--line); }
.dt-view {
  position: relative; display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 14px 12px; border: 0; background: 0; cursor: pointer;
  font-family: var(--f-body); font-size: 0.92rem; font-weight: 600; color: var(--muted);
  transition: color .16s;
}
.dt-view:hover { color: var(--text-2); }
.dt-view.active { color: var(--text); }
.dt-view.active::after {
  content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px;
  background: var(--accent); border-radius: 2px 2px 0 0;
}
.dt-view .n {
  font-family: var(--f-mono); font-size: 0.7rem; padding: 2px 7px; border-radius: 100px;
  background: var(--surface-3); color: var(--text-2); min-width: 22px; text-align: center;
}
.dt-view.active .n { background: var(--accent-soft); color: var(--accent-hot); }
.dt-view .n.alert { background: var(--red-soft); color: var(--red); }

/* ---------------- Фасеты ---------------- */
.dt-facets {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  overflow: hidden; position: sticky; top: 0;
}
.dtf-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 13px 15px; border-bottom: 1px solid var(--line);
}
.dtf-head b { font-family: var(--f-display); font-size: 0.92rem; font-weight: 600; }
.dtf-reset { background: 0; border: 0; cursor: pointer; font-family: var(--f-mono); font-size: 0.7rem; color: var(--accent-hot); }
.dtf-reset:hover { text-decoration: underline; }
.dtf-reset[disabled] { color: var(--faint); cursor: default; text-decoration: none; }
.dtf-body { max-height: calc(100vh - 260px); overflow-y: auto; padding: 4px 0 8px; }
.dtf-body::-webkit-scrollbar { width: 7px; }
.dtf-body::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 5px; }

.dtf-grp { border-bottom: 1px solid var(--line); padding: 10px 6px 12px; }
.dtf-grp:last-child { border-bottom: 0; }
.dtf-t {
  display: flex; align-items: center; gap: 7px; width: 100%; padding: 4px 9px 8px;
  background: 0; border: 0; cursor: pointer; text-align: left;
  font-family: var(--f-mono); font-size: 0.66rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted);
}
.dtf-t:hover { color: var(--text-2); }
.dtf-t i { font-style: normal; color: var(--faint); }
.dtf-t .car { margin-left: auto; transition: transform .18s; font-size: 0.7rem; }
.dtf-grp.closed .dtf-t .car { transform: rotate(-90deg); }
.dtf-grp.closed .dtf-o, .dtf-grp.closed .dtf-more { display: none; }

.dtf-o {
  display: grid; grid-template-columns: 15px 1fr 34px; align-items: center; gap: 9px;
  padding: 5px 10px; border-radius: 7px; cursor: pointer;
}
.dtf-o:hover { background: var(--surface-2); }
.dtf-o input { width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; margin: 0; }
.dtf-l { font-size: 0.84rem; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dtf-o.on .dtf-l { color: var(--text); font-weight: 600; }
.dtf-n { font-family: var(--f-mono); font-size: 0.74rem; color: var(--muted); text-align: right; }
.dtf-bar { grid-column: 2 / 4; height: 3px; border-radius: 3px; background: var(--surface-3); overflow: hidden; margin-top: -3px; }
.dtf-bar i { display: block; height: 100%; border-radius: 3px; background: var(--line-2); }
.dtf-o.on .dtf-bar i { background: var(--accent); }
.dtf-more {
  margin: 6px 10px 0; background: 0; border: 0; cursor: pointer;
  font-family: var(--f-mono); font-size: 0.7rem; color: var(--accent-hot);
}
.dtf-more:hover { text-decoration: underline; }

/* ---------------- Панель управления ---------------- */
.dt-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.dt-count { font-family: var(--f-mono); font-size: 0.76rem; color: var(--muted); white-space: nowrap; }
.dt-count b { color: var(--text); }
.dt-search {
  display: flex; align-items: center; gap: 9px; flex: 1; min-width: 200px;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: 9px; padding: 8px 12px;
  color: var(--muted); transition: border-color .18s, box-shadow .18s;
}
.dt-search:focus-within { border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-soft); }
.dt-search svg { width: 15px; height: 15px; flex-shrink: 0; }
.dt-search input { flex: 1; min-width: 0; background: 0; border: 0; outline: 0; color: var(--text); font-family: var(--f-body); font-size: 0.86rem; }
.dt-search input::placeholder { color: var(--faint); }
.dt-search .clr { background: 0; border: 0; color: var(--muted); cursor: pointer; font-size: 0.9rem; line-height: 1; }
.dt-search .clr:hover { color: var(--text); }

.dt-sel {
  background: var(--surface); border: 1px solid var(--line-2); color: var(--text-2);
  font-family: var(--f-mono); font-size: 0.74rem; padding: 8px 30px 8px 12px; border-radius: 9px; cursor: pointer;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 16px) 16px, calc(100% - 11px) 16px;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat;
}
.dt-sel:hover { border-color: var(--accent-line); color: var(--text); }

.dt-iconbtn {
  width: 34px; height: 34px; flex-shrink: 0; border-radius: 9px;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--text-2);
  display: grid; place-items: center; cursor: pointer; transition: border-color .18s, color .18s;
}
.dt-iconbtn:hover { border-color: var(--accent-line); color: var(--text); }
.dt-iconbtn.on { border-color: var(--accent-line); background: var(--accent-soft); color: var(--accent-hot); }
.dt-iconbtn svg { width: 16px; height: 16px; }

.dt-pop { position: relative; }
.dt-popmenu {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 60; width: 232px;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: 12px; padding: 8px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.5);
}
.dt-popmenu[hidden] { display: none; }
.dt-popt { font-family: var(--f-mono); font-size: 0.62rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--faint); padding: 6px 8px; }
.dt-popmenu label { display: flex; align-items: center; gap: 9px; padding: 7px 8px; border-radius: 7px; cursor: pointer; font-size: 0.84rem; color: var(--text-2); }
.dt-popmenu label:hover { background: var(--surface-2); }
.dt-popmenu input { width: 15px; height: 15px; accent-color: var(--accent); }

/* активные фильтры отдельной строкой — видно, что именно сужает выборку */
.dt-chips { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.dt-chips:empty { display: none; }
.dt-chip {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--f-mono); font-size: 0.7rem; padding: 4px 8px 4px 10px; border-radius: 100px;
  border: 1px solid var(--accent-line); background: var(--accent-soft); color: var(--accent-hot);
}
.dt-chip b { font-weight: 500; color: var(--text-2); }
.dt-chip button { background: 0; border: 0; color: inherit; cursor: pointer; font-size: 0.82rem; line-height: 1; opacity: 0.75; }
.dt-chip button:hover { opacity: 1; }
.dt-chips .dt-clear { background: 0; border: 0; cursor: pointer; font-family: var(--f-mono); font-size: 0.7rem; color: var(--muted); }
.dt-chips .dt-clear:hover { color: var(--text); text-decoration: underline; }

/* ---------------- Массовые действия ---------------- */
.dt-bulk {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 14px; border-radius: 11px;
  border: 1px solid var(--accent-line); background: var(--accent-soft);
}
.dt-bulk[hidden] { display: none; }
.dt-bulk .b-n { font-family: var(--f-mono); font-size: 0.78rem; color: var(--accent-hot); }
.dt-bulk .b-x { margin-left: auto; background: 0; border: 0; color: var(--muted); cursor: pointer; font-family: var(--f-mono); font-size: 0.72rem; }
.dt-bulk .b-x:hover { color: var(--text); }

/* ---------------- Таблица ---------------- */
.dt-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.dt-scroll { overflow: auto; max-height: clamp(340px, 60vh, 940px); }
.dt-scroll::-webkit-scrollbar { width: 10px; height: 10px; }
.dt-scroll::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 6px; }
.dt-scroll::-webkit-scrollbar-track { background: transparent; }

.dt-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 0.88rem; }
.dt-table thead th {
  position: sticky; top: 0; z-index: 3;
  font-family: var(--f-body); font-size: 0.76rem; font-weight: 600; letter-spacing: 0;
  text-transform: none; text-align: left; color: var(--muted);
  padding: 11px 16px; white-space: nowrap;
  background: #171413; border-bottom: 1px solid var(--line-2);
}
.dt-table thead th.sortable { cursor: pointer; user-select: none; }
.dt-table thead th.sortable:hover { color: var(--text); }
.dt-table thead th .sort-i { display: inline-block; margin-left: 6px; opacity: 0; font-size: 0.66rem; color: var(--accent-hot); }
.dt-table thead th.sortable:hover .sort-i { opacity: 0.4; }
.dt-table thead th.sorted { color: var(--text); }
.dt-table thead th.sorted .sort-i { opacity: 1; }

.dt-table tbody td {
  padding: 12px 16px; border-bottom: 1px solid var(--line); color: var(--text-2); vertical-align: middle;
  background: var(--surface);
}
.dt[data-dense="1"] .dt-table tbody td { padding: 7px 16px; }
.dt[data-dense="1"] .dt-table thead th { padding: 8px 16px; }
.dt-table tbody tr:last-child td { border-bottom: 0; }
.dt-row { cursor: pointer; }
.dt-row:hover td { background: var(--surface-2); }
.dt-row.sel td { background: rgba(255,106,31,0.07); }
.dt-row:focus { outline: 0; }
/* Подсветка строки — фоном и одним маркером у левого края.
   Рамка/полоса на каждой ячейке давала вертикальные оранжевые линии
   на каждой границе колонок. */
.dt-row:focus-visible td { background: var(--surface-2); }
.dt-row.opened td { background: var(--surface-2); }
.dt-row.opened td:first-child { box-shadow: inset 3px 0 0 var(--accent); }

/* закреплённые слева колонки */
.dt-table th.pin, .dt-table td.pin { position: sticky; z-index: 2; }
.dt-table thead th.pin { z-index: 4; }
.dt-table td.pin { background: var(--surface); }
.dt-row:hover td.pin { background: var(--surface-2); }
.dt-row.sel td.pin { background: #1e1613; }
.dt-table .pin-edge::after {
  content: ""; position: absolute; top: 0; bottom: -1px; right: -1px; width: 1px; background: var(--line);
}
.dt.scrolled .dt-table .pin-edge::after { box-shadow: 6px 0 12px -4px rgba(0,0,0,0.75); width: 1px; background: var(--line-2); }

/* первая (закреплённая) колонка — имя объекта: держим запас ширины,
   длинные хосты переносим по точкам, а не рвём посреди слова */
.dt-table td.pin .host, .dt-table td.pin .dm-name b { overflow-wrap: anywhere; }
.dt-table th.pin:not(.dt-c-pick):not(.dt-c-star),
.dt-table td.pin:not(.dt-c-pick):not(.dt-c-star) { min-width: 220px; }
.dt-grp td.pin { padding-right: 10px; }
.dt-grp .g-n { margin-left: 7px; }

/* служебные колонки */
.dt-c-pick, .dt-c-star, .dt-c-open { width: 34px; text-align: center; padding-left: 10px !important; padding-right: 0 !important; }
.dt-c-open { padding-right: 12px !important; }
.dt-pick { width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; margin: 0; vertical-align: middle; }
.dt-star, .dt-open {
  background: 0; border: 0; padding: 3px; cursor: pointer; color: var(--muted);
  display: inline-grid; place-items: center; border-radius: 6px; transition: color .15s;
}
.dt-star svg, .dt-open svg { width: 15px; height: 15px; }
.dt-star:hover, .dt-open:hover { color: var(--text); }
.dt-star.on { color: var(--amber); }
.dt-star.on svg { fill: var(--amber); }

/* режим списка: строка рисуется своим шаблоном (карточка, лента) */
.dt-mode-list .dt-scroll { overflow-x: hidden; }
.dt-listcell { padding: 0 !important; }
.dt-listcell > * { border-bottom: 0 !important; background: transparent !important; }
.dt-mode-list .dt-row td { vertical-align: top; }
.dt-mode-list .dt-c-pick, .dt-mode-list .dt-c-star { padding-top: 20px !important; vertical-align: top; }
.dt-mode-list .dt-c-open { vertical-align: top; padding-top: 18px !important; }
.dt-mode-list .dt-grp td { padding: 10px 16px; }

/* отметка времени: относительная сверху, точная — под ней */
.ts { display: block; line-height: 1.35; }
.ts b { display: block; font-weight: 500; color: var(--text-2); }
.ts i { display: block; font-style: normal; font-family: var(--f-mono); font-size: 0.72rem; color: var(--muted); }
.dt[data-dense="1"] .ts { display: flex; gap: 8px; align-items: baseline; }

/* группировка */
.dt-grp td { background: rgba(255,255,255,0.028); font-weight: 600; color: var(--text); cursor: pointer; }
.dt-grp:hover td { background: rgba(255,255,255,0.05); }
.dt-grp .g-car { display: inline-block; width: 12px; color: var(--muted); transition: transform .16s; }
.dt-grp.open .g-car { transform: rotate(90deg); }
.dt-grp .g-n {
  font-family: var(--f-mono); font-size: 0.7rem; font-weight: 500; color: var(--muted);
  background: var(--surface-3); border-radius: 100px; padding: 1px 8px; margin-left: 9px;
}
.dt-sub td:first-child { padding-left: 32px !important; }

.dt-empty { padding: 0; }
.dt-empty .empty { padding: 54px 24px; }
.dt-loading { padding: 46px 24px; text-align: center; color: var(--muted); font-family: var(--f-mono); font-size: 0.8rem; }

/* ---------------- Подвал / догрузка ---------------- */
.dt-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  padding: 12px 16px; border-top: 1px solid var(--line);
}
.dt-foot:empty { display: none; }
.dt-foot .f-t { font-family: var(--f-mono); font-size: 0.74rem; color: var(--muted); }
.dt-more {
  font-family: var(--f-mono); font-size: 0.76rem; padding: 7px 14px; border-radius: 9px;
  border: 1px solid var(--line-2); background: var(--surface-2); color: var(--text-2); cursor: pointer;
}
.dt-more:hover { border-color: var(--accent-line); color: var(--text); }

/* ---------------- Фокус клавиатуры ----------------
   Раньше :focus был описан только у полей ввода — навигация с клавиатуры
   шла вслепую. Правило общее для всего приложения. */
.nav-item:focus-visible,
.qfilter button:focus-visible,
.mini-btn:focus-visible,
.btn:focus-visible,
.link:focus-visible,
.tile:focus-visible,
.icon-btn:focus-visible,
.dt :focus-visible,
.dd-panel :focus-visible,
.ss-modal :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
/* у строки таблицы обводка идёт внутрь: снаружи она наезжала бы на соседние строки */
.dt-row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 0; }
/* у поля поиска фокус показывает обёртка (.dt-search:focus-within) — собственный
   контур input'а давал вторую рамку поверх первой */
.dt-search input:focus-visible { outline: none; }

/* ---------------- Шапка шторки: копирование ссылки + закрытие ---------------- */
.dd-head-acts { display: flex; align-items: center; gap: 8px; }
.dd-x svg { width: 15px; height: 15px; display: block; }
.dd-x.ok { color: var(--green); }

/* ---------------- Табы в шторке деталей ---------------- */
.dd-tabs { display: flex; gap: 4px; margin: 14px -22px -16px; padding: 0 22px; border-bottom: 1px solid var(--line); }
.dd-tab {
  position: relative; background: 0; border: 0; cursor: pointer; padding: 9px 2px 11px; margin-right: 18px;
  font-family: var(--f-body); font-size: 0.86rem; font-weight: 600; color: var(--muted);
}
.dd-tab:hover { color: var(--text-2); }
.dd-tab.active { color: var(--text); }
.dd-tab.active::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--accent); }
.dd-tab .n { font-family: var(--f-mono); font-size: 0.7rem; color: var(--muted); margin-left: 6px; }

/* ---------------- Адаптив ---------------- */
@media (max-width: 1400px) {
  .dt-layout { grid-template-columns: 212px minmax(0, 1fr); gap: 14px; }
  /* в режиме списка колонки действий фиксированной ширины перестают помещаться */
  .dt-mode-list .issue-row .issue-act { width: 74px; }
  .dt-mode-list .issue-row .issue-act.wide { width: 100px; }
  .dt-mode-list .issue-row .sev { width: 78px; }
}
@media (max-width: 980px) {
  .dt-layout { grid-template-columns: minmax(0, 1fr); }
  .dt-facets { position: static; max-height: none; }
  .dtf-body { max-height: 320px; }
}
