/* MNH Costing Co-pilot: calm, utilitarian, desktop-first; readable tables with tabular numbers.
   No inline styles anywhere (CSP style-src 'self'). */

:root {
  --ink: #1b2629;
  --ink-2: #3c4a4d;
  --muted: #5d6c6f;
  --paper: #f3f6f5;
  --surface: #ffffff;
  --line: #d6dedc;
  --line-soft: #e6ecea;
  --head: #eef2f1;
  --accent: #1d5a73;
  --accent-ink: #ffffff;
  --accent-soft: #e4eff4;
  --focus: #e8a317;

  --block: #9e2a2b;
  --block-bg: #fbeceb;
  --warn: #7a5200;
  --warn-bg: #fdf4de;
  --info: #1d5a73;
  --info-bg: #e4eff4;
  --ok: #2d6a3a;
  --ok-bg: #e6f2e8;

  --radius: 6px;
  --gap: 16px;
  font-size: 15px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.45;
  color: var(--ink);
  background: var(--paper);
}

a { color: var(--accent); }
a:hover { text-decoration-thickness: 2px; }
code { font-family: ui-monospace, "SF Mono", Consolas, monospace; font-size: 0.86em; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 8px; }
h1 { font-size: 1.6rem; font-weight: 650; }
h2 { font-size: 1.15rem; font-weight: 650; }
h3 { font-size: 1rem; font-weight: 650; }
p { margin: 0 0 8px; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 2px; }
main:focus { outline: none; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip { position: absolute; left: 8px; top: -40px; background: var(--surface); padding: 8px 12px; z-index: 10; }
.skip:focus { top: 8px; }

.muted { color: var(--muted); }
.small { font-size: 0.87rem; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.tnum { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ------------------------------------------------------------------ frame */

.topbar {
  display: flex; align-items: center; gap: 24px; padding: 10px 24px;
  background: var(--surface); border-bottom: 1px solid var(--line); border-top: 3px solid var(--accent);
}
.brand { font-weight: 650; color: var(--ink); text-decoration: none; display: flex; align-items: center; gap: 8px; }
.brand-mark {
  background: var(--accent); color: var(--accent-ink); font-size: 0.72rem; letter-spacing: 0.06em;
  padding: 3px 6px; border-radius: 4px;
}
.topnav { display: flex; gap: 16px; }
.topnav a { text-decoration: none; color: var(--ink-2); padding: 4px 2px; }
.topnav a:hover { color: var(--accent); text-decoration: underline; }
.who { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.who form { margin: 0; }

.page { max-width: 1240px; margin: 0 auto; padding: 24px; }
.foot { max-width: 1240px; margin: 0 auto; padding: 8px 24px 32px; color: var(--muted); font-size: 0.85rem; }

.page-head, .job-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 16px; }
.job-meta { display: flex; gap: 8px; align-items: center; }
.crumb { margin: 0 0 4px; font-size: 0.87rem; }
.crumb a { color: var(--muted); }

/* ------------------------------------------------------------------ steps */

.steps { margin: 0 0 20px; }
.steps ol { list-style: none; display: flex; flex-wrap: wrap; gap: 4px; margin: 0; padding: 0; counter-reset: step; }
.steps li {
  counter-increment: step; display: flex; align-items: center; gap: 6px;
  padding: 6px 12px 6px 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface);
  font-size: 0.9rem; color: var(--muted);
}
.steps li::before {
  content: counter(step); display: inline-grid; place-items: center; width: 20px; height: 20px;
  border-radius: 50%; background: var(--head); color: var(--ink-2); font-size: 0.75rem; font-weight: 650;
}
.steps li.done::before { content: "\2713"; background: var(--ok-bg); color: var(--ok); }
.steps li.current { border-color: var(--accent); color: var(--ink); font-weight: 650; background: var(--accent-soft); }
.steps li.current::before { background: var(--accent); color: var(--accent-ink); }
.steps a { color: inherit; }
.steps .unreachable { color: #8b9799; }
.steps li.open { border-color: var(--warn); }
.steps li.open::before { content: "!"; background: var(--warn-bg); color: var(--warn); }
.step-note { font-size: 0.75rem; color: var(--warn); font-weight: 600; }

/* ------------------------------------------------------------------ surfaces */

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; margin: 0 0 var(--gap);
}
.card.narrow { max-width: 420px; }
.two-col { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 20px; align-items: start; }
.stack-panel > .card:last-child { margin-bottom: 0; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: var(--gap); margin-bottom: var(--gap); }
.cards .card { margin: 0; }
.block-section { margin: 0 0 28px; }
.section-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; }
.section-head h2 { margin: 0; }
.section-title { margin: 18px 0 6px; font-size: 0.95rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-2); }
.lede { color: var(--ink-2); max-width: 78ch; }
.empty { text-align: left; max-width: 640px; }
.error-page { max-width: 640px; }
.error-code { color: var(--muted); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.06em; }
.identity { font-weight: 600; margin: 0 0 4px; }

