:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-muted: #64748b;
  --text-faint: #94a3b8;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --danger: #dc2626;
  --warning: #d97706;
  --success: #059669;
  --code: ui-monospace, 'JetBrains Mono', 'SF Mono', Menlo, monospace;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.06), 0 2px 4px -2px rgba(15, 23, 42, 0.04);
}

* { box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  margin: 0;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  position: sticky;
  top: 0;
  z-index: 10;
}

nav .brand {
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--text);
}

nav .brand .project {
  color: var(--text-muted);
  font-weight: 400;
  margin-left: 0.5rem;
  font-size: 0.875rem;
}

nav .links {
  display: flex;
  gap: 0.25rem;
  flex: 1;
}

.project-switcher {
  position: relative;
}

.project-switcher > summary {
  display: inline-flex;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.375rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  font-size: 0.8125rem;
  color: var(--text);
  cursor: pointer;
  list-style: none;
  background: var(--bg);
}

.project-switcher > summary::-webkit-details-marker { display: none; }

.project-switcher > summary:hover {
  border-color: var(--text-faint);
}

.project-switcher[open] > summary {
  border-color: var(--accent);
  color: var(--accent);
}

.project-switcher .proj-label {
  color: var(--text-faint);
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.project-switcher .proj-name {
  font-weight: 600;
}

.project-switcher .proj-repo {
  color: var(--text-muted);
  font-family: var(--code);
  font-size: 0.75rem;
}

.project-switcher .proj-caret {
  color: var(--text-faint);
  font-size: 0.75rem;
}

.project-switcher .proj-menu {
  position: absolute;
  top: calc(100% + 0.375rem);
  right: 0;
  min-width: 240px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  box-shadow: var(--shadow-md);
  padding: 0.25rem;
  z-index: 50;
}

.project-switcher .proj-menu a {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  padding: 0.5rem 0.625rem;
  border-radius: 0.375rem;
  color: var(--text);
  font-size: 0.8125rem;
}

.project-switcher .proj-menu a:hover {
  background: var(--bg);
  text-decoration: none;
}

.project-switcher .proj-menu a.active {
  background: var(--bg);
}

.project-switcher .proj-menu a.active .proj-name {
  color: var(--accent);
}

nav a {
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.375rem 0.75rem;
  border-radius: 0.375rem;
  font-size: 0.875rem;
  transition: all 0.15s;
}

nav a:hover, nav a.active {
  color: var(--text);
  background: var(--bg);
}

main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 2rem 1.5rem 3rem;
}

h1 {
  font-size: 1.5rem;
  margin: 0 0 0.5rem;
  color: var(--text);
  font-weight: 600;
  letter-spacing: -0.01em;
}

h2 {
  font-size: 1rem;
  margin: 2rem 0 1rem;
  color: var(--text);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.subtitle {
  color: var(--text-muted);
  margin: 0 0 2rem;
  font-size: 0.875rem;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin: 0 0 2rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow-sm);
}

.card .label {
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

.card .value {
  font-size: 1.875rem;
  font-weight: 600;
  margin-top: 0.375rem;
  color: var(--text);
  letter-spacing: -0.02em;
}

.card .value.danger { color: var(--danger); }
.card .value.warning { color: var(--warning); }
.card .value.muted { color: var(--text-muted); }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 2rem;
}

.panel-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.panel-body { padding: 1.25rem; }

.chart-container {
  position: relative;
  height: 240px;
}

