/* AuroraMed chrome. Theme variables and layout constants mirror Overlord's console (48px top bar, 210px sidebar, 28px status footer,
   red offline banner, dark + gold accent). Palette values are Overlord's :root variables. */
:root {
  --bg: #0b0f14; --panel: #12181f; --panel2: #1a222d; --panel3: #222c3a;
  --border: #2a3544; --border-strong: #3a4a5c; --text: #e8eef4; --muted: #8b9aab; --faint: #5a6a7c;
  --accent: #c9a227; --accent-dim: #a6841c; --accent2: #58a6ff;
  --danger: #e05c5c; --danger-bg: rgba(224,92,92,0.12); --success: #3fb950; --success-bg: rgba(63,185,80,0.12);
  --warn: #d29922; --warn-bg: rgba(210,153,34,0.12);
  --sidebar-w: 210px; --sidebar-rail-w: 56px; --top-h: 48px; --status-h: 28px;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif; --mono: "Cascadia Code", "Consolas", "SF Mono", ui-monospace, monospace;
  --bead-thumb: linear-gradient(180deg, #e4c04a 0%, var(--accent) 42%, var(--accent-dim) 100%);
  --fs: 14px;
}
body.theme-light { --bg:#f4f6f8; --panel:#fff; --panel2:#eef1f4; --panel3:#e3e8ee; --text:#111; --muted:#555; --faint:#889; --border:#dde1e6; --border-strong:#c3cad3; }
body.large-text { --fs: 17px; }
body.high-contrast { --border: #7d8ea3; --muted: #c5d0dc; --text: #fff; }
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: var(--fs)/1.45 var(--font); overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
::-webkit-scrollbar { width: 10px; height: 10px; } ::-webkit-scrollbar-track { background: var(--panel); }
::-webkit-scrollbar-thumb { background: var(--bead-thumb); border-radius: 6px; border: 2px solid var(--panel); }

#app { display: grid; grid-template-rows: var(--top-h) 1fr var(--status-h); height: 100vh; height: 100dvh; }
#body { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 0; }
body.rail #body { grid-template-columns: var(--sidebar-rail-w) 1fr; }
#top { background: var(--panel); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; padding: 0 12px; min-width: 0; }
#top .brand { font-weight: 700; letter-spacing: .4px; color: var(--accent); white-space: nowrap; }
#top .brand small { color: var(--muted); font-weight: 400; margin-left: 6px; }
#top .spacer { flex: 1; }
.iconbtn { background: transparent; border: 1px solid transparent; color: var(--muted); width: 34px; height: 34px; border-radius: 6px; cursor: pointer; font-size: 16px; }
.iconbtn:hover { color: var(--accent); border-color: var(--border); } .iconbtn:disabled { opacity: .35; cursor: default; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; border: 1px solid var(--border); background: var(--panel2); color: var(--muted); white-space: nowrap; }
.pill.demo { color: var(--warn); border-color: var(--warn); background: var(--warn-bg); font-weight: 700; }
.pill.ok { color: var(--success); } .pill.bad { color: var(--danger); border-color: var(--danger); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); display: inline-block; } .dot.on { background: var(--success); } .dot.busy { background: var(--warn); } .dot.dnd { background: var(--danger); }
.userchip { display: flex; align-items: center; gap: 8px; padding: 3px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--panel2); max-width: 300px; }
.userchip .n { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .userchip .r { color: var(--muted); font-size: 11px; white-space: nowrap; }
#sidebar { background: var(--panel); border-right: 1px solid var(--border); overflow-y: auto; padding: 8px 0; }
#sidebar .grp { color: var(--faint); font-size: 10.5px; text-transform: uppercase; letter-spacing: 1px; padding: 12px 16px 4px; }
#sidebar .item { display: flex; align-items: center; gap: 10px; padding: 9px 16px; cursor: pointer; color: var(--muted); border-left: 3px solid transparent; min-height: 44px; }
#sidebar .item:hover { background: var(--panel2); color: var(--text); }
#sidebar .item.active { background: var(--panel2); color: var(--accent); border-left-color: var(--accent); }
#sidebar .item .ic { width: 22px; text-align: center; font-size: 16px; } #sidebar .item .lb { flex: 1; } 
.badge { background: var(--danger); color: #fff; border-radius: 999px; min-width: 20px; padding: 0 6px; font-size: 11px; text-align: center; font-weight: 700; }
body.rail #sidebar .lb, body.rail #sidebar .grp { display: none; } body.rail #sidebar .item { justify-content: center; padding: 9px 0; } body.rail .badge { position: absolute; margin: -18px -20px 0 0; }
#content { overflow: auto; padding: 16px; min-width: 0; position: relative; }
#status { background: var(--panel); border-top: 1px solid var(--border); display: flex; align-items: center; padding: 0 14px; gap: 18px; font-size: 11.5px; color: var(--muted); overflow: hidden; white-space: nowrap; }
#status .ok { color: var(--success); } #status .bad { color: var(--danger); } #status .sep { color: var(--faint); }
#offlineBanner { display: none; position: fixed; top: 0; left: 0; right: 0; z-index: 9999; background: #7f1d1d; color: #fff; text-align: center; padding: 8px 12px; font-size: 13px; }
body.offline #offlineBanner { display: block; } body.offline #top { margin-top: 34px; } body.offline #app { grid-template-rows: calc(var(--top-h) + 34px) 1fr var(--status-h); }
body.offline .needs-online { opacity: .45; pointer-events: none; }

h1 { font-size: 20px; margin: 0 0 4px; } h2 { font-size: 15px; margin: 0 0 8px; } .sub { color: var(--muted); font-size: 12.5px; margin-bottom: 12px; }
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 14px; margin-bottom: 14px; min-width: 0; }
.panel-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.stat { font-size: 30px; font-weight: 700; color: var(--accent); } .stat small { display: block; font-size: 12px; font-weight: 400; color: var(--muted); }
.btn { background: var(--panel2); border: 1px solid var(--border); border-radius: 8px; padding: 7px 14px; cursor: pointer; min-height: 36px; }
.btn:hover { border-color: var(--accent); color: var(--accent); } .btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--accent); color: #111; border-color: var(--accent); font-weight: 600; } .btn.primary:hover { background: #dbb12e; color: #111; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; } .btn.big { min-height: 56px; font-size: 17px; padding: 10px 26px; }
input[type=text], input[type=number], input[type=date], input[type=password], select, textarea { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; width: 100%; min-height: 36px; }
textarea { resize: vertical; min-height: 90px; } label.f { display: block; margin: 8px 0 3px; font-size: 12px; color: var(--muted); } .row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; } .row > * { flex: 0 0 auto; } .row .grow { flex: 1 1 200px; }
.two { display: grid; grid-template-columns: 250px 1fr; gap: 14px; height: 100%; min-height: 0; } .two > * { min-height: 0; overflow: auto; }
table { width: 100%; border-collapse: collapse; } th { text-align: left; font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; padding: 6px 8px; border-bottom: 1px solid var(--border); } td { padding: 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
tr.click { cursor: pointer; } tr.click:hover td { background: var(--panel2); } tr.sel td { background: var(--panel3); } tr.unread td { font-weight: 700; }
.list .li { padding: 10px 12px; border-bottom: 1px solid var(--border); cursor: pointer; display: flex; gap: 8px; align-items: center; } .list .li:hover { background: var(--panel2); } .list .li.sel { background: var(--panel3); border-left: 3px solid var(--accent); }
.li .t { font-weight: 600; } .li .s { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .li .col { flex: 1; min-width: 0; }
.tag { font-size: 10.5px; padding: 1px 7px; border-radius: 4px; border: 1px solid var(--border); color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.tag.P0, .tag.P1 { color: #fff; background: var(--danger); border-color: var(--danger); } .tag.P2 { color: #111; background: var(--warn); border-color: var(--warn); } .tag.crit { color: #fff; background: var(--danger); } .tag.ok { color: var(--success); border-color: var(--success); }
.muted { color: var(--muted); } .mono { font-family: var(--mono); font-size: 12.5px; }
.synthetic-banner { background: var(--warn-bg); border: 1px solid var(--warn); color: var(--warn); border-radius: 8px; padding: 6px 12px; font-size: 12px; margin-bottom: 12px; }

/* chart */
.timeline .entry { border-left: 3px solid var(--border-strong); padding: 6px 12px; margin: 0 0 8px 6px; background: var(--panel2); border-radius: 0 8px 8px 0; }
.timeline .entry.new { animation: flash 2.4s ease-out; border-left-color: var(--accent); } .timeline .entry.result-crit { border-left-color: var(--danger); }
@keyframes flash { 0% { background: rgba(201,162,39,.45); } 100% { background: var(--panel2); } }
.entry .h { display: flex; gap: 8px; align-items: center; font-size: 12px; color: var(--muted); } .entry .kind { color: var(--accent); font-weight: 700; text-transform: uppercase; font-size: 11px; letter-spacing: .6px; }
.vit { display: inline-block; margin: 2px 12px 2px 0; } .vit b { font-size: 16px; } .vit.bad b { color: var(--danger); }
.live { color: var(--success); font-size: 12px; font-weight: 700; } .live.off { color: var(--danger); }

/* IM */
.chat { display: flex; flex-direction: column; height: 100%; min-height: 0; } .msgs { flex: 1; overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 6px; }
.msg { max-width: 72%; background: var(--panel2); border-radius: 12px; padding: 7px 12px; align-self: flex-start; } .msg.me { align-self: flex-end; background: #2b3a22; border: 1px solid var(--accent-dim); }
.msg .who { font-size: 11px; color: var(--muted); } .msg .rc { font-size: 11px; color: var(--muted); text-align: right; } .msg .rc.read { color: var(--accent2); } .msg.important { border-color: var(--warn); }
.compose { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--border); }

/* memo desk: folder rail + table + reading pane (deliberately unlike IM) */
.memo { display: grid; grid-template-columns: 150px 1fr; grid-template-rows: minmax(140px, 40%) 1fr; gap: 0; height: 100%; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--panel); }
.memo .folders { grid-row: 1 / span 2; border-right: 1px solid var(--border); padding: 10px 0; background: var(--panel2); } .memo .folders .fo { padding: 8px 14px; cursor: pointer; display: flex; justify-content: space-between; } .memo .folders .fo.sel { color: var(--accent); background: var(--panel3); }
.memo .table { overflow: auto; border-bottom: 1px solid var(--border); } .memo .read { overflow: auto; padding: 16px 20px; } .memo .read .body { white-space: pre-wrap; font-family: Georgia, "Times New Roman", serif; font-size: 1.05em; line-height: 1.6; margin: 14px 0; }
.memo .hdr { display: grid; grid-template-columns: 70px 1fr; gap: 2px 10px; font-size: 13px; border-bottom: 1px solid var(--border); padding-bottom: 8px; } .memo .hdr .k { color: var(--muted); }
.chip { display: inline-flex; gap: 6px; align-items: center; background: var(--panel3); border: 1px solid var(--border); border-radius: 999px; padding: 2px 10px; margin: 2px 4px 2px 0; font-size: 12.5px; } .chip button { background: none; border: 0; color: var(--muted); cursor: pointer; }

/* alerts */
.acard { border: 2px solid var(--border-strong); border-radius: 10px; padding: 10px 14px; margin-bottom: 10px; background: var(--panel2); display: flex; gap: 12px; align-items: center; } .acard .col { flex: 1; min-width: 0; } .acard .ttl { font-weight: 700; font-size: 1.05em; }
.swatch { width: 44px; height: 44px; border-radius: 8px; border: 2px solid rgba(255,255,255,.25); flex: 0 0 auto; }
.codegrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; } .codebtn { min-height: 64px; border-radius: 10px; border: 2px solid rgba(255,255,255,.3); cursor: pointer; text-align: left; padding: 8px 12px; font-weight: 700; color: #fff; text-shadow: 0 1px 2px #000; position: relative; overflow: hidden; } .codebtn small { display: block; font-weight: 400; font-size: 11px; opacity: .95; } .codebtn:disabled { opacity: .35; filter: grayscale(.8); cursor: default; }
#alertLayer { position: fixed; inset: 0; pointer-events: none; z-index: 8000; } #alertLayer > * { pointer-events: auto; }
.banner-stack { position: fixed; top: calc(var(--top-h) + 8px); right: 12px; width: min(420px, calc(100vw - 24px)); max-height: calc(100vh - var(--top-h) - var(--status-h) - 20px); overflow-y: auto; z-index: 8100; display: flex; flex-direction: column; gap: 8px; pointer-events: none; } .banner-stack > * { pointer-events: auto; } body.offline .banner-stack { top: calc(var(--top-h) + 42px); } body.p0bar .banner-stack { top: calc(var(--top-h) + 52px); }
.abanner { border-radius: 10px; border: 2px solid #fff; padding: 10px 12px; position: relative; flex-wrap: wrap; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.7); box-shadow: 0 8px 30px rgba(0,0,0,.6); display: block; animation: pop .25s ease-out; } .abanner .ttl { font-size: 1.05em; padding-right: 30px; font-weight: 800; } .abanner .abody { display: flex; gap: 10px; align-items: center; } .abanner .btns { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 8px; }
.abanner .btn { color: #111; background: #fff; font-weight: 700; min-height: 38px; padding: 4px 12px; } @keyframes pop { from { transform: scale(.94); opacity: 0; } to { transform: none; opacity: 1; } } .abanner .btn.sm { min-height: 32px; font-size: .85em; }
.toasts { position: fixed; right: 14px; bottom: 40px; z-index: 8200; display: flex; flex-direction: column; gap: 8px; } .toast { background: var(--panel3); border: 1px solid var(--accent); border-radius: 8px; padding: 8px 14px; max-width: 360px; box-shadow: 0 4px 20px rgba(0,0,0,.5); } .toast.err { border-color: var(--danger); }
#takeover { position: fixed; inset: 0; z-index: 9500; background: #000; color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 30px; }
#takeover.flash { animation: strobe 1.1s infinite; } @keyframes strobe { 0%, 100% { background: #000; } 50% { background: #5b0a0a; } } body.reduce-motion #takeover.flash { animation: none; background: #3a0606; }
#takeover .drill { background: var(--warn); color: #111; font-weight: 800; padding: 4px 20px; border-radius: 6px; letter-spacing: 2px; margin-bottom: 14px; } #takeover h1 { font-size: clamp(34px, 7vw, 84px); margin: 6px 0; letter-spacing: 1px; } #takeover .loc { font-size: clamp(22px, 4vw, 44px); font-weight: 700; color: #ffd43b; } #takeover .scr { font-size: clamp(16px, 2.4vw, 26px); max-width: 900px; margin: 16px 0; } #takeover .btns { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; margin-top: 12px; } #takeover .cancelbox { margin-top: 22px; border: 1px dashed #888; border-radius: 10px; padding: 10px 16px; font-size: 14px; max-width: 700px; }
.modal-back { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 9000; display: flex; align-items: center; justify-content: center; padding: 14px; } .modal { background: var(--panel); border: 1px solid var(--border-strong); border-radius: 12px; max-width: 900px; width: 100%; max-height: 92vh; overflow: auto; padding: 18px; }
.holdbtn { position: relative; overflow: hidden; user-select: none; touch-action: none; } .holdbtn .fill { position: absolute; inset: 0 auto 0 0; width: 0; background: rgba(255,255,255,.4); } .holdbtn > span { position: relative; }
.kv { display: grid; grid-template-columns: 160px 1fr; gap: 4px 12px; font-size: 13px; } .kv .k { color: var(--muted); }
.login { max-width: 980px; margin: 28px auto; padding: 0 16px; overflow: auto; height: 100%; } .ucard { border: 1px solid var(--border); background: var(--panel2); border-radius: 10px; padding: 12px; cursor: pointer; min-height: 80px; } .ucard:hover { border-color: var(--accent); } .ucard .n { font-weight: 700; } .ucard .r { color: var(--muted); font-size: 12.5px; }
.pattern-stripes { background-image: repeating-linear-gradient(45deg, rgba(255,255,255,.28) 0 6px, transparent 6px 14px); }

/* responsive web build (tablets / narrow windows): sidebar becomes a rail, panes stack */
@media (max-width: 980px) { #body { grid-template-columns: var(--sidebar-rail-w) 1fr; } #sidebar .lb, #sidebar .grp { display: none; } #sidebar .item { justify-content: center; padding: 9px 0; } #top .hide-narrow { display: none; } }
@media (max-width: 760px) { .two { grid-template-columns: 1fr; } .two > .side { max-height: 30vh; } .memo { grid-template-columns: 1fr; grid-template-rows: auto minmax(120px, 34%) 1fr; } .memo .folders { grid-row: auto; display: flex; border-right: 0; border-bottom: 1px solid var(--border); padding: 0; } .msg { max-width: 92%; } #content { padding: 10px; } .userchip .r { display: none; } }

/* alert dismiss controls: X on every banner, +N chip + tray, P0 minimise bar */
.abanner .aclose { position: absolute; top: 6px; right: 6px; width: 30px; height: 30px; border-radius: 50%; border: 2px solid #fff; background: rgba(0,0,0,.45); color: #fff; font-size: 16px; line-height: 1; cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0; text-shadow: none; } .abanner .aclose:hover, .abanner .aclose:focus-visible { background: #fff; color: #111; outline: none; }
.morechip { background: #111; color: #fff; border: 2px solid #fff; border-radius: 999px; padding: 6px 16px; font-weight: 700; cursor: pointer; align-self: flex-end; box-shadow: 0 4px 18px rgba(0,0,0,.6); } .morechip small { margin-left: 8px; font-weight: 400; opacity: .8; }
.alerttray { background: var(--panel); border: 1px solid var(--border-strong); border-radius: 10px; padding: 10px; box-shadow: 0 8px 30px rgba(0,0,0,.6); } .alerttray .trayitems { display: flex; flex-direction: column; gap: 6px; max-height: 45vh; overflow-y: auto; } .alerttray .abanner { box-shadow: none; animation: none; } .btn.sm { min-height: 30px; padding: 3px 10px; font-size: 12.5px; }
#takeover .minimize { position: absolute; top: 14px; right: 14px; background: rgba(255,255,255,.12); color: #fff; border-color: #fff; font-weight: 700; min-height: 44px; }
#p0bar { position: fixed; top: 0; left: 0; right: 0; z-index: 9400; background: #b00020; color: #fff; display: flex; align-items: center; gap: 14px; padding: 8px 14px; border-bottom: 3px solid #fff; font-weight: 700; } #p0bar.flash { animation: barflash 1.2s infinite; } @keyframes barflash { 50% { background: #5b0a0a; } } body.reduce-motion #p0bar.flash { animation: none; } #p0bar .sub2 { flex: 1; font-weight: 400; font-size: .85em; opacity: .95; } #p0bar .btn { color: #111; background: #fff; min-height: 32px; font-weight: 700; }
body.p0bar #app { padding-top: 46px; height: 100vh; } body.p0bar.offline #offlineBanner { top: 46px; }

/* patient history: chapter rail + compartments */
.histbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 6px 0 10px; padding: 8px; background: var(--panel2); border: 1px solid var(--border); border-radius: 10px; position: sticky; top: -14px; z-index: 5; } .histbar .spacer { flex: 1; } .histbar select, .histbar input[type=date] { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 5px 8px; min-height: 34px; color-scheme: dark; }
.histbar .seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; } .histbar .seg .tb { border: 0; border-radius: 0; border-right: 1px solid var(--border); } .histbar .seg .tb:last-child { border-right: 0; }
.tb { background: var(--panel); border: 1px solid var(--border); color: var(--text); border-radius: 8px; padding: 5px 12px; min-height: 34px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; font-size: 13px; } .tb:hover { border-color: var(--accent); } .tb.on { background: var(--accent); color: #111; border-color: var(--accent); font-weight: 700; } .tb:disabled { opacity: .35; cursor: default; } .tb .ic { font-size: 15px; }
.daynav { display: inline-flex; align-items: center; gap: 6px; }
.hist { display: grid; grid-template-columns: 240px 1fr; gap: 14px; align-items: start; }
.rail { position: sticky; top: 52px; max-height: calc(100vh - 230px); overflow-y: auto; border: 1px solid var(--border); border-radius: 10px; background: var(--panel2); padding: 4px 0 8px; } .rail .railhd { padding: 8px 12px; font-weight: 700; color: var(--accent); border-bottom: 1px solid var(--border); margin-bottom: 4px; } .rail .railhd small { display: block; color: var(--muted); font-weight: 400; font-size: 11px; }
.rail .rl { padding: 6px 12px 6px 14px; cursor: pointer; border-left: 3px solid transparent; } .rail .rl:hover { background: var(--panel3); } .rail .rl.on { background: var(--panel3); border-left-color: var(--accent); } .rail .rl .rt { font-size: 12.5px; } .rail .rl .rs { font-size: 11px; color: var(--muted); }
.rail .rl.stay { margin-top: 8px; border-left-color: var(--border-strong); background: var(--panel3); } .rail .rl.stay .rt { font-weight: 700; } .rail .rl.stay.cur { border-left-color: var(--success); } .rail .rl.chp { margin-left: 10px; border-left: 2px solid var(--border-strong); padding-left: 10px; }
.histmain { min-width: 0; } .stayhd { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; border-bottom: 2px solid var(--border-strong); margin: 4px 0 10px; } .stayhd.cur { border-bottom-color: var(--success); } .stayhd h2 { margin: 0 0 4px; font-size: 16px; } .staysec { margin-bottom: 26px; }
.chap { margin-bottom: 16px; scroll-margin-top: 60px; } .chap.pulse, .staysec.pulse { animation: flash 1.4s ease-out; } .chaphd { display: flex; gap: 10px; align-items: baseline; margin-bottom: 6px; } .chaphd h3 { margin: 0; font-size: 13.5px; color: var(--accent); }
.comp { border: 1px solid var(--border); border-radius: 10px; background: var(--panel); margin: 0 0 10px; padding: 6px 10px 2px; border-top: 3px solid var(--border-strong); } .comp .comphd { font-size: 12px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.comp.cat-lab { border-top-color: #58a6ff; } .comp.cat-blood { border-top-color: #e05c5c; } .comp.cat-imaging { border-top-color: #b392f0; } .comp.cat-vitals { border-top-color: #3fb950; } .comp.cat-meds { border-top-color: #d29922; } .comp.cat-io { border-top-color: #39c5cf; } .comp.cat-notes { border-top-color: #8b9aab; } .comp.cat-stay { border-top-color: var(--accent); }
.labtbl { border-collapse: collapse; margin: 4px 0 2px; font-size: 13px; } .labtbl td { padding: 1px 16px 1px 0; } .labtbl .u { color: var(--muted); font-size: 11.5px; margin-right: 6px; } .labtbl tr.abn b { color: var(--danger); } .labtbl .flag { font-size: 11px; font-weight: 700; color: var(--danger); }
@media (max-width: 900px) { .hist { grid-template-columns: 1fr; } .rail { position: static; max-height: 180px; } }
/* sign-in */
.loginbox { max-width: 440px; margin: 7vh auto 0; padding: 0 16px; } .loginbox .panel { padding: 22px; } .loginbox label.f { display: block; margin: 12px 0 4px; } .loginbox input { width: 100%; } .pwrow { display: flex; gap: 6px; } .pwrow input { flex: 1; } .loginerr { margin-top: 12px; padding: 8px 12px; border: 1px solid var(--danger); background: var(--danger-bg); color: var(--danger); border-radius: 8px; font-size: 13px; }
.histbar select, .histbar input[type=date] { width: auto; }

/* ---- wave 1: capability runtime, auth stages, lock screen, registration/admin/privacy views ---- */
:root { --accent-on: #111; --accent-hover: #dbb12e; }
.btn.primary { color: var(--accent-on); } .btn.primary:hover { background: var(--accent-hover); color: var(--accent-on); }
.brandlogo { height: 22px; width: auto; max-width: 120px; vertical-align: middle; margin-right: 8px; border-radius: 4px; } .loginbox .logo { max-height: 56px; max-width: 200px; margin-bottom: 8px; }
.qr { background: #fff; padding: 6px; border-radius: 8px; line-height: 0; } .qr svg { width: 160px; height: 160px; }
#lockLayer { position: fixed; inset: 0; z-index: 7900; background: rgba(6,9,13,.94); display: flex; align-items: center; justify-content: center; padding: 16px; } .lockbox { width: min(420px, 100%); }
body.locked #app { filter: blur(6px); pointer-events: none; }
.secret { display: flex; justify-content: space-between; gap: 12px; padding: 6px 10px; margin: 4px 0; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; } .secret code { user-select: all; color: var(--accent); }
.tabbar { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 12px; flex-wrap: wrap; } .tab { background: transparent; border: 0; border-bottom: 3px solid transparent; color: var(--muted); padding: 8px 14px; cursor: pointer; min-height: 40px; } .tab:hover { color: var(--text); } .tab.on { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.tablewrap { overflow-x: auto; } .tablewrap table td { vertical-align: top; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 0 14px; } .fld { min-width: 0; } .hint { font-size: 11.5px; margin-top: 2px; }
.chip { display: inline-block; font-size: 11px; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--border); background: var(--panel2); color: var(--muted); margin-right: 4px; } .chip.ok { color: var(--success); border-color: var(--success); } .chip.warn { color: var(--warn); border-color: var(--warn); } .chip.bad { color: var(--danger); border-color: var(--danger); } .chip.vip { color: #fff; background: #6b21a8; border-color: #6b21a8; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; } .toolbar .grow { flex: 1; min-width: 160px; }
.termpick { position: relative; } .termres { position: absolute; z-index: 50; left: 0; right: 0; top: 100%; background: var(--panel); border: 1px solid var(--border-strong); border-radius: 8px; max-height: 240px; overflow: auto; box-shadow: 0 8px 24px rgba(0,0,0,.4); } .termres:empty { display: none; }
.termitem { display: flex; gap: 10px; padding: 7px 10px; cursor: pointer; border-bottom: 1px solid var(--border); } .termitem:hover, .termitem:focus { background: var(--panel2); outline: none; } .termitem.none { cursor: default; color: var(--muted); font-size: 12.5px; } .termitem .code { color: var(--accent); min-width: 70px; }
.lists { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; } .lists .panel { margin: 0; background: var(--panel2); }
.listrow { display: flex; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--border); align-items: flex-start; } .listrow:last-child { border-bottom: 0; } .listrow .col { flex: 1; min-width: 0; } .listrow .s { color: var(--muted); font-size: 12px; }
.uncoded { color: var(--warn); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; }
.vipbar { background: #3b0764; border: 1px solid #6b21a8; color: #f3e8ff; border-radius: 8px; padding: 8px 12px; margin-bottom: 10px; }
.wristband { background: #fff; color: #000; border: 2px solid #000; border-radius: 12px; width: 420px; max-width: 100%; padding: 12px 16px; font-family: Arial, sans-serif; } .wristband .nm { font-size: 20px; font-weight: 800; } .wristband .bar { font-family: 'Libre Barcode 39', monospace; letter-spacing: 3px; font-size: 26px; margin-top: 6px; border-top: 1px dashed #000; padding-top: 4px; }
.mfa-tile { display: flex; gap: 10px; align-items: center; }
.preview-note { font-size: 11px; color: var(--accent2); }
@media print { body * { visibility: hidden; } .wristband, .wristband * { visibility: visible; } .wristband { position: fixed; left: 0; top: 0; } }
@media (max-width: 760px) { .grid2 { grid-template-columns: 1fr; } }
.toasts { pointer-events: none; }

/* ---- Wave 2: circuit status + permission matrix ---- */
.cdot { font-weight: 600; white-space: nowrap; } .cdot.ok { color: #3fb950; } .cdot.fail { color: #ff6b6b; } .cdot.off, .cdot.unknown { color: var(--muted, #8b98a8); }
table.matrix { font-size: 12px; border-collapse: collapse; } table.matrix th.vh { height: 130px; vertical-align: bottom; padding: 2px 3px; } table.matrix th.vh span { display: inline-block; writing-mode: vertical-rl; transform: rotate(180deg); white-space: nowrap; font-weight: 600; }
table.matrix td.mx { text-align: center; width: 28px; padding: 2px 3px; } table.matrix td.mx.yes { background: rgba(63,185,80,.22); color: #3fb950; font-weight: 700; } table.matrix td.mx.no { color: var(--muted, #667); }
table.matrix td:first-child { min-width: 260px; max-width: 360px; }

/* Wave 2 piece screens (lab, imaging, forms, notes, vitals, orders, inbox) */
.piece-panel > summary { cursor: pointer; padding: 4px 0; } .piece-panel[open] > summary { margin-bottom: 8px; }
.spark { vertical-align: middle; } .trends { display: flex; flex-wrap: wrap; gap: 12px; margin: 6px 0 10px; } .trendbox { min-width: 270px; } .trendbox svg { display: block; background: var(--panel); border-radius: 6px; }
table.scale th, table.scale td { padding: 6px 8px; } tr.struck td { text-decoration: line-through; color: var(--muted); } .flag-C { color: var(--danger); font-weight: 700; } .flag-H, .flag-L { color: var(--warn, #d29922); font-weight: 600; }
.formfill .fld { margin: 8px 0; } .formfill textarea, .formfill input[type=text], .formfill input[type=number], .formfill input[type=date] { width: 100%; max-width: 640px; } .formsec { border-top: 1px solid var(--line, #30363d); padding: 6px 0; } .formsec.staff { background: rgba(255,255,255,.03); }
.sigpad { border: 2px dashed var(--muted); border-radius: 6px; background: #fff; max-width: 100%; height: auto; cursor: crosshair; } .sigimg { background: #fff; border: 1px solid var(--muted); border-radius: 4px; padding: 2px; } .typedsig { font-family: 'Segoe Script', 'Brush Script MT', cursive; font-size: 24px; }
.printdoc { background: var(--panel2); padding: 12px; border-radius: 8px; } .sigline { margin: 8px 0; } .impression { font-size: 15px; }
.kv .k { color: var(--muted); }
@media print { .noprint, .rail, nav, header, .toasts { display: none !important; } .modal { max-width: none !important; box-shadow: none; } body { background: #fff; color: #000; } }

/* D20 (Wave 2): glove-friendly 48 px touch targets on touch screens (REQ-4901); the 36 px desktop size is unchanged. */
@media (pointer: coarse) { .btn, .tab, #sidebar .item, .iconbtn { min-height: 48px; } input[type=text], input[type=number], input[type=date], input[type=password], select { min-height: 44px; } }

/* ---- Wave 6: Menu tab, Patients attachment, pinned tabs, always-visible strip, protocol indicator (D-087) */
:root { --top-h: 52px; }
.menutab, .attachtab, .pintab, .avbtn { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--panel2); color: var(--text); cursor: pointer; font: inherit; font-size: 13px; white-space: nowrap; position: relative; }
.menutab { border-color: var(--accent); color: var(--accent); font-weight: 700; } .menutab:hover, .attachtab:hover, .pintab:hover, .avbtn:hover { background: var(--panel3); }
.menutab[aria-expanded="true"] { background: var(--accent); color: var(--accent-on); }
.attachtab.on, .pintab.on { border-color: var(--accent); color: var(--accent); }
.pintab { background: transparent; height: 30px; padding: 0 9px; font-size: 12.5px; }
.avbtn .badge { position: static; margin-left: 2px; } .avbtn.warn { border-color: var(--danger, #d9534f); color: var(--danger, #d9534f); }
.avbtn.proto { color: var(--muted); } .avbtn.proto.live { border-color: var(--accent); color: var(--accent); font-weight: 600; max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 1100px) { .pintab .ml, .avbtn .ml, .attachtab .ml { display: none; } .menutab .ml { display: inline; } .avbtn.proto.live .ml { display: inline; max-width: 110px; overflow: hidden; text-overflow: ellipsis; } }
#sidebar .menuhead { padding: 8px 12px 2px; } #sidebar .menuhead input { width: 100%; box-sizing: border-box; }
#sidebar .pinbtn { background: none; border: 0; color: var(--faint); cursor: pointer; font-size: 15px; padding: 2px 6px; border-radius: 6px; } #sidebar .pinbtn:hover { color: var(--accent); background: var(--panel3); } #sidebar .pinbtn.on { color: var(--accent); }
#sidebar .item.pinnedrow { border-left-color: var(--accent-dim, var(--accent)); }
/* menu_tab: no permanent sidebar; the list is a panel under the Menu tab */
body.nav-menu_tab #body, body.nav-menu_tab.rail #body { grid-template-columns: 1fr; }
body.nav-menu_tab #sidebar, body.nav-combo.menu-open #sidebar { position: fixed; top: var(--top-h); left: 0; bottom: 30px; width: 340px; max-width: 92vw; z-index: 60; box-shadow: 6px 0 24px rgba(0,0,0,.45); border-right: 1px solid var(--border-strong, var(--border)); }
body.nav-menu_tab:not(.menu-open) #sidebar { display: none; }
body.nav-menu_tab #sidebar .lb, body.nav-menu_tab #sidebar .grp, body.nav-combo.menu-open #sidebar .lb, body.nav-combo.menu-open #sidebar .grp { display: inline; } body.nav-menu_tab #sidebar .grp, body.nav-combo.menu-open #sidebar .grp { display: block; }
body.nav-menu_tab #sidebar .item, body.nav-combo.menu-open #sidebar .item { justify-content: flex-start; padding: 9px 16px; }
body.nav-menu_tab #sidebar .badge, body.nav-combo.menu-open #sidebar .badge { position: static; margin: 0 6px 0 0; }
/* combo: a slim icon rail stays, the Menu tab opens the labelled list over it */
body.nav-combo #body { grid-template-columns: var(--sidebar-rail-w) 1fr; } body.nav-combo:not(.menu-open) #sidebar .lb, body.nav-combo:not(.menu-open) #sidebar .grp, body.nav-combo:not(.menu-open) #sidebar .pinbtn, body.nav-combo:not(.menu-open) #sidebar .menuhead { display: none; } body.nav-combo:not(.menu-open) #sidebar .item { justify-content: center; padding: 9px 0; }
/* Wave 6: access basis on charts and roster rows */
.basischip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); border-radius: 999px; padding: 2px 10px; font-size: 12px; background: var(--panel2); cursor: pointer; }
.basischip.out { border-color: var(--danger, #d9534f); color: var(--danger, #d9534f); }
.redframe { outline: 3px solid var(--danger, #d9534f); outline-offset: -3px; border-radius: 10px; }
.accessnotice { border: 1px solid var(--danger, #d9534f); background: rgba(217, 83, 79, .08); border-radius: 10px; padding: 10px 12px; margin: 8px 0; }
.accessnotice.mild { border-color: var(--warn, #d9a441); background: rgba(217, 164, 65, .08); }
.rrow.out { box-shadow: inset 4px 0 0 var(--danger, #d9534f); }
.chip.rel { border-color: var(--accent); }
/* Phone: the top bar wraps onto a second row so the always-visible strip (Alerts, Break-glass, Downtime, protocol) never leaves the screen */
@media (max-width: 760px) {
  #app { grid-template-rows: auto 1fr var(--status-h); }
  #top { flex-wrap: wrap; row-gap: 4px; padding: 4px 8px; height: auto; min-height: var(--top-h); }
  #top .spacer { flex-basis: 100%; height: 0; order: 5; }
  #top .pill.demo { display: none; } #top .userchip .r { display: none; }
  #top .avbtn, #top .menutab, #top .attachtab, #top .pintab { height: 36px; }
  #status { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
  body.nav-menu_tab #sidebar, body.nav-combo.menu-open #sidebar { top: var(--top-real, var(--top-h)); }
}
