/* Identity PoC: hand-written CSS on shadcn/ui's tokens (zinc base, 0.5rem radius). No build step.
   Light is the default; dark follows the system unless the top-bar toggle pins a theme (html[data-theme]).
   Two badge families: a relation's state is a filled pill (.state-*), an evidence class an outlined pill with a
   coloured dot (.evc .evc-*). Plain colour classes (.ok, .warn, .no) mark status only. */

:root {
  --background: #ffffff;
  --foreground: #09090b;
  --card: #ffffff;
  --muted: #f4f4f5;
  --muted-foreground: #6b6b74;
  --border: #e4e4e7;
  --input: #d4d4d8;
  --ring: #a1a1aa;
  --primary: #18181b;
  --primary-foreground: #fafafa;
  --link: #1d4ed8;
  --radius: 0.5rem;
  --ok: #15803d;      --ok-bg: #ecfdf3;      --ok-line: #a7e9c0;
  --warn: #a15c07;    --warn-bg: #fffbeb;    --warn-line: #fcd88a;
  --no: #b91c1c;      --no-bg: #fef2f2;      --no-line: #fcb4b4;
  --off: #52525b;     --off-bg: #f4f4f5;     --off-line: #d4d4d8;
  /* evidence classes, from strongest to weakest */
  --ev-registry: #047857;
  --ev-report: #0e7490;
  --ev-agent: #6d28d9;
  --ev-self: #1d4ed8;
  --ev-inferred: #c2410c;
  --ev-asserted: #8a8a94;
  --ev-profile: #be185d;
  --ev-customer: #4d7c0f;
  --shadow: 0 1px 2px rgba(9, 9, 11, .05);
  --bar: rgba(255, 255, 255, .88);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --background: #09090b; --foreground: #fafafa; --card: #111113; --muted: #1c1c1f; --muted-foreground: #a1a1aa;
    --border: #27272a; --input: #3f3f46; --ring: #71717a; --primary: #fafafa; --primary-foreground: #18181b;
    --link: #93b4ff;
    --ok: #4ade80; --ok-bg: #06200f; --ok-line: #166534;
    --warn: #fbbf24; --warn-bg: #261a04; --warn-line: #854d0e;
    --no: #f87171; --no-bg: #2a0b0b; --no-line: #991b1b;
    --off: #a1a1aa; --off-bg: #1c1c1f; --off-line: #3f3f46;
    --ev-registry: #34d399; --ev-report: #22d3ee; --ev-agent: #a78bfa; --ev-self: #93b4ff;
    --ev-inferred: #fb923c; --ev-asserted: #a1a1aa; --ev-profile: #f472b6; --ev-customer: #a3e635;
    --shadow: none; --bar: rgba(9, 9, 11, .88);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --background: #09090b; --foreground: #fafafa; --card: #111113; --muted: #1c1c1f; --muted-foreground: #a1a1aa;
  --border: #27272a; --input: #3f3f46; --ring: #71717a; --primary: #fafafa; --primary-foreground: #18181b;
  --link: #93b4ff;
  --ok: #4ade80; --ok-bg: #06200f; --ok-line: #166534;
  --warn: #fbbf24; --warn-bg: #261a04; --warn-line: #854d0e;
  --no: #f87171; --no-bg: #2a0b0b; --no-line: #991b1b;
  --off: #a1a1aa; --off-bg: #1c1c1f; --off-line: #3f3f46;
  --ev-registry: #34d399; --ev-report: #22d3ee; --ev-agent: #a78bfa; --ev-self: #93b4ff;
  --ev-inferred: #fb923c; --ev-asserted: #a1a1aa; --ev-profile: #f472b6; --ev-customer: #a3e635;
  --shadow: none; --bar: rgba(9, 9, 11, .88);
  color-scheme: dark;
}

