:root {
  --bg: #0b1020;
  --panel: rgba(0, 0, 0, 0.22);
  --card: rgba(255, 255, 255, 0.05);
  --text: #e8ecff;
  --muted: #a7b0d8;
  --border: rgba(255, 255, 255, 0.08);
  --primary: #6aa6ff;
  --danger: #ff6a6a;
  --ctrl-h: 38px;

  --ok: #2bd576;
  --warn: #f7c948;
  --bad: #ff5c7a;

  --surface-card: linear-gradient(180deg, rgba(0,0,0,0.10), rgba(0,0,0,0.26)), linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.02));
  --surface-card2: linear-gradient(180deg, rgba(0,0,0,0.08), rgba(0,0,0,0.22)), linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.02));
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background:
    radial-gradient(900px 520px at 20% 0%, rgba(106, 166, 255, 0.25), transparent 60%),
    radial-gradient(900px 520px at 80% 20%, rgba(160, 106, 255, 0.15), transparent 60%),
    var(--bg);
  color: var(--text);
}

.muted { color: var(--muted); }
.small { font-size: 12px; }
.muted.small { line-height: 16px; }
.brand { font-weight: 800; letter-spacing: 0.2px; }
code { background: rgba(255, 255, 255, 0.06); border: 1px solid var(--border); padding: 2px 6px; border-radius: 6px; }

/* Scrollbars */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(232,236,255,0.22) rgba(0,0,0,0.10);
}
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track {
  background: rgba(0,0,0,0.12);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 999px;
}
*::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, rgba(106,166,255,0.30), rgba(160,106,255,0.22));
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 999px;
}
*::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, rgba(106,166,255,0.42), rgba(160,106,255,0.34));
}
*::-webkit-scrollbar-corner { background: rgba(0,0,0,0.12); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.06);
  font-size: 12px;
  white-space: nowrap;
  color: var(--text);
  font-weight: 700;
}
.badge::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: rgba(255,255,255,0.35);
}
.badge--ok { border-color: rgba(43,213,118,.35); background: rgba(43,213,118,.16); }
.badge--ok::before { background: var(--ok); }
.badge--warn { border-color: rgba(247,201,72,.38); background: rgba(247,201,72,.16); }
.badge--warn::before { background: var(--warn); }
.badge--off { border-color: rgba(255,92,122,.38); background: rgba(255,92,122,.16); }
.badge--off::before { background: var(--bad); }

@keyframes badgePulseBad {
  0%, 100% { box-shadow: 0 0 0 rgba(255,92,122,0.00); }
  50% { box-shadow: 0 0 18px rgba(255,92,122,0.35); }
}
.badge--blink { animation: badgePulseBad 1.1s ease-in-out infinite; }

.badgebtn {
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.06);
  color: inherit;
  font: inherit;
  cursor: pointer;
}
.badgebtn:disabled {
  cursor: default;
  opacity: 0.7;
}

.haRoleBadge { gap: 6px; }
.haRoleIcon { font-size: 13px; line-height: 1; }

.tag {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.06);
  font-size: 11px;
  line-height: 16px;
  color: var(--muted);
  vertical-align: middle;
}
.tag--v4 { border-color: rgba(106,166,255,0.30); color: rgba(190,214,255,0.95); }
.tag--v6 { border-color: rgba(160,106,255,0.28); color: rgba(224,200,255,0.95); }

.srcicon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.06);
  color: rgba(231, 236, 255, 0.75);
  vertical-align: middle;
}
.srcicon svg { width: 14px; height: 14px; }
.srcicon--discovered { border-color: rgba(106,166,255,0.35); color: rgba(190,214,255,0.95); }
.srcicon--import { border-color: rgba(160,106,255,0.35); color: rgba(224,200,255,0.95); }
.srcicon--manual { border-color: rgba(255,255,255,0.12); color: rgba(231, 236, 255, 0.70); }
.srcicon--seed { border-color: rgba(106,255,176,0.25); color: rgba(190,255,220,0.90); }
.srcicon--group { border-color: rgba(255,214,106,0.25); color: rgba(255,238,190,0.90); }

