/* Network Landscape — вкладки «Ландшафт» и «Связи» раздела «Сеть».
   Карта инфраструктуры: CATEGORY → DOMAIN → (раскрытие) LOGICAL NETWORK.
   Цветовой акцент категории задаётся inline-переменной --nl-color (2–3px
   сбоку, иконка, бейдж, selected) — строки НЕ заливаются, градиентов нет.
   Все правила с префиксом .nl-, палитра — из переменных кабинета. */

/* ─── Тулбар (компактный, один ряд) ──────────────────────────────────── */
.nl-toolbar {
    display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
    padding: 2px 0 8px;
}
.nl-field { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; min-width: 0; }
.nl-field > span { color: var(--muted2); font-size: 11px; white-space: nowrap; }
.nl-field select {
    width: 150px; max-width: 170px;
    background: var(--input); border: 1px solid var(--border); color: var(--text);
    border-radius: var(--radius); font-size: 12px; font-family: inherit;
    padding: 4px 6px;
}
.nl-field select:focus { outline: none; border-color: var(--accent); }
.nl-field select:disabled { color: var(--muted2); }
.nl-search {
    flex: 1 1 200px; min-width: 140px; max-width: 520px;
    background: var(--input); border: 1px solid var(--border); color: var(--text);
    border-radius: var(--radius); font-size: 13px; font-family: inherit; padding: 5px 9px;
}
.nl-search::placeholder { color: var(--muted2); }
.nl-search:focus { outline: none; border-color: var(--accent); }
.nl-collapse { margin-left: auto; border-color: var(--border); color: var(--text); white-space: nowrap; }
.nl-collapse:hover { background: var(--hover); border-color: var(--border2); }

/* ─── Фильтр «Тип сети» (popover с чекбоксами) ───────────────────────── */
.nl-typewrap { position: relative; display: inline-flex; }
.nl-type-chip {
    display: inline-flex; align-items: center; gap: 4px;
    background: var(--input); border: 1px solid var(--border); color: var(--text);
    border-radius: var(--radius); font: inherit; font-size: 12px; padding: 4px 8px; cursor: pointer;
}
.nl-type-chip:hover { border-color: var(--border2); }
.nl-type-chip.is-active { border-color: color-mix(in srgb, var(--accent) 55%, transparent); color: var(--accent); }
.nl-type-n {
    display: inline-block; min-width: 14px; text-align: center;
    background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent);
    border-radius: 8px; padding: 0 4px; font-size: 10px; line-height: 15px;
    font-variant-numeric: tabular-nums;
}
.nl-popover {
    position: absolute; top: calc(100% + 4px); left: 0; z-index: 30;
    display: flex; flex-direction: column; gap: 1px; min-width: 180px; padding: 5px;
    background: var(--panel, var(--bg)); border: 1px solid var(--border2);
    border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0, 0, 0, .35);
}
.nl-popover[hidden] { display: none; }
.nl-pop-item {
    display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--text);
    padding: 4px 6px; border-radius: var(--radius); cursor: pointer; white-space: nowrap;
}
.nl-pop-item:hover { background: var(--hover); }
.nl-pop-item input[type="checkbox"] { width: 13px; height: 13px; cursor: pointer; }
.nl-pop-dot { flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--nl-color, var(--muted2)); }

