/* ── Reset & Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 19px;
  scroll-behavior: smooth;
  transition: background-color 0.25s, color 0.25s;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg-gradient);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.6;
  isolation: isolate;
}

/* Ambient color blobs — dark theme */
[data-theme="dark"] body::before,
[data-theme="dark"] body::after {
  content: '';
  position: fixed;
  border-radius: 50%;
  filter: blur(80px);
  z-index: -1;
  pointer-events: none;
}

[data-theme="dark"] body::before {
  width: 500px; height: 500px;
  top: -100px; left: -60px;
  background: radial-gradient(circle, rgba(30,80,180,0.18) 0%, transparent 70%);
}

[data-theme="dark"] body::after {
  width: 420px; height: 420px;
  bottom: 5%; right: 0;
  background: radial-gradient(circle, rgba(160,30,60,0.14) 0%, transparent 70%);
}

/* Ambient color blobs — light theme */
[data-theme="light"] body::before,
[data-theme="light"] body::after {
  content: '';
  position: fixed;
  border-radius: 50%;
  filter: blur(70px);
  z-index: -1;
  pointer-events: none;
}

[data-theme="light"] body::before {
  width: 480px; height: 480px;
  top: -80px; left: -40px;
  background: radial-gradient(circle, rgba(9,105,218,0.12) 0%, transparent 70%);
}

[data-theme="light"] body::after {
  width: 400px; height: 400px;
  bottom: 5%; right: 0;
  background: radial-gradient(circle, rgba(140,20,40,0.07) 0%, transparent 70%);
}

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); border: 0;
}

/* ── CSS Variables ────────────────────────────────────────────────────────── */
[data-theme="dark"] {
  --bg:              #0b0f19;
  --bg-gradient:     linear-gradient(135deg, #080c14 0%, #0d1117 50%, #0c1220 100%);
  --bg-card:         rgba(22, 28, 38, 0.72);
  --bg-hover:        rgba(30, 38, 52, 0.82);
  --bg-input:        rgba(33, 38, 45, 0.75);
  --border:          rgba(255, 255, 255, 0.09);
  --border-sub:      rgba(255, 255, 255, 0.05);
  --text:            #e6edf3;
  --text-muted:      #8b949e;
  --text-sub:        #6e7681;
  --accent:          #58a6ff;
  --glass-blur:      blur(14px);
  --glass-border:    rgba(255, 255, 255, 0.09);
  --track-bg:        rgba(255, 255, 255, 0.12);

  --sev-critical:    #ff4444;
  --sev-critical-bg: rgba(255,68,68,0.12);
  --sev-high:        #ff8c00;
  --sev-high-bg:     rgba(255,140,0,0.12);
  --sev-medium:      #e3b341;
  --sev-medium-bg:   rgba(227,179,65,0.12);
  --sev-low:         #4dabf7;
  --sev-low-bg:      rgba(77,171,247,0.12);
  --sev-info:        #6e7681;
  --sev-info-bg:     rgba(110,118,129,0.12);

  --shadow:   0 8px 32px rgba(0,0,0,0.55);
  --shadow-s: 0 2px 12px rgba(0,0,0,0.4);
}

[data-theme="light"] {
  --bg:              #dde4ef;
  --bg-gradient:     linear-gradient(135deg, #dce3ef 0%, #e8eef8 50%, #dde6f4 100%);
  --bg-card:         rgba(255, 255, 255, 0.68);
  --bg-hover:        rgba(246, 248, 252, 0.82);
  --bg-input:        rgba(240, 244, 250, 0.75);
  --border:          rgba(0, 0, 0, 0.1);
  --border-sub:      rgba(0, 0, 0, 0.06);
  --text:            #1f2328;
  --text-muted:      #57606a;
  --text-sub:        #8c959f;
  --accent:          #0969da;
  --glass-blur:      blur(14px);
  --glass-border:    rgba(255, 255, 255, 0.75);
  --track-bg:        rgba(0, 0, 0, 0.1);

  --sev-critical:    #cf222e;
  --sev-critical-bg: rgba(207,34,46,0.08);
  --sev-high:        #bc4c00;
  --sev-high-bg:     rgba(188,76,0,0.08);
  --sev-medium:      #7d4e00;
  --sev-medium-bg:   rgba(125,78,0,0.08);
  --sev-low:         #0550ae;
  --sev-low-bg:      rgba(5,80,174,0.08);
  --sev-info:        #57606a;
  --sev-info-bg:     rgba(87,96,106,0.08);

  --shadow:   0 8px 32px rgba(0,0,0,0.12);
  --shadow-s: 0 2px 12px rgba(0,0,0,0.08);
}

/* ── Header ───────────────────────────────────────────────────────────────── */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.875rem 2rem;
  background: var(--bg-card);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid var(--glass-border);
  position: sticky;
  top: 0;
  z-index: 100;
  flex-wrap: wrap;
  gap: 0.75rem;
  box-shadow: var(--shadow-s);
}

.header-brand { display: flex; align-items: center; gap: 0.75rem; }

.brand-icon { width: 30px; height: 30px; color: var(--accent); flex-shrink: 0; }

.brand-title { font-size: 1.05rem; font-weight: 700; color: var(--text); letter-spacing: -0.01em; }
.brand-sub   { font-size: 0.72rem; color: var(--text-muted); margin-top: 0.1rem; }

.header-controls { display: flex; align-items: center; gap: 0.6rem; }

.select-wrap select {
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.35rem 0.7rem;
  font-size: 0.85rem;
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s;
}
.select-wrap select:focus { border-color: var(--accent); }

.theme-btn {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.35rem;
  cursor: pointer;
  color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  width: 34px; height: 34px;
  transition: background 0.15s, color 0.15s;
}
.theme-btn:hover { background: var(--bg-hover); color: var(--text); }
.theme-btn svg { width: 17px; height: 17px; }

[data-theme="dark"]  .icon-sun  { display: block; }
[data-theme="dark"]  .icon-moon { display: none; }
[data-theme="light"] .icon-sun  { display: none; }
[data-theme="light"] .icon-moon { display: block; }

/* ── Main ─────────────────────────────────────────────────────────────────── */
.main-content {
  flex: 1;
  max-width: 1600px;
  margin: 0 auto;
  padding: 1.25rem 2rem 3rem;
  width: 100%;
}

/* ── Loading ──────────────────────────────────────────────────────────────── */
.loading-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1rem; min-height: 40vh; color: var(--text-muted);
}

