/* Design tokens: plain, public-service styling. Light by default; dark follows the system unless chosen. */
:root {
  color-scheme: light;
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #f4f5f6;
  --surface-3: #e9ebed;
  --ink: #1b1f23;
  --ink-2: #3d444b;
  --ink-3: #5f6870;
  --line: #dfe2e5;
  --line-strong: #b4bac0;
  --brand: #1f3a5f;
  --brand-ink: #ffffff;
  --accent: #1f3a5f;
  --accent-soft: #eef0f3;
  --link: #1a4f8b;
  --row-hover: #f6f7f8;
  --row-open: #eef0f3;
  --none-fg: #5f6870;  --none-bg: transparent;
  --low-fg: #3d444b;   --low-bg: transparent;
  --mod-fg: #1b1f23;   --mod-bg: transparent;
  --high-fg: #1b1f23;  --high-bg: transparent;
  --ext-fg: #1b1f23;   --ext-bg: transparent;
  --unk-fg: #5f6870;   --unk-bg: transparent;
  --official-fg: #1b1f23; --official-bg: transparent;
  --review-fg: #3d444b; --review-bg: transparent;
  --shadow: none;
  --shadow-lg: 0 0 0 1px var(--line-strong), 0 8px 24px rgb(0 0 0 / .12);
  --radius: 0;
  --radius-sm: 2px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #17191c; --surface: #17191c; --surface-2: #202327; --surface-3: #2a2e33;
    --ink: #e4e6e8; --ink-2: #c1c5ca; --ink-3: #979da4; --line: #2f3338; --line-strong: #4c5258;
    --brand: #c1c5ca; --brand-ink: #17191c; --accent: #c1c5ca; --accent-soft: #24272b; --link: #a9c1de;
    --row-hover: #202327; --row-open: #24272b;
    --none-fg: #979da4; --none-bg: transparent; --low-fg: #c1c5ca; --low-bg: transparent;
    --mod-fg: #e4e6e8; --mod-bg: transparent; --high-fg: #e4e6e8; --high-bg: transparent;
    --ext-fg: #e4e6e8; --ext-bg: transparent; --unk-fg: #979da4; --unk-bg: transparent;
    --official-fg: #e4e6e8; --official-bg: transparent; --review-fg: #c1c5ca; --review-bg: transparent;
    --shadow-lg: 0 0 0 1px var(--line-strong), 0 8px 24px rgb(0 0 0 / .5);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #17191c; --surface: #17191c; --surface-2: #202327; --surface-3: #2a2e33;
  --ink: #e4e6e8; --ink-2: #c1c5ca; --ink-3: #979da4; --line: #2f3338; --line-strong: #4c5258;
  --brand: #c1c5ca; --brand-ink: #17191c; --accent: #c1c5ca; --accent-soft: #24272b; --link: #a9c1de;
  --row-hover: #202327; --row-open: #24272b;
  --none-fg: #979da4; --none-bg: transparent; --low-fg: #c1c5ca; --low-bg: transparent;
  --mod-fg: #e4e6e8; --mod-bg: transparent; --high-fg: #e4e6e8; --high-bg: transparent;
  --ext-fg: #e4e6e8; --ext-bg: transparent; --unk-fg: #979da4; --unk-bg: transparent;
  --official-fg: #e4e6e8; --official-bg: transparent; --review-fg: #c1c5ca; --review-bg: transparent;
  --shadow-lg: 0 0 0 1px var(--line-strong), 0 8px 24px rgb(0 0 0 / .5);
}

* { box-sizing: border-box; }
html, body { max-width: 100%; }
html { scrollbar-gutter: stable; }
body { margin: 0; background: var(--bg); color: var(--ink); }
a { color: var(--link); text-underline-offset: 3px; overflow-wrap: anywhere; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
[hidden] { display: none !important; }
.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; }
.skip-link { position: absolute; left: 12px; top: -48px; z-index: 100; padding: 8px 12px; background: var(--surface); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); }
.skip-link:focus { top: 12px; }
code, kbd { font-size: .92em; }
kbd { padding: 0 5px; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 4px; background: var(--surface); font-family: inherit; }
.muted { color: var(--ink-3); }
summary { cursor: pointer; font-weight: 600; }

