/**
 * components.css
 * WebhookWise Dashboard — Component Styles
 */

/* ═══════════════════════════════════════════════════════════════════════════
   Alert List
   ═══════════════════════════════════════════════════════════════════════════ */

.alerts-section {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

/* Alert quality center — diagnostic and deliberately read-only. */
.alert-quality-header p,
.alert-quality-panel-heading p,
.alert-quality-sources > .alert-quality-panel-heading p {
  margin: 0.3rem 0 0;
  color: var(--text-secondary);
  font-size: var(--fs-sm);
}

.alert-quality-title-line,
.alert-quality-source-name {
  display: flex;
  gap: 0.55rem;
  align-items: center;
  flex-wrap: wrap;
}

.alert-quality-readonly,
.alert-quality-source-name em {
  display: inline-flex;
  align-items: center;
  border: 1px solid color-mix(in srgb, var(--primary) 24%, var(--border));
  border-radius: 999px;
  background: color-mix(in srgb, var(--primary) 7%, var(--card-bg));
  color: var(--primary);
  padding: 0.18rem 0.55rem;
  font-size: var(--fs-xs);
  font-style: normal;
  font-weight: 700;
}

.alert-quality-window {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  color: var(--text-secondary);
  font-size: var(--fs-sm);
  font-weight: 600;
}

.alert-quality-window select {
  width: auto;
}

.alert-quality-disclaimer {
  display: flex;
  gap: 0.8rem;
  align-items: flex-start;
  margin-bottom: 1rem;
  border: 1px solid color-mix(in srgb, var(--primary) 18%, var(--border));
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--primary) 5%, var(--card-bg));
  padding: 0.85rem 1rem;
}

.alert-quality-disclaimer > span {
  font-size: 1.1rem;
}

.alert-quality-disclaimer strong {
  color: var(--text-main);
  font-size: 0.86rem;
}

.alert-quality-disclaimer p {
  margin: 0.2rem 0 0;
  color: var(--text-secondary);
  font-size: var(--fs-sm);
  line-height: 1.5;
}

.alert-quality-summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.alert-quality-summary > article {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card-bg);
  padding: 0.9rem 1rem;
  box-shadow: var(--shadow-sm);
}

.alert-quality-summary article > span {
  display: block;
  overflow: hidden;
  color: var(--text-secondary);
  font-size: var(--fs-xs);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.alert-quality-summary article > strong {
  display: block;
  margin: 0.25rem 0 0.2rem;
  color: var(--text-main);
  font-size: 1.45rem;
  line-height: 1.1;
}

.alert-quality-summary article > small {
  display: block;
  overflow: hidden;
  color: var(--text-muted);
  font-size: var(--fs-xs);
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Tier state rides the LEFT edge only (border-color painted the card's whole
   1px outline too — a full alarm ring around a mid score). */
.alert-quality-score-card {
  border-left: 3px solid var(--text-muted) !important;
}

.alert-quality-score-card.is-healthy,
.alert-quality-source-score.is-healthy {
  border-left-color: var(--success) !important;
  color: var(--success);
}

.alert-quality-score-card.is-fair,
.alert-quality-source-score.is-fair {
  border-left-color: #6c8e32 !important;
  color: #6c8e32;
}

.alert-quality-score-card.is-warning,
.alert-quality-source-score.is-warning {
  border-left-color: var(--warning) !important;
  color: #a96d00;
}

.alert-quality-score-card.is-poor,
.alert-quality-source-score.is-poor {
  border-left-color: var(--danger) !important;
  color: var(--danger);
}

.alert-quality-panel,
.alert-quality-sources {
  margin-bottom: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card-bg);
  padding: 1rem;
  box-shadow: var(--shadow-sm);
}

.alert-quality-panel-heading {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 0.85rem;
}

.alert-quality-panel-heading h3 {
  margin: 0;
  color: var(--text-main);
  font-size: 0.95rem;
}

.alert-quality-coverage-grid,
.alert-quality-source-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
}

.alert-quality-coverage-item {
  min-width: 0;
}

.alert-quality-coverage-item > div:first-child {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
  color: var(--text-secondary);
  font-size: 0.74rem;
}

.alert-quality-coverage-item strong {
  color: var(--text-main);
}

.alert-quality-meter {
  overflow: hidden;
  height: 0.4rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--border) 70%, transparent);
}

.alert-quality-meter i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--text-muted);
}

.alert-quality-meter.is-ok i { background: var(--success); }
.alert-quality-meter.is-mid i { background: var(--warning); }
.alert-quality-meter.is-low i { background: var(--danger); }

.alert-quality-top-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.65rem;
}

.alert-quality-top-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.2rem 0.5rem;
  border: 1px solid var(--border);
  border-left: 3px solid var(--text-muted);
  border-radius: var(--radius);
  padding: 0.7rem;
}

.alert-quality-top-item.is-high,
.alert-quality-finding.is-high {
  border-left-color: var(--danger);
}

.alert-quality-top-item.is-medium,
.alert-quality-finding.is-medium {
  border-left-color: var(--warning);
}

.alert-quality-top-item.is-low,
.alert-quality-finding.is-low {
  border-left-color: var(--primary);
}

.alert-quality-top-item strong {
  overflow: hidden;
  color: var(--text-main);
  font-size: var(--fs-sm);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.alert-quality-top-item small {
  grid-column: 2;
  color: var(--text-muted);
  font-size: var(--fs-xs);
}

.alert-quality-severity {
  border-radius: 999px;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  padding: 0.12rem 0.4rem;
  font-size: var(--fs-xs);
  font-weight: 700;
}

.alert-quality-source {
  margin-top: 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--card-bg) 94%, var(--bg-secondary));
  padding: 1rem;
}

.alert-quality-source > header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
}

.alert-quality-source-name strong {
  color: var(--text-main);
  font-size: 0.95rem;
}

.alert-quality-source-name > span {
  color: var(--text-muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: var(--fs-xs);
}

.alert-quality-source > header p {
  margin: 0.3rem 0 0;
  color: var(--text-muted);
  font-size: 0.74rem;
}

.alert-quality-source-score {
  min-width: 4rem;
  border-right: 3px solid var(--text-muted);
  padding-right: 0.6rem;
  text-align: right;
}

.alert-quality-source-score strong,
.alert-quality-source-score span {
  display: block;
}

.alert-quality-source-score strong {
  font-size: 1.35rem;
  line-height: 1;
}

.alert-quality-source-score span {
  margin-top: 0.2rem;
  color: var(--text-muted);
  font-size: var(--fs-xs);
  white-space: nowrap;
}

.alert-quality-source-metrics {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin-top: 0.9rem;
  border-top: 1px solid var(--border);
  padding-top: 0.8rem;
}

.alert-quality-mini-metric {
  display: flex;
  justify-content: space-between;
  gap: 0.4rem;
  align-items: center;
  border-left: 1px solid var(--border);
  padding-left: 0.75rem;
  color: var(--text-secondary);
  font-size: 0.74rem;
}

.alert-quality-mini-metric strong {
  color: var(--text-main);
}

.alert-quality-findings {
  display: grid;
  gap: 0.55rem;
  margin-top: 0.85rem;
}

.alert-quality-finding {
  border: 1px solid var(--border);
  border-left: 3px solid var(--text-muted);
  border-radius: var(--radius);
  background: var(--card-bg);
  padding: 0.75rem 0.85rem;
}

.alert-quality-finding-title {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.alert-quality-finding-title strong {
  color: var(--text-main);
  font-size: var(--fs-sm);
}

.alert-quality-finding-title > span:last-child {
  color: var(--text-muted);
  font-size: var(--fs-xs);
}

.alert-quality-finding > p,
.alert-quality-fix p {
  margin: 0.4rem 0 0;
  color: var(--text-secondary);
  font-size: 0.76rem;
  line-height: 1.5;
}

.alert-quality-fix {
  margin-top: 0.55rem;
  border-radius: calc(var(--radius) - 2px);
  background: color-mix(in srgb, var(--primary) 6%, var(--bg-secondary));
  padding: 0.55rem 0.65rem;
}

.alert-quality-fix > span {
  color: var(--primary);
  font-size: var(--fs-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.alert-quality-fix p {
  margin-top: 0.2rem;
}

.alert-quality-samples {
  display: block;
  margin-top: 0.45rem;
  color: var(--text-muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: var(--fs-xs);
}

.alert-quality-source-healthy {
  margin-top: 0.85rem;
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--success) 8%, var(--card-bg));
  color: var(--success);
  padding: 0.65rem 0.8rem;
  font-size: 0.76rem;
}

@media (max-width: 960px) {
  .alert-quality-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .alert-quality-coverage-grid,
  .alert-quality-source-metrics,
  .alert-quality-top-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .alert-quality-summary,
  .alert-quality-coverage-grid,
  .alert-quality-source-metrics,
  .alert-quality-top-list {
    grid-template-columns: 1fr;
  }

  .alert-quality-source > header,
  .alert-quality-header {
    align-items: stretch;
    flex-direction: column;
  }

  .alert-quality-source-score {
    display: flex;
    gap: 0.5rem;
    align-items: baseline;
    border-right: 0;
    border-left: 3px solid var(--text-muted);
    padding: 0 0 0 0.6rem;
    text-align: left;
  }

  .alert-quality-mini-metric {
    border-left: 0;
    padding-left: 0;
  }
}

.alert-item {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  margin-bottom: 0.75rem;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.alert-item:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--primary-light);
  transform: translateY(-2px);
}

.alert-item.alert-focus {
  border-color: var(--primary-light);
  box-shadow: var(--ring-primary), var(--shadow-lg);
}

.alert-item:last-child {
  border-bottom: 1px solid var(--border);
}

.alert-header {
  padding: 0.875rem 1.25rem;
  display: block;
  cursor: pointer;
  border-bottom: 1px solid transparent;
  transition: background 0.15s;
}

.alert-item:hover .alert-header {
  background: var(--bg-base);
}

.alert-item.expanded .alert-header {
  border-bottom-color: var(--border);
}

.alert-left {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 1;
  min-width: 0;
}

.alert-card-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(18rem, auto);
  align-items: start;
  gap: 1rem 1.5rem;
}

.alert-title-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.alert-icon {
  font-size: 1.25rem;
  flex-shrink: 0;
}

.alert-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
  min-width: 0;
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  line-height: 1.45;
  white-space: normal;
  word-break: break-word;
}

.alert-title.is-muted {
  color: var(--text-muted);
  font-weight: 500;
  font-style: italic;
}