.btn {
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  padding: 9px 12px;
  cursor: pointer;
  line-height: 16px;
  white-space: nowrap;
}
.btn.primary { border-color: rgba(106, 166, 255, 0.55); background: rgba(106, 166, 255, 0.18); }
.btn.success { border-color: rgba(43,213,118,0.45); background: rgba(43,213,118,0.18); }
.btn.danger { border-color: rgba(255, 106, 106, 0.35); background: rgba(255, 106, 106, 0.14); }
.btn.secondary:hover { background: rgba(255, 255, 255, 0.10); }

input, select, textarea {
  width: 100%;
  padding: 10px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background-color: rgba(0, 0, 0, 0.25);
  color: var(--text);
  outline: none;
  height: var(--ctrl-h);
}
textarea {
  height: auto;
  resize: vertical;
  font: inherit;
}
input:focus, select:focus, textarea:focus { border-color: rgba(106, 166, 255, 0.55); }
.select.compact { width: 220px; }

select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding-right: 36px;
  background-image:
    linear-gradient(45deg, transparent 50%, rgba(231,236,255,0.70) 50%),
    linear-gradient(135deg, rgba(231,236,255,0.70) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 50%,
    calc(100% - 12px) 50%;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}
select option,
select optgroup {
  background-color: #0b1020;
  color: var(--text);
}

input[type="checkbox"],
input[type="radio"] {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  padding: 0;
  background-color: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.06);
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease, box-shadow 120ms ease, transform 60ms ease;
}
input[type="checkbox"] { border-radius: 6px; }
input[type="radio"] { border-radius: 999px; }
input[type="checkbox"]:hover,
input[type="radio"]:hover {
  background-color: rgba(255, 255, 255, 0.10);
  border-color: rgba(255,255,255,0.14);
}
input[type="checkbox"]:active,
input[type="radio"]:active { transform: translateY(1px); }
input[type="checkbox"]:focus-visible,
input[type="radio"]:focus-visible {
  outline: none;
  border-color: rgba(106, 166, 255, 0.45);
  box-shadow: 0 0 0 3px rgba(106, 166, 255, 0.20), inset 0 1px 0 rgba(255,255,255,0.06);
}
input[type="checkbox"]:checked {
  background-color: rgba(106, 166, 255, 0.22);
  border-color: rgba(106, 166, 255, 0.48);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M4.3 10.4l3.3 3.6L15.7 6.6' fill='none' stroke='white' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 14px 14px;
}
input[type="checkbox"]:indeterminate {
  background-color: rgba(106, 166, 255, 0.22);
  border-color: rgba(106, 166, 255, 0.48);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M5 10h10' fill='none' stroke='white' stroke-width='2.4' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 14px 14px;
}
input[type="radio"]:checked {
  background-color: rgba(106, 166, 255, 0.16);
  border-color: rgba(106, 166, 255, 0.48);
  box-shadow:
    inset 0 0 0 5px rgba(106,166,255,0.85),
    inset 0 1px 0 rgba(255,255,255,0.06);
}

.row { display:flex; gap:10px; align-items:center; }
.row.space { justify-content: space-between; }

.login {
  height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login__card {
  width: min(520px, 96vw);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
  background: var(--surface-card);
  box-shadow: 0 10px 30px rgba(0,0,0,0.25);
}
.login__brand { margin-bottom: 10px; }
.form { display:grid; gap:10px; margin-top: 12px; }
label { display:grid; gap:6px; font-size: 13px; color: var(--muted); }

.seg { display:flex; gap:8px; margin-top: 10px; }
.seg__btn {
  flex: 1;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.06);
  color: var(--text);
  padding: 8px 10px;
  cursor: pointer;
}
.seg__btn--active { border-color: rgba(106, 166, 255, 0.55); background: rgba(106, 166, 255, 0.18); }
.seg--disabled { opacity: 0.7; }
.seg__btn:disabled { opacity: 0.7; cursor: not-allowed; }
.seg--compact { margin-top: 0; gap: 6px; }
.seg--compact .seg__btn { flex: 0 0 auto; padding: 6px 10px; }

