/* ==========================================================================
   MOBILE VIEW & RESPONSIVE PERFECTION (< 768px and < 480px)
   ========================================================================== */

@media (max-width: 768px) {
  body {
    padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px)) !important;
  }

  /* Mobile Toasts: Dock to bottom above bottom app bar, avoiding header button collisions */
  .toast-container {
    top: auto !important;
    bottom: calc(68px + env(safe-area-inset-bottom, 0px)) !important;
    left: 12px !important;
    right: 12px !important;
    width: auto !important;
    max-width: none !important;
    pointer-events: none !important;
  }
  .toast {
    pointer-events: auto;
    font-size: 12px;
    padding: 10px 14px;
  }

  /* Header adjustments */
  .app-header {
    padding: 8px 12px;
    height: 56px;
  }
  .brand-logo-wrap {
    width: 32px;
    height: 32px;
  }
  .brand-title {
    font-size: 14px;
  }
  .brand-badge {
    font-size: 9px;
    padding: 2px 6px;
  }
  .brand-subtitle {
    display: none;
  }

  /* Status pills in header */
  #header-poller-pill, #header-graph-pill {
    display: none !important;
  }
  .system-health-pill {
    padding: 4px 8px;
    font-size: 11px;
  }

  /* Main Tactical Workspace on Mobile */
  .tactical-workspace {
    padding: 10px 10px calc(76px + env(safe-area-inset-bottom, 0px)) !important;
    gap: 12px;
  }

  /* KPI Strip - Sleek 2-column grid */
  .kpi-strip {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px !important;
    padding: 4px 0 8px !important;
  }
  .kpi-card {
    padding: 10px 12px;
  }
  .kpi-title {
    font-size: 11px;
  }
  .kpi-value {
    font-size: 19px;
  }
  .kpi-sub {
    font-size: 10px;
    margin-top: 2px;
  }
  #kpi-card-neo4j {
    grid-column: span 2;
  }

  /* Tactical Split - Stack Left & Right */
  .tactical-split {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  /* Target Profiles Grid on Mobile */
  .tactical-profile-grid {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }
  .tactical-card {
    padding: 12px 14px;
  }
  .btn-tactical {
    min-height: 38px;
    font-size: 12px;
  }

  /* Filter pills horizontal scroll */
  .filter-pills {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex-wrap: nowrap !important;
    padding: 2px 0 6px;
  }
  .filter-pills::-webkit-scrollbar {
    display: none;
  }
  .pill-filter {
    flex-shrink: 0;
    white-space: nowrap;
    padding: 6px 12px;
    font-size: 12px;
  }

  /* Mobile Drawer */
  .mobile-drawer {
    width: 290px;
    max-width: 85vw;
    background: var(--bg-card-solid);
    border-left: 1px solid var(--border-subtle);
  }
  .mobile-drawer-header {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-subtle);
  }

  /* Mobile Bottom App Bar */
  .mobile-bottom-nav {
    display: flex !important;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 62px;
    background: color-mix(in srgb, var(--bg-card-solid) 96%, transparent);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid var(--border-subtle);
    z-index: 9990 !important;
    align-items: center;
    justify-content: space-around;
    padding: 0 4px calc(env(safe-area-inset-bottom, 0px));
  }

  /* Bottom Clearance for all Main Views on Mobile */
  .workflow-view,
  .admin-view,
  .monitor-view,
  .tactical-workspace,
  .board-container {
    padding-bottom: calc(84px + env(safe-area-inset-bottom, 0px)) !important;
  }
  .mob-nav-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 600;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    transition: color var(--transition-fast);
  }
  .mob-nav-btn.active {
    color: var(--accent-cyan);
  }
  .mob-nav-btn svg {
    stroke-width: 2.2;
  }

  /* Modals as Mobile Bottom Sheets */
  .modal-backdrop {
    align-items: flex-end !important;
    padding: 0 !important;
  }
  .modal-box {
    width: 100% !important;
    max-width: 100% !important;
    border-radius: 20px 20px 0 0 !important;
    max-height: 86vh !important;
    border-bottom: none !important;
    animation: modalSlideUp 0.28s cubic-bezier(0.16, 1, 0.3, 1) !important;
  }
  @keyframes modalSlideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
  }

  /* Dossier stats on mobile */
  .dossier-stats-strip {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px !important;
  }

  /* Neo4j stats on mobile */
  .graph-stats-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px !important;
  }
  .graph-stat-card {
    padding: 10px 12px !important;
  }
  .graph-stat-num {
    font-size: 18px !important;
  }
}

