:root {
  --bg: #1a1b1e;
  --surface: #25262b;
  --border: #373a40;
  --text: #e9ecef;
  --muted: #868e96;
  --accent: #4dabf7;
  --warning-bg: #3d2a1a;
  --warning-border: #e67700;
  --error-bg: #3d1f1f;
  --error-border: #ff4444;
}
* { box-sizing: border-box; }
body {
  font-family: ui-monospace, "Cascadia Code", "SF Mono", Monaco, monospace;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  margin: 0;
  padding: 1rem;
}
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.page-header h1 { font-size: 1.25rem; margin: 0; color: var(--accent); }
.header-actions { display: flex; gap: 0.5rem; flex-shrink: 0; }
.btn-header {
  font-size: 0.8rem;
  padding: 0.35rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
}
.btn-header:hover:not(:disabled) { background: var(--border); }
.btn-header:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-header-danger {
  border-color: var(--error-border);
  color: #ff8888;
}
.btn-header-danger:hover:not(:disabled) {
  background: var(--error-bg);
}
h1 { font-size: 1.25rem; margin: 0 0 1rem 0; color: var(--accent); }
.layout { display: flex; gap: 1rem; min-height: 80vh; }
.sidebar {
  width: 280px;
  flex-shrink: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem;
  overflow: auto;
}
.sidebar h2 { font-size: 0.85rem; margin: 0 0 0.5rem 0; color: var(--muted); }
.run-item {
  padding: 0.5rem 0.6rem;
  border-radius: 4px;
  cursor: pointer;
  border: 1px solid transparent;
}
.run-item:hover { background: var(--border); }
.run-item.selected { background: var(--border); border-color: var(--accent); }
.run-item .run-name { font-weight: 600; }
.run-item .run-meta { font-size: 0.75rem; color: var(--muted); }
.run-item.running .live-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 0.35rem;
  border-radius: 50%;
  background: var(--accent);
  vertical-align: middle;
  animation: live-dot-pulse 1.5s ease-in-out infinite;
}
@keyframes live-dot-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-width: 0;
}
/* Run Summary panel: status strip, KPI chips, callouts, quick filters (above timeline). */
.run-summary {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1rem;
  margin-bottom: 1rem;
}
.summary-status-strip {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
.summary-status-strip .status-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  text-transform: uppercase;
}
.summary-status-strip .status-badge.ok { background: rgba(34, 139, 34, 0.3); border: 1px solid #2e8b2e; color: #7cfc7c; }
.summary-status-strip .status-badge.error { background: var(--error-bg); border: 1px solid var(--error-border); color: #ff8888; }
.summary-status-strip .status-badge.running { background: rgba(77, 171, 247, 0.2); border: 1px solid var(--accent); color: var(--accent); }
.summary-status-strip .run-name { font-weight: 600; font-size: 1rem; }
.summary-status-strip .run-meta { font-size: 0.8rem; color: var(--muted); }
.summary-status-strip .run-id-wrap { display: inline-flex; align-items: center; gap: 0.25rem; }
.summary-status-strip .run-id-wrap .btn-copy-id { font-size: 0.7rem; padding: 0.15rem 0.35rem; border-radius: 4px; border: 1px solid var(--border); background: var(--bg); color: var(--text); cursor: pointer; font-family: inherit; }
.summary-status-strip .btn-copy-id:hover { background: var(--border); }
.summary-kpis {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}
.summary-kpis .kpi-chip {
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--muted);
}
.summary-kpis .kpi-chip .kpi-value { color: var(--text); font-weight: 600; }
.summary-callouts {
  margin-bottom: 0.75rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.summary-callouts .callout {
  font-size: 0.8rem;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  border: 1px solid var(--warning-border);
  background: var(--warning-bg);
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  text-decoration: none;
  display: inline-block;
}
.summary-callouts .callout.error { border-color: var(--error-border); background: var(--error-bg); }
.summary-callouts .callout:hover { opacity: 0.9; }
.summary-callouts .callout-refresh { border-color: var(--accent); background: rgba(77, 171, 247, 0.15); }
.summary-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  align-items: center;
}
.summary-filters .filter-chip {
  font-size: 0.75rem;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
}
.summary-filters .filter-chip:hover { background: var(--border); }
.summary-filters .filter-chip.active { border-color: var(--accent); background: rgba(77, 171, 247, 0.15); }
.event.highlight { animation: highlight-flash 2s ease-out; }
@keyframes highlight-flash {
  0% { box-shadow: 0 0 0 2px var(--accent); }
  100% { box-shadow: none; }
}
.timeline-toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.5rem;
}
.timeline-toolbar .event-count { font-size: 0.85rem; color: var(--muted); }
.filter-chip {
  font-size: 0.75rem;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.filter-chip:hover { background: var(--border); }
.filter-chip.active { border-color: var(--accent); background: rgba(77, 171, 247, 0.15); }
.timeline { flex: 1; overflow: auto; }
.event {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 0.5rem;
  overflow: hidden;
}
.event.loop-warning {
  border-color: var(--warning-border);
  background: var(--warning-bg);
}
.event.error {
  border-color: var(--error-border);
  background: var(--error-bg);
}
.event-summary {
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.event-summary:hover { background: rgba(255,255,255,0.04); }
.event-summary .toggle { color: var(--muted); font-size: 0.7rem; }
.event-summary .type { font-weight: 600; min-width: 6rem; }
.event-summary .name { color: var(--muted); flex: 0 1 auto; min-width: 0; }
.event-summary .duration { font-size: 0.75rem; color: var(--muted); }
.event-summary .ts { margin-left: auto; font-size: 0.75rem; color: var(--muted); flex-shrink: 0; }
.event-details {
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  white-space: pre-wrap;
  word-break: break-all;
}
.event-details .row { margin-bottom: 0.5rem; }
.event-details .label { color: var(--muted); }
.event-details pre { margin: 0.25rem 0 0 0; background: var(--bg); padding: 0.5rem; border-radius: 4px; overflow: auto; }
.empty { color: var(--muted); padding: 1rem; }
.list-error { color: #ff6b6b; padding: 0.5rem; }
.run-list-loading {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem;
  color: var(--muted);
  font-size: 0.9rem;
}
.run-list-loading .spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.sidebar-header { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.5rem; }
.sidebar-header h2 { margin: 0; }
.btn-refresh {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-refresh:hover { background: var(--border); color: var(--text); }
.btn-refresh:disabled { opacity: 0.5; cursor: not-allowed; }
.run-not-found-banner {
  background: var(--warning-bg);
  border: 1px solid var(--warning-border);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  color: var(--text);
}