/* Form controls */
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; color: var(--ink); }
input, select, textarea {
  font: inherit; font-weight: 400; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: 4px;
  padding: 4px 8px; min-height: 30px; max-width: 100%; min-width: 0;
}
textarea { resize: vertical; min-height: 56px; }
input:hover, select:hover, textarea:hover { border-color: var(--ink-3); }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
input[type="checkbox"] { min-height: auto; width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
input[type="number"] { width: 100%; }
.checkbox { flex-direction: row; align-items: flex-start; gap: 8px; font-weight: 500; color: var(--ink); line-height: 1.35; }
.checkbox input { margin-top: 1px; flex: 0 0 auto; }
button, .button-like {
  font: inherit; font-weight: 550; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  padding: 6px 12px; cursor: pointer; line-height: 1.3;
}
button:hover, .button-like:hover { background: var(--surface-3); }
button:disabled { color: var(--ink-3); border-color: var(--line); background: var(--surface); cursor: default; opacity: .7; }
.button-like { display: inline-flex; flex-direction: row; align-items: center; }
.button-like:focus-within { outline: 2px solid var(--accent); outline-offset: 1px; }
button.small, .button-like.small { padding: 4px 10px; font-size: 12px; }
button.ghost { background: transparent; border-color: transparent; color: var(--link); font-weight: 400; text-decoration: underline; text-underline-offset: 3px; }
button.ghost:hover { background: var(--surface-3); color: var(--ink); }
.icon-button { display: inline-flex; align-items: center; gap: 6px; }
.icon-button svg { width: 16px; height: 16px; }
.icon-only { font-size: 15px; line-height: 1; padding: 6px 9px; }
.link-button { background: none; border: 0; padding: 0; color: var(--link); text-decoration: underline; text-underline-offset: 3px; font-weight: 500; }
.link-button:hover { background: none; color: var(--ink); }
.field-help { font-size: 11.5px; color: var(--ink-3); font-weight: 400; margin: 0; }

/* Top bar */
.topbar { max-width: 1480px; margin: 0 auto; padding: 12px 24px 10px; display: flex; justify-content: space-between; align-items: center; gap: 16px; border-bottom: 1px solid var(--line-strong); }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 0 0 12.5em; }
h1 { margin: 0; font-size: 19px; line-height: 1.2; font-weight: 700; }
.tagline { margin: 1px 0 0; font-size: 12.5px; color: var(--ink-3); }
/* Fixed two-by-two layout (language and theme, then import and help) so nothing moves when a choice changes. */
.topbar-actions { display: grid; grid-template-columns: auto auto; justify-items: end; align-items: center; gap: 6px 14px; flex: 0 0 auto; }
/* Country and source sit in the top bar, next to the title. */
.topbar-sources { flex: 1 1 auto; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; min-width: 0; }
.topbar-sources label { display: flex; flex-direction: row; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; min-width: 0; white-space: nowrap; }
.topbar-sources select { text-overflow: ellipsis; }
.topbar-sources .country-selector select { padding: 2px 6px; width: auto; }
.topbar-sources .dataset-selector { flex: 1 1 320px; max-width: 560px; }
.topbar-sources .dataset-selector select { width: 100%; }

main { max-width: 1480px; margin: 0 auto; padding: 14px 24px 32px; }

