/* ── Artifice — Shared Styles ── */

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url(/static/fonts/inter-latin.woff2) format('woff2');
}
@font-face {
  font-family: 'Fira Code';
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url(/static/fonts/fira-code-latin.woff2) format('woff2');
}
:root {
  --bg: #0f1923;
  --bg-deep: #0b1420;
  --bg-surface: #111b2b;
  --panel: #162233;
  --panel-alt: #111b2b;
  --border: #243447;
  --border-dim: #141e32;
  --text: #d4dce6;
  --text-dim: #7a8a9e;
  --text-muted: #384560;
  --accent: #5b8af0;
  --accent-hover: #4a75d4;
  --accent-dim: rgba(91,138,240,0.08);
  --accent-cyan: #32b8c6;
  --accent-green: #3aad6b;
  --accent-rose: #c75070;
  --color-danger: #ef4444;
  --color-warning: #f59e0b;
  --color-success: #22c55e;
  --sev-critical: #ef4444;
  --sev-high: #f59e0b;
  --sev-medium: #c9a84c;
  --sev-low: #22c55e;
  --sev-info: #7a8a9e;
  --font-mono: 'Fira Code','Cascadia Code','Consolas','Courier New', monospace;
  --font-ui: 'Inter','Segoe UI', system-ui, -apple-system, sans-serif;
  --sidebar-width: 240px;
  --sidebar-collapsed-width: 56px;
  --topbar-height: 44px;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body {
  height: 100%;
  overflow: hidden;
}
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

/* ── Alpine cloak ── */
[x-cloak] { display: none !important; }

/* ── HTMX indicator ── */
.htmx-indicator { opacity: 0; transition: opacity 0.2s ease-in; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }

/* ══════════════════════════════════════════════════════
   APP SHELL
══════════════════════════════════════════════════════ */
.app-shell {
  display: flex;
  height: 100vh;
  width: 100%;
  overflow: hidden;
}

/* ══════════════════════════════════════════════════════
   SIDEBAR
══════════════════════════════════════════════════════ */
.sidebar {
  display: flex;
  flex-direction: column;
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-deep);
  border-right: 1px solid var(--border-dim);
  overflow: hidden;
  transition: width 0.22s cubic-bezier(0.4, 0, 0.2, 1),
              min-width 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 50;
  flex-shrink: 0;
}
.sidebar.collapsed {
  width: var(--sidebar-collapsed-width);
  min-width: var(--sidebar-collapsed-width);
}
/* Pre-Alpine collapsed state (prevents flash) */
html.sidebar-collapsed-init .sidebar {
  width: var(--sidebar-collapsed-width);
  min-width: var(--sidebar-collapsed-width);
}
html.sidebar-collapsed-init .sidebar .sidebar-label,
html.sidebar-collapsed-init .sidebar .brand-text,
html.sidebar-collapsed-init .sidebar .sidebar-chevron,
html.sidebar-collapsed-init .sidebar .sidebar-version,
html.sidebar-collapsed-init .sidebar .sidebar-footer-link {
  opacity: 0;
  width: 0;
  pointer-events: none;
}

/* ── Brand ── */
.sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px 0 14px;
  height: var(--topbar-height);
  border-bottom: 1px solid var(--border-dim);
  flex-shrink: 0;
}
.sidebar-brand-link {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  overflow: hidden;
  min-width: 0;
}
.brand-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  min-width: 26px;
  border-radius: 5px;
  background: var(--bg-deep);
  border: 1.5px solid rgba(212,220,230,0.22);
  font-size: 0.62em;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.5px;
  box-shadow: 0 0 10px rgba(0,0,0,0.5), 0 0 20px rgba(0,0,0,0.25);
  text-shadow: 0 0 8px rgba(0,0,0,0.7);
  position: relative;
  flex-shrink: 0;
}
.brand-icon::after {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: 6px;
  background: linear-gradient(135deg, rgba(0,0,0,0.2) 0%, transparent 40%, rgba(0,0,0,0.15) 100%);
  pointer-events: none;
}
.brand-text {
  font-size: 0.92em;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 1;
  transition: opacity 0.15s;
}
.sidebar.collapsed .brand-text {
  opacity: 0;
  width: 0;
  pointer-events: none;
}
.sidebar-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 5px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  transition: color 0.15s, background 0.15s;
  flex-shrink: 0;
}
.sidebar-toggle svg {
  width: 14px;
  height: 14px;
}
.sidebar-toggle:hover {
  color: var(--text-dim);
  background: rgba(255,255,255,0.04);
}
.sidebar.collapsed .sidebar-toggle {
  margin: 0 auto;
}

