/*
Theme Name: CompDNA
Description: CompDNA company profiles read as a due-diligence index: numbered chapters, ruled line items, evidence cells and an outstanding-items list. Requires Advanced Custom Fields and Contact Form 7.
Version: 2.0.0
Requires PHP: 8.0
Text Domain: firmographics
*/

/*
DIRECTION CONTRACT
THESIS: A CompDNA profile is a due-diligence request list, not a dashboard. It refuses the SaaS card-and-pill arrangement: one ruled sheet, numbered like a data-room index, where numbering gaps reveal what is missing.
OWN-WORLD: White sheet on a cool grey desk, 1px grid rules, grey header bands, square cells. One deep corporate blue for actions and place. Status = Excel conditional-format cells (Good / Neutral / Bad). Archivo with tabular figures.
STORY: The analyst sees in one glance how complete the file is (filling rate + 12-cell chapter strip) and how well it is sourced, reads chapter by chapter, opens the evidence behind any row, and ends on the outstanding items.
FIRST VIEWPORT: Register on the left; on the sheet, identity (logo mat, name, description), a term-sheet row, the receipt (filling rate cell, items received, chapter strip, citations), then the sticky chapter index.
FORM: Due-diligence index, grounded list #4 (seed 95800241), staging: evidence transect (claims pinned to their sources).
*/

:root {
	--ink: #14202e;
	--logo-ink: #00194C;
	--ink-2: #3d4b5c;
	--ink-3: #5b6878;
	--paper: #ffffff;
	--desk: #eceff3;
	--band: #f3f5f7;
	--rule: #d5dbe2;
	--rule-strong: #aab4c0;
	/* Blues derived from the compdna logo: navy #00194C, blue #007DFE (darkened to #0072E8 for AA text contrast). */
	--logo-blue: #007DFE;
	--accent: #0062CC;
	--accent-hover: #00194C;
	--accent-soft: #E6F2FF;
	--btn-bg: #0072E8;
	--btn-hover: #00194C;
	--good-fill: #c6efce;
	--good-ink: #006100;
	--neutral-fill: #ffeb9c;
	--neutral-ink: #7a4500;
	--bad-fill: #ffc7ce;
	--bad-ink: #9c0006;
	--star: #c27c0e;
	--shadow: 0 14px 24px -10px rgba(20, 32, 46, .28);
	--font: Archivo, system-ui, -apple-system, "Segoe UI", sans-serif;
	color-scheme: light;
}

@media (prefers-color-scheme: dark) {
	:root {
		--ink: #e8edf3;
		--logo-ink: #ffffff;
		--ink-2: #b8c3cf;
		--ink-3: #93a0ae;
		--paper: #161d26;
		--desk: #0f141b;
		--band: #1c2530;
		--rule: #2b3643;
		--rule-strong: #3d4a59;
		--accent: #5AA9FF;
		--accent-hover: #8CC4FF;
		--accent-soft: #0B2240;
		--btn-bg: #0072E8;
		--btn-hover: #0062CC;
		--good-fill: #173d24;
		--good-ink: #8fe0a6;
		--neutral-fill: #43360f;
		--neutral-ink: #ffd66b;
		--bad-fill: #4a1a20;
		--bad-ink: #ffb3bb;
		--star: #f5c451;
		--shadow: 0 14px 24px -10px rgba(0, 0, 0, .6);
		color-scheme: dark;
	}
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
	font-family: var(--font);
	font-size: .875rem;
	line-height: 1.5;
	color: var(--ink);
	background: var(--desk);
	font-variant-numeric: tabular-nums;
	-webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }
