/* WAJD Quality: the internal clinical quality dashboard. Copyright WAJD Group. Built by WAJD AI.
   One system, applied everywhere: flat cards with a hairline border, one gold pill for the
   primary action, colour only for status. Nothing animates unless the person asks for it. */

:root {
  --gold: #C9A227;
  --gold-deep: #8a6d12;
  --on-gold: #1d1a10;
  --ink: #1f2533;
  --muted: #586174;
  --faint: #7f8798;
  --bg: #f4f5f7;
  --card: #ffffff;
  --line: #dde1e8;
  --field: #ffffff;
  --chip: #eceef3;
  --good: #2f6b41;
  --good-bg: #e4f1e7;
  --warn: #8a4a1c;
  --warn-bg: #f8ead9;
  --bad: #8f2f2f;
  --bad-bg: #f7e1e1;
  --info: #2c4f85;
  --info-bg: #e3ebf7;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
[data-theme="dark"] {
  --gold-deep: #dcb945;
  --ink: #e7e9ef;
  --muted: #aab0bf;
  --faint: #858c9d;
  --bg: #13161d;
  --card: #1c202a;
  --line: #313747;
  --field: #161a23;
  --chip: #272c3a;
  --good: #7cc391;
  --good-bg: #1c3324;
  --warn: #e0a070;
  --warn-bg: #3a2a1b;
  --bad: #e58d8d;
  --bad-bg: #3d2020;
  --info: #93b4e6;
  --info-bg: #1e2c44;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font: 15px/1.55 "Avenir Next", "Segoe UI", system-ui, sans-serif; background: var(--bg); color: var(--ink); }
a { color: var(--gold-deep); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; line-height: 1.25; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 0 0 10px; }
h3 { font-size: 14px; margin: 14px 0 4px; }
p { margin: 6px 0; }
ul { margin: 6px 0; padding-left: 20px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.right { margin-left: auto; }
.nowrap { white-space: nowrap; }
.measure { max-width: 46rem; }

/* Shell */
.shell { max-width: 1180px; margin: 0 auto; padding: 0 20px 64px; }
header.top { display: flex; align-items: center; gap: 12px; padding: 14px 0 12px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 17px; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand img { width: 28px; height: 28px; display: block; }
.who { margin-left: auto; display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
nav.main { display: flex; gap: 2px; flex-wrap: wrap; border-bottom: 1px solid var(--line); padding-bottom: 10px; margin-bottom: 22px; }
nav.main a { padding: 6px 12px; border-radius: 999px; color: var(--muted); font-size: 14px; }
nav.main a:hover { text-decoration: none; background: var(--chip); }
nav.main a.active { background: var(--chip); color: var(--ink); font-weight: 600; }
.crumbs { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.pagehead { display: flex; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.pagehead .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* Cards: flat, hairline border, real gaps */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 18px 20px; margin-bottom: 16px; }
.card > h2:first-child { margin-top: 0; }
.cardhead { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.cardhead h2 { margin: 0; }
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid.four { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.grid > .card { margin-bottom: 0; }
.split { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 900px) { .split { grid-template-columns: 1fr; } }
.stack { margin-bottom: 16px; }

/* Tiles */
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px; }
.tile .label { font-size: 13px; color: var(--muted); }
.tile .figure { font-size: 32px; font-weight: 600; line-height: 1.15; margin: 4px 0 2px; }
.tile .note { font-size: 12.5px; color: var(--faint); }
.tile.alert .figure { color: var(--bad); }
.tile.fine .figure { color: var(--good); }

/* Buttons: one metric. Gold pill is the single primary action. */
button, .btn {
  font: inherit; font-size: 14px; line-height: 1; height: 36px; padding: 0 16px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: var(--card); color: var(--ink); display: inline-flex; align-items: center; gap: 6px;
}
button:hover, .btn:hover { border-color: var(--faint); text-decoration: none; }
button.primary { background: var(--gold); border-color: var(--gold); color: var(--on-gold); font-weight: 600; }
button.primary:hover { background: #d6ae32; border-color: #d6ae32; }
button.danger { color: var(--bad); border-color: var(--bad); }
button.quiet { border-color: transparent; background: transparent; color: var(--muted); padding: 0 10px; }
button.quiet:hover { background: var(--chip); }
button.link { border: 0; background: none; height: auto; padding: 0; color: var(--gold-deep); border-radius: 0; }
button.link:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* Chips: status only */
.chip { display: inline-flex; align-items: center; height: 22px; padding: 0 9px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--chip); color: var(--muted); white-space: nowrap; }
.chip.good { background: var(--good-bg); color: var(--good); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.bad { background: var(--bad-bg); color: var(--bad); }
.chip.info { background: var(--info-bg); color: var(--info); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.filters { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; align-items: center; }
.filters button { height: 30px; font-size: 13px; padding: 0 12px; }
.filters button.on { background: var(--ink); border-color: var(--ink); color: var(--bg); }

/* The ten gates */
.gates { list-style: none; margin: 0; padding: 0; }
.gates li { display: grid; grid-template-columns: 24px 1fr; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.gates li:first-child { border-top: 0; padding-top: 2px; }
.gates .t { font-weight: 600; font-size: 14px; }
.gates .d { font-size: 13px; color: var(--muted); }
.mark { width: 22px; height: 22px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.mark svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.mark.pass { background: var(--good-bg); color: var(--good); }
.mark.fail { background: var(--bad-bg); color: var(--bad); }
.mark.wait { background: var(--chip); color: var(--muted); }
.strip { display: inline-flex; gap: 3px; vertical-align: middle; }
.strip i { width: 9px; height: 16px; border-radius: 2px; background: var(--bad); display: block; }
.strip i.pass { background: var(--good); }
.strip i.wait { background: var(--line); }
.gatebar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 14px; margin-bottom: 16px; color: var(--ink); font-size: 14px; }
.gatebar:hover { text-decoration: none; border-color: var(--faint); }
.gatebar .right { color: var(--gold-deep); }
.card > .help, .card > .rowactions { margin-top: 12px; }
.verdict { border-radius: 8px; padding: 10px 12px; font-size: 14px; margin-bottom: 12px; background: var(--bad-bg); color: var(--bad); }
.verdict.good { background: var(--good-bg); color: var(--good); }
.verdict.wait { background: var(--info-bg); color: var(--info); }

/* Tabs */
.tabs { display: flex; gap: 2px; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs a { padding: 8px 14px; color: var(--muted); font-size: 14px; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a:hover { text-decoration: none; color: var(--ink); }
.tabs a.active { color: var(--ink); font-weight: 600; border-bottom-color: var(--gold); }
.tabs .count { font-size: 12px; color: var(--faint); margin-left: 4px; }

/* Tables and lists */
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 6px 10px 6px 0; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 9px 10px 9px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--chip); }
td.code { font-family: var(--mono); font-size: 12.5px; white-space: nowrap; }
td.check, th.check { width: 28px; }
.rows { list-style: none; margin: 0; padding: 0; }
.rows > li { padding: 12px 0; border-top: 1px solid var(--line); }
.rows > li:first-child { border-top: 0; padding-top: 0; }
.rows > li:last-child { padding-bottom: 0; }
.rowhead { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 4px; }
.rowactions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.rowactions button { height: 30px; font-size: 13px; padding: 0 12px; }
.empty { color: var(--muted); font-size: 14px; padding: 6px 0; }
dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 0; font-size: 14px; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; }

/* Questions */
.item { border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; margin-bottom: 10px; display: grid; grid-template-columns: 22px 1fr; gap: 10px; }
.item .stem { font-weight: 600; }
.item ol { margin: 6px 0; padding-left: 22px; }
.item li.correct { font-weight: 600; color: var(--good); }
.item .why { font-size: 13.5px; color: var(--muted); border-left: 2px solid var(--line); padding-left: 10px; margin: 6px 0; }
.bar { position: sticky; bottom: 12px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; background: var(--card);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; margin-top: 12px; }

/* Reading a module */
.reading { max-width: 46rem; }
.reading h3 { font-size: 16px; margin-top: 22px; }
.callout { border-left: 3px solid var(--gold); background: var(--chip); padding: 10px 14px; border-radius: 0 8px 8px 0; margin: 10px 0; }
.say { display: grid; grid-template-columns: 84px 1fr; gap: 10px; padding: 6px 0; font-size: 14px; }
.say b { color: var(--muted); font-weight: 600; text-transform: capitalize; }

/* Forms and dialogs */
label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 4px; }
input[type="text"], input[type="email"], input[type="password"], input[type="date"], select, textarea {
  width: 100%; font: inherit; font-size: 16px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--field); color: var(--ink);
}
textarea { min-height: 96px; resize: vertical; }
input[type="checkbox"], input[type="radio"] { width: 16px; height: 16px; accent-color: var(--gold); margin: 0; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.choice { display: flex; gap: 8px; align-items: flex-start; margin: 6px 0; font-size: 14px; color: var(--ink); }
.choice input { margin-top: 3px; }
.help { font-size: 12.5px; color: var(--faint); margin-top: 3px; }
.error { background: var(--bad-bg); color: var(--bad); border-radius: 8px; padding: 9px 12px; font-size: 14px; margin: 12px 0 0; }
.notice { background: var(--info-bg); color: var(--info); border-radius: 8px; padding: 9px 12px; font-size: 14px; margin: 0 0 14px; }
.notice.good { background: var(--good-bg); color: var(--good); }
.notice.bad { background: var(--bad-bg); color: var(--bad); }
.notice.warn { background: var(--warn-bg); color: var(--warn); }
dialog { border: 1px solid var(--line); border-radius: 12px; padding: 0; background: var(--card); color: var(--ink); width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 48px); }
dialog::backdrop { background: rgba(15, 18, 26, 0.55); }
dialog form { padding: 20px 22px; }
dialog h2 { font-size: 18px; margin: 0 0 6px; }
.formactions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }
.enrol { text-align: center; margin: 14px 0 4px; }
.enrol .qr { display: block; width: 216px; height: 216px; margin: 0 auto 12px; border-radius: 8px; }
.enrol p { margin: 0 0 4px; }
.enrol .key { font-size: 15px; letter-spacing: 0.04em; color: var(--ink); user-select: all; overflow-wrap: anywhere; }
.login { max-width: 380px; margin: 9vh auto 0; }
.login .brand { justify-content: center; margin-bottom: 18px; font-size: 19px; }
.login button.primary { width: 100%; justify-content: center; margin-top: 18px; height: 40px; }

/* Print: the release report */
@media print {
  body { background: #fff; color: #000; }
  header.top, nav.main, .tabs, .actions, .noprint, .crumbs { display: none !important; }
  .card, .tile { border-color: #999; break-inside: avoid; }
  .split { grid-template-columns: 1fr; }
}

/* Narrow screens. The dashboard is built for a desk, and stays usable on a phone. */
.brand { white-space: nowrap; }
header.top { flex-wrap: wrap; }
@media (max-width: 900px) { .grid.four { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 700px) {
  .shell { padding: 0 14px 48px; }
  .bar { position: static; }
  .pagehead .actions { margin-left: 0; }
  dl.facts { grid-template-columns: 1fr; gap: 0; }
  dl.facts dt { margin-top: 8px; font-size: 12.5px; }
}