/* ---- base ---- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--background); color: var(--foreground);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; border-radius: 4px; }
h1 { font-size: 1.6rem; line-height: 1.25; font-weight: 650; letter-spacing: -.02em; margin: 0 0 20px; }
h2 { font-size: 1.05rem; font-weight: 600; letter-spacing: -.01em; margin: 30px 0 10px; }
h3 { font-size: .95rem; font-weight: 600; margin: 0 0 6px; }
h4 { font-size: .8rem; font-weight: 600; color: var(--muted-foreground); margin: 16px 0 6px; }
p { margin: 6px 0; }
ul, ol { margin: 4px 0; padding-left: 20px; }
li { margin: 2px 0; }
code, pre, kbd, .urn { font-family: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, monospace; }
code { font-size: .85em; background: var(--muted); border-radius: 4px; padding: 1px 5px; }
.urn { font-size: .72rem; color: var(--muted-foreground); word-break: break-all; }
a.urn { color: var(--link); }
pre.excerpt {
  white-space: pre-wrap; font-size: .78rem; background: var(--muted); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px 12px; max-height: 220px; overflow: auto;
}
q { quotes: "\201C" "\201D"; }
blockquote {
  margin: 6px 0; padding: 6px 12px; border-left: 3px solid var(--input); background: var(--muted);
  border-radius: 0 6px 6px 0;
}
.dim { color: var(--muted-foreground); font-size: .92em; }
.dim .dim { font-size: 1em; }
.ok { color: var(--ok); } .warn { color: var(--warn); } .no { color: var(--no); }

/* ---- app shell ---- */
.topbar {
  position: sticky; top: 0; z-index: 20; background: var(--bar);
  -webkit-backdrop-filter: saturate(1.4) blur(8px); backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar-in {
  max-width: 1600px; margin: 0 auto; padding: 0 24px; min-height: 56px;
  display: flex; align-items: center; gap: 8px 20px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 650; letter-spacing: -.01em; color: var(--foreground); white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand-mark { display: grid; grid-template-columns: repeat(3, 5px); grid-template-rows: repeat(2, 5px); gap: 2px; }
.brand-mark i { background: var(--foreground); border-radius: 1px; }
.brand-mark i:nth-child(2), .brand-mark i:nth-child(6) { background: var(--ev-registry); }
.brand-mark i:nth-child(4) { opacity: .35; }
.topnav { display: flex; gap: 2px; flex-wrap: wrap; }
.topnav a { color: var(--muted-foreground); padding: 6px 12px; border-radius: 6px; font-weight: 500; white-space: nowrap; }
.topnav a:hover { color: var(--foreground); background: var(--muted); text-decoration: none; }
.topnav a[aria-current="page"] { color: var(--foreground); background: var(--muted); box-shadow: inset 0 -2px 0 var(--foreground); border-radius: 6px 6px 2px 2px; }
.asof { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.asof label { display: flex; align-items: center; gap: 8px; margin: 0; color: var(--muted-foreground); font-size: .82rem; font-weight: 500; white-space: nowrap; }
.asof input[type=date] { margin: 0; height: 32px; padding: 0 8px; display: inline-block; }
.asof button { height: 32px; }
.asof a { font-size: .82rem; white-space: nowrap; }
.asof.on input[type=date] { border-color: var(--warn); box-shadow: 0 0 0 1px var(--warn); }
.theme-toggle { width: 32px; height: 32px; padding: 0; }
.theme-toggle svg { width: 16px; height: 16px; }
main { max-width: 1600px; margin: 0 auto; padding: 28px 24px 72px; }
/* the page header: every page opens with its h1 and, mostly, a one-line explanation */
main > h1 + p.dim, main > h1 + p { color: var(--muted-foreground); font-size: .92rem; margin: -16px 0 18px; max-width: 100ch; }
main > h1 + p.tabs { margin-top: -6px; }
/* inline radio labels (Search: collapse to) */
label[style*="inline"] { margin: 0 12px 0 4px; font-weight: 400; }
main > h1 .dim { font-size: .9rem; font-weight: 400; letter-spacing: 0; }

/* ---- surfaces ---- */
.card, article.card {
  background: var(--card); border: 1px solid var(--border); border-radius: calc(var(--radius) + 2px);
  padding: 14px 16px; margin-bottom: 12px; box-shadow: var(--shadow);
}
.error, .notice, .banner {
  border: 1px solid var(--border); border-left-width: 4px; border-radius: var(--radius); padding: 10px 14px; margin: 10px 0;
  background: var(--card); color: var(--foreground); max-width: 120ch;
}
.error { border-color: var(--no-line); border-left-color: var(--no); background: var(--no-bg); }
.notice { border-color: var(--ok-line); border-left-color: var(--ok); background: var(--ok-bg); }
.banner { border-color: var(--warn-line); border-left-color: var(--warn); background: var(--warn-bg); }
.banner p:first-child { margin-top: 0; }

.cols { display: flex; gap: 28px; align-items: flex-start; }
.side { width: 260px; flex: none; position: sticky; top: 76px; max-height: calc(100vh - 96px); overflow: auto; }
.side > h2:first-child { margin-top: 0; font-size: .85rem; color: var(--muted-foreground); }
.main { flex: 1; min-width: 0; }
.main > h2:first-child { margin-top: 0; }
@media (max-width: 900px) {
  .cols { flex-direction: column; }
  .side { width: 100%; position: static; max-height: none; }
}

/* ---- chips and badges ---- */
.chip, .badge {
  display: inline-flex; align-items: center; gap: 5px; vertical-align: 1px; white-space: nowrap;
  border: 1px solid var(--border); border-radius: 999px; padding: 0 8px; min-height: 20px;
  font-size: .72rem; font-weight: 500; line-height: 1.2; color: var(--foreground); background: var(--muted);
  margin-right: 4px;
}
.chip.warn { color: var(--warn); border-color: var(--warn-line); background: var(--warn-bg); }
/* relation and value state: filled */
.state-active { color: var(--ok); background: var(--ok-bg); border-color: var(--ok-line); }
.state-needs_review { color: var(--warn); background: var(--warn-bg); border-color: var(--warn-line); }
.state-refused { color: var(--no); background: var(--no-bg); border-color: var(--no-line); }
.state-ended, .state-retracted, .state-undone { color: var(--off); background: var(--off-bg); border-color: var(--off-line); }
/* evidence class: outlined, with a dot in the class colour */
.evc { background: transparent; --c: var(--ev-asserted); }
.evc::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--c); flex: none; }
.evc-registry, .evc-registry-confirmed { --c: var(--ev-registry); }
.evc-annual_report, .evc-annual-report { --c: var(--ev-report); }
.evc-agent-verified { --c: var(--ev-agent); }
.evc-own_website, .evc-self-declared { --c: var(--ev-self); }
.evc-inferred, .evc-other_website, .evc-third_party { --c: var(--ev-inferred); }
.evc-asserted { --c: var(--ev-asserted); }
.evc-crawler_profile { --c: var(--ev-profile); }
.evc-customer_list { --c: var(--ev-customer); }
td .chip, td .badge { margin: 1px 4px 1px 0; }
td .badge.evc { white-space: normal; padding-top: 2px; padding-bottom: 2px; }

/* ---- tabs (Add) ---- */
.tabs { display: inline-flex; gap: 2px; padding: 3px; background: var(--muted); border-radius: var(--radius); margin: 4px 0 18px; flex-wrap: wrap; }
.tabs a { color: var(--muted-foreground); padding: 5px 12px; border-radius: 6px; font-weight: 500; white-space: nowrap; }
.tabs a:hover { text-decoration: none; color: var(--foreground); }
.tabs a.on { background: var(--background); color: var(--foreground); box-shadow: 0 1px 2px rgba(0,0,0,.1); }

/* ---- tables ---- */
table {
  border-collapse: separate; border-spacing: 0; width: 100%; font-size: .85rem;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); margin: 6px 0 14px;
}
th, td { text-align: left; vertical-align: top; padding: 7px 12px; border-bottom: 1px solid var(--border); }
td a, td .urn, td q, td blockquote, ul.tree a { overflow-wrap: anywhere; }
td > code:first-child { white-space: nowrap; }
th { font-weight: 500; color: var(--muted-foreground); background: var(--muted); font-size: .78rem; vertical-align: middle; }
tr:first-child > th:first-child { border-top-left-radius: calc(var(--radius) - 1px); }
tr:first-child > th:last-child { border-top-right-radius: calc(var(--radius) - 1px); }
tr:last-child > td { border-bottom: 0; }
td ul { padding-left: 16px; margin: 0; }
td blockquote { margin: 0; }
td p:first-child { margin-top: 0; }
td.actions { white-space: nowrap; width: 1%; }
table.values td:nth-child(6), table.values td:nth-child(4) { white-space: nowrap; }
table.values td:first-child code { white-space: nowrap; }
table.relations td:first-child { min-width: 170px; }
table.relations td:first-child .urn { display: block; overflow-wrap: anywhere; }
table.relations td:nth-child(2) { min-width: 110px; }
table.relations td:nth-child(6) { min-width: 120px; }
table.relations td:nth-child(7) { min-width: 240px; }
table.relations td ul { padding-left: 14px; }
td.actions > * { vertical-align: middle; }
tr.retracted td { text-decoration: line-through; color: var(--muted-foreground); }
tr.retracted td.keep { text-decoration: none; }
tr.ev > td { background: var(--muted); padding: 0 16px; }
tr.ev > td:empty { padding: 0; border-bottom: 0; }
tr.ev > td > div { padding: 10px 0; }
tr.ev > td > div + div { border-top: 1px solid var(--border); }
table.undone { opacity: .6; }