/* Repo-health: two charts side by side, stacking on narrow viewports. */
.health-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}
@media (max-width: 760px) {
  .health-grid { grid-template-columns: 1fr; }
}
.chart-title {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.unit-toggle {
  font-weight: 400;
  font-size: 0.75rem;
}
.unit-toggle a {
  color: var(--text-faint);
  text-decoration: none;
  padding: 0 0.25rem;
}
.unit-toggle a.active {
  color: var(--accent);
  font-weight: 600;
}

table {
  width: 100%;
  border-collapse: collapse;
}

.panel table {
  border-radius: 0;
}

th, td {
  text-align: left;
  padding: 0.625rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: rgba(241, 245, 249, 0.5); }

th {
  background: rgba(248, 250, 252, 0.5);
  color: var(--text-muted);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}

td .num {
  font-variant-numeric: tabular-nums;
  text-align: right;
}

th.num { text-align: right; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }

td.dim { color: var(--text-faint); font-size: 0.875rem; }

code, .mono {
  font-family: var(--code);
  font-size: 0.8125rem;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover { color: var(--accent-hover); text-decoration: underline; }

a.key {
  color: var(--accent);
  font-family: var(--code);
  font-size: 0.8125rem;
  font-weight: 500;
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 0.25rem;
  padding: 0.125rem 0.5rem;
  font-family: var(--code);
  font-size: 0.75rem;
  margin: 0.125rem 0.25rem 0.125rem 0;
  color: var(--text-muted);
  white-space: nowrap;
}

.tag-chip strong {
  color: var(--text);
  font-weight: 600;
}

/* Category chip: a small solid-colour pill identifying an observation's
   coarse class (network/dependency/test-failure/…). Colour comes from
   parser.CategoryColor via the inline background style. */
.cat-chip {
  display: inline-block;
  vertical-align: middle;
  margin-left: 0.5rem;
  padding: 0.0625rem 0.4375rem;
  border-radius: 0.625rem;
  font-family: var(--code);
  font-size: 0.6875rem;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
}

/* Fix-state badges + dimming for fixed-and-quiet rows ("show fixed" view). */
.badge {
  display: inline-block;
  vertical-align: middle;
  margin-left: 0.375rem;
  padding: 0.0625rem 0.4375rem;
  border-radius: 0.625rem;
  font-size: 0.6875rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge-fixed { background: #dcfce7; color: #166534; }
.badge-regressed { background: #fee2e2; color: #991b1b; }
tr.row-fixed { opacity: 0.5; }
.show-fixed {
  margin-left: auto;
  font-size: 0.8125rem;
}
.show-fixed a { color: var(--text-muted); }

/* Group-page fix controls. */
.fix-bar {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  margin: 0.25rem 0 1rem;
}
.fix-meta { color: var(--text-muted); font-size: 0.8125rem; }
.fix-date {
  border: 1px solid var(--border);
  border-radius: 0.25rem;
  padding: 0.125rem 0.25rem;
  font-size: 0.75rem;
  color: var(--text);
}
.fix-btn {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: 0.375rem;
  padding: 0.25rem 0.75rem;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
}
.fix-btn:hover { background: #f1f5f9; }
.link-btn {
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 0.75rem;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
}
.obs-postfix { border-left: 3px solid #dc2626; }

.tag-chip .dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  flex-shrink: 0;
}

.filter-bar {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  margin: 0 0 1.5rem;
  flex-wrap: wrap;
}

.filter-bar .label {
  color: var(--text-muted);
  font-size: 0.8125rem;
  margin-right: 0.5rem;
}

.filter-pill {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 9999px;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.8125rem;
  text-decoration: none;
  transition: all 0.15s;
}

.filter-pill:hover {
  border-color: var(--text-faint);
  color: var(--text);
}

.filter-pill.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.filter-pill.active:hover {
  background: var(--accent-hover);
  color: white;
  text-decoration: none;
}

.tag-block {
  border-left: 3px solid var(--tag-color, var(--text-faint));
  padding-left: 0.875rem;
}

.tag-block .tag-key {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text);
  font-family: var(--code);
}

.tag-block .tag-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.empty {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(220px, 1.4fr) minmax(80px, 1fr) 70px;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0;
  font-size: 0.875rem;
}

.bar-row .label {
  color: var(--text);
  font-family: var(--code);
  font-size: 0.8125rem;
  /* Wrap long tag values (e.g. test names) so differences stay visible. */
  white-space: normal;
  word-break: break-all;
  line-height: 1.35;
}

.bar-row .bar {
  background: var(--bg);
  border-radius: 0.25rem;
  height: 0.5rem;
  overflow: hidden;
}

.bar-row .bar > div {
  background: var(--accent);
  height: 100%;
  border-radius: 0.25rem;
}

.bar-row .count {
  text-align: right;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  font-size: 0.8125rem;
}

.obs-list { display: flex; flex-direction: column; gap: 1rem; padding: 1.25rem; }

.obs {
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  padding: 0.75rem 1rem;
  background: var(--surface);
}

.obs .when {
  font-family: var(--code);
  color: var(--text-muted);
  font-size: 0.8125rem;
  margin-right: 0.75rem;
}

.obs .job {
  color: var(--text);
  font-family: var(--code);
  font-size: 0.8125rem;
  margin-top: 0.375rem;
}

.obs .tags { margin-top: 0.5rem; }

.log-meta {
  margin-bottom: 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.log-meta strong {
  color: var(--text);
  font-weight: 600;
}

pre.log {
  background: #0f172a;
  color: #e2e8f0;
  padding: 1rem;
  border-radius: 0.5rem;
  overflow-x: auto;
  font-family: var(--code);
  font-size: 0.75rem;
  line-height: 1.5;
  white-space: pre;
  max-height: 80vh;
  margin: 0;
}

pre.log .line-num {
  color: #475569;
  user-select: none;
  display: inline-block;
  width: 4em;
  padding-right: 0.5em;
  text-align: right;
}

pre.log .error { color: #fca5a5; }
pre.log .group { color: #93c5fd; }
pre.log .annotation { color: #c4b5fd; }

/* Wrap each rendered line in a span so we can target individual lines via #L<n>
   and apply the evidence highlight without breaking the monospace layout. */
pre.log .log-line { display: block; }

pre.log .evidence {
  background: rgba(252, 211, 77, 0.18);
  box-shadow: inset 3px 0 0 #fbbf24;
}
pre.log .evidence.error,
pre.log .evidence .error { color: #fde68a; }

.btn {
  display: inline-block;
  padding: 0.375rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  color: var(--text);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s;
}

.btn:hover { background: var(--bg); border-color: var(--text-faint); }

.day-banner {
  background: #fef3c7;
  border: 1px solid #fcd34d;
  border-radius: 0.5rem;
  padding: 0.625rem 1rem;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.875rem;
  color: #78350f;
}

.day-banner a {
  color: #78350f;
  font-weight: 500;
  border-bottom: 1px solid currentColor;
}

.day-banner a:hover { text-decoration: none; opacity: 0.8; }

/* Footer stamp injected into the static (GitHub Pages) export only. */
.static-footer {
  margin: 2rem 0 1rem;
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-faint);
}