.alert-meta {
  display: flex;
  gap: 1.25rem;
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  flex-wrap: wrap;
}

.alert-meta-item {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  white-space: nowrap;
}

.alert-status {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  max-width: 34rem;
}

.alert-time {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  white-space: nowrap;
}

.alert-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  cursor: default;
}

.alert-primary-actions,
.alert-secondary-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 0.375rem;
}

.alert-action-menu {
  margin-left: auto;
  max-width: 100%;
}

.alert-action-menu > summary {
  list-style: none;
  width: max-content;
  margin-left: auto;
}

.alert-action-menu > summary::-webkit-details-marker {
  display: none;
}

.alert-action-menu[open] {
  flex: 1 0 100%;
  width: 100%;
}

.alert-secondary-actions {
  margin-top: 0.625rem;
  padding: 0.75rem;
  border-radius: var(--radius-md);
  background: var(--bg-base);
  border: 1px solid var(--border);
}

.btn:disabled,
.btn.is-busy {
  opacity: 0.55;
  cursor: wait;
  pointer-events: none;
  transform: none;
}

.btn.is-busy::before {
  content: "";
  width: 0.7rem;
  height: 0.7rem;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: alert-action-spin 0.7s linear infinite;
}

@keyframes alert-action-spin {
  to { transform: rotate(360deg); }
}

.alert-details {
  padding: 0 1.25rem 1.25rem;
  display: none;
}

.alert-item.expanded .alert-details {
  display: block;
  animation: slideDown 0.2s ease-out;
}

.details-tabs {
  display: flex;
  gap: 1rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
  padding-top: 1rem;
}

/* Inline tab component (inside alert detail panels) */
.tab {
  padding: 0.5rem 0;
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}

.tab:hover {
  color: var(--text-main);
}

.tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* ═══════════════════════════════════════════════════════════════════════════
   Badges
   ═══════════════════════════════════════════════════════════════════════════ */

.badge {
  padding: 0.2rem 0.6rem;
  border-radius: 9999px;
  font-size: var(--fs-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  gap: 0.25rem;
}

.badge-high { background: var(--danger-bg); color: var(--danger); border: 1px solid rgba(225,29,72,0.18); }
.badge-medium { background: var(--warning-bg); color: var(--warning); border: 1px solid rgba(217,119,6,0.18); }
.badge-low { background: var(--success-bg); color: var(--success); border: 1px solid rgba(5,150,105,0.18); }
.badge-duplicate { background: var(--primary-bg); color: var(--primary-hover); border: 1px solid rgba(99,102,241,0.20); }
.badge-new { background: var(--bg-subtle); color: var(--text-secondary); border: 1px solid var(--border); }
.badge-success { background: var(--success-bg); color: var(--success); border: 1px solid rgba(5,150,105,0.18); }
.badge-outline { background: transparent; color: var(--text-secondary); border: 1px solid var(--border); }
.badge-danger { background: var(--danger-bg); color: var(--danger); border: 1px solid rgba(225,29,72,0.18); }

/* ═══════════════════════════════════════════════════════════════════════════
   Pagination
   ═══════════════════════════════════════════════════════════════════════════ */

.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-top: 1rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.pagination-info {
  font-size: var(--fs-sm);
  color: var(--text-secondary);
}

.pagination-buttons {
  display: flex;
  gap: 0.375rem;
  flex-wrap: wrap;
}

.pagination button {
  padding: 0.4rem 0.85rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: var(--fs-sm);
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text-secondary);
}

.pagination button:hover:not(:disabled) {
  background: var(--bg-subtle);
  border-color: var(--text-muted);
}

.pagination button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.compact-pagination {
  width: 100%;
  box-sizing: border-box;
  margin-top: 0;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Modal
   ═══════════════════════════════════════════════════════════════════════════ */

.modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.25s ease;
}

.modal:not(.active) {
  display: none;
}

.modal.active {
  opacity: 1;
  visibility: visible;
}

.modal-content {
  background: var(--bg-surface);
  border-radius: var(--radius-xl);
  width: 90%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: scale(0.96) translateY(8px);
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  border: 1px solid var(--border);
}

.modal.active .modal-content {
  transform: scale(1) translateY(0);
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg-elevated);
  backdrop-filter: blur(8px);
}

.modal-title {
  margin: 0;
  font-size: 1.15rem;
  color: var(--text-main);
  font-weight: 600;
  letter-spacing: -0.02em;
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  padding: 1.25rem 1.5rem;
  border-top: 1px solid var(--border-light);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  background: var(--bg-base);
}

/* ═══════════════════════════════════════════════════════════════════════════
   Code Block
   ═══════════════════════════════════════════════════════════════════════════ */

.code-wrapper {
  margin: 1rem 0;
}

.code-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 1rem;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.code-lang {
  color: var(--text-muted);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.05em;
}

.code-copy-btn {
  padding: 0.25rem 0.75rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-secondary);
  font-size: var(--fs-xs);
  cursor: pointer;
  transition: all 0.2s;
}

.code-copy-btn:hover {
  background: var(--bg-surface);
  color: var(--text-main);
}

.code-block {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  padding: 1.25rem;
  overflow-x: auto;
  font-size: var(--fs-sm);
  font-family: var(--font-mono);
  line-height: 1.6;
  max-height: 600px;
  overflow-y: auto;
}

.code-block pre {
  margin: 0;
  color: var(--code-fg);
}

.code-block pre::-webkit-scrollbar { height: 6px; }
.code-block pre::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* JSON syntax highlight — themed via the code tokens, not a palette island. */
.json-key { color: var(--code-key); }
.json-string { color: var(--code-string); }
.json-number { color: var(--code-number); }
.json-boolean { color: var(--code-literal); }
.json-null { color: var(--code-literal); }

/* The ONE preformatted style for plain code/text blocks (raw payloads,
   analysis dumps, sandbox output). Anything mono-and-boxed uses this or the
   full .code-wrapper component; ad-hoc inline <pre> styling is design debt. */
.ww-pre {
  margin: 0;
  background: var(--code-bg);
  color: var(--code-fg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.75rem 0.9rem;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* ═══════════════════════════════════════════════════════════════════════════
   AI Analysis Panel (inside alert detail)
   ═══════════════════════════════════════════════════════════════════════════ */

.ai-section {
  background: var(--success-bg);
  border: 1px solid rgba(5,150,105,0.18);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  margin-top: 1rem;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Deep-Analysis Report (investigation result, inside alert detail)
   ═══════════════════════════════════════════════════════════════════════════ */

/* The investigator returns a structured report — summary, root cause, impact,
   evidence, timeline, recommendations, and what it could NOT determine. It was
   being dumped into a <pre> as raw JSON because the renderer assumed the
   gateway's text field held markdown. These classes exist so an operator reads
   a report instead of a payload; the sections are the report's own shape, not
   a new one invented here. */
.dar-summary {
  font-size: var(--fs-md);
  color: var(--text-main);
  line-height: 1.65;
  padding-bottom: var(--sp-4);
  margin-bottom: var(--sp-4);
  border-bottom: 1px solid var(--border);
}

.dar-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--sp-5);
}

.dar-wide { grid-column: 1 / -1; }

.dar-body {
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  line-height: 1.6;
  margin: 0;
  white-space: pre-wrap;
}

.dar-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.dar-list > li {
  position: relative;
  padding-left: var(--sp-4);
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  line-height: 1.6;
}

.dar-list > li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.62em;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--text-muted);
}

/* Evidence says what it found AND what that supports; the timeline says when.
   That second line is the part that makes a claim checkable, so it stays on
   screen rather than behind a tooltip. */
.dar-sub {
  display: block;
  margin-top: var(--sp-1);
  font-size: var(--fs-xs);
  color: var(--text-muted);
  line-height: 1.55;
}

.dar-time {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

/* Priority is a state, so it carries one point of colour (the dot) on a
   neutral surface — a filled chip would be decoration. */
.dar-pri {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  margin-right: var(--sp-2);
  padding: 0 var(--sp-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: var(--fs-xs);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
  white-space: nowrap;
}

/* What the investigation could not establish is a first-class section, not an
   omission: a report that only lists findings reads as more certain than it
   is. Held at secondary weight so it informs without competing. */
.dar-open > li::before { background: var(--warning); }

/* ═══════════════════════════════════════════════════════════════════════════
   Empty & Loading States
   ═══════════════════════════════════════════════════════════════════════════ */

.empty-state {
  text-align: center;
  padding: 4rem 2rem;
}

.empty-icon {
  font-size: 3.5rem;
  margin-bottom: 1rem;
  opacity: 0.25;
}

.empty-title {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 0.5rem;
}

.empty-text {
  color: var(--text-muted);
  font-size: var(--fs-md);
}

.loading {
  text-align: center;
  padding: 3rem;
}

.spinner {
  width: 36px;
  height: 36px;
  margin: 0 auto 1rem;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ═══════════════════════════════════════════════════════════════════════════
   Custom Checkboxes (used in config modal & rule form)
   ═══════════════════════════════════════════════════════════════════════════ */

.form-checkbox {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  background: var(--bg-subtle);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  transition: all 0.2s ease;
  cursor: pointer;
}

.form-checkbox:hover {
  background: var(--bg-surface);
  border-color: var(--text-muted);
}

.form-checkbox input[type="checkbox"] {
  width: 1.2rem;
  height: 1.2rem;
  border-radius: 4px;
  border: 2px solid var(--border);
  appearance: none;
  background-color: var(--bg-surface);
  cursor: pointer;
  position: relative;
  transition: all 0.2s;
  flex-shrink: 0;
}

.form-checkbox input[type="checkbox"]:checked {
  background-color: var(--primary);
  border-color: var(--primary);
}

.form-checkbox.importance-check {
  padding: 0.35rem 0.75rem;
  margin-bottom: 0;
  display: inline-flex;
}

.importance-check {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  font-size: var(--fs-md);
  color: var(--text-secondary);
  user-select: none;
}

.event-type-check {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0.4rem 0.6rem;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  transition: all 0.15s;
  user-select: none;
}

.event-type-check:hover {
  background: var(--primary-bg);
  border-color: var(--primary-light);
  color: var(--text-main);
}

.event-type-check input[type="checkbox"] {
  width: 0.9rem;
  height: 0.9rem;
  accent-color: var(--primary);
  flex-shrink: 0;
}

.form-checkbox input[type="checkbox"]:checked::after {
  content: '✓';
  color: #ffffff;
  font-size: var(--fs-sm);
  font-weight: bold;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.form-checkbox input[type="checkbox"]:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.form-checkbox label {
  margin: 0;
  cursor: pointer;
  font-weight: 500;
  color: var(--text-secondary);
  flex-grow: 1;
  font-size: var(--fs-md);
}

/* ═══════════════════════════════════════════════════════════════════════════
   Toggle Switch (forward rules enabled/disabled)
   ═══════════════════════════════════════════════════════════════════════════ */

.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: var(--border);
  transition: 0.3s;
  border-radius: 24px;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
}

.slider::before {
  content: '';
  position: absolute;
  height: 18px; width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.3s;
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.switch input:checked + .slider {
  background: var(--accent-gradient);
}

.switch input:checked + .slider::before {
  transform: translateX(20px);
}

/* ═══════════════════════════════════════════════════════════════════════════
   Deep Analysis Cards
   ═══════════════════════════════════════════════════════════════════════════ */

.da-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 1.25rem;
  background: var(--bg-surface);
  overflow: hidden;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow-sm);
}

.da-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--primary-light);
  transform: translateY(-2px);
}

