:root {
  color-scheme: light dark;
  --canvas: #f4f6f8;
  --surface: #fdfdfd;
  --surface-subtle: #e9eef3;
  --text-heading: #18212b;
  --text-body: #45515e;
  --text-muted: #667382;
  --border: #d5dde5;
  --primary: #176b5b;
  --primary-hover: #0f5749;
  --primary-text: #f7faf9;
  --danger: #b42318;
  --danger-bg: #fff1f0;
  --warning: #8a4b08;
  --warning-bg: #fff8e6;
  --success: #197044;
  --shadow-sm: 0 4px 16px rgba(25, 43, 58, 0.08);
  --radius: 12px;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  margin: 0;
  background: var(--canvas);
  color: var(--text-body);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.55;
}

a {
  color: var(--primary);
}

a:hover {
  color: var(--primary-hover);
}

button,
input {
  font: inherit;
}

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

h1,
h2,
h3 {
  color: var(--text-heading);
  line-height: 1.2;
}

h1 {
  margin-bottom: 12px;
  font-size: clamp(2rem, 5vw, 3rem);
}

h2 {
  font-size: 1.75rem;
}

h3 {
  font-size: 1.25rem;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;
  padding: 12px max(24px, calc((100vw - 1200px) / 2));
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.brand {
  color: var(--text-heading);
  font-size: 1.125rem;
  font-weight: 700;
  text-decoration: none;
}

.topbar__actions,
.run-card__actions,
.filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar form,
.run-card form {
  margin: 0;
}

.page {
  width: min(1200px, calc(100% - 32px));
  margin: 0 auto;
  padding: 48px 0 64px;
}

.hero,
.auth-card,
.progress-card,
.run-card,
.empty-state {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 480px);
  gap: 48px;
  align-items: end;
  padding: 40px;
}

.auth-card {
  width: min(480px, 100%);
  margin: 40px auto;
  padding: 40px;
}

.section-heading {
  max-width: 680px;
}

.section-heading p:last-child {
  max-width: 64ch;
  margin-bottom: 0;
}

.section-heading--compact h1,
.section-heading--compact h2 {
  margin-bottom: 0;
}

.eyebrow {
  margin-bottom: 8px;
  color: var(--primary);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.search-form {
  display: flex;
  gap: 12px;
  align-items: end;
}

.form-stack,
.field {
  display: grid;
  gap: 8px;
}

.form-stack {
  gap: 24px;
  margin-top: 32px;
}

.field {
  flex: 1;
}

.field--short {
  flex: 0 1 144px;
}

.password-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.field label {
  color: var(--text-heading);
  font-weight: 650;
}

.field input {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text-heading);
}

.field input:focus {
  border-color: var(--primary);
  outline: 3px solid color-mix(in srgb, var(--primary) 25%, transparent);
}

.field__hint,
.field__error {
  font-size: 1rem;
}

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

.field__error {
  color: var(--danger);
  font-weight: 600;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 650;
  line-height: 1.2;
  text-decoration: none;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease;
}

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

.button--primary {
  background: var(--primary);
  color: var(--primary-text);
}

.button--primary:hover {
  background: var(--primary-hover);
  color: var(--primary-text);
}

.button--secondary,
.button--ghost {
  border-color: var(--border);
  background: var(--surface);
  color: var(--text-heading);
}

.button--secondary:hover,
.button--secondary.is-active {
  border-color: var(--primary);
  background: var(--surface-subtle);
  color: var(--primary);
}

.button--ghost {
  border-color: transparent;
}

.button--danger {
  border-color: color-mix(in srgb, var(--danger) 30%, var(--border));
  background: var(--danger-bg);
  color: var(--danger);
}

.button--full {
  width: 100%;
}

.notice {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-top: 24px;
  padding: 16px;
  border-radius: 8px;
}

.notice > span:first-child {
  display: inline-grid;
  flex: 0 0 24px;
  width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 50%;
  font-weight: 800;
}

.notice--warning {
  border: 1px solid color-mix(in srgb, var(--warning) 24%, transparent);
  background: var(--warning-bg);
  color: var(--warning);
}

.notice--warning > span:first-child {
  background: var(--warning);
  color: var(--warning-bg);
}

.notice--error {
  border: 1px solid color-mix(in srgb, var(--danger) 24%, transparent);
  background: var(--danger-bg);
  color: var(--danger);
}