/* ── Nav icons (shared) ── */
.nav-i {
  width: 15px;
  height: 15px;
  min-width: 15px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.45;
  transition: opacity 0.15s;
}

/* ── Primary nav list ── */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 0;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.sidebar-nav::-webkit-scrollbar { display: none; }

/* ── Nav links ── */
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px 0 14px;
  height: 36px;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.84em;
  font-weight: 500;
  letter-spacing: 0.01em;
  white-space: nowrap;
  border-left: 2px solid transparent;
  border-radius: 0 6px 6px 0;
  margin: 1px 8px 1px 0;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
  overflow: hidden;
}
.sidebar-link:hover {
  color: var(--text);
  background: rgba(255,255,255,0.035);
}
.sidebar-link:hover .nav-i { opacity: 0.75; }
.sidebar-link.active {
  color: var(--text);
  background: var(--accent-dim);
  border-left-color: var(--accent);
}
.sidebar-link.active .nav-i { opacity: 1; }

/* Secondary links (slightly dimmer default state) */
.sidebar-link-secondary {
  color: var(--text-muted);
  font-size: 0.82em;
}
.sidebar-link-secondary:hover { color: var(--text-dim); }
.sidebar-link-secondary.active { color: var(--text); }

/* ── Labels (collapse hide) ── */
.sidebar-label {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  opacity: 1;
  transition: opacity 0.12s;
}
.sidebar.collapsed .sidebar-label {
  opacity: 0;
  width: 0;
  pointer-events: none;
}

/* ── Section separator ── */
.sidebar-sep {
  height: 1px;
  background: var(--border-dim);
  margin: 6px 14px;
}

/* ── Security group (expandable) ── */
.sidebar-group {
  margin: 1px 0;
}
.sidebar-group-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px 0 14px;
  height: 36px;
  width: calc(100% - 8px);
  color: var(--text-dim);
  background: none;
  border: none;
  border-left: 2px solid transparent;
  border-radius: 0 6px 6px 0;
  margin: 0 8px 0 0;
  font-size: 0.84em;
  font-weight: 500;
  letter-spacing: 0.01em;
  cursor: pointer;
  font-family: var(--font-ui);
  text-align: left;
  white-space: nowrap;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
  overflow: hidden;
}
.sidebar-group-btn:hover {
  color: var(--text);
  background: rgba(255,255,255,0.035);
}
.sidebar-group-btn:hover .nav-i { opacity: 0.75; }
.sidebar-group-btn.active {
  color: var(--text);
  background: var(--accent-dim);
  border-left-color: var(--accent);
}
.sidebar-group-btn.active .nav-i { opacity: 1; }

/* Push chevron to the right */
.sidebar-chevron {
  width: 12px;
  height: 12px;
  min-width: 12px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.35;
  margin-left: auto;
  transition: transform 0.2s, opacity 0.15s;
  flex-shrink: 0;
}
.sidebar-chevron.open { transform: rotate(180deg); }
.sidebar-group-btn:hover .sidebar-chevron { opacity: 0.6; }
.sidebar.collapsed .sidebar-chevron { display: none; }

/* Sub-items */
.sidebar-sub {
  overflow: hidden;
}
.sidebar-sublink {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px 0 30px;
  height: 32px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.81em;
  font-weight: 500;
  white-space: nowrap;
  border-left: 2px solid transparent;
  border-radius: 0 5px 5px 0;
  margin: 1px 8px 1px 0;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
  overflow: hidden;
}
.sidebar-sublink:hover {
  color: var(--text-dim);
  background: rgba(255,255,255,0.025);
}
.sidebar-sublink:hover .nav-i { opacity: 0.65; }
.sidebar-sublink.active {
  color: var(--accent);
  background: var(--accent-dim);
  border-left-color: var(--accent);
}
.sidebar-sublink.active .nav-i { opacity: 1; }

/* Collapsed sidebar: show sub-items as regular links (tooltips via title attr) */
.sidebar.collapsed .sidebar-sublink {
  padding: 0 0 0 14px;
  height: 36px;
  justify-content: center;
}
.sidebar.collapsed .sidebar-group-btn {
  justify-content: center;
  padding: 0;
  width: var(--sidebar-collapsed-width);
  margin: 0;
}

