:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #dfe3e8;
  --text: #1b1f24;
  --muted: #5b6673;
  --accent: #1f5f9c;
  --ok: #1a7f4b;
  --warn: #9a6400;
  --danger: #a32222;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171b; --surface: #1c2025; --border: #2c323a; --text: #e8eaed; --muted: #9aa4b1;
    --accent: #6fb2f0; --ok: #57c08a; --warn: #e0a33a; --danger: #ef6b6b;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
main { max-width: 1180px; margin: 0 auto; padding: 24px 16px 64px; }
h1 { font-size: 1.5rem; margin: 0 0 16px; }
h2 { font-size: 1.15rem; margin: 28px 0 10px; }
h3 { font-size: 1rem; margin: 20px 0 8px; }
a { color: var(--accent); }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9em; }

header { background: var(--surface); border-bottom: 1px solid var(--border); }
nav { max-width: 1180px; margin: 0 auto; padding: 10px 16px; display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
nav a { text-decoration: none; color: var(--muted); padding: 4px 0; }
nav a.active, nav a:hover { color: var(--text); border-bottom: 2px solid var(--accent); }
nav .brand { color: var(--text); font-weight: 600; margin-right: 8px; }
nav .right { margin-left: auto; }
button.link { background: none; border: 0; color: var(--muted); cursor: pointer; font: inherit; }

footer { max-width: 1180px; margin: 0 auto; padding: 16px; color: var(--muted); font-size: .85rem; }

form.query-form {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; align-items: end;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px;
}
form.query-form .wide { grid-column: 1 / -1; }
label { display: flex; flex-direction: column; gap: 4px; font-size: .85rem; color: var(--muted); }
label.checkbox { flex-direction: row; align-items: center; gap: 6px; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; width: 100%;
}
button {
  font: inherit; font-weight: 600; background: var(--accent); color: #fff; border: 0;
  border-radius: 8px; padding: 9px 16px; cursor: pointer;
}
button.secondary, a.secondary {
  background: transparent; color: var(--accent); border: 1px solid var(--border);
  text-decoration: none; display: inline-block; padding: 8px 14px; border-radius: 8px;
}
.htmx-indicator { display: none; color: var(--muted); }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: inline; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; margin: 16px 0; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.card .label { color: var(--muted); font-size: .8rem; display: block; }
.card strong { font-size: 1.5rem; display: block; margin: 2px 0; }
.card strong.small { font-size: .95rem; word-break: break-all; }
.note { color: var(--muted); font-size: .8rem; display: block; }
.msg { color: var(--muted); font-size: .82rem; word-break: break-word; }
.actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 12px 0 4px; }
.warning { color: var(--warn); font-size: .85rem; }
.error { color: var(--danger); }

table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin-bottom: 12px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; font-size: .9rem; }
th { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; }
tr:last-child td { border-bottom: 0; }
table.compact td, table.compact th { padding: 6px 8px; }
tr.detail td { padding-top: 0; }

.tag { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: .75rem; background: var(--bg); border: 1px solid var(--border); color: var(--muted); }
.tag.ok, .tag.high, .tag.high_risk { border-color: transparent; }
.tag.ok { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.tag.failed, .tag.high, .tag.high_risk { background: color-mix(in srgb, var(--danger) 18%, transparent); color: var(--danger); }
.tag.medium, .tag.caution, .tag.needs_review { background: color-mix(in srgb, var(--warn) 20%, transparent); color: var(--warn); }
.tag.low, .tag.clear { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); }
.tag.running { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }

