/* Previva web client. Colours from the brand: accent #00B2D4, strong #00748C, navy #003554.
   No external fonts — nothing on this page loads from anyone else's server. */
:root {
  --accent: #00B2D4; --strong: #00748C; --navy: #003554; --navy2: #00263D;
  --bg: #FFFFFF; --raised: #EBFAFC; --line: #D7E6EA; --text: #10232B; --muted: #5C7580;
  --ok: #1E9E5A; --warn: #D98E04; --bad: #C8322B;
  --radius: 12px; --shadow: 0 1px 2px rgba(0,53,84,.06), 0 4px 16px rgba(0,53,84,.06);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 Montserrat, Poppins, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }
a { color: var(--strong); text-decoration: none; } a:hover { text-decoration: underline; }
h1, h2, h3 { color: var(--navy); margin: 0 0 .5em; line-height: 1.2; }
h1 { font-size: 1.6rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1rem; }
p { margin: .4em 0 .8em; }
.muted { color: var(--muted); } .small { font-size: .85em; } .right { text-align: right; } .nowrap { white-space: nowrap; }
.center { text-align: center; padding: 3rem 1rem; }
[hidden] { display: none !important; }

header#top { display: flex; align-items: center; gap: 1rem; padding: .6rem 1.2rem; background: var(--navy); color: #fff; position: sticky; top: 0; z-index: 5; }
header .brand { color: #fff; font-weight: 700; font-size: 1.15rem; letter-spacing: .02em; }
header nav { display: flex; gap: .2rem; flex-wrap: wrap; }
header nav a { color: #CFEFF6; padding: .35rem .7rem; border-radius: 8px; font-size: .92rem; }
header nav a.active, header nav a:hover { background: rgba(255,255,255,.12); color: #fff; text-decoration: none; }
header .spacer { flex: 1; }
header .lang button { background: none; border: 0; color: #CFEFF6; cursor: pointer; padding: .3rem .4rem; font: inherit; font-size: .85rem; }
header .lang button.on { color: #fff; font-weight: 700; text-decoration: underline; }
header button.link { color: #CFEFF6; }
button.link { background: none; border: 0; padding: 0; color: var(--strong); cursor: pointer; font: inherit; }

main { max-width: 1080px; margin: 0 auto; padding: 1.4rem 1.2rem 4rem; }
.narrow { max-width: 440px; margin: 2rem auto; }
.card { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.1rem 1.2rem; margin-bottom: 1rem; }
.card.raised { background: var(--raised); border-color: transparent; box-shadow: none; }
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.cols { display: grid; gap: 1.2rem; grid-template-columns: 2fr 1fr; }
@media (max-width: 800px) { .cols { grid-template-columns: 1fr; } }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }

.stats { display: grid; gap: .8rem; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); margin-bottom: 1rem; }
.stat { background: var(--raised); border-radius: var(--radius); padding: .8rem 1rem; }
.stat .v { font-size: 1.5rem; font-weight: 700; color: var(--navy); }
.stat .l { font-size: .8rem; color: var(--muted); }
.stat .v.up { color: var(--bad); } .stat .v.down { color: var(--ok); }

form { display: block; }
label { display: block; font-size: .85rem; color: var(--muted); margin: .7rem 0 .2rem; }
label.inline { display: flex; align-items: flex-start; gap: .5rem; color: var(--text); font-size: .95rem; margin: .6rem 0; }
label.inline input { margin-top: .25rem; }
input, select, textarea { width: 100%; padding: .55rem .7rem; border: 1px solid var(--line); border-radius: 8px; font: inherit; background: #fff; color: var(--text); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
input[type=checkbox] { width: auto; }
textarea { min-height: 4.5em; resize: vertical; }
.fields { display: grid; gap: 0 1rem; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
button, .btn { display: inline-block; padding: .55rem 1rem; border: 0; border-radius: 8px; background: var(--accent); color: #fff; font: inherit; font-weight: 600; cursor: pointer; }
button:hover, .btn:hover { background: var(--strong); text-decoration: none; }
button.secondary { background: var(--raised); color: var(--strong); }
button.secondary:hover { background: #D9F3F8; }
button.danger { background: var(--bad); } button.danger:hover { background: #9E2620; }
button.sm { padding: .3rem .6rem; font-size: .82rem; font-weight: 500; }
button:disabled { opacity: .5; cursor: default; }
.actions { display: flex; gap: .6rem; margin-top: 1rem; flex-wrap: wrap; align-items: center; }
.error { color: var(--bad); background: #FCEDEC; border-radius: 8px; padding: .5rem .8rem; margin: .8rem 0; }
.notice { background: var(--raised); border-radius: 8px; padding: .6rem .9rem; margin: .8rem 0; }
.notice.warn { background: #FFF6E0; }
.hint { font-size: .82rem; color: var(--muted); margin-top: .2rem; }

table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
tr.click { cursor: pointer; } tr.click:hover td { background: var(--raised); }
.scroll { overflow-x: auto; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

.badge { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .75rem; font-weight: 600; background: var(--raised); color: var(--strong); }
.badge.green { background: #E3F6EA; color: var(--ok); } .badge.amber { background: #FFF1D6; color: var(--warn); } .badge.red { background: #FCE4E3; color: var(--bad); }
.badge.internal { background: #EEE; color: #666; } .badge.clinicians { background: #E8ECF7; color: #3A4E8C; } .badge.client { background: #E3F6EA; color: var(--ok); }
.badge.grey { background: #EEE; color: #666; }

canvas.chart { width: 100%; height: 240px; display: block; }
.range button { background: none; border: 1px solid var(--line); color: var(--strong); font-weight: 500; padding: .25rem .6rem; }
.range button.on { background: var(--accent); color: #fff; border-color: var(--accent); }

.comment { border-left: 3px solid var(--line); padding: .3rem .8rem; margin: .6rem 0; }
.comment.resolved { opacity: .55; }
.comment .who { font-size: .8rem; color: var(--muted); }
.comment .body { white-space: pre-wrap; margin: .2rem 0; }
.comment.reply { margin-left: 1.4rem; }

.doc { border: 1px solid var(--line); border-radius: var(--radius); margin: .6rem 0; }
.doc summary { padding: .6rem .9rem; cursor: pointer; font-weight: 600; color: var(--navy); }
.doc .md { padding: 0 1rem 1rem; font-size: .9rem; max-height: 22rem; overflow: auto; }
.md h1 { font-size: 1.15rem; } .md h2 { font-size: 1rem; } .md h3 { font-size: .95rem; }

pre { background: var(--raised); padding: .8rem; border-radius: 8px; overflow: auto; font-size: .82rem; white-space: pre-wrap; word-break: break-word; }
code { background: var(--raised); padding: .05rem .3rem; border-radius: 4px; font-size: .9em; }
.copy { font-family: ui-monospace, Menlo, monospace; font-size: .85rem; word-break: break-all; background: var(--raised); padding: .5rem .7rem; border-radius: 8px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .2rem 1rem; font-size: .92rem; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }

#toasts { position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: .4rem; z-index: 20; }
.toast { background: var(--navy); color: #fff; padding: .6rem 1rem; border-radius: 8px; box-shadow: var(--shadow); font-size: .9rem; animation: fade 4s forwards; }
.toast.bad { background: var(--bad); } .toast.ok { background: var(--ok); }
@keyframes fade { 0%,80% { opacity: 1 } 100% { opacity: 0 } }
#modal { position: fixed; inset: 0; background: rgba(0,38,61,.45); display: flex; align-items: center; justify-content: center; z-index: 30; padding: 1rem; }
#modal .card { max-width: 480px; width: 100%; margin: 0; }
.tabs { display: flex; gap: .3rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; flex-wrap: wrap; }
.tabs a { padding: .5rem .8rem; border-bottom: 2px solid transparent; color: var(--muted); }
.tabs a.on { color: var(--navy); border-color: var(--accent); font-weight: 600; }