.da-card-expanded {
  border-color: var(--primary-light);
  box-shadow: var(--ring-primary), var(--shadow-lg);
}

.da-summary {
  display: flex;
  align-items: flex-start;
  padding: 1.1rem 1.25rem;
  cursor: pointer;
  gap: 1rem;
  background: var(--bg-base);
  border-bottom: 1px solid transparent;
  transition: background 0.2s;
  min-width: 0;
}

.da-summary:hover { background: var(--bg-subtle); }

.da-card-expanded .da-summary {
  border-bottom-color: var(--border);
  background: var(--bg-surface);
}

.da-summary-main {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 0.55rem;
  min-width: 0;
}

.da-summary-meta-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
  min-width: 0;
}

.da-alert-title {
  color: var(--text-main);
  font-size: 0.95rem;
  font-weight: 700;
  white-space: nowrap;
}

.da-source {
  color: var(--text-muted);
  font-size: var(--fs-sm);
  min-width: 0;
  max-width: min(36rem, 100%);
  overflow-wrap: anywhere;
}

.da-preview {
  color: var(--text-main);
  display: -webkit-box;
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1.55;
  margin-top: 0.1rem;
  overflow: hidden;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.da-preview-pending {
  color: var(--warning);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.da-preview-error {
  color: var(--danger);
}

.da-preview-empty {
  color: var(--text-muted);
  font-weight: 500;
}

.da-summary-runtime {
  color: var(--text-muted);
  flex: 0 0 9.5rem;
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  line-height: 1.45;
  overflow-wrap: anywhere;
  text-align: right;
}

.da-duration-value {
  color: var(--text-main);
  margin-top: 0.25rem;
}

.da-analysis-report {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1.25rem;
}

.da-report-strip {
  align-items: center;
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  font-size: var(--fs-sm);
  font-weight: 600;
  gap: 0.45rem 0.85rem;
  padding: 0.55rem 0.75rem;
}

.da-report-strip span {
  line-height: 1.4;
}

.da-report-failed {
  color: var(--danger);
}

.da-empty-report {
  background: var(--warning-bg);
  border: 1px solid rgba(217,119,6,0.18);
  border-radius: var(--radius-md);
  color: var(--warning);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 1rem;
}

.da-empty-report strong {
  color: var(--text-main);
  font-size: 0.95rem;
}

.da-empty-report span {
  font-size: 0.86rem;
}

.da-analysis-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.da-analysis-section {
  background: var(--bg-base);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  min-width: 0;
  padding: 1rem;
}

.da-analysis-summary {
  background: var(--primary-bg);
  border-color: rgba(99, 102, 241, 0.20);
}

.da-analysis-section-wide {
  grid-column: 1 / -1;
}

.da-analysis-section h4 {
  color: var(--text-muted);
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.05em;
  margin: 0 0 0.65rem;
  text-transform: uppercase;
}

.da-analysis-section p,
.da-analysis-section li,
.da-analysis-section dd {
  color: var(--text-main);
  font-size: 0.94rem;
  line-height: 1.7;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.da-analysis-section p {
  margin: 0;
}

.da-analysis-section ul {
  margin: 0;
  padding-left: 1.25rem;
}

.da-report-list li {
  margin-bottom: 0.45rem;
}

.da-report-list li:last-child {
  margin-bottom: 0;
}

.da-kv-grid {
  display: grid;
  gap: 0.6rem;
  margin: 0;
}

.da-kv-row {
  display: grid;
  gap: 0.25rem;
  grid-template-columns: minmax(6rem, 0.34fr) minmax(0, 1fr);
}

.da-kv-row dt {
  color: var(--text-muted);
  font-size: var(--fs-sm);
  font-weight: 700;
  min-width: 0;
}

.da-kv-row dd {
  margin: 0;
  min-width: 0;
}

.da-kv-row dd .da-kv-grid {
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  margin-top: 0.15rem;
  padding: 0.65rem;
}

.da-duration { color: var(--text-muted); font-size: 0.85em; white-space: nowrap; font-family: var(--font-mono); flex-shrink: 0; }

.da-details {
  display: none;
  padding: 1.5rem;
  border-top: 1px solid var(--border);
  background: var(--bg-surface);
}

.da-card-expanded .da-details {
  display: block;
  animation: slideDown 0.3s ease-out forwards;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Outbox Table
   ═══════════════════════════════════════════════════════════════════════════ */

.outbox-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
}

.outbox-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
}

.outbox-table thead {
  background: var(--bg-base);
  border-bottom: 2px solid var(--border);
}

.outbox-table th {
  padding: 0.6rem 0.85rem;
  text-align: left;
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.outbox-table td {
  padding: 0.55rem 0.85rem;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-main);
}

.outbox-table .col-check {
  width: 2.5rem;
  text-align: center;
}

.modal-content-wide {
  max-width: min(920px, calc(100vw - 2rem));
}

.detail-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1rem;
}

.detail-table th,
.detail-table td {
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.detail-table th {
  width: 8rem;
  color: var(--text-muted);
  font-weight: 600;
}

.json-preview {
  max-height: 18rem;
  overflow: auto;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-base);
  color: var(--text-main);
  white-space: pre-wrap;
  word-break: break-word;
  font-size: var(--fs-sm);
}

.outbox-row {
  cursor: pointer;
  transition: background 0.15s;
}

.outbox-row:hover {
  background: var(--bg-subtle);
}

.outbox-id {
  font-family: var(--font-mono);
  color: var(--text-muted);
  font-size: var(--fs-sm);
}

@media (max-width: 1100px) {
  .alert-card-top {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.75rem;
  }

  .alert-status {
    max-width: none;
    justify-content: flex-start;
  }
}

@media (max-width: 768px) {
  .alert-header {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .alert-title-row {
    align-items: flex-start;
  }

  .alert-title {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    white-space: normal;
    word-break: break-word;
  }

  .alert-meta {
    gap: 0.4rem 0.75rem;
  }

  .alert-meta-item {
    white-space: normal;
  }

  .alert-status {
    width: 100%;
    justify-content: flex-start;
  }

  .alert-toolbar,
  .alert-primary-actions,
  .alert-secondary-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .alert-action-menu {
    width: 100%;
    margin-left: 0;
  }

  .alert-action-menu > summary {
    margin-left: 0;
  }

  .alert-secondary-actions .btn {
    width: 100%;
    justify-content: flex-start;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   Responsive
   ═══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
  .alert-header, .da-summary {
    padding: 1rem !important;
    flex-direction: column;
    align-items: flex-start !important;
    gap: 0.75rem !important;
  }

  .da-summary-main,
  .da-summary-runtime {
    width: 100%;
  }

  .da-summary-meta-row {
    gap: 0.45rem;
  }

  .da-source,
  .da-alert-title {
    white-space: normal;
  }

  .da-preview {
    -webkit-line-clamp: 4;
  }

  .da-summary-runtime {
    display: flex;
    flex: 0 1 auto;
    justify-content: space-between;
    gap: 0.75rem;
    text-align: left;
  }

  .da-duration-value {
    margin-top: 0;
    white-space: nowrap;
  }

  .alert-status {
    flex-wrap: wrap;
    width: 100%;
  }

  .da-details, .rule-card {
    padding: 1rem !important;
  }

  .rule-actions, .da-btn-row,
  div[style*="display: flex; gap: 1rem; flex-wrap: wrap;"] {
    flex-direction: column;
    align-items: stretch !important;
    gap: 0.5rem !important;
  }

  .rule-actions .btn, .da-btn-row .btn,
  div[style*="display: flex; gap: 1rem; flex-wrap: wrap;"] .btn {
    width: 100%;
    justify-content: center;
    margin: 0 !important;
  }

  .modal-content {
    width: 95%;
    margin: 1rem;
    max-height: 95vh;
  }

  .modal-header, .modal-body, .modal-footer {
    padding: 1rem;
  }

  .modal-footer {
    flex-direction: column;
  }

  .modal-footer .btn {
    width: 100%;
    margin-bottom: 0.5rem;
  }

  .rule-header {
    flex-direction: column;
    align-items: flex-start !important;
    gap: 1rem;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   AI Cost trend (lightweight CSS bar chart)
   ═══════════════════════════════════════════════════════════════════════════ */
.aicost-trend-chart {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 160px;
  overflow-x: auto;
}

.aicost-trend-col {
  flex: 1 1 0;
  min-width: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
}

.aicost-trend-bar-wrap {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.aicost-trend-bar {
  /* Sparse windows (2-3 days) get wide flex columns; without a cap the bar
     becomes a solid slab that out-shouts the entire page. */
  width: 100%;
  max-width: 40px;
  min-height: 2px;
  background: color-mix(in srgb, var(--primary) 45%, var(--bg-subtle));
  border-radius: 3px 3px 0 0;
  transition: height 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.aicost-trend-col:last-child .aicost-trend-bar { background: var(--primary); }

.aicost-trend-col:hover .aicost-trend-bar { background: var(--primary-hover, #4f46e5); }

.aicost-trend-val {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  margin-bottom: 4px;
  white-space: nowrap;
}

.aicost-trend-col:last-child .aicost-trend-val { color: var(--text-main); }

.aicost-trend-x {
  margin-top: 6px;
  font-size: var(--fs-xs);
  color: var(--text-muted);
  white-space: nowrap;
}

/* Suppression-stack primer: a quiet one-line disclosure, not a floating
   bold string. The chevron is the affordance; the body reads at prose width. */
.dt-suppression-help {
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 8px;
}

.dt-suppression-help summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  list-style: none;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-secondary);
  padding: 2px 4px;
  border-radius: var(--radius-md);
}

.dt-suppression-help summary::-webkit-details-marker { display: none; }
.dt-suppression-help summary:hover { color: var(--text-main); background: var(--bg-subtle); }

.dt-help-chevron { transform: rotate(-90deg); transition: transform 0.15s ease; }
.dt-suppression-help[open] .dt-help-chevron { transform: rotate(0deg); }

.dt-help-body {
  padding: 8px 4px 4px 26px;
  line-height: 1.7;
  max-width: 60rem;
  color: var(--text-secondary);
  font-size: var(--fs-sm);
}

/* Segmented period switch: one control, not three loose buttons. */
.btn-seg-group { display: inline-flex; }
.btn-seg-group .btn { border-radius: 0; margin-left: -1px; position: relative; }
.btn-seg-group .btn:first-child { border-radius: var(--radius-md) 0 0 var(--radius-md); margin-left: 0; }
.btn-seg-group .btn:last-child { border-radius: 0 var(--radius-md) var(--radius-md) 0; }
.btn-seg-group .btn.active { z-index: 1; }

/* Which build am I looking at — quiet, at the end of the rail. */
.sidebar-version {
  padding: 8px 10px 4px;
  font-size: var(--fs-xs);
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  font-variant-numeric: tabular-nums;
}

body.sidebar-collapsed .sidebar-version { display: none; }

::selection { background: color-mix(in srgb, var(--primary) 30%, transparent); }

/* Per-rule importance list: two columns on wide screens — one 560px bar per
   full-width row left half the card empty. */
.dt-rule-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(460px, 1fr));
  gap: 0.25rem 2.5rem;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Decision Trace
   ═══════════════════════════════════════════════════════════════════════════ */
.dt-chip {
  font-size: var(--fs-sm);
  padding: 0.35rem 0.75rem;
  border-radius: 9999px;
}

.dt-chip.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* In-page view switches (segmented control): Decision Trace | AI Cost, and
   Routing's Forward Rules | Silences | Sandbox. */
.dt-view-btn.active,
.routing-view-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.dt-chain {
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.dt-step-row {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 1rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: var(--fs-sm);
}

.dt-step-row:last-child { border-bottom: none; }

.dt-step-name {
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
}

.dt-step-value {
  color: var(--text-secondary);
  word-break: break-word;
}

@media (max-width: 640px) {
  .dt-step-row {
    grid-template-columns: 1fr;
    gap: 0.25rem;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   Incident Intelligence
   ═══════════════════════════════════════════════════════════════════════════ */
.incident-intelligence {
  margin: 0 0 1.25rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-base);
}

.incident-intelligence-title {
  color: var(--text-main);
  font-size: var(--fs-md);
  font-weight: 700;
}

.incident-intelligence-note {
  margin: 0.25rem 0 0.85rem;
  color: var(--text-muted);
  font-size: var(--fs-xs);
}

.incident-intelligence-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
}

.incident-intelligence-group {
  min-width: 0;
}

.incident-intelligence-group h4 {
  margin: 0 0 0.5rem;
  color: var(--text-secondary);
  font-size: var(--fs-sm);
  font-weight: 700;
}

.incident-intelligence-card {
  margin-bottom: 0.55rem;
  padding: 0.7rem;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--bg-surface);
}

.incident-intelligence-card:last-child {
  margin-bottom: 0;
}

.incident-intelligence-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  color: var(--text-main);
  font-size: var(--fs-sm);
  line-height: 1.35;
}

.incident-intelligence-card-head strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.incident-intelligence-score {
  flex: 0 0 auto;
  color: var(--primary);
  font-size: 0.67rem;
  font-weight: 700;
}

.incident-intelligence-card p {
  display: -webkit-box;
  margin: 0.45rem 0 0;
  overflow: hidden;
  color: var(--text-secondary);
  font-size: var(--fs-xs);
  line-height: 1.4;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.incident-intelligence-card p span {
  color: var(--text-muted);
}

.incident-intelligence-reasons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-top: 0.5rem;
}

.incident-intelligence-reason {
  padding: 2px 5px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--primary) 9%, transparent);
  color: var(--text-secondary);
  font-size: 0.63rem;
}

.incident-intelligence-feedback {
  display: flex;
  gap: 0.35rem;
  margin-top: 0.55rem;
}

.incident-intelligence-feedback-btn {
  min-height: 24px;
  padding: 2px 7px;
  font-size: 0.63rem;
}

.incident-intelligence-feedback-btn.active {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.incident-intelligence-empty,
.incident-intelligence-loading {
  padding: 0.75rem;
  border: 1px dashed var(--border);
  border-radius: 7px;
  color: var(--text-muted);
  font-size: var(--fs-xs);
  text-align: center;
}

.incident-timeline-change-node {
  position: relative;
}

.incident-timeline-change-indicator {
  position: absolute;
  left: -2.1rem;
  top: 5px;
  display: flex;
  width: 1.25rem;
  height: 1.25rem;
  align-items: center;
  justify-content: center;
  border: 1px solid color-mix(in srgb, var(--primary) 45%, var(--border));
  border-radius: 50%;
  background: var(--bg-surface);
  box-shadow: 0 0 0 3px var(--bg-surface);
  font-size: var(--fs-xs);
}

.incident-timeline-change {
  padding: 0.65rem 0.85rem;
  border: 1px dashed color-mix(in srgb, var(--primary) 55%, var(--border));
  border-radius: 7px;
  background: color-mix(in srgb, var(--primary) 6%, var(--bg-surface));
}

.incident-timeline-change-head,
.incident-timeline-change-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}

.incident-timeline-change-head > div {
  display: flex;
  min-width: 0;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
  color: var(--text-main);
  font-size: var(--fs-sm);
}

.incident-timeline-change-badge {
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-size: 0.62rem;
  font-weight: 700;
}

.incident-timeline-offset {
  flex: 0 0 auto;
  padding: 2px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-base);
  color: var(--text-muted);
  font-size: var(--fs-xs);
  font-weight: 700;
}

.incident-timeline-change-version,
.incident-timeline-change-meta,
.incident-timeline-change-footer {
  margin-top: 0.35rem;
  color: var(--text-muted);
  font-size: var(--fs-xs);
}

.incident-timeline-change-version span {
  color: var(--text-secondary);
}

.incident-timeline-change-footer {
  flex-wrap: wrap;
}

.incident-timeline-change-footer a {
  color: var(--primary);
  font-weight: 700;
  text-decoration: none;
}

.incident-timeline-change-footer a:hover {
  text-decoration: underline;
}

.incident-detail {
  cursor: default;
}

.incident-command-summary {
  margin-bottom: 1rem;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-base);
}

.incident-command-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 0.9rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
}

