/* Raft (IHH referral intake). One typeface, large type, every status = word + color + pattern. */
:root {
  --bg: #eef2f4;
  --surface: #ffffff;
  --ink: #17212b;
  --muted: #475563;
  --line: #c3cdd5;
  --primary: #0a5c78;
  --primary-hover: #084a61;
  --ok: #16693b;      --ok-bg: #e3f2e8;
  --bad: #ad2318;     --bad-bg: #fbe7e4;
  --warn: #7f5300;    --warn-bg: #fff1cf;
  --held: #563b99;    --held-bg: #eee8fa;
  --off: #5b6670;     --off-bg: #e4e8eb;
  --focus: #f2b705;
  --radius: 10px;
  font-size: 19px;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  font-family: "Atkinson Hyperlegible", "Segoe UI", system-ui, sans-serif;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
}
h1, h2, h3 { line-height: 1.2; margin: 0; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.1rem; }
p { margin: 0 0 .6em; max-width: 72ch; }
a { color: var(--primary); }
:focus-visible { outline: 4px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---------- Top bar and steps ---------- */
.topbar {
  display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: center; justify-content: space-between;
  padding: 14px 24px; background: var(--ink); color: #fff;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-logo { display: block; height: 64px; width: auto; flex: none; background: #fff; border-radius: 10px; padding: 4px 8px; }
.brand-text { display: flex; flex-direction: column; }
.brand-name { font-size: 1.6rem; font-weight: 700; line-height: 1.1; letter-spacing: .01em; }
.brand-sub { color: #c9d4dc; font-size: .9rem; }

.steps {
  display: flex; gap: 8px; padding: 12px 24px; background: var(--surface);
  border-bottom: 2px solid var(--line); overflow-x: auto;
}
.step {
  display: inline-flex; align-items: center; gap: 10px; min-height: 56px; padding: 0 20px;
  border: 2px solid var(--line); border-radius: var(--radius); background: var(--surface);
  font: inherit; font-size: 1.05rem; font-weight: 700; color: var(--ink); cursor: pointer; white-space: nowrap;
}
.step-n {
  display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%;
  border: 2px solid currentColor; font-size: .95rem;
}
.step[aria-current="page"] { background: var(--primary); border-color: var(--primary); color: #fff; }
.step:disabled { color: #9aa6b0; border-style: dashed; cursor: not-allowed; }
.step-beds { margin-left: auto; }
.step .done-mark { color: var(--ok); }
.step[aria-current="page"] .done-mark { color: #fff; }

.demo-banner {
  padding: 10px 24px; background: var(--warn-bg); color: var(--warn); font-weight: 700;
  border-bottom: 2px solid #e6c56b;
}

main { max-width: 1180px; margin: 0 auto; padding: 28px 24px 80px; outline: none; }
.stack > * + * { margin-top: 24px; }

/* ---------- Controls ---------- */
input[type=text], input[type=search], select, textarea {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 2px solid var(--muted); border-radius: 8px; padding: 10px 12px; min-height: 52px;
}
textarea { min-height: 110px; width: 100%; resize: vertical; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 56px; padding: 0 24px; border-radius: var(--radius);
  font: inherit; font-weight: 700; font-size: 1.05rem; cursor: pointer;
  border: 2px solid var(--primary); background: var(--surface); color: var(--primary);
}
.btn:hover { background: #e6f0f4; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn-ok:hover { background: #105430; }
.btn-bad { background: var(--surface); border-color: var(--bad); color: var(--bad); }
.btn-bad:hover { background: var(--bad-bg); }
.btn-big { min-height: 72px; font-size: 1.25rem; padding: 0 32px; }
.btn-small { min-height: 44px; padding: 0 14px; font-size: .95rem; }
.btn-link { border: none; background: none; padding: 0 4px; min-height: 44px; text-decoration: underline; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.muted { color: var(--muted); }
.small { font-size: .9rem; }

/* ---------- Panels ---------- */
.panel {
  background: var(--surface); border: 2px solid var(--line); border-radius: 14px; padding: 24px;
}
.panel-head { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.panel-head h2 { display: flex; align-items: center; gap: 12px; }
.panel.is-confirmed { border-color: var(--ok); }
.panel.is-editing { border-color: var(--warn); box-shadow: 0 0 0 4px var(--warn-bg); }

.notice { padding: 14px 16px; border-radius: var(--radius); border-left: 8px solid; margin: 12px 0; }
.notice p:last-child { margin-bottom: 0; }
.notice-warn { background: var(--warn-bg); border-color: var(--warn); }
.notice-bad { background: var(--bad-bg); border-color: var(--bad); }
.notice-ok { background: var(--ok-bg); border-color: var(--ok); }
.notice-info { background: #e6f0f4; border-color: var(--primary); }

/* ---------- Upload ---------- */
.dropzone {
  display: grid; place-items: center; gap: 14px; text-align: center;
  padding: 48px 24px; border: 3px dashed var(--primary); border-radius: 16px; background: var(--surface);
  cursor: pointer;
}
.dropzone.drag { background: #e6f0f4; }
.dropzone .file-name { font-weight: 700; font-size: 1.15rem; }
.progress-track { height: 18px; border-radius: 9px; background: var(--off-bg); overflow: hidden; }
.progress-fill { height: 100%; background: var(--primary); transition: width .6s ease; }
.progress-meta { display: flex; justify-content: space-between; margin-top: 8px; font-size: 1.05rem; }
.confidence { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--off-bg); }
.confidence-head { margin-bottom: 8px; }
.confidence-track { position: relative; height: 14px; border-radius: 7px;
  background: linear-gradient(90deg, #c8372d, #e2a72e 50%, #2e8b57); }
.confidence-marker { position: absolute; top: -5px; width: 6px; height: 24px; border-radius: 3px;
  background: var(--ink); box-shadow: 0 0 0 2px #fff; }
.confidence-scale { display: flex; justify-content: space-between; font-size: .85rem; margin-top: 4px; opacity: .8; }
.confidence-factors { margin: 8px 0 0; font-size: .95rem; }
.confidence-note { font-size: .85rem; margin-top: 6px; }
.progress-fill.indeterminate { width: 35% !important; animation: slide 1.6s ease-in-out infinite; }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(290%); } }
@media (prefers-reduced-motion: reduce) { .progress-fill.indeterminate { animation: none; width: 100% !important; opacity: .5; } }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 1rem; }
th, td { text-align: left; vertical-align: top; padding: 12px 12px; border-bottom: 1px solid var(--line); }
th { font-size: .9rem; color: var(--muted); font-weight: 700; border-bottom: 2px solid var(--ink); }
tbody tr:last-child td { border-bottom: none; }
td.key { width: 30%; font-weight: 700; }
tr.is-chosen td { background: var(--held-bg); }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: #f3f7f9; }
td input[type=text], td select { width: 100%; }
.edited-mark { color: var(--warn); font-weight: 700; font-size: .85rem; }

/* ---------- Badges (word + color + pattern) ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 12px; border-radius: 999px;
  font-weight: 700; font-size: .9rem; border: 2px solid; white-space: nowrap;
}
.badge::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: currentColor; }
.b-ok { color: var(--ok); background: var(--ok-bg); }
.b-bad { color: var(--bad); background: var(--bad-bg); }
.b-bad::before { border-radius: 2px; }
.b-warn { color: var(--warn); background: var(--warn-bg); }
.b-warn::before { border-radius: 0; transform: rotate(45deg); width: 9px; height: 9px; }
.b-held { color: var(--held); background: var(--held-bg); }
.b-held::before { background: linear-gradient(90deg, currentColor 50%, transparent 50%); border: 2px solid currentColor; }
.b-off { color: var(--off); background: var(--off-bg); }
.b-off::before { background: none; border: 2px solid currentColor; }
.b-info { color: var(--primary); background: #e6f0f4; }
.rule-id { font-weight: 700; white-space: nowrap; }

/* ---------- Recommendation banner + confirmation rail ---------- */
.verdict {
  display: grid; grid-template-columns: 1fr minmax(260px, 340px); gap: 0;
  background: var(--surface); border: 2px solid var(--line); border-radius: 16px; overflow: hidden;
}
.verdict-main { padding: 24px 28px; border-left: 14px solid var(--primary); }
.verdict-main.v-approve { border-left-color: var(--ok); }
.verdict-main.v-deny { border-left-color: var(--bad); }
.verdict-main.v-needs_review { border-left-color: var(--warn); }
.verdict-kicker { font-weight: 700; color: var(--muted); margin-bottom: 4px; }
.verdict-word { font-size: 2.6rem; font-weight: 700; line-height: 1.1; margin-bottom: 10px; }
.v-approve .verdict-word { color: var(--ok); }
.v-deny .verdict-word { color: var(--bad); }
.v-needs_review .verdict-word { color: var(--warn); }
.verdict-main ul { margin: 12px 0 0; padding-left: 1.2em; }
.verdict-main li { margin-bottom: 6px; }
.verdict-note { margin-top: 14px; font-weight: 700; }
.rail { background: #f6f8f9; border-left: 2px solid var(--line); padding: 20px; }
.rail h3 { margin-bottom: 12px; }
.rail ol { list-style: none; margin: 0 0 16px; padding: 0; }
.rail li { display: flex; gap: 12px; align-items: center; padding: 8px 0; }
.rail .tick {
  flex: none; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid var(--line); background: var(--surface); font-weight: 700;
}
.rail li.ok .tick { border-color: var(--ok); background: var(--ok); color: #fff; }
.rail a { color: inherit; }

/* ---------- Rules and evidence ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 16px; }
.chip {
  min-height: 44px; padding: 0 16px; border-radius: 999px; border: 2px solid var(--line);
  background: var(--surface); font: inherit; font-weight: 700; font-size: .95rem; cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.section-title { margin: 24px 0 8px; padding-bottom: 6px; border-bottom: 2px solid var(--line); }
.rule { padding: 14px 0; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 110px 1fr; gap: 6px 16px; }
.rule:last-child { border-bottom: none; }
.rule-text { color: var(--muted); font-size: .95rem; }
.rule-body > * + * { margin-top: 6px; }
.evidence {
  display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 8px; background: #f3f6f8;
  font-size: .95rem;
}
.evidence.unverified { background: var(--warn-bg); border: 2px solid var(--warn); }
.evidence q { font-style: italic; }
.override { display: grid; grid-template-columns: minmax(200px, 260px) 1fr; gap: 8px; padding: 10px; border-radius: 8px; background: var(--warn-bg); }

.tree { list-style: none; margin: 0; padding: 0; }
.tree li { display: grid; grid-template-columns: 36px 1fr; gap: 12px; padding-bottom: 14px; position: relative; }
.tree li::after { content: ""; position: absolute; left: 17px; top: 36px; bottom: 0; width: 2px; background: var(--line); }
.tree li:last-child::after { display: none; }
.tree .dot { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; border: 3px solid var(--ok); color: var(--ok); background: var(--surface); }
.tree .triggered .dot { border-color: var(--warn); background: var(--warn); color: #fff; }

details.reasoning > summary {
  cursor: pointer; font-weight: 700; color: var(--primary); min-height: 52px; display: flex; align-items: center;
  font-size: 1.05rem;
}

/* ---------- Bed board ---------- */
.occupancy { display: flex; height: 40px; border-radius: 10px; overflow: hidden; border: 2px solid var(--ink); }
.occupancy > span { display: block; height: 100%; }
.legend { display: flex; flex-wrap: wrap; gap: 10px 24px; margin-top: 12px; }
.legend-item { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.legend-item .count { font-size: 1.5rem; }
.swatch { width: 28px; height: 28px; border-radius: 6px; border: 2px solid var(--ink); }

/* status fills shared by the bar, swatches and bed tiles */
.s-available { background: #ffffff; }
.s-held { background: repeating-linear-gradient(135deg, var(--held-bg) 0 8px, #d9cff3 8px 16px); }
.s-occupied { background: #3b4a58; }
.s-needs_cleaning { background: repeating-linear-gradient(45deg, #ffe7a6 0 6px, #f7d36f 6px 12px); }
.s-out_of_service { background: repeating-linear-gradient(0deg, var(--off-bg) 0 4px, #c7ced3 4px 8px); }

.facility { margin-top: 28px; }
.facility-head { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: baseline; justify-content: space-between; margin-bottom: 12px; }
.facility-meta { color: var(--muted); }
.rooms { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.room { border: 2px solid var(--line); border-radius: 12px; padding: 10px; background: #f8fafb; }
.room-name { font-weight: 700; margin: 0 0 8px 4px; }
.room-beds { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
.bed {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-height: 92px; padding: 10px;
  border: 2px solid var(--ink); border-radius: 10px; font: inherit; text-align: left; cursor: pointer; color: var(--ink);
}
.bed:hover { box-shadow: 0 0 0 3px var(--primary); }
.bed .bed-label { font-weight: 700; font-size: 1.1rem; }
.bed .bed-status { font-size: .85rem; font-weight: 700; padding: 0 6px; border-radius: 4px; background: rgba(255,255,255,.88); color: var(--ink); }
.bed .bed-feat { font-size: .8rem; padding: 0 6px; border-radius: 4px; background: rgba(255,255,255,.88); }
.bed.s-occupied { color: #fff; }
.bed.s-occupied .bed-feat { color: var(--ink); }
.bed.is-due { box-shadow: inset 0 0 0 4px var(--bad); }

.kv { display: grid; grid-template-columns: minmax(140px, 34%) 1fr; gap: 8px 16px; margin: 0; }
.kv dt { font-weight: 700; }
.kv dd { margin: 0; }

/* ---------- Dialog ---------- */
dialog {
  width: min(960px, 96vw); max-height: 92vh; padding: 0; border: none; border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .35); color: var(--ink);
}
dialog::backdrop { background: rgba(23, 33, 43, .55); }
.dialog-head {
  position: sticky; top: 0; z-index: 1; display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 16px 24px; background: var(--surface); border-bottom: 2px solid var(--line);
}
.dialog-body { padding: 20px 24px 28px; }
.dialog-body > * + * { margin-top: 18px; }
.page-img { width: 100%; border: 2px solid var(--line); border-radius: 8px; background: #fff; }
pre.transcript { white-space: pre-wrap; font: inherit; font-size: .95rem; background: #f3f6f8; padding: 14px; border-radius: 8px; margin: 0; }
pre.draft { white-space: pre-wrap; font: inherit; font-size: .95rem; background: #f7f7f2; border: 2px dashed var(--muted); padding: 16px; border-radius: 8px; margin: 0; }

.confirm-hero { display: flex; gap: 20px; align-items: center; }
.confirm-hero .big-tick { flex: none; display: grid; place-items: center; width: 80px; height: 80px; border-radius: 50%; font-size: 2.6rem; color: #fff; background: var(--ok); }
.confirm-hero .big-tick.deny { background: var(--bad); }
.confirm-hero .big-tick.info { background: var(--warn); }

.choices { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.choice { display: flex; flex-direction: column; gap: 10px; }
.choice .btn { width: 100%; }
.why-disabled { color: var(--bad); font-weight: 700; font-size: .9rem; }

@media (max-width: 820px) {
  :root { font-size: 18px; }
  main { padding: 20px 16px 64px; }
  .topbar, .steps { padding-left: 16px; padding-right: 16px; }
  .verdict { grid-template-columns: 1fr; }
  .rail { border-left: none; border-top: 2px solid var(--line); }
  .choices { grid-template-columns: 1fr; }
  .rule { grid-template-columns: 1fr; }
  .override { grid-template-columns: 1fr; }
  .step-beds { margin-left: 0; }
}
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
summary { list-style: none; }
summary::-webkit-details-marker { display: none; }
summary::before { content: "▸"; display: inline-block; width: 1.2em; }
details[open] > summary::before { content: "▾"; }
.occupancy-small { height: 16px; border-width: 1px; border-radius: 6px; width: 100%; }
.sites { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.site-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding: 16px; min-height: 170px;
  border: 2px solid var(--line); border-radius: 14px; background: var(--surface); font: inherit; color: var(--ink);
  text-align: left; cursor: pointer;
}
.site-card:hover { border-color: var(--primary); box-shadow: 0 0 0 3px #cfe2ea; }
.site-name { font-weight: 700; font-size: 1.15rem; }
.site-count strong { font-size: 1.5rem; }
main:focus-visible { outline: none; }
@media (max-width: 820px) { .steps { flex-wrap: wrap; } .step { flex: 1 1 auto; } }

/* ---------- Admission criteria checklist (Table 2) ---------- */
.checklist { border: 2px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--surface); }
details.check { border-bottom: 1px solid var(--line); }
.checklist > details.check:last-child { border-bottom: none; }
details.check > summary {
  display: grid; grid-template-columns: 44px minmax(0, 1fr) auto 28px; align-items: center; gap: 6px 14px;
  min-height: 72px; padding: 12px 16px; cursor: pointer;
}
details.check > summary::before { content: none; }
details.check > summary:hover { background: #f3f7f9; }
details.check[open] > summary { background: #eef3f6; }
.check-icon {
  display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; border: 3px solid;
  font-weight: 700; font-size: 1.3rem; line-height: 1;
}
.c-b-ok > summary .check-icon { background: var(--ok); border-color: var(--ok); color: #fff; }
.c-b-bad > summary .check-icon { background: var(--bad); border-color: var(--bad); color: #fff; }
.c-b-warn > summary .check-icon, .c-b-held > summary .check-icon { background: var(--warn-bg); border-color: var(--warn); color: var(--warn); }
.c-b-off > summary .check-icon { background: var(--surface); border-color: var(--off); color: var(--off); }
.c-b-info > summary .check-icon { background: #e6f0f4; border-color: var(--primary); color: var(--primary); }
.check-title { font-weight: 700; font-size: 1.12rem; }
.check-detail { display: flex; flex-direction: column; align-items: flex-end; text-align: right; }
.c-b-ok > summary .check-detail strong { color: var(--ok); }
.c-b-bad > summary .check-detail strong { color: var(--bad); }
.c-b-warn > summary .check-detail strong, .c-b-held > summary .check-detail strong { color: var(--warn); }
.check-chevron { font-size: 1.3rem; color: var(--muted); transition: transform .2s; }
details.check[open] > summary > .check-chevron { transform: rotate(180deg); }
@media (prefers-reduced-motion: reduce) { .check-chevron { transition: none; } }
.check-body { padding: 8px 16px 18px 74px; }
.check-body > * { margin: 0; }
.check-body > * + * { margin-top: 10px; }
.check-body .checklist { border-width: 1px; border-radius: 10px; }

/* one criterion inside a main criterion */
details.check-item > summary { grid-template-columns: 32px minmax(0, 1fr) auto 24px; min-height: 56px; padding: 10px 12px; }
.check-item .check-icon { width: 30px; height: 30px; border-width: 2px; font-size: 1rem; }
.check-item .check-title { font-weight: 400; font-size: 1rem; }
.check-item .check-detail { font-weight: 700; font-size: .95rem; }
.check-item.c-b-off > summary .check-title, .check-item.c-b-off > summary .check-detail { color: var(--muted); }
.check-item.c-b-ok > summary .check-detail { color: var(--ok); }
.check-item.c-b-bad > summary .check-detail { color: var(--bad); }
.check-item.c-b-warn > summary .check-detail, .check-item.c-b-held > summary .check-detail { color: var(--warn); }
.check-item .check-body { padding: 4px 12px 16px 56px; }
ol.questions { margin: 0; padding-left: 1.3em; }
ol.questions li { margin-bottom: 6px; }
@media (max-width: 820px) {
  details.check > summary, details.check-item > summary { grid-template-columns: 36px minmax(0, 1fr) 24px; }
  .check-icon { grid-row: span 2; }
  .check-detail { grid-column: 2; align-items: flex-start; text-align: left; }
  .check-chevron { grid-row: 1; grid-column: 3; }
  .check-body, .check-item .check-body { padding-left: 12px; }
}

@media (max-width: 820px) {
  .panel { padding: 16px; }
  details.check > summary { padding: 10px; gap: 4px 10px; }
  details.check-item > summary { grid-template-columns: 28px minmax(0, 1fr) 20px; padding: 8px; }
  .check-body, .check-item .check-body { padding: 6px 10px 14px; }
}