/* Sub-group separator */
.sidebar-sub-sep {
  height: 1px;
  background: var(--border-dim);
  margin: 4px 14px;
}

/* ── Admin section ── */
.sidebar-admin {
  flex-shrink: 0;
  padding-bottom: 2px;
}
.sidebar-admin-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px 0 14px;
  height: 34px;
  width: calc(100% - 8px);
  color: var(--text-muted);
  background: none;
  border: none;
  border-left: 2px solid transparent;
  border-radius: 0 6px 6px 0;
  margin: 0 8px 0 0;
  font-size: 0.8em;
  font-weight: 500;
  letter-spacing: 0.01em;
  cursor: pointer;
  font-family: var(--font-ui);
  text-align: left;
  white-space: nowrap;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
  overflow: hidden;
}
.sidebar-admin-btn:hover {
  color: var(--text-dim);
  background: rgba(255,255,255,0.025);
}
.sidebar-admin-btn:hover .nav-i { opacity: 0.65; }
.sidebar-admin-btn.active {
  color: var(--text);
  border-left-color: var(--accent);
  background: var(--accent-dim);
}
.sidebar.collapsed .sidebar-admin-btn {
  justify-content: center;
  padding: 0;
  width: var(--sidebar-collapsed-width);
  margin: 0;
}
.sidebar-sub-admin .sidebar-sublink {
  padding-left: 26px;
}

/* ── Footer ── */
.sidebar-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-top: 1px solid var(--border-dim);
  flex-shrink: 0;
  gap: 8px;
  overflow: hidden;
}
.sidebar-footer-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.75em;
  font-weight: 500;
  opacity: 0.7;
  transition: color 0.15s, opacity 0.15s;
  white-space: nowrap;
  overflow: hidden;
}
.sidebar-footer-link:hover { color: var(--text-dim); opacity: 1; }
.sidebar-version {
  font-size: 0.68em;
  font-weight: 400;
  color: var(--text-muted);
  font-family: var(--font-mono);
  white-space: nowrap;
  flex-shrink: 0;
  opacity: 1;
  transition: opacity 0.12s;
}
.sidebar.collapsed .sidebar-footer {
  justify-content: center;
  padding: 10px 0;
}
.sidebar.collapsed .sidebar-footer-link,
.sidebar.collapsed .sidebar-version {
  display: none;
}

/* ── Mobile overlay ── */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 40;
  backdrop-filter: blur(2px);
}

/* ══════════════════════════════════════════════════════
   MAIN AREA
══════════════════════════════════════════════════════ */
.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  min-width: 0;
}

/* ── Top bar ── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 16px 0 12px;
  height: var(--topbar-height);
  min-height: var(--topbar-height);
  background: var(--bg-deep);
  border-bottom: 1px solid var(--border-dim);
  z-index: 10;
  flex-shrink: 0;
}
.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

/* Mobile hamburger — hidden on desktop */
.topbar-hamburger {
  display: none;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 5px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-dim);
  flex-shrink: 0;
  transition: color 0.15s, background 0.15s;
}
.topbar-hamburger svg { width: 16px; height: 16px; }
.topbar-hamburger:hover { color: var(--text); background: rgba(255,255,255,0.04); }

/* ── Hierarchy breadcrumb ── */
.hierarchy-breadcrumb {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.8em;
  font-weight: 500;
}
.hier-segment {
  color: var(--text-muted);
  padding: 2px 7px;
  border-radius: 4px;
  transition: color 0.2s, background 0.2s;
  cursor: default;
  white-space: nowrap;
}
.hier-segment.hier-active {
  color: var(--accent);
  background: var(--accent-dim);
}
.hier-sep {
  display: flex;
  align-items: center;
  color: var(--text-muted);
  opacity: 0.35;
}
.hier-sep svg { width: 12px; height: 12px; }

/* ── New Scan button ── */
.topbar-new-scan {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  background: rgba(91,138,240,0.12);
  border: 1px solid rgba(91,138,240,0.35);
  border-radius: 5px;
  color: var(--accent);
  text-decoration: none;
  font-size: 0.82em;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.topbar-new-scan svg { width: 13px; height: 13px; stroke-width: 2; }
.topbar-new-scan:hover {
  background: rgba(91,138,240,0.2);
  border-color: var(--accent);
  box-shadow: 0 0 12px rgba(91,138,240,0.15);
}

/* ── User group ── */
.topbar-user-group {
  display: flex;
  align-items: center;
  gap: 2px;
}
.topbar-icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 5px;
  color: var(--text-dim);
  text-decoration: none;
  transition: color 0.15s, background 0.15s;
}
.topbar-icon-btn:hover { color: var(--text); background: rgba(255,255,255,0.04); }
.topbar-icon-btn.active { color: var(--accent); }
.topbar-icon-btn .nav-i { width: 14px; height: 14px; opacity: 0.55; }
.topbar-icon-btn:hover .nav-i { opacity: 0.85; }
.topbar-icon-btn.active .nav-i { opacity: 1; color: var(--accent); }