.incident-command-meta,
.incident-command-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.incident-command-meta {
  min-width: 0;
  flex: 1 1 auto;
  color: var(--text-muted);
  font-size: 0.74rem;
}

.incident-command-meta strong {
  padding: 3px 7px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--primary) 12%, transparent);
  color: var(--primary);
}

.incident-command-actions {
  flex: 0 0 auto;
  justify-content: flex-end;
}

.incident-action-menu {
  margin-left: 0;
}

.incident-action-menu[open] {
  flex-basis: 100%;
}

.incident-action-menu .alert-secondary-actions {
  justify-content: flex-end;
}

.incident-command-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  padding: 0.85rem;
}

.incident-command-card {
  min-width: 0;
  padding: 0.8rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-surface);
}

.incident-command-label,
.incident-section-title {
  color: var(--text-muted);
  font-size: var(--fs-xs);
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.incident-command-body {
  display: -webkit-box;
  margin-top: 0.45rem;
  overflow: hidden;
  color: var(--text-main);
  font-size: var(--fs-sm);
  font-weight: 600;
  line-height: 1.45;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
}

.incident-command-body.is-muted {
  color: var(--text-muted);
  font-weight: 500;
}

.incident-command-card-meta {
  margin-top: 0.45rem;
  color: var(--text-muted);
  font-size: var(--fs-xs);
  line-height: 1.4;
}

.incident-service-profile {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0 0.9rem 0.85rem;
  color: var(--text-secondary);
  font-size: var(--fs-xs);
}

.incident-service-profile > strong {
  flex: 0 0 auto;
  color: var(--text-main);
}

.incident-service-profile > div {
  display: flex;
  min-width: 0;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.incident-service-profile > div > span,
.incident-service-health {
  padding: 2px 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-surface);
}

.incident-service-health.health-healthy {
  color: var(--success);
}

.incident-service-health.health-watch {
  color: var(--warning);
}

.incident-service-health.health-at_risk {
  color: var(--danger);
}

.incident-change-impact {
  margin-top: 0.55rem;
}

.incident-change-impact.is-compact {
  margin-top: 0.45rem;
}

.incident-change-impact-head,
.incident-change-impact-metrics {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.incident-impact-badge {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--bg-subtle);
  color: var(--text-muted);
  font-size: 0.63rem;
  font-weight: 800;
}

.incident-impact-badge.impact-high {
  background: color-mix(in srgb, var(--danger) 13%, transparent);
  color: var(--danger);
}

.incident-impact-badge.impact-medium {
  background: color-mix(in srgb, var(--warning) 16%, transparent);
  color: var(--warning);
}

.incident-impact-badge.impact-low {
  background: color-mix(in srgb, var(--success) 13%, transparent);
  color: var(--success);
}

.incident-change-impact-summary {
  min-width: 0;
  color: var(--text-secondary);
  font-size: var(--fs-xs);
  line-height: 1.4;
}

.incident-change-impact-metrics {
  margin-top: 0.35rem;
}

.incident-change-impact-metrics span {
  padding: 2px 5px;
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text-muted);
  font-size: 0.63rem;
}

.incident-runbook-start {
  margin-top: 0.55rem;
}

.incident-runbook-card-progress {
  margin-top: 0.55rem;
  color: var(--primary);
  font-size: var(--fs-xs);
  font-weight: 700;
}

.incident-runbook-section {
  margin-bottom: 1rem;
  padding: 0.9rem;
  border: 1px solid color-mix(in srgb, var(--primary) 32%, var(--border));
  border-radius: 9px;
  background: color-mix(in srgb, var(--primary) 4%, var(--bg-surface));
}

.incident-runbook-section > .incident-section-title {
  margin-bottom: 0.65rem;
  color: var(--primary);
}

.incident-runbook-execution {
  margin-top: 0.6rem;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-surface);
}

.incident-runbook-execution:first-of-type {
  margin-top: 0;
}