.notice--error > span:first-child {
  background: var(--danger);
  color: var(--danger-bg);
}

.runs-section,
.results-section {
  margin-top: 48px;
}

.run-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin-top: 24px;
}

.run-card {
  display: flex;
  flex-direction: column;
  gap: 24px;
  min-height: 240px;
  padding: 24px;
}

.run-card h3 {
  margin-bottom: 0;
  font-size: 2rem;
}

.run-card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.run-card__actions {
  margin-top: auto;
}

.status {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  color: var(--text-body);
  font-weight: 650;
}

.status--completed {
  color: var(--success);
}

.status--failed {
  color: var(--danger);
}

.status--running {
  color: var(--primary);
}

.empty-state {
  display: grid;
  justify-items: center;
  margin-top: 24px;
  padding: 48px 24px;
  text-align: center;
}

.empty-state p {
  max-width: 52ch;
}

.empty-state__icon {
  display: grid;
  width: 56px;
  height: 56px;
  margin-bottom: 16px;
  place-items: center;
  border-radius: 50%;
  background: var(--surface-subtle);
  color: var(--primary);
  font-size: 2rem;
}

.back-link {
  display: inline-block;
  margin-bottom: 24px;
  font-weight: 650;
  text-decoration: none;
}

.run-header__row,
.results-toolbar,
.progress-card__heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.progress-card {
  margin-top: 24px;
  padding: 24px;
}

.progress-card progress {
  width: 100%;
  height: 12px;
  margin-top: 16px;
  accent-color: var(--primary);
}

.progress-card > p {
  min-height: 24px;
  margin: 8px 0 0;
  color: var(--text-muted);
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-top: 24px;
}

.metrics div {
  display: grid;
  gap: 4px;
  padding: 16px;
  border-radius: 8px;
  background: var(--surface-subtle);
}

.metrics strong {
  color: var(--text-heading);
  font-size: 1.5rem;
}

.metrics span {
  color: var(--text-muted);
}

.table-wrap {
  margin-top: 24px;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

table {
  width: 100%;
  border-collapse: collapse;
  white-space: nowrap;
}

.attribution {
  margin-top: 12px;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

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

.numeric {
  text-align: right;
}

.source-label {
  display: block;
  margin-bottom: 4px;
  color: var(--text-heading);
  font-weight: 650;
}

th {
  background: var(--surface-subtle);
  color: var(--text-heading);
  font-size: 1rem;
  font-weight: 700;
}

td {
  max-width: 320px;
  white-space: normal;
}

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

.completeness {
  color: var(--success);
  font-weight: 650;
}

.completeness--uncertain {
  color: var(--warning);
}

[hidden] {
  display: none !important;
}

@media (max-width: 800px) {
  .page {
    padding-top: 32px;
  }

  .hero {
    grid-template-columns: 1fr;
    gap: 32px;
    padding: 24px;
  }

  .search-form,
  .results-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .search-form .button {
    width: 100%;
  }

  .run-header__row {
    align-items: flex-start;
  }
}

@media (max-width: 560px) {
  .topbar {
    align-items: flex-start;
    padding: 12px 16px;
  }

  .topbar__actions {
    align-items: stretch;
    flex-direction: column;
  }

  .page {
    width: min(100% - 24px, 1200px);
  }

  .auth-card {
    margin: 16px auto;
    padding: 24px;
  }

  .run-card__actions,
  .filter-group {
    align-items: stretch;
    flex-direction: column;
  }

  .run-card__actions .button,
  .filter-group .button {
    width: 100%;
  }

  .metrics {
    grid-template-columns: 1fr;
  }

  .password-field {
    grid-template-columns: 1fr;
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    --canvas: #11171d;
    --surface: #192129;
    --surface-subtle: #232e38;
    --text-heading: #f2f2f2;
    --text-body: #cacaca;
    --text-muted: #aeb8c2;
    --border: #34424f;
    --primary: #63c6b3;
    --primary-hover: #83d5c6;
    --primary-text: #10231f;
    --danger: #ff9b91;
    --danger-bg: #3a2222;
    --warning: #f4c36a;
    --warning-bg: #362c1d;
    --success: #71d6a2;
    --shadow-sm: 0 4px 16px rgba(4, 10, 15, 0.28);
  }
}