.topbar-user-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border-dim);
  border-radius: 5px;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.8em;
  font-family: var(--font-mono);
  white-space: nowrap;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 0.15s, border-color 0.15s;
}
.topbar-user-chip:hover { color: var(--text); border-color: var(--border); }
.topbar-user-chip.active { color: var(--accent); border-color: rgba(91,138,240,0.3); }
.topbar-user-chip .nav-i { opacity: 0.4; width: 13px; height: 13px; }
.topbar-user-chip:hover .nav-i { opacity: 0.7; }

.topbar-logout {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 5px;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.15s, background 0.15s;
}
.topbar-logout:hover { color: var(--color-danger); background: rgba(239,68,68,0.06); }
.topbar-logout .nav-i { width: 14px; height: 14px; opacity: 0.5; }
.topbar-logout:hover .nav-i { opacity: 1; }

/* ── Dev/Demo badges (topbar) ── */
.dev-badge {
  padding: 2px 7px;
  background: rgba(201,168,76,0.12);
  border: 1px solid rgba(201,168,76,0.25);
  border-radius: 3px;
  color: #c9a84c;
  font-size: 0.68em;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  font-family: var(--font-mono);
}
.demo-badge {
  padding: 2px 7px;
  background: rgba(91,138,240,0.1);
  border: 1px solid rgba(91,138,240,0.2);
  border-radius: 3px;
  color: var(--accent);
  font-size: 0.68em;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  font-family: var(--font-mono);
}

/* ── Main content area ── */
.main-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

/* ── Content wrapper (child templates) ── */
.ms-content {
  padding: 24px;
}

/* ══════════════════════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════════════════════ */
@media (max-width: 1024px) {
  .sidebar:not(.mobile-open) {
    width: var(--sidebar-collapsed-width);
    min-width: var(--sidebar-collapsed-width);
  }
  .sidebar:not(.mobile-open) .sidebar-label,
  .sidebar:not(.mobile-open) .brand-text,
  .sidebar:not(.mobile-open) .sidebar-chevron,
  .sidebar:not(.mobile-open) .sidebar-version,
  .sidebar:not(.mobile-open) .sidebar-footer-link {
    opacity: 0;
    width: 0;
    pointer-events: none;
  }
  .sidebar:not(.mobile-open) .sidebar-brand {
    justify-content: center;
    padding: 0;
  }
  .sidebar:not(.mobile-open) .sidebar-toggle { display: none; }
  .sidebar:not(.mobile-open) .sidebar-group-btn,
  .sidebar:not(.mobile-open) .sidebar-admin-btn {
    justify-content: center;
    padding: 0;
    width: var(--sidebar-collapsed-width);
    margin: 0;
  }
  .sidebar:not(.mobile-open) .sidebar-footer {
    justify-content: center;
    padding: 10px 0;
  }
}

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    transform: translateX(-100%);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1),
                width 0.22s cubic-bezier(0.4, 0, 0.2, 1);
    width: var(--sidebar-width) !important;
    min-width: var(--sidebar-width) !important;
    z-index: 60;
  }
  .sidebar .sidebar-label,
  .sidebar .brand-text,
  .sidebar .sidebar-chevron,
  .sidebar .sidebar-version,
  .sidebar .sidebar-footer-link {
    opacity: 1 !important;
    width: auto !important;
    pointer-events: auto !important;
  }
  .sidebar .sidebar-brand {
    justify-content: space-between !important;
    padding: 0 12px 0 14px !important;
  }
  .sidebar .sidebar-toggle { display: flex !important; }
  .sidebar .sidebar-group-btn,
  .sidebar .sidebar-admin-btn {
    justify-content: flex-start !important;
    padding: 0 12px 0 14px !important;
    width: calc(100% - 8px) !important;
    margin: 0 8px 0 0 !important;
  }
  .sidebar .sidebar-footer {
    justify-content: space-between !important;
    padding: 10px 14px !important;
  }
  .sidebar.mobile-open {
    transform: translateX(0);
  }
  .sidebar-backdrop { display: block; }
  .topbar-hamburger { display: flex; }
  .topbar-toggle { display: none; }
}