.incident-runbook-execution-head,
.incident-runbook-execution-head > div,
.incident-runbook-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.incident-runbook-execution-head {
  justify-content: space-between;
  color: var(--text-main);
  font-size: var(--fs-sm);
}

.incident-runbook-status {
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--bg-subtle);
  color: var(--text-muted);
  font-size: 0.63rem;
  font-weight: 800;
}

.incident-runbook-status.status-in_progress {
  background: color-mix(in srgb, var(--primary) 12%, transparent);
  color: var(--primary);
}

.incident-runbook-status.status-completed {
  background: color-mix(in srgb, var(--success) 13%, transparent);
  color: var(--success);
}

.incident-runbook-status.status-failed,
.incident-runbook-status.status-abandoned {
  background: color-mix(in srgb, var(--danger) 10%, transparent);
  color: var(--danger);
}

.incident-runbook-meta,
.incident-runbook-notes,
.incident-runbook-manual-note {
  color: var(--text-muted);
  font-size: 0.67rem;
}

.incident-runbook-meta {
  margin-top: 0.25rem;
}

.incident-runbook-progress {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-top: 0.55rem;
  color: var(--text-muted);
  font-size: var(--fs-xs);
}

.incident-runbook-progress-track {
  width: min(240px, 65%);
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--bg-subtle);
}

.incident-runbook-progress-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
}

.incident-runbook-steps {
  display: grid;
  gap: 0.4rem;
  margin-top: 0.65rem;
}

.incident-runbook-step {
  display: grid;
  grid-template-columns: 1.35rem minmax(0, 1fr);
  gap: 0.45rem;
  width: 100%;
  align-items: center;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-base);
  color: var(--text-secondary);
  cursor: pointer;
  text-align: left;
}

.incident-runbook-step > span {
  display: inline-flex;
  width: 1.2rem;
  height: 1.2rem;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--bg-surface);
  font-size: var(--fs-xs);
}

.incident-runbook-step > strong {
  min-width: 0;
  font-size: var(--fs-xs);
  overflow-wrap: anywhere;
}

.incident-runbook-step.is-complete {
  border-color: color-mix(in srgb, var(--success) 45%, var(--border));
  color: var(--text-muted);
}

.incident-runbook-step.is-complete > span {
  border-color: var(--success);
  background: var(--success);
  color: #fff;
}

.incident-runbook-step:disabled {
  cursor: default;
  opacity: 0.75;
}

.incident-runbook-notes {
  margin: 0.6rem 0 0;
  padding: 0.5rem;
  border-left: 2px solid var(--border);
  white-space: pre-wrap;
}

.incident-runbook-actions {
  margin-top: 0.65rem;
}

.incident-runbook-actions .btn.active {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.incident-runbook-manual-note {
  margin-left: auto;
}

.incident-supporting-details {
  margin-bottom: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-surface);
}

.incident-supporting-details > summary {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.7rem 0.85rem;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.76rem;
  font-weight: 700;
  list-style: none;
}

.incident-supporting-details > summary::-webkit-details-marker {
  display: none;
}

.incident-supporting-count {
  display: inline-flex;
  min-width: 1.25rem;
  height: 1.25rem;
  align-items: center;
  justify-content: center;
  padding: 0 0.3rem;
  border-radius: 999px;
  background: var(--bg-subtle);
  color: var(--text-muted);
  font-size: 0.63rem;
}

.incident-supporting-details > .incident-intelligence {
  margin: 0;
  border: 0;
  border-top: 1px solid var(--border);
  border-radius: 0;
}

.incident-notes > div {
  padding: 0 0.85rem 0.7rem;
}

.incident-note {
  padding: 0.45rem 0;
  border-top: 1px solid var(--border-light);
  color: var(--text-secondary);
  font-size: var(--fs-xs);
}

.incident-note span {
  color: var(--text-muted);
}

.incident-summary-state {
  margin-bottom: 1rem;
  padding: 0.55rem 0.7rem;
  border-radius: 6px;
  background: var(--bg-base);
  color: var(--text-muted);
  font-size: var(--fs-xs);
}

.incident-summary-state.is-warning {
  color: var(--warning);
}

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