.spinner {
  width: 34px; height: 34px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Meta Strip ───────────────────────────────────────────────────────────── */
.meta-strip {
  display: flex; flex-wrap: wrap; gap: 0.4rem 1.25rem;
  font-size: 0.72rem; color: var(--text-sub); margin-bottom: 1rem;
  font-family: ui-monospace, "Cascadia Code", monospace;
}
.meta-strip span { display: flex; align-items: center; gap: 0.25rem; }

/* ── KPI Row ──────────────────────────────────────────────────────────────── */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.75rem;
  margin-bottom: 1rem;
}

@media (max-width: 900px)  { .kpi-row { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 600px)  { .kpi-row { grid-template-columns: repeat(2, 1fr); } }

.kpi-tile {
  background: var(--bg-card);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow-s);
  transition: transform 0.15s, box-shadow 0.15s;
}
.kpi-tile:hover { transform: translateY(-2px); box-shadow: var(--shadow); }

.kpi-threat {
  border-left: 4px solid var(--glass-border);
  transition: border-color 0.3s, box-shadow 0.3s;
}
.kpi-threat.level-critical {
  border-left-color: var(--sev-critical);
  background: var(--sev-critical-bg);
  box-shadow: 0 0 22px rgba(255,68,68,0.18), var(--shadow-s);
}
.kpi-threat.level-high {
  border-left-color: var(--sev-high);
  background: var(--sev-high-bg);
  box-shadow: 0 0 22px rgba(255,140,0,0.16), var(--shadow-s);
}
.kpi-threat.level-medium {
  border-left-color: var(--sev-medium);
  background: var(--sev-medium-bg);
  box-shadow: 0 0 18px rgba(227,179,65,0.14), var(--shadow-s);
}
.kpi-threat.level-low {
  border-left-color: var(--sev-low);
  background: var(--sev-low-bg);
  box-shadow: 0 0 18px rgba(77,171,247,0.14), var(--shadow-s);
}
.kpi-threat.level-info {
  border-left-color: #3fb950;
  background: rgba(63,185,80,0.09);
  box-shadow: 0 0 18px rgba(63,185,80,0.12), var(--shadow-s);
}
.badge-nominal {
  background: rgba(63,185,80,0.15);
  color: #3fb950;
}

