:root {
  color-scheme:light;
  font:100%/1.5 Inter,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
  --navy:#192b39; --ink:#213442; --muted:#536571; --brass:#c7a163;
  --page:#f5f4ef; --surface:#fff; --line:#d5d9d7; --edge:#a7b1b5; --error:#944331;
  color:var(--ink); background:var(--page);
}
* {box-sizing:border-box}
body {margin:0; min-height:100svh}
[hidden] {display:none!important}
button,input,textarea,select {font:inherit}
button {min-height:44px; padding:.55rem 1rem; border:1px solid var(--edge); border-radius:7px; background:white; color:var(--ink); font-weight:600; cursor:pointer}
button:hover {background:#eff2f2; border-color:#788791}
button:disabled {opacity:.46; cursor:default}
:focus-visible {outline:3px solid #926922; outline-offset:3px}
.primary {background:var(--navy); color:white; border-color:var(--navy)}
.primary:hover {background:#304858; border-color:#304858}
.link {border-color:transparent; background:transparent; text-decoration:underline; text-underline-offset:4px}
input,textarea,select {width:100%; min-width:0; min-height:46px; padding:.6rem .75rem; border:1px solid var(--edge); border-radius:6px; background:white; color:var(--ink); font-size:1rem; line-height:1.4; font-weight:400}
textarea {resize:vertical}
input[readonly] {background:#f4f5f2}
label {display:flex; flex-direction:column; gap:.35rem; font-size:.9rem; font-weight:620}
label small,.muted,.context {color:var(--muted); font-weight:400}
.check {display:inline-flex; flex-direction:row; align-items:center; gap:.65rem; min-height:44px; cursor:pointer; line-height:1.35}
.check input {width:19px; height:19px; min-height:0; margin:0; padding:0; flex:none; accent-color:var(--navy)}
h1,h2,h3,p {margin:0}
h1,h2 {font-family:"STIX Two Text",Georgia,"Times New Roman",serif; font-weight:500; line-height:1.12; letter-spacing:-.035em; color:var(--navy)}
h1 {font-size:clamp(2.25rem,4.2vw,3.45rem)}
h2 {font-size:clamp(1.7rem,2.8vw,2.25rem)}
h3 {font-size:1.05rem; margin:1.5rem 0 .65rem}
body[aria-busy] {cursor:progress}
body[aria-busy]::after {content:""; position:fixed; inset:0 0 auto; height:3px; z-index:10; background:var(--brass); pointer-events:none}
.mast {background:var(--navy); color:#fff; border-bottom:2px solid var(--brass); padding:8px max(24px,calc((100vw - 976px)/2)); display:flex; justify-content:space-between; align-items:center; flex-wrap:wrap; gap:.5rem 1rem}
.brand {display:flex; align-items:center; gap:clamp(8px,1.5vw,16px); min-width:0}
.brand img {width:clamp(58px,16vw,88px); height:auto; flex:none; border-radius:8px; display:block}
.wordmark {display:block; font-size:clamp(1.48rem,3.7vw,2.25rem); font-weight:700; line-height:1.1; letter-spacing:-.04em}
.wordmark b {color:#dec08b; font-weight:550}
.brand small {display:block; font-size:.78rem; color:#d5dfe4; margin-top:.15rem}
.outline-light {background:transparent; color:white; border-color:#83919b; font-size:.86rem}
.outline-light:hover {background:#304858}
main {max-width:1024px; margin:auto; padding:clamp(24px,4vw,48px) 24px}
main:has(.login:not([hidden])) {min-height:100svh; display:grid; place-items:center}
.login {width:min(100%,820px); display:grid; grid-template-columns:.85fr 1.15fr; background:white; border:1px solid var(--line); border-radius:18px; overflow:hidden; box-shadow:0 18px 65px #172c3910}
.login-brand {display:flex; flex-direction:column; align-items:center; justify-content:center; background:#172937; color:#fff; padding:3rem 1.5rem; text-align:center}
.login-brand img {width:min(100%,264px); height:auto; display:block}
.institution {margin-top:1rem; font-weight:600; font-size:1rem}
.institution small {display:block; font-size:.85rem; font-weight:400; color:#c3cfd6}
#login-form {align-self:center; display:grid; gap:1.25rem; padding:clamp(30px,5vw,64px) clamp(24px,4vw,48px); min-width:0}
#login-form h1 {font-size:clamp(2rem,3.2vw,2.7rem); margin-bottom:.2rem}
.remember {font-weight:550}
.remember small {display:block; margin-top:.15rem; font-size:.79rem}
.login-actions {display:flex; justify-content:space-between; gap:.5rem}
.login-actions:has(> [hidden]):not(:has(> :not([hidden]))) {display:none}
.login-actions button {font-size:.86rem; padding:.35rem .25rem}
.workspace-top,.list-head,.dialog-head,.modal-foot,.weekbar,.export,.export-options,.export-buttons {display:flex; align-items:center; gap:.75rem}
.workspace-top,.list-head,.dialog-head {justify-content:space-between}
.workspace-top {margin-bottom:1rem}
.workspace-top h1 {font-size:clamp(1.25rem,2.6vw,1.85rem)}
.tabs {display:inline-flex; gap:3px; padding:4px; border:1px solid var(--line); border-radius:10px; background:#eaece8}
.tabs button {border:0; background:transparent; color:var(--muted); padding:.5rem 1.5rem}
.tabs button[aria-pressed=true] {color:#fff; background:var(--navy)}
.weekbar {align-items:flex-end; flex-wrap:wrap; margin:1rem 0}
.arrows {display:flex; gap:4px}
.arrows button {font-size:1.45rem; line-height:1; min-width:44px; padding:0}
.list {background:var(--surface); border:1px solid var(--line); border-top:3px solid var(--brass); border-radius:12px; overflow:hidden}
.list-head,.patient,.export {padding:1.35rem 1.55rem}
.list-head h2 {font-size:clamp(1.25rem,2.2vw,1.6rem); margin-bottom:.15rem}
#count {font-size:.9rem; font-variant-numeric:tabular-nums}
.export {justify-content:space-between; flex-wrap:wrap; background:#fafaf7; border-top:1px solid var(--line)}
.export-options {align-items:end; flex-wrap:wrap}
.patient {border-top:1px solid var(--line)}
.patient summary,.staff-card summary {cursor:pointer; font-weight:650; overflow-wrap:anywhere}
.patient small,.staff-card small {display:block; font-size:.88rem; color:var(--muted); font-weight:400}
.patient small {margin:.2rem 0 0 1.1rem}
.details {display:grid; grid-template-columns:minmax(130px,1fr) 3fr; gap:.45rem 1rem}
.details dt {font-weight:600; color:var(--muted)}
.details dd {margin:0; white-space:pre-wrap; overflow-wrap:anywhere}
.details .outcome {border:1px solid var(--line); padding:.55rem; min-height:46px}
#status,.dialog-status {font-size:.94rem; margin-top:1rem}
#login-status {margin:0}
.status-error {color:var(--error)}
#status:empty,.dialog-status:empty {display:none}
dialog {background:white; color:var(--ink); border:1px solid var(--line); border-radius:14px; padding:clamp(18px,4vw,32px); width:min(680px,calc(100% - 24px)); max-height:90svh; box-shadow:0 24px 70px #12212a33}
dialog::backdrop {background:#152530b8}
dialog form {margin:0}
.dialog-head {margin-bottom:1.25rem}
.dialog-head button {font-size:1.5rem; line-height:1; padding:.1rem; width:44px; flex:none}
.context {font-size:.85rem; margin-bottom:.3rem}
.fields,#addresses {display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:1rem}
.wide {grid-column:1/-1}
.modal-foot {justify-content:flex-end; flex-wrap:wrap; margin-top:1.4rem}
.danger {color:var(--error); margin-right:auto}
.staff-card {border-top:1px solid var(--line); padding:.65rem 0}
.staff-head {display:grid; grid-template-columns:minmax(0,1fr) auto; align-items:start; gap:.8rem}
.staff-card summary {min-height:44px; padding:.2rem 0}
.staff-card summary>span {display:inline-block; max-width:calc(100% - 1.5rem); vertical-align:top}
.staff-card .role {font-size:.79rem; margin-left:.5rem; color:var(--muted); font-weight:500}
.staff-head .check {font-size:.85rem}
.staff-row {display:grid; grid-template-columns:1fr 1fr; gap:.7rem; padding:.75rem 0}
.staff-row button {align-self:end; justify-self:start; color:var(--error)}
#add-staff {margin:.65rem 0 .4rem}
li {overflow-wrap:anywhere}
@media (max-width:650px) {
  main {padding:24px 16px}
  .mast {padding:6px 12px; column-gap:6px}
  .mast .outline-light {padding:.5rem .6rem}
  main:has(.login:not([hidden])) {min-height:100svh; align-content:start; padding-top:clamp(20px,6svh,64px)}
  .login {grid-template-columns:1fr; max-width:420px}
  .login-brand {padding:1rem 1.2rem; flex-direction:row; justify-content:flex-start; gap:1rem; text-align:left}
  .login-brand img {width:clamp(110px,32vw,138px); flex:none}
  .institution {margin:0; font-size:.92rem}
  .institution small {font-size:.76rem}
  #login-form {padding:1.75rem 1.35rem; gap:1.1rem}
  .workspace-top {align-items:center; flex-wrap:wrap; gap:.5rem; margin-bottom:.7rem}
  #settings {font-size:.85rem; padding:.4rem .7rem}
  .tabs {display:flex}
  .tabs button {flex:1; padding:.5rem .2rem}
  .weekbar {gap:.4rem; margin:1rem 0}
  .weekbar .link {padding:.45rem}
  .list-head,.patient,.export {padding:1rem}
  .export,.export-options,.export-buttons {display:grid; width:100%; gap:.65rem}
  .export-options,.export-buttons {grid-template-columns:repeat(2,minmax(0,1fr))}
  .export-options .check {font-size:.85rem}
  .export-buttons button {padding:.5rem}
  .details,.fields,#addresses,.staff-row {grid-template-columns:minmax(0,1fr)}
  .details dd {margin-bottom:.55rem}
  .staff-head {gap:.4rem}
  body:has(dialog[open]) {overflow:hidden}
  #entry[open] {position:fixed; inset:0; margin:0; width:100%; max-width:100%; height:100dvh; max-height:100dvh; padding:0; border:0; border-radius:0; overflow:hidden}
  #case-form {height:100%; display:grid; grid-template-rows:auto minmax(0,1fr) auto auto}
  #case-form>.dialog-head {padding:max(1rem,env(safe-area-inset-top)) 1rem .75rem; margin:0; border-bottom:1px solid var(--line)}
  #case-form>.fields {display:flex; flex-direction:column; gap:.9rem; min-height:0; overflow:auto; overscroll-behavior:contain; padding:1rem; scroll-padding-block:1rem}
  #case-form>.modal-foot {grid-row:4; margin:0; border-top:1px solid var(--line); padding:.65rem 1rem max(.65rem,env(safe-area-inset-bottom)); background:#fafaf7; gap:.45rem}
  #case-form .modal-foot button {padding:.5rem .65rem}
  .modal-foot .primary {flex:1}
  #case-form .dialog-status:not(:empty) {grid-row:3; margin:0; padding:.4rem 1rem}
}
