/* Morgana UI - Dark theme matching Merlino */
:root {
  --bg-base:       #1a1a1a;
  --bg-sidebar:    #222222;
  --bg-card:       #2c2c2c;
  --bg-input:      #3a3a3a;
  --bg-table-row:  #333333;
  --bg-table-head: #252525;
  --bg-hover:      #3d3d3d;

  --text-primary:  #ffffff;
  --text-secondary:#aaaaaa;
  --text-muted:    #666666;

  --accent:        #667eea;
  --accent-hover:  #5a6fd6;

  --success:       #4caf50;
  --warning:       #ff9800;
  --danger:        #f44336;
  --info:          #2196f3;

  --border:        #3d3d3d;
  --border-radius: 6px;

  --font-mono:    'Consolas', 'Monaco', monospace;
  --font-ui:      -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.5;
  height: 100vh;
  overflow: hidden;
}

.df-detection-filters {
  display: grid;
  grid-template-columns: minmax(260px, 2fr) repeat(7, minmax(130px, 1fr)) auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 12px;
}

.df-detection-filters label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

.df-detection-filters input,
.df-detection-filters select {
  width: 100%;
  min-width: 0;
  height: 34px;
  text-transform: none;
}

.df-detections-scroll {
  max-height: 560px;
  overflow: auto;
  border: 1px solid var(--border);
  scrollbar-gutter: stable both-edges;
}

.df-detections-table {
  min-width: 1950px;
}

.df-detections-scroll .df-detections-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--bg-table-head);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.df-detection-row {
  cursor: pointer;
}

.df-detection-row:focus {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.df-detection-id {
  display: inline-block;
  min-width: 285px;
  color: #b8c2ff;
  font-size: 11px;
  white-space: nowrap;
}

.df-association-cell {
  display: flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
}

.df-association-badge,
.df-unassociated-badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 7px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 700;
}

.df-association-badge {
  border: 1px solid #2f855a;
  background: #173c2b;
  color: #68d391;
}

.df-unassociated-badge {
  border: 1px solid #555;
  background: #292929;
  color: #999;
}

@media (max-width: 1400px) {
  .df-detection-filters {
    grid-template-columns: repeat(4, minmax(150px, 1fr));
  }

  .df-filter-wide {
    grid-column: span 2;
  }
}

/* Layout */
.layout {
  display: flex;
  height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 200px;
  min-width: 200px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 0;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px 12px;
  border-bottom: 1px solid var(--border);
}

.brand-logo {
  width: auto;
  height: 104px;
  max-width: 100%;
  object-fit: contain;
  display: block;
}

.brand-icon {
  width: 32px; height: 32px;
  background: var(--accent);
  color: white;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 18px;
  flex-shrink: 0;
}

.brand-name {
  font-weight: 700;
  font-size: 16px;
  color: var(--text-primary);
}

.brand-version {
  font-size: 10px;
  color: var(--text-muted);
  margin-left: auto;
}

.nav-links {
  list-style: none;
  padding: 8px 0;
  margin: 0;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

.nav-links-static {
  flex: none;
  overflow: visible;
  padding: 0;
}

.nav-item {
  padding: 10px 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-secondary);
  border-radius: 0;
  transition: all 0.15s;
  user-select: none;
}

/* Sidebar sections (collapsible macro-groups) */
.nav-section {
  list-style: none;
}

.nav-section + .nav-section {
  margin-top: 6px;
}

.nav-section-header {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 8px 16px 6px;
  background: transparent;
  border: none;
  cursor: pointer;
  color: #c9d1e8;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  text-align: left;
  user-select: none;
}

.nav-section-header:hover {
  color: #e2e8f0;
}

.nav-section-header:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.nav-section-caret {
  display: inline-block;
  width: 12px;
  font-size: 11px;
  color: #8b93b8;
  transition: transform 0.15s;
}

.nav-section-items {
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-section.collapsed .nav-section-items {
  display: none;
}

.nav-section.collapsed .nav-section-caret {
  transform: rotate(-90deg);
}

.sidebar-help {
  flex: none;
  border-top: 1px solid var(--border);
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.nav-item.active {
  background: rgba(102, 126, 234, 0.15);
  color: var(--accent);
  border-left: 3px solid var(--accent);
}

.nav-item-help {
  margin-bottom: 0;
}

.nav-icon {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
}

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}

/* Help */
.help-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding: 28px 32px 24px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, #17191d 0%, #20232c 100%);
}

.help-header h1 {
  margin: 5px 0 8px;
  color: var(--text-primary);
  font-size: 28px;
}

.help-eyebrow,
.help-link-kicker,
.help-author-label {
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
}

.help-intro {
  margin: 0;
  max-width: 700px;
  color: var(--text-secondary);
  line-height: 1.55;
}

.help-product-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 7px;
  color: var(--text-muted);
  font-size: 12px;
  white-space: nowrap;
}

.help-free-badge {
  padding: 5px 9px;
  border: 1px solid #3d8b55;
  border-radius: 4px;
  background: #14251a;
  color: #66d28a;
  font-weight: 700;
}

.help-author-band {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 24px 32px;
  border-bottom: 1px solid var(--border);
  background: #1b1d21;
}

.help-logo {
  width: 72px;
  height: 72px;
  object-fit: contain;
}

.help-author-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin: 7px 0 6px;
  color: var(--text-primary);
  text-decoration: none;
}

.help-author-link:hover {
  color: var(--accent);
}

.help-author-link:hover .help-author-identity strong,
.help-author-link:hover .help-author-identity span {
  text-decoration: underline;
}

.linkedin-icon {
  display: inline-flex;
  width: 34px;
  height: 34px;
  align-items: center;
  justify-content: center;
  flex: 0 0 34px;
  border-radius: 4px;
  background: #0a66c2;
  color: #fff;
  font-family: Arial, sans-serif;
  font-size: 21px;
  font-weight: 700;
  line-height: 1;
}

