/* ============================================================ */
/* Design tokens — light + dark, single source of truth          */
/* ============================================================ */
:root {
  --bg:          #f8fafc;
  --surface:    #ffffff;
  --surface-2:  #f1f5f9;
  --border:     #e2e8f0;
  --border-strong: #cbd5e1;
  --fg:         #0f172a;
  --muted:      #64748b;
  --subtle:     #94a3b8;

  --primary:    #6366f1;
  --primary-hover: #4f46e5;
  --primary-tint:  rgba(99, 102, 241, 0.08);

  --pass:       #059669;
  --pass-bg:    rgba(16, 185, 129, 0.14);
  --fail:       #dc2626;
  --fail-bg:    rgba(239, 68, 68, 0.14);
  --pending:    #d97706;
  --pending-bg: rgba(245, 158, 11, 0.16);

  --shadow-sm:  0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md:  0 4px 12px rgba(15, 23, 42, 0.08), 0 1px 3px rgba(15, 23, 42, 0.04);
  --shadow-lg:  0 12px 32px rgba(15, 23, 42, 0.10), 0 2px 6px rgba(15, 23, 42, 0.04);

  --radius-sm:  6px;
  --radius:     10px;
  --radius-lg:  14px;

  --header-gradient: linear-gradient(135deg, rgba(99,102,241,0.08) 0%, rgba(168,85,247,0.06) 50%, rgba(236,72,153,0.05) 100%);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:          #0b1220;
    --surface:    #111a2e;
    --surface-2:  #182238;
    --border:     #243049;
    --border-strong: #334155;
    --fg:         #f1f5f9;
    --muted:      #94a3b8;
    --subtle:     #64748b;

    --primary:    #818cf8;
    --primary-hover: #a5b4fc;
    --primary-tint:  rgba(129, 140, 248, 0.12);

    --pass:       #34d399;
    --pass-bg:    rgba(16, 185, 129, 0.18);
    --fail:       #f87171;
    --fail-bg:    rgba(239, 68, 68, 0.18);
    --pending:    #fbbf24;
    --pending-bg: rgba(245, 158, 11, 0.18);

    --shadow-sm:  0 1px 2px rgba(0,0,0,0.4);
    --shadow-md:  0 4px 12px rgba(0,0,0,0.4), 0 1px 3px rgba(0,0,0,0.2);
    --shadow-lg:  0 12px 32px rgba(0,0,0,0.45), 0 2px 6px rgba(0,0,0,0.2);

    --header-gradient: linear-gradient(135deg, rgba(99,102,241,0.18) 0%, rgba(168,85,247,0.12) 50%, rgba(236,72,153,0.08) 100%);
  }
}

/* ============================================================ */
/* Reset + base                                                  */
/* ============================================================ */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font: 14px/1.55 "Inter", -apple-system, system-ui, "Segoe UI", Roboto, sans-serif;
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
a { color: var(--primary); text-decoration: none; transition: color 0.15s; }
a:hover { color: var(--primary-hover); text-decoration: underline; }
code, .mono {
  font: 12.5px/1.4 ui-monospace, "JetBrains Mono", "SF Mono", Consolas, monospace;
}

/* ============================================================ */
/* Layout                                                        */
/* ============================================================ */
header {
  background: var(--surface);
  background-image: var(--header-gradient);
  border-bottom: 1px solid var(--border);
  padding: 1.5rem 2rem;
  box-shadow: var(--shadow-sm);
}
header .header-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.015em;
}
header .sub {
  color: var(--muted);
  font-size: 0.875rem;
}
/* Prominent breadcrumb-style back link on detail pages. */
header .back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  align-self: flex-start;
  padding: 0.4rem 0.85rem 0.4rem 0.65rem;
  margin: -0.1rem 0 0.35rem -0.65rem;
  color: var(--primary);
  background: var(--primary-tint);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.82rem;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
}
header .back-link:hover {
  background: var(--primary-tint);
  border-color: var(--primary);
  color: var(--primary-hover);
  text-decoration: none;
}
header .back-link:active { transform: translateY(1px); }
header .back-link .arrow {
  font-size: 1rem;
  line-height: 1;
  transition: transform 0.15s;
}
header .back-link:hover .arrow { transform: translateX(-2px); }

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
}
main > section + section { margin-top: 2rem; }
h2 {
  font-size: 1.025rem;
  font-weight: 600;
  margin: 0 0 0.75rem;
  letter-spacing: -0.005em;
  color: var(--fg);
}
.muted { color: var(--muted); }
.subtle { color: var(--subtle); font-size: 0.825rem; }