/* ─── Счётчик Ландшафта (над лентой) ─────────────────────────────────── */
.nl-summary-host:empty { display: none; }
.nl-summary {
    display: flex; flex-direction: column; gap: 5px;
    padding: 8px 10px 9px; border-bottom: 1px solid var(--border2);
}
.nl-sum-primary { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.nl-sum-total { font-size: 14px; font-weight: 600; color: var(--text); white-space: nowrap; }
.nl-sum-cats { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-left: auto; }
.nl-sum-chip {
    display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; color: var(--text);
    background: var(--input); border: 1px solid var(--border); border-radius: 10px;
    padding: 1px 8px; white-space: nowrap;
}
.nl-sum-dot { flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--nl-color, var(--muted2)); }
.nl-sum-name { color: var(--muted); }
.nl-sum-n { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--text); }
.nl-sum-secondary {
    font-size: 11px; color: var(--muted2); font-variant-numeric: tabular-nums;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ─── Скролл-контейнер (scroll переживает обновление) ────────────────── */
.nl-scroll { overflow: auto; max-height: 64vh; border-top: 1px solid var(--border2); }

/* Общая сетка колонок: один заголовок на всю ленту, домен и логическая
   сеть выравниваются по одним и тем же колонкам. */
.nl-tree {
    --nl-cols: 16px minmax(180px, 2.2fr) minmax(160px, 1.1fr) minmax(96px, .7fr)
               minmax(110px, .85fr) minmax(80px, .6fr);
    display: flex; flex-direction: column;
}
.nl-head {
    display: grid; grid-template-columns: var(--nl-cols); align-items: center; gap: 8px;
    position: sticky; top: 0; z-index: 2;
    padding: 6px 10px; background: var(--panel, var(--bg));
    border-bottom: 1px solid var(--border2);
    color: var(--muted2); font-size: 10px; text-transform: uppercase; letter-spacing: .5px;
}
.nl-head-caret { width: 16px; }
.nl-head-c { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ─── Категория (уровень 1) — визуальный разделитель ─────────────────── */
.nl-cat {
    position: relative;
    display: flex; align-items: center; gap: 10px;
    min-height: 44px; padding: 6px 12px; cursor: pointer; user-select: none;
    border-left: 3px solid var(--nl-color, transparent);
    border-bottom: 1px solid var(--border2);
    background: color-mix(in srgb, var(--nl-color, transparent) 6%, transparent);
}
.nl-cat:hover { background: color-mix(in srgb, var(--nl-color, transparent) 10%, transparent); }
.nl-cat-ic { flex: none; display: inline-flex; width: 20px; height: 20px; color: var(--nl-color, var(--muted2)); }
.nl-cat-svg { width: 20px; height: 20px; }
.nl-cat-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.nl-cat-name { font-size: 16.5px; font-weight: 600; color: var(--text); line-height: 1.2; }
.nl-cat-desc {
    font-size: 11.5px; color: var(--muted2);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.nl-cat-meta {
    margin-left: auto; color: var(--muted); font-size: 11.5px;
    font-variant-numeric: tabular-nums; white-space: nowrap;
}
.nl-caret { flex: none; width: 12px; color: var(--muted2); font-size: 10px; text-align: center; }

/* ─── Домен (уровень 2) — главный объект ─────────────────────────────── */
.nl-cat-body { display: flex; flex-direction: column; }
.nl-dom {
    display: grid; grid-template-columns: var(--nl-cols); align-items: center; gap: 8px;
    min-height: 40px; padding: 4px 10px; cursor: pointer;
    border-left: 3px solid transparent;
    border-bottom: 1px solid color-mix(in srgb, var(--border2) 60%, transparent);
}
.nl-dom:hover:not(.is-selected) { background: var(--hover); }
.nl-dom.is-selected {
    border-left-color: var(--nl-color, var(--accent));
    background: color-mix(in srgb, var(--nl-color, var(--accent)) 7%, transparent);
}
.nl-dom-main { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.nl-dom-name { font-size: 13.5px; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nl-dom-tech { font-size: 11px; color: var(--muted2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Организационный контекст домена из одного Scope («{Клиент} · {Объект}»).
 * Различает независимые сети с одинаковым CIDR, не меняя имя/CIDR (§10). */
.nl-dom-org { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nl-dom-org.is-mixed { color: color-mix(in srgb, var(--inf-warn, #D29922) 78%, var(--text)); }
.nl-dom-meta { font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nl-dom-gw, .nl-dom-upd {
    font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.nl-dom-upd { color: var(--muted2); font-size: 11px; text-align: right; }

/* ─── Логические сети домена (уровень 3) ─────────────────────────────── */
.nl-scope {
    position: relative;
    display: grid; grid-template-columns: var(--nl-cols); align-items: center; gap: 8px;
    min-height: 30px; padding: 3px 10px 3px 32px; cursor: pointer;
    border-left: 3px solid transparent;
    border-bottom: 1px solid color-mix(in srgb, var(--border2) 45%, transparent);
}
/* tree-guide: тонкая вертикаль под caret домена */
.nl-scope::before {
    content: ''; position: absolute; left: 19px; top: 0; bottom: 0; width: 1px;
    background: color-mix(in srgb, var(--text) 13%, transparent);
}
.nl-scope:hover:not(.is-selected) { background: var(--hover); }
.nl-scope.is-selected {
    border-left-color: var(--nl-color, var(--accent));
    background: color-mix(in srgb, var(--nl-color, var(--accent)) 8%, transparent);
}
.nl-caret-gap { width: 16px; }
.nl-scope-main { display: flex; align-items: center; gap: 7px; min-width: 0; }
.nl-scope-cidr {
    font-family: var(--mono, ui-monospace, monospace); font-size: 12.5px; color: var(--text);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* Тех.бейдж подтипа — приглушённый, не доминирует над CIDR. */
.nl-scope-sub {
    flex: none; font-size: 10px; line-height: 15px; padding: 0 5px;
    border: 1px solid var(--border2); border-radius: var(--radius);
    color: var(--muted2); white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis; max-width: 130px;
}
/* Организационный контекст (клиент · объект) — приглушённый, но различимый:
 * независимые сети с одинаковым CIDR различаются этой подписью. Смешанная
 * принадлежность помечается предупреждающим тоном, не ярче CIDR (§7/§10/§12). */
.nl-scope-org {
    flex: 0 1 auto; min-width: 0; font-size: 10.5px; line-height: 15px; padding: 0 5px;
    border: 1px solid var(--border2); border-radius: var(--radius);
    color: var(--muted); white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis; max-width: 240px;
}
.nl-scope-org.is-mixed {
    border-color: color-mix(in srgb, var(--inf-warn, #D29922) 55%, transparent);
    color: color-mix(in srgb, var(--inf-warn, #D29922) 78%, var(--text));
}
.nl-scope-m { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.nl-scope-gw, .nl-scope-upd {
    font-size: 11.5px; color: var(--muted);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.nl-scope-upd { color: var(--muted2); font-size: 11px; text-align: right; }
.nl-scope-flags { display: inline-flex; gap: 5px; overflow: hidden; flex: none; }

/* ─── Признаки (flags) — приглушённые ────────────────────────────────── */
.nl-flag {
    flex: none; font-size: 10px; line-height: 16px; padding: 0 5px; white-space: nowrap;
    border: 1px solid color-mix(in srgb, var(--inf-warn, #D29922) 55%, transparent);
    border-radius: var(--radius);
    color: color-mix(in srgb, var(--inf-warn, #D29922) 80%, var(--text));
}
.nl-flag.is-overlap {
    border-color: color-mix(in srgb, var(--inf-crit, #f85149) 50%, transparent);
    color: color-mix(in srgb, var(--inf-crit, #f85149) 70%, var(--text));
}

/* ─── Мелочи строк ───────────────────────────────────────────────────── */
.nl-k { color: var(--muted2); font-size: 10px; text-transform: uppercase; letter-spacing: .4px; }
.nl-sub { color: var(--muted2); font-size: 10px; margin-left: 3px; }

/* ─── Здоровье ───────────────────────────────────────────────────────── */
.nl-health { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nl-hdot { flex: none; width: 6px; height: 6px; border-radius: 50%; background: var(--muted2); }
.nl-health.is-ok { color: var(--inf-ok, var(--accent)); }
.nl-health.is-ok .nl-hdot { background: var(--inf-ok, var(--accent)); }
.nl-health.is-info { color: var(--inf-info, #4493F8); }
.nl-health.is-info .nl-hdot { background: var(--inf-info, #4493F8); }
.nl-health.is-warn { color: var(--inf-warn, #D29922); }
.nl-health.is-warn .nl-hdot { background: var(--inf-warn, #D29922); }
.nl-health.is-crit { color: var(--inf-crit, var(--danger)); }
.nl-health.is-crit .nl-hdot { background: var(--inf-crit, var(--danger)); }
.nl-health.is-unknown { color: var(--muted2); }
.nl-health.is-unknown .nl-hdot { background: transparent; box-shadow: inset 0 0 0 1px var(--muted2); }

/* ─── Вкладка «Связи» ────────────────────────────────────────────────── */
.nl-links-hint { font-size: 11.5px; color: var(--muted2); padding: 2px 0 8px; }
.nl-links-table td, .nl-links-table th { vertical-align: top; }
.nl-link-row { cursor: pointer; }
.nl-link-name { font-size: 12.5px; color: var(--text); font-weight: 500; white-space: nowrap; }
.nl-connects { font-size: 12px; color: var(--muted); }
.nl-arrow { color: var(--muted2); margin: 0 3px; }
.nl-num { text-align: right; font-variant-numeric: tabular-nums; }
.nl-links-table th.nl-num { text-align: right; }

/* ─── Узкие окна: второстепенные колонки прячем раньше отступов ─────── */
@media (max-width: 1400px) {
    .nl-tree {
        --nl-cols: 16px minmax(150px, 2.2fr) minmax(140px, 1fr) minmax(88px, .7fr)
                   minmax(100px, .85fr) minmax(72px, .6fr);
    }
}
@media (max-width: 1200px) {
    .nl-dom-gw, .nl-scope-gw { display: none; }
    .nl-tree {
        --nl-cols: 16px minmax(150px, 2.2fr) minmax(140px, 1fr) minmax(100px, .85fr) minmax(72px, .6fr);
    }
}
@media (max-width: 1000px) {
    .nl-dom-upd, .nl-scope-upd { display: none; }
    .nl-tree { --nl-cols: 16px minmax(140px, 2fr) minmax(130px, .95fr) minmax(96px, .8fr); }
}
@media (max-width: 820px) {
    .nl-cat-desc { display: none; }
    .nl-sum-cats { margin-left: 0; }
    .nl-search { max-width: none; }
}

/* Инспектор домена — фиксированный правый drawer поверх ленты. Когда он открыт,
   прячем только крайнюю (последнюю) колонку — CIDR/машины/health остаются. */
@supports selector(:has(*)) {
    body:has(.nin-drawer.nin-open) .nl-dom-upd,
    body:has(.nin-drawer.nin-open) .nl-scope-upd { display: none; }
}