.help-author-identity {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.help-author-identity strong {
  color: var(--text-primary);
  font-size: 20px;
}

.help-author-identity span {
  color: #70a8e0;
  font-size: 12px;
  font-weight: 600;
}

.help-author-company {
  color: var(--text-muted);
  font-size: 12px;
}

.help-link-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  padding: 28px 32px;
}

.help-link-panel {
  display: flex;
  min-height: 180px;
  flex-direction: column;
  gap: 12px;
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-card);
  color: var(--text-secondary);
  line-height: 1.55;
  text-decoration: none;
  transition: border-color 0.15s, background 0.15s;
}

.help-link-panel:hover {
  border-color: var(--accent);
  background: var(--bg-hover);
}

.help-link-panel strong {
  color: var(--text-primary);
  font-size: 18px;
}

.help-link-primary {
  border-top: 3px solid var(--accent);
}

.help-link-action {
  margin-top: auto;
  color: var(--accent);
  font-weight: 700;
}

.help-notice {
  margin: 0 32px 32px;
  padding: 18px 20px;
  border-left: 3px solid #d6a84b;
  background: #282314;
  color: #e4cf9a;
}

.help-notice p {
  margin: 7px 0 0;
  line-height: 1.55;
}

@media (max-width: 850px) {
  .help-header,
  .help-author-band,
  .help-link-grid {
    padding-left: 20px;
    padding-right: 20px;
  }

  .help-header {
    flex-direction: column;
  }

  .help-product-meta {
    align-items: flex-start;
  }

  .help-link-grid {
    grid-template-columns: 1fr;
  }

  .help-notice {
    margin-left: 20px;
    margin-right: 20px;
  }
}

.server-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-secondary);
}

.btn-logout {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 7px 12px;
  background: transparent;
  border: 1px solid rgba(229, 57, 53, 0.35);
  border-radius: 5px;
  color: #ef9a9a;
  font-size: 12px;
  font-family: var(--font-mono);
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.btn-logout:hover {
  background: rgba(229, 57, 53, 0.15);
  border-color: #e53935;
  color: #ff5252;
}

.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
}
.status-dot.online  { background: var(--success); }
.status-dot.offline { background: var(--danger); }

/* Main content */
.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 0;
}

/* Pages */
.page { display: none; padding: 24px; }
.page.active { display: block; }

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.page-header h1 {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
}

.header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.scripts-page-header {
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
}

.scripts-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.script-search-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
}

.script-search-label {
  color: var(--text-secondary);
  font-size: .82rem;
  white-space: nowrap;
  min-width: 44px;
}

.script-search-input {
  flex: 1;
  min-width: 0;
}

.script-filters,
.script-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

/* prevent filter dropdowns from stretching to full width */
.script-filters .select-input {
  width: auto;
}

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--border-radius);
  margin-bottom: 16px;
}

.card-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-header h2 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.card-body { padding: 16px; }

/* Stats row */
.stats-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--border-radius);
  padding: 16px;
  text-align: center;
}

.stat-card.success { border-color: var(--success); }
.stat-card.danger  { border-color: var(--danger); }
.stat-card.warning { border-color: var(--warning); }

.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
  margin-bottom: 4px;
}

.stat-card.success .stat-value { color: var(--success); }
.stat-card.danger  .stat-value { color: var(--danger); }

