:root {
  color-scheme: light;
  --bg: #f7f8f5;
  --surface: #ffffff;
  --surface-2: #f0f3ef;
  --ink: #1e2420;
  --muted: #667066;
  --line: #d9dfd6;
  --accent: #16866f;
  --accent-2: #2d6f9f;
  --warn: #a76c00;
  --bad: #b33b3b;
  --good: #1f8a4c;
  --shadow: 0 18px 50px rgba(37, 45, 38, 0.10);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  min-height: 40px;
  padding: 0 14px;
  border-radius: 8px;
  cursor: pointer;
}

button:hover {
  border-color: #aeb8aa;
}

input {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #fff;
  color: var(--ink);
}

.app-shell {
  width: min(1500px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.topbar,
.selected-run,
.panel-heading,
.auth-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar {
  margin-bottom: 18px;
}

.topbar h1,
.selected-run h2 {
  margin: 0;
  letter-spacing: 0;
}

.topbar h1 {
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.muted {
  color: var(--muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.live-pill,
.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 12px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.live-pill span {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--warn);
}

.live-pill.ok span {
  background: var(--good);
}

.live-pill.bad span {
  background: var(--bad);
}

.auth-row {
  margin-bottom: 18px;
  padding: 12px;
  background: #fff8e5;
  border: 1px solid #edd79b;
  border-radius: 8px;
}

.auth-row label {
  font-weight: 800;
  white-space: nowrap;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.runs-panel,
.detail-panel,
.chart-panel,
.table-panel,
.metric,
.selected-run {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.runs-panel {
  position: sticky;
  top: 18px;
  max-height: calc(100vh - 36px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.panel-heading {
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.panel-heading.compact {
  padding-bottom: 10px;
}

.panel-heading h2,
.panel-heading h3 {
  margin: 0;
  font-size: 16px;
}

.runs-list {
  overflow: auto;
  padding: 8px;
}

.run-item {
  width: 100%;
  text-align: left;
  display: block;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 8px;
  padding: 12px;
  min-height: 82px;
}

.run-item:hover,
.run-item.active {
  background: var(--surface-2);
  border-color: var(--line);
}

.run-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.run-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 800;
}

.run-meta {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.detail-panel {
  padding: 16px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.metric {
  padding: 14px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 26px;
}

.selected-run {
  padding: 16px;
  margin-bottom: 14px;
}

.selected-run p:last-child {
  margin-bottom: 0;
}

.split {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.bars {
  padding: 14px;
  display: grid;
  gap: 10px;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(80px, 1fr) minmax(120px, 2fr) 42px;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.bar-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
}

.bar-track {
  height: 10px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

.table-panel {
  margin-top: 14px;
  overflow: hidden;
}

.table-wrap {
  overflow: auto;
  max-height: 470px;
}

.compact-wrap {
  max-height: 260px;
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 13px;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 8px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.tag.good {
  background: #e3f4e7;
  color: var(--good);
}

.tag.bad {
  background: #fae5e3;
  color: var(--bad);
}

.tag.warn {
  background: #fff0cc;
  color: var(--warn);
}

.link-button {
  border: 0;
  background: transparent;
  min-height: 0;
  padding: 0;
  color: var(--accent-2);
  font-weight: 800;
  text-align: left;
  cursor: pointer;
}

.link-button:hover {
  text-decoration: underline;
}

.mono {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 12px;
}

.events-list {
  display: grid;
  gap: 8px;
  padding: 12px;
  max-height: 260px;
  overflow: auto;
}

.event-row {
  display: grid;
  grid-template-columns: 150px 130px 1fr;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  font-size: 12px;
}

.empty {
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 980px) {
  .app-shell {
    padding: 16px;
  }

  .dashboard-grid,
  .split {
    grid-template-columns: 1fr;
  }

  .runs-panel {
    position: static;
    max-height: 360px;
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .topbar,
  .selected-run,
  .auth-row {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 620px) {
  .metric-grid {
    grid-template-columns: 1fr;
  }

  .event-row {
    grid-template-columns: 1fr;
  }
}