.app { height: 100%; display:flex; flex-direction: column; }
.topbar {
  min-height: 56px;
  position: sticky;
  top: 0;
  z-index: 80;
  display:flex;
  align-items:center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: rgba(0,0,0,0.20);
  backdrop-filter: blur(10px);
  gap: 12px;
  flex-wrap: wrap;
}
.topbar__left { display:flex; align-items:center; gap:12px; flex-wrap: wrap; }
.topbar__center { flex:1; display:flex; justify-content:center; min-width: 0; }
.topbar__right { display:flex; align-items:center; gap:10px; flex-wrap: nowrap; min-width: 0; }
.topbar__badges { display:flex; align-items:center; gap:10px; flex-wrap: wrap; }
.topbar__node { display:flex; align-items:center; gap:10px; }
.topbar__actions {
  display:flex;
  align-items:center;
  gap:10px;
  flex-wrap: wrap;
  justify-content: flex-end;
  min-width: 0;
  overflow: visible;
}
.topbar__more { display:none; }
.pill {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 10px;
  background: rgba(255,255,255,0.06);
  font-size: 12px;
  height: 30px;
  display: inline-flex;
  align-items: center;
}
.pill--ok { border-color: rgba(43,213,118,.35); background: rgba(43,213,118,.16); }
.pill--warn { border-color: rgba(247,201,72,.38); background: rgba(247,201,72,.16); }
.pill--off { border-color: rgba(255,92,122,.38); background: rgba(255,92,122,.16); }
.searchrow { display:flex; align-items:center; justify-content: center; gap:10px; }

.btn-group { display:flex; gap:10px; }

.menu { position: relative; }
.menu__panel {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 220px;
  z-index: 60;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(10, 14, 28, 0.92);
  backdrop-filter: blur(8px);
  box-shadow: 0 14px 40px rgba(0,0,0,0.38);
  padding: 6px;
}
.menu__item {
  width: 100%;
  display:flex;
  justify-content: space-between;
  align-items:center;
  gap: 10px;
  padding: 10px 10px;
  border-radius: 10px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}
.menu__item:hover { background: rgba(255,255,255,0.06); border-color: rgba(255,255,255,0.06); }
.menu__item.danger { color: rgba(255,180,180,0.95); }
.menu__label { padding: 10px 10px; color: var(--muted); font-size: 12px; }
.menu__sep { height: 1px; background: rgba(255,255,255,0.08); margin: 6px 6px; }

@media (max-width: 1180px) {
  .search { width: min(420px, 45vw); }
  .topbar__actions { display:none; }
  .topbar__more { display:block; }
}

@media (max-width: 980px) {
  .topbar__center { order: 3; width: 100%; justify-content: flex-start; min-width: 0; }
  .searchrow { width: 100%; flex-wrap: wrap; }
  .search { width: 100%; }
}

#whoamiBtn {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.body { flex:1; display:grid; grid-template-columns: 240px 1fr 320px; min-height: 0; }
.sidebar {
  border-right: 1px solid var(--border);
  padding: 12px;
  background: rgba(0,0,0,0.18);
  overflow: auto;
}
.sidebar__head { margin-bottom: 10px; display:flex; gap:10px; align-items:center; }
.nav { display:flex; flex-direction: column; gap: 4px; }
.nav__item {
  display:flex;
  align-items: center;
  padding: 10px 10px;
  border-radius: 10px;
  color: var(--text);
  text-decoration: none;
  border: 1px solid transparent;
}
.nav__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.06);
  color: rgba(231, 236, 255, 0.80);
  flex: 0 0 auto;
}
.nav__icon svg { width: 16px; height: 16px; stroke: currentColor; }
.nav__label { margin-left: 10px; display:flex; align-items:center; gap:8px; }
.nav__item:hover { background: rgba(255,255,255,0.06); border-color: rgba(255,255,255,0.06); }
.nav__item--active { background: rgba(106, 166, 255, 0.12); border-color: rgba(106, 166, 255, 0.22); }
.nav__group { margin-top: 10px; margin-bottom: 6px; font-size: 12px; color: var(--muted); }
.nav__item--sub { padding-left: 18px; }
.nav__item--sub .nav__icon { width: 24px; height: 24px; border-radius: 9px; }

