:root {
  --bg: #f7f7f8;
  --surface: #ffffff;
  --surface-2: #fbfbfc;
  --border: #e4e4e7;
  --text: #18181b;
  --text-muted: #71717a;
  --accent: #4f46e5;
  --accent-text: #ffffff;
  --accent-bg: #eef2ff;
  --pass: #15803d;
  --pass-bg: #f0fdf4;
  --fail: #b91c1c;
  --fail-bg: #fef2f2;
  --pending: #b45309;
  --pending-bg: #fffbeb;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(0,0,0,0.04), 0 2px 12px rgba(0,0,0,0.04);
  --shadow-hover: 0 2px 4px rgba(0,0,0,0.06), 0 6px 20px rgba(0,0,0,0.07);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c0c0e;
    --surface: #17171b;
    --surface-2: #1c1c21;
    --border: #2a2a30;
    --text: #f4f4f5;
    --text-muted: #9a9aa2;
    --accent: #818cf8;
    --accent-text: #0f0f12;
    --accent-bg: #1c1d33;
    --pass: #4ade80;
    --pass-bg: #0f1f14;
    --fail: #f87171;
    --fail-bg: #24100f;
    --pending: #fbbf24;
    --pending-bg: #241d0a;
    --shadow: 0 1px 2px rgba(0,0,0,0.4), 0 2px 12px rgba(0,0,0,0.3);
    --shadow-hover: 0 2px 4px rgba(0,0,0,0.5), 0 8px 24px rgba(0,0,0,0.4);
  }
}

* { box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  margin: 0;
  padding: 0 20px 60px;
  -webkit-font-smoothing: antialiased;
  line-height: 1.45;
}

.wrap { max-width: 780px; margin: 0 auto; }

/* Header */
header.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 26px 0 18px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 10px;
}
header.top h1 { font-size: 18px; font-weight: 700; margin: 0; letter-spacing: -0.015em; }
header.top .badge {
  font-size: 12px; font-weight: 600; color: var(--text-muted); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 999px; padding: 5px 12px;
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 22px;
  margin-bottom: 14px;
  animation: fade-in 0.25s ease;
}
@keyframes fade-in { from { opacity: 0; transform: translateY(2px); } to { opacity: 1; transform: none; } }

.card-title {
  font-size: 12px; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.04em; margin: 0 0 12px;
}

/* KPI / stat tiles */
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.stat-tile { text-align: center; padding: 14px 8px; border-radius: var(--radius-sm); background: var(--surface-2); }
.stat-value { font-size: 24px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; }
.stat-label { font-size: 11.5px; color: var(--text-muted); margin-top: 4px; font-weight: 500; }
.stat-value.pass { color: var(--pass); }
.stat-value.fail { color: var(--fail); }
@media (max-width: 420px) {
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .stat-grid > :first-child { grid-column: 1 / -1; }
}

/* Config rows */
.config-row { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--text); padding: 5px 0; }
.config-row .icon { width: 16px; text-align: center; flex-shrink: 0; opacity: 0.8; }
.config-row a { word-break: break-all; }

/* Run rows */
.run-row { border-left: 3px solid transparent; }
.run-row.passed { border-left-color: var(--pass); }
.run-row.failed { border-left-color: var(--fail); }
.run-row.queued, .run-row.running { border-left-color: var(--pending); }
.run-row-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.run-row .meta { font-size: 12px; color: var(--text-muted); }
.run-row .count { font-weight: 700; font-size: 14.5px; display: flex; align-items: center; gap: 8px; }

.status-icon {
  width: 20px; height: 20px; border-radius: 50%; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 800; color: white; line-height: 1;
}
.status-icon.passed { background: var(--pass); }
.status-icon.failed { background: var(--fail); }
.status-icon.queued, .status-icon.running { background: var(--pending); }

.pulse { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

.progress-bar { height: 6px; border-radius: 999px; background: var(--border); margin-top: 12px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--pending); border-radius: 999px; transition: width 0.5s ease; }

.status-pill {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.02em;
  padding: 3px 10px; border-radius: 999px; display: inline-block;
}
.status-pill.pending { color: var(--pending); background: var(--pending-bg); }
.status-pill.approved { color: var(--pass); background: var(--pass-bg); }
.status-pill.rejected { color: var(--fail); background: var(--fail-bg); }

/* Forms */
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 5px; font-weight: 500; }
input, select, textarea {
  font: inherit;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  color: var(--text);
  width: 100%;
  transition: border-color 0.15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }

button {
  font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer;
  background: var(--accent); color: var(--accent-text);
  border: none; border-radius: var(--radius-sm); padding: 10px 18px;
  transition: opacity 0.15s, transform 0.1s;
}
button:hover:not(:disabled) { opacity: 0.88; }
button:active:not(:disabled) { transform: scale(0.98); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button.secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
button.danger { background: var(--fail); }

.row { display: flex; align-items: center; gap: 8px; }
.step-row { display: grid; grid-template-columns: 130px 1fr 1fr auto; gap: 8px; margin-bottom: 8px; }
@media (max-width: 560px) { .step-row { grid-template-columns: 1fr; } }

/* Run/test/step detail drill-down */
.run-detail { display: none; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.test-item { display: flex; gap: 10px; padding: 8px 0; align-items: flex-start; }
.test-item + .test-item { border-top: 1px solid var(--border); }
.test-icon {
  width: 16px; height: 16px; border-radius: 50%; margin-top: 1px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center; font-size: 9px; font-weight: 800; color: white;
}
.test-icon.passed { background: var(--pass); }
.test-icon.failed, .test-icon.timedOut { background: var(--fail); }
.test-icon.skipped { background: var(--text-muted); }
.test-name { font-size: 13.5px; font-weight: 600; }
.test-error { font-size: 12px; color: var(--fail); margin-top: 3px; }
.step-list { margin: 8px 0 2px 1px; padding-left: 16px; border-left: 2px solid var(--border); }
.step-item { display: flex; gap: 7px; align-items: flex-start; padding: 3px 0; }
.step-icon { width: 12px; height: 12px; border-radius: 50%; margin-top: 3px; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; font-size: 8px; font-weight: 800; color: white; }
.step-icon.passed { background: var(--pass); }
.step-icon.failed { background: var(--fail); }
.step-title { font-size: 12.5px; color: var(--text-muted); }
.step-item.failed .step-title { color: var(--fail); font-weight: 600; }
.step-error { font-size: 11.5px; color: var(--fail); margin-top: 2px; }

#status-line { font-size: 13px; color: var(--text-muted); min-height: 18px; margin-top: 8px; }

/* Empty / loading states */
.empty { color: var(--text-muted); font-size: 13.5px; padding: 14px 4px; text-align: center; }
.skeleton { height: 52px; border-radius: var(--radius-sm); background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 50%, var(--surface-2) 75%); background-size: 200% 100%; animation: shimmer 1.3s infinite; margin-bottom: 8px; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

.section-title { font-size: 12.5px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; margin: 30px 0 10px; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
pre { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px; }