/* ---- forms and buttons ---- */
:where(button) {
  font: inherit; font-size: .85rem; font-weight: 500; display: inline-flex; align-items: center; justify-content: center;
  gap: 6px; height: 34px; padding: 0 14px; white-space: nowrap; cursor: pointer; vertical-align: middle;
  border-radius: 6px; border: 1px solid var(--input); background: var(--background); color: var(--foreground);
  box-shadow: var(--shadow); transition: background-color .12s, border-color .12s, opacity .12s;
}
:where(button):hover { background: var(--muted); }
/* the form's main action is a filled button; small, inline and in-table actions are outlined. The generic rules
   sit in :where() so that a class (.primary, .secondary, .danger) on a button always wins. */
:where(form > button[type=submit]:last-of-type) { background: var(--primary); color: var(--primary-foreground); border-color: var(--primary); }
:where(form > button[type=submit]:last-of-type):hover { opacity: .88; background: var(--primary); }
:where(td button, form.inline > button, .rel .toolbar button) { background: var(--background); color: var(--foreground); border-color: var(--input); }
:where(td button, form.inline > button, .rel .toolbar button):hover { background: var(--muted); opacity: 1; }
td button { height: 28px; padding: 0 10px; font-size: .8rem; }
button.primary { background: var(--primary); color: var(--primary-foreground); border-color: var(--primary); }
button.primary:hover { background: var(--primary); opacity: .88; }
button.secondary { background: var(--background); color: var(--foreground); border-color: var(--input); }
button.secondary:hover { background: var(--muted); opacity: 1; }
button.danger { color: var(--no); border-color: var(--no-line); background: var(--background); }
button.danger:hover { background: var(--no-bg); opacity: 1; }
label { display: block; margin: 10px 0; font-weight: 500; font-size: .85rem; }
label input[type=checkbox], label input[type=radio] { margin: 0 6px 0 0; vertical-align: -2px; accent-color: var(--primary); }
input[type=text], input[type=date], input[type=number], input[type=file], select, textarea {
  font: inherit; font-size: .875rem; color: var(--foreground); background: var(--background);
  border: 1px solid var(--input); border-radius: 6px; height: 34px; padding: 0 10px; max-width: 100%; vertical-align: middle;
}
select { padding-right: 6px; min-width: 120px; }
input[type=file] { padding: 5px 8px; height: auto; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--ring); outline-offset: 1px; }
input::placeholder, textarea::placeholder { color: var(--muted-foreground); opacity: .75; }
label > input[type=text], label > input[type=date], label > input[type=number], label > select, label > textarea, label > input[type=file] {
  display: block; margin-top: 6px; font-weight: 400;
}
textarea {
  width: 100%; height: auto; padding: 10px 12px; font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: .8rem; line-height: 1.5;
}
fieldset { border: 1px solid var(--border); border-radius: var(--radius); margin: 14px 0; padding: 6px 16px 10px; background: var(--card); }
legend { font-weight: 600; font-size: .85rem; padding: 0 6px; }
form.inline { display: inline; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 12px 0; }
.toolbar form { display: inline-flex; gap: 6px; align-items: center; }
.toolbar label { margin: 0; display: inline-flex; align-items: center; gap: 6px; }
.toolbar label > input, .toolbar label > select { margin: 0; display: inline-block; }

