:root {
  --background: #f5f5f4;
  --surface: #ffffff;
  --surface-subtle: #fafaf9;
  --foreground: #171717;
  --secondary: #525252;
  --muted: #737373;
  --border: #d6d3d1;
  --border-strong: #a8a29e;
  --accent: #a16207;
  --accent-hover: #854d0e;
  --focus: #075985;
  --error: #b91c1c;
  --shadow: 0 1px 2px rgb(23 23 23 / 0.06), 0 8px 30px rgb(23 23 23 / 0.05);
  --radius: 10px;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  font-size: 16px;
}

body {
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  font-family: var(--sans);
  line-height: 1.5;
}

a {
  color: inherit;
}

button,
input,
select {
  font: inherit;
}

button,
select,
input,
a {
  transition: border-color 160ms ease, background-color 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--focus) 35%, transparent);
  outline-offset: 2px;
}

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 100;
  padding: 8px 12px;
  transform: translateY(-160%);
  background: var(--foreground);
  color: white;
}

.skip-link:focus {
  transform: translateY(0);
}

.site-header {
  display: flex;
  min-height: 64px;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  border-bottom: 1px solid var(--border);
  background: rgb(255 255 255 / 0.94);
}

.brand,
.login-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--foreground);
  text-decoration: none;
  letter-spacing: -0.02em;
}

.brand-mark {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 4px solid var(--foreground);
  border-top-color: var(--accent);
  border-radius: 50%;
}

.page-shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 40px 32px 72px;
}

.page-heading,
.run-heading,
.panel-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  font-size: clamp(2rem, 4vw, 3.8rem);
  line-height: 1;
  letter-spacing: -0.055em;
}

h2 {
  margin-bottom: 0;
  font-size: 1.6rem;
  letter-spacing: -0.03em;
}

.eyebrow {
  margin-bottom: 8px;
  color: var(--accent-hover);
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.lede {
  max-width: 62ch;
  color: var(--secondary);
  font-size: 1.05rem;
}

.lede.compact {
  margin-bottom: 4px;
  font-size: 0.925rem;
}

.muted {
  color: var(--muted);
  font-size: 0.78rem;
}

.button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: 7px;
  cursor: pointer;
  font-weight: 650;
  text-decoration: none;
}

.button-primary {
  border-color: var(--foreground);
  background: var(--foreground);
  color: white;
}

.button-primary:hover {
  background: #303030;
}

.button-quiet {
  border-color: var(--border);
  background: var(--surface);
  color: var(--foreground);
}

.button-quiet:hover {
  border-color: var(--border-strong);
  background: var(--surface-subtle);
}

.filter-bar {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(220px, 1.4fr) minmax(160px, 0.8fr) auto auto;
  gap: 12px;
  align-items: end;
  margin: 32px 0 20px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

label {
  display: grid;
  gap: 6px;
  color: var(--secondary);
  font-size: 0.78rem;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  background: var(--surface);
  color: var(--foreground);
}

input:hover,
select:hover {
  border-color: var(--foreground);
}

.table-frame {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
}

caption {
  padding: 12px 16px;
  color: var(--secondary);
  font-weight: 700;
  text-align: left;
}

th,
td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}

th {
  background: var(--surface-subtle);
  color: var(--secondary);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.runs-table tbody tr:hover {
  background: #fafaf9;
}

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

.row-link,
.back-link {
  color: #075985;
  font-weight: 700;
  text-underline-offset: 3px;
}

.pagination {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 16px;
  align-items: center;
  margin-top: 20px;
  color: var(--secondary);
  font-size: 0.875rem;
}

.pagination > :last-child {
  justify-self: end;
}

.empty-state {
  padding: 72px 24px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  color: var(--secondary);
  text-align: center;
}

.empty-state.compact {
  padding: 32px 20px;
}

.empty-state h2,
.empty-state h3 {
  margin-bottom: 6px;
  color: var(--foreground);
}

.back-link {
  display: inline-block;
  margin-bottom: 28px;
}

.heading-separator {
  color: var(--border-strong);
  font-weight: 300;
}

.stat-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 28px 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.stat-strip div {
  padding: 16px 20px;
  border-right: 1px solid var(--border);
}

.stat-strip div:last-child {
  border-right: 0;
}

dt {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

dd {
  margin: 3px 0 0;
  font-weight: 700;
}

.telemetry-panel {
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.plot-controls {
  display: grid;
  width: min(620px, 100%);
  grid-template-columns: 1fr 1.35fr auto;
  gap: 12px;
  align-items: end;
}

.plot {
  width: 100%;
  min-height: 320px;
  margin-top: 20px;
  overflow: hidden;
}

.u-legend {
  font-family: var(--mono);
  font-size: 0.76rem;
}

.status-message {
  padding: 32px;
  color: var(--secondary);
  text-align: center;
}

.summary-frame {
  margin-top: 12px;
  box-shadow: none;
}

.artifact-details {
  margin-top: 20px;
  padding: 14px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.artifact-details summary {
  cursor: pointer;
  font-weight: 700;
}

.artifact-details dl {
  display: grid;
  gap: 12px;
  margin-bottom: 0;
}

.checksum {
  overflow-wrap: anywhere;
}

.login-panel {
  width: min(520px, 100%);
  margin: 8vh auto 0;
  padding: 36px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-brand {
  margin-bottom: 56px;
  font-weight: 700;
}

.login-form {
  display: grid;
  gap: 14px;
  margin-top: 28px;
}

.field-help,
.field-error {
  margin: -6px 0 0;
  font-size: 0.78rem;
  font-weight: 400;
}

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

.field-error {
  color: var(--error);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 900px) {
  .filter-bar {
    grid-template-columns: 1fr 1fr;
  }

  .stat-strip {
    grid-template-columns: 1fr 1fr;
  }

  .stat-strip div:nth-child(2) {
    border-right: 0;
  }

  .stat-strip div:nth-child(-n + 2) {
    border-bottom: 1px solid var(--border);
  }
}

@media (max-width: 640px) {
  .site-header {
    padding: 0 16px;
  }

  .page-shell {
    padding: 28px 16px 56px;
  }

  .page-heading,
  .run-heading,
  .panel-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .filter-bar,
  .plot-controls {
    grid-template-columns: 1fr;
  }

  .runs-table thead {
    display: none;
  }

  .runs-table tr,
  .runs-table td {
    display: block;
  }

  .runs-table tr {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
  }

  .runs-table tr:last-child {
    border-bottom: 0;
  }

  .runs-table td {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 5px 0;
    border: 0;
    white-space: normal;
    text-align: right;
  }

  .runs-table td[data-label]::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
  }

  #series-summary thead {
    display: none;
  }

  #series-summary tr,
  #series-summary td {
    display: block;
  }

  #series-summary tr {
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
  }

  #series-summary tr:last-child {
    border-bottom: 0;
  }

  #series-summary td {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 4px 0;
    border: 0;
    white-space: normal;
  }

  #series-summary td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
  }

  .login-panel {
    margin-top: 2vh;
    padding: 28px 22px;
  }

  .login-brand {
    margin-bottom: 40px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