.kpi-label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.kpi-value {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
  margin-bottom: 0.25rem;
}

.kpi-num { font-variant-numeric: tabular-nums; }

.kpi-sub {
  font-size: 0.7rem;
  color: var(--text-sub);
}

/* ── Cards ────────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-s);
}

.card-header {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 0.5rem;
  margin-bottom: 1rem; padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-sub);
}

.card-title {
  font-size: 0.95rem; font-weight: 600; color: var(--text);
}

.card-label {
  font-size: 0.68rem; font-weight: 600; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--accent);
  background: rgba(88,166,255,0.1); padding: 0.18rem 0.5rem; border-radius: 4px;
}
[data-theme="light"] .card-label { background: rgba(9,105,218,0.1); }

.card-count {
  font-size: 0.78rem; color: var(--text-muted);
  background: var(--bg-input); padding: 0.18rem 0.55rem;
  border-radius: 10px; border: 1px solid var(--border);
}

/* ── Activity Timeline ────────────────────────────────────────────────────── */
.timeline-chart {
  width: 100%;
  min-height: 158px;
  overflow: hidden;
}

.timeline-chart svg {
  display: block;
  width: 100%;
  overflow: visible;
}


/* ── Charts Row ───────────────────────────────────────────────────────────── */
.charts-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}
@media (max-width: 700px) { .charts-row { grid-template-columns: 1fr; } }

.charts-card { margin-bottom: 0; }

/* ── Donut Chart ──────────────────────────────────────────────────────────── */
.donut-wrap {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}

#donut-chart svg { display: block; flex-shrink: 0; }

.donut-legend {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  flex: 1;
}

.legend-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

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

.legend-label { flex: 1; color: var(--text-muted); }
.legend-count { font-variant-numeric: tabular-nums; color: var(--text); font-weight: 600; }
.legend-pct   { color: var(--text-sub); font-size: 0.72rem; min-width: 32px; text-align: right; }

/* ── Category Bars ────────────────────────────────────────────────────────── */
.category-bars { display: flex; flex-direction: column; gap: 0.55rem; }

.bar-row {
  display: flex; align-items: center; gap: 0.6rem; font-size: 0.78rem;
}

.bar-label { min-width: 64px; color: var(--text-muted); font-size: 0.75rem; }

.bar-track {
  flex: 1; height: 7px;
  background: var(--track-bg); border-radius: 4px; overflow: hidden;
}

.bar-fill {
  height: 100%; border-radius: 4px;
  transition: width 0.6s cubic-bezier(0.4,0,0.2,1);
}

.bar-count {
  min-width: 24px; text-align: right;
  color: var(--text-sub); font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}

/* ── Content Row ──────────────────────────────────────────────────────────── */
.content-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
  align-items: start;
}
@media (max-width: 900px) { .content-row { grid-template-columns: 1fr; } }

.content-card {
  margin-bottom: 0;
  height: 960px;
  display: flex;
  flex-direction: column;
}

.card-body-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  background: var(--bg-input);
  margin-top: 0.75rem;
}
.card-body-scroll::-webkit-scrollbar { width: 5px; }
.card-body-scroll::-webkit-scrollbar-track { background: transparent; }
.card-body-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.expand-btn {
  background: none; border: 1px solid var(--border);
  border-radius: 5px; color: var(--text-muted);
  cursor: pointer; font-size: 0.8rem;
  padding: 0.1rem 0.4rem; line-height: 1.4;
  transition: color 0.15s, border-color 0.15s;
}
.expand-btn:hover { color: var(--text); border-color: var(--accent); }
.content-card.expanded .expand-btn { color: var(--accent); border-color: var(--accent); }