button, input, select { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; text-wrap: balance; }
p { margin: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.screen-reader-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.skip-link { position: absolute; left: -9999px; top: 8px; z-index: 100; background: var(--btn-bg); color: #fff; padding: 8px 14px; text-decoration: none; }
.skip-link:focus { left: 8px; }
.icon { width: 18px; height: 18px; flex: none; color: var(--ink-3); vertical-align: -3px; }
.icon-sm { width: 14px; height: 14px; vertical-align: -2px; }
.ref { color: var(--ink-3); font-weight: 500; margin-right: .6em; font-variant-numeric: tabular-nums; }
.count { color: var(--ink-3); font-weight: 500; }
.muted { color: var(--ink-3); }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Buttons ---------- */
.btn {
	display: inline-flex; align-items: center; justify-content: center; gap: 6px;
	min-height: 36px; padding: 7px 14px;
	border: 1px solid var(--rule-strong); border-radius: 3px;
	background: var(--paper); color: var(--ink);
	font-size: .875rem; font-weight: 600; cursor: pointer; white-space: nowrap;
	transition: background-color .15s ease-out, border-color .15s ease-out;
}
.btn:hover { background: var(--band); border-color: var(--ink-3); }
.btn-primary { background: var(--btn-bg); border-color: var(--btn-bg); color: #fff; }
.btn-primary:hover { background: var(--btn-hover); border-color: var(--btn-hover); color: #fff; }
.btn:disabled { opacity: .55; cursor: default; }
.icon-btn { width: 36px; height: 36px; border: 0; border-radius: 3px; background: none; color: var(--ink-2); font-size: 1.375rem; line-height: 1; cursor: pointer; flex: none; }
.icon-btn:hover { background: var(--band); color: var(--ink); }

/* ---------- Status cells (Excel conditional-format styles) ---------- */
.status {
	display: inline-flex; align-items: center; justify-content: center; gap: 6px;
	min-width: 46px; padding: 2px 7px;
	font-size: .75rem; font-weight: 600; line-height: 1.5; white-space: nowrap;
}
/* Five bands: dark orange, light orange, light green, dark green, violet (top band reads as premium, not as a warning scale); one near-black ink keeps every band readable in both themes. */
.st-l1, .st-l2, .st-l3, .st-l4, .st-l5 { color: #0b1118; }
.st-l1 { background: #D9541E; }
.st-l2 { background: #F5A54A; }
.st-l3 { background: #8FD9A0; }
.st-l4 { background: #27AE60; }
.st-l5 { background: #8B7CF6; }
.st-progress { background: var(--accent-soft); color: var(--accent); }
.status-lg { font-size: 1.125rem; font-weight: 700; padding: 4px 12px; min-width: 72px; }
.spinner { width: 10px; height: 10px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .9s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; border-right-color: currentColor; opacity: .6; } }

/* ---------- App frame ---------- */
.app { display: grid; grid-template-columns: 320px minmax(0, 1fr); height: 100vh; }
.admin-bar .app { height: calc(100vh - 32px); }
.desk { overflow: auto; min-width: 0; min-height: 0; padding: 24px 28px 0; outline: none; display: flex; flex-direction: column; }
.sheet { flex: none; width: 100%; max-width: 1120px; margin: 0 auto 24px; background: var(--paper); border: 1px solid var(--rule); }

/* ---------- Register (sidebar) ---------- */
.register { background: var(--paper); border-right: 1px solid var(--rule); display: flex; flex-direction: column; min-height: 0; }
.reg-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 16px 12px; }
.brand { display: inline-flex; align-items: center; gap: 9px; min-height: 36px; font-weight: 700; font-size: 1rem; color: var(--ink); text-decoration: none; letter-spacing: -.005em; }
.brand:hover { color: var(--ink); }
.brand-logo { height: 22px; width: auto; flex: none; display: block; }
.brand-by { font-weight: 500; font-size: .75rem; color: var(--ink-3); white-space: nowrap; }
.tb-baseline { font-size: 1.125rem; font-weight: 600; color: var(--ink); margin-top: 8px; }
.tb-subtitle { font-style: italic; color: var(--ink-2); margin-top: 2px; }
.btn-export { text-decoration: none; }
.reg-cols { display: flex; justify-content: space-between; padding: 6px 16px; background: var(--band); border-bottom: 1px solid var(--rule); font-size: .75rem; font-weight: 600; color: var(--ink-3); }
.reg-foot { margin-top: auto; padding: 12px 16px; border-top: 1px solid var(--rule); font-size: .75rem; color: var(--ink-3); display: grid; gap: 4px; }
.reg-keys kbd { display: inline-block; min-width: 18px; padding: 0 4px; border: 1px solid var(--rule-strong); border-radius: 3px; font: 600 .75rem/1.5 var(--font); text-align: center; color: var(--ink-2); }
.reg-keys kbd + kbd { margin-left: 2px; }
.reg-toggle { display: none; }
.reg-body { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.reg-search { position: relative; padding: 0 16px 12px; }
.reg-search input {
	width: 100%; min-height: 36px; padding: 7px 56px 7px 10px;
	border: 1px solid var(--rule-strong); border-radius: 3px; background: var(--paper); font-size: .875rem;
}
.reg-search input::placeholder { color: var(--ink-3); }
.reg-search kbd {
	position: absolute; right: 24px; top: 8px; min-width: 20px; padding: 0 5px; pointer-events: none;
	border: 1px solid var(--rule-strong); border-radius: 3px; font: 600 .75rem/1.5 var(--font); color: var(--ink-3); text-align: center;
}
.reg-list { overflow: auto; flex: 0 1 auto; }
.reg-row {
	display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; align-items: center; gap: 10px;
	min-height: 52px; padding: 8px 16px; border-bottom: 1px solid var(--rule);
	color: var(--ink); text-decoration: none;
}
.reg-row:hover { background: var(--band); color: var(--ink); }
.reg-row[hidden] { display: none; }
.reg-row.is-current { background: var(--accent-soft); }
.reg-row.is-current .reg-name { font-weight: 700; }
.reg-icon {
	width: 28px; height: 28px; display: grid; place-items: center; overflow: hidden;
	border: 1px solid var(--rule); background: #fff; color: #3d4b5c; font-size: .75rem; font-weight: 700;
}
.reg-icon img { width: 100%; height: 100%; object-fit: contain; }
.reg-name { font-weight: 600; font-size: .875rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reg-place { display: block; font-weight: 400; font-size: .75rem; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; }
.reg-empty { padding: 16px; color: var(--ink-2); font-size: .875rem; }

/* ---------- Title block ---------- */
.title-block { padding: 28px 32px 24px; border-bottom: 1px solid var(--rule); display: grid; gap: 20px; }
.sheet > .title-block:first-child:has(> .btn) { grid-template-columns: minmax(0, 1fr) auto; align-items: end; }
.tb-identity { display: flex; flex-wrap: wrap; gap: 20px; align-items: center; }
.tb-name { flex: 1 1 240px; min-width: 0; }
.doc-side { flex: none; width: 272px; align-self: flex-start; display: grid; gap: 8px; }
.doc-control { margin: 0; border: 1px solid var(--rule); font-size: .75rem; }
.doc-control > div { display: grid; grid-template-columns: 104px minmax(0, 1fr); border-bottom: 1px solid var(--rule); }
.doc-control > div:last-child { border-bottom: 0; }
.doc-control dt { padding: 5px 8px; background: var(--band); color: var(--ink-3); font-weight: 600; border-right: 1px solid var(--rule); }
.doc-control dd { margin: 0; padding: 5px 8px; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.logo-mat { width: 88px; height: 88px; flex: none; display: grid; place-items: center; padding: 10px; background: #fff; border: 1px solid var(--rule); }
.logo-mat img { max-width: 100%; max-height: 100%; object-fit: contain; }
.kicker { font-size: .75rem; font-weight: 600; color: var(--accent); margin-bottom: 4px; }
.title-block h1 { font-size: 2.125rem; line-height: 1.1; font-weight: 700; letter-spacing: -.015em; }
.tb-aka { color: var(--ink-2); margin-top: 2px; }
.tb-desc { color: var(--ink-2); margin-top: 6px; max-width: 70ch; font-size: 1rem; }

.terms { margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); border-top: 1px solid var(--rule); border-left: 1px solid var(--rule); }
.terms > div { padding: 8px 12px; border-right: 1px solid var(--rule); border-bottom: 1px solid var(--rule); min-width: 0; }
.terms dt { display: flex; align-items: center; gap: 5px; font-size: .75rem; font-weight: 600; color: var(--ink-3); }
.terms dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }

.receipt { background: var(--band); border: 1px solid var(--rule); padding: 14px 16px; display: grid; gap: 12px; }
.receipt-main { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.receipt-label { font-weight: 700; }
.receipt-count { color: var(--ink-2); }
.explain { font-size: .875rem; }
.explain summary { color: var(--accent); cursor: pointer; text-decoration: underline dotted; text-underline-offset: 3px; list-style: none; min-height: 24px; display: inline-flex; align-items: center; }
.explain summary::-webkit-details-marker { display: none; }
.explain p { margin-top: 6px; max-width: 62ch; color: var(--ink-2); }
.explain[open] { flex-basis: 100%; margin-left: 0; }
.strip { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(28px, 1fr)); gap: 2px; }
.strip a {
	display: grid; place-items: center; height: 30px;
	font-size: .75rem; font-weight: 700; text-decoration: none;
	transition: filter .15s ease-out;
}
.strip a:hover { filter: brightness(.94); }
.legend { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: .75rem; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 12px; display: inline-block; }
.receipt-foot { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 6px 20px; }
.evidence-line { font-size: .875rem; color: var(--ink-2); }
.foundation { border: 1px solid var(--rule); }
.foundation summary { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; min-height: 44px; padding: 8px 16px; cursor: pointer; list-style: none; }
.foundation summary::-webkit-details-marker { display: none; }
.foundation summary::after { content: ""; width: 7px; height: 7px; margin-left: auto; border-right: 2px solid var(--ink-3); border-bottom: 2px solid var(--ink-3); transform: rotate(45deg); transition: transform .15s ease-out; }
.foundation[open] summary::after { transform: rotate(-135deg); }
.foundation summary:hover .foundation-title { color: var(--accent); }
.foundation-title { font-weight: 700; }
.foundation-glance { font-size: .875rem; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.foundation .foundation-grid { width: calc(100% - 32px); max-width: 560px; margin: 0 16px; }
.foundation-grid thead th { padding: 7px 10px; }
.foundation-grid tbody th { background: none; color: var(--ink); font-size: .875rem; font-weight: 400; padding: 7px 10px; vertical-align: middle; white-space: normal; }
.foundation-grid td { font-weight: 600; font-variant-numeric: tabular-nums; min-width: 160px; vertical-align: middle; }
.foundation-note { margin: 10px 16px 14px; max-width: 70ch; font-size: .75rem; color: var(--ink-3); }
.completion-body { display: grid; gap: 12px; padding: 4px 16px 16px; }
.completion-note, .completion-how { max-width: 78ch; color: var(--ink-2); }
.completion-how { font-size: .75rem; color: var(--ink-3); }
.stars { display: inline-block; font-size: 1.0625rem; line-height: 1; background: linear-gradient(90deg, var(--star) var(--fill), var(--rule-strong) var(--fill)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.stars::before { content: "\2605\2605\2605\2605\2605"; }
.evidence-line strong { color: var(--ink); }
.pending-note { color: var(--ink-2); max-width: 70ch; }
.pending-note.is-late { color: var(--neutral-ink); background: var(--neutral-fill); padding: 8px 10px; }

/* ---------- Chapter index (sticky) ---------- */
.chapter-index {
	position: sticky; top: -24px; z-index: 5;
	display: flex; align-items: stretch; gap: 8px;
	background: var(--paper); border-bottom: 1px solid var(--rule);
	padding-right: 12px;
}
.ci-links { display: flex; flex-wrap: nowrap; overflow-x: auto; flex: 1; min-width: 0; padding: 0 32px 0 20px; scrollbar-width: thin; scrollbar-color: var(--rule-strong) transparent; -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 40px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 40px), transparent); }
.ci-links.is-scrolled { -webkit-mask-image: linear-gradient(90deg, transparent, #000 40px, #000 calc(100% - 40px), transparent); mask-image: linear-gradient(90deg, transparent, #000 40px, #000 calc(100% - 40px), transparent); }
.ci-links.is-scrolled.at-end { -webkit-mask-image: linear-gradient(90deg, transparent, #000 40px); mask-image: linear-gradient(90deg, transparent, #000 40px); }
.ci-links.at-end:not(.is-scrolled) { -webkit-mask-image: none; mask-image: none; }
.ci-links::-webkit-scrollbar { height: 4px; }
.ci-links::-webkit-scrollbar-thumb { background: var(--rule-strong); }
.ci-links a {
	display: inline-flex; align-items: center; flex: none; min-height: 42px; padding: 0 10px;
	white-space: nowrap; font-size: .875rem; color: var(--ink-2); text-decoration: none;
	box-shadow: inset 0 -2px 0 transparent; transition: box-shadow .15s ease-out, color .15s ease-out;
}
.ci-links a .ref { margin-right: .45em; }
.ci-links a .icon { margin-right: 5px; }
.ci-links a[aria-current="true"] .icon { color: var(--accent); }
.ci-links a .count { margin-left: .4em; }
.ci-links a:hover { color: var(--ink); }
.ci-links a[aria-current="true"] { color: var(--ink); font-weight: 600; box-shadow: inset 0 -2px 0 var(--accent); }
.ci-all { align-self: center; border: 0; background: none; color: var(--accent); font-size: .875rem; font-weight: 600; cursor: pointer; padding: 6px 8px; min-height: 32px; white-space: nowrap; }
.ci-all:hover { text-decoration: underline; }

/* ---------- Chapters ---------- */
.chapter { border-bottom: 1px solid var(--rule); scroll-margin-top: 60px; }
.chapter:last-child { border-bottom: 0; }
.chapter-band { display: flex; align-items: center; gap: 12px; padding: 8px 32px; min-height: 52px; background: var(--band); border-bottom: 1px solid var(--rule); }
.chapter-band h2 { flex: 1; font-size: 1.125rem; font-weight: 650; min-width: 0; }
.ch-toggle { display: inline-flex; align-items: center; gap: 10px; min-height: 36px; padding: 0; border: 0; background: none; font-weight: inherit; cursor: pointer; text-align: left; }
.ch-toggle .ref { margin-right: 0; }
.ch-toggle .icon { margin-right: -2px; }
.h-icon { display: inline-flex; align-items: center; gap: 10px; }
.chev { width: 8px; height: 8px; border-right: 2px solid var(--ink-3); border-bottom: 2px solid var(--ink-3); transform: rotate(45deg) translate(-2px, -2px); transition: transform .2s ease-out; flex: none; }
.ch-toggle[aria-expanded="false"] .chev { transform: rotate(-45deg); }
.received { font-size: .875rem; color: var(--ink-3); white-space: nowrap; }
a.received { color: var(--ink-2); text-decoration: underline dotted; text-underline-offset: 3px; min-height: 24px; display: inline-flex; align-items: center; }
a.received:hover { color: var(--accent); }
.chapter-body { padding: 20px 32px 28px; }
.chapter-body[hidden] { display: none; }

/* Line items: a ruled two-line grid */
.items { margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); border-top: 1px solid var(--rule); border-left: 1px solid var(--rule); }
.item { padding: 9px 12px 10px; border-right: 1px solid var(--rule); border-bottom: 1px solid var(--rule); min-width: 0; }
.item.wide { grid-column: 1 / -1; }
.item dt { font-size: .75rem; font-weight: 600; color: var(--ink-2); margin-bottom: 2px; }
.item dt .ref { margin-right: .5em; }
.item dd { margin: 0; overflow-wrap: anywhere; }
.item.wide dd { max-width: 68ch; }
.item-img { display: block; max-width: 140px; max-height: 40px; object-fit: contain; background: #fff; padding: 4px; border: 1px solid var(--rule); }

.block, .items + .items { margin-top: 24px; }
.block:first-child { margin-top: 0; }
.block + .items { margin-top: 24px; }
.block-head { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; min-height: 28px; }
.block-head h3 { flex: 1; font-size: 1rem; font-weight: 650; }
.block-head h3 .ref { margin-right: .5em; }

/* Tables */
.tbl-frame { position: relative; overflow-x: auto; max-width: 100%; }
.grid { border-collapse: collapse; width: 100%; font-size: .875rem; }
.grid th { background: var(--band); color: var(--ink-2); font-size: .75rem; font-weight: 600; text-align: left; border: 1px solid var(--rule); padding: 0; white-space: nowrap; vertical-align: bottom; }
.grid th.num { text-align: right; }
.grid th.th-ev { padding: 7px 10px; }
.grid td { border: 1px solid var(--rule); padding: 7px 10px; vertical-align: top; }
.grid td.date { white-space: nowrap; }
.grid td.td-ev { white-space: nowrap; padding: 3px 4px; }
.grid tbody tr:hover td { background: color-mix(in srgb, var(--band) 60%, transparent); }
.th-sort { display: flex; align-items: center; gap: 6px; width: 100%; min-height: 32px; padding: 6px 10px; border: 0; background: none; font-weight: inherit; text-align: inherit; cursor: pointer; white-space: nowrap; }
.num .th-sort { justify-content: flex-end; }
.th-sort::after { content: ""; width: 0; height: 0; border-left: 4px solid transparent; border-right: 4px solid transparent; border-top: 5px solid var(--rule-strong); opacity: .9; }
th[aria-sort="ascending"] .th-sort::after { border-top: 0; border-bottom: 5px solid var(--ink-2); }
th[aria-sort="descending"] .th-sort::after { border-top-color: var(--ink-2); }
.th-sort:hover { color: var(--ink); }
.tbl-frame .grid tr > :first-child { position: sticky; left: 0; z-index: 1; background: var(--paper); }
.tbl-frame .grid thead tr > :first-child { background: var(--band); }
.tbl-frame .grid tbody tr:hover > :first-child { background: color-mix(in srgb, var(--band) 60%, var(--paper)); }
.thumb { width: 36px; height: 36px; object-fit: cover; border: 1px solid var(--rule); display: block; }
.cell-avatar { display: flex; align-items: center; gap: 10px; min-width: 12em; }
.cell-avatar .thumb { flex: none; }

/* Plain lists side by side (top linked entities): ruled columns, one entry per line. */
.entities { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); border-top: 1px solid var(--rule); border-left: 1px solid var(--rule); }
.entity-col { border-right: 1px solid var(--rule); border-bottom: 1px solid var(--rule); min-width: 0; }
.entity-col h4 { margin: 0; padding: 7px 12px; background: var(--band); border-bottom: 1px solid var(--rule); font-size: .75rem; font-weight: 600; color: var(--ink-2); }
.entity-col h4 .ref { margin-right: .5em; }
.entity-col ul { list-style: none; margin: 0; padding: 0; }
.entity-col li { padding: 5px 12px; font-size: .875rem; border-bottom: 1px solid var(--rule); overflow-wrap: anywhere; }
.entity-col li:last-child { border-bottom: 0; }

/* Evidence cells */
.evidence {
	display: inline-flex; align-items: center; min-height: 28px; padding: 3px 8px;
	border: 0; border-radius: 3px; background: none; color: var(--accent);
	font-size: .75rem; font-weight: 500; cursor: pointer; white-space: nowrap;
}
.evidence .icon { color: currentColor; margin-right: 4px; opacity: .8; }
.evidence .ev-n { font-weight: 700; margin-right: .3em; }
.evidence .ev-date { color: var(--ink-3); margin-left: .35em; }
.evidence:hover { background: var(--accent-soft); }

/* People */
.person { display: flex; align-items: center; gap: 14px; padding: 12px; border: 1px solid var(--rule); }
.person-photo { width: 64px; height: 64px; object-fit: cover; border: 1px solid var(--rule); flex: none; }
.person-body { flex: 1; min-width: 0; }
.person-name { font-size: 1rem; font-weight: 700; }
.person-title { color: var(--ink-2); }
.person-meta { font-size: .875rem; color: var(--ink-3); margin-top: 2px; }

/* Exhibits */
.exhibits { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.exhibits figure { margin: 0; border: 1px solid var(--rule); background: #fff; }
.exhibits img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; }
.exhibits figcaption { padding: 8px 10px; font-size: .875rem; background: var(--paper); border-top: 1px solid var(--rule); }

/* Outstanding items */
.out-intro { color: var(--ink-2); max-width: 70ch; margin-bottom: 18px; }
.out-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 22px 28px; align-items: start; }
.out-group { scroll-margin-top: 60px; }
.out-group h3 { font-size: .875rem; font-weight: 650; margin-bottom: 6px; }
.out-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule); font-size: .875rem; }
.out-list li { display: grid; grid-template-columns: 4em minmax(0, 1fr) auto; gap: 10px; align-items: baseline; padding: 6px 0; border-bottom: 1px solid var(--rule); }
.out-ref { color: var(--ink-3); font-weight: 500; }
a.out-ref { text-decoration: none; }
a.out-ref:hover { color: var(--accent); text-decoration: underline; }
.out-n { color: var(--ink-3); font-size: .75rem; white-space: nowrap; }
.out-action { display: flex; align-items: center; gap: 12px; margin-top: 22px; }
.out-note { color: var(--ink-2); font-size: .875rem; }

/* Other company-related images */
.related-intro { color: var(--ink-2); font-style: italic; margin-bottom: 14px; }
.related figcaption a { color: var(--ink-3); font-size: .75rem; }

/* Empty state (home) */
.empty-state .chapter-body { display: grid; gap: 12px; justify-items: start; padding: 40px 32px; }
.empty-state h2 { font-size: 1.125rem; }
.empty-state p { color: var(--ink-2); max-width: 65ch; }

/* ---------- Dialogs ---------- */
.dialog {
	width: min(480px, calc(100vw - 32px)); padding: 0;
	border: 1px solid var(--rule-strong); border-radius: 3px;
	background: var(--paper); color: var(--ink); box-shadow: var(--shadow);
}
.dialog::backdrop { background: rgba(20, 32, 46, .38); }
.dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 18px 20px 6px; }
.dialog-head h2 { font-size: 1.125rem; font-weight: 700; padding-top: 4px; }
.dialog-hint { padding: 0 20px; color: var(--ink-2); font-size: .875rem; }
.firmo-form { padding: 14px 20px 20px; }
.firmo-form .field { margin-bottom: 12px; }
.firmo-form label { display: block; font-size: .875rem; font-weight: 600; }
.firmo-form .req { color: var(--bad-ink); }
.firmo-form .wpcf7-form-control-wrap { display: block; margin-top: 4px; }
.firmo-form input[type="text"] {
	width: 100%; min-height: 38px; padding: 8px 10px;
	border: 1px solid var(--rule-strong); border-radius: 3px; background: var(--paper); font-size: .875rem;
}
.firmo-form input[type="text"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
.firmo-form .wpcf7-not-valid { border-color: var(--bad-ink) !important; }
.firmo-form .wpcf7-not-valid-tip { color: var(--bad-ink); font-size: .75rem; margin-top: 3px; }
.field-group { margin: 16px 0 0; padding: 12px 12px 4px; border: 1px solid var(--rule); min-width: 0; }
.field-group legend { padding: 0 6px; font-size: .75rem; font-weight: 600; color: var(--ink-3); }
.field-note { font-size: .75rem; color: var(--ink-3); margin-bottom: 8px; }
.dup-hint { background: var(--neutral-fill); color: var(--neutral-ink); padding: 8px 10px; font-size: .875rem; margin-bottom: 12px; }
.dup-hint a { color: inherit; font-weight: 700; }
.dialog-actions { display: flex; justify-content: flex-end; align-items: center; gap: 8px; margin-top: 16px; }
.dialog-actions .wpcf7-spinner { order: -1; margin: 0; }
.wpcf7 form .wpcf7-response-output { margin: 14px 0 0; padding: 8px 10px; border: 1px solid var(--rule-strong); font-size: .875rem; }
.wpcf7 form.invalid .wpcf7-response-output, .wpcf7 form.failed .wpcf7-response-output { border-color: var(--bad-ink); color: var(--bad-ink); }
.wpcf7 form.sent .wpcf7-response-output { border-color: var(--good-ink); color: var(--good-ink); }

/* ---------- Information pages & site footer ---------- */
.prose { padding: 24px 32px 36px; max-width: 78ch; }
.prose > * + * { margin-top: 12px; }
.prose h2 { font-size: 1.125rem; font-weight: 650; margin-top: 28px; }
.prose h3 { font-size: 1rem; font-weight: 650; margin-top: 20px; }
.prose p, .prose li { font-size: 1rem; color: var(--ink-2); }
.prose ul { margin: 12px 0 0; padding-left: 20px; }
.prose strong { color: var(--ink); }
.prose blockquote { margin: 20px 0 0; padding: 10px 16px; border-left: 3px solid var(--accent); background: var(--band); }
.prose blockquote p { color: var(--ink); font-weight: 600; }
.prose .formula { padding: 10px 14px; border: 1px solid var(--rule); background: var(--band); color: var(--ink); font-weight: 650; }
.prose .grid { max-width: 520px; }
.prose .grid th, .prose .grid td { padding: 7px 10px; }
/* Pinned to the bottom of the scrolling desk; the negative margins cancel the desk padding. */
.site-foot { position: sticky; bottom: 0; z-index: 6; flex: none; margin: auto -28px 0; padding: 6px 28px; display: flex; align-items: center; justify-content: space-between; gap: 0 24px; background: var(--paper); border-top: 1px solid var(--rule); font-size: .75rem; color: var(--ink-3); }
.site-foot p { flex: none; }
.site-foot nav { display: flex; gap: 4px 16px; min-width: 0; overflow-x: auto; white-space: nowrap; scrollbar-width: none; }
.site-foot a { flex: none; }
.site-foot a { color: var(--ink-2); min-height: 24px; display: inline-flex; align-items: center; }
.site-foot a:hover { color: var(--accent); }

/* Provenance drawer */
.drawer { margin: 0 0 0 auto; width: min(560px, 100vw); height: 100dvh; max-height: none; border-width: 0 0 0 1px; border-radius: 0; display: none; flex-direction: column; }
.drawer[open] { display: flex; animation: drawer-in .22s cubic-bezier(.16, 1, .3, 1); }
@keyframes drawer-in { from { transform: translateX(24px); opacity: .6; } }
@media (prefers-reduced-motion: reduce) { .drawer[open] { animation: none; } }
.src-path { font-size: .875rem; color: var(--ink-2); margin-top: 2px; }
.src-tools { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 20px; border-bottom: 1px solid var(--rule); font-size: .875rem; }
.src-count { color: var(--ink-2); }
.src-sort select { margin-left: 6px; min-height: 30px; padding: 3px 6px; border: 1px solid var(--rule-strong); border-radius: 3px; background: var(--paper); }
.src-list { list-style: none; margin: 0; padding: 0 20px 24px; overflow: auto; flex: 1; }
.src-list li { padding: 14px 0; border-bottom: 1px solid var(--rule); }
.src-title { font-weight: 600; }
.src-meta { font-size: .75rem; color: var(--ink-3); margin: 3px 0 5px; }
.src-snip { font-size: .875rem; color: var(--ink-2); }
.src-state { padding: 18px 0; color: var(--ink-2); display: flex; gap: 12px; align-items: center; }

/* Toast */
.toast { position: fixed; bottom: 20px; right: 20px; z-index: 60; padding: 10px 16px; background: var(--ink); color: var(--paper); font-size: .875rem; font-weight: 600; border-radius: 3px; opacity: 0; transform: translateY(8px); transition: opacity .2s ease-out, transform .2s ease-out; pointer-events: none; }
.toast.show { opacity: 1; transform: none; }

/* ---------- Phone ---------- */
@media (max-width: 859px) {
	.app { grid-template-columns: minmax(0, 1fr); height: auto; }
	.admin-bar .app { height: auto; }
	.register { border-right: 0; border-bottom: 1px solid var(--rule); }
	.reg-head { padding: 12px 16px; }
	.reg-toggle {
		display: flex; align-items: center; justify-content: space-between; width: 100%; min-height: 44px; padding: 0 16px;
		border: 0; border-top: 1px solid var(--rule); background: var(--band); font-weight: 600; cursor: pointer;
	}
	.reg-toggle::after { content: ""; width: 8px; height: 8px; border-right: 2px solid var(--ink-3); border-bottom: 2px solid var(--ink-3); transform: rotate(45deg); }
	.reg-toggle[aria-expanded="true"]::after { transform: rotate(-135deg); }
	.register.is-collapsed .reg-body { display: none; }
	.reg-search { padding-top: 12px; }
	.reg-search kbd, .reg-foot { display: none; }
	.tb-identity { flex-wrap: wrap; }
	.doc-side { width: 100%; }
	.doc-side .btn-export { justify-self: start; }
	.doc-control { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
	.doc-control > div { grid-template-columns: minmax(0, 1fr); border-right: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
	.doc-control > div:nth-child(2n) { border-right: 0; }
	.doc-control > div:nth-last-child(-n+2):nth-child(odd), .doc-control > div:last-child { border-bottom: 0; }
	.doc-control dt { border-right: 0; }
	.reg-list { max-height: 50vh; }
	.desk { overflow: visible; padding: 0; }
	.sheet { border-width: 0 0 1px; margin-bottom: 0; }
	.title-block { padding: 20px 16px; }
	.sheet > .title-block:first-child:has(> .btn) { grid-template-columns: minmax(0, 1fr); }
	.tb-identity { align-items: flex-start; gap: 14px; }
	.logo-mat { width: 64px; height: 64px; padding: 6px; }
	.title-block h1 { font-size: 1.5rem; }
	.terms { grid-template-columns: repeat(2, minmax(0, 1fr)); }
	.explain { margin-left: 0; }
	.strip { grid-template-columns: repeat(6, minmax(0, 1fr)); }
	.chapter-index { top: 0; padding-right: 4px; }
	.ci-links { padding-left: 4px; scrollbar-width: none; }
	.chapter, .out-group { scroll-margin-top: 48px; }
	.ci-links a { min-height: 40px; padding: 0 10px; }
	.chapter-band { padding: 6px 16px; flex-wrap: wrap; row-gap: 0; }
	.chapter-band h2 { font-size: 1rem; flex-basis: 100%; }
	.chapter-band .evidence { margin-left: auto; }
	.chapter-body { padding: 16px; }
	.items { grid-template-columns: minmax(0, 1fr); }
	.tbl-frame .grid { width: max-content; min-width: 100%; }
	.tbl-frame .grid td { max-width: 15em; }
	.out-grid { grid-template-columns: minmax(0, 1fr); }
	.prose { padding: 16px; }
	.site-foot { margin: 0; padding: 4px 16px; }
	.site-foot p { display: none; }
	.site-foot a { min-height: 36px; }
	.person { align-items: flex-start; flex-wrap: wrap; }
	.drawer { width: 100vw; border-width: 0; }
}

/* ---------- Print (committee memos, PDF) ---------- */
@media print {
	@page { margin: 14mm; }
	body { background: #fff; color: #000; font-size: 10pt; }
	.app { display: block; height: auto; }
	.register, .chapter-index, .skip-link, .toast, .site-foot, dialog, .evidence, .explain, .btn-export, .out-action, .ch-toggle .chev, .ci-all, [data-open] { display: none !important; }
	.desk { overflow: visible; padding: 0; }
	.desk { display: block; }
	.sheet { border: 0; max-width: none; }
	.title-block, .chapter-band, .chapter-body { padding-left: 0; padding-right: 0; }
	.chapter-body[hidden] { display: block !important; }
	.chapter-band { break-after: avoid; }
	.chapter-band, .out-group, .person, .item, .grid tr { break-inside: avoid; }
	.tbl-frame { overflow: visible; }
	.tbl-frame .grid tr > :first-child { position: static; }
	.foundation .foundation-grid { margin-left: 0; }
	.status, .strip a, .legend i, .receipt, .chapter-band, .grid th, .stars { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
	.item dd a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 8pt; color: #3d4b5c; overflow-wrap: anywhere; }
}

/* ---------- Tablet (600–859px): phone structure, but use the width ---------- */
@media (min-width: 600px) and (max-width: 859px) {
	.terms { grid-template-columns: repeat(3, minmax(0, 1fr)); }
	.strip { grid-template-columns: repeat(12, minmax(0, 1fr)); }
	.items { grid-template-columns: repeat(2, minmax(0, 1fr)); }
	.items .item.wide { grid-column: 1 / -1; }
	.title-block, .chapter-body { padding-left: 24px; padding-right: 24px; }
	.chapter-band { padding-left: 24px; padding-right: 24px; }
}
