:root {
  --bg: #f6f5f2;
  --panel: #ffffff;
  --ink: #1d232b;
  --muted: #5b6573;
  --line: #d9dde3;
  --accent: #23527c;
  --accent-ink: #ffffff;
  --urgent: #a4161a;
  --urgent-bg: #fdecec;
  --high: #8a5a00;
  --high-bg: #fff4dc;
  --ok: #1e6b3a;
  --ok-bg: #e6f4ea;
  --demo: #5a3e8c;
  --demo-bg: #efe9f8;
  --focus: #f0b400;
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121519; --panel: #1b2027; --ink: #e8ebef; --muted: #a3adba; --line: #313945;
    --accent: #7fb0e0; --accent-ink: #0d1a26; --urgent: #ff8a8f; --urgent-bg: #3a1618;
    --high: #f2c46b; --high-bg: #3a2c10; --ok: #8fd6a6; --ok-bg: #12301d; --demo: #c7b3ee; --demo-bg: #2a2140;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121519; --panel: #1b2027; --ink: #e8ebef; --muted: #a3adba; --line: #313945;
  --accent: #7fb0e0; --accent-ink: #0d1a26; --urgent: #ff8a8f; --urgent-bg: #3a1618;
  --high: #f2c46b; --high-bg: #3a2c10; --ok: #8fd6a6; --ok-bg: #12301d; --demo: #c7b3ee; --demo-bg: #2a2140;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: 1.4rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .75em; }

.skip { position: absolute; left: -9999px; }
.skip:focus { left: 16px; top: 8px; background: var(--panel); padding: 8px 12px; z-index: 10; }

header.top { background: var(--panel); border-bottom: 1px solid var(--line); padding: 10px 16px; display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between; }
header.top .brand { font-weight: 650; }
header.top .who { color: var(--muted); font-size: .92rem; }
.banner { padding: 8px 16px; font-size: .92rem; border-bottom: 1px solid var(--line); }
.banner.demo { background: var(--demo-bg); color: var(--demo); }
.banner.off { background: var(--high-bg); color: var(--high); }

nav.tabs { display: flex; gap: 4px; overflow-x: auto; padding: 8px 16px 0; background: var(--panel); border-bottom: 1px solid var(--line); }
nav.tabs button { border: 0; background: none; color: var(--muted); padding: 10px 12px; border-bottom: 3px solid transparent; font: inherit; cursor: pointer; white-space: nowrap; }
nav.tabs button[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
nav.tabs .count { display: inline-block; min-width: 1.4em; padding: 0 .4em; margin-left: 4px; border-radius: 99px; background: var(--urgent); color: #fff; font-size: .78rem; text-align: center; }

main { max-width: 1100px; margin: 0 auto; padding: 16px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.grow { flex: 1; min-width: 0; width: auto; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }

button, .button { font: inherit; border-radius: 8px; padding: 9px 14px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); cursor: pointer; min-height: 44px; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.danger { border-color: var(--urgent); color: var(--urgent); }
button:disabled { opacity: .55; cursor: not-allowed; }

label { display: block; font-weight: 600; font-size: .92rem; margin: 10px 0 4px; }
input, select, textarea { font: inherit; width: 100%; padding: 9px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); }
textarea { min-height: 90px; resize: vertical; }
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; margin: 10px 0; }
legend { font-weight: 600; font-size: .92rem; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 400; }
.check input { width: auto; }

table { width: 100%; border-collapse: collapse; font-size: .94rem; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: .85rem; }
.table-wrap { overflow-x: auto; }

.pill { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: .8rem; border: 1px solid var(--line); white-space: nowrap; }
.pill.urgent { background: var(--urgent-bg); color: var(--urgent); border-color: transparent; font-weight: 600; }
.pill.high { background: var(--high-bg); color: var(--high); border-color: transparent; }
.pill.ok { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.pill.unreviewed { background: var(--high-bg); color: var(--high); border-color: transparent; font-weight: 600; }

.flag { border-left: 5px solid var(--urgent); }
.flag.high { border-left-color: var(--high); }
.notice { padding: 10px 12px; border-radius: 8px; background: var(--high-bg); color: var(--high); margin-bottom: 12px; }
.error { padding: 10px 12px; border-radius: 8px; background: var(--urgent-bg); color: var(--urgent); margin-bottom: 12px; }
.success { padding: 10px 12px; border-radius: 8px; background: var(--ok-bg); color: var(--ok); margin-bottom: 12px; }

.timeline { list-style: none; padding: 0; margin: 0; border-left: 2px solid var(--line); }
.timeline li { position: relative; padding: 0 0 14px 16px; }
.timeline li::before { content: ""; position: absolute; left: -7px; top: 6px; width: 12px; height: 12px; border-radius: 50%; background: var(--accent); }
.timeline li.task::before { background: var(--muted); }

.section-answers, .section-scores, .section-eval { border-radius: 8px; padding: 10px 12px; margin: 10px 0; border: 1px solid var(--line); }
.section-answers h3::before { content: "Person's answers"; display: block; font-size: .75rem; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.section-scores h3::before { content: "Calculated by rule"; display: block; font-size: .75rem; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.section-eval h3::before { content: "Clinician's judgement"; display: block; font-size: .75rem; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }

.demo-pick { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }
.demo-pick button { justify-content: flex-start; text-align: left; flex-direction: column; align-items: flex-start; }

@media (max-width: 600px) {
  main { padding: 12px; }
  .panel { padding: 12px; }
  th, td { padding: 6px 4px; }
}
@media print {
  header.top, nav.tabs, .banner, button { display: none !important; }
  body { background: #fff; color: #000; }
}
