/* ============================================
   traceattest Design System
   Commercial-grade UI tokens & components
   ============================================ */

/* ---------- Design Tokens ---------- */
:root {
  /* Brand — indigo/violet */
  --as-brand-50: #eef2ff;
  --as-brand-100: #e0e7ff;
  --as-brand-200: #c7d2fe;
  --as-brand-300: #a5b4fc;
  --as-brand-400: #818cf8;
  --as-brand-500: #6366f1;
  --as-brand-600: #4f46e5;
  --as-brand-700: #4338ca;

  /* Semantic */
  --as-success: #10b981;
  --as-success-bg: #ecfdf5;
  --as-warning: #f59e0b;
  --as-warning-bg: #fffbeb;
  --as-error: #ef4444;
  --as-error-bg: #fef2f2;
  --as-info: #3b82f6;
  --as-info-bg: #eff6ff;

  /* Surface */
  --as-bg: #f8fafc;
  --as-surface: #ffffff;
  --as-surface-hover: #f1f5f9;
  --as-border: #e2e8f0;
  --as-border-light: #f1f5f9;

  /* Text */
  --as-text-primary: #0f172a;
  --as-text-secondary: #475569;
  --as-text-muted: #94a3b8;

  /* Sidebar */
  --as-sidebar-bg: #0f172a;
  --as-sidebar-hover: #1e293b;
  --as-sidebar-active-bg: rgba(99, 102, 241, 0.15);
  --as-sidebar-active-bar: #6366f1;
  --as-sidebar-text: #94a3b8;
  --as-sidebar-text-active: #ffffff;
  --as-sidebar-divider: #1e293b;

  /* Shadows */
  --as-shadow-xs: 0 1px 2px 0 rgb(15 23 42 / 0.05);
  --as-shadow-sm: 0 1px 3px 0 rgb(15 23 42 / 0.08), 0 1px 2px -1px rgb(15 23 42 / 0.06);
  --as-shadow-md: 0 4px 6px -1px rgb(15 23 42 / 0.08), 0 2px 4px -2px rgb(15 23 42 / 0.06);
  --as-shadow-lg: 0 10px 15px -3px rgb(15 23 42 / 0.1), 0 4px 6px -4px rgb(15 23 42 / 0.05);
  --as-shadow-xl: 0 20px 25px -5px rgb(15 23 42 / 0.12), 0 8px 10px -6px rgb(15 23 42 / 0.05);
  --as-shadow-card: 0 1px 3px 0 rgb(15 23 42 / 0.04), 0 1px 2px -1px rgb(15 23 42 / 0.03);
  --as-shadow-card-hover: 0 4px 12px -2px rgb(15 23 42 / 0.08), 0 2px 6px -2px rgb(15 23 42 / 0.05);
  --as-shadow-stat: 0 1px 3px 0 rgb(15 23 42 / 0.05), 0 1px 2px -1px rgb(15 23 42 / 0.03);

  /* Radius */
  --as-radius-sm: 6px;
  --as-radius: 8px;
  --as-radius-lg: 12px;
  --as-radius-xl: 16px;

  /* Transitions */
  --as-transition: 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
  letter-spacing: -0.01em;
}

.as-main { min-width: 0; }

code, pre, .font-mono {
  font-family: 'JetBrains Mono', 'Fira Code', ui-monospace, monospace;
}

/* Custom scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ---------- Focus & skip link ---------- */
/* One ring for every focusable surface: the browser default is a different
   product's blue, and DESIGN.md already reserves indigo for pointers. */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--as-brand-600);
  outline-offset: 2px;
  border-radius: var(--as-radius-sm);
}
/* Dark sidebar needs the light end of the ramp to clear 3:1 against #0f172a. */
.as-sidebar :where(a, button):focus-visible {
  outline-color: var(--as-brand-400);
  outline-offset: 1px;
}
/* Header search: the tinted field needs a darker placeholder than the muted
   token to clear 4.5:1 on its own background. */
.as-search-input::placeholder { color: #475569; }
.as-search-input:focus-visible { outline: 2px solid var(--as-brand-600); outline-offset: 2px; }
/* Skip link: 16 nav items stand between the page top and its content. */
.as-skip-link {
  position: absolute;
  left: 8px;
  top: -48px;
  z-index: 50;
  padding: 8px 14px;
  border-radius: var(--as-radius-sm);
  background: var(--as-brand-600);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  transition: top var(--as-transition);
}
.as-skip-link:focus {
  top: 8px;
  outline-offset: 2px;
}
/* Screen-reader-only text: state that is otherwise carried by color alone. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Cards ---------- */
.as-card {
  background: var(--as-surface);
  border: 1px solid var(--as-border);
  border-radius: var(--as-radius-lg);
  box-shadow: var(--as-shadow-card);
  transition: box-shadow var(--as-transition), border-color var(--as-transition), transform var(--as-transition);
}
.as-card:hover {
  box-shadow: var(--as-shadow-card-hover);
  border-color: #cbd5e1;
}
.as-card-flat {
  background: var(--as-surface);
  border: 1px solid var(--as-border);
  border-radius: var(--as-radius-lg);
}

/* ---------- Stat Cards ---------- */
.as-stat {
  display: block;
  color: inherit;
  text-decoration: none;
  background: var(--as-surface);
  border: 1px solid var(--as-border);
  border-radius: var(--as-radius-lg);
  padding: 20px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--as-shadow-stat);
  transition: box-shadow var(--as-transition), transform var(--as-transition), border-color var(--as-transition);
}
.as-stat:hover {
  box-shadow: var(--as-shadow-card-hover);
  transform: translateY(-2px);
  border-color: #cbd5e1;
}
.as-stat::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--as-brand-500), var(--as-brand-400));
  opacity: 0;
  transition: opacity var(--as-transition);
}
.as-stat:hover::before { opacity: 1; }
.as-stat::after {
  content: '';
  position: absolute;
  top: -20px; right: -20px;
  width: 80px; height: 80px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--as-brand-50) 0%, transparent 70%);
  opacity: 0.6;
  pointer-events: none;
}
.as-stat-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--as-text-secondary);
  letter-spacing: 0.01em;
  margin-bottom: 6px;
}
.as-stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--as-text-primary);
  letter-spacing: -0.03em;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}
.as-stat-sub {
  font-size: 12px;
  color: var(--as-text-secondary);
  margin-top: 4px;
}
.as-stat-icon {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 28px;
  height: 28px;
  border-radius: var(--as-radius);
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--as-brand-50), var(--as-brand-100));
  color: var(--as-brand-600);
  box-shadow: 0 1px 3px rgb(99 102 241 / 0.1);
}
.as-stat-icon svg { width: 16px; height: 16px; }