@media (max-width: 480px) {
  .app-header {
    padding: 6px 10px;
  }
  .system-health-pill {
    display: none;
  }
  .btn-tactical {
    font-size: 11px;
    padding: 6px 8px;
  }
}

/* --- Monitoring Alert Event Triage & Profile Highlights --- */
.tactical-card.highlight-active {
  border: 1.5px solid var(--accent-rose) !important;
  box-shadow: 0 4px 16px rgba(251, 113, 133, 0.18) !important;
  background: var(--bg-card) !important;
}

body.light-theme .tactical-card.highlight-active {
  border-color: #fb7185 !important;
  box-shadow: 0 4px 16px rgba(244, 63, 94, 0.15) !important;
}

.pulse-rose {
  background-color: var(--accent-rose);
  box-shadow: 0 0 0 0 rgba(251, 113, 133, 0.7);
  animation: pulseRose 1.8s infinite;
}

@keyframes pulseRose {
  0% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(251, 113, 133, 0.7);
  }
  70% {
    transform: scale(1);
    box-shadow: 0 0 0 6px rgba(251, 113, 133, 0);
  }
  100% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(251, 113, 133, 0);
  }
}

.btn-filter-pill {
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-filter-pill:hover {
  border-color: var(--border-focus);
  color: var(--text-primary);
}

.btn-filter-pill.active {
  background: var(--accent-blue);
  color: #ffffff !important;
  border-color: var(--accent-blue);
}

body.light-theme .btn-filter-pill.active {
  background: #0284c7;
  color: #ffffff !important;
  border-color: #0284c7;
}

.btn-link {
  text-decoration: underline;
  cursor: pointer;
}
.btn-link:hover {
  opacity: 0.8;
}

/* ==========================================================================
   ALERTS TRIAGE INBOX & RULES MANAGER ARCHITECTURE
   ========================================================================== */

/* Sub-tabs Navigation Bar */
.threats-tabs-nav {
  display: inline-flex;
  gap: 6px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 3px;
}

.threats-tab-btn {
  background: none;
  border: none;
  padding: 6px 14px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.threats-tab-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

.threats-tab-btn.active {
  background: var(--accent-blue);
  color: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

body.light-theme .threats-tab-btn.active {
  background: #0284c7;
  color: #ffffff;
}

.threats-live-pill {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent-emerald);
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: var(--radius-full);
  padding: 4px 10px;
  display: inline-flex;
  align-items: center;
}

/* Review Signal Notice */
.alerts-signal-notice {
  padding: 10px 14px;
  background: rgba(100, 136, 255, 0.08);
  border-left: 3px solid var(--accent-cyan);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Summary Strip (4 Status Counts) */
.alerts-summary-strip {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}

.summary-stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.summary-stat-card:hover {
  border-color: var(--border-medium);
  transform: translateY(-1px);
}

.summary-stat-card.active {
  border-color: var(--accent-blue);
  background: color-mix(in srgb, var(--accent-blue) 10%, var(--bg-card));
  box-shadow: 0 0 0 1px var(--accent-blue);
}

.summary-stat-card .stat-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}

.summary-stat-card .stat-count {
  font-size: 20px;
  font-weight: 800;
  color: var(--text-primary);
  font-family: var(--font-mono);
}

.summary-stat-card.status-unreviewed .stat-count { color: var(--accent-rose); }
.summary-stat-card.status-acknowledged .stat-count { color: var(--accent-cyan); }
.summary-stat-card.status-escalated .stat-count { color: var(--accent-amber); }
.summary-stat-card.status-dismissed .stat-count { color: var(--text-muted); }

/* Filter Bar */
.alerts-filter-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  margin-bottom: 12px;
}

.alerts-monitored-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  white-space: nowrap;
}