/* ── AI Analysis ──────────────────────────────────────────────────────────── */
.threat-summary {
  font-size: 0.9rem; line-height: 1.7; color: var(--text); margin-bottom: 0.75rem;
  flex-shrink: 0;
}

.analysis-panel {
  background: var(--bg-input);
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  padding: 0.875rem 1rem;
  margin-bottom: 0.75rem;
}

.panel-title {
  display: flex; align-items: center; gap: 0.4rem;
  font-size: 0.72rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--text-muted); margin-bottom: 0.6rem;
}
.panel-title svg { width: 13px; height: 13px; }

.action-list {
  list-style: none; display: flex; flex-direction: column;
  gap: 0.5rem; padding: 0; counter-reset: actions;
}

.action-list li {
  display: flex; gap: 0.55rem;
  font-size: 0.85rem; color: var(--text); line-height: 1.5;
  counter-increment: actions;
}

.action-list li::before {
  content: counter(actions);
  background: var(--accent); color: #fff; border-radius: 50%;
  min-width: 18px; height: 18px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.65rem; font-weight: 700; margin-top: 0.18rem; flex-shrink: 0;
}

.analysis-details {
  border-top: 1px solid var(--border-sub);
  padding-top: 0.6rem; margin-top: 0.25rem;
}

.analysis-details summary {
  font-size: 0.82rem; color: var(--text-muted);
  cursor: pointer; user-select: none;
  padding: 0.2rem 0; list-style: none;
  display: flex; align-items: center; gap: 0.35rem;
}
.analysis-details summary::-webkit-details-marker { display: none; }
.analysis-details summary::before {
  content: '›'; font-size: 1rem;
  transition: transform 0.2s; display: inline-block;
}
.analysis-details[open] summary::before { transform: rotate(90deg); }

.details-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 0.875rem; margin-top: 0.875rem;
}
.details-full { grid-column: 1 / -1; }
.details-grid h4 {
  font-size: 0.7rem; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--text-muted); margin-bottom: 0.3rem;
}
.details-grid p { font-size: 0.85rem; color: var(--text); line-height: 1.6; }
@media (max-width: 600px) { .details-grid { grid-template-columns: 1fr; } }

/* ── Severity / Category colors ───────────────────────────────────────────── */
.sev-critical { color: var(--sev-critical); }
.sev-high     { color: var(--sev-high); }
.sev-medium   { color: var(--sev-medium); }
.sev-low      { color: var(--sev-low); }
.sev-info     { color: var(--sev-info); }

.badge {
  display: inline-flex; align-items: center;
  padding: 0.12rem 0.45rem; border-radius: 4px;
  font-size: 0.68rem; font-weight: 600;
  letter-spacing: 0.04em; text-transform: uppercase; white-space: nowrap;
}
.badge-critical { background: var(--sev-critical-bg); color: var(--sev-critical); }
.badge-high     { background: var(--sev-high-bg);     color: var(--sev-high); }
.badge-medium   { background: var(--sev-medium-bg);   color: var(--sev-medium); }
.badge-low      { background: var(--sev-low-bg);      color: var(--sev-low); }
.badge-info     { background: var(--sev-info-bg);     color: var(--sev-info); }

/* ── Attack Chain Timeline ────────────────────────────────────────────────── */
.chain-header { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.75rem; }

.chain-status {
  font-size: 0.68rem; font-weight: 600; letter-spacing: 0.06em;
  text-transform: uppercase; padding: 0.18rem 0.5rem; border-radius: 4px;
}
.chain-status.confirmed { background: var(--sev-critical-bg); color: var(--sev-critical); }
.chain-status.no-chain  { background: var(--sev-medium-bg);   color: var(--sev-medium); }

.chain-timeline { display: flex; flex-direction: column; }

.chain-step { display: flex; gap: 0.65rem; }
.chain-step:last-child .chain-line { display: none; }

.chain-dot-col {
  display: flex; flex-direction: column; align-items: center;
  flex-shrink: 0; width: 14px; padding-top: 0.28rem;
}

.chain-dot {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
  border: 2px solid var(--bg-card); transition: transform 0.15s;
}
.chain-step:hover .chain-dot { transform: scale(1.3); }