/* Dataset and search */
.primary-controls { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.primary-controls:not(:has(> :not([hidden]))) { display: none; }
.primary-controls label { min-width: 0; }
.primary-controls select, .primary-controls input:not([type="checkbox"]) { width: 100%; }
.korea-picker { grid-column: 1 / -1; display: grid; gap: 6px; }
.korea-picker[hidden] { display: none; }
.korea-picker label { display: grid; gap: 4px; }
.korea-facet { display: flex; align-items: baseline; gap: 2px 14px; overflow-x: auto; white-space: nowrap; scrollbar-width: none; padding: 4px 0; border-top: 1px solid var(--line); }
.korea-facet[hidden] { display: none; }
.korea-facet button { background: none; border: 0; padding: 0; color: var(--ink); font: inherit; cursor: pointer; }
.korea-facet button:hover { background: none; text-decoration: underline; }
.korea-facet button.on { font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.korea-facet .muted { margin-left: 4px; font-weight: 400; }
.korea-facet .facet-label { flex: none; width: 9.5em; color: var(--ink); font-size: 12px; font-weight: 700; }
.korea-facet.child { border-top-style: dotted; }
.korea-facet.child .facet-label { padding-left: 1em; font-weight: 400; color: var(--ink-2); }
.korea-facet.child .facet-label::before { content: '↳ '; }
.korea-results[hidden] { display: none; }
.korea-results { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 14px; max-height: 9.5em; overflow-y: auto; }
.notice-box { border-left: 4px solid var(--mod-fg); background: var(--surface-2); padding: 4px 14px; margin-top: 12px; font-size: 13px; }

/* One-line dataset overview */
/* Second row: institution box, Dataset, Sources, Advanced filters. An opened panel shows below the whole row, so the
   toggles never move: an open <details> lays out its summary and body as items of the row (display: contents). */
.picker-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin: 10px 0; font-size: 13px; color: var(--ink-2); }
.picker-row .korea-search-label input { width: 280px; }
.picker-row .korea-search-label[hidden] { display: none; }
.picker-row > details[open], .picker-row > details[open]::details-content { display: contents; }
.picker-row > details[open] > :not(summary) { flex-basis: 100%; width: 100%; order: 20; min-width: 0; box-sizing: border-box; }
/* The same arrow on all three toggles. */
.picker-row > details > summary { list-style: none; cursor: pointer; }
.picker-row > details > summary::-webkit-details-marker { display: none; }
.picker-row > details > summary::before { content: "▸ "; color: var(--ink-3); text-decoration: none; display: inline-block; margin-right: 4px; }
.picker-row > details[open] > summary::before { content: "▾ "; }
.korea-results { margin: -4px 0 10px; }
.dataset-details { font-size: 13px; min-width: 0; }
.dataset-details > summary { color: var(--link); font-weight: 400; text-decoration: underline; text-underline-offset: 3px; width: fit-content; }
.dataset-details .details-body { border-left: 4px solid var(--line-strong); padding: 2px 0 2px 12px; margin: 0; }
.dataset-note { font-size: 13px; color: var(--ink-2); margin: 6px 0; }
.dataset-note ul { padding-left: 20px; }

/* Workspace: collapsible filter sidebar + results */
/* Filters open above the table, laid out across the full width. */
.filter-panel { width: fit-content; }
.filter-panel > .controls { border: 1px solid var(--line); background: var(--surface); }
.filter-panel > summary { display: flex; align-items: center; gap: 6px; padding: 0; list-style: none; font-size: 13px; color: var(--link); cursor: pointer; }
.filter-panel > summary .filter-toggle-label { text-decoration: underline; text-underline-offset: 3px; font-weight: 400; }
.count-pill:not(:empty) { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.controls { display: flex; flex-direction: column; gap: 12px; padding: 12px; }
.controls fieldset { border: 0; margin: 0; padding: 0 0 12px; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 9px 14px; align-items: end; min-width: 0; }
.controls fieldset > .field-help { grid-column: 1 / -1; }
.context-filters[open] { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 9px 14px; align-items: end; }
.context-filters > summary { grid-column: 1 / -1; }
.controls legend { padding: 0; margin-bottom: 6px; font-size: 13px; font-weight: 700; color: var(--ink); }
.controls select, .controls input:not([type="checkbox"]):not([type="file"]) { width: 100%; }
.button-row { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.link-like { display: inline; font-size: inherit; font-weight: 400; color: var(--link); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.link-like:focus-within { outline: 2px solid var(--accent); }
.context-filters, .local-file { display: flex; flex-direction: column; gap: 9px; padding-bottom: 12px; border-bottom: 1px solid var(--line); font-size: 13px; }
.context-filters > summary, .local-file > summary { font-weight: 600; color: var(--link); }
.context-filters[open] > summary, .local-file[open] > summary { margin-bottom: 8px; }
.context-filters > label + label { margin-top: 0; }
.local-file { border-bottom: 0; padding-bottom: 0; }
.local-file input[type="file"] { font-size: 12px; padding: 4px; min-height: auto; width: 100%; }
.local-file > label { gap: 5px; }
.reset-button { width: fit-content; }
@media (min-width: 1001px) {
  .filter-panel > summary { cursor: pointer; }
}

.results { min-width: 0; outline: none; }
.results-bar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 16px; margin-bottom: 8px; }
@media (min-width: 1001px) { .results-bar { flex-wrap: nowrap; } .results-bar > #status { flex: 1 1 auto; min-width: 0; text-align: right; font-size: 12px; } .results-bar > .toolbar, .results-bar > .export-actions { flex: none; flex-wrap: nowrap; } }
.toolbar .search input { width: 220px; }
.toolbar .basic-signal-filter { white-space: nowrap; align-items: center; }
#status { color: var(--ink-2); font-size: 13px; font-weight: 550; margin: 0; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.inline-label { flex-direction: row; align-items: center; gap: 6px; font-weight: 600; }
.inline-label select { min-height: 32px; padding: 4px 8px; font-size: 12.5px; max-width: 220px; }
.export-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin: 0; font-size: 12px; color: var(--ink-3); }
.export-label { margin-right: 2px; }
.export-actions button { padding: 4px 10px; font-size: 12px; }

/* Results table: 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;
  background: var(--surface); border: 1px solid var(--line-strong);
}
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.main-table { table-layout: auto; min-width: 1100px; }
caption { text-align: left; color: var(--ink-3); padding: 0 0 10px; }
th {
  position: sticky; top: 0; z-index: 2; background: var(--surface-2); text-align: left;
  font-size: 11.5px; font-weight: 650; color: var(--ink-2); white-space: nowrap; box-shadow: 0 1px 0 var(--line-strong);
}
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
/* Desktop: every column is only as wide as its content needs. The short columns (date, procedure, amount, offers,
   bid ratio, signals, index) shrink to their content (width: 1% with no wrapping); the free-text columns share the rest. */
.main-table > thead > tr > th:nth-child(1), .main-table > thead > tr > th.col-procedure, .main-table > thead > tr > th.numeric,
.main-table > thead > tr > th.col-signals { width: 1%; }
.contract-row > td.col-procedure, .contract-row > td.numeric { white-space: nowrap; }
.contract-row > td.col-extra .provenance, .contract-row > td.col-index .provenance, .contract-row > td.col-procedure .provenance { white-space: nowrap; }
.col-procedure .procedure-name { display: block; max-width: 11em; overflow: hidden; text-overflow: ellipsis; }
.main-table.no-extra .col-extra, .main-table.no-sector .col-sector, .main-table.no-offers .col-offers, .main-table.no-procedure .col-procedure { display: none; }
.col-party { white-space: nowrap; }
.clip { display: inline-block; max-width: 12em; overflow: hidden; text-overflow: ellipsis; vertical-align: bottom; }
.amount-changes { margin: 0; padding-left: 1.4em; font-variant-numeric: tabular-nums; }
.numeric { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.amount-range span { display: block; }
.contract-row { cursor: pointer; }
/* Wrap between words only (Korean too: keep-all); a word longer than the column is the only thing broken. */
.main-table > tbody > .contract-row > td { word-break: keep-all; overflow-wrap: break-word; }
.main-table > tbody > .contract-row > td:last-child { position: sticky; right: 0; z-index: 1; background: var(--surface); box-shadow: -1px 0 var(--line); }
.main-table > thead > tr > th:last-child { right: 0; z-index: 3; }
.contract-row:hover > td, .contract-row:hover > td:last-child { background: var(--row-hover); }
.contract-row.is-open > td, .contract-row.is-open > td:last-child { background: var(--row-open); }
.contract-row.is-open > td:first-child { box-shadow: inset 3px 0 var(--accent); }
.numeric .provenance, .contract-row td:nth-child(1) .provenance { white-space: normal; }
.contract-row td:nth-child(1) { white-space: nowrap; }
.row-toggle {
  font: inherit; font-weight: 600; text-align: left; color: inherit; text-decoration: none; text-underline-offset: 3px; background: none; border: 0; border-radius: 3px; padding: 0;
  cursor: pointer; line-height: 1.35; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden;
}
.row-toggle:hover, .contract-row:hover .row-toggle { background: none; color: var(--ink); text-decoration: underline; }
.provenance { display: block; color: var(--ink-3); font-size: 11px; margin-top: 3px; }
.provenance.tone-official { color: var(--official-fg); font-weight: 600; }
.provenance.tone-proceeding { color: var(--ink-2); }
.info-tip { display: inline-block; width: 13px; height: 13px; margin-left: 3px; border: 1px solid currentColor; border-radius: 50%; font: italic 700 9px/11px Georgia, serif; text-align: center; vertical-align: 1px; cursor: help; }
.info-tip:focus-visible { outline: 2px solid currentColor; outline-offset: 1px; }
.mobile-buyer { display: none; }
.review-tag { display: inline-block; margin-top: 4px; padding: 1px 7px; border-radius: 999px; font-size: 10.5px; font-weight: 650; color: var(--review-fg); background: var(--review-bg); }
.review-reviewed { color: var(--ink-2); background: var(--surface-3); }
.empty-row td { padding: 28px; text-align: center; color: var(--ink-2); }
.group-row td { background: var(--surface-3); color: var(--ink); font-weight: 650; border-bottom-color: var(--line-strong); }
.group-link, .clear-group { font: inherit; color: var(--link); background: none; border: 0; border-bottom: 1px solid currentColor; border-radius: 0; padding: 0; cursor: pointer; }
.group-link:hover, .clear-group:hover { background: none; }

.mobile-signals { display: none; }

/* Index and signals are plain text: weight marks the level, the words say what it is. */
.score-chip, .badge { display: inline; font-size: 12.5px; line-height: 1.4; font-weight: 400; }
.score-chip { white-space: nowrap; font-variant-numeric: tabular-nums; }
.contract-row td.col-signals { min-width: 9em; max-width: 15em; }
.contract-row td.col-signals .badge { white-space: nowrap; }
.badge.not-counted, .badge.context, .badge.offset { color: var(--ink-3); }
.level-none, .level-below, .level-context, .level-offset, .level-unknown, .severity-low { color: var(--ink-3); }
.level-moderate, .severity-moderate { font-weight: 500; }
.level-high, .severity-high, .level-extreme, .severity-extreme, .badge.official { font-weight: 650; }

/* Pagination */
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0 4px; font-size: 12.5px; min-height: 38px; }
.pagination > button { width: 108px; white-space: nowrap; }
#page-status { min-width: 140px; display: flex; align-items: center; justify-content: center; text-align: center; font-variant-numeric: tabular-nums; color: var(--ink-2); }
.page-size { flex-direction: row; align-items: center; gap: 6px; white-space: nowrap; }
.page-size select { min-height: 32px; padding: 4px 6px; width: 70px; }

.project-panel { margin: 0 0 12px; font-size: 13px; padding: 10px 14px; background: var(--surface-2); border-left: 4px solid var(--accent); }
.project-panel h2 { font-size: 16px; margin: 0 0 8px; }

/* Buyer / supplier profile */
.profile-table { border-collapse: collapse; margin: 8px 0; font-size: 12px; }
.profile-table th, .profile-table td { border-bottom: 1px solid var(--line); padding: 4px 8px; text-align: left; }
.profile-links { margin: 8px 0 0; display: flex; gap: 8px; flex-wrap: wrap; }
.evidence-list { margin: 8px 0; padding-left: 20px; }
.evidence-list li + li { margin-top: 5px; }

footer { margin-top: 28px; border-top: 1px solid var(--line); padding-top: 16px; color: var(--ink-3); font-size: 12px; }
footer p { margin: 0 0 2px; }

/* Detail side panel */
.detail-panel {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 40; width: min(700px, 100%);
  display: flex; flex-direction: column; background: var(--surface); border-left: 1px solid var(--line-strong); box-shadow: var(--shadow-lg);
  outline: none;
}
.detail-toolbar { display: flex; align-items: center; gap: 2px; padding: 6px 10px; border-bottom: 1px solid var(--line-strong); background: var(--surface-2); flex: 0 0 auto; }
.detail-position { flex: 1; font-size: 12px; color: var(--ink-3); padding: 0 8px; font-variant-numeric: tabular-nums; }
.detail-body { flex: 1; overflow: auto; padding: 18px 22px 40px; font-size: 13px; overscroll-behavior: contain; }
.detail-head h2 { margin: 4px 0 12px; font-size: 18px; line-height: 1.35; overflow-wrap: anywhere; }
.detail-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 6px 14px; margin: 0 0 10px; padding: 0 0 10px; border-bottom: 1px solid var(--line); }
.detail-facts dt { font-size: 12px; font-weight: 700; color: var(--ink-3); }
.detail-facts dd { margin: 1px 0 0; overflow-wrap: anywhere; }
.detail-documents { margin: 0 0 10px; padding: 0 0 10px; border-bottom: 1px solid var(--line); font-size: 14px; overflow-wrap: anywhere; }
.detail-documents .documents-head { margin: 0 0 4px; }
.doc-group { margin: 2px 0; }
.doc-label { font-weight: 700; color: var(--ink-3); font-size: 12px; }
.doc-more { display: inline; }
.doc-more summary { display: inline; cursor: pointer; color: var(--ink-3); }
.doc-more[open] summary { display: block; }
.review-box { display: grid; grid-template-columns: minmax(120px, 150px) minmax(0, 1fr) auto; gap: 8px; align-items: start; margin-bottom: 4px; }
.review-box textarea { min-height: 34px; resize: vertical; }
.review-box .field-help { align-self: center; white-space: nowrap; }
.detail-status { margin: 0 0 8px; font-size: 12.5px; font-weight: 600; color: var(--mod-fg); }
.profile-link { font-size: 12px; }
.detail-checks > summary { cursor: pointer; font-weight: 700; font-size: 14px; padding: 2px 0; }
.detail-checks[open] > summary { margin-bottom: 6px; }
.link-row { line-height: 1.8; }
.field-notes { margin: 6px 0 0; padding-left: 18px; }
.field-notes li + li { margin-top: 4px; }
.detail-section { padding: 14px 0 6px; border-bottom: 1px solid var(--line); scroll-margin-top: 48px; }
.detail-section:last-of-type { border-bottom: 0; }
.section-title { margin: 0 0 8px; font-size: 14.5px; }
.detail-section h4 { margin: 16px 0 6px; font-size: 13px; }
.detail-section p { margin: 6px 0; }
.detail-section ul, .detail-section ol { padding-left: 20px; margin: 6px 0; }
.detail-section li + li { margin-top: 4px; }
.detail-section blockquote { margin: 10px 0; padding: 8px 12px; border-left: 3px solid var(--line-strong); background: var(--surface-2); white-space: pre-wrap; overflow-wrap: anywhere; }
.triggered-indicators { list-style: none; padding: 0 !important; }
.severity-line { padding: 4px 0 4px 12px; border-left: 2px solid var(--line-strong); background: none !important; }
.severity-line strong { color: inherit; }
.severity-line > span, .severity-line > p { color: var(--ink); }
.severity-line > p { margin: 4px 0 0; font-size: 12.5px; color: var(--ink-2); }
.assessment-checks { list-style: none; padding: 0 !important; }
.assessment-checks li { position: relative; padding: 6px 8px 6px 30px; border-radius: 6px; font-size: 12.5px; }
.assessment-checks li::before { position: absolute; left: 8px; top: 6px; width: 16px; text-align: center; font-weight: 700; }
.check-signal { font-weight: 600; }
.check-signal::before { content: "!"; color: var(--high-fg); }
.check-clear::before { content: "✓"; color: var(--none-fg); }
.check-unknown::before { content: "?"; color: var(--unk-fg); }
.check-not-applicable { color: var(--ink-3); }
.check-not-applicable::before { content: "–"; color: var(--ink-3); }
.notice-criterion { border-left: 2px solid var(--line-strong); padding: 4px 12px; margin: 10px 0; }
.history-wrap { overflow-x: auto; }
.history-table { width: 100%; min-width: 0; table-layout: auto; margin: 10px 0; }
.history-table th { position: static; }
.history-table caption { font-size: 12px; }
.verify-links li { padding-left: 2px; }
.verify { padding-bottom: 12px; }
.print-only { display: none; }

/* Help, import and notes dialogs */
.help-dialog { width: min(860px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 0; border: 1px solid var(--line-strong); border-radius: 0; background: var(--surface); color: var(--ink); box-shadow: var(--shadow-lg); }
.help-dialog::backdrop { background: rgb(8 14 12 / .45); }
.dialog-head { position: sticky; top: 0; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 20px; background: var(--surface); border-bottom: 1px solid var(--line); }
.dialog-head h2 { margin: 0; font-size: 17px; }
.reading-notes, .dialog-content { padding: 12px 20px; font-size: 13px; color: var(--ink-2); }
.help-dialog > p { padding: 0 20px 12px; }
.dialog-content > label { display: flex; flex-direction: column; gap: 5px; }
.dialog-content select { width: 100%; }
#sort-direction { min-width: 34px; }
.score-legend { display: flex; flex-wrap: wrap; gap: 6px 10px; margin: 10px 0; font-size: 11px; }
.score-legend span { white-space: normal; }

/* Sortable column headers: a real button, arrow shows the active direction. */
.sort-header { font: inherit; font-weight: inherit; color: inherit; background: none; border: 0; border-radius: 0; padding: 0; cursor: pointer; text-align: inherit; }
.sort-header:hover, .sort-header:focus-visible { background: none; text-decoration: underline; }
.sort-header::after { content: " ↕"; color: var(--ink-3); font-weight: normal; opacity: .7; }
.sort-header[data-direction="descending"]::after { content: " ↓"; color: var(--accent); opacity: 1; }
.sort-header[data-direction="ascending"]::after { content: " ↑"; color: var(--accent); opacity: 1; }

@media (max-width: 1000px) {
  .workspace { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .filter-panel { position: static; max-height: none; }
}

@media (max-width: 760px) {
  .topbar { padding: 10px 14px 6px; flex-wrap: wrap; gap: 2px 12px; }
  .topbar-actions { margin-left: auto; max-width: 100%; }
  .topbar-actions button { padding: 4px 6px; font-size: 13px; }
  .tagline { display: none; }
  main { padding: 6px 14px 24px; }
  .primary-controls { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .controls { grid-template-columns: minmax(0, 1fr); }
  .results-bar { align-items: flex-start; }
  .toolbar { gap: 8px; }
  .inline-label select { max-width: 150px; }
  .pagination { width: 100%; display: grid; grid-template-columns: 1fr auto 1fr; gap: 6px; }
  .pagination > button { width: auto; }
  #page-status { min-width: 0; }
  .page-size { grid-column: 1 / -1; justify-self: center; }
  .main-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.col-index { width: 82px; }
  .main-table > thead > tr > th:not(:nth-child(1)):not(:nth-child(4)):not(.col-index),
  .contract-row > td:not(:nth-child(1)):not(:nth-child(4)):not(:last-child) { display: none; }
  .mobile-buyer { display: block; color: var(--ink-3); font-size: 11px; margin-top: 3px; }
  .mobile-signals { display: block; color: var(--high-fg); font-size: 11px; margin-top: 3px; }
  .mobile-signals.context { color: var(--unk-fg); }
  .contract-row td:nth-child(1) { white-space: normal; }
  .main-table > tbody > .contract-row > td:last-child { position: static; }
  th, td { padding: 8px 6px; }
  .detail-panel { left: 0; width: auto; border-left: 0; }
  .detail-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .detail-body { padding: 14px 14px 32px; }
    .review-box { grid-template-columns: minmax(0, 1fr); }
  .detail-toolbar { flex-wrap: wrap; }
}

/* Print: the results table in full, or a single case sheet from the side panel. */
@media print {
  :root { --bg: #fff; --surface: #fff; --surface-2: #fff; --surface-3: #f2f2f2; --ink: #000; --ink-2: #222; --ink-3: #444; --line: #bbb; color-scheme: light; font-size: 11px; }
  body { background: #fff; }
  .topbar-actions, .skip-link, .primary-controls, .filter-panel, .toolbar, .pagination,   .workspace { display: block; }
  .table-wrap { height: auto; overflow: visible; border: 0; }
  .main-table { min-width: 0; }
  th { position: static; }
  .main-table > tbody > .contract-row > td:last-child { position: static; }
  a { color: #000; }
  body.print-detail > main, body.print-detail > header { display: none !important; }
  body.print-detail .detail-panel { display: block !important; position: static; width: auto; border: 0; animation: none; }
  body.print-detail .detail-toolbar, body.print-detail   body.print-detail .detail-body { overflow: visible; padding: 0; }
  body.print-detail .review-box select, body.print-detail .review-box textarea { border: 1px solid #999; }
  body.print-detail .print-only { display: block; font-size: 10px; color: #444; border-top: 1px solid #bbb; padding-top: 8px; margin-top: 16px; }
  body.print-detail .verify-links a::after { content: " — " attr(href); font-size: 9.5px; color: #444; }
  .detail-section { break-inside: auto; }
  .severity-line, .assessment-checks li { break-inside: avoid; }
}

/* Interface language */
.lang-selector { flex-direction: row; align-items: center; gap: 4px; font-size: 12px; color: var(--ink-2); }
.lang-selector select { font-size: 12px; padding: 2px 4px; width: auto; min-height: 0; }


/* Very wide screens: make room for the panel instead of covering the table. */
@media (min-width: 1700px) {
  body.detail-open { padding-right: min(700px, 100%); }
}
/* Dataset sources: open APIs used (Korea) */
#sources-body h4 { margin: .8em 0 .2em; font-size: .95em; }
#sources-body .source-apis li { margin: .15em 0; }
#sources-body .attribution { color: var(--ink-3); font-size: .9em; }