/* ══════════════════════════════════════════════════════
   BUTTONS
══════════════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--panel-alt);
  color: var(--text);
  font-size: 0.85em;
  font-weight: 500;
  cursor: pointer;
  font-family: var(--font-ui);
  transition: border-color 0.15s, background 0.15s;
}
.btn:hover { border-color: var(--accent); background: var(--bg-surface); }
.btn-primary { border-color: var(--accent); background: rgba(91,138,240,0.12); color: var(--accent); }
.btn-primary:hover { background: rgba(91,138,240,0.2); }
.btn-danger { border-color: var(--color-danger); color: var(--color-danger); }
.btn-danger:hover { background: rgba(239,68,68,0.1); }
.btn-success { border-color: var(--color-success); color: var(--color-success); }
.btn-success:hover { background: rgba(34,197,94,0.1); }
.btn-sm { padding: 4px 10px; font-size: 0.82em; }

/* ══════════════════════════════════════════════════════
   PANELS
══════════════════════════════════════════════════════ */
.panel {
  background: var(--panel);
  border: 1px solid var(--border-dim);
  border-radius: 6px;
  margin-bottom: 16px;
}
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-dim);
}
.panel-header h2 {
  font-size: 0.88em;
  font-weight: 600;
  letter-spacing: 0.2px;
}
.panel-body { padding: 16px; }

/* ══════════════════════════════════════════════════════
   TABLES
══════════════════════════════════════════════════════ */
.ms-table { width: 100%; border-collapse: collapse; font-size: 0.85em; }
.ms-table th {
  text-align: left;
  padding: 8px 12px;
  color: var(--text-muted);
  font-size: 0.72em;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}
.ms-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-dim);
}
.ms-table tr:last-child td { border-bottom: none; }
.ms-table tr:hover td { background: rgba(91,138,240,0.02); }
.ms-table .mono { font-family: var(--font-mono); font-size: 0.92em; }
.ms-table .dim { color: var(--text-dim); }
.ms-table.sortable th[data-sort] { cursor: pointer; transition: color 0.15s; }
.ms-table.sortable th[data-sort]:hover { color: var(--text-dim); }
.ms-table.sortable th.sort-active { color: var(--accent); }

/* ══════════════════════════════════════════════════════
   TOAST
══════════════════════════════════════════════════════ */
.ms-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  padding: 12px 20px;
  border-radius: 6px;
  font-size: 0.85em;
  z-index: 2000;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}
.ms-toast.visible { opacity: 1; transform: translateY(0); pointer-events: auto; }
.ms-toast.error { border-left-color: var(--color-danger); }

/* ══════════════════════════════════════════════════════
   FORM INPUTS
══════════════════════════════════════════════════════ */
.ms-input {
  padding: 7px 10px;
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 0.9em;
}
.ms-input:focus { border-color: var(--accent); outline: none; }

/* ══════════════════════════════════════════════════════
   STATUS BADGES
══════════════════════════════════════════════════════ */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 0.72em;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  font-family: var(--font-mono);
}
.badge-running { background: rgba(91,138,240,0.12); color: var(--accent); }
.badge-completed { background: rgba(34,197,94,0.12); color: var(--color-success); }
.badge-failed { background: rgba(239,68,68,0.12); color: var(--color-danger); }
.badge-stopped { background: rgba(100,116,139,0.12); color: var(--text-dim); }
.badge-interrupted { background: rgba(245,158,11,0.12); color: var(--color-warning); }
.badge-pending { background: rgba(100,116,139,0.12); color: var(--text-dim); }