.stat-label {
  font-size: 11px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Tables */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th {
  background: var(--bg-table-head);
  padding: 8px 12px;
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
}

.data-table tr:hover td {
  background: var(--bg-hover);
}

.data-table tr:last-child td { border-bottom: none; }

.sortable-th {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.sortable-th:hover { color: var(--accent, #667eea); }
.sortable-th::after       { content: " \25B4\25BE"; color: var(--text-muted, #888); font-size: 0.7em; vertical-align: middle; }
.sortable-th.sort-asc::after  { content: " \25B2"; color: var(--accent, #667eea); font-size: 0.75em; vertical-align: middle; }
.sortable-th.sort-desc::after { content: " \25BC"; color: var(--accent, #667eea); font-size: 0.75em; vertical-align: middle; }

.empty-row {
  text-align: center;
  color: var(--text-muted);
  font-style: italic;
  padding: 24px !important;
}

/* State badges */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

.badge-running  { background: rgba(33,150,243,0.2);  color: #2196f3; }
.badge-finished { background: rgba(76,175,80,0.2);   color: #4caf50; }
.badge-failed   { background: rgba(244,67,54,0.2);   color: #f44336; }
.badge-timeout  { background: rgba(245,158,11,0.2);  color: #f59e0b; }
.badge-pending  { background: rgba(158,158,158,0.2); color: #9e9e9e; }
.badge-paused   { background: rgba(255,152,0,0.2);   color: #ff9800; }
.badge-online   { background: rgba(76,175,80,0.2);   color: #4caf50; }
.badge-offline  { background: rgba(244,67,54,0.2);   color: #f44336; }
.badge-idle     { background: rgba(33,150,243,0.2);  color: #2196f3; }
.badge-busy     { background: rgba(255,152,0,0.2);   color: #ff9800; }
/* Detection Fabric derived statuses (AI Review BLOCKED +/- Detection Fabric verdict) */
.badge-detected { background: rgba(231,76,60,0.28);  color: #ff5547; border:1px solid rgba(231,76,60,0.45); }
.badge-possible { background: rgba(245,158,11,0.18); color:#fbbf24; border:1px solid rgba(245,158,11,0.4); }
.badge-not-detected { background: rgba(245,158,11,0.18); color:#f59e0b; border:1px solid rgba(245,158,11,0.4); }
.badge-no-telemetry { background: rgba(144,205,244,0.16); color:#90cdf4; border:1px solid rgba(144,205,244,0.35); }
.badge-inconclusive { background: rgba(160,174,192,0.16); color:#a0aec0; border:1px solid rgba(160,174,192,0.35); }
.badge-blocked  { background: rgba(255,152,0,0.25);  color: #ffb04a; border:1px solid rgba(255,152,0,0.4); }

/* Agents grid */
.agents-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
}

.agent-chip {
  background: var(--bg-table-row);
  border: 1px solid var(--border);
  border-radius: var(--border-radius);
  padding: 12px;
}

.agent-chip-hostname {
  font-weight: 600;
  font-size: 13px;
  color: var(--text-primary);
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.agent-chip-meta {
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

/* Buttons */
.btn {
  padding: 8px 14px;
  border-radius: var(--border-radius);
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: background 0.15s;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: white;
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary {
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg-hover); }

.btn-danger {
  background: var(--danger);
  color: #fff;
  border: none;
}
.btn-danger:hover { background: #c62828; }
.btn-danger:disabled { opacity: .55; cursor: not-allowed; }
.btn-warning {
  background: #e65100;
  color: #fff;
  border: none;
}
.btn-warning:hover { background: #bf360c; }

/* Admin page */
.admin-section { margin-top: 1.4rem; }
.admin-section h3 { font-size: 13px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: .05em; margin-bottom: .7rem; }
.admin-hint { font-size: 12px; color: var(--text-secondary); margin-bottom: .9rem; line-height: 1.6; }
.admin-hint code { background: var(--bg-input); padding: 1px 5px; border-radius: 3px; font-family: monospace; font-size: 11px; }
.admin-log {
  margin-top: .8rem;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--border-radius);
  font-family: monospace;
  font-size: 12px;
  white-space: pre-wrap;
  line-height: 1.6;
}
.admin-log.hidden { display: none; }
.admin-log.log-success { border-color: var(--success); color: var(--success); }
.admin-log.log-error   { border-color: var(--danger);  color: var(--danger); }
.search-input, .select-input {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 7px 12px;
  border-radius: var(--border-radius);
  font-size: 13px;
  outline: none;
}
.search-input { width: 240px; }
.search-input:focus, .select-input:focus { border-color: var(--accent); }

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal.hidden { display: none; }
.hidden { display: none !important; }

.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--border-radius);
  width: 560px;
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 { font-size: 15px; font-weight: 600; }

.modal-close {
  background: none; border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 16px;
  padding: 4px 8px;
}
.modal-close:hover { color: var(--text-primary); }

.modal-body { padding: 16px; overflow-y: auto; flex: 1; }
.modal-body p { margin-bottom: 12px; color: var(--text-secondary); font-size: 13px; }
.modal-note { margin-top: 12px; font-size: 11px; color: var(--text-muted); font-style: italic; }

.code-block {
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 12px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: #a6e22e;
  word-break: break-all;
  white-space: pre-wrap;
}

/* Empty state */
.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 40px;
  font-style: italic;
}

/* Tcode badge */
.tcode {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent);
  background: rgba(102,126,234,0.1);
  padding: 2px 6px;
  border-radius: 4px;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-base); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #555; }

/* ====================================================
   SCRIPT EDITOR MODAL + TAGS
   ==================================================== */

/* Wider modal variant */
.modal-wide { max-width: 820px; width: 95vw; }

/* Code-style textarea */
.code-editor {
  font-family: var(--font-mono);
  font-size: 13px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .75rem;
  width: 100%;
  resize: vertical;
  box-sizing: border-box;
  line-height: 1.5;
}
.code-editor:focus { outline: none; border-color: var(--accent); }

/* Two-column script form */
.form-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .75rem;
}
@media (max-width: 600px) { .form-grid { grid-template-columns: 1fr 1fr; } }

/* Generic modal sections */
.modal-divider { border: none; border-top: 1px solid var(--border); margin: 1rem 0; }
.execute-section h4 { margin: 0 0 .5rem; font-size: 14px; color: var(--text-primary); }

.modal-footer {
  display: flex;
  gap: .5rem;
  align-items: center;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  justify-content: flex-end;
}
.modal-footer .btn-danger { margin-right: auto; }

/* select styled like inputs */
.select-input {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .45rem .7rem;
  font-size: 13px;
  width: 100%;
}
.select-input:focus { outline: none; border-color: var(--accent); }
.select-input option {
  background: #2c2c2c;
  color: #fff;
}

/* Open-row button in tables */
.btn-open {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 8px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}
.btn-open:hover { opacity: .85; }

/* Inline alias rename */
.agent-alias {
  font-weight: 600;
  color: var(--text-primary);
}
.agent-alias-edit {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--accent);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 13px;
  width: 130px;
}
.agent-alias-unset {
  color: var(--text-muted);
  font-style: italic;
  font-size: 12px;
}
.rename-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 11px;
  padding: 0 2px;
  vertical-align: middle;
}
.rename-btn:hover { color: var(--accent); }

/* Small btn variant — same height as .btn, reduced horizontal padding + font */
.btn-sm { padding: 8px 10px; font-size: 12px; }

/* Detection action cell — keep buttons on one line */
.df-action-cell { display: flex; gap: 4px; align-items: center; }

/* Tags container */
.tags-container { display: flex; flex-wrap: wrap; gap: 4px; min-height: 24px; }

/* Tag badge */
.tag-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  cursor: default;
}
.tag-x {
  cursor: pointer;
  opacity: .7;
  font-size: 13px;
  line-height: 1;
}
.tag-x:hover { opacity: 1; }

/* Create tag form (collapsed by default) */
.create-tag-form {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1rem;
}
.form-row {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
  align-items: flex-end;
}
.form-row .form-group { flex: 1; min-width: 120px; }

/* Tag picker modal */
.tag-picker-list {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  max-height: 320px;
  overflow-y: auto;
}
.tag-item {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .35rem .8rem;
  border: 1px solid var(--border);
  border-radius: 16px;
  cursor: pointer;
  font-size: 13px;
  transition: border-color .15s, background .15s;
}
.tag-item:hover { border-color: var(--accent); }
.tag-item.assigned {
  border-color: var(--accent);
  background: rgba(102,126,234,.15);
}

/* Danger button (consolidated — duplicate removed) */
.btn-danger {
  background: #e53e3e;
  color: #fff;
  border: none;
}
.btn-danger:hover { background: #c53030; }

/* ---- Version badge ------------------------------------------------------- */
.beacon-click {
  cursor: pointer;
  border-bottom: 1px dashed var(--text-muted);
  padding-bottom: 1px;
}
.beacon-click:hover { color: var(--accent-color); border-bottom-color: var(--accent-color); }

.beacon-edit-input {
  background: var(--bg-input, #3a3a3a);
  border: 1px solid var(--accent-color);
  color: var(--text-color);
  border-radius: 4px;
  padding: 2px 4px;
  font-size: 12px;
}

.console-reset-btn {
  margin-left: 5px;
  padding: 3px 9px;
  font-size: 11px;
  background: transparent;
  border: 1px solid #666;
  border-radius: 4px;
  color: #999;
  cursor: pointer;
  white-space: nowrap;
}
.console-reset-btn:hover {
  border-color: #e53e3e;
  color: #e53e3e;
  background: rgba(229,62,62,.08);
}

.version-badge {
  font-family: Consolas, monospace;
  font-size: 11px;
  color: #a0a0b0;
  background: rgba(255,255,255,.06);
  border: 1px solid #444;
  border-radius: 4px;
  padding: 1px 5px;
  white-space: nowrap;
}

/* ---- Console (reverse shell) modal --------------------------------------- */
.modal-console {
  max-width: 900px;
  width: 90vw;
}
.console-terminal {
  width: 100%;
  height: 480px;
  background: #0d0d0d;
  padding: 6px;
  overflow: hidden;
  box-sizing: border-box;
}
/* Ensure xterm canvas fills the container */
.console-terminal .xterm { height: 100%; }
.console-terminal .xterm-viewport { overflow-y: hidden !important; }

/* ---- Script execution output panel --------------------------------------- */
.output-pre {
  background: #0d0d0d;
  color: #c8ffb0;
  font-family: Consolas, 'Courier New', monospace;
  font-size: 12px;
  padding: .7rem;
  border-radius: 6px;
  border: 1px solid #333;
  max-height: 320px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
  margin: 0;
}
/* ─── Chain flow builder ────────────────────────────────────────────────── */

.chain-flow {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 0 40px;
  min-height: 200px;
  position: relative;
  user-select: none;
}

/* Vertical connector line */
.chain-vline {
  width: 2px;
  height: 22px;
  background: var(--border);
  flex-shrink: 0;
}

/* Start circle (green dot at top) */
.chain-start-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--success);
  border: 2px solid #66bb69;
  flex-shrink: 0;
}

/* + Add button circle */
.chain-add-btn {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px dashed var(--accent);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s;
}
.chain-add-btn:hover { background: rgba(102,126,234,0.18); }

/* Script node card */
.chain-script-node {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 14px;
  min-width: 240px;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
}
.chain-script-node:hover { border-color: var(--accent); }
.chain-script-node .csn-tactic {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
}
.chain-script-node .csn-tcode {
  font-size: 11px;
  color: var(--accent);
  font-family: var(--font-mono);
}
.chain-script-node .csn-name {
  font-size: 13px;
  color: var(--text-primary);
  font-weight: 500;
  word-break: break-word;
}
.chain-script-node .csn-desc {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
  word-break: break-word;
}
.chain-script-node .csn-actions {
  display: flex;
  gap: 6px;
  margin-top: 4px;
  flex-wrap: wrap;
}

/* If/Else node */
.chain-ifelse-node {
  background: var(--bg-card);
  border: 1px solid #f59e0b;
  border-radius: 8px;
  padding: 8px 14px;
  min-width: 280px;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.chain-ifelse-node .cie-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #f59e0b;
  font-weight: 600;
}
.chain-ifelse-node .cie-contains-input {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 12px;
  width: 160px;
}
.chain-ifelse-node .cie-hint {
  font-size: 10px;
  color: var(--text-muted);
}

/* Branches layout */
.chain-branches-row {
  display: flex;
  gap: 0;
  justify-content: center;
  width: 100%;
  position: relative;
}
.chain-branch-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 280px;
  flex: 1;
  max-width: 420px;
}
.chain-branch-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .6px;
  padding: 3px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-base);
}
.chain-branch-if .chain-branch-label  { color: var(--success); border-color: var(--success); }
.chain-branch-else .chain-branch-label { color: var(--danger);  border-color: var(--danger); }

/* Horizontal line connecting the two branches at top */
.chain-branch-top-line {
  position: relative;
  width: 100%;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.chain-branch-top-line::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 25%;
  right: 25%;
  height: 2px;
  background: var(--border);
}
.chain-branch-top-line::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 2px;
  height: 11px;
  background: var(--border);
  transform: translateX(-50%) translateY(-100%);
}

/* Add-node floating popup menu */
.chain-add-menu {
  position: fixed;
  background: var(--bg-card);
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 6px 4px;
  z-index: 9000;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 170px;
}
.chain-add-menu button {
  background: none;
  border: none;
  color: var(--text-primary);
  padding: 8px 14px;
  text-align: left;
  cursor: pointer;
  border-radius: 5px;
  font-size: 13px;
  transition: background 0.12s;
}
.chain-add-menu button:hover { background: var(--bg-hover); }

/* Execution log modal steps */
.exec-step {
  border-left: 3px solid var(--border);
  padding: 8px 12px;
  margin-bottom: 8px;
  background: var(--bg-card);
  border-radius: 0 6px 6px 0;
}
.exec-step.step-finished { border-color: var(--success); }
.exec-step.step-failed   { border-color: var(--danger); }
.exec-step.step-partial  { border-color: var(--warning); }

/* Campaign: Parallel node */
.camp-parallel-node {
  background: var(--bg-card);
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 8px 14px 12px;
  min-width: 480px;
  max-width: 960px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.cpar-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--accent);
  font-weight: 600;
}
.camp-parallel-branches {
  display: flex;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}
.camp-branch-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 220px;
  flex: 1;
  padding: 8px 8px 12px;
  border-right: 1px solid var(--border);
}
.camp-branch-col:last-child { border-right: none; }
.camp-branch-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}
.exec-step.step-ifelse   { border-color: #f59e0b; }
.exec-step .step-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}
.exec-step .step-output {
  background: #0d0d0d;
  color: #c8ffb0;
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 6px 8px;
  border-radius: 4px;
  max-height: 160px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
  margin-top: 6px;
}

/* ─── Tests: stats bar ───────────────────────────────────────────────────────── */
.tests-statsbar {
  display: grid;
  grid-template-columns: repeat(6, minmax(86px, 1fr));
  gap: 7px;
  margin-bottom: 7px;
}

.tsb-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--border-radius);
  padding: 8px 10px;
  min-width: 0;
  text-align: center;
  color: inherit;
  font: inherit;
}

.tsb-value {
  font-size: 19px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
  margin-bottom: 3px;
}

.tsb-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.tsb-state-card {
  cursor: pointer;
  transition: border-color .15s, background .15s, box-shadow .15s;
}

.tsb-state-card:hover {
  background: var(--bg-hover);
}

.tsb-state-card.active {
  background: rgba(102, 126, 234, .12);
  box-shadow: inset 0 -2px 0 currentColor;
}

.tsb-total     .tsb-value { color: var(--accent); }
.tsb-detected  .tsb-value { color: #ff5547; }
.tsb-detected              { border-color: rgba(255, 85, 71, .55); }
.tsb-blocked   .tsb-value { color: #f59e0b; }
.tsb-blocked               { border-color: rgba(245, 158, 11, .55); }
.tsb-running   .tsb-value { color: var(--info); }
.tsb-running               { border-color: rgba(33, 150, 243, .55); }
.tsb-finished .tsb-value  { color: var(--success); }
.tsb-finished              { border-color: rgba(76, 175, 80, .55); }
.tsb-failed   .tsb-value  { color: var(--danger); }
.tsb-failed                { border-color: rgba(244, 67, 54, .55); }
.tsb-pending   .tsb-value { color: #a0aec0; }
.tsb-timeout   .tsb-value { color: #c084fc; }
.tsb-timeout               { border-color: rgba(192, 132, 252, .5); }

.tests-metricsbar {
  display: grid;
  grid-template-columns: repeat(5, minmax(110px, 1fr));
  gap: 1px;
  margin-bottom: 9px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--border-radius);
  background: var(--border);
}

.tests-metric {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
  padding: 5px 10px;
  background: #242424;
  font-size: 12px;
}

.tests-metric-label {
  overflow: hidden;
  color: var(--text-muted);
  font-size: 9px;
  letter-spacing: .4px;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.tests-metric strong {
  color: var(--text-primary);
  font-size: 13px;
  white-space: nowrap;
}

/* ─── Tests: Detection Fabric AI mini-panel ──────────────────────────────────── */
.ai-fabric-panel {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--bg-card);
  border: 1px solid var(--accent);
  border-radius: var(--border-radius);
  padding: 7px 14px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.ai-fabric-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--accent);
  white-space: nowrap;
}

.ai-fabric-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  display: inline-block;
  flex-shrink: 0;
}

.ai-fabric-dot.active {
  background: var(--success, #48bb78);
  box-shadow: 0 0 6px var(--success, #48bb78);
  animation: ai-pulse 1.5s ease-in-out infinite;
}

@keyframes ai-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.35; }
}

.ai-fabric-stats {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  align-items: center;
}

.ai-fabric-stat {
  display: flex;
  align-items: baseline;
  gap: 5px;
}

.ai-fabric-val {
  font-size: 16px;
  font-weight: 700;
  min-width: 20px;
  text-align: right;
}

.ai-fabric-lbl {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  white-space: nowrap;
}

.ai-fabric-sep {
  color: var(--border);
  font-size: 14px;
  user-select: none;
}

.ai-fabric-model {
  font-size: 10px;
  color: var(--text-muted);
  font-style: italic;
  margin-left: auto;
  white-space: nowrap;
}

.detection-intelligence-panel {
  display: grid;
  grid-template-columns: minmax(145px, 1.2fr) repeat(7, minmax(90px, 1fr));
  gap: 1px;
  margin-bottom: 9px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--border-radius);
  background: var(--border);
}

.detection-intelligence-panel > div {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 6px;
  padding: 6px 8px;
  background: #202525;
}

.detection-intelligence-panel strong {
  color: var(--accent);
  font-size: 15px;
}

.detection-intelligence-panel span,
.detection-intelligence-title {
  color: var(--text-muted);
  font-size: 9px;
  letter-spacing: .35px;
  text-transform: uppercase;
  white-space: nowrap;
}

.detection-intelligence-panel .detection-intelligence-title {
  justify-content: flex-start;
  align-items: center;
  color: var(--text-primary);
  font-weight: 700;
}

.detection-intelligence-panel .detected strong,
.detection-intelligence-panel .error strong { color: var(--danger); }
.detection-intelligence-panel .confirmed strong { color: var(--success); }

@media (max-width: 1100px) {
  .detection-intelligence-panel {
    grid-template-columns: repeat(4, minmax(100px, 1fr));
  }
}

/* ─── Tests: filter bar ─────────────────────────────────────────────────────── */
.tests-filterbar {
  display: grid;
  grid-template-columns: minmax(260px, 2fr) repeat(5, minmax(120px, 1fr)) repeat(2, minmax(155px, auto)) auto minmax(90px, auto);
  gap: 8px;
  margin-bottom: 9px;
  align-items: center;
}

.filter-input,
.filter-select {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--border-radius);
  color: var(--text-primary);
  font-size: 12px;
  padding: 5px 10px;
  height: 30px;
}

.filter-input {
  min-width: 200px;
  flex: 1;
}

.filter-select {
  cursor: pointer;
}

.filter-input:focus,
.filter-select:focus {
  outline: none;
  border-color: var(--accent);
}

.filter-date {
  min-width: 130px;
  flex: none;
}

.filter-count {
  font-size: 11px;
  color: var(--text-muted);
  text-align: right;
  white-space: nowrap;
}

.tests-filterbar .filter-input,
.tests-filterbar .filter-select,
.tests-filterbar .btn {
  width: 100%;
  min-width: 0;
  height: 32px;
}

.tests-filter-search {
  min-width: 0;
}

.filter-date-field {
  display: grid;
  grid-template-columns: auto minmax(116px, 1fr);
  gap: 6px;
  align-items: center;
  min-width: 0;
  color: var(--text-muted);
  font-size: 10px;
  text-transform: uppercase;
}

.tests-filterbar .filter-date {
  min-width: 0;
}

.tests-table-card {
  margin-bottom: 0;
  overflow: hidden;
}

.tests-table-pane {
  height: clamp(320px, calc(100vh - 370px), 720px);
  overflow: auto;
  scrollbar-gutter: stable;
}

.tests-data-table {
  min-width: 1540px;
}

.tests-data-table thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  box-shadow: 0 1px 0 var(--border);
}

.test-detection-count {
  display: inline-grid;
  grid-template-columns: auto auto;
  gap: 1px 5px;
  align-items: baseline;
  min-width: 92px;
  padding: 3px 7px;
  border: 1px solid rgba(102, 126, 234, .45);
  border-radius: 4px;
  background: rgba(102, 126, 234, .1);
  color: var(--text-primary);
  cursor: pointer;
  font: inherit;
}

.test-detection-count:hover {
  border-color: var(--accent);
  background: rgba(102, 126, 234, .2);
}

.test-detection-count span,
.test-detection-count strong {
  text-align: right;
}

.test-detection-count strong {
  color: var(--success);
}

.test-detection-count small {
  color: var(--text-muted);
  font-size: 9px;
  text-transform: uppercase;
}

.test-detection-count.empty {
  display: inline-block;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  cursor: default;
}

.related-detection-summary,
.related-detection-tabs {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

/* ==========================================================================
   Stage 2F.2 — Technique Intelligence Workspace
   Dark theme (matches Morgana style). Accent #667eea, base #1a1a1a.
   ========================================================================== */

.ti-breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
  padding: 10px 18px;
  border-bottom: 1px solid var(--border);
}
.ti-breadcrumb .crumb { color: var(--text-secondary); }
.ti-breadcrumb .crumb.current { color: var(--accent); font-weight: 600; }
.ti-breadcrumb .sep { opacity: .5; }

.ti-microcopy {
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
  margin: 2px 0 0;
}

.ti-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(102,126,234,.08), transparent);
}
.ti-hero h1 { margin: 0; font-size: 20px; }
.ti-hero .ti-name { color: var(--accent); font-weight: 700; }
.ti-hero .ti-actions { display: flex; gap: 8px; align-items: center; }

.ti-stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  padding: 14px 20px;
}
.ti-stat {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--border-radius);
  padding: 10px 12px;
}
.ti-stat .v { font-size: 22px; font-weight: 700; color: var(--accent); }
.ti-stat .l { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.ti-stat.warn .v { color: var(--warning, #f59e0b); }
.ti-stat.good .v { color: var(--success, #48bb78); }
.ti-stat.gap .v { color: #f56565; }

.ti-tabs {
  display: flex;
  gap: 2px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
  overflow-x: auto;
}
.ti-tab {
  background: none;
  border: none;
  color: var(--text-secondary);
  padding: 10px 14px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.ti-tab:hover { color: var(--text-primary); }
.ti-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.ti-panel { padding: 16px 20px; }

/* Filter chips */
.ti-filterbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
}
.ti-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #1f2540;
  border: 1px solid #3a3f6e;
  color: #a5b4fc;
  border-radius: 14px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
}
.ti-chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.ti-chip .x { opacity: .7; font-weight: 700; }
.ti-chip .x:hover { opacity: 1; }

/* Behavior class node color coding (plus text labels; not color-only). */
.bc-tag {
  display: inline-block;
  font-size: 10px;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-radius: 3px;
  padding: 1px 6px;
  letter-spacing: .03em;
  text-transform: uppercase;
  white-space: nowrap;
}
.bc-credential       { border-color: #c084fc; color: #c084fc; }
.bc-security_disable { border-color: #f56565; color: #f56565; }
.bc-execution_path   { border-color: #48bb78; color: #48bb78; }
.bc-persistence      { border-color: #f59e0b; color: #f59e0b; }
.bc-internet_zone    { border-color: #90cdf4; color: #90cdf4; }
.bc-disabled         { border-color: #a0aec0; color: #a0aec0; }

/* Technique cards */
.ti-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.ti-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--border-radius);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  cursor: pointer;
}
.ti-card:hover { border-color: var(--accent); }
.ti-card .ti-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.ti-card .ti-tcode { font-family: monospace; color: var(--accent); font-weight: 700; }
.ti-card .ti-card-title { font-size: 15px; font-weight: 600; }
.ti-card .ti-counts { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--text-secondary); }
.ti-card .ti-counts strong { color: var(--text-primary); }
.ti-card .ti-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* Family card */
.ti-family-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--border-radius);
  padding: 14px;
  margin-bottom: 10px;
}
.ti-family-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ti-family-head .name { font-weight: 600; }
.ti-family-head .meta { font-size: 11px; color: var(--text-muted); }

/* Lineage flow */
.ti-lineage {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 12px;
  padding: 10px 16px;
  background: #1f2540;
  border: 1px solid #3a3f6e;
  border-radius: var(--border-radius);
  margin-bottom: 12px;
}
.ti-lineage .node { padding: 3px 9px; border-radius: 4px; }
.ti-lineage .node.technique { background: rgba(167,139,250,.18); color: #a78bfa; border: 1px solid rgba(167,139,250,.4); }
.ti-lineage .node.family { background: rgba(45,212,191,.14); color: #2dd4bf; border: 1px solid rgba(45,212,191,.35); }
.ti-lineage .node.variant { background: rgba(102,126,234,.16); color: #93a4ff; border: 1px solid rgba(102,126,234,.4); }
.ti-lineage .node.plan { background: rgba(245,158,11,.14); color: #fbbf24; border: 1px solid rgba(245,158,11,.35); }
.ti-lineage .node.test { background: rgba(72,187,120,.14); color: #48bb78; border: 1px solid rgba(72,187,120,.35); }
.ti-lineage .arrow { color: var(--text-muted); }

/* Chain node visual types */
.chain-node {
  border-left: 3px solid var(--border);
  padding: 8px 12px;
  margin-bottom: 8px;
  background: var(--bg-card);
  border-radius: 0 var(--border-radius) var(--border-radius) 0;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.chain-node.technique { border-left-color: #a78bfa; }
.chain-node.family    { border-left-color: #2dd4bf; }
.chain-node.variant   { border-left-color: #667eea; }
.chain-node.plan      { border-left-color: #f59e0b; }
.chain-node.scenario  { border-left-color: #a0aec0; }
.chain-node .cn-type { font-size: 10px; text-transform: uppercase; letter-spacing: .05em; font-weight: 700; }
.chain-node .cn-count { font-size: 11px; color: var(--text-muted); }

/* Strategy modal radio cards */
.strategy-card {
  border: 1px solid var(--border);
  border-radius: var(--border-radius);
  padding: 12px;
  cursor: pointer;
  background: var(--bg-card);
}
.strategy-card.selected { border-color: var(--accent); background: rgba(102,126,234,.08); }
.strategy-card .radio-dot { margin-right: 8px; }
.strategy-card h4 { margin: 0 0 4px; font-size: 14px; }
.strategy-card p { margin: 0; font-size: 12px; color: var(--text-muted); }

.ti-hint {
  border: 1px solid #3a3f6e;
  background: #1f2540;
  color: #a5b4fc;
  border-radius: var(--border-radius);
  padding: 10px 14px;
  font-size: 13px;
  margin: 10px 0;
}
.ti-hint.warn { border-color: #7c5a17; background: #2d2310; color: #fbbf24; }
.ti-hint.error { border-color: #7c2d2d; background: #2d1515; color: #fca5a5; }

.ti-discriminator {
  display: inline-block;
  font-size: 11px;
  color: var(--text-muted);
  background: rgba(102, 126, 234, 0.12);
  border: 1px solid rgba(102, 126, 234, 0.28);
  border-radius: 10px;
  padding: 1px 8px;
  margin-left: 6px;
  vertical-align: middle;
  white-space: nowrap;
}

.ti-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 40px 20px;
  font-size: 13px;
  line-height: 1.7;
}

.saved-view-pill {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-radius: 4px;
  padding: 3px 9px;
  font-size: 12px;
  cursor: pointer;
}
.saved-view-pill:hover { color: var(--accent); border-color: var(--accent); }

.related-detection-summary span {
  padding: 4px 9px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-input);
  color: var(--text-muted);
  font-size: 11px;
}

.related-detection-summary strong {
  color: var(--text-primary);
  font-size: 13px;
}

.purple-report-modal {
  width: min(680px, 94vw);
}

.report-scope-summary {
  margin: 10px 0 14px;
  padding: 8px 10px;
  border-left: 3px solid var(--accent);
  background: rgba(102, 126, 234, .1);
  color: var(--text-secondary);
  font-size: 12px;
}

.report-date-fields {
  display: none;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

.report-date-fields label {
  display: grid;
  gap: 4px;
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
}

.report-date-fields .search-input {
  width: 100%;
}

.report-status {
  min-height: 38px;
  margin-top: 14px;
  padding: 9px 10px;
  border: 1px solid var(--border);
  background: var(--bg-base);
  color: var(--text-muted);
  font-size: 12px;
}

.report-success { color: var(--success); }
.report-error { color: var(--danger); }

.report-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 12px;
}

@media (max-width: 1450px) {
  .tests-filterbar {
    grid-template-columns: minmax(260px, 2fr) repeat(5, minmax(120px, 1fr));
  }

  .filter-count {
    grid-column: 4 / -1;
  }
}

@media (max-width: 1000px) {
  .tests-statsbar {
    grid-template-columns: repeat(4, minmax(86px, 1fr));
  }

  .tests-filterbar {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .tests-filter-search {
    grid-column: 1 / -1;
  }

  .filter-count {
    grid-column: 2 / -1;
  }

  .tests-table-pane {
    height: clamp(300px, calc(100vh - 460px), 620px);
  }
}

@media (max-width: 620px) {
  .tests-statsbar,
  .tests-metricsbar,
  .tests-filterbar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .tests-filter-search,
  .filter-count {
    grid-column: 1 / -1;
  }
}

/* ── Canary download progress ───────────────────────────────────── */
.canary-progress-track {
  position: relative;
  height: 8px;
  border-radius: 4px;
  background: rgba(255,255,255,.1);
  overflow: hidden;
  margin: .6rem 0 .4rem;
}

.canary-progress-bar {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 0%;
  border-radius: 4px;
  background: #f59e0b;
  transition: width 0.4s ease, background 0.3s ease;
}

.canary-step {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .82rem;
  padding: .18rem 0;
  color: #888;
  transition: color .3s;
}
.canary-step.active  { color: #f59e0b; }
.canary-step.done    { color: #4caf50; }
.canary-step.error   { color: #f44336; }
.canary-step .cs-icon { font-size: .9rem; min-width: 1rem; text-align: center; }
.canary-step .cs-spin { display: inline-block; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
/* == Logs page ================================================================ */
.logs-table td          { font-size: 12.5px; vertical-align: top; }
.log-ts                 { color: var(--text-muted); white-space: nowrap; font-size: 12px; }
.log-name               { color: var(--text-muted); font-size: 11px; word-break: break-all; }
.log-msg                { word-break: break-word; font-family: monospace; font-size: 12px; }
.log-exc                { color: #ef9a9a; font-size: 11px; white-space: pre-wrap; margin-top: 4px; }

.log-badge              { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; }
.log-badge-info         { background: rgba(33,150,243,.15);  color: #64b5f6; }
.log-badge-warning      { background: rgba(255,152,0,.15);   color: #ffb74d; }
.log-badge-error        { background: rgba(244,67,54,.2);    color: #ef9a9a; }
.log-badge-debug        { background: rgba(158,158,158,.12); color: #9e9e9e; }


/* ============================================================
   Generic progress overlay (Sync Tests / Sync Detections)
   ============================================================ */
#morProgressOverlay {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(0,0,0,0.65);
  display: flex; align-items: center; justify-content: center;
}
#morProgressOverlay.hidden { display: none; }
.mor-progress-card {
  background: #1f2230; border: 1px solid #3a3f55; border-radius: 8px;
  padding: 22px 26px; min-width: 460px; max-width: 80vw;
  box-shadow: 0 12px 32px rgba(0,0,0,0.55);
  color: #e2e8f0;
}
.mor-progress-title {
  font-size: 15px; font-weight: 600; margin-bottom: 14px; color: #fff;
  letter-spacing: 0.02em;
}
.mor-progress-bar {
  width: 100%; height: 14px; background: #11131a;
  border: 1px solid #2a2f42; border-radius: 7px; overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.5);
}
.mor-progress-fill {
  height: 100%; width: 0%; background: linear-gradient(90deg, #667eea 0%, #48bb78 100%);
  transition: width 0.18s ease-out;
}
.mor-progress-meta {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 10px; font-size: 12.5px; color: #cbd5e0;
}
.mor-progress-meta #morProgressPct { font-weight: 600; color: #fff; }
.mor-progress-meta #morProgressLabel {
  max-width: 60%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: #a0aec0;
}
.mor-progress-foot { margin-top: 14px; text-align: right; }

.mor-progress-stats {
  margin-top: 12px;
  padding: 8px 10px;
  border: 1px solid #34394c;
  border-radius: 5px;
  background: #181a23;
  color: #cbd5e0;
  font-size: 11px;
  line-height: 1.6;
}

.mor-progress-latest {
  min-height: 20px;
  margin-top: 8px;
  color: #a0aec0;
  font-family: var(--font-mono);
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ====================================================
   Industrial Lab
   ==================================================== */
.segmented-control { display: inline-flex; gap: 2px; background: var(--bg-input); border: 1px solid var(--border); border-radius: 6px; padding: 2px; }
.seg-btn { background: none; border: none; color: var(--text-secondary); padding: 6px 14px; border-radius: 4px; cursor: pointer; font-size: 13px; font-weight: 500; }
.seg-btn:hover { color: var(--text-primary); }
.seg-btn.active { background: var(--accent); color: #fff; }
.lab-tab { display: block; }

/* ====================================================
   Parameter Packs (Environments + Assessment Parameter Packs)
   ==================================================== */
.input-full {
  background: var(--bg-input, #1f2540);
  color: var(--text-primary, #fff);
  border: 1px solid var(--border, #3a3f6e);
  border-radius: 6px;
  padding: .45rem .7rem;
  font-size: 13px;
  width: 100%;
  box-sizing: border-box;
  margin-top: .25rem;
}
.input-full:focus { outline: none; border-color: var(--accent, #667eea); }
.kv-row { display: flex; gap: .5rem; padding: .3rem 0; font-size: 13px; align-items: baseline; flex-wrap: wrap; }
.kv-row strong { min-width: 130px; color: var(--text-muted, #a0aec0); }

.pp-status { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; letter-spacing: .02em; }
.pp-ready { background: rgba(76,175,80,.18); color: #4caf50; }
.pp-draft { background: rgba(160,174,192,.15); color: #a0aec0; }
.pp-incomplete { background: rgba(255,152,0,.18); color: #ff9800; }
.pp-locked { background: rgba(102,126,234,.2); color: #90a7ff; }
.pp-stale { background: rgba(245,158,11,.2); color: #fbbf24; }
.pp-archived { background: rgba(160,174,192,.2); color: #cbd5e1; }
.pp-revoked { background: rgba(244,67,54,.18); color: #f44336; }
.pp-active { background: rgba(76,175,80,.18); color: #4caf50; }

.pp-source { display: inline-block; padding: 1px 6px; border-radius: 6px; font-size: 10px; font-weight: 600; text-transform: uppercase; }
.pp-source-default { background: rgba(160,174,192,.15); color: #a0aec0; }
.pp-source-environment { background: rgba(33,150,243,.15); color: #90cdf4; }
.pp-source-assessment { background: rgba(168,85,247,.15); color: #c084fc; }
.pp-source-execution { background: rgba(245,158,11,.15); color: #fbbf24; }

.pp-banner { padding: .6rem 1rem; border-radius: 6px; margin-bottom: 1rem; font-size: 13px; font-weight: 600; border: 1px solid; }
.pp-banner-stale { background: rgba(245,158,11,.1); border-color: rgba(245,158,11,.4); color: #fbbf24; }
.pp-banner-revoked { background: rgba(244,67,54,.1); border-color: rgba(244,67,54,.4); color: #f44336; }

.readiness-bar { position: relative; height: 18px; background: var(--bg-input, #1a1a1a); border-radius: 10px; overflow: hidden; margin-top: .8rem; border: 1px solid var(--border, #3a3f6e); }
.readiness-fill { height: 100%; background: linear-gradient(90deg, #4caf50, #66bb6a); transition: width .3s ease; }
.readiness-bar span { position: absolute; top: 0; left: .6rem; line-height: 18px; font-size: 11px; color: #fff; text-shadow: 0 0 3px rgba(0,0,0,.6); }
.readiness-counts { margin-top: .5rem; font-size: 12px; color: var(--text-muted, #a0aec0); }

/* Large, usable parameter JSON editor (handoff §7.1): min 50-60vh, scrollable, monospace. */
.pp-json-editor {
  min-height: 55vh;
  width: 100%;
  resize: vertical;
  overflow: auto;
  white-space: pre;
  background: var(--bg-input, #14161f);
  color: #e2e8f0;
  border: 1px solid var(--border, #3a3f6e);
  border-radius: 6px;
  padding: .8rem 1rem;
  line-height: 1.5;
  font-size: 13px;
  tab-size: 2;
}