/* ---------- Buttons ---------- */
.as-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--as-radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--as-transition);
  border: 1px solid transparent;
  white-space: nowrap;
  line-height: 1;
}
.as-btn-primary {
  background: linear-gradient(135deg, var(--as-brand-600), var(--as-brand-500));
  color: #fff;
  box-shadow: 0 1px 3px rgb(79 70 229 / 0.3), inset 0 1px 0 rgb(255 255 255 / 0.1);
}
.as-btn-primary:hover {
  background: linear-gradient(135deg, var(--as-brand-700), var(--as-brand-600));
  box-shadow: 0 2px 6px rgb(79 70 229 / 0.4), inset 0 1px 0 rgb(255 255 255 / 0.15);
}
.as-btn-secondary {
  background: var(--as-surface);
  color: var(--as-text-secondary);
  border-color: var(--as-border);
}
.as-btn-secondary:hover {
  background: var(--as-surface-hover);
  border-color: #cbd5e1;
}
.as-btn-ghost {
  background: transparent;
  color: var(--as-text-secondary);
}
.as-btn-ghost:hover {
  background: var(--as-surface-hover);
  color: var(--as-text-primary);
}
.as-btn-sm { padding: 5px 10px; font-size: 12px; }
.as-btn-success {
  background: var(--as-success);
  color: #fff;
}
.as-btn-success:hover { background: #059669; }
.as-btn-danger {
  background: var(--as-error);
  color: #fff;
}
.as-btn-danger:hover { background: #dc2626; }

/* ---------- Badges ---------- */
.as-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.5;
  letter-spacing: 0.01em;
}
.as-badge-blue { background: #eff6ff; color: #1d4ed8; }
.as-badge-green { background: var(--as-success-bg); color: #047857; }
.as-badge-amber { background: var(--as-warning-bg); color: #b45309; }
.as-badge-red { background: var(--as-error-bg); color: #b91c1c; }
.as-badge-purple { background: #f5f3ff; color: #6d28d9; }
.as-badge-gray { background: #f1f5f9; color: #475569; }

/* dot-style badge — softer, Langfuse-like. Text uses the 700 tier of each hue
   so the label clears 4.5:1 on its wash; the 6px dot inherits currentColor and
   only needs 3:1 as a graphic. */
.as-badge-dot {
  padding: 2px 8px 2px 6px;
  background: transparent;
  border: 1px solid var(--as-border);
}
.as-badge-dot::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  margin-right: 5px;
  flex-shrink: 0;
}
.as-badge-dot.as-badge-blue { color: #1d4ed8; background: #eff6ff; border-color: #dbeafe; }
.as-badge-dot.as-badge-green { color: #047857; background: #ecfdf5; border-color: #d1fae5; }
.as-badge-dot.as-badge-amber { color: #b45309; background: #fffbeb; border-color: #fef3c7; }
.as-badge-dot.as-badge-red { color: #b91c1c; background: #fef2f2; border-color: #fee2e2; }
.as-badge-dot.as-badge-purple { color: #6d28d9; background: #f5f3ff; border-color: #ede9fe; }
.as-badge-dot.as-badge-gray { color: #475569; background: #f8fafc; border-color: #e2e8f0; }

/* ---------- Command palette ---------- */
/* The rail carries structure; ⌘K carries speed. A modal is right here: the task
   is do-one-thing-then-gone, and it must not disturb the page underneath. */
.as-palette {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 12vh;
}
.as-palette-scrim {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
}
.as-palette-box {
  position: relative;
  width: min(560px, calc(100vw - 32px));
  background: var(--as-surface);
  border: 1px solid var(--as-border);
  border-radius: var(--as-radius-lg);
  box-shadow: var(--as-shadow-overlay, 0 20px 40px -12px rgb(15 23 42 / 0.35));
  overflow: hidden;
  animation: as-palette-in 120ms cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes as-palette-in {
  from { opacity: 0; transform: translateY(-6px) scale(0.99); }
  to { opacity: 1; transform: none; }
}
.as-palette-input {
  width: 100%;
  padding: 14px 16px;
  border: 0;
  border-bottom: 1px solid var(--as-border);
  font-size: 14px;
  color: var(--as-text-primary);
  background: transparent;
  outline: none;
}
.as-palette-input::placeholder { color: #64748b; }
.as-palette-list {
  list-style: none;
  margin: 0;
  padding: 6px;
  max-height: 44vh;
  overflow-y: auto;
}
.as-palette-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--as-radius-sm);
  font-size: 13px;
  color: var(--as-text-primary);
  cursor: pointer;
}
.as-palette-item.is-active { background: var(--as-brand-50, #eef2ff); color: var(--as-brand-700); }
.as-palette-group {
  flex-shrink: 0;
  min-width: 34px;
  font-size: 11px;
  font-weight: 600;
  color: var(--as-text-secondary);
}
.as-palette-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.as-palette-empty { padding: 12px; font-size: 13px; color: var(--as-text-secondary); }
.as-palette-hint {
  padding: 8px 12px;
  border-top: 1px solid var(--as-border);
  font-size: 11px;
  color: var(--as-text-secondary);
  background: var(--as-surface-hover);
}

/* ---------- Tables ---------- */
.as-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}
.as-table thead th {
  background: var(--as-surface-hover);
  font-weight: 600;
  color: var(--as-text-secondary);
  text-align: left;
  padding: 9px 12px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 2px solid var(--as-border);
  position: sticky;
  top: 0;
  z-index: 1;
  white-space: nowrap;
}
.as-table tbody td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--as-border-light);
  color: var(--as-text-primary);
  vertical-align: middle;
}
.as-table tbody tr:nth-child(even) {
  background: rgba(241, 245, 249, 0.4);
}
.as-table tbody tr {
  transition: background var(--as-transition);
}
.as-table tbody tr:hover {
  background: rgba(99, 102, 241, 0.06);
}
.as-table td[class*="text-right"],
.as-table th[class*="text-right"] {
  font-variant-numeric: tabular-nums;
}
.as-table a { text-decoration: none; }
.as-table tbody tr:hover .as-link { color: var(--as-brand-600); }
.as-table tbody tr:last-child td {
  border-bottom: none;
}

/* ---------- Inputs ---------- */
.as-input {
  border: 1px solid var(--as-border);
  border-radius: var(--as-radius-sm);
  padding: 8px 12px;
  font-size: 13px;
  color: var(--as-text-primary);
  background: var(--as-surface);
  transition: border-color var(--as-transition), box-shadow var(--as-transition);
  outline: none;
  width: 100%;
}
.as-input:focus {
  border-color: var(--as-brand-500);
  box-shadow: 0 0 0 3px rgb(99 102 241 / 0.1);
}
.as-input::placeholder { color: #64748b; }

.as-select {
  border: 1px solid var(--as-border);
  border-radius: var(--as-radius-sm);
  padding: 8px 12px;
  font-size: 13px;
  color: var(--as-text-primary);
  background: var(--as-surface);
  transition: border-color var(--as-transition), box-shadow var(--as-transition);
  outline: none;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}
.as-select:focus {
  border-color: var(--as-brand-500);
  box-shadow: 0 0 0 3px rgb(99 102 241 / 0.1);
}

/* ---------- Sidebar Nav ---------- */
.as-nav-group-label {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  font-size: 11px;
  font-weight: 600;
  color: #94a3b8;
  letter-spacing: 0.06em;
  padding: 4px 12px;
  margin: 12px 0 4px;
  background: transparent;
  border: 0;
  cursor: pointer;
  text-align: left;
  border-radius: var(--as-radius-sm);
  transition: color var(--as-transition), background var(--as-transition);
}
.as-nav-group-label:hover { color: #e2e8f0; background: rgba(148, 163, 184, 0.08); }
.as-nav-group-label:focus-visible { outline: 2px solid var(--as-brand-400); outline-offset: 1px; }
.as-nav-group-caret {
  margin-left: auto;
  width: 6px;
  height: 6px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg) translateY(-2px);
  transition: transform var(--as-transition);
}
.as-nav-group[data-collapsed="true"] .as-nav-group-caret {
  transform: rotate(-45deg) translateY(0);
}
.as-nav-group[data-collapsed="true"] .as-nav-group-items { display: none; }
.as-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--as-radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--as-sidebar-text);
  transition: all var(--as-transition);
  position: relative;
  margin: 1px 8px;
}
.as-nav-item:hover {
  background: var(--as-sidebar-hover);
  color: var(--as-sidebar-text-active);
}
.as-nav-item-active {
  background: var(--as-sidebar-active-bg);
  color: var(--as-sidebar-text-active);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.05);
}
.as-nav-item-active::before {
  content: '';
  position: absolute;
  left: -8px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 20px;
  background: var(--as-sidebar-active-bar);
  border-radius: 0 2px 2px 0;
}
.as-nav-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.7;
}
.as-nav-item-active .as-nav-icon { opacity: 1; }

/* ---------- Section Headers ---------- */
.as-section-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--as-text-primary);
  letter-spacing: -0.01em;
}
.as-page-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--as-text-primary);
  letter-spacing: -0.03em;
  line-height: 1.3;
}

/* ---------- Empty State ---------- */
.as-empty {
  text-align: center;
  padding: 56px 24px;
  color: var(--as-text-muted);
}
.as-empty-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 16px;
  padding: 14px;
  opacity: 0.6;
  background: linear-gradient(135deg, var(--as-brand-50), var(--as-surface-hover));
  border-radius: var(--as-radius-xl);
  color: var(--as-brand-400);
}
.as-empty-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--as-text-secondary);
  margin-bottom: 4px;
}
.as-empty-hint {
  font-size: 12px;
  color: var(--as-text-muted);
}

/* ---------- Misc ---------- */
.as-link {
  color: var(--as-brand-600);
  font-size: 13px;
  transition: color var(--as-transition);
  text-decoration: none;
}
.as-link:hover { color: var(--as-brand-700); text-decoration: underline; }

.as-divider {
  height: 2px;
  background: var(--as-border);
  margin: 16px 0;
  border: none;
}

.as-skeleton {
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
  background-size: 200% 100%;
  animation: as-shimmer 1.5s infinite;
  border-radius: var(--as-radius-sm);
}

@keyframes as-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.as-fade-in {
  animation: as-fade-in 0.2s ease-out;
}
@keyframes as-fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Trace waterfall bar hover */
.as-waterfall-bar {
  transition: opacity var(--as-transition);
  cursor: pointer;
}
.as-waterfall-bar:hover { opacity: 0.85; }

/* Span tree row */
.as-span-row {
  transition: background var(--as-transition), border-color var(--as-transition);
  border-radius: 0;
  margin: 0;
  padding-left: 16px;
  padding-right: 16px;
  border-bottom: 1px solid var(--as-border-light);
  position: relative;
  background: var(--as-surface);
  min-height: 36px;
  padding-top: 8px;
  padding-bottom: 8px;
}
/* Root rows: left accent border */
.as-span-row:not(:has(.as-tree-indent)) {
  border-left: 3px solid var(--as-brand-500);
}
/* Child rows: subtle tint to distinguish from root */
.as-span-row:has(.as-tree-indent) {
  background: rgba(99, 102, 241, 0.025);
}
.as-span-row:hover { background: rgba(99, 102, 241, 0.06); }
html.dark .as-span-row { border-color: var(--as-border); background: var(--as-surface); }
html.dark .as-span-row:not(:has(.as-tree-indent)) { border-left-color: var(--as-brand-400); }
html.dark .as-span-row:has(.as-tree-indent) { background: rgba(99, 102, 241, 0.04); }
html.dark .as-span-row:hover { background: rgba(99, 102, 241, 0.08); }
.as-span-indent {
  display: inline-block;
  width: 16px;
  border-left: 1px solid var(--as-border);
  margin-left: 4px;
  align-self: stretch;
}
 .as-tree-indent {
   display: block;
   width: 52px;
   min-height: 40px;
   align-self: stretch;
   margin-right: 0;
   border-left: 1px solid var(--as-brand-200);
   flex-shrink: 0;
   position: relative;
 }
.as-tree-indent.as-tree-connector::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  width: 38px;
  height: 2px;
  background: var(--as-brand-400);
  transform: translateY(-1px);
  opacity: 1;
}
/* Connection dot */
.as-tree-indent.as-tree-connector::after {
  content: "";
  position: absolute;
  left: 32px;
  top: 50%;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--as-brand-500);
  transform: translateY(-5px);
  box-shadow: 0 0 0 3px var(--as-surface);
}
 html.dark .as-tree-indent { border-left-color: var(--as-brand-700); }