/* ============================================================ */
/* Buttons + actions                                             */
/* ============================================================ */
.actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}
button, .btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: var(--primary);
  color: white;
  border: 0;
  padding: 0.6rem 1.1rem;
  border-radius: var(--radius-sm);
  font: 600 0.875rem/1 "Inter", system-ui, sans-serif;
  cursor: pointer;
  transition: background 0.15s, transform 0.05s, box-shadow 0.15s;
  box-shadow: var(--shadow-sm);
  text-decoration: none;
}
button:hover, .btn:hover {
  background: var(--primary-hover);
  box-shadow: var(--shadow-md);
  text-decoration: none;
  color: white;
}
button:active, .btn:active { transform: translateY(1px); }
button:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn-ghost {
  background: transparent;
  color: var(--primary);
  box-shadow: none;
  border: 1px solid var(--border-strong);
}
.btn-ghost:hover { background: var(--primary-tint); color: var(--primary-hover); box-shadow: none; }

/* Compact button used inside table cells. */
.btn-sm {
  padding: 0.38rem 0.75rem;
  font-size: 0.78rem;
  font-weight: 600;
}

/* ============================================================ */
/* Stat cards                                                    */
/* ============================================================ */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.85rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  box-shadow: var(--shadow-sm);
}
.stat-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 600;
}
.stat-value {
  font: 700 1.6rem/1.1 "Inter", sans-serif;
  margin-top: 0.25rem;
  letter-spacing: -0.02em;
}
.stat-value.pass { color: var(--pass); }
.stat-value.fail { color: var(--fail); }
.stat-value.pending { color: var(--pending); }
.stat-card .stat-extra {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 0.2rem;
}

/* ============================================================ */
/* Tables                                                        */
/* ============================================================ */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
table {
  width: 100%;
  border-collapse: collapse;
}
th, td {
  text-align: left;
  padding: 0.65rem 0.95rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
th {
  background: var(--surface-2);
  font-weight: 600;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
tbody tr {
  transition: background 0.12s;
}
tbody tr:hover {
  background: var(--primary-tint);
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr.log-row { background: var(--surface-2); }
tbody tr.log-row:hover { background: var(--surface-2); }
tbody tr.log-row td { padding: 0.6rem 0.95rem 1rem; }

td.id { width: 110px; }
td.id code { color: var(--fg); font-weight: 600; }
td.cls { color: var(--muted); }
td.cls.match { color: var(--fg); font-weight: 500; }
td.dur { width: 130px; }
td.actions-cell { width: 130px; text-align: right; }

/* ============================================================ */
/* Badges                                                        */
/* ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.22rem 0.6rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}
.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 3px currentColor;
  filter: opacity(0.2);
}
.badge.pass { background: var(--pass-bg); color: var(--pass); }
.badge.fail { background: var(--fail-bg); color: var(--fail); }
.badge.pending { background: var(--pending-bg); color: var(--pending); }
.badge.pending::before { animation: pulse 1.6s ease-in-out infinite; }

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50%      { transform: scale(1.4); opacity: 0.5; }
}

/* ============================================================ */
/* Latency bar (inline in duration cell)                         */
/* ============================================================ */
.lat {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}
.lat .lat-text {
  font: 500 0.78rem/1 ui-monospace, "JetBrains Mono", monospace;
  color: var(--muted);
  min-width: 42px;
  text-align: right;
}
.lat .lat-bar {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: var(--surface-2);
  overflow: hidden;
  max-width: 80px;
}
.lat .lat-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary) 0%, #a855f7 100%);
  transition: width 0.3s ease;
}

/* ============================================================ */
/* Ticket link                                                   */
/* ============================================================ */
.ticket-link {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font: 500 0.82rem/1 ui-monospace, "JetBrains Mono", monospace;
  color: var(--primary);
}
.ticket-link .ext { font-size: 0.75em; opacity: 0.65; }

/* ============================================================ */
/* Log expander                                                  */
/* ============================================================ */
.toggle {
  background: transparent;
  color: var(--primary);
  padding: 0.3rem 0.65rem;
  font-weight: 500;
  font-size: 0.78rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: none;
}
.toggle:hover {
  background: var(--primary-tint);
  color: var(--primary-hover);
  box-shadow: none;
}
pre.log {
  background: #0b1220;
  color: #e2e8f0;
  font: 11.5px/1.5 ui-monospace, "JetBrains Mono", "SF Mono", monospace;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  max-height: 360px;
  margin: 0;
  border: 1px solid #1e293b;
}

/* ============================================================ */
/* Empty / loading states                                        */
/* ============================================================ */
.empty {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--muted);
  font-size: 0.9rem;
}
.empty .hint { display: block; margin-top: 0.35rem; font-size: 0.82rem; color: var(--subtle); }

/* ============================================================ */
/* Run row entrance animation                                    */
/* ============================================================ */
tbody tr {
  animation: rowIn 0.25s ease both;
}
@keyframes rowIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
tbody tr.log-row { animation: none; }

/* ============================================================ */
/* Live indicator                                                */
/* ============================================================ */
.live-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--pending);
  box-shadow: 0 0 0 0 var(--pending);
  animation: liveBeat 1.4s ease-in-out infinite;
  margin-right: 0.4rem;
  vertical-align: middle;
}
@keyframes liveBeat {
  0%, 100% { box-shadow: 0 0 0 0 var(--pending-bg); }
  50%      { box-shadow: 0 0 0 6px transparent; }
}