/* ══════════════════════════════════════════════════════
   VAPORWAVE THEME
══════════════════════════════════════════════════════ */
[data-theme="Vaporwave"] .sidebar {
  border-right-color: var(--accent);
  box-shadow: 1px 0 20px rgba(255,46,204,0.1), 1px 0 6px rgba(0,255,238,0.06);
}
[data-theme="Vaporwave"] .topbar {
  border-bottom-color: var(--accent);
  box-shadow: 0 1px 20px rgba(255,46,204,0.12), 0 1px 6px rgba(0,255,238,0.06);
}
[data-theme="Vaporwave"] .brand-text {
  text-shadow: 0 0 12px rgba(255,46,204,0.6), 0 0 30px rgba(255,46,204,0.2);
}
[data-theme="Vaporwave"] .brand-icon {
  box-shadow: 0 0 10px rgba(0,255,238,0.4), 0 0 25px rgba(0,255,238,0.15);
}
[data-theme="Vaporwave"] .sidebar-link.active {
  text-shadow: 0 0 8px rgba(0,255,238,0.4);
}
[data-theme="Vaporwave"] .sidebar-link:hover {
  text-shadow: 0 0 6px rgba(255,46,204,0.35);
}
[data-theme="Vaporwave"] .sidebar-sublink.active {
  text-shadow: 0 0 8px rgba(0,255,238,0.4);
}
[data-theme="Vaporwave"] .hier-segment.hier-active {
  text-shadow: 0 0 8px rgba(0,255,238,0.5);
  box-shadow: 0 0 8px rgba(0,255,238,0.08);
}
[data-theme="Vaporwave"] .topbar-new-scan {
  box-shadow: 0 0 10px rgba(255,46,204,0.2), 0 0 24px rgba(255,46,204,0.06);
}
[data-theme="Vaporwave"] .topbar-new-scan:hover {
  box-shadow: 0 0 16px rgba(255,46,204,0.35), 0 0 36px rgba(255,46,204,0.1);
}
[data-theme="Vaporwave"] .sidebar-version {
  text-shadow: 0 0 6px rgba(0,255,238,0.4);
}
[data-theme="Vaporwave"] .panel {
  box-shadow: 0 0 1px rgba(255,46,204,0.2), 0 2px 12px rgba(0,0,0,0.4);
}
[data-theme="Vaporwave"] .panel:hover {
  box-shadow: 0 0 8px rgba(255,46,204,0.15), 0 0 20px rgba(0,255,238,0.06), 0 2px 12px rgba(0,0,0,0.4);
}
[data-theme="Vaporwave"] .btn-primary,
[data-theme="Vaporwave"] .btn[class*="primary"] {
  box-shadow: 0 0 10px rgba(255,46,204,0.25), 0 0 30px rgba(255,46,204,0.08);
}
[data-theme="Vaporwave"] .btn-primary:hover,
[data-theme="Vaporwave"] .btn[class*="primary"]:hover {
  box-shadow: 0 0 16px rgba(255,46,204,0.4), 0 0 40px rgba(255,46,204,0.12);
}
[data-theme="Vaporwave"] .ms-toast {
  box-shadow: 0 0 16px rgba(255,46,204,0.3), 0 4px 20px rgba(0,0,0,0.5);
}
[data-theme="Vaporwave"] input:focus,
[data-theme="Vaporwave"] select:focus,
[data-theme="Vaporwave"] textarea:focus {
  box-shadow: 0 0 0 1px var(--accent), 0 0 12px rgba(255,46,204,0.2);
}
[data-theme="Vaporwave"] .preset-card.preset-active {
  box-shadow: 0 0 12px rgba(255,46,204,0.3), 0 0 30px rgba(0,255,238,0.1);
}
[data-theme="Vaporwave"] .wg-gauge-num {
  filter: drop-shadow(0 0 4px rgba(0,255,238,0.5));
}
[data-theme="Vaporwave"] ::selection {
  background: rgba(255,46,204,0.3);
  color: #fff;
}
/* artifice.css — Artifice demo traffic management page */

.artifice-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.artifice-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text);
    margin: 0;
}

.artifice-subtitle {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin: 0.2rem 0 0;
}

.artifice-header-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

/* Two-column layout */
.artifice-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    align-items: start;
}

@media (max-width: 1100px) {
    .artifice-layout {
        grid-template-columns: 1fr;
    }
}

.artifice-section-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-dim);
}

.artifice-count {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 10px;
    background: var(--panel);
    color: var(--text-muted);
}

.artifice-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1rem;
}

@media (max-width: 720px) {
    .artifice-grid { grid-template-columns: 1fr; }
}

.artifice-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-left: 3px solid var(--border);
    border-radius: 6px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    transition: border-left-color 0.3s;
}

.artifice-card-running {
    border-left-color: var(--accent-green);
}

.artifice-card-selected {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}

.artifice-card:hover {
    cursor: pointer;
    border-color: var(--border-hover, var(--border));
}

.artifice-card-top {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
}

.artifice-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 5px;
}

.artifice-dot-on {
    background: var(--accent-green);
    box-shadow: 0 0 0 0 var(--accent-green);
    animation: artifice-pulse 2s infinite;
}