html.dark .as-tree-indent.as-tree-connector::before { background: var(--as-brand-500); }
html.dark .as-tree-indent.as-tree-connector::after { background: var(--as-brand-400); box-shadow: 0 0 0 2px var(--as-surface); }

/* Span tree arrow rotation */
.as-span-row svg { transition: transform 0.15s ease; flex-shrink: 0; }
.as-span-row.as-collapsed svg { transform: rotate(-90deg); }

/* Chart container */
.as-chart {
  background: var(--as-surface);
  border: 1px solid var(--as-border);
  border-radius: var(--as-radius-lg);
  padding: 16px;
  box-shadow: var(--as-shadow-card);
}
.as-waterfall-chart {
  min-width: 0;
  overflow-x: auto;
  overscroll-behavior-x: contain;
}
.as-chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--as-border-light);
  margin: -16px -16px 12px;
  background: linear-gradient(180deg, var(--as-surface-hover), transparent);
  border-radius: var(--as-radius-lg) var(--as-radius-lg) 0 0;
}
.as-chart-header .as-section-title { font-size: 14px; }
/* States the aggregation window next to a chart title, so a number is never
   read against the wrong time base. */
.as-chart-window {
  font-size: 11px;
  font-weight: 600;
  color: var(--as-text-secondary);
  background: var(--as-surface-hover);
  border-radius: 20px;
  padding: 2px 8px;
  margin-left: auto;
}