@media (max-width: 760px) {
  .incident-command-bar {
    align-items: flex-start;
    flex-direction: column;
  }

  .incident-command-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .incident-command-grid {
    grid-template-columns: 1fr;
  }

  .incident-command-body {
    display: block;
    overflow: visible;
  }

  .incident-service-profile {
    flex-direction: column;
    gap: 0.4rem;
  }

  .incident-action-menu > summary {
    margin-left: 0;
  }

  .incident-runbook-manual-note {
    width: 100%;
    margin-left: 0;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   Response work queue, resolution capture, and onboarding
   ═══════════════════════════════════════════════════════════════════════════ */

.response-work-queue,
#routingViewIngress {
  padding: 20px 0;
}

.response-view-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.response-view-header p {
  margin: 0.25rem 0 0;
  color: var(--text-secondary);
  font-size: var(--fs-sm);
}

.response-header-actions,
.response-bucket-switch {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.response-actor-field {
  display: grid;
  gap: 0.35rem;
  width: min(16rem, 100%);
  color: var(--text-muted);
  font-size: var(--fs-xs);
  font-weight: 700;
}

.response-bucket-switch {
  margin-bottom: 1rem;
}

.response-bucket-btn.active {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.response-queue-summary,
.response-load-more {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
  color: var(--text-muted);
  font-size: var(--fs-xs);
}

.response-queue-summary em {
  color: var(--warning);
  font-style: normal;
}

.response-queue-list {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
}

.response-queue-row {
  display: grid;
  grid-template-columns:
    minmax(10rem, 1.25fr)
    minmax(9rem, 1fr)
    minmax(8rem, 0.8fr)
    minmax(8rem, 0.75fr)
    minmax(9.5rem, auto);
  gap: 0.8rem;
  align-items: center;
  min-height: 4.4rem;
  padding: 0.75rem 0.9rem;
  border-left: 3px solid transparent;
  border-bottom: 1px solid var(--border-light);
}

.response-queue-row:last-child {
  border-bottom: 0;
}

.response-queue-row.is-critical {
  border-left-color: var(--danger);
}

.response-queue-row.is-warning {
  border-left-color: var(--warning);
}

.response-queue-cell {
  display: grid;
  min-width: 0;
  gap: 0.2rem;
}

.response-queue-cell > span {
  color: var(--text-muted);
  font-size: 0.63rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.response-queue-cell > strong {
  min-width: 0;
  overflow: hidden;
  color: var(--text-main);
  font-size: var(--fs-sm);
  font-weight: 650;
  line-height: 1.4;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Countdown colour is earned by the clock, not worn permanently: neutral by
   default, amber inside the final 30 minutes, red once overdue. */
.response-queue-countdown > strong {
  color: var(--text-main);
  font-variant-numeric: tabular-nums;
}

.response-queue-countdown.is-soon > strong { color: var(--warning); }
.response-queue-countdown.is-overdue > strong { color: var(--danger); }

.bucket-count {
  display: inline-block;
  min-width: 1.4em;
  margin-left: 6px;
  padding: 0 0.35em;
  border-radius: 999px;
  background: var(--bg-subtle);
  color: var(--text-muted);
  font-size: var(--fs-xs);
  font-variant-numeric: tabular-nums;
}

.response-bucket-btn.active .bucket-count {
  /* The active pill is primary-filled; the count must not vanish into it. */
  background: rgba(255, 255, 255, 0.22);
  color: #ffffff;
}

.response-next-action {
  justify-self: end;
  white-space: nowrap;
}

.response-priority-explain {
  display: flex;
  grid-column: 1 / -1;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem;
  color: var(--text-muted);
  font-size: 0.63rem;
}

.response-priority-explain > span,
.response-priority-explain > small {
  padding: 0.16rem 0.35rem;
  border-radius: 999px;
  background: var(--bg-base);
}

.response-priority-explain > span {
  color: var(--primary);
  font-weight: 750;
}

.response-load-more {
  justify-content: center;
  margin: 0.8rem 0 0;
}

.response-empty {
  padding: 3rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  text-align: center;
}

.response-empty.is-error {
  color: var(--danger);
}

.knowledge-gap-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 0.9rem;
}

.knowledge-gap-card {
  display: grid;
  gap: 0.7rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  box-shadow: var(--shadow-sm);
}

.knowledge-gap-head,
.knowledge-gap-head > div,
.knowledge-gap-next {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.knowledge-gap-head {
  justify-content: space-between;
}

.knowledge-gap-head strong {
  overflow-wrap: anywhere;
  color: var(--text-main);
  font-size: var(--fs-md);
}

.knowledge-gap-count {
  flex: 0 0 auto;
  color: var(--text-muted);
  font-size: var(--fs-xs);
}

.knowledge-gap-score {
  color: var(--primary);
  font-size: var(--fs-xs);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.knowledge-gap-card p {
  margin: 0;
  color: var(--text-secondary);
  font-size: var(--fs-sm);
  line-height: 1.5;
}

.knowledge-gap-drills {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.knowledge-gap-form {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border-light);
}

/* Shared modal close: quiet in the corner, unmissable on hover. Every modal
   header carries one; ESC and the × leave through the same close routing. */
.modal-close {
  flex: 0 0 auto;
  margin-left: auto;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  cursor: pointer;
}

.modal-close:hover {
  background: var(--bg-subtle);
  color: var(--text-main);
}

/* Card head, two lines: the pattern title owns the full width (wraps at word
   boundaries; anywhere only rescues unbroken tokens), badges sit below. */
.knowledge-gap-title {
  font-weight: 700;
  color: var(--text-main);
  overflow-wrap: anywhere;
  line-height: 1.4;
  margin-bottom: 8px;
}

.knowledge-gap-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.knowledge-gap-meta .knowledge-gap-score { white-space: nowrap; }
.knowledge-gap-meta .knowledge-gap-count { margin-left: auto; white-space: nowrap; }

.knowledge-gap-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.knowledge-gap-tags span {
  padding: 0.2rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--bg-base);
  color: var(--text-muted);
  font-size: var(--fs-xs);
}

.knowledge-gap-next {
  justify-content: space-between;
  padding-top: 0.65rem;
  border-top: 1px solid var(--border-light);
  color: var(--text-muted);
  font-size: var(--fs-xs);
}

/* Advisory text, not a control: accent blue here read as a link that went
   nowhere (the drills below are the card's real exits). */
.knowledge-gap-next strong {
  color: var(--text-main);
  text-align: right;
}

.incident-recurrence-badge {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  padding: 0.16rem 0.42rem;
  border: 1px solid color-mix(in srgb, var(--warning) 35%, var(--border));
  border-radius: 999px;
  background: color-mix(in srgb, var(--warning) 10%, transparent);
  color: var(--warning);
  font-size: 0.63rem;
  font-weight: 800;
  white-space: nowrap;
}

.incident-recurrence-badge.status-confirmed {
  border-color: color-mix(in srgb, var(--danger) 35%, var(--border));
  background: color-mix(in srgb, var(--danger) 9%, transparent);
  color: var(--danger);
}

.incident-recurrence-badge.status-dismissed {
  border-color: var(--border);
  background: var(--bg-subtle);
  color: var(--text-muted);
}

.incident-recurrence-review {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  margin: 0.75rem 0;
  padding: 0.65rem 0.75rem;
  border: 1px solid color-mix(in srgb, var(--warning) 30%, var(--border));
  border-radius: 8px;
  background: color-mix(in srgb, var(--warning) 5%, var(--bg-surface));
}

.incident-recurrence-copy,
.incident-recurrence-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.incident-recurrence-copy > div {
  display: grid;
  gap: 0.15rem;
}

.incident-recurrence-copy strong {
  color: var(--text-main);
  font-size: 0.76rem;
}

.incident-recurrence-copy span,
.incident-recurrence-reviewed {
  color: var(--text-muted);
  font-size: 0.67rem;
}

.incident-intelligence-calibration {
  position: relative;
  flex: 0 0 auto;
}

.incident-intelligence-calibration > summary {
  cursor: pointer;
  list-style: none;
}

.incident-intelligence-calibration > summary::-webkit-details-marker {
  display: none;
}

.incident-intelligence-calibration[open] {
  flex-basis: 100%;
}

.incident-intelligence-calibration p {
  margin: 0.35rem 0 0;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-base);
  color: var(--text-muted);
  font-size: var(--fs-xs);
  font-weight: 500;
  line-height: 1.45;
}

.incident-intelligence-feedback-state {
  display: inline-flex;
  margin-top: 0.45rem;
  color: var(--success);
  font-size: var(--fs-xs);
  font-weight: 700;
}

.incident-intelligence-feedback {
  display: block;
  margin-top: 0.45rem;
}

.incident-intelligence-feedback > summary {
  width: max-content;
  cursor: pointer;
  color: var(--primary);
  font-size: var(--fs-xs);
  font-weight: 700;
  list-style: none;
}

.incident-intelligence-feedback > summary::-webkit-details-marker {
  display: none;
}

.incident-intelligence-feedback > div {
  display: flex;
  gap: 0.35rem;
  margin-top: 0.35rem;
}

.incident-intelligence-feedback .btn {
  min-height: 24px;
  padding: 2px 7px;
  font-size: 0.63rem;
}

.incident-intelligence-feedback .btn.active {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.incident-resolution-modal {
  width: min(760px, calc(100vw - 2rem));
  max-height: min(90vh, 900px);
}

.modal-subtitle {
  margin: 0.25rem 0 0;
  color: var(--text-muted);
  font-size: 0.76rem;
}

.resolution-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
}

.resolution-progress {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 1rem;
}

.resolution-progress > div {
  flex: 1;
  height: 0.4rem;
  overflow: hidden;
  border-radius: 999px;
  background: var(--bg-subtle);
}

.resolution-progress > div > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
}

.resolution-progress > strong {
  flex: 0 0 auto;
  color: var(--text-muted);
  font-size: var(--fs-xs);
}

.resolution-optional-note {
  margin: 0.8rem 0 0;
  color: var(--text-muted);
  font-size: var(--fs-xs);
  line-height: 1.5;
}

.resolution-feedback {
  margin-top: 0.8rem;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.resolution-feedback > summary {
  padding: 0.7rem 0.8rem;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.76rem;
  font-weight: 700;
}

.resolution-feedback > div {
  padding: 0 0.8rem 0.8rem;
}

.resolution-feedback p {
  margin: 0;
  color: var(--text-muted);
  font-size: var(--fs-xs);
}

.form-error {
  min-height: 1.1rem;
  margin-top: 0.5rem;
  color: var(--danger);
  font-size: var(--fs-xs);
}

.form-error.is-success {
  color: var(--success);
}

.ingress-stepper {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0;
  margin: 0 0 1.25rem;
  padding: 0;
  list-style: none;
}

.ingress-stepper li {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 0.35rem;
  color: var(--text-muted);
  text-align: center;
}

.ingress-stepper li::before {
  position: absolute;
  z-index: 0;
  top: 0.8rem;
  right: 50%;
  width: 100%;
  height: 2px;
  background: var(--border);
  content: "";
}

.ingress-stepper li:first-child::before {
  display: none;
}

.ingress-stepper li > span {
  z-index: 1;
  display: inline-flex;
  width: 1.7rem;
  height: 1.7rem;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--border);
  border-radius: 50%;
  background: var(--bg-surface);
  font-size: var(--fs-xs);
  font-weight: 800;
}

.ingress-stepper li > strong {
  font-size: var(--fs-xs);
}

.ingress-stepper li.is-current,
.ingress-stepper li.is-complete {
  color: var(--primary);
}

.ingress-stepper li.is-current > span,
.ingress-stepper li.is-complete > span {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.ingress-stepper li.is-complete::before,
.ingress-stepper li.is-current::before {
  background: var(--primary);
}

.ingress-wizard-body {
  max-width: 860px;
  margin: 0 auto;
}

.ingress-step-card {
  padding: 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  box-shadow: var(--shadow-sm);
}

.ingress-step-heading {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.ingress-step-heading > span {
  display: inline-flex;
  width: 1.8rem;
  height: 1.8rem;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: var(--fs-xs);
  font-weight: 800;
}

.ingress-step-heading h3 {
  margin: 0;
  color: var(--text-main);
  font-size: var(--fs-lg);
}

.ingress-step-heading p {
  margin: 0.25rem 0 0;
  color: var(--text-secondary);
  font-size: var(--fs-sm);
  line-height: 1.5;
}

.ingress-source-types {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.ingress-source-type {
  display: grid;
  gap: 0.3rem;
  min-height: 5rem;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-base);
  color: var(--text-main);
  cursor: pointer;
  text-align: left;
}

.ingress-source-type:hover,
.ingress-source-type.is-selected {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 7%, var(--bg-surface));
}

.ingress-source-type strong {
  font-size: var(--fs-sm);
}

.ingress-source-type span {
  color: var(--text-muted);
  font-size: var(--fs-xs);
  line-height: 1.4;
}

.ingress-step-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1rem;
}

.ingress-existing {
  margin-top: 1rem;
  border-top: 1px solid var(--border-light);
}

.ingress-existing > summary {
  padding: 0.8rem 0 0;
  color: var(--text-muted);
  cursor: pointer;
  font-size: var(--fs-xs);
  font-weight: 700;
}

.ingress-existing > div {
  display: grid;
  gap: 0.4rem;
  margin-top: 0.6rem;
}

.ingress-existing button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--bg-base);
  color: var(--text-main);
  cursor: pointer;
  text-align: left;
}

.ingress-existing button span:first-child {
  display: grid;
  gap: 0.15rem;
}

.ingress-existing small {
  color: var(--text-muted);
}

.ingress-copy-field {
  display: grid;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
}

.ingress-copy-field > span {
  color: var(--text-muted);
  font-size: var(--fs-xs);
  font-weight: 700;
}

.ingress-copy-field > div {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--bg-base);
}

.ingress-copy-field code {
  min-width: 0;
  flex: 1;
  overflow-wrap: anywhere;
  color: var(--text-main);
  font-size: var(--fs-xs);
}

.ingress-copy-field.is-sensitive > div {
  border-color: color-mix(in srgb, var(--warning) 35%, var(--border));
}

.ingress-token-warning,
.ingress-test-result {
  margin-bottom: 0.8rem;
  padding: 0.65rem 0.75rem;
  border-radius: 7px;
  background: color-mix(in srgb, var(--warning) 10%, var(--bg-surface));
  color: var(--warning);
  font-size: var(--fs-xs);
  line-height: 1.5;
}

.ingress-test-result.is-success {
  margin-top: 0.75rem;
  margin-bottom: 0;
  background: color-mix(in srgb, var(--success) 10%, var(--bg-surface));
  color: var(--success);
}

.ingress-config-block {
  position: relative;
}

.ingress-config-block pre {
  max-height: 18rem;
  margin: 0;
  overflow: auto;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--code-bg);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.ingress-config-block code {
  color: var(--text-main);
  font-size: var(--fs-xs);
  line-height: 1.6;
}

.ingress-config-block .btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
}

.ingress-payload {
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: var(--fs-xs);
}

.ingress-connection-state {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 1rem;
  border: 1px dashed var(--border);
  border-radius: 8px;
  background: var(--bg-base);
}

.ingress-connection-state > span {
  display: inline-flex;
  width: 1.8rem;
  height: 1.8rem;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--border);
  border-radius: 50%;
  color: #fff;
}

.ingress-connection-state.is-connected {
  border-style: solid;
  border-color: color-mix(in srgb, var(--success) 40%, var(--border));
}

.ingress-connection-state.is-connected > span {
  border-color: var(--success);
  background: var(--success);
}

.ingress-connection-state > div {
  display: grid;
  gap: 0.2rem;
}

.ingress-connection-state strong {
  color: var(--text-main);
  font-size: var(--fs-sm);
}

.ingress-connection-state small {
  color: var(--text-muted);
  overflow-wrap: anywhere;
}

.ingress-status {
  min-height: 1.2rem;
  margin-top: 0.6rem;
  color: var(--text-muted);
  font-size: var(--fs-xs);
  text-align: center;
}

.ingress-status.is-error {
  color: var(--danger);
}

.ingress-status.is-success {
  color: var(--success);
}

.ingress-connection-management {
  margin-top: 1rem;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-base);
}

.ingress-connection-management > summary {
  cursor: pointer;
  color: var(--text-main);
  font-size: var(--fs-xs);
  font-weight: 750;
}

.ingress-connection-management p {
  margin: 0.55rem 0 0;
  color: var(--text-muted);
  font-size: var(--fs-xs);
  line-height: 1.5;
}

.ingress-revoke-btn {
  border-color: color-mix(in srgb, var(--danger) 45%, var(--border));
  color: var(--danger);
}

@media (max-width: 900px) {
  .response-queue-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .response-next-action {
    grid-column: 1 / -1;
    width: 100%;
    justify-self: stretch;
  }
}