.main { padding: 14px; overflow:auto; min-width: 0; }
.view { min-height: 0; }
.card {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  background: var(--surface-card);
  box-shadow: 0 10px 30px rgba(0,0,0,0.25);
}

.callout {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  background: rgba(0,0,0,0.18);
}
.callout--locked {
  border-color: rgba(255,214,106,0.25);
  background: rgba(255,214,106,0.06);
}

.drawer {
  border-left: 1px solid var(--border);
  background: rgba(0,0,0,0.18);
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px;
  min-width: 0;
}
.drawer__head {
  display:flex;
  align-items:center;
  gap:10px;
  position: sticky;
  top: 0;
  z-index: 5;
  padding: 10px 0;
  background: rgba(0,0,0,0.18);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.drawer__head input { min-width: 0; }
.drawer__title { font-weight: 700; }
.drawer__tabs { display:flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.drawer__tabs .tab { flex: 1 1 calc(50% - 8px); }
.tab {
  flex:1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.06);
  color: var(--text);
  cursor: pointer;
}
.tab__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  color: rgba(231, 236, 255, 0.78);
  flex: 0 0 auto;
}
.tab__icon svg { width: 18px; height: 18px; stroke: currentColor; }
.tab--active { border-color: rgba(106, 166, 255, 0.55); background: rgba(106, 166, 255, 0.18); }
.drawer__body { margin-top: 10px; }

body.drawer-collapsed .body { grid-template-columns: 240px 1fr 44px; }
body.drawer-collapsed .drawer { padding: 10px 6px; }
body.drawer-collapsed .drawer .drawer__title,
body.drawer-collapsed .drawer #drawerSearch,
body.drawer-collapsed .drawer .drawer__tabs,
body.drawer-collapsed .drawer .drawer__body { display: none; }
body.drawer-collapsed #drawerToggleBtn { width: 100%; padding: 8px 6px; }
body.drawer-collapsed .sidepanel { right: 44px; width: min(560px, 52vw); }

body.sidebar-collapsed .body { grid-template-columns: 44px 1fr 320px; }
body.sidebar-collapsed .sidebar { padding: 10px 6px; }
body.sidebar-collapsed .nav__group { display: none; }
body.sidebar-collapsed .nav__label { display: none; }
body.sidebar-collapsed .nav__item { justify-content: center; padding: 10px 6px; }
body.sidebar-collapsed #sidebarToggleBtn { width: 100%; padding: 8px 6px; }

body.sidebar-collapsed.drawer-collapsed .body { grid-template-columns: 44px 1fr 44px; }
.item {
  display:flex;
  justify-content: space-between;
  gap: 10px;
  align-items:center;
  padding: 9px 10px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.03);
  margin-bottom: 8px;
  min-width: 0;
}
.item__name { font-weight: 600; font-size: 13px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item__sub { font-size: 12px; color: var(--muted); }
.drag { cursor: grab; user-select: none; }
.drag:active { cursor: grabbing; }

.table { width: 100%; border-collapse: collapse; margin-top: 12px; }
th, td { text-align:left; padding: 10px; border-bottom: 1px solid var(--border); font-size: 13px; }
th { color: var(--muted); font-weight: 700; }
.table tbody tr:hover { background: rgba(255,255,255,0.04); }

/* Nodes: HA grouping (visual ribbon/card) */
.haGroupHeadRow:hover { background: transparent !important; }
.haGroupHeadRow td { border-bottom: 0; padding: 12px 10px; }
.haGroupHead {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px 14px;
  background: linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.02));
  box-shadow: 0 10px 30px rgba(0,0,0,0.22);
  position: relative;
  overflow: hidden;
}
.haGroupHead::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(520px 140px at 10% 0%, rgba(106,166,255,0.16), transparent 55%),
    radial-gradient(420px 140px at 70% 20%, rgba(160,106,255,0.10), transparent 60%);
  pointer-events: none;
}
.haGroupHead > * { position: relative; z-index: 1; }