.chain-dot.dot-critical { background: var(--sev-critical); box-shadow: 0 0 0 1px var(--sev-critical); }
.chain-dot.dot-high     { background: var(--sev-high);     box-shadow: 0 0 0 1px var(--sev-high); }
.chain-dot.dot-medium   { background: var(--sev-medium);   box-shadow: 0 0 0 1px var(--sev-medium); }
.chain-dot.dot-low      { background: var(--sev-low);      box-shadow: 0 0 0 1px var(--sev-low); }
.chain-dot.dot-info     { background: var(--sev-info);     box-shadow: 0 0 0 1px var(--sev-info); }

.chain-line {
  flex: 1; width: 2px; min-height: 10px; margin-top: 3px;
  background: var(--track-bg); border-radius: 1px; opacity: 0.7;
}
.chain-timeline:not(.no-chain) .chain-line { background: var(--sev-high); }

.chain-content { flex: 1; padding-bottom: 0.65rem; }
.chain-step:last-child .chain-content { padding-bottom: 0; }

.chain-step-header {
  display: flex; align-items: center; gap: 0.4rem;
  flex-wrap: wrap; margin-bottom: 0.2rem;
}

.chain-time {
  font-family: ui-monospace, "Cascadia Code", monospace;
  font-size: 0.72rem; color: var(--text-sub); white-space: nowrap;
}

.chain-label { font-size: 0.82rem; font-weight: 600; color: var(--text); }

.chain-note {
  font-size: 0.65rem; font-weight: 600; letter-spacing: 0.05em;
  text-transform: uppercase; color: var(--text-sub);
  background: var(--bg-input); border: 1px solid var(--border);
  padding: 0.08rem 0.35rem; border-radius: 3px;
}

.chain-detail { font-size: 0.8rem; color: var(--text-muted); line-height: 1.5; }

.chain-outcome {
  display: inline-block; margin-top: 0.2rem;
  font-size: 0.68rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--sev-info); background: var(--sev-info-bg);
  padding: 0.08rem 0.35rem; border-radius: 3px;
}

/* ── Anomaly Cards ────────────────────────────────────────────────────────── */
.anomaly-list { display: flex; flex-direction: column; gap: 0.65rem; }

.anomaly-card {
  border: 1px solid var(--glass-border); border-radius: 8px;
  padding: 0.875rem; background: var(--bg-input);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: background 0.15s, box-shadow 0.15s;
}
.anomaly-card:hover { background: var(--bg-hover); box-shadow: var(--shadow-s); }
.anomaly-card.crit  { border-left: 3px solid var(--sev-critical); }
.anomaly-card.high  { border-left: 3px solid var(--sev-high); }
.anomaly-card.med   { border-left: 3px solid var(--sev-medium); }
.anomaly-card.low   { border-left: 3px solid var(--sev-low); }

.anomaly-header {
  display: flex; align-items: center; gap: 0.5rem;
  margin-bottom: 0.4rem; flex-wrap: wrap;
}

.anomaly-type {
  font-size: 0.65rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--text-sub);
  background: var(--bg-input); border: 1px solid var(--border);
  padding: 0.12rem 0.4rem; border-radius: 3px;
}

.anomaly-title { font-size: 0.85rem; font-weight: 600; color: var(--text); flex: 1; }

.anomaly-body  { font-size: 0.82rem; color: var(--text-muted); line-height: 1.55; margin-bottom: 0.5rem; }

.anomaly-rec {
  font-size: 0.8rem; color: var(--text);
  background: var(--bg-card); border: 1px solid var(--border-sub);
  border-radius: 5px; padding: 0.4rem 0.65rem; line-height: 1.5;
}
.anomaly-rec::before { content: '→ '; color: var(--accent); font-weight: 600; }

/* ── Filter Pills ─────────────────────────────────────────────────────────── */
.filter-row {
  display: flex; flex-wrap: wrap; gap: 0.6rem 1.25rem;
  margin-bottom: 0.875rem; padding-bottom: 0.875rem;
  border-bottom: 1px solid var(--border-sub);
}

.filter-group { display: flex; align-items: center; gap: 0.35rem; flex-wrap: wrap; }