/* Bulk Action Bar */
.alerts-bulk-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-surface);
  border: 1px solid var(--accent-blue);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  margin-bottom: 12px;
  animation: fadeInDown 0.2s ease;
}

.alerts-bulk-bar .bulk-count {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-cyan);
}

/* Two-Column Triage Inbox Layout */
.alerts-inbox-grid {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 14px;
  min-height: 580px;
  align-items: start;
}

.alerts-list-pane {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: calc(100vh - 270px);
  overflow-y: auto;
  padding-right: 4px;
}

.alerts-compact-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Compact Alert Card */
.alert-compact-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-left: 4px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.alert-compact-card:hover {
  background: var(--bg-surface);
  border-color: var(--border-medium);
}

.alert-compact-card.selected {
  background: color-mix(in srgb, var(--accent-blue) 12%, var(--bg-card));
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 1px var(--accent-blue);
}

.alert-compact-card.sev-critical { border-left-color: var(--accent-rose); }
.alert-compact-card.sev-alert { border-left-color: var(--accent-amber); }
.alert-compact-card.sev-routine { border-left-color: var(--accent-emerald); }

.card-top-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
}

.alert-card-cb {
  cursor: pointer;
  width: 15px;
  height: 15px;
  margin: 0;
  accent-color: var(--accent-blue);
}

.alert-handle {
  font-weight: 700;
  color: var(--text-primary);
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.author-tag-pill {
  font-size: 9.5px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
  text-transform: uppercase;
  white-space: nowrap;
}

.author-tag-pill.tag-monitored {
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-emerald);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.author-tag-pill.tag-extra {
  background: rgba(100, 136, 255, 0.12);
  color: var(--accent-cyan);
  border: 1px solid rgba(100, 136, 255, 0.25);
}

.author-tag-pill.tag-external {
  background: rgba(148, 163, 184, 0.12);
  color: var(--text-muted);
  border: 1px solid rgba(148, 163, 184, 0.2);
}

.alert-platform {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: capitalize;
}

.alert-time {
  margin-left: auto;
  font-size: 10px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  white-space: nowrap;
}

.card-snippet-row {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
}

.card-bottom-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-top: 2px;
}

.card-chips {
  display: flex;
  gap: 4px;
  overflow: hidden;
}

.alert-term-chip {
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 3px;
  background: rgba(251, 113, 133, 0.12);
  color: var(--accent-rose);
  border: 1px solid rgba(251, 113, 133, 0.2);
  white-space: nowrap;
}

.alert-term-chip.more {
  background: var(--bg-surface);
  color: var(--text-muted);
  border-color: var(--border-subtle);
}

.card-status-badge {
  font-size: 9.5px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
  text-transform: uppercase;
}

.card-status-badge.status-unreviewed { background: rgba(251, 113, 133, 0.15); color: var(--accent-rose); }
.card-status-badge.status-acknowledged { background: rgba(100, 136, 255, 0.15); color: var(--accent-cyan); }
.card-status-badge.status-escalated { background: rgba(251, 191, 36, 0.15); color: var(--accent-amber); }
.card-status-badge.status-dismissed { background: rgba(148, 163, 184, 0.15); color: var(--text-muted); }

/* Right Column: Alert Detail Pane */
.alert-detail-pane {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: calc(100vh - 270px);
  overflow-y: auto;
}

.mobile-back-btn {
  display: none;
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
  cursor: pointer;
  align-self: flex-start;
  min-height: 44px;
}

.detail-header-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.detail-user-block {
  display: flex;
  align-items: center;
  gap: 12px;
}

.detail-avatar {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-full);
  background: var(--accent-blue);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 15px;
}

.detail-user-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.user-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.detail-handle {
  font-size: 15px;
  font-weight: 800;
  color: var(--accent-cyan);
  text-decoration: none;
}

.detail-handle:hover {
  text-decoration: underline;
}

.time-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
}

.sev-pill-critical {
  font-size: 10px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 3px;
  background: rgba(251, 113, 133, 0.18);
  color: var(--accent-rose);
}