.haRibbon {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid rgba(106,166,255,0.35);
  background: rgba(106,166,255,0.14);
  font-weight: 800;
  letter-spacing: 0.2px;
  margin-bottom: 8px;
}
.haRibbon::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: rgba(106,166,255,0.85);
  box-shadow: 0 0 0 3px rgba(106,166,255,0.14);
}
.haRibbon--off {
  border-color: rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.06);
}
.haRibbon--off::before {
  background: rgba(255,255,255,0.30);
  box-shadow: 0 0 0 3px rgba(255,255,255,0.08);
}

.haMemberRow td { background: rgba(0,0,0,0.08); }
.haMemberRow td:first-child { border-left: 1px solid rgba(255,255,255,0.10); }
.haMemberRow td:last-child { border-right: 1px solid rgba(255,255,255,0.10); }
.haMemberRow--first td { border-top: 1px solid rgba(255,255,255,0.10); }
.haMemberRow--last td { border-bottom: 1px solid rgba(255,255,255,0.10); }
.haMemberRow:hover td { background: rgba(255,255,255,0.04); }

.pre {
  margin-top: 12px;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.25);
  overflow: auto;
  max-height: 360px;
  font-size: 12px;
}

.list {
  margin: 6px 0 0;
  padding-left: 18px;
}

.list li {
  margin: 6px 0;
}

.linkbtn {
  background: transparent;
  border: 0;
  padding: 0;
  text-align: left;
  cursor: pointer;
  display: inline;
  color: var(--text);
  font: inherit;
}

.linkbtn:hover {
  text-decoration: underline;
}

.sidepanel {
  position: fixed;
  top: var(--topbar-height, 56px);
  right: 320px;
  width: min(560px, 46vw);
  height: calc(100% - var(--topbar-height, 56px));
  border-left: 1px solid var(--border);
  background: rgba(0,0,0,0.72);
  backdrop-filter: blur(12px);
  z-index: 50;
  padding: 12px;
  overflow: auto;
}
.sidepanel__head { display:flex; justify-content: space-between; gap: 12px; align-items:center; }
.sidepanel__title { font-weight: 800; }
.grid2 { display:grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; margin-top: 10px; }
.grid3 { display:grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 10px; margin-top: 12px; }
.check { display:flex; align-items:center; gap:10px; color: var(--muted); font-size: 13px; padding: 6px 0; }
.check input:not([type="checkbox"]):not([type="radio"]) { width: auto; }

.kpi { padding: 14px; }
.kpi__label { color: var(--muted); font-size: 12px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; }
.kpi__value { font-size: 30px; font-weight: 900; line-height: 1.05; margin-top: 6px; }
.kpi__hint { margin-top: 8px; color: var(--muted); font-size: 13px; }
.kpi__badge { font-size: 12px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--border); background: rgba(255,255,255,0.06); }
.kpi--ok { border-color: rgba(60, 202, 94, 0.35); }
.kpi--warn { border-color: rgba(255, 196, 0, 0.35); }
.kpi--off { border-color: rgba(255, 84, 84, 0.35); }

.dashlist { display: grid; gap: 8px; }
.dashitem {
  display:flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(0,0,0,0.18);
}
.dashitem__label { color: var(--muted); font-size: 13px; }
.dashitem__value { font-weight: 900; }

.toggle {
  width: 18px;
  height: 18px;
}
.actbtns .btn { padding: 6px 10px; border-radius: 10px; }
.actbtns { white-space: nowrap; }
.iconbtn.btn { padding: 6px 8px; min-width: 34px; text-align: center; font-weight: 800; }
.iconbtn svg { width: 16px; height: 16px; stroke: currentColor; }
.sortbtns { display: inline-flex; gap: 6px; }

.chipbox {
  display:flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.25);
  min-height: 44px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.06);
  font-size: 12px;
  line-height: 18px;
}
.chip--ro {
  border-style: dashed;
  opacity: 0.9;
}
.chip__rotag {
  font-size: 10px;
  opacity: 0.75;
  padding: 1px 6px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.14);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 18px;
}
.modal--sub { z-index: 90; }
.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(8px);
}
.modal__card {
  position: relative;
  width: min(720px, 92vw);
  max-height: min(88vh, 840px);
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
  background: rgba(0, 0, 0, 0.65);
  box-shadow: 0 16px 40px rgba(0,0,0,0.45);
}
.modal__card--sub {
  width: min(860px, 94vw);
  max-height: min(80vh, 760px);
}
.modal__title { font-weight: 800; }