details { margin: 4px 0; }
summary { cursor: pointer; color: var(--muted-foreground); font-weight: 500; font-size: .85rem; user-select: none; width: fit-content; }
summary:hover { color: var(--foreground); }
details[open] > summary { margin-bottom: 6px; }
kbd { font-size: .72rem; border: 1px solid var(--input); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; background: var(--muted); color: var(--muted-foreground); }

/* ---- trees (Explore, Result) ---- */
ul.tree { list-style: none; margin: 2px 0; padding-left: 14px; border-left: 1px solid var(--border); }
.side > ul.tree, .main > ul.tree, h4 + ul.tree { border-left: 0; padding-left: 0; }
ul.tree li { margin: 7px 0; line-height: 1.35; }
ul.tree b { font-weight: 650; }
ul.tree .urn { font-size: .66rem; }

/* ---- run steps: a vertical stepper ---- */
.steps a { position: relative; display: block; padding: 8px 10px; margin: 0; color: var(--foreground); border-radius: 6px; }
.steps a:hover { background: var(--muted); text-decoration: none; }
.steps a.on { background: var(--muted); font-weight: 600; }
.steps a .dim { display: block; font-weight: 400; font-size: .78rem; line-height: 1.35; margin-top: 1px; }
.side.steps a { padding-left: 40px; min-height: 52px; }
.side.steps a > span:first-child {
  position: absolute; left: 8px; top: 8px; width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center; font-size: .72rem; font-weight: 700; line-height: 1;
  border: 1.5px solid var(--input); background: var(--background); color: var(--muted-foreground); z-index: 1;
}
.side.steps a > span.ok:first-child { background: var(--ok); border-color: var(--ok); color: var(--background); }
.side.steps a > span.dim:first-child { color: transparent; }
.side.steps a > span.no:first-child { background: var(--no); border-color: var(--no); color: var(--background); }
/* The connector runs from the bottom of this step's circle to the top of the next one's, whatever the text height. */
.side.steps a:not(:last-child)::after { content: ""; position: absolute; left: 18.25px; top: 30px; bottom: -8px; width: 1.5px; background: var(--border); }
.side.steps a.step-succeeded:not(:last-child)::after { background: var(--ok); }