@media (max-width: 640px) {
  .response-view-header {
    flex-direction: column;
  }

  .response-actor-field,
  .response-header-actions {
    width: 100%;
  }

  .response-header-actions .filter-input {
    flex: 1;
  }

  .response-bucket-switch {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .response-bucket-switch .btn {
    width: 100%;
  }

  .response-queue-row {
    grid-template-columns: 1fr;
    gap: 0.55rem;
  }

  .response-queue-cell {
    grid-template-columns: 6.5rem minmax(0, 1fr);
    align-items: baseline;
  }

  .response-queue-cell > strong {
    white-space: normal;
  }

  .knowledge-gap-list,
  .resolution-form-grid {
    grid-template-columns: 1fr;
  }

  .incident-recurrence-review {
    align-items: flex-start;
    flex-direction: column;
  }

  .incident-recurrence-actions {
    width: 100%;
  }

  .incident-recurrence-actions .btn {
    flex: 1;
  }

  .incident-resolution-modal {
    width: calc(100vw - 1rem);
  }

  .ingress-stepper {
    display: flex;
    overflow-x: auto;
    justify-content: flex-start;
    padding-bottom: 0.5rem;
  }

  .ingress-stepper li {
    min-width: 5.5rem;
  }

  .ingress-stepper li::before {
    display: none;
  }

  .ingress-step-card {
    padding: 0.9rem;
  }

  .ingress-source-types {
    grid-template-columns: 1fr;
  }

  .ingress-copy-field > div {
    align-items: stretch;
    flex-direction: column;
  }

  .ingress-copy-field .btn,
  .ingress-step-actions .btn {
    width: 100%;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   Command palette — the navigation surface
   ═══════════════════════════════════════════════════════════════════════════ */

.command-palette {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: none;
  /* Aligned to the upper third, not centred: the eye is already near the top
     bar where the trigger lives, and a centred panel jumps the focal point. */
  align-items: flex-start;
  justify-content: center;
  padding-top: 12vh;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(2px);
}

.command-palette.is-open { display: flex; }

.palette-panel {
  width: min(620px, calc(100vw - 32px));
  max-height: 68vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.palette-input-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}

.palette-input-row .palette-prompt { color: var(--text-muted); font-size: 0.95rem; }

#paletteInput {
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 0.95rem;
}

#paletteInput::placeholder { color: var(--text-muted); }

.palette-list { overflow-y: auto; padding: 6px; }

.palette-group {
  padding: 10px 10px 4px;
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.palette-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-main);
  font-family: inherit;
  font-size: var(--fs-md);
  text-align: left;
  cursor: pointer;
}

/* Keyboard selection and hover share one state: the highlighted row is
   always the row Enter will open, whichever input moved it there. */
.palette-item:hover,
.palette-item.is-active { background: var(--primary-bg); }

.palette-icon { width: 1.25rem; text-align: center; flex-shrink: 0; }
.palette-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.palette-slug {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--text-muted);
  flex-shrink: 0;
}

.palette-item.is-active .palette-slug { color: var(--primary); }

.palette-empty { padding: 28px 12px; text-align: center; color: var(--text-muted); font-size: var(--fs-md); }

.palette-footer {
  display: flex;
  gap: 14px;
  padding: 8px 14px;
  border-top: 1px solid var(--border);
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

.palette-footer kbd {
  font-family: var(--font-mono);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 5px;
  margin-right: 4px;
}

/* The trigger. Looks like a search field because that is the affordance
   people already understand, and it is the only entry point without a
   keyboard — so it must never collapse to an icon on touch. */
.palette-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 220px;
  padding: 5px 10px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-family: inherit;
  font-size: var(--fs-sm);
  cursor: pointer;
}

.palette-trigger:hover { border-color: var(--primary); color: var(--text-secondary); }
.palette-trigger .trigger-hint { margin-left: auto; font-family: var(--font-mono); font-size: var(--fs-xs); }

@media (max-width: 640px) {
  .palette-trigger { min-width: 0; }
  .palette-trigger .trigger-label,
  .palette-trigger .trigger-hint { display: none; }
}

/* Breadcrumb — replaces the tab highlight as the "where am I" signal.
   The divider is what keeps it from reading as part of the logo string
   ("Webhook 监控概览 / 总览" was one visual word without it). */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-right: auto;
  margin-left: 1.1rem;
  padding-left: 1.1rem;
  border-left: 1px solid var(--border);
  height: 24px;
  font-size: var(--fs-sm);
  min-width: 0;
}

.breadcrumb:empty { border-left: none; }

.crumb-area { color: var(--text-muted); }
.crumb-sep { color: var(--border); }
.crumb-leaf { color: var(--text-main); font-weight: 600; }

/* Inbox badge: the one count worth interrupting the minimal bar for, so it
   is a button rather than the decoration it used to be. */
.inbox-badge {
  background: var(--danger);
  color: #fff;
  border-radius: 999px;
  padding: 1px 7px;
  font-size: var(--fs-xs);
  font-weight: 700;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
}
.inbox-badge:hover { filter: brightness(1.1); }

/* ═══════════════════════════════════════════════════════════════════════════
   Sidebar — the persistent left rail (industry-standard shell)
   ═══════════════════════════════════════════════════════════════════════════ */

:root { --sidebar-width: 224px; --sidebar-collapsed-width: 56px; --navbar-height: 64px; }

.sidebar {
  position: fixed;
  top: var(--navbar-height);
  bottom: 0;
  left: 0;
  width: var(--sidebar-width);
  overflow-y: auto;
  padding: 10px 8px 8px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 2px;
  z-index: 100;
  transition: width 0.15s ease, transform 0.2s ease;
}

/* When the rail outgrows the viewport (e.g. the More tier expanded), it must
   SCROLL — flex children default to shrink, which crushed the group labels
   into clipped slivers before overflow-y ever engaged. */
.sidebar > * { flex-shrink: 0; }

/* Content shifts with the rail; nothing overlaps. */
.container { margin-left: var(--sidebar-width); transition: margin-left 0.15s ease; }
body.sidebar-collapsed .container { margin-left: var(--sidebar-collapsed-width); }
body.sidebar-collapsed .sidebar { width: var(--sidebar-collapsed-width); }

.sidebar-group {
  padding: 12px 10px 4px;
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
}

/* Rarely-used tier: one fold at the end of the rail. The summary row reads
   like an item, the marker rotates, and the folded items are plain items. */
.sidebar-lowfreq { margin-top: 8px; border-top: 1px solid var(--border); padding-top: 6px; }
.sidebar-lowfreq-summary { list-style: none; cursor: pointer; color: var(--text-muted); }
.sidebar-lowfreq-summary::-webkit-details-marker { display: none; }
.sidebar-lowfreq-summary .sidebar-icon { transform: rotate(-90deg); transition: transform 0.15s ease; }
.sidebar-lowfreq[open] .sidebar-lowfreq-summary .sidebar-icon { transform: rotate(0deg); }

.sidebar-item,
.sidebar-collapse {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 7px 10px;
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: var(--fs-sm);
  text-align: left;
  cursor: pointer;
  white-space: nowrap;
}

.sidebar-item:hover { background: var(--bg-subtle); color: var(--text-main); }

/* Active = the one place saying "you are here"; keep it unmistakable. */
.sidebar-item.is-active {
  background: var(--primary-bg);
  color: var(--text-main);
  box-shadow: inset 2px 0 0 var(--primary);
}

.sidebar-icon { width: 1.3rem; text-align: center; flex-shrink: 0; }
.sidebar-label { overflow: hidden; text-overflow: ellipsis; }

.sidebar-badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  border-radius: 999px;
  padding: 0 6px;
  font-size: var(--fs-xs);
  font-weight: 700;
  line-height: 16px;
  font-variant-numeric: tabular-nums;
}

.sidebar-collapse { margin-top: auto; color: var(--text-muted); }
.sidebar-collapse:hover { color: var(--text-main); background: var(--bg-subtle); }

/* Collapsed: icons only. Labels and group headers vanish; the title attribute
   (set at render time) becomes the tooltip, which is the Grafana convention. */
body.sidebar-collapsed .sidebar-label,
body.sidebar-collapsed .sidebar-group,
body.sidebar-collapsed .sidebar-badge { display: none; }
body.sidebar-collapsed .sidebar-item,
body.sidebar-collapsed .sidebar-collapse { justify-content: center; padding: 9px 0; }
body.sidebar-collapsed .sidebar-collapse .sidebar-icon { transform: rotate(180deg); }

.sidebar-scrim { display: none; }
.sidebar-toggle-mobile { display: none; }

