/*
  Prewarming study app. NUHS design system, app theme (Kent Ridge Clinical "kr-app"): grey ground, white rounded
  cards with hairlines, navy as the only accent, a white app bar with the four-quarter band (orange / red / stripe
  blue / navy), Open Sans (index.html), 44px tap targets. Light only, phone first (360 px). Tokens from
  ../design/tokens.css (--n-*); app tokens below.
  The patient main screen is compact: everything for one timepoint fits a 390 x 844 phone without scrolling.
*/
:root {
  --bg: #f3f3f3; --card: #fff; --ink: var(--n-ink); --muted: #646b73; --line: var(--n-line); --line-input: var(--n-line-input);
  --navy: var(--n-navy); --soft: #e0ebf7; --chip: #e8f4fb; --key: #fff;
  --ok: #1a7f37; --ok-soft: #e3f4e8;
  --warn: #8a5a00; --warn-soft: #fff5d6;
  --err: #b42318; --err-soft: #fdecea;
  --info-soft: #e3f2fb;
  --r: 10px; --r-card: 14px; --r-full: 999px;
  --tap: 44px; --band: 5px;
  --font: var(--n-font);
  --num: var(--n-font);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
/* interface size (Settings, this phone): scales everything */
body { zoom: var(--ui-zoom, 1); }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 15px/1.45 var(--font); -webkit-tap-highlight-color: transparent;
  padding-left: env(safe-area-inset-left, 0px); padding-right: env(safe-area-inset-right, 0px); }
button, input, select, textarea { font: inherit; color: inherit; }