.filter-label {
  font-size: 0.7rem; color: var(--text-muted); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em; white-space: nowrap;
}

.filter-pills { display: flex; flex-wrap: wrap; gap: 0.3rem; }

.pill {
  padding: 0.18rem 0.55rem; border-radius: 20px;
  border: 1px solid var(--border); font-size: 0.72rem;
  cursor: pointer; background: var(--bg-input); color: var(--text-muted);
  transition: all 0.15s; user-select: none;
}
.pill:hover { border-color: var(--accent); color: var(--text); }

.pill.active-critical { background: var(--sev-critical-bg); border-color: var(--sev-critical); color: var(--sev-critical); }
.pill.active-high     { background: var(--sev-high-bg);     border-color: var(--sev-high);     color: var(--sev-high); }
.pill.active-medium   { background: var(--sev-medium-bg);   border-color: var(--sev-medium);   color: var(--sev-medium); }
.pill.active-low      { background: var(--sev-low-bg);      border-color: var(--sev-low);      color: var(--sev-low); }
.pill.active-info     { background: var(--sev-info-bg);     border-color: var(--sev-info);     color: var(--sev-info); }
.pill.active-cat      { background: rgba(88,166,255,0.12); border-color: var(--accent); color: var(--accent); }

/* ── Events Table ─────────────────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  overflow-y: auto;
  max-height: 480px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-input);
  margin-top: 0.75rem;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.table-wrap::-webkit-scrollbar { width: 5px; height: 5px; }
.table-wrap::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.events-table { width: 100%; border-collapse: collapse; font-size: 0.83rem; }

[data-theme="dark"]  .events-table thead th { position: sticky; top: 0; z-index: 1; background: #161c26; box-shadow: 0 2px 0 var(--border); }
[data-theme="light"] .events-table thead th { position: sticky; top: 0; z-index: 1; background: #e8eef8; box-shadow: 0 2px 0 var(--border); }
.events-table th {
  text-align: left; padding: 0.45rem 0.7rem;
  font-size: 0.7rem; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--text-muted);
  border-bottom: 1px solid var(--border); white-space: nowrap; font-weight: 600;
}

.events-table td {
  padding: 0.45rem 0.7rem; border-bottom: 1px solid var(--border-sub);
  vertical-align: middle; color: var(--text);
}

.events-table tbody tr { cursor: pointer; transition: background 0.1s; }
.events-table tbody tr:hover { background: var(--bg-hover); }
.events-table tbody tr.flagged { background: rgba(255,140,0,0.04); }

.td-line  { font-family: ui-monospace, monospace; font-size: 0.72rem; color: var(--text-sub); white-space: nowrap; }
.td-time  { font-family: ui-monospace, monospace; font-size: 0.75rem; color: var(--text-muted); white-space: nowrap; }
.td-cat   { font-size: 0.73rem; color: var(--text-muted); white-space: nowrap; }
.td-title { font-size: 0.83rem; color: var(--text); }

.flag-dot {
  display: inline-block; width: 6px; height: 6px;
  border-radius: 50%; background: var(--sev-high);
  margin-left: 0.35rem; vertical-align: middle;
}

/* ── Modal ────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; padding: 1rem;
  backdrop-filter: blur(4px);
}

.modal {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: 12px; max-width: 680px; width: 100%;
  max-height: 85vh; overflow-y: auto; box-shadow: var(--shadow);
}

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.1rem 1.4rem; border-bottom: 1px solid var(--glass-border);
  position: sticky; top: 0;
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 1;
}
.modal-header h3 { font-size: 0.95rem; font-weight: 600; color: var(--text); flex: 1; }

.modal-close {
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text-muted);
  cursor: pointer; padding: 0.2rem 0.45rem; font-size: 0.82rem;
  transition: all 0.15s;
}
.modal-close:hover { background: var(--sev-critical-bg); color: var(--sev-critical); border-color: var(--sev-critical); }

.modal-body { padding: 1.1rem 1.4rem; }

.modal-meta { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-bottom: 0.875rem; }

.modal-raw {
  background: var(--bg); border: 1px solid var(--border); border-radius: 6px;
  padding: 0.65rem 0.875rem;
  font-family: ui-monospace, "Cascadia Code", monospace;
  font-size: 0.76rem; color: var(--text-muted);
  word-break: break-all; line-height: 1.6; margin-bottom: 0.875rem;
}

.modal-detail { font-size: 0.875rem; color: var(--text); line-height: 1.7; }

/* ── Footer ───────────────────────────────────────────────────────────────── */
.site-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.875rem 2rem; border-top: 1px solid var(--glass-border);
  font-size: 0.78rem; color: var(--text-sub);
  background: var(--bg-card);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
}
.site-footer a { color: var(--accent); text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }
.footer-links { display: flex; gap: 1.25rem; align-items: center; }