/* Mobile: off-canvas drawer over a scrim; the hamburger is the way in. */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  body.sidebar-open .sidebar { transform: translateX(0); width: var(--sidebar-width); }
  body.sidebar-open .sidebar-scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 99;
    background: rgba(0, 0, 0, 0.5);
  }
  .container { margin-left: 0 !important; }
  .sidebar-toggle-mobile { display: inline-flex; }
  /* Collapsed mode is a desktop concept; the drawer always shows labels. */
  body.sidebar-collapsed .sidebar-label,
  body.sidebar-collapsed .sidebar-group { display: block; }
  body.sidebar-collapsed .sidebar-badge { display: inline-block; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   Icons — one visual voice
   ═══════════════════════════════════════════════════════════════════════════ */

.icon {
  width: 1em;
  height: 1em;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  vertical-align: -0.125em;
  flex-shrink: 0;
}

.icon-sm { width: 0.85em; height: 0.85em; }
.icon-lg { width: 1.25em; height: 1.25em; }

/* Severity is carried by colour on a uniform glyph — the discipline emoji
   made impossible, since every emoji shipped its own palette. */
.icon-danger { color: var(--danger); }
.icon-warning { color: var(--warning); }
.icon-success { color: var(--success); }
.icon-muted { color: var(--text-muted); }

/* ═══════════════════════════════════════════════════════════════════════════
   Scales — 5 type sizes, a 4px spacing grid
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
  /* Type. Each step has ONE job; a size outside these is a design bug.
     xs  = badges, eyebrows, table meta
     sm  = secondary text, dense table cells
     md  = body (the default)
     lg  = panel titles
     num = the big stat figures */
  --fs-xs: 0.72rem;
  --fs-sm: 0.8125rem;
  --fs-md: 0.875rem;
  --fs-lg: 1rem;
  --fs-num: 1.75rem;

  /* Space: 4px grid. */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Semantic classes for the patterns the JS renderers repeated inline
   ═══════════════════════════════════════════════════════════════════════════ */

/* Empty and error states: the two most-duplicated inline blocks. */
.ww-empty {
  text-align: center;
  padding: var(--sp-6) var(--sp-4);
  color: var(--text-secondary);
  font-size: var(--fs-md);
}

.ww-error {
  text-align: center;
  padding: var(--sp-6) var(--sp-4);
  color: var(--danger);
  font-size: var(--fs-md);
}

/* Eyebrow: the small uppercase section label. */
.ww-eyebrow {
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: var(--sp-3);
}

/* Meta line: icon-and-fragment rows under a title. */
.ww-meta {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-wrap: wrap;
  font-size: var(--fs-sm);
  color: var(--text-secondary);
}

.ww-muted { color: var(--text-muted); }
.ww-mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* Stat figure — the number IS the content; the label defers to it. */
.ww-num { font-size: var(--fs-num); font-weight: 650; font-variant-numeric: tabular-nums; }

/* ═══════════════════════════════════════════════════════════════════════════
   De-carding — boxes earn their borders
   ═══════════════════════════════════════════════════════════════════════════ */

/* Cards sit IN the page: border only. Shadow is reserved for layers that
   genuinely float (palette, modals, drawer) — when everything casts a
   shadow, nothing reads as elevated. */
.card, .stat-card, .action-center-item, .incident-intelligence-card {
  box-shadow: none;
}

/* A card nested in a card dissolves into a divided region. */
.card .card {
  border: 0;
  border-top: 1px solid var(--border-light);
  border-radius: 0;
  background: transparent;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Details — focus, motion
   ═══════════════════════════════════════════════════════════════════════════ */

/* One focus treatment everywhere. :focus-visible only: mouse clicks don't
   flash rings, keyboard users always get one. */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* One motion voice: quick and quiet. Anything slower reads as decoration. */
.btn, .sidebar-item, .palette-item, .nav-tab, .stat-card, .alert-item,
.badge, .card, a { transition-duration: 0.15s; }

/* Severity dot: one glyph, tokens decide the colour. */
.ww-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  vertical-align: middle;
}
.ww-dot-danger { color: var(--danger); }
.ww-dot-warning { color: var(--warning); }
.ww-dot-success { color: var(--success); }
.ww-dot-muted { color: var(--text-muted); }

/* Trace row: what the alert actually was. The id link stays compact; this
   carries the AI one-liner (or the rule name) and yields space gracefully. */
.da-alert-what {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--fs-sm);
  color: var(--text-secondary);
}

/* ═══════════════════════════════════════════════════════════════════════════
   Restraint pass — colour moves from surfaces to points
   ═══════════════════════════════════════════════════════════════════════════

   Filled chips on every row made the console read as a mosaic. The cold
   treatment: badge surfaces go neutral (transparent + hairline border,
   secondary text); the STATUS lives in one small point of colour — the
   badge's icon when it has one, a 6px dot when it doesn't. Severity stays
   scannable, at a fraction of the ink. */

.badge-high, .badge-medium, .badge-low, .badge-success, .badge-danger,
.badge-warning, .badge-info, .badge-duplicate {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.badge-high .icon { color: var(--danger); }
.badge-medium .icon { color: var(--warning); }
.badge-low .icon, .badge-success .icon { color: var(--success); }
.badge-danger .icon { color: var(--danger); }
.badge-warning .icon { color: var(--warning); }
.badge-info .icon, .badge-duplicate .icon { color: var(--info); }

.badge-high::before, .badge-medium::before, .badge-low::before,
.badge-success::before, .badge-danger::before, .badge-warning::before,
.badge-info::before, .badge-duplicate::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-right: 5px;
  vertical-align: middle;
  background: currentColor;
}

.badge-high::before { background: var(--danger); }
.badge-medium::before { background: var(--warning); }
.badge-low::before, .badge-success::before { background: var(--success); }
.badge-danger::before { background: var(--danger); }
.badge-warning::before { background: var(--warning); }
.badge-info::before, .badge-duplicate::before { background: var(--info); }

/* An icon already carries the point of colour; don't double-mark. */
.badge-high:has(.icon)::before, .badge-medium:has(.icon)::before,
.badge-low:has(.icon)::before, .badge-success:has(.icon)::before,
.badge-danger:has(.icon)::before, .badge-warning:has(.icon)::before,
.badge-info:has(.icon)::before, .badge-duplicate:has(.icon)::before {
  display: none;
}

/* Sidebar active: a permanently-visible element must not be a colour block.
   Neutral fill, hairline accent, stronger text. */
.sidebar-item.is-active {
  background: var(--bg-subtle);
  color: var(--text-main);
  box-shadow: inset 2px 0 0 var(--primary);
}

.icon-primary { color: var(--primary); }

/* ═══════════════════════════════════════════════════════════════════════════
   Affordance — restrained is not invisible
   ═══════════════════════════════════════════════════════════════════════════

   The restraint pass stripped colour from surfaces and took clickability
   cues with it. Interactive things must read as interactive BEFORE hover:
   buttons keep a visible border and brighten decisively; clickable stat
   cards carry a corner mark and answer hover with an accent border. */

.btn {
  border: 1px solid var(--border);
}

.btn:hover {
  border-color: var(--text-muted);
  background: var(--bg-subtle);
  color: var(--text-main);
}

.btn:active { transform: translateY(1px); }

/* The Open-details destination tag: the jump says where it goes. */
.btn-dest {
  color: var(--primary);
  font-size: var(--fs-xs);
}

/* Clickable summary cards: a quiet corner mark all the time, an unmistakable
   answer on hover. Non-clickable cards do neither. */
.stat-card[onclick] { position: relative; }

.stat-card[onclick]::after {
  content: '↗';
  position: absolute;
  top: 8px;
  right: 10px;
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

.stat-card[onclick]:hover {
  border-color: var(--primary);
}

.stat-card[onclick]:hover::after { color: var(--primary); }

/* Action items: the whole card acknowledges pointer presence so the buttons
   inside are discovered, without making the card itself pretend clickable. */
.action-center-item:hover { border-color: var(--text-muted); }

/* Bulk-selection bar: sticky context for a checked set. */
.alerts-bulk-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  margin-bottom: 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius-md);
}

.alerts-bulk-bar .bulk-count { font-weight: 600; margin-right: 4px; }

.alert-bulk-check {
  width: 15px;
  height: 15px;
  accent-color: var(--primary);
  flex: 0 0 auto;
  cursor: pointer;
}


/* Toggle buttons must LOOK toggled. `.is-active` was set on these by the JS
   for months while only .palette-item and .sidebar-item had rules for it, so
   the class changed nothing you could see and the only signal of state was a
   tooltip you had to hover for. */
.btn.is-active {
  /* Colour lives in points, not surfaces (design-language.md #3). The first
     version gave this a background, a border AND a text colour at once, which
     in a row of quiet icon buttons reads as a shout. The glyph alone carries
     the state — one point of colour, the same way status badges do it. */
  color: var(--primary);
}
.btn.is-active .icon { color: var(--primary); }

/* These two carry a short state word beside the glyph. Small and quiet — the
   point is that the state is legible at rest, not that it shouts. */
#autoRefreshText,
#notifyToggleText {
  font-size: 11px;
  margin-left: 0.3rem;
  letter-spacing: 0.01em;
}


/* A badge that is also a control. Without this the <button> arrives with the
   browser's own border, background and font, so the one clickable badge on the
   card looked unlike every badge beside it — which is the opposite of the
   point: it should read as the same object, only actionable. */
.badge-action {
  border: 1px dashed transparent;
  background-clip: padding-box;
  cursor: pointer;
  font: inherit;
  font-size: var(--fs-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  transition: border-color 0.15s ease;
}
.badge-action:hover,
.badge-action:focus-visible {
  /* The affordance appears on approach rather than shouting all the time:
     a dashed edge says "editable" without competing with the severity colour. */
  border-color: currentColor;
}
.badge-action:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }

/* ===== Operator guide (#/guide) ===== */

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

.guide-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  padding: 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.guide-card-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.guide-step {
  flex: none;
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 50%;
  background: var(--accent-bg);
  color: var(--accent);
  font-weight: 700;
  font-size: var(--fs-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.guide-card-title {
  margin: 0;
  font-size: var(--fs-md);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.guide-card-desc {
  margin: 0;
  color: var(--text-secondary);
  font-size: var(--fs-sm);
  line-height: 1.55;
  flex: 1;
}

.guide-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.guide-card .code-block { margin: 0; }

/* ===== Runtime settings table (#/settings) =====
   Three columns on purpose: a long env default (keyword CSVs) once blew a
   six-column table past the viewport and hid the edit button entirely. */

.rs-toolbar { margin-bottom: 0.75rem; max-width: 380px; }

.rs-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  overflow: hidden;
}

.rs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
  table-layout: fixed;
}

.rs-table th {
  padding: 0.5rem 1rem;
  font-weight: 600;
  color: var(--text-muted);
  text-align: left;
}

.rs-table th:first-child { width: 38%; }
.rs-table th:last-child { width: 110px; }

.rs-cell {
  padding: 0.55rem 1rem;
  border-top: 1px solid var(--border);
  vertical-align: top;
}

.rs-group td {
  padding: 0.4rem 1rem;
  border-top: 1px solid var(--border);
  background: var(--bg-subtle);
  font-weight: 700;
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

.rs-key {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rs-desc {
  color: var(--text-secondary);
  font-size: var(--fs-xs);
  line-height: 1.45;
  margin-top: 2px;
}

.rs-value {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  overflow-wrap: anywhere;
  line-height: 1.5;
}

.rs-meta {
  color: var(--text-muted);
  font-size: var(--fs-xs);
  margin-top: 3px;
  display: flex;
  flex-wrap: wrap;
  gap: 0 6px;
  align-items: center;
}

.rs-badge { font-size: 0.65rem; }

.rs-error {
  color: var(--danger);
  font-size: var(--fs-xs);
  margin-top: 4px;
  overflow-wrap: anywhere;
}

.rs-row-override { background: var(--warning-bg); }

.rs-actions { text-align: right; white-space: nowrap; }

/* ===== Shared data table (noise sources, rule audit) =====
   Was a ghost class: with no definition the browser centered every <th>
   over left-aligned cells. Numeric columns opt into .num for right-align. */

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
}

.data-table th {
  padding: 0.5rem 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-align: left;
}

.data-table td {
  padding: 0.5rem 0.75rem;
  border-top: 1px solid var(--border);
  vertical-align: top;
}

.data-table th.num,
.data-table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
