/* ── Traces tab ──────────────────────────────────────────────── */
#tab-traces { flex-direction: column; width: 100%; }
.traces-header { margin-bottom: 16px; width: 100%; display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.traces-header h2 { margin: 0; font-size: 20px; }
.traces-header p { color: var(--text-dim); font-size: 13px; margin: 0; }
.traces-header code { font-size: 12px; background: var(--border); padding: 1px 6px; border-radius: 3px; }
.traces-count { font-weight: 700; color: var(--text); margin-left: 8px; }
.traces-refresh { background: none; border: 1px solid var(--border); border-radius: 6px; padding: 4px 10px; cursor: pointer; font-size: 13px; color: var(--text-dim); transition: all 0.15s; margin-left: auto; }
.traces-refresh:hover { border-color: var(--accent, #3b82f6); color: var(--text); }

/* Filters — horizontal inline pills */
#traces-filters { width: 100%; display: flex; flex-wrap: wrap; gap: 8px 24px; padding: 10px 14px; background: var(--card-bg, var(--bg)); border: 1px solid var(--border); border-radius: 8px; margin-bottom: 14px; box-sizing: border-box; }
.traces-filter-row { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 6px; }
.traces-filter-inner > .traces-filter-row:nth-child(1) { background: rgba(59,130,246,0.07); }
.traces-filter-inner > .traces-filter-row:nth-child(2) { background: rgba(168,85,247,0.07); }
.traces-filter-inner > .traces-filter-row:nth-child(3) { background: rgba(234,179,8,0.07); }
.traces-filter-inner > .traces-filter-row:nth-child(4) { background: rgba(34,197,94,0.07); }
.traces-filter-inner > .traces-filter-row:nth-child(5) { background: rgba(244,114,82,0.07); }
[data-theme="dark"] .traces-filter-inner > .traces-filter-row:nth-child(1) { background: rgba(59,130,246,0.12); }
[data-theme="dark"] .traces-filter-inner > .traces-filter-row:nth-child(2) { background: rgba(168,85,247,0.12); }
[data-theme="dark"] .traces-filter-inner > .traces-filter-row:nth-child(3) { background: rgba(234,179,8,0.12); }
[data-theme="dark"] .traces-filter-inner > .traces-filter-row:nth-child(4) { background: rgba(34,197,94,0.12); }
[data-theme="dark"] .traces-filter-inner > .traces-filter-row:nth-child(5) { background: rgba(244,114,82,0.12); }
.traces-filter-row label { font-size: 11px; font-weight: 700; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; white-space: nowrap; }
.traces-pills { display: inline-flex; gap: 3px; flex-wrap: wrap; }
.traces-pills .filter-item { font-size: 12px; padding: 3px 10px; border-radius: 12px; border: 1px solid var(--border); background: transparent; color: var(--text-dim); cursor: pointer; transition: all 0.15s; white-space: nowrap; }
.traces-pills .filter-item:hover { border-color: var(--accent, #3b82f6); color: var(--text); }
.traces-pills .filter-item.active { background: var(--accent, #3b82f6); color: #fff; border-color: var(--accent, #3b82f6); }

/* Date filter */
.traces-date-row { flex-wrap: wrap; }
.traces-date-range { display: inline-flex; align-items: center; gap: 6px; margin-left: 4px; }
.traces-date-input { font-size: 12px; padding: 3px 8px; border-radius: 6px; border: 1px solid var(--border); background: var(--card-bg, var(--bg)); color: var(--text); font-family: inherit; }
.traces-date-input:focus { outline: none; border-color: var(--accent, #3b82f6); }

/* Table — full width */
#traces-list { width: 100%; }
.traces-table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 8px; width: 100%; }
.traces-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.traces-table th { text-align: left; padding: 10px 12px; background: var(--card-bg, var(--bg)); border-bottom: 2px solid var(--border); font-size: 11px; font-weight: 700; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.6px; white-space: nowrap; }
.traces-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.traces-table tbody tr:last-child td { border-bottom: none; }
.trace-row { cursor: pointer; transition: background 0.15s; }
.trace-row:nth-child(4n+1) { background: rgba(0,0,0,0.02); }
.trace-row:hover { background: rgba(59,130,246,0.06); }
.trace-row.expanded { background: rgba(59,130,246,0.08); }
[data-theme="dark"] .trace-row:nth-child(4n+1) { background: rgba(255,255,255,0.03); }
.trace-time { white-space: nowrap; font-size: 12px; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.trace-task { max-width: 45vw; line-height: 1.4; }

/* Status badges */
.trace-status { display: inline-block; padding: 3px 10px; border-radius: 12px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.3px; }
.trace-success { background: #dcfce7; color: #15803d; }
.trace-error { background: #fee2e2; color: #b91c1c; }
.trace-partial { background: #fef9c3; color: #a16207; }

/* Type labels */
.trace-type-error { color: #dc2626; font-weight: 600; }
.trace-type-start { color: #2563eb; font-weight: 500; }

/* Expanded detail */
.trace-detail td { padding: 0 12px 12px !important; border-bottom: 2px solid var(--border) !important; }
.trace-detail-inner { padding: 14px 18px; font-size: 13px; line-height: 1.8; background: linear-gradient(135deg, rgba(59,130,246,0.03), rgba(59,130,246,0.06)); border-radius: 8px; border-left: 3px solid var(--accent, #3b82f6); }
.trace-detail-inner div { margin-bottom: 5px; }
.trace-detail-inner strong { color: var(--text-dim); font-size: 12px; text-transform: uppercase; letter-spacing: 0.3px; }
.trace-detail-inner code { background: var(--border); padding: 2px 7px; border-radius: 4px; font-size: 12px; }

/* Dark mode */
[data-theme="dark"] .trace-success { background: rgba(34,197,94,0.18); color: #4ade80; }
[data-theme="dark"] .trace-error { background: rgba(239,68,68,0.18); color: #f87171; }
[data-theme="dark"] .trace-partial { background: rgba(234,179,8,0.18); color: #facc15; }

/* Mobile: collapsible filters */
@media (max-width: 768px) {
  #traces-filters { flex-direction: column; gap: 0; padding: 0; border: none; background: none; }
  .traces-filter-toggle { display: block; width: 100%; text-align: center; padding: 8px; font-weight: 600; font-size: 13px; border: 1px solid var(--border); border-radius: 8px; background: var(--card-bg, var(--bg)); cursor: pointer; margin-bottom: 8px; color: var(--text); }
  .traces-filter-inner { padding: 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--card-bg, var(--bg)); }
  .traces-filter-row { flex-wrap: wrap; margin-bottom: 6px; }
  .traces-table { font-size: 12px; }
  .traces-table th, .traces-table td { padding: 8px 6px; }
  .trace-task { max-width: 40vw; font-size: 12px; }
  .trace-detail-inner { padding: 10px 12px; font-size: 12px; }
  .traces-header { flex-direction: column; gap: 4px; }
}

/* Desktop hide mobile toggle */
@media (min-width: 769px) {
  .traces-filter-toggle { display: none; }
}