body.modal-nonblocking #modal { pointer-events: none; }
body.modal-nonblocking #modal .modal__card { pointer-events: auto; }
body.modal-nonblocking #modalBackdrop {
  pointer-events: none;
  background: rgba(0, 0, 0, 0.22);
  backdrop-filter: none;
}

.checklist {
  display: grid;
  gap: 8px;
  padding: 10px 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.25);
  max-height: 320px;
  overflow: auto;
}

.details {
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(0,0,0,0.16);
  padding: 10px 10px;
}
.details__summary {
  cursor: pointer;
  color: var(--muted);
  font-weight: 700;
  user-select: none;
}
.details__body { margin-top: 12px; }

.sidepanel__body--nat {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.natcard {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  background: rgba(255,255,255,0.02);
}
.pickerrow {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
}
.pickerrow .chipbox {
  min-height: 44px;
}
.pickbtns {
  display: flex;
  gap: 6px;
  align-self: stretch;
  align-items: center;
}
.muted.tiny {
  font-size: 11px;
  color: var(--text-muted);
}

/* Matching condition: keep layout stable when chipboxes grow/shrink. */
.matchgrid {
  margin-top: 8px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  align-items: start;
}
.matchgrid > * { min-width: 0; }
.matchgrid .chipbox { min-height: 58px; }
@media (max-width: 980px) {
  .matchgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .matchgrid { grid-template-columns: 1fr; }
}

/* Chain accordion (Firewall view) */
.chainacc { padding: 0; }
.chainacc > summary {
  list-style: none;
  padding: 10px 12px;
  cursor: pointer;
}
.chainacc > summary::-webkit-details-marker { display: none; }
.chainacc__summary {
  display: grid;
  grid-template-columns: 18px 1fr auto;
  align-items: center;
  gap: 10px;
  user-select: none;
}
.chainacc__chev {
  width: 18px;
  text-align: center;
  color: rgba(231, 236, 255, 0.70);
}
.chainacc[open] .chainacc__chev { transform: rotate(90deg); }
.chainacc__title {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  min-width: 0;
}
.chainacc__title .name {
  font-weight: 800;
  color: rgba(231, 236, 255, 0.92);
}
.chainacc__actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.chainacc__body { padding: 0 12px 12px; }
.chainacc__body .table { margin-top: 10px; }
.tagbtn.tagbtn--link {
  text-decoration: none;
}

.drop-target.drop-hover {
  border-color: rgba(106, 166, 255, 0.55);
  box-shadow: 0 0 0 2px rgba(106, 166, 255, 0.12);
}

.draghandle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.04);
  cursor: grab;
  user-select: none;
}
.draghandle:active { cursor: grabbing; }

.tags {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
}
.ctchips {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.tagbtn {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 12px;
  line-height: 18px;
  cursor: pointer;
}
.tagbtn:hover { color: var(--text); border-color: rgba(255,255,255,0.22); }
.tagbtn--on {
  border-color: rgba(106, 166, 255, 0.40);
  background: rgba(106, 166, 255, 0.10);
  color: rgba(210, 228, 255, 0.95);
}

.matchstack {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.matchsection {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(0,0,0,0.14);
  padding: 10px 10px;
}
.matchsection__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.matchsection__title {
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.02em;
  color: rgba(231, 236, 255, 0.78);
}
.matchsection .chipbox {
  min-height: 58px;
}
.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.06);
  font-size: 12px;
  line-height: 18px;
  white-space: nowrap;
  color: var(--muted);
}
.chip__x {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  line-height: 14px;
  padding: 0 2px;
}
.chip__x:hover { color: var(--text); }
.drop-hover { outline: 2px solid rgba(106, 166, 255, 0.55); outline-offset: 2px; }

.toast {
  position: fixed;
  top: 64px;
  right: 18px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(0,0,0,0.60);
  padding: 10px 12px;
  z-index: 100;
  max-width: 520px;
}

