:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #222;
  background: #fff;
  font-size: 14px;
  line-height: 1.5;
}

* { box-sizing: border-box; }
html, body { max-width: 100%; }
html { scrollbar-gutter: stable; }
select, input { max-width: 100%; min-width: 0; }
.dataset-details { font-size: 12px; }
.dataset-details .dataset-note { margin: 8px 0; }
body { margin: 0; }
main { max-width: 1420px; margin: 22px auto; padding: 0 24px; }
h1 { margin: 4px 0; font-size: 30px; line-height: 1.2; font-weight: 650; letter-spacing: -.6px; }
header { margin-bottom: 14px; }
header p { margin: 3px 0; font-size: 12px; color: #666; }
.dataset-note { font-size: 11px; color: #555; }
.primary-controls { display: grid; grid-template-columns: minmax(240px, 1.4fr) minmax(260px, 2fr) minmax(160px, 1fr); gap: 12px; align-items: end; }
.primary-controls label { min-width: 0; }
.primary-controls select, .primary-controls input { width: 100%; }
.advanced-filters { margin-top: 12px; font-size: 12px; }
.advanced-filters > summary { width: fit-content; color: #174a7c; }
#advanced-count { color: #765400; }
.quick-caveat { color: #555; font-size: 12px; margin: 10px 0 2px; }
.reading-notes { border-top: 1px solid #ddd; padding-top: 12px; margin-top: 20px; color: #555; font-size: 12px; }
.reading-notes p { margin: 5px 0 12px; }
.reading-notes details { margin: 8px 0; }

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 10px 14px;
  padding: 12px 0 4px;
}
label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; }
.search { min-width: 0; }
.controls > label:not(.checkbox) { flex: 1 1 170px; }
.controls > label:has(#indicator), .controls > label:has(#legal) { flex-basis: 240px; }
input, select {
  font: inherit;
  color: inherit;
  background: #fff;
  border: 1px solid #999;
  border-radius: 0;
  padding: 8px;
  min-height: 36px;
}
input[type="number"] { width: 150px; }
.checkbox { flex-direction: row; align-items: center; flex: 1 1 320px; gap: 8px; }
input[type="checkbox"] { min-height: auto; margin: 0; accent-color: #444; }
:focus-visible { outline: 2px solid #155eef; outline-offset: 3px; }
.results-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 42px; }
#status { color: #555; font-size: 12px; margin: 8px 0; }
#file-help { border: 1px solid #aaa; padding: 12px; margin-top: 16px; }
.privacy-note code { font-size: 11px; }
.local-file { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin: 10px 0 0; font-size: 12px; color: #555; }
.local-file label { flex-direction: row; align-items: center; gap: 8px; color: #222; }
.local-file input[type="file"] { min-height: auto; padding: 4px; border-color: #ccc; font-size: 12px; max-width: 260px; }

/* The table is the only intentionally scrollable page region. */
.table-wrap {
  width: 100%;
  max-width: 100%;
  height: clamp(360px, 65vh, 760px);
  overflow: auto;
  scrollbar-gutter: stable;
  overflow-anchor: none;
  border-top: 1px solid #bbb;
  border-bottom: 1px solid #bbb;
}
table { width: 100%; border-collapse: collapse; font-size: 12px; }
.main-table,
.table-wrap > table {
  table-layout: fixed;
  min-width: 1120px;
}
caption { text-align: left; color: #666; padding: 0 0 10px; }
th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f1f3f2;
  text-align: left;
  font-size: 11px;
  font-weight: 650;
  white-space: nowrap;
  box-shadow: 0 1px 0 #bbb;
}
th, td { padding: 7px 9px; border-bottom: 1px solid #ddd; vertical-align: top; }
.main-table > thead > tr > th:nth-child(1) { width: 7%; }
.main-table > thead > tr > th:nth-child(2) { width: 12%; }
.main-table > thead > tr > th:nth-child(3) { width: 12%; }
.main-table > thead > tr > th:nth-child(4) { width: 26%; }
.main-table > thead > tr > th:nth-child(5) { width: 8%; }
.main-table > thead > tr > th:nth-child(6) { width: 10%; }
.main-table > thead > tr > th:nth-child(7) { width: 5%; }
.main-table > thead > tr > th:nth-child(8) { width: 12%; }
.main-table > thead > tr > th:nth-child(9) { width: 8%; }
.numeric { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.contract-row { cursor: pointer; }
.main-table > tbody > .contract-row > td { overflow-wrap: anywhere; }
.main-table > tbody > .contract-row > td:last-child { position: sticky; right: 0; z-index: 1; background: #fff; box-shadow: -1px 0 #ddd; }
.main-table > thead > tr > th:last-child { right: 0; z-index: 3; }
.numeric .provenance, .contract-row td:nth-child(1) .provenance { white-space: normal; }
.project-panel h2 { font-size: 16px; margin: 0 0 8px; }
.project-panel { margin: 12px 0; font-size: 12px; }
.contract-row:hover { background: #f7faf8; }
.contract-row td:nth-child(1) { white-space: nowrap; }
.row-toggle {
  font: inherit;
  text-align: left;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}
.row-toggle::before { content: "+ "; font-weight: bold; }
.row-toggle[aria-expanded="true"]::before { content: "− "; }
.provenance { display: block; color: #666; font-size: 10px; margin-top: 3px; }
.mobile-buyer { display: none; }

.score-chip, .badge { display: inline-block; font-size: 10px; line-height: 1.25; font-weight: 650; }
.score-chip { padding: 4px 7px; border: 1px solid currentColor; white-space: nowrap; }
.badge { padding: 2px 5px; margin: 0 3px 2px 0; border: 1px solid currentColor; }
.contract-row td:nth-child(8) .badge { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.badge-extra { display: block; color: #555; font-size: 10px; }
.level-none, .severity-low { color: #1b5e20; background: #e8f5e9; }
.level-low { color: #245c22; background: #d8f0d2; }
.level-moderate, .severity-moderate { color: #765400; background: #fff3c4; }
.level-high, .severity-high { color: #8a3b00; background: #ffe0b2; }
.level-extreme, .severity-extreme { color: #8b1e1e; background: #ffd6d6; }
.level-unknown { color: #4b5563; background: #e5e7eb; }
.badge.official { color: #7d1d1d; background: #ffe8e8; }
.badge.investigation { color: #485161; background: #f1f3f6; }
.muted { color: #666; }
.detail-row td { background: #fafafa; padding: 16px 22px; }
.detail-row h3 { font-size: 13px; margin: 18px 0 8px; }
.detail-row p { margin: 6px 0; }
.detail-row ul { padding-left: 20px; }
.notice-criterion { border-left: 2px solid #cbd3ce; padding: 4px 12px; margin: 10px 0; }
.detail-row blockquote { margin: 10px 0; padding: 8px 12px; border-left: 2px solid #bbb; white-space: pre-wrap; overflow-wrap: anywhere; }
.project-panel { border-left: 3px solid #c8d5cd; padding: 10px 14px; background: #fff; }
.evidence-list { margin: 8px 0; padding-left: 20px; }
.evidence-list li + li { margin-top: 5px; }
.history-table {
  width: 100%;
  min-width: 0;
  table-layout: auto;
}
.detail-row .history-table { margin: 10px 0; }
.detail-row .history-table th { position: static; }
.detail-row .history-table td, .detail-row .history-table th { padding: 7px 9px; }
.detail-row .history-table td { background: #fff; }

.group-row td { background: #eef1ef; color: #37413b; font-weight: 650; border-bottom-color: #cbd3ce; }
.group-link, .clear-group {
  font: inherit;
  color: #24533a;
  background: none;
  border: 0;
  border-bottom: 1px solid currentColor;
  padding: 0;
  cursor: pointer;
}
.score-legend { display: flex; flex-wrap: wrap; gap: 6px 12px; margin: 10px 0; font-size: 11px; }
.score-legend span { white-space: normal; }
a { color: #174a7c; text-underline-offset: 3px; overflow-wrap: anywhere; }

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 0;
  font-size: 12px;
}
.pagination button, button {
  border: 1px solid #999;
  border-radius: 0;
  background: #fff;
  color: #222;
  padding: 7px 10px;
  font: inherit;
  cursor: pointer;
}
.pagination button { width: 104px; white-space: nowrap; }
.pagination #copy-page { width: auto; }
.export-actions { margin: 0 0 8px; font-size: 12px; color: #555; }
.export-actions button { padding: 3px 10px; margin-left: 4px; }
.export-actions button:disabled { color: #888; border-color: #ddd; cursor: default; }
.page-size { flex-direction: row; align-items: center; gap: 5px; white-space: nowrap; }
.page-size select { min-height: 32px; padding: 4px; width: 66px; }
.pagination button:disabled { color: #888; border-color: #ddd; cursor: default; }
#page-status { min-width: 140px; display: flex; align-items: center; justify-content: center; text-align: center; font-variant-numeric: tabular-nums; }
.pagination { min-height: 38px; }
.method { margin: 24px 0; font-size: 12px; }
summary { cursor: pointer; font-weight: 600; }
footer { border-top: 1px solid #ddd; padding-top: 18px; color: #666; font-size: 11px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
[hidden] { display: none !important; }

@media (max-width: 760px) {
  main { margin: 16px auto; padding: 0 14px; }
  h1 { font-size: 25px; }
  .primary-controls { grid-template-columns: minmax(0, 1fr); gap: 7px; }
  .controls > label:not(.checkbox), .checkbox { flex: 1 1 100%; }
  input[type="number"] { width: 100%; }
  .results-bar { flex-wrap: wrap; gap: 0; }
  .pagination { width: 100%; display: grid; grid-template-columns: 1fr auto 1fr; gap: 6px; }
  .pagination button { width: auto; }
  .pagination #copy-page { grid-column: 2 / 4; justify-self: end; }
  .local-file input[type="file"] { max-width: 100%; }
  #page-status { min-width: 0; }
  .page-size { grid-column: 1 / 2; }
  .main-table, .table-wrap > table { min-width: 0; table-layout: fixed; }
  .main-table > thead > tr > th:nth-child(1) { width: 80px; }
  .main-table > thead > tr > th:nth-child(4) { width: auto; }
  .main-table > thead > tr > th:nth-child(9) { width: 78px; }
  .main-table > thead > tr > th:nth-child(2), .main-table > thead > tr > th:nth-child(3),
  .main-table > thead > tr > th:nth-child(5), .main-table > thead > tr > th:nth-child(6),
  .main-table > thead > tr > th:nth-child(7), .main-table > thead > tr > th:nth-child(8),
  .contract-row > td:nth-child(2), .contract-row > td:nth-child(3),
  .contract-row > td:nth-child(5), .contract-row > td:nth-child(6),
  .contract-row > td:nth-child(7), .contract-row > td:nth-child(8) { display: none; }
  .mobile-buyer { display: block; color: #666; font-size: 10px; margin-top: 3px; }
  .main-table > tbody > .contract-row > td:last-child { position: static; box-shadow: none; }
  th, td { padding: 7px 5px; }
  .detail-row td { padding: 12px; }
}