.artifice-dot-off {
    background: var(--text-muted);
}

@keyframes artifice-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.5); }
    70%  { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
    100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.artifice-name {
    font-weight: 600;
    color: var(--text);
    font-size: 0.95rem;
    line-height: 1.2;
}

.artifice-iface {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 1px;
}

.artifice-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.artifice-badge-site {
    font-size: 0.72rem;
    font-weight: 500;
    padding: 1px 7px;
    border-radius: 3px;
    background: rgba(59, 130, 246, 0.18);
    color: var(--accent);
    border: 1px solid rgba(59, 130, 246, 0.25);
}

.artifice-badge-zone {
    font-size: 0.72rem;
    font-weight: 500;
    padding: 1px 7px;
    border-radius: 3px;
    background: rgba(6, 182, 212, 0.15);
    color: var(--accent-cyan);
    border: 1px solid rgba(6, 182, 212, 0.22);
}

.artifice-badge-proto {
    font-size: 0.72rem;
    font-weight: 500;
    padding: 1px 7px;
    border-radius: 3px;
    background: rgba(139, 92, 246, 0.15);
    color: #a78bfa;
    border: 1px solid rgba(139, 92, 246, 0.22);
}

.artifice-stats {
    display: flex;
    gap: 1rem;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--text-dim);
    padding: 0.4rem 0.5rem;
    background: var(--panel);
    border-radius: 4px;
    flex-wrap: wrap;
}

.artifice-stat-label {
    color: var(--text-muted);
    margin-right: 2px;
}

.artifice-proto-bar {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.artifice-proto-track {
    height: 8px;
    border-radius: 4px;
    background: var(--panel);
    overflow: hidden;
    display: flex;
}

.artifice-proto-segment {
    height: 100%;
    transition: width 0.4s;
}

.artifice-proto-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 0.75rem;
}

.artifice-proto-legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.72rem;
    color: var(--text-dim);
    font-family: var(--font-mono);
}

.artifice-proto-swatch {
    width: 8px;
    height: 8px;
    border-radius: 2px;
    flex-shrink: 0;
}

.artifice-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: auto;
}

.artifice-actions .btn {
    flex: 1;
}

.artifice-delete-btn {
    flex: 0 !important;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 0.35rem 0.55rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    line-height: 1;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.artifice-delete-btn:hover {
    color: var(--color-danger);
    border-color: var(--color-danger);
    background: rgba(239, 68, 68, 0.07);
}

.artifice-scenario-row {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.artifice-scenario-label {
    font-size: 0.72rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.artifice-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 4rem 1rem;
    color: var(--text-muted);
}

.artifice-empty-icon {
    margin-bottom: 0.75rem;
    opacity: 0.35;
}

.artifice-empty-text {
    font-size: 0.95rem;
    margin-bottom: 0.35rem;
    color: var(--text-dim);
}

.artifice-empty-sub {
    font-size: 0.82rem;
    max-width: 400px;
    margin: 0 auto;
}

/* ── Inspector panel (right side) ── */

.artifice-inspector {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1rem;
    position: sticky;
    top: calc(var(--topbar-height, 48px) + 1rem);
}

.artifice-inspector-body {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.artifice-inspect-desc {
    font-size: 0.82rem;
    color: var(--text-dim);
    line-height: 1.4;
    padding: 0.5rem 0.6rem;
    background: var(--panel);
    border-radius: 4px;
}

.artifice-inspect-empty {
    font-size: 0.82rem;
    color: var(--text-muted);
    text-align: center;
    padding: 2rem 1rem;
    line-height: 1.5;
}

.artifice-matrix-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.artifice-matrix {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.artifice-matrix-row {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    padding: 0.4rem 0.5rem;
    background: var(--panel);
    border-radius: 4px;
}

.artifice-matrix-proto {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text);
    font-family: var(--font-mono);
}

.artifice-matrix-weight {
    display: flex;
    align-items: center;
    gap: 6px;
}

.artifice-weight-bar-track {
    flex: 1;
    height: 6px;
    border-radius: 3px;
    background: var(--bg-deep);
    overflow: hidden;
}

.artifice-weight-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s;
}

.artifice-weight-val {
    font-size: 0.72rem;
    font-family: var(--font-mono);
    color: var(--text-dim);
    min-width: 28px;
    text-align: right;
}

.artifice-matrix-roles {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.artifice-role-tag {
    font-size: 0.7rem;
    font-family: var(--font-mono);
    color: var(--text-muted);
    padding: 0 4px;
    background: var(--bg-deep);
    border-radius: 2px;
}

.artifice-timing {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin-top: 0.5rem;
    padding: 0.5rem 0.6rem;
    background: var(--panel);
    border-radius: 4px;
}

.artifice-timing-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.artifice-timing-label {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.artifice-timing-val {
    font-size: 0.78rem;
    font-family: var(--font-mono);
    color: var(--text-dim);
}

/* Host inventory */
.artifice-hosts {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    max-height: 200px;
    overflow-y: auto;
}

.artifice-host-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    font-family: var(--font-mono);
    background: var(--panel);
    border-radius: 3px;
}

.artifice-host-id {
    color: var(--text);
    min-width: 80px;
}

.artifice-host-ip {
    color: var(--text-dim);
    min-width: 90px;
}

/* ── Protocol Configuration ── */

.proto-preset-btns {
    display: flex;
    gap: 4px;
    align-items: center;
}

.proto-weight-bar-wrap {
    margin-bottom: 1rem;
    padding: 0.6rem 0.75rem;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 6px;
}

.proto-weight-bar-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.4rem;
}

.proto-weight-bar {
    display: flex;
    height: 10px;
    border-radius: 5px;
    overflow: hidden;
    background: var(--bg-deep);
}

.proto-weight-bar-seg {
    height: 100%;
    transition: width 0.3s;
}

.proto-weight-bar-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem 0.6rem;
    margin-top: 0.4rem;
}

.proto-weight-bar-legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.68rem;
    color: var(--text-dim);
    font-family: var(--font-mono);
}