/* ---------- Top Bar ---------- */
.as-topbar {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 1px 3px 0 rgb(15 23 42 / 0.03);
}

/* ---------- Theme Toggle ---------- */
.as-theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--as-radius-sm);
  color: var(--as-text-secondary);
  cursor: pointer;
  border: none;
  background: transparent;
  transition: all var(--as-transition);
}
.as-theme-toggle:hover {
  background: var(--as-surface-hover);
  color: var(--as-text-primary);
}

/* ---------- Table Sort ---------- */
.as-table thead th.as-th-sort {
  cursor: pointer;
  user-select: none;
  transition: color var(--as-transition);
  white-space: nowrap;
}
.as-table thead th.as-th-sort:hover {
  color: var(--as-brand-600);
}
.as-sort-ind {
  display: inline-flex;
  vertical-align: middle;
  margin-left: 4px;
  opacity: 0.25;
  transition: opacity var(--as-transition);
}
.as-table thead th.as-th-sort:hover .as-sort-ind { opacity: 0.6; }
.as-table thead th.as-sort-asc .as-sort-ind,
.as-table thead th.as-sort-desc .as-sort-ind {
  opacity: 1;
  color: var(--as-brand-600);
}

/* ---------- Server-side sort headers (URL-driven tables) ---------- */
.as-th-sort-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: inherit;
  font-weight: inherit;
  white-space: nowrap;
  transition: color var(--as-transition);
}
.as-th-sort-link:hover {
  color: var(--as-brand-600);
}
.as-th-sort-arrow {
  opacity: 0.3;
  transition: opacity var(--as-transition);
}
.as-th-sort-link:hover .as-th-sort-arrow {
  opacity: 0.6;
}
.as-th-sort-arrow-active {
  opacity: 1;
  color: var(--as-brand-600);
}
.as-th-sort-arrow-muted {
  transform: rotate(180deg);
}

/* ---------- Multica refresh status ---------- */
.as-refresh-msg {
  display: inline-block;
  font-weight: 500;
  color: var(--as-brand-600);
}

/* ---------- Pagination ---------- */
.as-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-top: 1px solid var(--as-border);
  font-size: 13px;
}
.as-pagination-info { font-size: 12px; color: var(--as-text-secondary); }
.as-pagination-ctrl { display: flex; align-items: center; gap: 4px; }
.as-page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 30px;
  padding: 0 8px;
  border-radius: var(--as-radius-sm);
  font-size: 12px;
  font-weight: 500;
  color: var(--as-text-secondary);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--as-transition);
}
.as-page-btn:hover:not(:disabled) {
  background: var(--as-surface-hover);
  color: var(--as-text-primary);
}
.as-page-btn:disabled, .as-page-btn.is-disabled { opacity: 0.4; cursor: not-allowed; }
.as-page-btn.as-page-active {
  background: linear-gradient(135deg, var(--as-brand-600), var(--as-brand-500));
  color: #fff;
  box-shadow: 0 1px 3px rgb(79 70 229 / 0.3);
}

/* ---------- Dark Mode ---------- */
html.dark {
  --as-bg: #0f172a;
  --as-surface: #1e293b;
  --as-surface-hover: #334155;
  --as-border: #334155;
  --as-border-light: #1e293b;
  --as-text-primary: #f1f5f9;
  --as-text-secondary: #94a3b8;
  --as-text-muted: #8b9bb4;
  --as-sidebar-bg: #020617;
  --as-sidebar-hover: #1e293b;
  --as-sidebar-divider: #1e293b;
  --as-success-bg: #052e2b;
  --as-warning-bg: #3b2308;
  --as-error-bg: #2c1414;
  --as-info-bg: #0c1f3a;
}

html.dark body { background: var(--as-bg); color: var(--as-text-primary); }
html.dark .as-topbar { background: rgba(15, 23, 42, 0.85); box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.2); }
html.dark .as-table thead th { background: #1e293b; }
html.dark .as-table tbody tr:nth-child(even) { background: rgba(30, 41, 59, 0.3); }
html.dark .as-table tbody tr:hover { background: rgba(99, 102, 241, 0.08); }
html.dark .as-span-row:hover { background: rgba(99, 102, 241, 0.1); }
html.dark .as-stat-icon { background: linear-gradient(135deg, rgba(99, 102, 241, 0.15), rgba(99, 102, 241, 0.08)); color: #a5b4fc; box-shadow: 0 1px 3px rgb(99 102 241 / 0.15); }
html.dark .as-empty-icon { background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), var(--as-surface-hover)); }
html.dark .as-chart-header { background: linear-gradient(180deg, rgba(30, 41, 59, 0.5), transparent); }
html.dark .as-stat::after { background: radial-gradient(circle, rgba(99, 102, 241, 0.08) 0%, transparent 70%); }

