:root {
  --bg: #f4f2ec;
  --ink: #1c1c1c;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --success: #16a34a;
  --warn: #d97706;
  --danger: #dc2626;
  --muted: #6b7280;
  --border: rgba(0,0,0,0.08);
  --card: rgba(255,255,255,0.7);
  --radius: 8px;
  /* entity type colors */
  --c-malware: #ef4444;
  --c-threat_actor: #f97316;
  --c-attack_pattern: #a855f7;
  --c-tool: #3b82f6;
  --c-vulnerability: #eab308;
  --c-campaign: #ec4899;
  --c-indicator: #14b8a6;
  --c-infrastructure: #6366f1;
  --c-mitigation: #22c55e;
  --c-report: #64748b;
  --c-identity: #0ea5e9;
  --c-unknown: #9ca3af;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: radial-gradient(ellipse at top left, #fff 0%, #f4f2ec 55%, #efe8dc 100%);
  color: var(--ink);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ── header ───────────────────────────────── */
header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(8px);
  z-index: 100;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.brand-mark-wrap {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: 0 2px 8px rgba(0,0,0,0.14);
  background: #0b0b0b;
  flex-shrink: 0;
}
.brand-mark {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  transform: scale(1.45);
  transform-origin: center;
}
header h1 { font-size: 18px; font-weight: 700; letter-spacing: -0.01em; white-space: nowrap; }
header .spacer { flex: 1; }

/* ── ingestion progress bar ───────────────── */
.ingest-bar {
  background: #1e293b;
  border-bottom: 1px solid #334155;
  padding: 0;
  overflow: hidden;
  transition: max-height 0.3s;
  max-height: 36px;
}
.ingest-bar.hidden { max-height: 0; padding: 0; border: none; }
.ingest-bar-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 24px;
  font-size: 11px;
  font-family: monospace;
  color: #94a3b8;
}
.ingest-counts { white-space: nowrap; }
.ingest-counts .val { color: #e2e8f0; font-weight: 600; }
.ingest-track {
  flex: 1;
  height: 6px;
  background: #334155;
  border-radius: 3px;
  overflow: hidden;
  min-width: 80px;
}
.ingest-fill {
  height: 100%;
  background: linear-gradient(90deg, #2563eb, #22c55e);
  border-radius: 3px;
  transition: width 0.6s ease;
  width: 0%;
}
.ingest-rate { white-space: nowrap; color: #64748b; }
.ingest-rate .active { color: #22c55e; }

/* ── tabs ─────────────────────────────────── */
.tab-bar {
  display: flex;
  gap: 2px;
  background: rgba(0,0,0,0.04);
  border-radius: 6px;
  padding: 3px;
}
.tab-btn {
  padding: 6px 16px;
  border: none;
  background: none;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border-radius: 4px;
  color: var(--muted);
  transition: all 0.15s;
}
.tab-btn.active {
  background: white;
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

/* ── layout ───────────────────────────────── */
main { display: flex; flex: 1; overflow: hidden; }
.sidebar {
  width: 360px;
  min-width: 300px;
  border-right: 1px solid var(--border);
  background: rgba(255,255,255,0.55);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.sidebar-section {
  padding: 16px;
  border-bottom: 1px solid var(--border);
}
.graph-area { flex: 1; position: relative; overflow: hidden; }

/* ── search input ─────────────────────────── */
.search-wrap { position: relative; }
.search-wrap svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px; height: 16px;
  color: var(--muted);
  pointer-events: none;
}
#searchInput {
  width: 100%;
  padding: 10px 12px 10px 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  outline: none;
  transition: border 0.15s;
  background: white;
}
#searchInput:focus { border-color: var(--accent); }

/* ── controls row ─────────────────────────── */
.controls { display: flex; gap: 8px; margin-top: 10px; }
.temporal-controls { margin-top: 8px; }
.ctrl-group { flex: 1; }
.ctrl-group label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 3px;
}
.ctrl-group label.label-help {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.help-dot {
  position: relative;
  width: 16px;
  height: 16px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: white;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  cursor: help;
  padding: 0;
}
.help-dot::after {
  content: attr(data-tip);
  position: absolute;
  left: 20px;
  top: -6px;
  width: 250px;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #111827;
  color: #f9fafb;
  font-size: 11px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: normal;
  line-height: 1.35;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.18);
  opacity: 0;
  pointer-events: none;
  transform: translateY(4px);
  transition: opacity 0.12s ease, transform 0.12s ease;
  z-index: 20;
}
.help-dot:hover::after,
.help-dot:focus-visible::after {
  opacity: 1;
  transform: translateY(0);
}
.ctrl-group input[type="number"],
.ctrl-group input[type="text"],
.ctrl-group input[type="datetime-local"],
.ctrl-group select {
  width: 100%;
  padding: 7px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  background: white;
}
.ctrl-group input[type="datetime-local"] {
  padding: 5px 6px;
  font-size: 12px;
  font-family: monospace;
  letter-spacing: -0.02em;
}
.ctrl-group input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}
.range-val { font-size: 11px; color: var(--muted); }
.checkbox-group { display: flex; flex-direction: column; justify-content: flex-end; }
.check-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: white;
  font-size: 12px;
  color: var(--ink);
}
.check-inline input[type="checkbox"] { accent-color: var(--accent); }

/* ── buttons ──────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-outline { background: white; border: 1px solid var(--border); color: var(--ink); }
.btn-outline:hover { background: #f9fafb; }
.btn-danger { background: transparent; border: 1px solid var(--danger); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-row { display: flex; gap: 6px; margin-top: 10px; }

/* ── entity list ──────────────────────────── */
.scroll-list { flex: 1; overflow-y: auto; padding: 8px 16px 16px; }
.entity-card {
  padding: 10px 12px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 6px;
  cursor: pointer;
  transition: all 0.12s;
  display: flex;
  align-items: center;
  gap: 8px;
}
.entity-card:hover { border-color: var(--accent); transform: translateX(2px); }
.entity-card.selected { border-color: var(--accent); background: #eff6ff; }
.entity-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c-unknown); flex-shrink: 0; }
.entity-dot.t-malware { background: var(--c-malware); }
.entity-dot.t-threat_actor { background: var(--c-threat_actor); }
.entity-dot.t-attack_pattern { background: var(--c-attack_pattern); }
.entity-dot.t-tool { background: var(--c-tool); }
.entity-dot.t-vulnerability { background: var(--c-vulnerability); }
.entity-dot.t-campaign { background: var(--c-campaign); }
.entity-dot.t-indicator { background: var(--c-indicator); }
.entity-dot.t-infrastructure { background: var(--c-infrastructure); }
.entity-dot.t-mitigation { background: var(--c-mitigation); }
.entity-dot.t-report { background: var(--c-report); }
.entity-dot.t-identity { background: var(--c-identity); }
.entity-type { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }
.entity-info { flex: 1; min-width: 0; }
.entity-name { font-weight: 500; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.entity-id { font-size: 10px; color: var(--muted); font-family: monospace; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── panels ───────────────────────────────── */
.panel { display: none; }
.panel.active { display: flex; flex-direction: column; flex: 1; overflow: hidden; }

/* ── pir dashboard (full-width) ──────────── */
.pir-dashboard {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #f8fafc;
}
.pir-dash-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 24px;
  background: white;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.pir-dash-title {
  display: flex;
  align-items: center;
  gap: 8px;
}
.pir-dash-title svg { color: var(--accent); flex-shrink: 0; }
.pir-dash-title h2 { font-size: 18px; font-weight: 700; margin: 0; }
.pir-dash-controls {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}
.pir-toolbar-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.pir-toolbar-group label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 600;
}
.pir-toolbar-group select,
.pir-toolbar-group input[type="date"] {
  font-size: 12px;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: white;
  cursor: pointer;
  color: var(--fg);
  font-family: inherit;
}
.pir-dash-controls .btn {
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.pir-dash-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
}
/* summary banner */
.pir-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: linear-gradient(135deg, #eff6ff 0%, #f8fafc 100%);
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 20px;
}
.pir-banner svg { flex-shrink: 0; color: var(--accent); }
.pir-banner-text { display: flex; flex-direction: column; gap: 2px; }
.pir-banner-text strong { font-size: 14px; color: var(--ink); }
/* category grid */
.pir-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(480px, 1fr));
  gap: 16px;
}
.pir-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: white;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.pir-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.pir-card-head h3 {
  font-size: 14px;
  line-height: 1.3;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
}
.pir-card-head h3 .pir-q-icon { width: 18px; height: 18px; flex-shrink: 0; }
.pir-chip {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
  border-radius: 999px;
  padding: 2px 8px;
  white-space: nowrap;
}
.pir-chip.t-malware { color: #991b1b; background: #fee2e2; }
.pir-chip.t-threat_actor { color: #9a3412; background: #ffedd5; }
.pir-chip.t-vulnerability { color: #854d0e; background: #fef9c3; }
.pir-chip.t-attack_pattern { color: #6b21a8; background: #f3e8ff; }
.pir-chip.t-tool { color: #1e40af; background: #dbeafe; }
.pir-chip.t-infrastructure { color: #3730a3; background: #e0e7ff; }
.pir-chip.t-identity { color: #0e7490; background: #cffafe; }
.pir-count-badge {
  font-size: 12px;
  color: var(--muted);
  font-weight: 400;
}
.pir-items { display: flex; flex-direction: column; }
.pir-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  border-bottom: 1px solid #f1f5f9;
  cursor: pointer;
  transition: background 0.1s;
}
.pir-item:last-child { border-bottom: none; }
.pir-item:hover { background: #f8fafc; }
.pir-item-color {
  width: 4px;
  min-height: 28px;
  border-radius: 2px;
  flex-shrink: 0;
  align-self: stretch;
}
.pir-item-body { flex: 1; min-width: 0; }
.pir-item-title {
  display: flex;
  align-items: center;
  gap: 6px;
}
.pir-name {
  font-weight: 600;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pir-item-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
  font-size: 11px;
  color: var(--muted);
}
.pir-item-sep { color: #cbd5e1; }
.pir-trend-badge {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 999px;
  padding: 1px 7px;
}
.pir-trend-badge.sm {
  font-size: 10px;
  padding: 0 6px;
}
.pir-trend-badge.up   { color: #166534; background: #dcfce7; }
.pir-trend-badge.down { color: #9f1239; background: #ffe4e6; }
.pir-trend-badge.flat { color: #64748b; background: #f1f5f9; }

/* ── PIR card stats row ────────────────────── */
.pir-card-stats {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 16px 0;
}
.pir-stat-total {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}

/* ── PIR card chart area ───────────────────── */
.pir-card-chart {
  padding: 4px 8px;
  min-height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.pir-card-chart svg { width: 100%; height: auto; }
.pir-chart-empty {
  font-size: 12px;
  color: var(--muted);
  padding: 30px 0;
  text-align: center;
}

/* ── PIR card legend ───────────────────────── */
.pir-card-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 0 16px 8px;
  border-bottom: 1px solid var(--border);
}
.pir-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 500;
  color: #475569;
}
.pir-legend-agg { color: #818cf8; }
.pir-legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.pir-legend-line {
  width: 16px;
  height: 0;
  border-top: 2px dashed #a5b4fc;
  flex-shrink: 0;
}

.pir-predicates {
  margin-top: 4px;
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
}
.pir-pred {
  font-size: 10px;
  color: #475569;
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  padding: 1px 6px;
  background: #f8fafc;
}
.pir-empty {
  font-size: 13px;
  color: var(--muted);
  padding: 24px 16px;
  text-align: center;
}
/* skeleton loader */
.pir-skeleton {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
  gap: 16px;
}
.pir-skeleton-card {
  height: 200px;
  border-radius: 12px;
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
  background-size: 200% 100%;
  animation: pir-shimmer 1.5s infinite;
}
@keyframes pir-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
/* active item highlight */
.pir-item--active { background: #f0f9ff !important; }
/* detail drawer */
.pir-detail {
  padding: 12px 16px 14px;
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
  animation: pir-detail-in 0.15s ease;
}
@keyframes pir-detail-in {
  from { opacity: 0; max-height: 0; }
  to   { opacity: 1; max-height: 600px; }
}
.pir-detail-loading {
  font-size: 12px;
  color: var(--muted);
  padding: 8px 0;
}
.pir-detail-attrs {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 10px;
}
.pir-detail-attr {
  font-size: 11px;
  font-weight: 600;
  border-radius: 999px;
  padding: 2px 8px;
  background: #e2e8f0;
  color: #334155;
}
.pir-cvss-critical { background: #fecaca; color: #991b1b; }
.pir-cvss-high     { background: #fed7aa; color: #9a3412; }
.pir-cvss-medium   { background: #fef08a; color: #854d0e; }
.pir-cvss-low      { background: #d9f99d; color: #3f6212; }
.pir-attr-bad      { background: #fecaca; color: #991b1b; }
.pir-attr-ok       { background: #d1fae5; color: #065f46; }
.pir-detail-section {
  margin-bottom: 10px;
}
.pir-detail-section-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 5px;
}
.pir-detail-pred-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  margin-bottom: 4px;
}
.pir-detail-pred-label {
  font-size: 10px;
  font-weight: 600;
  color: #64748b;
  background: #e2e8f0;
  border-radius: 4px;
  padding: 1px 6px;
  flex-shrink: 0;
}
.pir-detail-entity {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 999px;
  background: white;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.1s;
}
.pir-detail-entity:hover {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}
.pir-detail-entity:hover .entity-dot { border-color: white; }
.pir-detail-source {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--accent);
  text-decoration: none;
  padding: 3px 0;
  overflow: hidden;
}
.pir-detail-source:hover { text-decoration: underline; }
.pir-detail-source svg { flex-shrink: 0; color: var(--muted); }
.pir-detail-source span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pir-detail-time {
  font-size: 10px;
  color: var(--muted);
  flex-shrink: 0;
  margin-left: auto;
}
.pir-detail-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

/* ── upload / drop zone ───────────────────── */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 32px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
  background: white;
}
.drop-zone.dragover { border-color: var(--accent); background: #eff6ff; }
.drop-zone p { color: var(--muted); font-size: 14px; margin-top: 8px; }
.drop-zone .hint { font-size: 12px; color: #9ca3af; }

.file-list { margin-top: 12px; }
.file-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 4px;
  font-size: 13px;
}
.file-item .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-item .size { color: var(--muted); font-size: 11px; white-space: nowrap; }
.file-item .remove-file {
  background: none; border: none; color: var(--muted); cursor: pointer;
  font-size: 16px; line-height: 1; padding: 0 4px;
}
.file-item .remove-file:hover { color: var(--danger); }

/* ── run items ────────────────────────────── */
.runs-section {
  border-top: 1px solid var(--border);
  padding: 12px 16px;
  flex-shrink: 0;
}
.runs-section #runsContent {
  max-height: 180px;
  overflow-y: auto;
}
.run-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 4px;
  font-size: 13px;
}
.run-item .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge {
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
}
.badge.pending { background: #fef3c7; color: #92400e; }
.badge.running { background: #dbeafe; color: #1e40af; }
.badge.completed { background: #dcfce7; color: #166534; }
.badge.failed { background: #fee2e2; color: #991b1b; }

/* ── graph toolbar ────────────────────────── */
.graph-toolbar {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  gap: 4px;
  z-index: 10;
}
.graph-toolbar .btn {
  background: rgba(255,255,255,0.9);
  backdrop-filter: blur(4px);
  border: 1px solid var(--border);
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.graph-toolbar .btn:hover { background: white; }
.graph-toolbar .btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.graph-toolbar .btn.active:hover { background: var(--accent-hover); }
.graph-toolbar .btn-danger { background: #fee2e2; color: var(--danger); border-color: #fca5a5; }
.graph-toolbar .btn-danger:hover { background: #fecaca; }
.toolbar-sep { width: 1px; height: 20px; background: var(--border); margin: 0 2px; }

/* ── timeline panel ──────────────────────── */
.timeline-panel {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 12;
  background: rgba(255,255,255,0.94);
  border: 1px solid var(--border);
  border-radius: 8px;
  backdrop-filter: blur(6px);
  box-shadow: 0 6px 22px rgba(0,0,0,0.1);
  padding: 10px 12px;
}
.timeline-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}
.timeline-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: #111827;
}
.timeline-meta {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#timelineSvg {
  width: 100%;
  height: 120px;
  display: block;
}
.timeline-empty {
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  padding: 38px 0;
}
.timeline-bar { fill: rgba(37, 99, 235, 0.22); }
.timeline-line {
  fill: none;
  stroke: #1d4ed8;
  stroke-width: 2;
}
.timeline-dot {
  fill: #1d4ed8;
  stroke: white;
  stroke-width: 1.5;
}
.timeline-axis text {
  fill: #6b7280;
  font-size: 10px;
}
.timeline-axis line,
.timeline-axis path {
  stroke: #d1d5db;
}

/* ── export dropdown ──────────────────────── */
.export-dropdown {
  position: relative;
}
.export-menu {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 4px;
  background: #1f2937;
  border: 1px solid #374151;
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
  padding: 4px;
  z-index: 60;
  min-width: 210px;
}
.export-menu.open { display: block; }
.sidebar-export .export-menu {
  top: auto;
  bottom: 100%;
  left: 0;
  right: 0;
  margin-top: 0;
  margin-bottom: 4px;
}
.export-item {
  display: block;
  width: 100%;
  padding: 7px 12px;
  background: none;
  border: none;
  color: #e5e7eb;
  font-size: 13px;
  text-align: left;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
}
.export-item:hover {
  background: #374151;
  color: white;
}

/* ── context menu ─────────────────────────── */
.context-menu {
  position: absolute;
  background: white;
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  padding: 4px;
  display: none;
  z-index: 50;
  min-width: 160px;
}
.context-menu.show { display: block; }
.ctx-item {
  display: block;
  width: 100%;
  padding: 8px 12px;
  text-align: left;
  border: none;
  background: none;
  font-size: 13px;
  cursor: pointer;
  border-radius: 4px;
}
.ctx-item:hover { background: #f3f4f6; }
.ctx-item.danger { color: var(--danger); }

/* ── graph elements ───────────────────────── */
.link { stroke: #9ca3af; stroke-opacity: 0.4; stroke-width: 1.5px; transition: stroke-opacity 0.15s; }
.link.selected { stroke: var(--accent); stroke-opacity: 1; stroke-width: 3px; }
.link.inferred { stroke-dasharray: 6 4; }
.link.cooccurrence { stroke-dasharray: 3 3; stroke-opacity: 0.25; }
.node { transition: opacity 0.15s; }
.node.selected circle { stroke: var(--accent); stroke-width: 3; filter: drop-shadow(0 0 6px rgba(37,99,235,0.5)); }
.node-label {
  font-size: 11px;
  font-weight: 500;
  pointer-events: none;
  user-select: none;
  fill: var(--ink);
  stroke: rgba(255,255,255,0.88);
  stroke-width: 3.5px;
  paint-order: stroke fill;
  stroke-linejoin: round;
}
.lasso-rect { fill: rgba(37,99,235,0.08); stroke: var(--accent); stroke-width: 1; stroke-dasharray: 4 2; }
.edge-label { font-size: 10px; fill: #374151; pointer-events: none; user-select: none; }

/* ── sidebar type toggles ─────────────────── */
.type-toggles {
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: white;
  overflow: hidden;
}
.type-toggles-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 10px;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
}
.type-toggles-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.type-toggles-all {
  font-size: 10px;
  font-weight: 600;
  padding: 1px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: white;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.12s;
}
.type-toggles-all:hover {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}
.type-toggle-list {
  display: flex;
  flex-direction: column;
  max-height: 210px;
  overflow-y: auto;
}
.type-toggle-row {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 10px;
  cursor: pointer;
  transition: background 0.1s;
  border-bottom: 1px solid #f1f5f9;
  opacity: 0.5;
}
.type-toggle-row:last-child { border-bottom: none; }
.type-toggle-row:hover { background: #f8fafc; }
.type-toggle-row.has-data { opacity: 1; }
.type-toggle-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.type-toggle-name {
  flex: 1;
  font-size: 11px;
  font-weight: 500;
  color: var(--ink);
  text-transform: capitalize;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.type-toggle-count {
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  min-width: 14px;
  text-align: right;
}
.type-toggle-cb {
  display: none;
}
.type-toggle-switch {
  position: relative;
  width: 28px;
  height: 16px;
  background: #d1d5db;
  border-radius: 8px;
  flex-shrink: 0;
  transition: background 0.2s;
}
.type-toggle-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 12px;
  height: 12px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 2px rgba(0,0,0,0.15);
}
.type-toggle-cb:checked + .type-toggle-switch {
  background: var(--accent);
}
.type-toggle-cb:checked + .type-toggle-switch::after {
  transform: translateX(12px);
}

/* ── compact graph legend ─────────────────── */
.graph-legend {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 11;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  background: rgba(255,255,255,0.88);
  backdrop-filter: blur(6px);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 8px;
  box-shadow: 0 1px 6px rgba(0,0,0,0.06);
}
.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}
.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ── task status bar ──────────────────────── */
.task-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: #1e293b;
  color: #e2e8f0;
  font-size: 12px;
  font-family: monospace;
  min-height: 28px;
}
.task-bar .task-label { color: #94a3b8; }
.task-bar .task-progress { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-bar .task-badge {
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
}
.task-badge.running { background: #2563eb; color: #fff; }
.task-badge.completed { background: #16a34a; color: #fff; }
.task-badge.failed { background: #dc2626; color: #fff; }

/* ── empty state ──────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--muted);
  font-size: 14px;
  gap: 8px;
}
.empty-state svg { width: 48px; height: 48px; opacity: 0.25; }

/* ── toasts ───────────────────────────────── */
.toasts {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  z-index: 9999;
}
.toast {
  padding: 10px 16px;
  background: #1e293b;
  color: #f8fafc;
  border-radius: 6px;
  font-size: 13px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  animation: slideIn 0.2s ease;
}
.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }
@keyframes slideIn { from { transform: translateX(40px); opacity: 0; } }

/* ── Ask tab ──────────────────────────────── */
.ask-dashboard {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}
.ask-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  max-width: 860px;
  width: 100%;
  margin: 0 auto;
  overflow: hidden;
}
.ask-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 24px 12px;
  flex-shrink: 0;
}
.ask-header h2 {
  font-size: 17px;
  font-weight: 700;
  margin: 0;
}
.ask-model-badge {
  margin-left: auto;
  font-size: 11px;
  font-family: monospace;
  color: var(--muted);
  background: rgba(0,0,0,0.05);
  padding: 3px 10px;
  border-radius: 12px;
}

/* ── messages area ─────────────────────── */
.ask-messages {
  flex: 1;
  overflow-y: auto;
  padding: 0 24px 16px;
  scroll-behavior: smooth;
}

/* ── welcome screen ────────────────────── */
.ask-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  color: var(--muted);
  gap: 12px;
  padding: 60px 0;
}
.ask-welcome-icon {
  opacity: 0.2;
}
.ask-welcome h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
  margin: 0;
}
.ask-welcome p {
  font-size: 13px;
  max-width: 400px;
  line-height: 1.5;
}
.ask-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 8px;
  max-width: 520px;
}
.ask-suggestion {
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--card);
  font-size: 12px;
  cursor: pointer;
  color: var(--ink);
  transition: all 0.15s;
}
.ask-suggestion:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(37, 99, 235, 0.04);
}

/* ── message bubbles ───────────────────── */
.ask-msg {
  margin-bottom: 16px;
  animation: askFadeIn 0.2s ease;
}
@keyframes askFadeIn { from { opacity: 0; transform: translateY(8px); } }

.ask-msg-user .ask-msg-content {
  background: var(--accent);
  color: white;
  padding: 10px 16px;
  border-radius: 16px 16px 4px 16px;
  margin-left: auto;
  max-width: 75%;
  width: fit-content;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
}
.ask-msg-assistant .ask-msg-content {
  background: var(--card);
  border: 1px solid var(--border);
  padding: 14px 18px;
  border-radius: 16px 16px 16px 4px;
  max-width: 90%;
  font-size: 13px;
  line-height: 1.7;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.ask-msg-assistant .ask-msg-content h2,
.ask-msg-assistant .ask-msg-content h3,
.ask-msg-assistant .ask-msg-content h4 {
  margin: 12px 0 6px;
  font-size: 14px;
}
.ask-msg-assistant .ask-msg-content h2:first-child,
.ask-msg-assistant .ask-msg-content h3:first-child,
.ask-msg-assistant .ask-msg-content h4:first-child {
  margin-top: 0;
}
.ask-msg-assistant .ask-msg-content p { margin: 6px 0; }
.ask-msg-assistant .ask-msg-content ul {
  margin: 6px 0;
  padding-left: 20px;
}
.ask-msg-assistant .ask-msg-content li {
  margin: 3px 0;
}
.ask-msg-assistant .ask-msg-content code {
  background: rgba(0,0,0,0.06);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 12px;
}
.ask-msg-assistant .ask-msg-content strong {
  font-weight: 600;
}

/* ── thinking indicator ────────────────── */
.ask-thinking {
  color: var(--muted);
  font-style: italic;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.ask-thinking::after {
  content: '';
  width: 6px;
  height: 6px;
  background: var(--accent);
  border-radius: 50%;
  animation: askPulse 1s infinite;
}
@keyframes askPulse {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}

/* ── error display ─────────────────────── */
.ask-error {
  color: var(--danger);
  font-size: 13px;
  padding: 8px 12px;
  background: rgba(220, 38, 38, 0.06);
  border-radius: 6px;
  border-left: 3px solid var(--danger);
}

/* ── source context chips ──────────────── */
.ask-msg-sources {
  margin-bottom: 10px;
  padding: 10px 14px;
  background: rgba(37, 99, 235, 0.04);
  border: 1px solid rgba(37, 99, 235, 0.12);
  border-radius: 10px;
  max-width: 90%;
}
.ask-source-summary {
  display: flex;
  gap: 14px;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 8px;
}
.ask-source-stat {
  white-space: nowrap;
}
.ask-source-entities {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.ask-entity-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 11px;
  white-space: nowrap;
}
.ask-chip-type {
  color: var(--muted);
  font-size: 10px;
}
.ask-chip-more {
  color: var(--muted);
  background: rgba(0,0,0,0.03);
  border: 1px dashed var(--border);
}
.ask-source-empty {
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
}

/* ── input area ────────────────────────── */
.ask-input-area {
  padding: 12px 24px 18px;
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  background: rgba(255,255,255,0.6);
}
.ask-input-wrap {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px 8px 8px 14px;
  transition: border-color 0.15s;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}
.ask-input-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.08);
}
.ask-input-wrap textarea {
  flex: 1;
  border: none;
  outline: none;
  font-size: 14px;
  font-family: inherit;
  line-height: 1.5;
  resize: none;
  background: transparent;
  min-height: 24px;
  max-height: 160px;
}
.ask-send-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
}
.ask-send-btn:hover { background: var(--accent-hover); }
.ask-send-btn:disabled {
  background: var(--muted);
  cursor: not-allowed;
  opacity: 0.5;
}
.ask-input-hint {
  font-size: 10px;
  color: var(--muted);
  margin-top: 6px;
  text-align: center;
}

/* ─── STATUS DASHBOARD ──────────────────────────────────────── */
.status-dashboard {
  flex: 1;
  overflow-y: auto;
  padding: 24px 32px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.status-dash-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}
.status-dash-title {
  display: flex;
  align-items: center;
  gap: 8px;
}
.status-dash-title h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
}
.status-dash-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}
.status-auto-refresh {
  font-size: 11px;
  color: var(--muted);
  font-family: monospace;
}

/* Grid of cards */
.status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
  gap: 16px;
}

/* Card */
.status-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: box-shadow 0.15s;
}
.status-card:hover {
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}
.status-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border);
}
.status-card-header h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}
.status-card-header svg {
  color: var(--accent);
  flex-shrink: 0;
}
.status-card-body {
  padding: 14px 16px 16px;
}

/* Metric counters */
.status-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}
.status-metric {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 64px;
}
.status-metric-val {
  font-size: 22px;
  font-weight: 700;
  font-family: monospace;
  color: var(--ink);
  line-height: 1.2;
}
.status-metric-val.ok    { color: var(--success); }
.status-metric-val.warn  { color: var(--warn); }
.status-metric-val.err   { color: var(--danger); }
.status-metric-val.accent{ color: var(--accent); }
.status-metric-label {
  font-size: 11px;
  color: var(--muted);
  text-align: center;
  margin-top: 2px;
}

/* Progress bar */
.status-progress-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
}
.status-progress-bar {
  flex: 1;
  height: 6px;
  background: rgba(0,0,0,0.06);
  border-radius: 3px;
  overflow: hidden;
}
.status-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.4s ease;
}
.status-progress-label {
  font-size: 11px;
  color: var(--muted);
  font-family: monospace;
  white-space: nowrap;
}

/* Row lists (runs, tasks, metrics status) */
.status-rows {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.status-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid rgba(0,0,0,0.04);
  font-size: 12px;
}
.status-row:last-child { border-bottom: none; }
.status-row-label {
  font-weight: 500;
  color: var(--ink);
  min-width: 100px;
}
.status-row-label.run-id {
  font-family: monospace;
  font-size: 11px;
  min-width: 140px;
}
.status-row-detail {
  font-size: 11px;
  color: var(--muted);
  font-family: monospace;
}

/* Badges */
.status-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 8px;
  border-radius: 10px;
  white-space: nowrap;
}
.status-badge.ok      { background: #dcfce7; color: #166534; }
.status-badge.running { background: #dbeafe; color: #1e40af; }
.status-badge.pending { background: #fef3c7; color: #92400e; }
.status-badge.warn    { background: #fef3c7; color: #92400e; }
.status-badge.err     { background: #fee2e2; color: #991b1b; }

/* Error and empty states */
.status-error {
  font-size: 11px;
  color: var(--danger);
  margin-top: 6px;
  word-break: break-word;
}
.status-error-inline {
  font-size: 10px;
  color: var(--danger);
  word-break: break-word;
}
.status-empty {
  font-size: 12px;
  color: var(--muted);
  padding: 16px 0;
  text-align: center;
}
.status-loading {
  font-size: 13px;
  color: var(--muted);
  padding: 40px;
  text-align: center;
  grid-column: 1 / -1;
}
.status-error-card {
  grid-column: 1 / -1;
  background: #fee2e2;
  border: 1px solid #fca5a5;
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
}
.status-error-card h3 {
  margin: 0 0 8px;
  color: #991b1b;
}
.status-error-card p {
  color: #991b1b;
  font-size: 13px;
  margin: 0;
}
