:root {
  --control-height: 44px;
  color-scheme: light;
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.5;
  color: #1f2933;
  background: #f4f6f5;
}

html {
  overflow-y: scroll;
  scrollbar-gutter: stable;
}

body { margin: 0; }

a {
  color: #155e4b;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

button {
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--control-height);
  border: 1px solid #1f6f5b;
  border-radius: 6px;
  padding: 0 1rem;
  color: #ffffff;
  background: #1f6f5b;
  font: inherit;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.72;
}

input,
select {
  box-sizing: border-box;
  width: 100%;
  min-height: var(--control-height);
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 0 0.7rem;
  color: #1f2933;
  background: #ffffff;
  font: inherit;
  line-height: 1.2;
}

code { font-size: 0.9em; }

.page {
  width: min(1280px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 32px 0;
}

.page-header {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.eyebrow {
  margin: 0 0 4px;
  color: #667085;
  font-size: 0.85rem;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: 2rem;
}

.age-badge,
.source-badge {
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  padding: 0.35rem 0.7rem;
  color: #334155;
  background: #ffffff;
  font-size: 0.9rem;
}

.source-badge {
  border-color: #b8d8ca;
  color: #155e4b;
  background: #eef8f3;
}

.toolbar,
.refresh-panel,
.empty-state,
.table-shell,
.detail-grid {
  border: 1px solid #d8dde6;
  border-radius: 8px;
  background: #ffffff;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px 24px;
  align-items: start;
  padding: 20px;
}

.toolbar-actions {
  display: grid;
  gap: 14px;
  justify-items: end;
}

.toolbar p,
.empty-state p,
.table-heading p {
  margin-bottom: 0;
  color: #475467;
}

.refresh-panel {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  margin-top: 16px;
  padding: 18px 20px;
}

.refresh-panel[hidden] { display: none; }

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid #d8dde6;
  border-top-color: #1f6f5b;
  border-radius: 50%;
  animation: spin 900ms linear infinite;
}

.refresh-title {
  margin-bottom: 8px;
  font-weight: 700;
}

.refresh-title.is-error { color: #b42318; }

.stage-list {
  margin: 0;
  padding-left: 20px;
  color: #667085;
}

.stage-list li { padding: 2px 0; }

.stage-list li.is-active {
  color: #1f2933;
  font-weight: 700;
}

.stage-list li.is-done { color: #1f6f5b; }

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

.summary-grid div {
  border: 1px solid #d8dde6;
  border-radius: 8px;
  padding: 16px;
  background: #ffffff;
}

.summary-grid span {
  display: block;
  color: #667085;
  font-size: 0.85rem;
}

.summary-grid strong {
  display: block;
  margin-top: 4px;
  font-size: 1.25rem;
}

.subnav {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  justify-content: flex-end;
}

.filter-bar {
  display: grid;
  grid-template-columns:
    minmax(200px, 1.55fr)
    repeat(4, minmax(120px, 0.88fr))
    auto
    minmax(150px, 0.86fr);
  gap: 12px 16px;
  align-items: end;
  margin: 0;
}

.filter-field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.filter-field > span:first-child {
  color: #667085;
  font-size: 0.85rem;
  line-height: 1.2;
}

.search-control {
  position: relative;
  display: block;
}

.search-control input {
  padding-right: 2.6rem;
}

input[type="search"]::-webkit-search-cancel-button {
  appearance: none;
}

.search-clear {
  position: absolute;
  top: 50%;
  right: 0.5rem;
  width: 26px;
  height: 26px;
  min-height: 0;
  padding: 0;
  border-color: #c8d1dc;
  border-radius: 999px;
  color: #667085;
  background: #f8faf9;
  font-size: 1rem;
  line-height: 1;
  transform: translateY(-50%);
}

.search-clear:hover,
.search-clear:focus-visible {
  border-color: #98a2b3;
  color: #1f2933;
  background: #eef2f1;
}

.filter-actions {
  display: flex;
  gap: 10px;
  align-items: end;
  min-width: max-content;
}

.filter-field-preset {
  min-width: 156px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
  overflow: hidden;
}

.detail-grid div {
  padding: 16px;
}

.detail-grid div + div {
  border-left: 1px solid #e4e7ec;
}

.detail-grid span {
  display: block;
  color: #667085;
  font-size: 0.85rem;
}

.detail-grid strong {
  display: block;
  margin-top: 4px;
  overflow-wrap: anywhere;
}

.table-shell,
.empty-state {
  margin-top: 16px;
}

.empty-state {
  padding: 24px;
}

.table-heading {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  gap: 16px;
  padding: 18px 20px;
  background: #ffffff;
}

.table-scroll {
  overflow-x: auto;
}

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

th,
td {
  border-top: 1px solid #e4e7ec;
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
}

th {
  color: #475467;
  background: #f8faf9;
  font-size: 0.85rem;
  font-weight: 700;
}

thead th { z-index: 4; }

.rank { color: #155e4b; font-weight: 700; }

th.number,
td.number {
  text-align: right;
}

.text-right {
  text-align: right;
}

.placeholder-value {
  color: #7f8a99;
  font-weight: 400;
}

td.placeholder-value {
  font-size: 0.95rem;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 1240px) {
  .filter-bar {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .filter-field-search {
    grid-column: span 2;
  }

  .filter-actions,
  .filter-field-preset {
    min-width: 0;
  }

  .filter-actions button {
    flex: 1;
  }
}

@media (max-width: 760px) {
  .page-header,
  .toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .badge-row {
    justify-content: flex-start;
  }

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

  .toolbar-actions {
    justify-items: start;
  }

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

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

  .filter-field-search {
    grid-column: auto;
  }

  .filter-actions {
    width: 100%;
  }

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

  .detail-grid div + div {
    border-top: 1px solid #e4e7ec;
    border-left: 0;
  }
}

@media (max-width: 520px) {
  .filter-actions {
    flex-direction: column;
  }

  .filter-actions button {
    width: 100%;
  }
}

@media print {
  body {
    background: #ffffff;
  }

  button,
  .filter-bar,
  .subnav {
    display: none;
  }

  .page {
    width: 100%;
    padding: 0;
  }

  .table-shell,
  th,
  td {
    border-color: #9aa4b2;
  }
}