/* Tailwind utility overrides */
html.dark .bg-white { background-color: var(--as-surface); }
html.dark .bg-white\/80 { background-color: rgba(30, 41, 59, 0.8); }
html.dark .bg-slate-50 { background-color: var(--as-bg); }
html.dark .bg-slate-100 { background-color: var(--as-surface-hover); }
html.dark .bg-slate-400 { background-color: #475569; }

html.dark .text-slate-900 { color: var(--as-text-primary); }
html.dark .text-slate-700 { color: var(--as-text-secondary); }
html.dark .text-slate-600 { color: var(--as-text-secondary); }
html.dark .text-slate-500 { color: var(--as-text-secondary); }
html.dark .text-slate-400 { color: var(--as-text-muted); }
html.dark .text-slate-300 { color: var(--as-text-muted); }

html.dark .border-slate-200 { border-color: var(--as-border); }
html.dark .border-slate-100 { border-color: var(--as-border-light); }

html.dark .text-green-600 { color: #34d399; }
html.dark .text-green-700 { color: #6ee7b7; }
html.dark .bg-green-100 { background-color: #052e2b; }
html.dark .text-red-600 { color: #f87171; }

html.dark ::-webkit-scrollbar-thumb { background: #334155; }
html.dark ::-webkit-scrollbar-thumb:hover { background: #475569; }

/* Badge dark overrides */
html.dark .as-badge-blue { background: #1e1b4b; color: #a5b4fc; }
html.dark .as-badge-green { background: #052e2b; color: #6ee7b7; }
html.dark .as-badge-amber { background: #3b2308; color: #fcd34d; }
html.dark .as-badge-red { background: #2c1414; color: #fca5a5; }
html.dark .as-badge-purple { background: #2e1065; color: #c4b5fd; }
html.dark .as-badge-gray { background: #1e293b; color: #94a3b8; }

html.dark .as-skeleton {
  background: linear-gradient(90deg, #1e293b 25%, #334155 50%, #1e293b 75%);
  background-size: 200% 100%;
}

/* ---------- Live indicator ---------- */
/* The sidebar light reflects the WebSocket state instead of glowing green
   unconditionally: a light that is always on cannot tell you the collector died. */
.as-live-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  background: #7c8ba1;
  transition: background var(--as-transition), box-shadow var(--as-transition);
}
#as-live[data-state="live"] { color: #6ee7b7; }
#as-live[data-state="live"] .as-live-dot {
  background: #10b981;
  animation: as-pulse 2s infinite;
}
#as-live[data-state="reconnecting"] { color: #fcd34d; }
#as-live[data-state="reconnecting"] .as-live-dot { background: #f59e0b; }
#as-live[data-state="offline"] { color: #fca5a5; }
#as-live[data-state="offline"] .as-live-dot { background: #ef4444; }

/* ---------- Pulse Animation ---------- */
@keyframes as-pulse {
  0% { box-shadow: 0 0 0 0 rgb(34 197 94 / 0.5); }
  70% { box-shadow: 0 0 0 6px rgb(34 197 94 / 0); }
  100% { box-shadow: 0 0 0 0 rgb(34 197 94 / 0); }
}

/* ---------- Span Detail Panel ---------- */
.span-detail {
  animation: as-fade-in 0.15s ease-out;
}
html.dark .span-detail { background: rgba(15, 23, 42, 0.3) !important; }

/* ---------- Key-Value Grid ---------- */
.as-kv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px 16px;
}
.as-kv-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--as-text-secondary);
  letter-spacing: 0.05em;
  margin-bottom: 2px;
}
.as-kv-value {
  font-size: 13px;
  color: var(--as-text-primary);
}

/* ---------- Code Block ---------- */
.as-code-block {
  font-size: 12px;
  background: var(--as-surface-hover);
  border: 1px solid var(--as-border);
  border-radius: var(--as-radius);
  padding: 12px;
  overflow-x: auto;
  font-family: "JetBrains Mono", "Fira Code", ui-monospace, monospace;
  color: var(--as-text-secondary);
  line-height: 1.5;
}
html.dark .as-code-block { background: rgba(15, 23, 42, 0.5); }

/* ---------- Verdict receipt ---------- */
/* The receipt is the answer to "did that click do anything": verdict pages used
   to POST and silently reload, which is why nobody trusted the button. */
.as-receipt {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  margin-bottom: 12px;
  border: 1px solid #a7f3d0;
  border-radius: var(--as-radius-sm);
  background: var(--as-success-bg);
  color: #065f46;
  font-size: 13px;
  line-height: 1.5;
}
.as-receipt-error {
  margin-top: 4px;
  color: #b91c1c;
  font-weight: 500;
}
html.dark .as-receipt {
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.35);
  color: #6ee7b7;
}

/* ---------- Filter Bar ---------- */
.as-filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
}
.as-filter-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--as-text-secondary);
  margin-bottom: 4px;
  white-space: nowrap;
}
/* Legend for the filter groups: same voice as a label, but it names a block of
   related controls instead of one input. */
.as-filter-legend {
  font-size: 11px;
  font-weight: 600;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0 0 6px;
  border-bottom: 1px solid var(--as-border-light);
  display: block;
  width: 100%;
}

/* ---------- Trace Header ---------- */
.as-trace-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--as-border-light);
}
html.dark .as-trace-header { border-color: var(--as-border); }

/* ---------- Mono ID ---------- */
.as-mono-id {
  font-family: "JetBrains Mono", "Fira Code", ui-monospace, monospace;
  font-size: 12px;
  color: var(--as-text-secondary);
}

/* ---------- Metadata Tag ---------- */
.as-meta-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: "JetBrains Mono", "Fira Code", ui-monospace, monospace;
  font-size: 11px;
  color: var(--as-text-secondary);
  background: var(--as-surface-hover);
  border: 1px solid var(--as-border);
  border-radius: var(--as-radius-sm);
  padding: 1px 6px;
}
html.dark .as-meta-tag { background: rgba(30, 41, 59, 0.5); }

 /* Span tree root grouping */
/* The tree sits inside .as-card, so a root group must not draw a second card:
   no border, no radius, no shadow. Roots are told apart by weight and a leading
   dot instead of a 3px colored bar (which reads as a callout, not a tree). */
.as-span-root {
  margin-bottom: 2px;
}
.as-span-root > .as-span-row {
  background: transparent;
  font-weight: 500;
}
.as-span-root > .as-span-row:hover {
  background: var(--as-surface-hover);
}
.as-span-root > .as-span-row::before {
  content: '';
  position: absolute;
  left: 6px;
  top: 50%;
  width: 4px;
  height: 4px;
  margin-top: -2px;
  border-radius: 50%;
  background: var(--as-brand-500);
}
.as-span-root > div > .as-span-row {
  border-left: 1px solid var(--as-border);
}
html.dark .as-span-root > .as-span-row {
  background: transparent;
}
html.dark .as-span-root > div > .as-span-row {
  border-left-color: var(--as-border);
}
html.dark .as-span-root > div > .as-span-row {
  border-left-color: var(--as-brand-500);
}

/* ---------- Trace Analysis ---------- */
.as-analysis {
  border: 1px solid var(--as-border);
  border-radius: var(--as-radius);
  background: var(--as-surface);
  overflow: hidden;
}
.as-analysis-critical { border-color: rgba(239, 68, 68, 0.35); }
.as-analysis-warning { border-color: rgba(245, 158, 11, 0.35); }
.as-analysis-healthy { border-color: rgba(16, 185, 129, 0.3); }
.as-analysis-status {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 7px;
  border: 1px solid var(--as-border);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}
.as-analysis-status-critical { color: #b91c1c; background: var(--as-error-bg); border-color: #fecaca; }
.as-analysis-status-warning { color: #b45309; background: var(--as-warning-bg); border-color: #fde68a; }
.as-analysis-status-healthy { color: #047857; background: var(--as-success-bg); border-color: #a7f3d0; }
.as-analysis-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--as-border-light);
}
.as-analysis-summary-title {
  color: var(--as-text-primary);
  font-size: 14px;
  font-weight: 650;
}
.as-analysis-summary-note {
  margin-top: 3px;
  color: var(--as-text-secondary);
  font-size: 12px;
}
.as-analysis-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(64px, 1fr));
  gap: 12px;
  min-width: 330px;
}
.as-analysis-metric {
  min-width: 0;
  padding: 0;
  background: transparent;
}
.as-analysis-metric span {
  display: block;
  color: var(--as-text-secondary);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.as-analysis-metric strong {
  display: block;
  margin-top: 2px;
  color: var(--as-text-primary);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.as-analysis-findings { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.as-analysis-finding {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 10px;
  min-width: 0;
  padding: 13px 15px;
  border-bottom: 1px solid var(--as-border-light);
}
.as-analysis-finding:nth-child(odd) { border-right: 1px solid var(--as-border-light); }
.as-analysis-finding-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--as-radius-sm);
}
.as-analysis-finding-critical .as-analysis-finding-icon { color: #dc2626; background: var(--as-error-bg); }
.as-analysis-finding-warning .as-analysis-finding-icon { color: #d97706; background: var(--as-warning-bg); }
.as-analysis-finding-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.as-analysis-finding h3 {
  overflow: hidden;
  color: var(--as-text-primary);
  font-size: 14px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.as-analysis-confidence {
  flex-shrink: 0;
  color: var(--as-text-secondary);
  font-size: 11px;
  font-weight: 600;
}
/* A finding that can point at its own evidence: the title is the link, the jump
   label says what will happen instead of relying on link-colored text alone. */
.as-analysis-finding-link {
  color: inherit;
  text-decoration: none;
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
}
.as-analysis-finding-link:hover .as-analysis-finding-jump {
  text-decoration: underline;
}
.as-analysis-finding-jump {
  font-size: 11px;
  font-weight: 500;
  color: var(--as-brand-600);
  white-space: nowrap;
}
.as-analysis-note-error {
  color: #b91c1c;
  font-weight: 600;
}
/* Span error dot: the color is the signal, the sr-only text is the fallback. */
.as-span-error-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #dc2626;
  display: inline-block;
  flex-shrink: 0;
}
.as-analysis-finding p {
  margin-top: 5px;
  color: var(--as-text-secondary);
  font-size: 13px;
  line-height: 1.5;
}
.as-analysis-finding p strong { color: var(--as-text-primary); font-weight: 600; }
.as-analysis-evidence { color: var(--as-text-primary) !important; font-weight: 550; }
.as-analysis-empty {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 16px;
  color: #047857;
  font-size: 12px;
}
@media (max-width: 900px) {
  .as-analysis-summary { align-items: stretch; flex-direction: column; }
  .as-analysis-metrics { min-width: 0; width: 100%; }
  .as-analysis-findings { grid-template-columns: 1fr; }
  .as-analysis-finding:nth-child(odd) { border-right: 0; }
}
@media (max-width: 540px) {
  .as-sidebar { display: none; }
  .as-main { margin-left: 0; width: 100%; }
  .as-main > main { padding: 16px; }
  .as-page-title { flex-basis: 100%; overflow-wrap: anywhere; }
  .as-analysis-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .as-waterfall-chart { padding: 10px; }
  .as-waterfall-chart > #waterfall { min-width: 0; }
}
html.dark .as-analysis-status-critical { color: #fca5a5; background: rgba(127, 29, 29, 0.22); border-color: rgba(239, 68, 68, 0.4); }
html.dark .as-analysis-status-warning { color: #fcd34d; background: rgba(120, 53, 15, 0.2); border-color: rgba(245, 158, 11, 0.35); }
html.dark .as-analysis-status-healthy { color: #6ee7b7; background: rgba(6, 78, 59, 0.2); border-color: rgba(16, 185, 129, 0.35); }

/* ---------- Span Waterfall (HTML/CSS tree + Gantt) ---------- */
/* Span waterfall (tree + Gantt) */
/* === Waterfall (span timeline) — two-pane Gantt layout === */

/* The waterfall lives inside .as-chart already; a second border+background would
   read as a card inside a card. Keep it a surface, not a container. */
.as-wf {
  overflow: hidden;
  background: transparent;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

/* Toolbar */
.as-wf-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--as-border-light);
  font-size: 11px;
  color: var(--as-text-muted);
  flex-shrink: 0;
}
.as-wf-count { flex-shrink: 0; color: var(--as-text-secondary); }
.as-wf-search {
  flex: 1;
  max-width: 200px;
  border: 1px solid var(--as-border);
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 12px;
  background: var(--as-surface);
  color: var(--as-text-primary);
  outline: none;
  transition: border-color var(--as-transition);
}
.as-wf-search:focus { border-color: var(--as-accent, #6366f1); }
.as-wf-search::placeholder { color: #64748b; }
.as-wf-toolbar-actions { display: flex; gap: 4px; flex-shrink: 0; align-items: center; }
.as-wf-toolbar-btn {
  border: 1px solid var(--as-border);
  border-radius: 4px;
  padding: 3px 10px;
  font-size: 11px;
  background: var(--as-surface);
  color: var(--as-text-secondary);
  cursor: pointer;
  transition: var(--as-transition);
  min-width: 28px;
  text-align: center;
}
.as-wf-toolbar-btn:hover { background: var(--as-surface-hover); color: var(--as-text-primary); }
.as-wf-toolbar-btn.active { border-color: var(--as-accent, #6366f1); color: var(--as-accent, #6366f1); }
.as-wf-zoom-level {
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--as-text-secondary);
  min-width: 36px;
  text-align: center;
  flex-shrink: 0;
}

/* Main: two-pane layout (gutter + chart) */
.as-wf-main {
  display: flex;
  overflow: hidden;
  flex: 1;
  min-height: 0;
}

/* Left pane: name + duration gutter */
.as-wf-left {
  flex-shrink: 0;
  overflow: hidden;
  border-right: 1px solid var(--as-border);
  display: flex;
  flex-direction: column;
}
.as-wf-left-header {
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--as-border);
  background: var(--as-surface-hover);
  flex-shrink: 0;
  overflow: hidden;
}
.as-wf-left-header .as-wf-lname {
  font-size: 11px;
  font-weight: 600;
  color: var(--as-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0 10px;
  display: flex;
  align-items: center;
  height: 100%;
}
.as-wf-left-header .as-wf-ldur {
  font-size: 11px;
  font-weight: 600;
  color: var(--as-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-align: right;
  padding: 0 8px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
}
.as-wf-left-body {
  overflow: hidden;
  flex: 1;
  min-height: 0;
}
.as-wf-left-inner {
  /* translateY driven by chart scroll */
  will-change: transform;
}

/* Left pane rows */
.as-wf-lrow {
  display: flex;
  border-bottom: 1px solid var(--as-border-light);
  transition: background var(--as-transition);
  align-items: center;
  flex-shrink: 0;
}
.as-wf-lrow.alt { background: rgba(99, 102, 241, 0.02); }
.as-wf-lrow.matched { background: rgba(250, 204, 21, 0.08); }
.as-wf-lrow.critical { background: rgba(239, 68, 68, 0.07); }
.as-wf-lname {
  display: flex;
  align-items: center;
  overflow: hidden;
  flex-shrink: 0;
}
.as-wf-name-inner {
  display: flex;
  align-items: center;
  height: 100%;
  position: relative;
  padding-right: 8px;
  overflow: hidden;
}
.as-wf-tree-line {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--as-border);
}
.as-wf-chevron {
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--as-text-muted);
  padding: 0;
  margin-right: 2px;
  transition: transform var(--as-transition), color var(--as-transition);
  transform: rotate(0deg);
}
.as-wf-chevron.expanded { transform: rotate(90deg); }
.as-wf-chevron:hover { color: var(--as-text-primary); }
.as-wf-chevron-spacer { flex-shrink: 0; width: 14px; margin-right: 2px; }
.as-wf-type-dot {
  flex-shrink: 0;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-right: 5px;
}
.as-wf-name {
  font-size: 12px;
  color: var(--as-text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.as-wf-ldur {
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--as-text-secondary);
  text-align: right;
  padding: 0 8px;
  white-space: nowrap;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-shrink: 0;
  height: 100%;
}

/* Right pane: scrollable chart */
.as-wf-right {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.as-wf-right-header {
  overflow: hidden;
  border-bottom: 1px solid var(--as-border);
  background: var(--as-surface-hover);
  flex-shrink: 0;
  position: relative;
}
.as-wf-scale-inner {
  position: relative;
  height: 100%;
  /* translateX driven by chart scroll */
  will-change: transform;
}
.as-wf-tick {
  position: absolute;
  top: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  pointer-events: none;
}
.as-wf-tick span {
  font-size: 11px;
  color: #475569;
  white-space: nowrap;
  transform: translateX(-50%);
  position: absolute;
  left: 0;
  font-variant-numeric: tabular-nums;
}
.as-wf-tick::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--as-border);
}

/* Chart body: the only scroll container (horizontal + vertical) */
.as-wf-right-body {
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-gutter: stable;
  flex: 1;
  min-height: 0;
  position: relative;
  cursor: grab;
  user-select: none;
}
.as-wf-right-body::-webkit-scrollbar { width: 7px; height: 7px; }
.as-wf-right-body::-webkit-scrollbar-thumb { background: var(--as-border); border-radius: 3px; }
.as-wf-right-body::-webkit-scrollbar-track { background: transparent; }
.as-wf-right-body::-webkit-scrollbar-corner { background: transparent; }

/* Bars container (wide track) */
.as-wf-bars {
  position: relative;
}
.as-wf-gridlines {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  z-index: 0;
}
.as-wf-gridline {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--as-border-light);
}

/* Right pane rows */
.as-wf-rrow {
  position: relative;
  border-bottom: 1px solid var(--as-border-light);
  flex-shrink: 0;
}
.as-wf-rrow.alt { background: rgba(99, 102, 241, 0.02); }

/* Bar */
.as-wf-bar {
  position: absolute;
  top: 3px;
  height: 22px;
  border-radius: 4px;
  min-width: 2px;
  cursor: pointer;
  transition: opacity var(--as-transition), filter var(--as-transition);
  display: flex;
  align-items: center;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.12);
  z-index: 1;
}
.as-wf-bar:hover { opacity: 0.85; filter: brightness(1.12); }
.as-wf-bar.error { box-shadow: 0 0 0 1px rgba(239, 68, 68, 0.4), inset 0 0 0 1px rgba(255,255,255,0.12); }
.as-wf-bar.critical { box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.9), inset 0 0 0 1px rgba(255,255,255,0.12); }
.as-wf-bar-label {
  font-size: 11px;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 6px;
  font-weight: 500;
  text-shadow: 0 1px 2px rgba(0,0,0,0.25);
  pointer-events: none;
  flex: 1;
  min-width: 0;
}
.as-wf-bar-dur {
  font-size: 10px;
  color: rgba(255,255,255,0.85);
  white-space: nowrap;
  padding: 0 4px;
  font-weight: 500;
  pointer-events: none;
}

/* Minimap */
.as-wf-minimap {
  position: relative;
  height: 32px;
  border-top: 1px solid var(--as-border);
  background: var(--as-surface-hover);
  cursor: pointer;
  user-select: none;
  flex-shrink: 0;
}
.as-wf-mm-track {
  position: absolute;
  top: 4px;
  left: 0;
  right: 0;
  bottom: 4px;
  overflow: hidden;
}
.as-wf-mm-bar {
  position: absolute;
  top: 0;
  height: 100%;
  min-width: 1px;
  opacity: 0.5;
  border-radius: 1px;
}
.as-wf-mm-viewport {
  position: absolute;
  top: 0;
  bottom: 0;
  border: 1.5px solid var(--as-accent, #6366f1);
  background: rgba(99, 102, 241, 0.08);
  border-radius: 2px;
  pointer-events: none;
}

/* Tooltip */
.as-wf-tooltip {
  position: fixed;
  z-index: 9999;
  background: var(--as-surface);
  border: 1px solid var(--as-border);
  border-radius: var(--as-radius);
  box-shadow: var(--as-shadow-lg);
  padding: 10px 12px;
  pointer-events: none;
  max-width: 320px;
}
.as-wf-tooltip-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--as-text-primary);
  margin-bottom: 6px;
  word-break: break-word;
}
.as-wf-tooltip-grid {
  display: grid;
  grid-template-columns: auto auto;
  gap: 2px 12px;
  font-size: 12px;
}
.as-wf-tooltip-grid span:nth-child(odd) { color: var(--as-text-muted); }
.as-wf-tooltip-grid span:nth-child(even) { color: var(--as-text-primary); font-weight: 500; }
.as-wf-tooltip-error { margin-top: 4px; color: var(--as-error); font-size: 12px; }
.as-wf-tooltip-critical { margin-top: 4px; color: var(--as-error); font-size: 12px; word-break: break-word; }

/* Dark mode */
html.dark .as-wf-lrow.alt { background: rgba(99, 102, 241, 0.04); }
html.dark .as-wf-lrow.matched { background: rgba(250, 204, 21, 0.06); }
html.dark .as-wf-lrow.critical { background: rgba(239, 68, 68, 0.08); }
html.dark .as-wf-gridline { background: rgba(255,255,255,0.04); }
html.dark .as-wf-mm-bar { opacity: 0.4; }

/* Row hover sync (both panes highlighted together) */
.as-wf-lrow.hover, .as-wf-rrow.hover {
  background: rgba(99, 102, 241, 0.08) !important;
}

/* Floating duration label for thin bars */
.as-wf-bar-dur-float {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  color: var(--as-text-secondary);
  white-space: nowrap;
  pointer-events: none;
  font-variant-numeric: tabular-nums;
  z-index: 2;
}

/* Dark mode hover */
html.dark .as-wf-lrow.hover, html.dark .as-wf-rrow.hover {
  background: rgba(99, 102, 241, 0.06) !important;
}

.as-evidence-disclosure {
  overflow: hidden;
}
.as-evidence-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  cursor: pointer;
  list-style: none;
}
.as-evidence-summary::-webkit-details-marker { display: none; }
.as-evidence-summary:hover { background: var(--as-surface-hover); }
.as-evidence-chevron {
  display: inline-block;
  font-size: 20px;
  line-height: 1;
  transition: transform var(--as-transition);
}
.as-evidence-disclosure[open] .as-evidence-chevron { transform: rotate(90deg); }
.as-evidence-table-wrap {
  overflow-x: auto;
  border-top: 1px solid var(--as-border);
}
.as-evidence-table { min-width: 900px; }
.as-evidence-table td:last-child { max-width: 520px; }

@media (max-width: 720px) {
  .as-wf-toolbar { align-items: stretch; flex-wrap: wrap; }
  .as-wf-search { order: 3; max-width: none; width: 100%; flex-basis: 100%; }
  .as-wf-toolbar-actions { margin-left: auto; }
  .as-wf-toolbar-btn { padding-inline: 7px; }
}

@media (max-width: 540px) {
  .as-wf-toolbar-actions { width: 100%; margin-left: 0; overflow-x: auto; }
  .as-wf-toolbar-actions .as-wf-toolbar-btn { flex: 0 0 auto; }
  .as-wf-minimap { height: 28px; }
  .as-evidence-summary { align-items: flex-start; padding: 12px; }
  .as-evidence-table-wrap { overflow: visible; }
  .as-evidence-table,
  .as-evidence-table tbody,
  .as-evidence-table tr,
  .as-evidence-table td {
    display: block;
    min-width: 0;
    width: 100%;
  }
  .as-evidence-table thead { display: none; }
  .as-evidence-table tr { padding: 10px 12px; border-bottom: 1px solid var(--as-border-light); }
  .as-evidence-table tr:last-child { border-bottom: 0; }
  .as-evidence-table td {
    display: grid;
    grid-template-columns: 72px minmax(0, 1fr);
    gap: 8px;
    padding: 5px 0;
    border: 0;
    max-width: none;
  }
  .as-evidence-table td::before {
    content: attr(data-label);
    color: var(--as-text-muted);
    font-family: var(--as-font-sans);
    font-size: 11px;
    font-weight: 600;
  }
}

/* Span evidence-locate: brief flash highlight when a span row is targeted
   via ?span=<id>, fading from the brand tint back to the surface color. */
.as-span-flash {
  animation: as-span-flash 2.2s ease-out;
}
@keyframes as-span-flash {
  0% {
    background: var(--as-brand-100);
    box-shadow: inset 0 0 0 2px var(--as-brand-400);
  }
  100% {
    background: var(--as-surface);
    box-shadow: inset 0 0 0 0 transparent;
  }
}

/* Dismissible top banner shown when an evidence span is not in the display
   range (the trace waterfall caps at 100 span rows). */
.as-span-notice {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--as-warning-bg);
  border: 1px solid var(--as-warning);
  color: #92400e;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}
.as-span-notice-close {
  border: none;
  background: transparent;
  color: inherit;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
}

/* ---- setup wizard ---- */
.setup-page { display: grid; gap: 22px; }
.setup-steps { display: grid; gap: 12px; }
.setup-step {
  display: flex; gap: 14px; align-items: flex-start;
  border: 1px solid var(--hairline, rgba(20,24,28,.10)); border-radius: 14px;
  background: var(--surface, #fff); padding: 16px 18px;
}
.setup-step.done { border-color: color-mix(in srgb, #16a34a 40%, transparent); }
.setup-step.done .setup-step-no { background: #16a34a; color: #fff; }
.setup-step-no {
  flex: none; width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center; font-family: ui-monospace, monospace;
  font-size: 13px; font-weight: 700;
  background: color-mix(in srgb, #6c5ce7 14%, transparent); color: #6c5ce7;
}
.setup-step h3 { margin: 0 0 4px; font-size: 14.5px; font-weight: 650; }
.setup-step p { margin: 0 0 8px; color: var(--ink-2, #4b5563); font-size: 13px; line-height: 1.7; }
.setup-step code { font-family: ui-monospace, monospace; font-size: 12.5px; background: rgba(20,24,28,.05); border-radius: 6px; padding: 1px 5px; }
.setup-tab-bar { display: flex; gap: 6px; border-bottom: 1px solid var(--hairline, rgba(20,24,28,.10)); margin-bottom: 16px; flex-wrap: wrap; }
.setup-tab {
  padding: 8px 14px; border: none; background: none; cursor: pointer;
  font-size: 13.5px; font-weight: 600; color: var(--ink-3, #6b7280);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.setup-tab.active { color: var(--accent, #6c5ce7); border-bottom-color: var(--accent, #6c5ce7); }
.setup-panel p { margin: 0 0 12px; color: var(--ink-2, #4b5563); font-size: 13.5px; line-height: 1.7; }
.setup-panel code { font-family: ui-monospace, monospace; font-size: 12.5px; background: rgba(20,24,28,.05); border-radius: 6px; padding: 1px 5px; }
.setup-code { position: relative; }
.setup-code pre { margin: 0; padding: 14px 16px; font-size: 12.5px; line-height: 1.6; overflow-x: auto; white-space: pre; }
.setup-copy {
  position: absolute; top: 8px; right: 8px; z-index: 2;
  border: 1px solid var(--hairline-strong, rgba(20,24,28,.18)); border-radius: 8px;
  background: var(--surface-raised, #fff); color: var(--ink-2, #4b5563);
  font-size: 12px; padding: 4px 10px; cursor: pointer;
}
.setup-copy:hover { color: var(--ink, #111827); border-color: var(--accent, #6c5ce7); }
.setup-note { font-size: 12.5px; color: var(--ink-3, #6b7280); }
.setup-test-result { margin-left: 10px; font-size: 13px; color: var(--ink-2, #4b5563); }
html.dark .setup-step { background: rgba(17, 24, 39, .55); }
html.dark .setup-step code, html.dark .setup-panel code { background: rgba(255,255,255,.07); }
.setup-install { border: 1px solid var(--hairline-strong, rgba(20,24,28,.18)); border-radius: 10px; padding: 10px 14px; margin-bottom: 14px; background: rgba(108,92,231,.04); }
.setup-install summary { cursor: pointer; font-size: 13.5px; font-weight: 600; color: var(--ink, #111827); list-style-position: inside; }
.setup-install summary:hover { color: var(--accent, #6c5ce7); }
.setup-install-steps { margin: 12px 0 4px; padding-left: 20px; }
.setup-install-steps li { font-size: 13px; color: var(--ink-2, #4b5563); line-height: 1.7; margin-bottom: 10px; }
.setup-install-steps .setup-code { margin: 8px 0; }
html.dark .setup-install { background: rgba(108,92,231,.08); }
.feedback-form { display: flex; flex-direction: column; gap: 12px; max-width: 640px; }
.feedback-field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--ink-2, #4b5563); }
.feedback-field select, .feedback-field textarea, .feedback-field input {
  border: 1px solid var(--hairline-strong, rgba(20,24,28,.18)); border-radius: 8px;
  padding: 8px 10px; font-size: 13.5px; font-family: inherit; background: var(--surface-raised, #fff); color: var(--ink, #111827);
}
.feedback-field textarea { resize: vertical; }
.feedback-table td.feedback-message { max-width: 420px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feedback-badge { font-size: 11.5px; border-radius: 999px; padding: 2px 8px; }
.feedback-badge.forwarded { background: rgba(22,163,74,.12); color: #15803d; }
.feedback-badge.local { background: rgba(107,114,128,.12); color: #6b7280; }
.section-title { font-size: 15px; margin: 20px 0 10px; }