.sev-pill-alert {
  font-size: 10px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 3px;
  background: rgba(251, 191, 36, 0.18);
  color: var(--accent-amber);
}

.sev-pill-routine {
  font-size: 10px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 3px;
  background: rgba(16, 185, 129, 0.18);
  color: var(--accent-emerald);
}

.detail-status {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 3px;
}

.detail-status.status-unreviewed { background: rgba(251, 113, 133, 0.15); color: var(--accent-rose); }
.detail-status.status-acknowledged { background: rgba(100, 136, 255, 0.15); color: var(--accent-cyan); }
.detail-status.status-escalated { background: rgba(251, 191, 36, 0.15); color: var(--accent-amber); }
.detail-status.status-dismissed { background: rgba(148, 163, 184, 0.15); color: var(--text-muted); }

.detail-date {
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.detail-quick-links {
  display: flex;
  gap: 8px;
}

.detail-actions-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 12px;
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

.kb-hint {
  margin-left: auto;
  font-size: 10.5px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.detail-snippet-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}

.snippet-header {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 6px;
}

.snippet-body {
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--text-primary);
  white-space: pre-wrap;
  word-break: break-word;
}

.snippet-body .highlight-term {
  background: rgba(251, 113, 133, 0.28);
  color: var(--accent-rose);
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 3px;
}

.detail-hits-card {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}

.hits-header {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.hits-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.alert-hit-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  gap: 8px;
}

.hit-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  flex-wrap: wrap;
}

.hit-sev {
  font-size: 9.5px;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 3px;
}

.hit-sev.critical { background: rgba(251, 113, 133, 0.18); color: var(--accent-rose); }
.hit-sev.alert { background: rgba(251, 191, 36, 0.18); color: var(--accent-amber); }

.hit-rule-name {
  font-weight: 700;
  color: var(--text-primary);
}

.hit-term {
  color: var(--text-secondary);
}

.btn-mute-word {
  background: none;
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  font-size: 11px;
  padding: 4px 8px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.btn-mute-word:hover {
  color: var(--accent-rose);
  border-color: var(--accent-rose);
  background: rgba(251, 113, 133, 0.08);
}

.detail-signal-notice {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg-surface);
  border: 1px dashed var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
}

/* =========================================================================
   PART B: MONITORING RULES MANAGER STYLES
   ========================================================================= */

.rules-manager-grid {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 14px;
  min-height: 600px;
  align-items: start;
}

.rules-list-pane {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: calc(100vh - 220px);
}

.rules-accordion-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
  flex: 1;
  padding-right: 2px;
}

.rules-cat-header {
  font-size: 10.5px;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 8px 4px 4px;
  letter-spacing: 0.5px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.cat-count {
  font-family: var(--font-mono);
  background: var(--bg-surface);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 10px;
}

.rule-row-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.rule-row-item:hover {
  background: var(--bg-card);
  border-color: var(--border-medium);
}

.rule-row-item.selected {
  background: color-mix(in srgb, var(--accent-blue) 12%, var(--bg-surface));
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 1px var(--accent-blue);
}

.rule-row-item.disabled {
  opacity: 0.55;
}

.rule-sev-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.rule-row-meta {
  flex: 1;
  min-width: 0;
}

.rule-row-name {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rule-row-words {
  font-size: 10px;
  color: var(--text-muted);
}

/* Toggle Switch */
.rule-toggle-switch {
  position: relative;
  display: inline-block;
  width: 32px;
  height: 18px;
  flex-shrink: 0;
}

.rule-toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: var(--border-medium);
  transition: .2s;
  border-radius: 18px;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 2px;
  bottom: 2px;
  background-color: white;
  transition: .2s;
  border-radius: 50%;
}

.rule-toggle-switch input:checked + .toggle-slider {
  background-color: var(--accent-emerald);
}

.rule-toggle-switch input:checked + .toggle-slider:before {
  transform: translateX(14px);
}

/* Right Column: Rule Editor Pane */
.rule-editor-pane {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: calc(100vh - 220px);
  overflow-y: auto;
}

.editor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-subtle);
}