.summary-bar {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1px;
  background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin-bottom: 24px;
}
.summary-bar > div { background: var(--surface); padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; }
.summary-bar .big { font-size: 1.5rem; font-weight: 650; text-align: left; }

/* ------------------------------------------------------------------ notices and chips */

.notice {
  border: 1px solid var(--line); border-left: 4px solid var(--info); background: var(--info-bg);
  padding: 10px 14px; border-radius: 4px; margin: 0 0 12px;
}
.notice ul { margin: 6px 0 0; padding-left: 20px; }
.notice.block { border-left-color: var(--block); background: var(--block-bg); }
.notice.warn { border-left-color: var(--warn); background: var(--warn-bg); }
.notice.ok { border-left-color: var(--ok); background: var(--ok-bg); }
.notice.small { padding: 6px 10px; font-size: 0.87rem; margin: 4px 0 8px; }
.flashes { margin-bottom: 8px; }

.chip {
  display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 0.78rem; font-weight: 650;
  border: 1px solid currentColor; line-height: 1.5; white-space: nowrap; background: var(--surface);
}
.chip.small { font-size: 0.7rem; padding: 0 6px; }
.chip.neutral { color: var(--ink-2); border-color: var(--line); background: var(--head); }
.chip.ok, .status-generated { color: var(--ok); background: var(--ok-bg); }
.chip.info, .status-scoped, .status-reviewed { color: var(--info); background: var(--info-bg); }
.status-extracted, .status-uploaded { color: var(--ink-2); background: var(--head); border-color: var(--line); }
.status-failed { color: var(--block); background: var(--block-bg); }
.chip.pending { color: var(--warn); background: var(--warn-bg); }
.chip.status-edited { color: var(--accent); background: var(--accent-soft); }
.sev-block.chip { color: var(--block); background: var(--block-bg); }
.sev-warn.chip { color: var(--warn); background: var(--warn-bg); }
.sev-info.chip { color: var(--info); background: var(--info-bg); }