/* Nodes dashboard (cards) */
.nodesdash{
  --nd-surface: var(--surface-card);
  --nd-surface2: var(--surface-card2);
  --nd-stroke: var(--border);
  --nd-text: var(--text);
  --nd-muted: var(--muted);
  --nd-muted2: rgba(167,176,216,0.75);

  --nd-ok: var(--ok);
  --nd-warn: var(--warn);
  --nd-bad: var(--bad);

  --nd-chip:rgba(255,255,255,0.06);
  --nd-chipStroke: var(--border);

  --nd-shadow: 0 10px 30px rgba(0,0,0,0.25);

  display:flex;
  flex-direction:column;
  gap: 14px;
  margin-top: 12px;
  color: var(--nd-text);
}
.nodesdash__group{ padding: 0; overflow: hidden; }
.nodesdash__groupHead{
  display:flex;
  gap: 12px;
  padding: 14px;
  align-items:flex-start;
  justify-content:space-between;
  border-bottom: 1px solid var(--nd-stroke);
  background: transparent;
}
.nodesdash__groupTitle { display:flex; flex-direction:column; gap: 8px; min-width: 260px; }
.nodesdash__groupTitleRow { display:flex; align-items:center; gap: 10px; flex-wrap:wrap; }
.nodesdash .pill.pill--sm { height: 28px; padding: 5px 10px; font-size: 12px; gap: 8px; }

/* Support ticket comments slide-over */
.slideover__backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 80;
}
.slideover {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  width: min(480px, calc(100vw - 18px));
  background: linear-gradient(180deg, rgba(18, 26, 51, 0.98), rgba(8, 12, 25, 0.98));
  border-left: 1px solid var(--border);
  box-shadow: -20px 0 50px rgba(0, 0, 0, 0.5);
  transform: translateX(100%);
  transition: transform 180ms ease;
  z-index: 90;
  display: flex;
  flex-direction: column;
}
.slideover.is-open {
  transform: translateX(0);
}
.slideover__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 14px 10px;
  border-bottom: 1px solid var(--border);
}
.slideover__title {
  font-size: 14px;
  font-weight: 700;
}
.slideover__body {
  padding: 14px;
  overflow: auto;
}
.commentlist {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.commentitem {
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.22);
  border-radius: 12px;
  padding: 10px;
}
.commentitem__meta {
  display: flex;
  gap: 10px;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 6px;
}
.commentitem__author {
  font-weight: 700;
}
.commentitem__body {
  white-space: pre-wrap;
  word-break: break-word;
}
.commentbox {
  margin-top: 14px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}
.nodesdash code{
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.14);
  color: var(--nd-text);
}
.dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--nd-muted2);
  display: inline-block;
}
.dot--ok { background: var(--nd-ok); }
.dot--warn { background: var(--nd-warn); }
.dot--off { background: var(--nd-bad); }
.nodesdash__groupSubtitle{
  display:flex;
  gap: 10px;
  flex-wrap:wrap;
  color: var(--nd-muted);
  font-size: 13px;
  align-items:center;
}
.nodesdash__sep { color: rgba(255,255,255,0.22); }
.nodesdash__groupStatus{
  text-align:right;
  display:flex;
  flex-direction:column;
  align-items:flex-end;
  gap: 6px;
  min-width: 220px;
}
.nodesdash__statusBig{ display:flex; align-items:center; gap: 10px; font-weight: 800; }
.nodesdash__statusHint{ font-size: 13px; color: var(--nd-muted); }
.nodesdash__nodes{ padding: 12px; display:flex; flex-direction:column; gap: 10px; }