.editor-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--text-primary);
  margin: 0 0 4px;
}

.editor-meta {
  font-size: 11px;
  color: var(--text-muted);
}

.noisy-words-banner {
  background: rgba(251, 191, 36, 0.12);
  border: 1px solid var(--accent-amber);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.noisy-words-banner p {
  margin: 2px 0 0;
  font-size: 11.5px;
  color: var(--text-secondary);
}

.btn-turn-off-noisy {
  background: var(--accent-amber);
  color: #000000;
  font-weight: 700;
  font-size: 11.5px;
  border: none;
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  cursor: pointer;
  white-space: nowrap;
}

.editor-add-words-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

.editor-words-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.words-chips-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 220px;
  overflow-y: auto;
  padding: 4px 0;
}

.rule-word-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 11.5px;
}

.rule-word-chip.noisy {
  border-color: var(--accent-amber);
  background: rgba(251, 191, 36, 0.08);
}

.chip-term {
  font-weight: 700;
  color: var(--text-primary);
}

.chip-stats {
  font-size: 10px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.noisy-pill {
  font-size: 9px;
  font-weight: 800;
  background: var(--accent-amber);
  color: #000000;
  padding: 1px 4px;
  border-radius: 2px;
  text-transform: uppercase;
}

.btn-chip-mute {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0 2px;
}

.btn-chip-mute:hover {
  color: var(--accent-rose);
}

/* Muted Words Section */
.muted-words-section {
  background: var(--bg-surface);
  border: 1px dashed var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

.muted-header {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.muted-chips-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.muted-word-pill {
  font-size: 11px;
  color: var(--text-muted);
  text-decoration: line-through;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 3px;
  padding: 2px 6px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-unmute {
  background: none;
  border: none;
  color: var(--accent-cyan);
  cursor: pointer;
  font-size: 10px;
  font-weight: 700;
  padding: 0;
  text-decoration: none;
}

/* Test Box */
.editor-test-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.test-box-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
}

.test-highlight-output {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 150px;
  overflow-y: auto;
}

.test-match-mark {
  background: rgba(251, 113, 133, 0.35);
  color: var(--accent-rose);
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 3px;
}

/* ==========================================================================
   MOBILE RESPONSIVE PERFECTION (< 768px & <= 375px)
   ========================================================================== */

@media (max-width: 768px) {
  .alerts-summary-strip {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px !important;
  }
  .summary-stat-card:first-child {
    grid-column: span 2;
  }

  .alerts-filter-bar {
    gap: 6px !important;
  }

  /* Two-Screen Mobile View for Alerts: List vs Detail */
  .alerts-inbox-grid {
    grid-template-columns: 1fr !important;
  }

  .alert-detail-pane {
    display: none !important;
  }

  .mobile-show-detail .alerts-list-pane {
    display: none !important;
  }

  .mobile-show-detail .alert-detail-pane {
    display: flex !important;
  }

  .mobile-back-btn {
    display: inline-flex !important;
  }

  /* Touch targets >= 44px */
  .btn-tactical, .btn-filter-pill, .summary-stat-card, .threats-tab-btn {
    min-height: 44px;
  }

  /* Rules Manager stacked on mobile */
  .rules-manager-grid {
    grid-template-columns: 1fr !important;
  }
}



/* Internal / External switch for the alerts list */
.alerts-scope-switch { display: inline-flex; border: 1px solid var(--border-subtle, #CBD5E1); border-radius: 10px; overflow: hidden; background: var(--bg-card, #fff); }
.alerts-scope-switch button { border: 0; background: transparent; color: inherit; padding: 8px 14px; font-size: 13px; font-weight: 500; cursor: pointer; min-height: 36px; }
.alerts-scope-switch button + button { border-left: 1px solid var(--border-subtle, #CBD5E1); }
.alerts-scope-switch button.on { background: #2563EB; color: #fff; }
.alerts-scope-switch button:focus-visible { outline: 2px solid #2563EB; outline-offset: -2px; }
@media (max-width: 600px) { .alerts-scope-switch { width: 100%; } .alerts-scope-switch button { flex: 1 1 33%; min-height: 44px; } }