.proto-weight-bar-legend-dot {
    width: 7px;
    height: 7px;
    border-radius: 2px;
    flex-shrink: 0;
}

.proto-cfg-container {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.proto-cfg-group {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-left: 3px solid var(--group-color, var(--accent));
    border-radius: 0 6px 6px 0;
    overflow: hidden;
}

.proto-cfg-group-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.75rem;
    background: rgba(255, 255, 255, 0.015);
    border-bottom: 1px solid var(--border);
}

.proto-cfg-group-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.proto-bulk-btns {
    display: flex;
    gap: 4px;
}

.proto-bulk-btn {
    font-size: 0.66rem;
    padding: 2px 8px;
    border: 1px solid var(--border);
    background: var(--panel);
    color: var(--text-dim);
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.15s;
}

.proto-bulk-btn:hover {
    color: var(--text);
    border-color: var(--group-color, var(--accent));
    background: rgba(255, 255, 255, 0.03);
}

.proto-cfg-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 6px;
    padding: 0.5rem 0.6rem;
}

.proto-cfg-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.5rem 0.6rem;
    transition: border-color 0.2s, opacity 0.2s;
}

.proto-cfg-card.disabled {
    opacity: 0.45;
}

.proto-cfg-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.proto-cfg-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 5px;
}

.proto-cfg-port {
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--text-dim);
    font-family: var(--font-mono);
}

.proto-cfg-toggle {
    position: relative;
    width: 32px;
    height: 17px;
    flex-shrink: 0;
    background: rgba(160, 160, 190, 0.35);
    border: 1px solid rgba(160, 160, 190, 0.5);
    border-radius: 9px;
    cursor: pointer;
    transition: all 0.2s;
}

.proto-cfg-toggle::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 11px;
    height: 11px;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 50%;
    transition: transform 0.2s, background 0.2s;
}

.proto-cfg-toggle.active {
    background: var(--accent);
    border-color: var(--accent);
}

.proto-cfg-toggle.active::after {
    background: white;
    transform: translateX(15px);
}

.proto-cfg-desc {
    font-size: 0.7rem;
    color: var(--text-dim);
    margin-top: 2px;
    line-height: 1.3;
}

.proto-cfg-body {
    margin-top: 0.35rem;
}

.proto-cfg-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.proto-cfg-label {
    font-size: 0.72rem;
    color: var(--text-dim);
}

.proto-cfg-value {
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--text);
    min-width: 22px;
    text-align: center;
}

.proto-cfg-controls {
    display: flex;
    gap: 3px;
    align-items: center;
}

.proto-cfg-btn {
    padding: 1px 6px;
    font-size: 0.72rem;
    min-width: 22px;
    text-align: center;
}

.proto-cfg-scope {
    font-weight: 400;
    font-size: 0.78rem;
    color: var(--text-muted);
}