/* ── Sim Status Badge (inside timeline card header) ──────────────────────── */
.sim-status-badge {
  display: inline-flex; align-items: center; gap: 0.45rem;
  padding: 0.22rem 0.75rem; border-radius: 20px;
  font-size: 0.72rem; font-weight: 600; letter-spacing: 0.04em;
  border: 1px solid currentColor;
  transition: color 0.4s, background 0.4s, border-color 0.4s, box-shadow 0.4s;
}
.sim-status-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: currentColor;
  animation: pulse-dot 1.6s ease-in-out infinite;
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.45; transform: scale(0.75); }
}
.sim-status-badge.sim-status-info     { color: #3fb950; background: rgba(63,185,80,0.1); }
.sim-status-badge.sim-status-low      { color: var(--sev-low);      background: var(--sev-low-bg); }
.sim-status-badge.sim-status-medium   { color: var(--sev-medium);   background: var(--sev-medium-bg); }
.sim-status-badge.sim-status-high     { color: var(--sev-high);     background: var(--sev-high-bg); }
.sim-status-badge.sim-status-critical { color: var(--sev-critical); background: var(--sev-critical-bg); box-shadow: 0 0 10px rgba(255,68,68,0.25); }

/* ── Simulation Bar ───────────────────────────────────────────────────────── */
.sim-bar {
  display: inline-flex; align-items: center; gap: 0.75rem;
  padding: 0.25rem 1.65rem;
  background: rgba(255, 68, 68, 0.08);
  border: 1px solid rgba(255, 68, 68, 0.25);
  border-radius: 20px;
  white-space: nowrap;
}
[data-theme="light"] .sim-bar {
  background: rgba(207, 34, 46, 0.06);
  border-color: rgba(207, 34, 46, 0.2);
}

.sim-info  { display: flex; align-items: center; gap: 0.65rem; }
.sim-controls { display: flex; align-items: center; gap: 0.5rem; }

.sim-live-tag {
  font-size: 0.65rem; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--sev-critical);
  background: var(--sev-critical-bg); border: 1px solid var(--sev-critical);
  padding: 0.15rem 0.45rem; border-radius: 4px;
  animation: sim-pulse 2s ease-in-out infinite;
}
@keyframes sim-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.6; }
}

.sim-phase {
  font-size: 0.8rem; font-weight: 600; color: var(--text);
}

.sim-btn {
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text-muted);
  cursor: pointer; padding: 0.28rem 0.65rem;
  font-size: 0.78rem; transition: all 0.15s;
}
.sim-btn:hover { background: var(--bg-hover); color: var(--text); }

.sim-btn-primary {
  background: var(--sev-critical-bg); border-color: var(--sev-critical);
  color: var(--sev-critical); font-weight: 600;
}
.sim-btn-primary:hover { background: var(--sev-critical); color: #fff; }

.sim-time {
  font-family: ui-monospace, "Cascadia Code", monospace;
  font-size: 0.78rem; color: var(--text-muted);
  min-width: 80px; text-align: right;
}

/* ── Responsive: sim-bar ──────────────────────────────────────────────────── */
@media (max-width: 700px) {
  .sim-bar {
    padding: 0.25rem 0.75rem;
    gap: 0.5rem;
    flex-shrink: 1;
    min-width: 0;
  }
  .sim-live-text,
  #sim-phase-label {
    display: none;
  }
}

/* ── Utility ──────────────────────────────────────────────────────────────── */
[hidden] { display: none !important; }