.nodecard{ border-radius: 14px; }
.nodecard__top{
  display:grid;
  grid-template-columns: 28px 1fr auto;
  gap: 12px;
  align-items:start;
}
.nodecard__check{
  margin-top: 6px;
  width: 18px;
  height: 18px;
  accent-color: rgba(106, 166, 255, 0.85);
}
.nodecard__main{ display:flex; flex-direction:column; gap: 10px; min-width: 0; }
.nodecard__title{ display:flex; gap: 10px; flex-wrap:wrap; align-items:center; }
.nodecard__name{ font-weight: 800; letter-spacing: 0.2px; color: var(--nd-text); }
.nodecard__name:hover{ color: rgba(255,255,255,.96); }
.rolechip{
  border: 1px solid var(--nd-chipStroke);
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  color: var(--nd-muted);
  background: rgba(255,255,255,.05);
  display:inline-flex;
  align-items:center;
  gap: 8px;
  white-space: nowrap;
}
.rolechip--master{ border-color: rgba(247,201,72,.35); }
.rolechip--backup{ border-color: rgba(247,201,72,.35); }
.rolechip--ok{
  border-color: rgba(43,213,118,.38);
  background: rgba(43,213,118,.14);
  color: var(--nd-text);
}
.rolechip--warn{
  border-color: rgba(247,201,72,.40);
  background: rgba(247,201,72,.14);
  color: var(--nd-text);
}

.nodecard__subline{
  display:flex;
  gap: 10px;
  flex-wrap:wrap;
  color: rgba(232,236,255,0.84);
  font-size: 13px;
  align-items:center;
}
.nodecard__pipe{
  display:flex;
  align-items:center;
  gap: 10px;
  flex-wrap:wrap;
  font-size: 12px;
  color: var(--nd-muted);
}
.pipeStep{
  display:inline-flex;
  align-items:center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--nd-chipStroke);
  background: rgba(255,255,255,.03);
  white-space: nowrap;
}
.pipeStep--ok{ border-color: rgba(43,213,118,.22); }
.pipeStep--warn{ border-color: rgba(247,201,72,.22); }
.pipeStep--off{ border-color: rgba(255,92,122,.25); }
.pipeArrow{ color: rgba(255,255,255,0.22); }

.nodecard__detailsToggle{
  display:inline-flex;
  align-items:center;
  gap: 8px;
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  user-select: none;
  width: fit-content;
  padding: 8px 10px;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  background: rgba(255,255,255,0.04);
  transition: background-color 120ms ease, border-color 120ms ease, transform 60ms ease;
}
.nodecard__detailsToggle:hover{
  background: rgba(255,255,255,0.07);
  border-color: rgba(255,255,255,0.12);
}
.nodecard__detailsToggle:active{ transform: translateY(1px); }
.nodecard__detailsToggle--open{
  border-color: rgba(106,166,255,0.28);
  background: rgba(106,166,255,0.10);
}
.nodecard__chev{ font-size: 14px; line-height: 1; color: rgba(232,236,255,0.90); }
.nodecard__detailsHint{
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
}
.nodecard__detailsPanel{
  margin-top: 10px;
  display:none;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(0,0,0,0.18);
  border-radius: 14px;
  padding: 10px;
}
.nodecard__detailsPanel--open{ display:block; }
.nodecard__detailsGrid{
  display:flex;
  flex-direction:column;
  gap: 8px;
  color: var(--nd-muted);
  font-size: 13px;
}
.kv{
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(255,255,255,.03);
  padding: 8px 10px;
  border-radius: 12px;
  display:flex;
  gap: 8px;
  align-items:center;
  width: 100%;
}
.kv b{ color: var(--nd-text); font-weight: 800; }

.nodecard__actions{ display:flex; align-items:center; justify-content:flex-end; gap: 10px; flex-wrap:wrap; }
.btn.btn--sm{ height: 32px; padding: 7px 10px; font-size: 13px; }
.btn.iconbtn.btn--sm{ width: 36px; padding: 0; }

.nodesdash__empty{
  border: 1px dashed rgba(255,255,255,0.18);
  border-radius: 14px;
  padding: 14px;
  color: var(--nd-muted);
  background: rgba(0,0,0,0.10);
}

@media (max-width: 1100px) {
  .body { grid-template-columns: 220px 1fr 280px; }
  .sidepanel { right: 280px; width: min(520px, 56vw); }
}
@media (max-width: 880px) {
  .body { grid-template-columns: 220px 1fr; }
  .drawer { display:none; }
  .sidepanel { right: 0; width: 100vw; }
  .nodesdash__groupHead{ flex-direction:column; align-items:flex-start; }
  .nodesdash__groupStatus{ align-items:flex-start; text-align:left; }
  .nodecard__top{ grid-template-columns: 28px 1fr; }
  .nodecard__actions{ justify-content:flex-start; }
}