/* app bar: white, with the four-quarter band along its top */
.bar { position: sticky; top: 0; z-index: 5; color: var(--navy); border-bottom: 1px solid var(--line);
  padding-top: max(var(--band), calc(env(safe-area-inset-top, 0px) + var(--band)));
  background: linear-gradient(90deg, var(--n-orange) 0 25%, var(--n-red) 25% 50%, var(--n-stripe-blue, #178fd7) 50% 75%, var(--navy) 75% 100%) top / 100% var(--band) no-repeat, var(--card); }
.bar .row { display: flex; align-items: center; gap: 2px; min-height: 50px; padding: 0 4px 0 12px; max-width: 600px; margin: 0 auto; }
.bar #back:not([hidden]) + h1 { margin-left: -4px; }
.bar .row:has(#back:not([hidden])) { padding-left: 2px; }
.bar h1 { flex: 0 1 auto; margin: 0; font-size: 17px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* running timer and next event (patient screen) */
#extra { display: flex; align-items: center; gap: 2px; min-width: 0; }
.clock { display: flex; align-items: center; gap: 8px; flex: 1 0 auto; margin-left: 8px; color: var(--navy); }
/* the next thing to log sits in the middle of the bar, between the title and the time now */
.clock .next { margin: 0 auto; justify-items: center; text-align: center; }
/* nothing due yet (no Prewarm on / Induction): the time now still sits on the right, by the Log button */
.clock .now:first-child { margin-left: auto; }
.clock > div { display: grid; justify-items: end; line-height: 1.15; text-align: right; min-width: 0; }
.clock small { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.clock b { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.clock .next b { font-size: 15px; }
.clock .next[data-state="soon"], .clock .next[data-state="now"], .clock .next[data-state="late"] { padding: 1px 8px; border-radius: var(--r); }
.clock .next[data-state] small { color: inherit; }
.clock .next[data-state="soon"] { background: var(--warn-soft); color: var(--warn); animation: duepulse 2s ease-in-out infinite; --pulse: rgba(138, 90, 0, .35); }
.clock .next[data-state="now"] { background: #fde3d3; color: #9a3412; animation: duepulse 1.2s ease-in-out infinite; --pulse: rgba(229, 114, 0, .55); }
.clock .next[data-state="late"] { background: var(--err); color: #fff; animation: duepulse .7s ease-in-out infinite; --pulse: rgba(180, 35, 24, .6); }
.bar #extra { flex: 1 1 auto; justify-content: flex-end; }
.logbtn { display: grid; justify-items: center; align-content: center; min-width: 60px; max-width: 84px; min-height: var(--tap); margin-left: 6px; padding: 2px 6px; border: 0; border-radius: var(--r); background: var(--navy); color: #fff; line-height: 1.1; cursor: pointer; touch-action: manipulation; }
.logbtn b { font-size: 15px; }
.logbtn small { font-size: 11px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.logbtn:active { background: var(--n-navy-hover); }
.iconbtn { background: none; border: 0; color: inherit; font-size: 1.5rem; line-height: 1; min-width: var(--tap); min-height: var(--tap); display: inline-flex; align-items: center; justify-content: center; text-decoration: none; cursor: pointer; border-radius: var(--r); }

main { max-width: 600px; margin: 0 auto; padding: 8px 12px calc(28px + env(safe-area-inset-bottom, 0px)); display: grid; gap: 6px; }
h2 { font-size: 16px; font-weight: 700; color: var(--navy); margin: 8px 0 0; }
a { color: var(--navy); }
:focus-visible { outline: 3px solid var(--n-focus); outline-offset: 2px; }
.muted { color: var(--muted); } .small { font-size: 13px; }
.tight { margin: -4px 0 0; }
.note a { color: var(--warn); font-weight: 600; }
.note { background: var(--warn-soft); color: var(--warn); border-radius: var(--r); padding: 8px 12px; margin: 0; }
.ok-box { background: var(--ok-soft); color: var(--ok); border-radius: var(--r); padding: 10px 12px; margin: 0; font-weight: 600; }
.stack { display: grid; gap: 10px; }

/* buttons */
.big { min-height: 48px; font-size: 16px; width: 100%; }
.primary, .secondary, .save, .danger { display: flex; align-items: center; justify-content: center; gap: 6px; border-radius: var(--r); border: 1px solid transparent; padding: 8px 14px; min-height: var(--tap); font-weight: 600; text-decoration: none; cursor: pointer; text-align: center; touch-action: manipulation; }
.primary, .save { background: var(--navy); border-color: var(--navy); color: #fff; }
.primary:hover, .save:hover { background: var(--n-navy-hover); border-color: var(--n-navy-hover); }
.primary:disabled { background: var(--n-disabled-bg); border-color: var(--n-disabled-bg); color: var(--n-disabled-ink); }
.secondary { background: var(--card); color: var(--ink); border-color: var(--line); font-weight: 400; }
.secondary:hover { border-color: var(--navy); }
.danger { background: var(--card); color: var(--err); border-color: var(--line); font-weight: 400; margin-top: 12px; }
.danger:hover { border-color: var(--err); }
.link { background: none; border: 0; color: var(--navy); text-decoration: underline; padding: 4px; cursor: pointer; font-size: inherit; }
.textlinks { display: flex; gap: 16px; margin: 0; padding: 0 4px; }
.textlinks { align-items: center; }
.textlinks a { font-weight: 600; padding: 10px 0; }
/* "Other data": a smaller box beside Form view and Sheet view */
.textlinks a.minicard { display: grid; padding: 6px 10px; border: 1px solid var(--line); border-radius: var(--r); background: var(--card); text-decoration: none; color: var(--navy); line-height: 1.2; }
.textlinks a.minicard small { font-weight: 400; font-size: 11px; color: var(--muted); }
.links.one { grid-template-columns: 1fr; }
.links.two { grid-template-columns: 1fr 1fr; margin-top: 12px; }
.links.three { margin-top: 6px; }
/* Perioperative data: the full width under Intra-op details and PACU */
a.widebox { display: grid; align-content: center; min-height: 52px; margin-top: 6px; padding: 6px 12px; background: var(--card); border: 1px solid var(--line); border-radius: var(--r-card); color: var(--navy); font-weight: 600; text-decoration: none; }
details.sect { margin-top: 12px; }
details.sect > summary { display: flex; align-items: baseline; gap: 8px; min-height: var(--tap); padding: 6px 2px; cursor: pointer; font-size: 16px; font-weight: 700; color: var(--navy); }
details.sect > summary small { font-size: 12px; font-weight: 400; color: var(--muted); }
details.sect > summary::-webkit-details-marker { display: none; }
details.sect > summary::before { content: '▸'; display: inline-block; width: 14px; transition: transform .15s; }
details.sect[open] > summary::before { transform: rotate(90deg); }
/* on a computer, label beside its box so more questions fit on the screen */
@media (min-width: 700px) {
  details.sect .fld { grid-template-columns: 220px 1fr; align-items: center; column-gap: 12px; padding: 6px 12px; }
  details.sect .fld > .lab, details.sect .fld > small { grid-column: 1; }
  details.sect .fld > input, details.sect .fld > .seg { grid-column: 2; grid-row: 1 / span 2; }
  details.sect > .stack { gap: 6px; }
}
details.sect > .stack { margin-top: 4px; }
.fld:focus-within { border-color: var(--navy); box-shadow: 0 0 0 1px var(--navy); }
/* the BP, HR, BIS box warms up like the due time */
.links a[data-state="soon"] { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); animation: duepulse 2s ease-in-out infinite; --pulse: rgba(138, 90, 0, .35); }
.links a[data-state="now"] { background: #fde3d3; border-color: #9a3412; color: #9a3412; animation: duepulse 1.2s ease-in-out infinite; --pulse: rgba(229, 114, 0, .55); }
.links a[data-state="late"] { background: var(--err); border-color: var(--err); color: #fff; animation: duepulse .7s ease-in-out infinite; --pulse: rgba(180, 35, 24, .6); }
.links a[data-state="soon"] small, .links a[data-state="now"] small { color: inherit; }
.links a[data-state="late"] small { color: #fff; }
@media (prefers-reduced-motion: reduce) { .links a[data-state] { animation: none; } }

/* home list */
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.list a { display: grid; gap: 2px; background: var(--card); border: 1px solid var(--line); border-radius: var(--r-card); padding: 12px 14px; text-decoration: none; color: var(--ink); }
.list b { font-size: 16px; font-weight: 700; color: var(--navy); }
.list b small { font-size: 13px; color: var(--muted); font-weight: 400; }
.list span { font-weight: 600; }
.list small { color: var(--muted); }

.dellist li { display: flex; align-items: center; justify-content: space-between; gap: 8px; background: var(--card); border: 1px solid var(--line); border-radius: var(--r-card); padding: 8px 8px 8px 14px; }
.dellist li div { display: grid; min-width: 0; }
.dellist .danger { margin: 0; flex: none; min-width: 96px; }
/* event times: compact grid of chips */
.times { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 4px; }
.tchip { position: relative; display: grid; align-content: center; justify-items: center; gap: 1px; text-align: center; padding: 11px 2px 2px; min-height: 52px; min-width: 0; border-radius: var(--r); border: 1px dashed #9aa1a9; background: var(--card); color: var(--muted); cursor: pointer; line-height: 1.1; }
.tchip .tn { position: absolute; top: 2px; left: 5px; font-size: 10px; font-style: normal; font-weight: 700; line-height: 1; }
.tchip span { font-size: 11px; max-width: 100%; overflow-wrap: anywhere; hyphens: manual; }
.tchip b { font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--muted); }
.tchip.set { border: 1px solid transparent; background: var(--chip); }
.tchip.set span { color: var(--navy); } .tchip.set b { color: var(--ink); }
/* gown and Bair Hugger times: light grey until tapped (labels 5.9:1), lavender once set (labels 8:1); amber, orange and red are kept for timing alarms only */
.tchip.warm { background: #e6e6e6; }
.tchip.warm span, .tchip.warm b { color: #50565c; }
.tchip.warm.set { background: #ebe5f7; border-color: transparent; }
.tchip.warm.set span { color: #4f2f86; } .tchip.warm.set b { color: var(--ink); }
.tchip.warm.edit:not(.set) { background: var(--card); }
.tchip.edit { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; border: 1px solid var(--navy); color: var(--ink); }
.tchip.edit input { width: auto; flex: 1; padding: 4px 6px; }

/* Pre-warming / Intra-op switch: navy underline tabs */
.tabs2 { display: grid; grid-template-columns: 1fr 1fr; border-bottom: 1px solid var(--line); }
.tabs2 a { display: flex; align-items: center; justify-content: center; min-height: 40px; padding: 4px 8px; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs2 a[aria-selected="true"] { border-bottom-color: var(--navy); color: var(--ink); font-weight: 600; }
.sect { margin: 0; }

/* previous / next timepoint either side of the tabs and strip */
.nav2 { display: grid; grid-template-columns: 48px minmax(0, 1fr) 48px; gap: 4px; align-items: stretch; }
.nav2 .mid { display: grid; gap: 4px; min-width: 0; align-content: end; }
.pn { display: flex; align-items: center; justify-content: center; min-height: var(--tap); border-radius: var(--r); border: 1px solid var(--line); background: var(--card); color: var(--navy); font-size: 2rem; font-weight: 600; line-height: 1; text-decoration: none; touch-action: manipulation; }
.pn:active { background: var(--soft); }
span.pn { color: var(--line); }
/* timepoint strip */
.strip { position: relative; display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.strip a { flex: none; min-width: 42px; min-height: 36px; display: flex; align-items: center; justify-content: center; border-radius: var(--r); border: 1px solid var(--line); background: var(--card); text-decoration: none; color: var(--muted); font-weight: 600; font-size: 13px; font-variant-numeric: tabular-nums; }
.strip a.done { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.strip a.missed { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.strip a.on { background: var(--navy); color: #fff; border-color: var(--navy); }
.tp { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; margin: -4px 0 -2px; }
.tp b { font-size: 18px; font-weight: 700; color: var(--navy); }
.due { font-size: 14px; font-weight: 600; color: var(--navy); font-variant-numeric: tabular-nums; }
/* due time: warms up as it nears the clock, pulses more once it passes (no movement with reduced motion) */
.due[data-state="soon"], .due[data-state="now"], .due[data-state="late"] { padding: 2px 10px; border-radius: var(--r-full); }
.due[data-state="soon"] { background: var(--warn-soft); color: var(--warn); animation: duepulse 2s ease-in-out infinite; --pulse: rgba(138, 90, 0, .35); }
.due[data-state="now"] { background: #fde3d3; color: #9a3412; animation: duepulse 1.2s ease-in-out infinite; --pulse: rgba(229, 114, 0, .55); }
.due[data-state="late"] { background: var(--err); color: #fff; animation: duepulse .7s ease-in-out infinite; --pulse: rgba(180, 35, 24, .6); }
@keyframes duepulse { 0%, 100% { box-shadow: 0 0 0 0 var(--pulse); } 50% { box-shadow: 0 0 0 6px transparent; } }
@media (prefers-reduced-motion: reduce) { .due[data-state], .clock .next[data-state] { animation: none; } }
.due .hint { font-size: 12px; font-weight: 400; color: var(--warn); }
.badge { font-size: 12px; background: var(--chip); color: var(--navy); border-radius: var(--r-full); padding: 2px 8px; vertical-align: middle; font-weight: 600; }

/* reading cards: label, then − value + on one row */
.board { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }
.card { min-width: 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--r-card); padding: 3px 5px 5px; display: grid; gap: 1px; }
.card.changed { border-color: var(--navy); box-shadow: inset 0 0 0 1px var(--navy); }
.card.fill { cursor: pointer; }
.card.wide { grid-column: 1 / -1; }
/* a row of chips with its label on the left */
.card.inline { grid-template-columns: 74px minmax(0, 1fr); align-items: center; gap: 4px; }
.card.inline .clab { display: block; line-height: 1.2; padding: 0 0 0 4px; }
.card.inline .clab small { display: block; }
.clab { font-weight: 600; display: flex; justify-content: space-between; gap: 4px; font-size: 13px; color: var(--navy); padding: 0 4px; }
.clab small { font-weight: 400; color: var(--muted); font-size: 12px; }
.pm { display: grid; grid-template-columns: var(--tap) minmax(0, 1fr) var(--tap); gap: 4px; align-items: center; }
.num { font: 600 1.6rem/1.1 var(--num); font-variant-numeric: tabular-nums; text-align: center; background: none; border: 0; color: var(--ink); width: 100%; min-width: 0; min-height: var(--tap); padding: 0; cursor: text; }
.num .muted { font-size: 1rem; font-weight: 400; }
.pm .num { white-space: nowrap; overflow: hidden; }
input.num { border: 2px solid var(--navy); border-radius: var(--r); background: var(--card); }
.card.typed input.num { border: 1px solid var(--line-input); }
.card.typed input.num:focus { border: 2px solid var(--navy); }
.k, .chip { min-height: var(--tap); border-radius: var(--r); border: 1px solid var(--line); background: var(--key); color: var(--navy); font-size: 1.4rem; font-weight: 600; cursor: pointer; touch-action: manipulation; -webkit-user-select: none; user-select: none; }
.k:active, .chip:active { background: var(--soft); }
.chip { font-size: 15px; padding: 4px 8px; background: var(--chip); color: var(--ink); font-weight: 400; }
.chip[aria-pressed="true"] { background: var(--navy); color: #fff; border-color: var(--navy); font-weight: 600; }
.chip:disabled { opacity: .6; cursor: default; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg .chip { flex: 1 1 auto; }
.seg.seven { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.seg.seven .chip { padding: 0; font-size: 14px; }
.seg.two { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.seg.col { flex-direction: column; }
.seg.many .chip { flex: 0 0 calc(16.66% - 5px); }

/* patient comfort */
.comfort { min-width: 0; display: grid; gap: 4px; background: var(--card); border: 1px solid var(--line); border-radius: var(--r-card); padding: 6px; }
.comfort .lab { color: var(--navy); font-size: 13px; padding: 0 4px; }
.comfort .lab small { margin-left: 6px; }
.comfort.done { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 0 6px 0 10px; font-size: 13px; }
.comfort5 { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; }
.comfort5 .chip { font-size: 11px; line-height: 1.15; padding: 2px; min-width: 0; hyphens: manual; }

/* forms */
.fld { display: grid; gap: 6px; background: var(--card); border: 1px solid var(--line); border-radius: var(--r-card); padding: 10px 12px; }
.lab { font-weight: 600; }
.lab small { color: var(--muted); font-weight: 400; }
input { font-size: 16px; padding: 8px 10px; min-height: var(--tap); border: 1px solid var(--line); border-radius: var(--r); background: #fff; color: var(--ink); width: 100%; min-width: 0; }
input:focus { border-color: var(--navy); }
.grid { border-collapse: collapse; width: 100%; background: var(--card); font-variant-numeric: tabular-nums; }
.grid th, .grid td { border: 1px solid var(--line); padding: 4px; text-align: center; }
.grid thead th { background: var(--navy); color: #fff; font-weight: 600; font-size: 12px; }
.grid tbody th { font-size: 13px; color: var(--navy); font-weight: 600; }
.grid td input { padding: 6px; }
.scroll { overflow-x: auto; }
.sheet td a { display: block; min-width: 40px; min-height: 30px; color: var(--ink); text-decoration: none; font-size: 13px; }
.sheet tbody th:first-child { position: sticky; left: 0; background: var(--card); text-align: left; }
.ixrow { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; background: var(--card); border: 1px solid var(--line); border-radius: var(--r-card); padding: 8px; }
.ixrow label { display: grid; gap: 2px; font-size: 12px; color: var(--muted); }
.ixrow .link { grid-column: 1 / -1; justify-self: end; }
/* last on the screen, apart from Save, so it isn't tapped by accident */
.okline { color: var(--ok); }
/* home list: a reading due on a patient being charted */
.dueline { display: block; justify-self: start; width: fit-content; margin: 2px 0; padding: 1px 8px; border-radius: var(--r); font-weight: 700; }
.dueline[data-state="soon"] { background: var(--warn-soft); color: var(--warn); }
.dueline[data-state="now"] { background: #fde3d3; color: #9a3412; }
.dueline[data-state="late"] { background: var(--err); color: #fff; }
.lockline { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-weight: 600; }
.ico { width: 1.1em; height: 1.1em; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -0.15em; }
/* a locked patient opened by an admin: read only */
body.ro main::before { content: "Locked: read only. Unlock it on the home page to change it."; display: block; padding: 8px 12px; border-radius: var(--r); background: var(--warn-soft); color: var(--warn); font-weight: 600; }
body.ro #save, body.ro [data-done], body.ro [data-undone], body.ro [data-sign], body.ro [data-unsign], body.ro #addix, body.ro [data-rmix] { display: none !important; }
body.ro main .k, body.ro main .num, body.ro main .chip, body.ro main .tchip, body.ro main input, body.ro main select, body.ro main textarea, body.ro main [data-use], body.ro main [data-map] { pointer-events: none; opacity: .65; }
.list a.locked { background: var(--bg); border-style: dashed; color: var(--muted); }
.listhead { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.listhead .link { font-size: 14px; }
.seltools { position: sticky; top: calc(56px + env(safe-area-inset-top, 0px)); z-index: 4; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 8px; background: var(--card); border: 1px solid var(--navy); border-radius: var(--r-card); }
.seltools span { flex: 1 1 100%; font-weight: 600; color: var(--navy); }
.seltools .primary, .seltools .secondary { flex: 1 1 auto; }
.selrow { display: flex; gap: 12px; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: var(--r-card); padding: 12px 14px; cursor: pointer; }
.selrow input { width: 22px; height: 22px; min-height: 0; padding: 0; flex: none; accent-color: var(--navy); }
.selrow > span { display: grid; gap: 2px; min-width: 0; }
.selrow b { font-size: 16px; color: var(--navy); }
.selrow small { color: var(--muted); }
.syncline { font-weight: 600; }
.syncline.late { color: var(--warn); }
.list a.warned { border-color: var(--warn); background: var(--warn-soft); }
.warnline { font-style: normal; font-weight: 600; color: var(--warn); }
.donetop { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 8px; padding: 8px 12px; }
.donetop small { font-weight: 400; }
.sign { color: var(--ok); font-weight: 600; font-size: 13px; text-align: center; margin-top: 24px; padding-top: 12px; border-top: 1px solid var(--line); }
.sign .link { font-weight: 400; }
.sign + .sign { margin-top: 8px; }
/* sign-offs: an empty box to tick, then a ticked box with who and when */
.tickbtn { display: inline-flex; align-items: center; gap: 10px; min-height: var(--tap); padding: 4px 12px; border: 0; background: none; color: var(--navy); font: inherit; font-size: 15px; font-weight: 600; cursor: pointer; }
.sign .tick { display: inline-grid; place-items: center; flex: 0 0 auto; width: 26px; height: 26px; border: 2px solid var(--navy); border-radius: 6px; background: var(--card); color: #fff; font-size: 18px; line-height: 1; }
.sign.on { display: flex; align-items: center; justify-content: center; gap: 10px; text-align: left; }
.sign.on .tick { background: var(--ok); border-color: var(--ok); }
.sign.on b { display: block; font-size: 15px; }
.sign.on small { display: block; font-weight: 400; color: var(--muted); }
/* no pull-to-refresh: a pull while scrolling up shouldn't reload mid-case */
html, body { overscroll-behavior-y: none; }
/* the two tabs under the bar: temperatures, BP / HR / BIS */
.ptabs:not([hidden]) { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; max-width: 600px; margin: 0 auto; padding: 0 12px 5px; }
/* on the patient screens the tab bar sits under the key times (owner, 12 Oct 2026) */
main .ptabs:not([hidden]) { width: 100%; max-width: none; padding: 0; margin: 2px 0 0; }
main .ptabs a { min-height: 34px; font-size: 15px; }
.note.nopw { margin-top: 4px; background: var(--card); border: 1px solid var(--line); color: var(--ink); }
.ptabs a { display: grid; place-items: center; min-height: 32px; border-radius: var(--r); border: 1px solid var(--line); color: var(--navy); font-size: 14px; font-weight: 600; text-decoration: none; background: var(--card); }
.ptabs a[aria-selected="true"] { background: var(--navy); border-color: var(--navy); color: #fff; }
.ptabs a[aria-selected="false"][data-state="soon"] { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); animation: duepulse 2s ease-in-out infinite; --pulse: rgba(138, 90, 0, .35); }
.ptabs a[aria-selected="false"][data-state="now"] { background: #fde3d3; border-color: #9a3412; color: #9a3412; animation: duepulse 1.2s ease-in-out infinite; --pulse: rgba(229, 114, 0, .55); }
.ptabs a[aria-selected="false"][data-state="late"] { background: var(--err); border-color: var(--err); color: #fff; animation: duepulse .7s ease-in-out infinite; --pulse: rgba(180, 35, 24, .6); }
.ptabs a[aria-selected="true"][data-state="now"], .ptabs a[aria-selected="true"][data-state="late"] { box-shadow: inset 0 -3px 0 var(--err); }
@media (prefers-reduced-motion: reduce) { .ptabs a { animation: none !important; } }
.links { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.links a { display: grid; align-content: center; gap: 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--r-card); padding: 6px 10px; text-decoration: none; color: var(--navy); font-weight: 600; min-height: 52px; line-height: 1.25; }
.links small { color: var(--muted); font-weight: 400; font-size: 12px; }

/* settings and admin */
.tog { display: flex; gap: 10px; align-items: flex-start; background: var(--card); border: 1px solid var(--line); border-radius: var(--r-card); padding: 10px 12px; cursor: pointer; }
.tog input { width: 20px; height: 20px; min-height: 0; padding: 0; margin: 2px 0 0; flex: none; accent-color: var(--navy); }
.tog small { display: block; color: var(--muted); }
.coderow { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.codebig { display: grid; justify-items: start; gap: 0; min-height: var(--tap); padding: 4px 10px; border: 1px dashed var(--line); border-radius: var(--r); background: var(--chip); color: var(--navy); font-size: 22px; font-weight: 700; letter-spacing: .06em; font-variant-numeric: tabular-nums; cursor: pointer; text-align: left; }
.codebig small { font-size: 11px; font-weight: 400; letter-spacing: 0; color: var(--muted); }
.coderow .link { flex: none; font-size: 13px; }
.mono { font-weight: 600; letter-spacing: .04em; font-variant-numeric: tabular-nums; }
.plain { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.addrow { display: flex; gap: 6px; } .addrow input { flex: 1; min-width: 0; }
.sharerow { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.qr { display: grid; justify-items: center; gap: 6px; padding: 8px 0; }
.qr svg { width: min(240px, 70vw); height: auto; }

/* bars and toast */
.banner { position: fixed; left: 0; right: 0; top: 0; z-index: 8; margin: 0 auto; max-width: 600px; box-shadow: 0 6px 16px rgba(0, 0, 0, .18); background: var(--warn-soft); color: var(--warn); border-bottom: 2px solid var(--warn); font-weight: 700; font-size: 17px; text-align: center; padding: 12px; cursor: pointer; }
.update { display: block; width: 100%; border: 0; background: var(--info-soft); color: var(--navy); padding: 8px; font-size: 13px; font-weight: 600; cursor: pointer; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); top: calc(10px + env(safe-area-inset-top, 0px)); background: var(--n-ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; box-shadow: 0 6px 20px rgba(0, 0, 0, .2); max-width: calc(100% - 32px); z-index: 10; pointer-events: none; }
.sizes { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; }
.sizes .chip { padding: 0; font-size: 14px; }
.seg.sites { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.seg.sites .chip { padding: 0; font-size: 13px; }

/* form view: the paper data collection form's pages, filled in; prints one section per page */
.form { display: grid; gap: 16px; }
.fpage { min-width: 0; overflow-x: auto; background: #fff; color: #000; border: 1px solid var(--line); padding: 16px; font-size: 13px; }
.fpage h3 { margin: 12px 0 8px; font-size: 15px; font-weight: 700; color: var(--navy); }
.fpage h4 { margin: 12px 0 6px; font-size: 13px; font-weight: 700; }
.fpage p { margin: 6px 0; }
.fhead, .ffoot { display: flex; justify-content: space-between; gap: 12px; border-bottom: 1px solid #000; padding-bottom: 6px; flex-wrap: wrap; }
.ffoot { border-bottom: 0; border-top: 1px solid #000; padding: 8px 0 0; margin-top: 16px; }
.ftable { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
.ftable th, .ftable td { border: 1px solid #555; padding: 4px 6px; text-align: center; vertical-align: top; }
.ftable th { font-weight: 600; background: #f2f4f7; }
.ftable.kv th { text-align: left; width: 45%; font-weight: 400; background: none; }
.ftable.kv td { text-align: left; }
.ftable.inner { width: auto; }
.grid5 td { min-width: 34px; }
.fill { display: inline-block; min-width: 5em; border-bottom: 1px solid #000; font-weight: 600; }
.fcap { font-weight: 600; margin-top: 14px !important; }
.fsmall { font-size: 12px; }
/* the Word form, shown scaled to the screen's width (wordview.js sets the zoom) */
.filebtn { cursor: pointer; }
.wordview { min-width: 0; overflow: hidden; }
.wordview .docx-wrapper { background: none; padding: 0; }
.wordview .docx { --docx-majorHAnsi-font: "Calibri Light", Calibri, Carlito, Arial, sans-serif; --docx-minorHAnsi-font: Calibri, Carlito, Arial, sans-serif; }
.wordview .docx-wrapper > section.docx { margin: 0 auto 12px; box-shadow: 0 0 0 1px var(--line); }
@media print {
  @page { size: A4; margin: 12mm; }
  body { background: #fff; }
  .bar, .banner, .update, .toast, .noprint { display: none !important; }
  main { max-width: none; padding: 0; }
  .form { display: block; }
  .fpage { border: 0; padding: 0; break-after: page; overflow: visible; font-size: 9pt; }
  .fpage:last-child { break-after: auto; }
  body { zoom: 1; }
  .wordview { zoom: 1 !important; overflow: visible; }
  .wordview .docx-wrapper > section.docx { margin: 0; box-shadow: none; break-after: page; }
  .wordview .docx-wrapper > section.docx:last-child { break-after: auto; }
  .ftable th, .ftable td { padding: 1px 4px; }
  .fpage h3 { margin: 6px 0 4px; } .fpage h4 { margin: 6px 0 3px; }
  .scroll { overflow: visible; }
}

/* ask to save before leaving a reading with changes */
dialog.ask { border: 0; border-radius: var(--r-card); padding: 16px; width: min(340px, calc(100vw - 32px)); background: var(--card); color: var(--ink); box-shadow: 0 8px 30px rgba(0, 0, 0, .25); }
dialog.ask::backdrop { background: rgba(0, 0, 0, .35); }
dialog.ask p { margin: 0 0 6px; }
.askbtns { display: grid; gap: 8px; margin-top: 12px; }
.askbtns button { min-height: var(--tap); }

/* what's still missing (patient screen, above Mark data collection as complete) */
.gaps { margin-top: 12px; padding: 10px 12px; border: 1px solid var(--warn); border-radius: var(--r-card); background: var(--warn-soft); color: var(--ink); font-size: 14px; }
.gaps b { color: var(--warn); }
.gaps ul { margin: 4px 0 0; padding-left: 18px; display: grid; gap: 4px; }
.gaps a { color: var(--warn); font-weight: 600; }

/* the phone couldn't store a change: stays until a write works again */
.storefull { position: sticky; top: 0; z-index: 9; padding: 10px 12px; background: var(--err); color: #fff; font-weight: 700; text-align: center; }
.twinline { display: block; font-size: 12px; font-weight: 600; color: var(--warn); }

/* the patient screen's three parts (owner, 12 Oct 2026): key times, the tab's readings, the shared bottom part */
.third { display: grid; gap: 4px; border: 1px solid var(--line); border-radius: var(--r-card); padding: 4px 6px; }
.third.top { background: #e9eef6; border-color: #c5d0e2; }
.third.mid { background: var(--bg); border-color: var(--line); }
.third.bot { background: #f3f0e8; border-color: #ddd6c4; }
.third.bot .links.two { margin-top: 0; }
.resetline { margin: 4px 0 0; text-align: center; }
.resetline .link { font-size: 12px; color: var(--muted); }
.pacutimes { grid-template-columns: 1fr 1fr; margin-bottom: 8px; }
/* home: New patient and PACU view side by side */
.newrow { display: grid; grid-template-columns: 2fr 1fr; gap: 8px; }
#pacuview { font-weight: 600; color: var(--navy); border-color: var(--navy); }
/* a section marked complete: read only until its tick is undone */
.sealed .card, .sealed .fld, .sealed .tchip, .sealed table, .sealed .ixrow, .sealed #addix { opacity: .6; }
.sealnote { margin: 4px 0; padding: 8px 12px; border-radius: var(--r); background: #e3f1e6; color: var(--ok); font-weight: 600; font-size: 14px; }

/* quick-entry pad: a number pad / time pad popup (owner, 13 Oct 2026) */
dialog.kp { border: 0; border-radius: var(--r-card); padding: 12px; width: min(360px, calc(100vw - 20px)); background: var(--card); color: var(--ink); box-shadow: 0 8px 30px rgba(0, 0, 0, .3); margin: auto auto 10px; }
dialog.kp::backdrop { background: rgba(0, 0, 0, .4); }
.kphead { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.kphead small { color: var(--muted); }
.kpin { width: 100%; box-sizing: border-box; text-align: center; font-size: 34px; font-weight: 700; min-height: 60px; border: 2px solid var(--navy); border-radius: var(--r); background: var(--card); color: var(--ink); }
.kpin.bad { border-color: var(--err); background: #fde8e6; }
.kpnow { display: flex; justify-content: center; gap: 10px; width: 100%; min-height: 52px; margin-bottom: 8px; border: 1px solid var(--navy); border-radius: var(--r); background: #e9eef6; color: var(--navy); font-size: 18px; font-weight: 600; align-items: center; cursor: pointer; }
.kpgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 8px 0; }
.kpgrid button { min-height: 58px; font-size: 26px; font-weight: 600; border: 1px solid var(--line-input); border-radius: var(--r); background: var(--card); color: var(--ink); cursor: pointer; touch-action: manipulation; }
.kpgrid button:active { background: #e9eef6; }
.kpbtns { display: flex; gap: 6px; }
.kpbtns button { flex: 1; min-height: 50px; font-size: 16px; }
.kpbtns .save { flex: 1.4; }
.clock .next[role="button"] { cursor: pointer; }

/* progress: which sections are marked complete (owner, 13 Oct 2026) */
.progress { display: flex; flex-wrap: wrap; gap: 3px 10px; margin: 2px 0; }
.progress > span { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); }
.progress > span.on { color: var(--ok); font-weight: 600; }
.progress .tick { display: inline-grid; place-items: center; flex: none; width: 14px; height: 14px; border: 1.5px solid var(--line-input); border-radius: 4px; font-size: 10px; line-height: 1; }
.progress > span.on .tick { background: var(--ok); border-color: var(--ok); color: #fff; }

/* PACU nurse link (owner, 13 Oct 2026) */
.paculink { display: grid; gap: 6px; margin-top: 12px; padding: 10px; border: 1px solid var(--line); border-radius: var(--r-card); background: var(--card); }
.paculink h2 { margin: 0; font-size: 16px; }
.pacuurl { width: 100%; box-sizing: border-box; font-size: 12px; padding: 6px; border: 1px solid var(--line-input); border-radius: var(--r); background: var(--bg); color: var(--ink); }
.pacutimes .tchip { min-height: 64px; font-size: 16px; }

/* values only carried over, not yet saved for this timepoint: light grey (owner, 13 Oct 2026) */
.card.dflt .num { color: #767676; font-weight: 400; }
.card.dflt .chip[aria-pressed="true"] { background: var(--line); border-color: var(--line-input); color: #4d545b; }
.refreshbox { display: grid; gap: 4px; margin-top: 12px; }

.bar h1 { display: flex; flex-direction: column; line-height: 1.1; }
.bar h1 .idlab { font-size: 11px; font-weight: 500; opacity: .8; }
.bar h1 span { overflow: hidden; text-overflow: ellipsis; }

/* the bar's sync status chip (owner, 13 Oct 2026): replaces the Log shortcut */
.syncchip { background: var(--card); color: var(--ink); border: 1px solid var(--line); }
.syncchip:active { background: var(--bg); }
.syncchip[data-state="ok"] { color: var(--ok); border-color: var(--ok); }
.syncchip[data-state="wait"] { background: var(--warn-soft); color: var(--warn); border-color: var(--warn); }
.syncchip[data-state="local"] { color: var(--muted); }
.syncchip[data-busy] { opacity: .6; }

/* patient list: admin Form view shortcut on each line; select to lock / export (owner, 13 Oct 2026) */
.list li.rowact { display: flex; gap: 6px; align-items: stretch; }
.list li.rowact > a:first-child { flex: 1 1 auto; min-width: 0; }
.list a.formlink { display: grid; place-items: center; flex: none; width: 52px; padding: 0; color: var(--navy); }
.headlinks { display: inline-flex; gap: 14px; }
.seltools { display: grid; gap: 8px; }
.seltools .selcount { flex: none; }
.selshort { display: flex; flex-wrap: wrap; gap: 6px; }
.selchip { font: inherit; font-size: 14px; min-height: 40px; padding: 4px 12px; border-radius: 20px; background: transparent; color: var(--navy); border: 1px dashed var(--navy); }
.selacts { display: flex; gap: 6px; }
.selacts .primary, .selacts .secondary { flex: 1 1 0; }
.seltools .link { justify-self: start; }
.listhead { flex-wrap: wrap; }
.headlinks { margin-left: auto; white-space: nowrap; }
.headlinks .link { white-space: nowrap; }
