/* CDQ: one stylesheet, light and dark, no external fonts (strict CSP). */
:root {
  --brand: #007595; --brand-2: #00afb9; --ink: #1d2733; --muted: #5b6875;
  --bg: #f6f8fa; --card: #ffffff; --line: #dde3e9; --focus: #007595; --on-brand: #ffffff;
  --ok: #1a6e2d; --warn: #8a5a00; --bad: #b42318; --info: #3b5b85;
  --radius: 8px; color-scheme: light;
  font: 16px/1.5 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root { --brand: #3fb3d6; --brand-2: #4fd1d9; --ink: #e6edf3; --muted: #9aa7b4; --bg: #0f1419;
    --card: #161d24; --line: #2a343e; --focus: #4fd1d9; --on-brand: #0f1419; --ok: #56c271; --warn: #e3b341; --bad: #f47067;
    --info: #8ab4f8; color-scheme: dark; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); }
a { color: var(--brand); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 1rem; top: 1rem; background: var(--card); padding: .5rem; z-index: 10; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
[hidden] { display: none !important; }

.top { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1.5rem; padding: .75rem 1rem;
  background: var(--card); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; text-decoration: none; color: var(--ink); font-size: 1.15rem; }
.brand span { font-weight: 400; color: var(--muted); font-size: .9rem; margin-left: .25rem; }
.top nav { display: flex; flex-wrap: wrap; gap: .25rem 1rem; flex: 1; }
.top nav a { text-decoration: none; padding: .25rem 0; }
.top nav a[aria-current="page"] { font-weight: 600; border-bottom: 2px solid var(--brand); }
.signout { display: flex; align-items: center; gap: .5rem; }
.who { color: var(--muted); font-size: .9rem; }

main { max-width: 72rem; margin: 0 auto; padding: 1.5rem 1rem 3rem; }
.foot { max-width: 72rem; margin: 0 auto; padding: 0 1rem 2rem; color: var(--muted); font-size: .85rem; }
.foot .notices { font-size: .75rem; }
.guide { max-width: 60rem; }
.guide pre { overflow-x: auto; padding: .75rem; border: 1px solid var(--line, #ccc); border-radius: 4px; }
.guide code { overflow-wrap: anywhere; }
.guide pre code { overflow-wrap: normal; }
h1 { font-size: 1.6rem; margin: .25rem 0 1rem; }
h2 { font-size: 1.15rem; margin: 0 0 .75rem; }
.lead { font-size: 1.1rem; color: var(--muted); max-width: 46rem; }
.muted { color: var(--muted); font-size: .9rem; }
.crumbs { font-size: .9rem; color: var(--muted); margin: 0; }
.hero { padding: 2rem 0; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.25rem; margin: 0 0 1.25rem; }
.error, .warning { padding: .75rem 1rem; border-radius: var(--radius); border-left: 4px solid; }
.error { color: var(--bad); border-color: var(--bad); background: color-mix(in srgb, var(--bad) 8%, transparent); }
.warning { color: var(--warn); border-color: var(--warn); background: color-mix(in srgb, var(--warn) 8%, transparent); }

.button, button.button { display: inline-block; background: var(--brand); color: var(--on-brand); border: 0;
  border-radius: var(--radius); padding: .6rem 1.1rem; font: inherit; font-weight: 600; text-decoration: none;
  cursor: pointer; margin: 0 .5rem .5rem 0; }
.button.secondary { background: transparent; color: var(--brand); border: 1px solid var(--brand); }
button.link { background: none; border: 0; color: var(--brand); font: inherit; cursor: pointer; padding: 0;
  text-decoration: underline; }
button.link.danger { color: var(--bad); }
input[type=file], select { font: inherit; max-width: 100%; }
label { font-weight: 600; display: block; margin: .5rem 0 .25rem; }
progress { width: min(24rem, 100%); height: 1rem; vertical-align: middle; accent-color: var(--brand); }

.facts { display: flex; flex-wrap: wrap; gap: 1rem 2rem; margin: 0 0 1rem; }
.facts dl { display: contents; }
.facts div { min-width: 7rem; }
.facts dt { color: var(--muted); font-size: .85rem; }
.facts dd { margin: 0; font-size: 1.35rem; font-weight: 600; font-variant-numeric: tabular-nums;
  overflow-wrap: break-word; }

ul.plain { list-style: none; padding: 0; }
ul.cards { list-style: none; padding: 0; display: grid; gap: .5rem;
  grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr)); }
ul.cards li { border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem; }
ul.cards label { display: grid; grid-template-columns: auto 1fr; gap: .1rem .6rem; font-weight: 400; margin: 0; }
ul.cards input { grid-row: span 2; margin-top: .3rem; }
ul.cards .name { font-weight: 600; }
ul.cards .count { color: var(--muted); font-size: .9rem; }
details { margin-top: .4rem; font-size: .9rem; }
fieldset { border: 0; padding: 0; margin: 0; }

.table-wrap { overflow-x: auto; position: relative; }
table { border-collapse: collapse; width: 100%; font-size: .92rem; }
caption { text-align: left; font-weight: 600; padding: .5rem 0; }
th, td { text-align: left; padding: .45rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
thead th { font-size: .82rem; color: var(--muted); font-weight: 600; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.date { white-space: nowrap; font-variant-numeric: tabular-nums; }

.tag, .sev, .status { display: inline-block; padding: .05rem .45rem; border-radius: 999px; font-size: .8rem;
  font-weight: 600; border: 1px solid currentColor; white-space: nowrap; }
.tag.missing_step, .status.overdue, .sev.critical { color: var(--bad); }
.tag.late_step, .sev.high, .status.due { color: var(--warn); }
.tag.premature_step, .sev.moderate { color: var(--info); }
.tag.conditional_gap, .sev.low, .sev.informational, .status.na { color: var(--muted); }
.status.complete { color: var(--ok); }

.filters { display: flex; flex-wrap: wrap; align-items: end; gap: .25rem 1rem; margin-bottom: 1rem; }
.filters label { margin: 0; }
.pager { display: flex; gap: 1rem; margin-top: 1rem; }
.discard { margin-top: 2rem; display: flex; flex-wrap: wrap; gap: .25rem 1rem; align-items: baseline; }
.devs { padding-left: 1.2rem; }
code { font-size: .9em; }

/* Pathway library */
.status.approved { color: var(--ok); }
.status.pending_review { color: var(--warn); }
.status.rejected { color: var(--bad); }
.status.draft, .status.retired { color: var(--muted); }
.facts.text dd { font-size: 1rem; }
.notice { padding: .75rem 1rem; border-radius: var(--radius); border-left: 4px solid var(--ok); color: var(--ok);
  background: color-mix(in srgb, var(--ok) 8%, transparent); }
h3 { font-size: 1rem; margin: 1.25rem 0 .25rem; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], textarea {
  font: inherit; width: min(32rem, 100%); padding: .45rem .6rem; border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--card); color: var(--ink); }
label.check { font-weight: 400; display: flex; gap: .5rem; align-items: baseline; overflow-wrap: anywhere; min-width: 0; }
label.check input { flex: none; }
.button.danger, button.button.danger { background: var(--bad); color: var(--on-brand); }
td.bar-col, th.bar-col { width: 30%; min-width: 6rem; }
td.bar-col meter { width: 100%; height: .8rem; }
input.key { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; width: min(40rem, 100%); }
.reveal { border-color: var(--warn); }

/* Step chain: a row of cards that wraps, read in order. */
ol.chain { list-style: none; padding: 0; margin: 0 0 1.5rem; display: flex; flex-wrap: wrap; gap: 1rem 2rem; }
ol.chain li { position: relative; flex: 0 1 12rem; min-width: 10rem; background: var(--card);
  border: 2px solid var(--line); border-top-width: 6px; border-radius: var(--radius); padding: .6rem .75rem;
  display: flex; flex-direction: column; gap: .15rem; }
ol.chain li + li::before { content: "→"; position: absolute; left: -1.6rem; top: 40%; color: var(--muted);
  font-size: 1.2rem; }
ol.chain li.trigger { background: var(--brand); color: var(--on-brand); border-color: var(--brand); }
ol.chain li.conditional { border-style: dashed; }
ol.chain li.sev-critical { border-top-color: var(--bad); }
ol.chain li.sev-high, ol.chain li.sev-moderate { border-top-color: var(--warn); }
ol.chain li.sev-low, ol.chain li.sev-informational { border-top-color: var(--info); }
.chain-order { font-size: .8rem; color: var(--muted); }
.chain-name { font-weight: 600; }
.chain-when { font-size: .9rem; }
.chain-meta { font-size: .8rem; color: var(--muted); }
li.trigger .chain-when, li.trigger .chain-order, li.trigger .chain-meta { color: var(--on-brand); }

/* Network (JS) */
.network { margin: 0 0 1.25rem; }
.network-canvas { height: min(70vh, 640px); background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; touch-action: none; }
.network-canvas svg { display: block; width: 100%; height: 100%; }
.net-tip { position: absolute; pointer-events: none; background: var(--ink); color: var(--bg); padding: .5rem .75rem;
  border-radius: 6px; font-size: .8rem; max-width: 16rem; z-index: 20; }
.net-link { fill: none; stroke: var(--muted); stroke-width: 2; stroke-dasharray: 7 4; opacity: .6; }
.net-link.dim { opacity: .2; }
.net-link.active { stroke: var(--brand); stroke-width: 2.5; opacity: .9; }
.net-step-link { fill: none; stroke: var(--line); stroke-width: 1.5; }
.net-label { font-size: 8px; fill: var(--muted); text-anchor: middle; pointer-events: none;
  stroke: var(--card); stroke-width: 3; stroke-linejoin: round; paint-order: stroke; }
.net-label.active { fill: var(--brand); font-weight: 700; }
.net-hub circle.body { stroke: var(--card); stroke-width: 2; }
.net-hub text { fill: #fff; font-size: 8.5px; text-anchor: middle; pointer-events: none; }
.net-hub.selected circle.ring { stroke: var(--brand); stroke-width: 4; opacity: 1; }
.net-hub:focus { outline: none; }
.net-hub:focus-visible circle.ring { stroke: var(--focus); stroke-width: 4; opacity: 1; }
.net-step rect { fill: var(--card); stroke-width: 2; }
.net-step text { fill: var(--ink); font-size: 8px; pointer-events: none; }
.net-step.conditional rect { stroke-dasharray: 4 3; }
.net-arrow { fill: var(--muted); }
@media (max-width: 40rem) {
  ol.chain { flex-direction: column; gap: 1.6rem; }
  ol.chain li { flex: none; }
  ol.chain li + li::before { content: "↓"; left: 50%; top: -1.55rem; }
}
legend { font-weight: 600; padding: 0; margin: 1rem 0 .25rem; }
.stack fieldset { margin-top: .5rem; }
details.links summary { cursor: pointer; font-weight: 600; }

/* Form errors */
.error-summary { border: 3px solid var(--bad); border-radius: var(--radius); padding: .75rem 1rem; margin: 0 0 1rem;
  background: var(--card); }
.error-summary h2 { margin: 0 0 .25rem; font-size: 1.05rem; }
.error-summary p { margin: 0; }
.error-summary a { color: var(--bad); font-weight: 600; }
.field-error { color: var(--bad); font-weight: 600; margin: .1rem 0 .25rem; }
[aria-invalid="true"] { border-color: var(--bad); box-shadow: 0 0 0 1px var(--bad); }

/* Tabs: plain links, the current one marked. */
nav.tabs { display: flex; flex-wrap: wrap; gap: .25rem 1.25rem; border-bottom: 1px solid var(--line); margin: 0 0 1rem; }
nav.tabs a { text-decoration: none; padding: .4rem 0; margin-bottom: -1px; border-bottom: 3px solid transparent; }
nav.tabs a[aria-current="page"] { font-weight: 600; color: var(--ink); border-bottom-color: var(--brand); }
.badge { display: inline-block; font-size: .75rem; font-weight: 600; padding: 0 .45rem; border-radius: 999px;
  background: var(--brand); color: var(--on-brand); vertical-align: middle; }

/* Review changes */
.change { border-left: 4px solid var(--line); padding: 0 0 0 .75rem; margin: 0 0 1.25rem; }
.change.added { border-left-color: var(--ok); }
.change.removed { border-left-color: var(--bad); }
.change.changed { border-left-color: var(--warn); }
.change h3 { margin: 0 0 .4rem; font-size: 1rem; }
.change-kind { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-right: .35rem; }
.change td, .change th[scope="row"] { white-space: pre-line; vertical-align: top; }
.change th[scope="row"] { font-weight: 600; text-align: left; }
.change td.was { color: var(--muted); }

/* Evidence links */
h3.evidence-step { font-size: .95rem; margin: .75rem 0 .25rem; }
ul.evidence { margin: 0 0 .5rem; padding-left: 1.25rem; }
ul.evidence li { margin: .25rem 0; }
form.inline { display: inline; margin: 0; }
.notice a, .warning a { color: inherit; font-weight: 600; }

/* Plans (Billing): cards that wrap, one column on a phone. */
ul.plans { list-style: none; padding: 0; margin: 0; display: grid; gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 13rem), 1fr)); }
li.plan { border: 2px solid var(--line); border-radius: var(--radius); padding: .75rem 1rem; display: flex;
  flex-direction: column; gap: .25rem; background: var(--card); }
li.plan.current { border-color: var(--brand); }
li.plan h3 { margin: 0; }
li.plan p { margin: 0; }
li.plan form { margin-top: auto; padding-top: .5rem; }
.plan-price { font-size: 1.15rem; font-weight: 600; }
.plan-badge { color: var(--brand); }

/* Phones. Without JS: the nav is one row that scrolls sideways, and data
   tables (table.rows) become one card per row, labelled from data-label.
   With JS: a Menu button opens the nav as a list (cdq.js). */
.menu-toggle { display: none; }
@media (max-width: 40rem) {
  .top { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .25rem .75rem; padding: .5rem 1rem; }
  .brand span { display: none; }
  .signout { grid-column: 2; grid-row: 1; min-width: 0; }
  .who { max-width: 9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .top nav { grid-column: 1 / -1; grid-row: 2; flex-wrap: nowrap; overflow-x: auto; gap: 1.25rem;
    scrollbar-width: thin; }
  .top nav a { white-space: nowrap; padding: .6rem 0; }
  .js .top { grid-template-columns: minmax(0, 1fr) auto auto; }
  .js .menu-toggle { display: inline-flex; align-items: center; gap: .4rem; grid-column: 3; grid-row: 1;
    min-height: 2.75rem; padding: 0 .75rem; margin: 0; }
  .js .top nav { display: none; }
  .js .top.open nav { display: flex; flex-direction: column; gap: 0; overflow: visible; border-top: 1px solid var(--line);
    margin-top: .25rem; }
  .js .top.open nav a { padding: .75rem 0; border-bottom: 1px solid var(--line); }
  .js .top.open nav a[aria-current="page"] { border-bottom: 1px solid var(--line); box-shadow: inset 4px 0 0 var(--brand);
    padding-left: .75rem; }
  main { padding-top: 1rem; }
  .button, button.button { min-height: 2.75rem; }
  .filters select, .filters input { min-height: 2.75rem; width: 100%; }
  .filters label { width: 100%; }

  .table-wrap:has(> table.rows) { overflow: visible; }
  table.rows, table.rows tbody, table.rows tr, table.rows td { display: block; }
  table.rows thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  table.rows tr { border: 1px solid var(--line); border-radius: var(--radius); background: var(--card);
    padding: .6rem .8rem; margin: 0 0 .6rem; display: flex; flex-direction: column; }
  table.rows td { border: 0; padding: .1rem 0; display: grid; grid-template-columns: minmax(6rem, 38%) 1fr;
    gap: .75rem; text-align: left; white-space: normal; justify-items: start; }
  table.rows td[data-label]::before { content: attr(data-label); color: var(--muted); font-size: .82rem; padding-top: .1rem; }
  table.rows td.lead-cell { display: block; font-weight: 600; padding-bottom: .35rem; order: -1; }
  table.rows td.lead-cell .muted { font-weight: 400; }
  table.rows td.action-cell { display: block; padding-top: .35rem; }
  table.rows td:empty, table.rows td.action-cell:not(:has(*)) { display: none; }
}

/* JS layer: sortable columns, live updates, finding rows, counts. */
th[aria-sort] button, th.sortable button { all: unset; cursor: pointer; display: inline-flex; gap: .3rem; align-items: center; }
th.sortable button:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
th.sortable button::after { content: "↕"; opacity: .45; font-size: .8em; }
th[aria-sort="ascending"] button::after { content: "↑"; opacity: 1; }
th[aria-sort="descending"] button::after { content: "↓"; opacity: 1; }
main[aria-busy="true"] { opacity: .55; transition: opacity .15s; }
.find { margin: 0 0 1rem; }
.find input { font: inherit; width: min(24rem, 100%); padding: .45rem .6rem; border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--card); color: var(--ink); min-height: 2.75rem; }
.chosen-count { font-weight: 600; }