/* ------------------------------------------------------------------ tables */

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
table.grid { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.table-wrap > table.grid { border: 0; }
.card table.grid { border: 1px solid var(--line-soft); margin: 8px 0; }
.grid th, .grid td { padding: 8px 10px; border-bottom: 1px solid var(--line-soft); vertical-align: top; text-align: left; }
.grid thead th {
  background: var(--head); font-size: 0.8rem; font-weight: 650; color: var(--ink-2);
  text-transform: uppercase; letter-spacing: 0.04em; border-bottom: 1px solid var(--line);
}
.grid th.num, .grid td.num { text-align: right; }
.grid tbody tr:last-child td { border-bottom: 0; }
.grid tbody tr:hover { background: #fafcfb; }
.grid.compact th, .grid.compact td { padding: 5px 8px; font-size: 0.9rem; }
.grid tr.is-confirmed td { background: #fbfdfb; }
.grid tr.has-error td { background: var(--block-bg); }
.grid tr:target td { box-shadow: inset 0 0 0 9999px rgba(232, 163, 23, 0.12); }
.actions-cell { text-align: right; }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 0 0 8px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: left; }
.kv-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.kv-table th { text-align: left; font-weight: 400; color: var(--ink-2); padding: 5px 0; border-bottom: 1px solid var(--line-soft); }
.kv-table td { padding: 5px 0; border-bottom: 1px solid var(--line-soft); font-weight: 650; }
.kv-table.totals { max-width: 520px; margin-bottom: 8px; }
.kv-table.totals td { font-size: 1.1rem; }

.q { font-weight: 550; display: block; }
.guidance { color: var(--muted); font-size: 0.87rem; margin: 3px 0 0; max-width: 70ch; }
.group-note { color: var(--warn); margin: 3px 0 0; }
.klass { display: inline-block; margin-top: 4px; font-size: 0.8rem; color: var(--muted); font-style: italic; }
.rule { color: var(--ink-2); background: var(--head); padding: 1px 5px; border-radius: 3px; white-space: nowrap; font-size: 0.8em; }
.value { font-weight: 650; }
.unit { color: var(--muted); font-size: 0.87rem; }
.formula { margin-top: 2px; }
.formula code { color: var(--ink-2); }
.status-cell { min-width: 170px; }

/* ------------------------------------------------------------------ evidence */

.ev { margin: 0 0 8px; max-width: 280px; }
.ev:last-child { margin-bottom: 0; }
.ev-meta { display: flex; gap: 8px; font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.ev-page { font-weight: 650; color: var(--ink-2); }
.ev-text { display: block; font-size: 0.87rem; color: var(--ink-2); quotes: "\201C" "\201D"; }
.ev-detail { font-size: 0.8rem; color: var(--muted); }
.ev-thumb { display: inline-block; margin-top: 4px; border: 1px solid var(--line); border-radius: 4px; background: #fff; }
.ev-thumb img { display: block; max-width: 260px; max-height: 150px; object-fit: contain; }
.ev-thumb.wide img { max-width: 100%; max-height: 260px; }
.ev-row { display: flex; flex-wrap: wrap; gap: 12px; }

/* ------------------------------------------------------------------ flags */

.flags { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.flag {
  background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--info);
  border-radius: 4px; padding: 10px 14px;
}
.flag.sev-block { border-left-color: var(--block); }
.flag.sev-warn { border-left-color: var(--warn); }
.flag.is-dismissed { border-left-color: var(--line); background: #fafbfb; }
.flag-head { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.flag-counts th { padding: 6px 0; }
details.dismiss, details.dismissed, details.edit { margin-top: 6px; }
details summary { cursor: pointer; color: var(--accent); font-size: 0.9rem; }
details.dismiss form, details.edit form { margin-top: 8px; }
details.dismissed, details.info-flags { margin-top: 12px; }
details.info-flags > summary { font-weight: 600; }
details.info-flags .flags { margin-top: 10px; }
details.ev-details { margin-top: 4px; }
details.ev-details .ev-row { margin-top: 6px; }

/* ------------------------------------------------------------------ forms */

input[type="text"], input:not([type]), input[type="password"], input[type="file"], textarea, select {
  font: inherit; color: inherit; border: 1px solid #b8c4c2; border-radius: 4px; padding: 6px 8px; background: #fff;
}
textarea { width: 100%; max-width: 520px; }
input[type="file"] { padding: 6px; width: 100%; }
input:hover, textarea:hover { border-color: #8fa09d; }
.num-input { width: 9.5em; text-align: right; font-variant-numeric: tabular-nums; }
.num-input.short { width: 5em; }
.num-input.rate-input { width: 16em; }
.inline-choices .multiple { color: var(--muted); font-size: 0.92em; }
.wide-input { width: 100%; min-width: 16em; }
.with-unit { display: inline-flex; align-items: center; gap: 6px; }
.field { margin: 0 0 14px; }
.field > label:not(.choice), fieldset legend { font-weight: 650; display: block; margin-bottom: 4px; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); margin: 0 0 var(--gap); padding: 12px 16px 14px; }
fieldset.card { padding-top: 12px; }
fieldset legend { padding: 0 4px; }
.inline-choices { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 4px 14px; }
.inline-choices label { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.choice { display: flex; align-items: baseline; gap: 8px; padding: 4px 0; font-weight: 400; }
.choice input:checked + span, .choice:has(input:checked) { font-weight: 600; }
.choice.disabled { color: var(--muted); }
.hint { color: var(--muted); font-size: 0.87rem; margin: 0 0 8px; }
.field-error { color: var(--block); font-weight: 600; font-size: 0.87rem; margin: 4px 0 0; }
.has-error > legend, fieldset.has-error { border-color: var(--block); }
.stack { display: grid; gap: 8px; max-width: 420px; }
.stack-form .actions { margin-top: 4px; }
.plain-steps { padding-left: 20px; margin: 0 0 8px; }
.plain-steps li { margin-bottom: 6px; }
.compact-list { margin: 0 0 8px; padding-left: 18px; }
.suggestion { display: grid; gap: 4px; justify-items: start; }
.answer-cell { min-width: 220px; }

.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 8px 0 16px; }
.actions.end { justify-content: flex-end; }
.actions.sticky {
  position: sticky; bottom: 0; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 10px 14px; box-shadow: 0 -2px 10px rgba(27, 38, 41, 0.06); z-index: 2;
}
form.inline { display: inline; margin: 0 0 4px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px; font: inherit; font-weight: 650; cursor: pointer;
  background: var(--accent); color: var(--accent-ink); border: 1px solid var(--accent);
  border-radius: var(--radius); padding: 7px 14px; text-decoration: none; line-height: 1.3;
}
.btn:hover { background: #164a5f; border-color: #164a5f; text-decoration: none; }
.btn-secondary { background: var(--surface); color: var(--accent); border-color: #9fb8c3; }
.btn-secondary:hover { background: var(--accent-soft); border-color: var(--accent); }
.btn-small { padding: 4px 10px; font-size: 0.87rem; }
.btn-large { padding: 10px 20px; font-size: 1.05rem; }
.btn[disabled], .btn[aria-disabled="true"] { background: #c9d2d1; border-color: #c9d2d1; color: #56625f; cursor: not-allowed; }
.btn.is-busy { opacity: 0.75; cursor: progress; }
button.link { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font: inherit; text-decoration: underline; }

.result { border-color: var(--ok); }

/* ------------------------------------------------------------------ review notes, rules, kept edits */

.row-note { color: var(--muted); margin-top: 3px; max-width: 40ch; text-align: left; font-variant-numeric: normal; }
.rule-label { font-size: 0.85rem; color: var(--ink-2); }
details.rule-why > summary, details.ev-more > summary { cursor: pointer; font-size: 0.8rem; color: var(--accent); }
details.rule-why p { margin: 4px 0 0; max-width: 42ch; }
details.ev-more { margin-top: 4px; }
details.ev-more[open] > summary { margin-bottom: 6px; }
.kept-edits { margin: 16px 0; border-left: 4px solid var(--warn); background: var(--warn-bg); }
.kept-edits h2 { display: flex; align-items: center; gap: 8px; }
.generate-actions .ack { display: flex; gap: 8px; align-items: flex-start; max-width: 72ch; flex-basis: 100%; }
.open-warnings { flex-basis: 100%; }
.open-warnings .compact-list li { margin-bottom: 4px; }
tr.is-pending th, tr.is-pending td { color: var(--warn); font-weight: 650; }
.item-choices [data-multiple-box] { margin-left: -8px; }

/* ------------------------------------------------------------------ laptop and narrower */

@media (max-width: 1080px) {
  .page { padding: 18px; }
  .two-col { grid-template-columns: 1fr; }
  .ev-thumb img { max-width: 200px; }
}
@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; gap: 10px 16px; padding: 10px 16px; }
  .who { margin-left: 0; }
  .page { padding: 16px; }
  .page-head, .job-head { flex-direction: column; align-items: flex-start; }
}