/* ---- a step's summary list: a soft panel ---- */
section.main > ul:not(.tree) { background: var(--muted); border-radius: var(--radius); padding: 10px 14px 10px 32px; margin: 8px 0 14px; }

/* ---- resolve: long mention lists scroll inside their card ---- */
article.card > ul { max-height: 216px; overflow: auto; padding-right: 8px; }

/* ---- resolve: relations inside a candidate ---- */
.rel { border-top: 1px solid var(--border); margin-top: 12px; padding-top: 10px; }
.outcome { font-weight: 600; margin: 4px 0 8px; }
.rel.active .outcome { color: var(--ok); } .rel.refused .outcome { color: var(--no); } .rel.needs_review .outcome { color: var(--warn); }
.rel.needs_review { border-left: 3px solid var(--warn); padding-left: 12px; }

/* ---- Cases: one compact row per case (a summary), its details below ---- */
.case-list { border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); margin: 6px 0 14px; font-size: .85rem; }
.case-head-row, details.case > summary {
  display: grid; grid-template-columns: minmax(0, 1fr) repeat(5, 5.2rem) minmax(7rem, 11rem); gap: 0 10px; align-items: center;
  padding: 8px 14px;
}
.case-head-row { background: var(--muted); color: var(--muted-foreground); font-size: .78rem; font-weight: 500; border-radius: calc(var(--radius) - 1px) calc(var(--radius) - 1px) 0 0; }
.case-head-row > span:not(:first-child) { text-align: right; }
details.case { margin: 0; border-top: 1px solid var(--border); }
details.case > summary { width: auto; list-style: none; color: var(--foreground); font-weight: 400; font-size: inherit; }
details.case > summary::-webkit-details-marker { display: none; }
details.case > summary:hover { background: var(--muted); }
details.case[open] > summary { margin: 0; background: var(--muted); }
.case-name { min-width: 0; position: relative; padding-left: 16px; }
.case-name::before { content: "\25B8"; position: absolute; left: 0; top: 1px; color: var(--muted-foreground); font-size: .75rem; }
details.case[open] .case-name::before { content: "\25BE"; }
.case-name > b { font-weight: 600; overflow-wrap: anywhere; }
.case-name > .urn { word-break: normal; white-space: nowrap; }
.case-name .chips { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 3px; }
.case-name .chips .chip { margin: 0; min-height: 18px; font-size: .68rem; }
.case-wide { grid-column: 2 / span 5; }
.m { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.m small { font-weight: 400; color: var(--muted-foreground); }
.m.bad { color: var(--no); } .m.bad small { color: var(--no); }
.m.bad::after { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--no); margin-left: 5px; vertical-align: 2px; }
.case-state { display: flex; flex-direction: column; align-items: flex-end; font-size: .75rem; line-height: 1.3; text-align: right; }
.case-body { padding: 10px 14px 14px 32px; border-top: 1px solid var(--border); }
.case-body > p.dim:first-child { margin-top: 0; max-width: 110ch; }
.case-body .toolbar { margin: 8px 0; }
table.case-inputs { width: auto; min-width: 26rem; max-width: 100%; margin: 10px 0 4px; }
table.case-inputs td { white-space: nowrap; vertical-align: middle; }
table.case-inputs td:first-child { white-space: normal; overflow-wrap: anywhere; }
table.case-inputs td button { height: 26px; }
.figures {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin: 0 0 8px;
}
.figure { padding: 7px 10px 8px; min-width: 0; cursor: default; margin: 0 -1px -1px 0; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.figure .v { display: block; font-size: 1.15rem; font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: -.01em; line-height: 1.3; white-space: nowrap; }
.figure .v small { font-size: .74rem; font-weight: 500; color: var(--muted-foreground); letter-spacing: 0; }
.figure .k { display: block; font-size: .72rem; color: var(--muted-foreground); line-height: 1.3; }
.figure .n { display: block; font-size: .68rem; color: var(--warn); line-height: 1.25; }
.figure.bad { background: var(--no-bg); } .figure.bad .v, .figure.bad .k { color: var(--no); }
.carried { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; font-size: .78rem; margin: 2px 0 4px; color: var(--muted-foreground); }
.carried .badge { margin: 0; }
.in-words { font-size: .82rem; color: var(--muted-foreground); margin-bottom: 10px; }
.in-words li { margin: 3px 0; }
.case-list details h4:first-of-type { margin-top: 8px; }

/* ---- Add: one readable column; an address on one row ---- */
main > form[action^="/runs"], main > form[action^="/vendors"] { max-width: 820px; }
fieldset:has(> label) { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0 12px; }
fieldset > label > input[type=text] { width: 100%; }
fieldset > p { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 8px 0; }
input[type=file]::file-selector-button { font: inherit; font-size: .8rem; border: 1px solid var(--input); border-radius: 4px; background: var(--muted); color: var(--foreground); padding: 3px 10px; margin-right: 10px; cursor: pointer; }

/* ---- vendor lists ---- */
p.filters { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; color: var(--muted-foreground); font-size: .85rem; margin: 6px 0 14px; }
p.filters a { padding: 3px 10px; border: 1px solid var(--border); border-radius: 999px; color: var(--foreground); white-space: nowrap; }
p.filters a:hover { background: var(--muted); text-decoration: none; }
p.filters > span { margin: 0 6px; }
p.filters a.export { border-style: dashed; }
p.filters a.on { background: var(--primary); color: var(--primary-foreground); border-color: var(--primary); }
.outcome-matched { color: var(--ok); background: var(--ok-bg); border-color: var(--ok-line); }
.outcome-needs_review { color: var(--warn); background: var(--warn-bg); border-color: var(--warn-line); }
.outcome-not_company { color: var(--off); background: var(--off-bg); border-color: var(--off-line); }
td.row-actions { width: 1%; white-space: nowrap; }
td.row-actions form { display: block; margin: 0 0 4px; }
td.row-actions button { width: 100%; }
td.row-actions p { white-space: normal; min-width: 180px; }

/* ---- judged precision tables (Judge, Cases, Agreement) ---- */
.judge-results-block { margin: 8px 0 24px; }
.judge-results-block > p.dim { max-width: 120ch; font-size: .82rem; }
table.judge-results th { white-space: normal; vertical-align: bottom; line-height: 1.3; }
table.judge-results td { font-variant-numeric: tabular-nums; }
table.judge-results td:first-child { min-width: 240px; }
table.judge-results td:not(:first-child) { white-space: nowrap; }
table.judge-results td .dim { font-size: .78rem; }

/* ---- small screens ---- */
@media (max-width: 760px) {
  .topbar-in, main { padding-left: 16px; padding-right: 16px; }
  .asof { margin-left: 0; width: 100%; padding-bottom: 8px; }
  table { display: block; overflow-x: auto; }
  .case-head-row { display: none; }
  details.case > summary { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px 8px; }
  .case-name, .case-state { grid-column: 1 / -1; }
  .case-wide { grid-column: 1 / -1; }
  .case-state { align-items: flex-start; flex-direction: row; gap: 8px; }
  .m::before { content: attr(data-k); display: block; font-size: .68rem; font-weight: 400; color: var(--muted-foreground); }
  .m { text-align: left; }
  .case-body { padding-left: 14px; }
  table.case-inputs { min-width: 0; }
  .figures { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
}
@media (min-width: 1800px) { body { font-size: 15px; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* a running step: a spinner in the circle, the step's progress line under its name */
.side.steps a > span.spinner:first-child { border-color: var(--border); border-top-color: var(--foreground); animation: step-spin .8s linear infinite; }
@keyframes step-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .side.steps a > span.spinner:first-child { animation-duration: 3s; } }
#steps { display: contents; }  /* the stepper's polling wrapper takes no box of its own */
/* Query results: a wide result scrolls inside its frame; a URN stays on one line */
.result-scroll { max-width: 100%; overflow-x: auto; }
table.result a.urn { white-space: nowrap; word-break: normal; font-size: .78rem; }
table.result td { max-width: 32rem; min-width: 9rem; overflow-wrap: anywhere; }
/* Run Result: the tree of what the run produced */
.result-tree { margin: 4px 0 18px; }
.result-tree h4 { margin-top: 6px; }
.result-tree ul.tree { border-left: 1px solid var(--border); }
.result-tree > section > ul.tree, .rt-bucket > ul.tree { border-left: 0; padding-left: 0; }
.result-tree summary { color: var(--foreground); font-weight: 400; font-size: inherit; width: auto; }
details.rt-bucket { border-top: 1px solid var(--border); padding-top: 8px; margin-top: 10px; }
details.rt-bucket > summary { font-weight: 600; font-size: .85rem; }
.rt-count { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--muted); color: var(--muted-foreground); font-size: .72rem; text-align: center; font-weight: 500; }
a.unnamed { font-style: italic; }
ul.tree .rt-urn { display: block; font-size: .64rem; opacity: .8; }
ul.tree details > summary { display: list-item; }
.rt-kind { font-weight: 600 !important; font-size: .8rem !important; color: var(--muted-foreground) !important; }
/* Explore: the tree's neighbourhood; the current subject marked, a collapsed set with a filter */
ul.tree li.current > b { background: var(--muted); border-radius: 4px; padding: 0 4px; margin-left: -4px; }
ul.tree li.tree-more summary { font-size: .8rem; }
.tree-more-list { max-height: 360px; overflow: auto; }
input.tree-filter { width: 100%; height: 30px; margin: 4px 0; font-size: .8rem; }
ul.tree.tree-all { border-left: 0; padding-left: 0; }
ul.tree.tree-all li { margin: 4px 0; }
ul.tree .chip { font-size: .64rem; min-height: 16px; padding: 0 6px; }
/* Explore: subjects named on the same website (not a group) */
details.same-site { border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 12px; margin: 6px 0; background: var(--card); }
details.same-site > summary { color: var(--foreground); font-weight: 600; }
details.same-site details { margin-left: 4px; }
ul.same-site-list { columns: 3 16rem; column-gap: 24px; list-style: none; padding-left: 4px; font-size: .85rem; }
ul.same-site-list li { break-inside: avoid; }
.tree-note { font-size: .8rem; margin-top: 10px; }
/* Explore: a person's ruling on a relation row */
td.rule-cell { min-width: 130px; }
td.rule-cell .rule-buttons { margin: 6px 0 0; }
td.rule-cell > .dim { display: block; margin-top: 4px; }
.rule-buttons { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
button.ok-button { color: var(--ok); border-color: var(--ok-line); }
button.ok-button:hover { background: var(--ok-bg); }
button.no-button { color: var(--no); border-color: var(--no-line); }
button.no-button:hover { background: var(--no-bg); }
.inline-rule { display: inline-flex; vertical-align: middle; margin: 0 0 0 6px; } .inline-rule button { height: 26px; padding: 0 9px; font-size: .78rem; }
/* Explore: possibly the same company, one line each, its sites and offerings beneath, marked as its own */
ul.candidates { list-style: none; padding-left: 0; margin: 4px 0; }
ul.candidates > li { border: 1px solid var(--border); border-left: 3px solid var(--warn-line); border-radius: var(--radius); background: var(--card); padding: 8px 12px; margin: 6px 0; }
.candidate-line { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.candidate-line > a { font-weight: 600; }
.candidate-line .rule-slot { margin-left: auto; }
.carried-by { font-size: .82rem; margin-top: 4px; }
.carried-by p { margin: 2px 0; }
details.why-not { margin: 2px 0 12px; }
details.why-not p { max-width: 90ch; }
/* Explore: the network view (static/network.js); kinds coloured with the evidence palette's tokens */
.view-tabs { margin: 0 0 10px; }
section.network { border: 1px solid var(--border); border-radius: calc(var(--radius) + 2px); background: var(--card); padding: 10px 14px; margin: 0 0 18px; }
.net-toolbar { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; font-size: .82rem; }
.net-toolbar label { margin: 0; font-weight: 400; }
.net-toolbar button { height: 28px; }
.net-hint { margin-left: auto; font-size: .75rem; }
.net-frame { width: 100%; max-height: 720px; overflow: auto; margin: 6px 0; }
svg.net-svg { display: block; width: 100%; margin: 0 auto; max-height: 700px; font: 11px -apple-system, BlinkMacSystemFont, "Inter", system-ui, sans-serif; }
.k-group { --k: var(--ev-agent); } .k-legal_entity { --k: var(--ev-self); } .k-site { --k: var(--ev-report); }
.k-business_unit { --k: var(--ev-inferred); } .k-brand { --k: var(--ev-profile); }
svg.net-svg .node .shape { fill: var(--card); stroke: var(--k, var(--ring)); stroke-width: 2; }
svg.net-svg .node.center .shape { fill: color-mix(in srgb, var(--k) 18%, var(--card)); stroke-width: 3; }
svg.net-svg .node .label { fill: var(--foreground); font-size: 11px; }
svg.net-svg .node.center .label { font-weight: 650; font-size: 13px; }
svg.net-svg .node.unnamed .label { font-style: italic; }
svg.net-svg .node.faint { opacity: .45; }
svg.net-svg .node:focus { outline: none; }
svg.net-svg .node:focus .shape, svg.net-svg .node:hover .shape { stroke-width: 3.5; filter: drop-shadow(0 0 3px var(--ring)); }
svg.net-svg .node.more .shape { fill: var(--muted); stroke: var(--input); stroke-dasharray: 3 2; }
svg.net-svg .node.more .count { fill: var(--muted-foreground); font-size: 10px; font-weight: 600; }
svg.net-svg .edge { stroke: var(--muted-foreground); stroke-width: 1.4; }
svg.net-svg .edge.st-needs_review { stroke: var(--warn); stroke-dasharray: 6 4; }
svg.net-svg .edge.st-refused { stroke: var(--no); stroke-dasharray: 2 3; }
svg.net-svg .edge.st-faint { stroke: var(--border); stroke-dasharray: 1 3; }
svg.net-svg .edge.former { opacity: .4; }
svg.net-svg .edge.hot { stroke-width: 2.6; opacity: 1; }
svg.net-svg .arrow { fill: var(--muted-foreground); }
svg.net-svg .arrow.st-needs_review { fill: var(--warn); } svg.net-svg .arrow.st-refused { fill: var(--no); } svg.net-svg .arrow.st-faint { fill: var(--border); }
svg.net-svg .edge-label { fill: var(--muted-foreground); font-size: 9.5px; paint-order: stroke; stroke: var(--card); stroke-width: 3px; display: none; }
svg.net-svg .edge-label.always, svg.net-svg .edge-label.hot { display: inline; }
.net-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: .75rem; align-items: center; }
.net-legend span { display: inline-flex; align-items: center; gap: 5px; }
.lg-line { display: inline-block; width: 22px; border-top: 2px solid var(--muted-foreground); }
.lg-line.dashed { border-top: 2px dashed var(--warn); } .lg-line.refused { border-top: 2px dotted var(--no); }
.lg-line.former { opacity: .4; } .lg-line.faint { border-top: 2px dotted var(--border); }
.lg-node { display: inline-block; width: 10px; height: 10px; border-radius: 3px; border: 2px solid var(--k); }
.net-panel { min-height: 1.6em; margin: 6px 0 0; font-size: .82rem; }
.net-panel button { height: 26px; margin-left: 6px; }
svg.net-svg .node .label { paint-order: stroke; stroke: var(--card); stroke-width: 3px; stroke-linejoin: round; }
@media (max-width: 1200px) { section.main table { display: block; overflow-x: auto; } section.main table > tbody { display: table; width: 100%; } section.main td { min-width: 6.5rem; } }