.report { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-top: 18px; }
.report > section { border-top: 1px solid var(--border); padding-top: 10px; margin-top: 18px; }
.report header.risk { display: flex; gap: 18px; align-items: flex-start; }
.report header.risk .score { font-size: 1rem; color: #fff; border-radius: var(--radius); padding: 14px 18px; text-align: center; min-width: 108px; }
.report header.risk .score b { display: block; font-size: 2.2rem; line-height: 1; }
.report header.risk h2 { margin: 0 0 4px; font-size: 1.1rem; }
.report header.risk p { margin: 0 0 4px; }
.report header.risk a { margin-left: auto; }
.risk.very_low .score, .risk.low .score { background: var(--ok); }
.risk.moderate .score { background: var(--warn); }
.risk.high .score, .risk.very_high .score { background: var(--danger); }
.risk.unverified .score { background: var(--muted); }
.risk.unverified .score span { display: block; font-size: .75rem; }

.components { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.component .bar { height: 6px; background: var(--bg); border-radius: 999px; overflow: hidden; margin-bottom: 6px; }
.component .bar span { display: block; height: 100%; background: var(--accent); }
.findings li, .recommendations li { margin-bottom: 6px; }
.recommendations li::marker { color: var(--accent); }
.events { list-style: none; padding-left: 0; }
.events li { border-left: 2px solid var(--border); padding: 4px 0 8px 12px; }
.limitations { color: var(--muted); font-size: .85rem; }
details { margin: 6px 0; }
summary { cursor: pointer; }

.login { max-width: 360px; margin: 12vh auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 28px; }
.login h1 { font-weight: 400; }
.login .sub { color: var(--muted); margin-top: -8px; }
.login form { display: grid; gap: 12px; }

.highlight { background: color-mix(in srgb, var(--accent) 10%, var(--surface)); border: 1px solid var(--accent); border-radius: var(--radius); padding: 14px; margin-bottom: 16px; }
.secret { display: block; padding: 10px; background: var(--bg); border-radius: 8px; word-break: break-all; user-select: all; }

/* Guided research workflow */
.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; }
div.query-form {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; align-items: end;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px;
}
div.query-form .wide { grid-column: 1 / -1; }
div.query-form .actions { margin: 0; }
.stepper ol { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; padding: 0; margin: 12px 0 16px; }
.stepper button {
  background: var(--surface); color: var(--muted); border: 1px solid var(--border); font-weight: 500;
  padding: 6px 12px; border-radius: 999px; font-size: .85rem;
}
.stepper button .n { display: inline-block; min-width: 1.4em; text-align: center; font-weight: 700; color: var(--accent); }
.stepper button.current { background: var(--accent); color: #fff; border-color: var(--accent); }
.stepper button.current .n { color: #fff; }
.stepper button:disabled { opacity: .5; cursor: not-allowed; }
button.small { padding: 4px 10px; font-size: .8rem; }
button.secondary.current { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
button.link-button { background: none; border: 0; padding: 0; color: var(--accent); font-weight: 600; text-decoration: underline; }
.chips { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; padding: 0; }
.wf-headline { display: flex; gap: 14px; align-items: center; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; margin-bottom: 8px; }
.wf-headline .score { color: #fff; border-radius: var(--radius); padding: 8px 12px; text-align: center; min-width: 76px; }
.wf-headline .score b { display: block; font-size: 1.5rem; line-height: 1; }
.wf-headline p { margin: 0 0 2px; }
.step { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 4px 18px 18px; overflow-x: auto; }
.step h2 { margin-top: 16px; }
.step h4, .step h5 { font-size: .92rem; margin: 16px 0 6px; }
.step .report { border: 0; padding: 0; margin-top: 0; }
.step caption { text-align: left; color: var(--muted); font-size: .8rem; padding: 6px 0; caption-side: top; }
.step th[scope="row"] { width: 22%; min-width: 120px; text-transform: none; letter-spacing: 0; font-size: .85rem; }
ul.rule li, ul.not-checked li { margin-bottom: 6px; }
ul.not-checked { color: var(--muted); }
ul.not-checked li.warning { color: var(--warn); }
.error-box { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 8%, var(--surface)); }
.error-box ul { margin: 4px 0 0; }
.prior { border-top: 1px solid var(--border); margin-top: 12px; }
.dossier .step-h { font-size: 1.1rem; border-bottom: 2px solid var(--border); padding-bottom: 4px; }
.dossier code { word-break: break-all; }
table.compare td { width: 39%; }

@media (max-width: 640px) {
  .wf-headline { flex-direction: column; align-items: flex-start; }
  .step { padding: 2px 10px 12px; }
  .step table { display: block; overflow-x: auto; }
}

@media print {
  :root { --bg: #fff; --surface: #fff; --border: #bbb; --text: #000; --muted: #333; --accent: #000; --ok: #000; --warn: #000; --danger: #000; }
  body > header, footer, .no-print, .stepper, .actions { display: none !important; }
  main { max-width: none; padding: 0; }
  body { font-size: 11pt; }
  .step, .report { border: 0; padding: 0; overflow: visible; }
  details > *:not(summary) { display: block; }
  a { color: inherit; text-decoration: none; }
  .tag { border: 1px solid #666; background: none !important; color: #000 !important; }
  table { break-inside: auto; border-radius: 0; }
  tr, .prior { break-inside: avoid; }
  h2, h3, h4, h5 { break-after: avoid; }
  .dossier-step { break-before: auto; }
}

/* Pre-approved specification terms: the page tray and the suggestions under a specification field. */
.tray { margin: 16px 0; }
.tray h2 { margin-top: 0; }
.tray-items { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.tray-items li { border: 1px solid var(--border); border-radius: 999px; padding: 2px 10px; font-size: .85rem; }
.tray-items .remove { color: var(--muted); font-size: .75rem; margin-left: 4px; }
.tray form.actions input { flex: 1 1 220px; }
.class-counts { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; }
.class-counts a { text-decoration: none; }
.class-counts a.current { font-weight: 600; border-bottom: 2px solid var(--accent); }
.class-counts .note, .terms-table td .note, .terms-table td .warning { display: inline; }
.terms-table td .note::before, .terms-table td .warning::before { content: " · "; }
.terms-picker { position: relative; }
.terms-suggestions { list-style: none; margin: 2px 0 0; padding: 4px 0; position: absolute; z-index: 5; left: 0; right: 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); max-height: 260px; overflow-y: auto; }
.terms-suggestions li { padding: 6px 10px; cursor: pointer; display: flex; gap: 10px; justify-content: space-between; align-items: baseline; }
.terms-suggestions li:hover, .terms-suggestions li.active { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.terms-suggestions .term { color: var(--text); font-size: .9rem; }
.terms-suggestions .note { white-space: nowrap; }
.terms-status { margin: 4px 0 0; }
.terms-status b { color: var(--text); }
.terms-status .warning, .terms-status .note { display: block; }
