:root {
  /* Windows 98: teal desktop, grey 3D windows, navy title bars. Red stays for
     pending and out-of-range values. Single look by design (no dark mode). */
  --desk: #008080;
  --bg: #c0c0c0;
  --card: #c0c0c0;
  --field: #ffffff;
  --ink: #000000;
  --muted: #404040;
  --line: #808080;
  --hi: #ffffff;
  --lo: #808080;
  --dk: #0a0a0a;
  --face: #dfdfdf;
  --brand: #000080;
  --brand-2: #1084d0;
  --brand-ink: #ffffff;
  --red: #c00000;
  --red-bg: #ffffff;
  --ok: #006400;
  --ok-bg: #ffffff;
  --warn: #7a5200;
  --warn-bg: #ffffe1;
  --na: #808080;
  --blue-bg: #ffffff;
  --radius: 0;
  --font: "Pixelify Sans", "MS Sans Serif", Tahoma, Verdana, sans-serif;
  --field-font: Tahoma, "MS Sans Serif", Verdana, Arial, sans-serif;
  --raised: inset -1px -1px var(--dk), inset 1px 1px var(--hi), inset -2px -2px var(--lo), inset 2px 2px var(--face);
  --sunken: inset -1px -1px var(--hi), inset 1px 1px var(--lo), inset -2px -2px var(--face), inset 2px 2px var(--dk);
  --window: inset -1px -1px var(--dk), inset 1px 1px var(--face), inset -2px -2px var(--lo), inset 2px 2px var(--hi);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 var(--font);
}
a { color: var(--brand); }
h2 { font-size: 1.25rem; margin: 0 0 .6rem; }
h3 { font-size: 1.05rem; margin: 0 0 .6rem; display: flex; align-items: center; gap: .5rem; }
h4 { margin: .8rem 0 .3rem; }
.muted { color: var(--muted); }
.small { font-size: .85em; }
.right { margin-left: auto; }
.pre { white-space: pre-line; }

/* ---------- header ---------- */
.top {
  position: sticky; top: 0; z-index: 10;
  background: #13294b; color: #fff; border-bottom: 3px solid #c8102e;
  display: flex; flex-wrap: wrap; align-items: center; gap: .25rem .75rem;
  padding: .5rem 16px calc(.25rem);
  padding-top: max(.5rem, env(safe-area-inset-top));
}
.brand { color: inherit; font-weight: 700; text-decoration: none; }
.sync { font-size: .75rem; padding: .1rem .5rem; border-radius: 99px; background: rgba(255,255,255,.18); }
.sync.warn { background: #c8102e; color: #fff; }
#nav { display: flex; gap: .15rem; width: 100%; overflow-x: auto; scrollbar-width: none; }
#nav a {
  color: inherit; text-decoration: none; opacity: .8;
  padding: .35rem .65rem; border-radius: 8px 8px 0 0; white-space: nowrap;
}
#nav a.on { opacity: 1; background: var(--bg); color: var(--ink); font-weight: 600; }
@media (min-width: 760px) { #nav { width: auto; margin-left: auto; } .top { padding-bottom: 0; } }

main { max-width: 1100px; margin: 0 auto; padding: 14px 16px 80px; }

/* ---------- basics ---------- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; margin-bottom: 12px; position: relative;
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .3rem;
  font: inherit; font-weight: 500; text-decoration: none; cursor: pointer;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  padding: .5rem .9rem; border-radius: 8px; min-height: 40px;
}
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.btn.danger { color: var(--red); border-color: var(--red); }
.btn.small { padding: .25rem .6rem; min-height: 32px; font-size: .85rem; }
.icon { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 1rem; padding: .25rem .4rem; }
.icon:disabled { opacity: .3; }
.link { border: 0; background: none; color: var(--brand); cursor: pointer; padding: 0; font: inherit; }
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--card);
  border: 1px solid var(--line); border-radius: 7px; padding: .45rem .55rem; width: 100%; min-width: 0;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, .chip:focus-visible { outline: 2px solid var(--brand); outline-offset: -1px; }
input[type=checkbox], input[type=radio] { width: auto; accent-color: var(--brand); }
label { display: block; font-size: .85rem; color: var(--muted); }
label > input, label > select, label > textarea { margin-top: .2rem; color: var(--ink); font-size: 15px; }
.row-between { display: flex; justify-content: space-between; align-items: flex-start; gap: .75rem; }
.actions, .form-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .75rem; align-items: center; }
.empty { text-align: center; color: var(--muted); padding: 2rem 1rem; }
.warn { color: var(--warn); }
.toolbar { display: flex; gap: .5rem; align-items: center; margin-bottom: .6rem; }
.toolbar input { flex: 1; }
.toolbar h2 { margin: 0; flex: 1; }

.chips { display: flex; gap: .35rem; flex-wrap: wrap; margin-bottom: .75rem; }
.chip {
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  border-radius: 99px; padding: .3rem .8rem; font: inherit; font-size: .85rem; cursor: pointer;
}
.chip.on { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }

.badge, .badge-select {
  font-size: .75rem; font-weight: 600; border-radius: 99px; padding: .15rem .6rem; white-space: nowrap;
  border: 0; width: auto;
}
.badge-select { padding: .3rem .5rem; }
.st-preop { background: var(--warn-bg); color: var(--warn); }
.st-posted { background: var(--blue-bg); color: var(--brand); }
.st-postop { background: var(--ok-bg); color: var(--ok); }
.st-discharged { background: var(--line); color: var(--muted); }
.st-plastic { background: #fdecef; color: #a3264a; }
.st-neuro { background: #eef0fd; color: #3b3fa3; }

.pill { font-size: .75rem; font-weight: 600; padding: .1rem .5rem; border-radius: 99px; background: var(--warn-bg); color: var(--warn); }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.tag {
  display: inline-block; font-size: .75rem; padding: .1rem .45rem; border-radius: 5px;
  background: var(--line); color: var(--ink); margin: 0 .25rem .25rem 0;
}
.tag.inv { background: var(--red-bg); color: var(--red); }
.tag.flag { background: var(--red-bg); color: var(--red); font-weight: 700; }
.tag.sent { background: var(--warn-bg); color: var(--warn); }
.tag.task { background: var(--blue-bg); color: var(--brand); }
.tag.ok { background: var(--ok-bg); color: var(--ok); }
.bed { display: none; font-size: .75rem; font-weight: 700; background: var(--brand); color: var(--brand-ink); border-radius: 5px; padding: 0 .35rem; margin-right: .4rem; vertical-align: 2px; }

/* ---------- dashboard ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; margin-bottom: .75rem; }
.stats div { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .5rem; text-align: center; }
.stats b { display: block; font-size: 1.4rem; }
.stats span { font-size: .75rem; color: var(--muted); }
.cards { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
@media (max-width: 400px) { .cards { grid-template-columns: 1fr; } }
.case-card { color: inherit; text-decoration: none; margin: 0; display: block; }
.case-card:hover { border-color: var(--brand); }
.cc-name { font-weight: 600; font-size: 1.05rem; }
.cc-dx { margin-top: .4rem; }
.cc-plan { color: var(--brand); font-weight: 500; }
.progress { height: 5px; background: var(--line); border-radius: 3px; margin: .6rem 0 .5rem; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--red); }
.progress i.ok { background: var(--ok); }

/* ---------- case detail ---------- */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .25rem .75rem; margin: .75rem 0 0; }
.kv dt { color: var(--muted); font-size: .85rem; }
.kv dd { margin: 0; }
.checks { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.chk { border: 1px solid var(--line); border-left: 4px solid var(--line); border-radius: 8px; padding: .5rem .6rem; display: flex; flex-direction: column; gap: .4rem; }
.chk-wide { grid-column: 1 / -1; }
.chk-top { display: flex; align-items: center; gap: .5rem; }
.chk-label { font-weight: 600; flex: 1; }
.chk .st { width: auto; padding: .2rem .4rem; font-size: .85rem; }
.chk-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(55px, 1fr)); gap: .35rem; }
.chk-fields input { padding: .3rem .4rem; }
.chk .note { padding: .3rem .45rem; font-size: .9rem; }
.chk-img { display: flex; gap: .4rem; }
.s-done { border-left-color: var(--ok) !important; }
.s-sent { border-left-color: var(--warn) !important; }
.s-pending { border-left-color: var(--red) !important; }
.s-na { border-left-color: var(--na) !important; opacity: .75; }
.op-row { display: grid; grid-template-columns: 1fr auto auto; gap: .35rem .5rem; align-items: center; border-left: 3px solid var(--line); padding-left: .5rem; }
.op-row .note { grid-column: 1 / 3; }
.inline-add { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: .5rem; }
.inline-add input { flex: 1 1 180px; }
.inline-add select { flex: 0 1 150px; }

.tasks { list-style: none; margin: 0; padding: 0; }
.tasks li { border-bottom: 1px solid var(--line); padding: .5rem 1.8rem .5rem 0; position: relative; }
.tasks li label { display: inline; color: var(--ink); font-size: 1rem; }
.tasks li.done span { text-decoration: line-through; color: var(--muted); }
.tasks .icon { position: absolute; right: 0; top: .4rem; }
.log { list-style: none; margin: 0; padding: 0; max-height: 280px; overflow: auto; font-size: .9rem; }
.log li { padding: .25rem 0; border-bottom: 1px dashed var(--line); }

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.thumb { border: 1px solid var(--line); background: #000; border-radius: 8px; padding: 0; overflow: hidden; cursor: pointer; display: flex; flex-direction: column; }
.thumb img { width: 100%; height: 100px; object-fit: cover; background: #222; }
.thumb span { font-size: .7rem; color: #fff; padding: .2rem .35rem; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

#modal { position: fixed; inset: 0; background: #05080f; z-index: 50; }
.viewer { display: flex; flex-direction: column; height: 100%; }
.viewer-bar { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .5rem; padding: .5rem 16px; color: #fff; }
.viewer-bar .muted { color: #aaa; }
.viewer-img { flex: 1; display: flex; align-items: center; justify-content: center; overflow: auto; touch-action: pinch-zoom; }
.viewer-img img { max-width: 100%; max-height: 100%; }

/* ---------- forms ---------- */
.form fieldset { border: 0; padding: 0; margin: 0 0 .75rem; display: grid; grid-template-columns: 1fr 1fr; gap: .6rem .75rem; }
.form legend { font-weight: 700; margin-bottom: .5rem; color: var(--brand); }
.span2 { grid-column: 1 / -1; }
.hint { display: block; font-size: .8rem; margin-top: .2rem; color: var(--muted); }
.block { display: block; }
.radios { display: flex; flex-wrap: wrap; gap: .35rem; }
@media (max-width: 520px) { .form fieldset { grid-template-columns: 1fr; } }

/* ---------- ward board ---------- */
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.board { border-collapse: collapse; font-size: .82rem; min-width: 1100px; width: 100%; }
.board th { white-space: nowrap; }
.board th, .board td { border-bottom: 1px solid var(--line); padding: .4rem; text-align: left; vertical-align: top; }
.board th { position: sticky; top: 0; background: var(--brand); font-size: .75rem; color: var(--brand-ink); }
.board tr[data-go] { cursor: pointer; }
.board tr[data-go]:hover { background: var(--bg); }
.board td.s-done, .board div.s-done { color: var(--ok); }
.board td.s-sent, .board div.s-sent { color: var(--warn); }
.board td.s-pending, .board div.s-pending { color: var(--red); }
.board td.s-na { color: var(--na); }

/* ---------- OT builder ---------- */
.picks { display: grid; gap: 6px; max-height: 50vh; overflow: auto; }
.pick { display: flex; gap: .6rem; align-items: flex-start; color: var(--ink); font-size: .95rem; border: 1px solid var(--line); border-radius: 8px; padding: .5rem; cursor: pointer; }
.pick > span:nth-child(2) { flex: 1; }
.pick input { margin-top: .25rem; transform: scale(1.25); }
.ot-row { border: 1px solid var(--line); border-radius: 8px; padding: .6rem; margin-bottom: 8px; }
.ot-row-head { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin-bottom: .3rem; }
.ot-fields { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: .5rem; }
.ot-fields .span2 { grid-column: span 2; }
.ot-fields .span3 { grid-column: 1 / -1; }
@media (max-width: 640px) { .ot-fields { grid-template-columns: 1fr 1fr; } .ot-fields .span2 { grid-column: 1 / -1; } }
.ot-preview-title { font: bold .85rem Arial, sans-serif; text-align: center; padding: .5rem; background: var(--bg); border-radius: 6px; }
.review-row { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; font-size: .9rem; }
.review-row input { width: 4.5rem; }
.review-row select { width: auto; }
.lh-preview { background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: .4rem; text-align: center; }
.lh-preview img { max-width: 100%; max-height: 90px; }
.nb-screen td:nth-child(4) { max-width: 360px; }

/* ---------- implants / settings ---------- */
.impl { padding-right: 2.5rem; }
.impl .icon { position: absolute; top: .6rem; right: .5rem; }
.impl-grid { display: grid; grid-template-columns: 1fr 2fr; gap: .5rem; }
@media (max-width: 520px) { .impl-grid { grid-template-columns: 1fr; } }
.members { list-style: none; padding: 0; }
.members li { padding: .3rem 0; border-bottom: 1px solid var(--line); }
.gate { max-width: 420px; margin: 10vh auto; text-align: center; }

#toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); transform: translate(-50%, 150%);
  background: var(--ink); color: var(--bg); padding: .6rem 1rem; border-radius: 8px;
  transition: transform .2s, opacity .2s; z-index: 60; max-width: calc(100% - 32px); opacity: 0;
}
#toast.show { transform: translate(-50%, 0); opacity: 1; }

/* ---------- print ---------- */
#print { display: none; }
@media print {
  body { background: #fff; color: #000; }
  .top, #view, #modal, #toast { display: none !important; }
  #print { display: block; }
}
.pr { color: #000; font-family: "Times New Roman", Times, serif; }
.pr-sub { font-size: .85em; font-weight: normal; }

/* OT list — matches the unit's Word template */
.ot-title { font: bold 14pt Arial, Helvetica, sans-serif; text-align: center; margin: 0 0 14pt; }
.ot-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.ot-table th, .ot-table td {
  border: 1px solid #000; padding: 2pt 4pt; vertical-align: top; text-align: left;
  font: bold 8pt "Times New Roman", Times, serif; word-wrap: break-word;
}
.ot-table td { height: 38pt; }
.ot-table tr { page-break-inside: avoid; }
.ot-sign { font: bold 8pt "Times New Roman", Times, serif; text-align: right; margin: 34pt 40pt 0 0; }

/* Ward notebook */
.nb-head { display: flex; justify-content: space-between; font-size: 11pt; margin-bottom: 6pt; }
.nb-table { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 10pt; }
.nb-table th { background: #d9d9d9; -webkit-print-color-adjust: exact; print-color-adjust: exact; text-align: left; }
.nb-table th, .nb-table td { border: 1px solid #000; padding: 4pt 5pt; vertical-align: top; }
.nb-table tr { page-break-inside: avoid; }
.nb-sno { text-align: center; position: relative; }
.nb-bot { display: block; font-size: 8pt; font-weight: 700; }
.nb-todo span { display: inline-block; margin-right: 10pt; }

/* Discharge — letterhead + grey patient box repeat on every page */
table.dc { width: 100%; border-collapse: collapse; font-size: 10.5pt; }
table.dc > thead { display: table-header-group; }
.dc-lh { text-align: center; }
.dc-lh img { height: 24mm; max-width: 80%; object-fit: contain; }
.dc-box {
  width: 100%; border-collapse: collapse; background: #e6e6e6; margin: 3pt 0 8pt;
  -webkit-print-color-adjust: exact; print-color-adjust: exact; font-size: 9pt;
}
.dc-box th, .dc-box td { text-align: left; padding: 2.5pt 4pt; vertical-align: top; text-transform: uppercase; }
.dc-box th { font-weight: 700; white-space: nowrap; width: 15%; padding-left: 10pt; }
.dc-box td:nth-child(2) { width: 2%; font-weight: 700; }
.dc-box td:nth-child(3) { width: 33%; font-weight: 700; }
.dc-box td:nth-child(5) { font-weight: 700; }
.dc-body { padding: 0 6% ; }
.dc-title { text-align: center; font-weight: 700; text-decoration: underline; margin-bottom: 8pt; }
.dc-sec { margin-bottom: 8pt; }
.dc-end { page-break-inside: avoid; }
.dc-sec h4 { margin: 0 0 3pt; font-size: 1em; text-decoration: underline; font-weight: 700; }
.dc-advice > div { padding-left: 30pt; }
.dc-ta { font-family: "Latha", "Noto Sans Tamil", "Nirmala UI", sans-serif; font-size: 9pt; margin: 6pt 0 0; }
.dc-doc { margin-top: 26pt; }
.dc-sig { text-align: right; font-weight: 700; margin: 30pt 10% 0 0; }
.board.nb-screen { min-width: 640px; }

/* ---------- flags & pending ---------- */
.flag, .is-flag input, .is-flag select, input.is-flag { color: var(--red) !important; font-weight: 700; }
.is-flag input, .is-flag select, input.is-flag { border-color: var(--red); }
.miss { color: var(--red); }
.italic { font-style: italic; }
.nowrap { white-space: nowrap; }

/* ---------- lab entry ---------- */
.lab-form { display: grid; gap: .75rem; }
.lab-date { max-width: 240px; }
.lab-group { border: 1px solid var(--line); border-radius: var(--radius); padding: .6rem .7rem .7rem; margin: 0; display: block !important; }
.lab-group legend { font-weight: 700; color: var(--brand); padding: 0 .3rem; margin: 0; font-size: .9rem; }
.lab-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: .5rem .6rem; }
.lab-in { display: flex; flex-direction: column; gap: .15rem; color: var(--ink); }
.lab-in .lab-name { font-weight: 600; font-size: .85rem; }
.lab-in small { color: var(--muted); font-size: .72rem; font-variant-numeric: tabular-nums; }
.lab-in input, .lab-in select { margin: 0; padding: .4rem .45rem; font-variant-numeric: tabular-nums; }
.new-customs { display: grid; gap: .4rem; margin: .5rem 0; }
.new-customs:empty { margin: 0; }
.custom-row { display: grid; grid-template-columns: 2fr 1fr 2fr 1fr auto; gap: .35rem; align-items: center; }
@media (max-width: 560px) { .custom-row { grid-template-columns: 1fr 1fr auto; } .custom-row [data-cn], .custom-row .mini-lab:has([data-cn]) { grid-column: 1 / 3; } }
.form .block-fs > .span2 { min-width: 0; }

/* ---------- flowsheet ---------- */
.flow { border-collapse: collapse; font-size: .88rem; font-variant-numeric: tabular-nums; min-width: 100%; }
.flow th, .flow td { border-bottom: 1px solid var(--line); padding: .3rem .5rem; text-align: left; white-space: nowrap; }
.flow thead th { background: var(--brand); color: var(--brand-ink); font-weight: 600; position: sticky; top: 0; }
.flow thead th.d { text-align: center; }
.flow .set-acts { display: block; }
.flow .set-acts .icon { color: var(--brand-ink); opacity: .75; font-size: .85rem; padding: 0 .3rem; }
.flow tr.grp th { background: var(--blue-bg); color: var(--brand); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }
.flow .rng { display: block; color: var(--muted); font-size: .72rem; font-weight: normal; }
.flow thead .rng { color: inherit; opacity: .75; }
.flow td.v { min-width: 4.5rem; }
.flow td.v { text-align: center; }
.flow tr.missing .pn { color: var(--red); }
.pus { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; margin-top: .75rem; }
@media (max-width: 520px) { .pus { grid-template-columns: 1fr; } }

/* ---------- work-up / opinions ---------- */
.work { display: grid; gap: .5rem; }
.work-row { display: flex; gap: .5rem; align-items: flex-end; border-left: 4px solid var(--ok); padding-left: .6rem; }
.work-row.missing { border-left-color: var(--red); }
.work-row > label { flex: 1; min-width: 0; color: var(--ink); font-weight: 600; }
.work-row.missing input::placeholder { color: var(--red); opacity: .8; }
.work-img { display: flex; gap: .35rem; }
@media (max-width: 520px) { .work-row { flex-wrap: wrap; } .work-img { width: 100%; } }

/* ---------- modal sheet ---------- */
#modal.sheet-wrap { background: rgba(10, 18, 36, .55); overflow: auto; padding: 16px; }
.sheet { max-width: 760px; margin: 4vh auto; }

/* ---------- OT picker ---------- */
.picker tr[data-row] { cursor: pointer; }
.picker tr.picked { background: var(--blue-bg); }
.picker input { transform: scale(1.2); }

/* ---------- implant database ---------- */
.impl-table { min-width: 760px; }
.impl-table td { padding: .3rem; }
.impl-table { min-width: 560px; }
.impl-table td:nth-child(1) { width: 30%; }
.impl-table td:nth-child(3) { width: 64px; text-align: center; }
.impl-table tfoot td { border-top: 2px solid var(--line); background: var(--bg); }
.test { margin-top: .75rem; }
.pr-flag { color: #c8102e; font-weight: 700; margin-right: 10pt; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.staff-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: .75rem; }
.staff-unit { display: grid; gap: .4rem; border: 1px solid var(--line); border-radius: var(--radius); padding: .6rem; }
.staff-unit b { color: var(--brand); }
.level-table { min-width: 820px; }
.level-table td:nth-child(1) { width: 80px; }
.level-table td:nth-child(2) { width: 16%; }
.level-table td:nth-child(3) { width: 34%; }
.level-table td:nth-child(5) { width: 64px; text-align: center; }
.level-table .lv-head th { background: var(--blue-bg); color: var(--brand); position: static; font-size: .8rem; text-align: left; }
.ver { font-size: .7rem; opacity: .7; }
.jump { position: sticky; top: calc(env(safe-area-inset-top, 0px) + 84px); z-index: 5; background: var(--bg); padding: .4rem 0; margin-bottom: .5rem; }
.jump .chip { text-decoration: none; }
.form > fieldset.card { margin-bottom: 12px; padding: 14px; scroll-margin-top: 190px; }
.form > fieldset.card > legend { font-size: 1.05rem; padding: 0 .3rem; }
#sec-inv { border-top: 3px solid var(--red); }
@media (min-width: 760px) { .jump { top: 52px; } }

/* viewer navigation */
.viewer-img { position: relative; }
.v-nav {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 2;
  width: 52px; height: 72px; border: 0; border-radius: 8px; cursor: pointer;
  background: rgba(19, 41, 75, .75); color: #fff; font-size: 2.2rem; line-height: 1;
}
.v-nav:disabled { opacity: .2; cursor: default; }
.v-prev { left: 12px; }
.v-next { right: 12px; }
.viewer-strip { display: flex; gap: .35rem; overflow-x: auto; padding: .5rem 16px calc(.5rem + env(safe-area-inset-bottom, 0px)); }
.v-dot { flex: none; border: 1px solid #556; background: transparent; color: #ccd; border-radius: 99px; padding: .2rem .6rem; font: inherit; font-size: .8rem; cursor: pointer; }
.v-dot.on { background: #c8102e; border-color: #c8102e; color: #fff; }
.img-link { color: var(--red); font-weight: 600; text-decoration: none; }
.img-link:hover { text-decoration: underline; }
.picker { min-width: 640px; }
a.btn[aria-disabled="true"] { opacity: .45; }

/* Picker on phones: one compact block per case instead of a wide table.
   Columns: 1 move ↑↓ · 2 tick · 3 name · 4 age/sex · 5 diagnosis · 6 plan · 7 DOA ·
   8 anaesthesia · 9 scheme · 10 radiographs · 11 hide */
@media (max-width: 640px) {
  .picker { min-width: 0; }
  .picker thead { display: none; }
  .picker tr[data-row] {
    display: grid; grid-template-columns: 34px 28px 1fr 1fr;
    grid-template-areas: "mv cb name age" "mv cb dx dx" "mv cb plan plan" "mv cb doa img" "mv cb an sc" "mv cb hide hide";
    gap: .2rem .4rem; padding: .55rem .4rem; border-bottom: 1px solid var(--line);
  }
  .picker tr[data-row] td { border: 0; padding: 0; min-width: 0; }
  .picker td:nth-child(1) { grid-area: mv; display: flex; flex-direction: column; justify-content: center; gap: .35rem; }
  .picker td:nth-child(2) { grid-area: cb; padding-top: .15rem; }
  .picker td:nth-child(3) { grid-area: name; }
  .picker td:nth-child(4) { grid-area: age; color: var(--muted); text-align: right; }
  .picker td:nth-child(5) { grid-area: dx; }
  .picker td:nth-child(6) { grid-area: plan; color: var(--brand); font-weight: 600; }
  .picker td:nth-child(6):not(:empty)::before { content: "▸ "; }
  .picker td:nth-child(7) { grid-area: doa; color: var(--muted); }
  .picker td:nth-child(7)::before { content: "DOA "; }
  .picker td:nth-child(8) { grid-area: an; }
  .picker td:nth-child(9) { grid-area: sc; }
  .picker td:nth-child(8) select, .picker td:nth-child(9) select { width: 100%; min-width: 0 !important; }
  .picker td:nth-child(10) { grid-area: img; text-align: right; }
  .picker td:nth-child(11) { grid-area: hide; text-align: right; }
}

/* OT list x2 on one sheet */
#print.measuring { display: block !important; position: absolute; left: -10000px; top: 0; }
.ot-dup { display: flex; flex-direction: column; }
.ot-half { height: var(--half); overflow: hidden; }
.ot-half .ot-title { font-size: 12pt; margin-bottom: 8pt; }
.ot-half .ot-table td { height: auto; }
.ot-half .ot-sign { margin-top: 14pt; }
.ot-cut { border-top: 1px dashed #000; }

/* Ward → Detailed: one column per investigation */
.board.detail { min-width: 1700px; font-variant-numeric: tabular-nums; }
.board.detail thead tr:first-child th { position: static; }
.board.detail th.grp-h { text-align: center; border-left: 2px solid rgba(255,255,255,.35); }
.board.detail th.ph { font-weight: 600; text-align: center; background: var(--brand-2); }
.board.detail th.ph span { display: block; font-weight: normal; font-size: .65rem; opacity: .85; }
.board.detail td.v { text-align: center; white-space: nowrap; }

/* Monitoring charts */
.chart { border: 1px solid var(--line); border-radius: var(--radius); padding: .6rem; margin-bottom: .75rem; }
.chart-head h4 { margin: 0; color: var(--brand); }
.chart-acts { display: flex; gap: .3rem; align-items: center; }
.chart-table th, .chart-table td { white-space: nowrap; }
.chart-table td.txt { white-space: normal; min-width: 8rem; }
.chart-table tr.from-inv td { color: var(--muted); }
.chart-table tr.from-inv td.flag { color: var(--red); }
.chart-table tr.editing td { background: var(--blue-bg); }
.chart-table { min-width: 0; width: auto; }
.chart-table td.v { min-width: 3.5rem; }
.chart-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: .45rem .6rem; margin-top: .6rem; padding: .6rem; background: var(--bg); border-radius: var(--radius); }
.chart-form.editing { background: var(--blue-bg); }
.chart-form label { color: var(--ink); font-weight: 600; font-size: .8rem; }
.chart-form label .muted { font-weight: normal; }
.chart-form input { margin-top: .15rem; padding: .35rem .45rem; }
.chart-form .wide { grid-column: span 2; }
.chart-form-acts { grid-column: 1 / -1; display: flex; gap: .4rem; }
.btn.suggest { border-color: var(--red); }
.btn.suggest .pill { background: var(--red-bg); color: var(--red); }
.cc-row { grid-template-columns: 2fr 1fr 2fr auto auto; }
.cc-cols { display: grid; gap: .4rem; margin: .5rem 0; }
.chart-pr-head { margin-bottom: 8pt; font-size: 11pt; display: grid; gap: 2pt; }
.chart-pr-table th, .chart-pr-table td { text-align: center; }

/* Sign-in */
.gate-form { display: grid; gap: .6rem; text-align: left; margin: .75rem 0; }
.gate-links { display: flex; justify-content: center; gap: 1rem; flex-wrap: wrap; font-size: .9rem; }
.gate-or { display: flex; align-items: center; gap: .6rem; color: var(--muted); margin: 1rem 0 .75rem; font-size: .85rem; }
.gate-or::before, .gate-or::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.actions.center { justify-content: center; }
.notice { background: var(--warn-bg); color: var(--ink); border-radius: var(--radius); padding: .6rem .75rem; }

/* Hide / add back in the OT picker */
.hide-btn { color: var(--muted); }
.hidden-cases { margin-top: .75rem; }
.hidden-cases summary { cursor: pointer; color: var(--brand); font-weight: 600; padding: .3rem 0; }
.hidden-cases ul { list-style: none; margin: .4rem 0 0; padding: 0; }
.hidden-cases li { display: flex; justify-content: space-between; align-items: center; gap: .5rem; padding: .45rem 0; border-bottom: 1px solid var(--line); }

/* Admission deck page */
.img-adders { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .6rem; }
.pending-imgs { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: .5rem; }
.pending-imgs:empty { display: none; }
.pthumb { position: relative; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; background: #000; }
.pthumb img { width: 100%; height: 84px; object-fit: cover; display: block; }
.pthumb span { display: block; font-size: .7rem; color: #fff; padding: .15rem .35rem; }
.pthumb .icon { position: absolute; top: 2px; right: 2px; background: rgba(0,0,0,.6); color: #fff; border-radius: 50%; }
.deck-case { border: 1px solid var(--line); border-radius: var(--radius); padding: .7rem; margin-bottom: .7rem; }
.deck-fields { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem .7rem; margin: .5rem 0; }
.deck-fields .span2 { grid-column: 1 / -1; }
@media (max-width: 520px) { .deck-fields { grid-template-columns: 1fr; } }
.deck-imgs { border-top: 1px dashed var(--line); padding-top: .5rem; margin-top: .5rem; }
.deck-label { width: auto; flex: 1; font-weight: 600; text-transform: uppercase; max-width: 260px; }
.dthumbs { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .4rem; }
.dthumb { position: relative; width: 92px; height: 72px; border-radius: 6px; overflow: hidden; background: #000; cursor: pointer; }
.dthumb img { width: 100%; height: 100%; object-fit: cover; }
.dthumb input { position: absolute; top: 4px; left: 4px; transform: scale(1.2); }
.dthumb.off img { opacity: .3; }
.cons-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1.2rem; }
@media (max-width: 520px) { .cons-grid { grid-template-columns: 1fr; } }
.cons-row { display: flex; align-items: center; justify-content: space-between; gap: .5rem; color: var(--ink); padding: .25rem 0; border-bottom: 1px solid var(--line); }
.cons-row input { width: 80px; text-align: center; text-transform: uppercase; margin: 0; }
.deck-previews { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; background: #2b3540; padding: 12px; border-radius: var(--radius); }
.deck-previews .pslide { margin: 0; cursor: default; }
.deck-previews .meta { color: #cfd6dd; }
/* slide preview styles from the admission-deck tool */
.slide-no{font-size:.8rem;color:var(--muted);white-space:nowrap}
.pslide{margin:0 0 18px;cursor:pointer}
.pslide .meta{display:flex;justify-content:space-between;font-size:.8rem;margin:0 0 6px}
.pslide .meta b{color:#E4E9EE}
.slide{position:relative;aspect-ratio:16/9;background:#fff;container-type:inline-size;overflow:hidden;border-radius:3px;box-shadow:0 0 0 1px rgba(255,255,255,.08),0 8px 28px rgba(0,0,0,.45);color:#000;font-family:Calibri,Carlito,"Segoe UI",Arial,sans-serif;line-height:1.12}
.pslide:hover .slide{box-shadow:0 0 0 3px var(--amber),0 8px 28px rgba(0,0,0,.45)}
.slide .abs{position:absolute}
.slide .bar-a{background:#E48312}.slide .bar-r{background:#BD582C}
.slide .rule{border-top:1px solid #808080;height:0}
.slide .light{font-family:"Calibri Light",Calibri,Carlito,"Segoe UI",Arial,sans-serif;font-weight:300;color:#404040}
.slide .tnr{font-family:"Times New Roman",Times,serif}
.slide table{border-collapse:collapse;table-layout:fixed;width:100%}
.slide td{border:1px solid #000;vertical-align:top;padding:.18cqw .2cqw;overflow-wrap:anywhere;white-space:pre-wrap}
.slide .noimg{border:2px dashed #B9C2CA;display:flex;align-items:center;justify-content:center;color:#8592A0;font-family:var(--font);font-size:2.2cqw;text-align:center;padding:2cqw}
.slide .lbl-chip{border:0;border-radius:0;background:rgba(0,0,0,.65);color:#fff;padding:0 .45cqw;display:flex;align-items:center;font-weight:300;cursor:inherit;white-space:nowrap}
.slide .plain{display:flex;align-items:center;white-space:nowrap;padding:0 .45cqw}

/* Radiographs PDF */
.ip-page { page-break-after: always; break-after: page; display: flex; flex-direction: column; height: 272mm; }
.ip-page:last-child { page-break-after: auto; break-after: auto; }
.ip-strip { border-bottom: 1.5px solid #000; padding-bottom: 4pt; font-size: 10.5pt; line-height: 1.35; }
.ip-title { font: bold 16pt "Times New Roman", serif; text-decoration: underline; text-align: center; margin: 8pt 0; }
.ip-imgs { flex: 1; display: flex; gap: 4mm; align-items: center; justify-content: center; min-height: 0; }
.ip-imgs img { max-height: 225mm; max-width: 100%; object-fit: contain; min-width: 0; }
.ip-imgs.n2 img { max-width: calc(50% - 2mm); }
.ip-imgs.n3 img { max-width: calc(33.3% - 3mm); }
/* Discharge helpers */
.drug-btns { display: flex; flex-wrap: wrap; gap: .35rem; }
.drug-btns .chip { font-size: .78rem; }
.drug-btns .chip.suggest { border-color: var(--red); color: var(--red); }
.dc-out { display: grid; gap: .75rem; }
.dc-out .out-row { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; justify-content: space-between; border: 1px solid var(--line); border-radius: var(--radius); padding: .6rem; }
.dc-out .out-row > div { flex: 1; min-width: 200px; }
.dc-imgs { display: flex; flex-wrap: wrap; gap: .5rem; }
.dc-imgs .kindbox { border: 1px solid var(--line); border-radius: 6px; padding: .4rem; min-width: 140px; }
.dc-imgs .kindbox b { font-size: .8rem; display: block; margin-bottom: .25rem; }
.dc-imgs .kindbox.missing b { color: var(--red); }
.dc-imgs .mini { display: flex; gap: .25rem; flex-wrap: wrap; margin-bottom: .3rem; }
.dc-imgs .mini img { width: 48px; height: 40px; object-fit: cover; border-radius: 3px; background: #000; }
.deck-add-row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-top: .5rem; }
.deck-add-row select { flex: 1; min-width: 200px; width: auto; }
.op-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem .75rem; }
.op-grid .span2 { grid-column: 1 / -1; }
@media (max-width: 520px) { .op-grid { grid-template-columns: 1fr; } }
.po-filter { display: flex; flex-wrap: wrap; gap: .6rem; align-items: flex-end; margin-bottom: .4rem; }
.po-filter label { min-width: 150px; }
.po-table { min-width: 860px; }


/* ================================================================
   Windows 98 skin (overrides the earlier component styles)
   ================================================================ */
body { background: var(--desk); color: var(--ink); font-family: var(--font); font-size: 15px; -webkit-font-smoothing: none; }
a { color: var(--brand); }
h2 { font-weight: 700; }
input, select, textarea {
  font-family: var(--field-font); font-size: 14px; color: var(--ink);
  background: var(--field); border: 0; border-radius: 0; box-shadow: var(--sunken); padding: .4rem .5rem;
}
input:disabled { background: var(--bg); color: var(--muted); }
input:focus, select:focus, textarea:focus { outline: 1px dotted var(--ink); outline-offset: -4px; }
label { color: var(--ink); }

/* App window frame: title bar + menu bar + tabs */
.top { background: var(--bg); color: var(--ink); border: 0; box-shadow: var(--window); display: block; padding: 3px 3px 0; padding-top: max(3px, env(safe-area-inset-top)); }
.titlebar { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: 3px 4px 3px 6px;
  background: linear-gradient(90deg, var(--brand), var(--brand-2)); color: #fff; }
.brand { display: flex; align-items: center; gap: .4rem; color: #fff; font-weight: 700; font-size: 15px; letter-spacing: .02em; text-decoration: none; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.brand-ico { width: 16px; height: 16px; flex: none; background: #fff; position: relative; box-shadow: inset -1px -1px #808080; }
.brand-ico::before, .brand-ico::after { content: ""; position: absolute; background: #c00000; }
.brand-ico::before { left: 6px; top: 2px; width: 4px; height: 12px; }
.brand-ico::after { left: 2px; top: 6px; width: 12px; height: 4px; }
.winbtns { display: flex; gap: 2px; flex: none; }
.winbtns i { font-style: normal; width: 16px; height: 14px; line-height: 12px; font-size: 11px; text-align: center; color: #000; background: var(--bg); box-shadow: var(--raised); font-family: var(--field-font); font-weight: 700; }
.winbtns i:last-child { margin-left: 2px; }
.menubar { display: flex; gap: .6rem; align-items: center; padding: 3px 6px; font-size: 13px; }
.sync { background: none; color: var(--ink); padding: 0; border-radius: 0; font-size: 13px; }
.sync.ok { color: var(--ok); }
.sync.warn { background: none; color: var(--red); font-weight: 700; }
.ver { opacity: 1; color: var(--muted); font-size: 12px; margin-left: auto; }
#nav { display: flex; gap: 0; padding: 2px 4px 0; width: auto; margin: 0; overflow-x: auto; }
#nav a {
  color: var(--ink); opacity: 1; background: var(--bg); padding: .35rem .7rem .3rem; margin-right: -1px; border-radius: 0;
  box-shadow: inset 1px 1px var(--hi), inset -1px 0 var(--dk), inset -2px 0 var(--lo); position: relative; top: 2px; font-size: 14px;
}
#nav a.on { top: 0; padding-bottom: .5rem; font-weight: 700; background: var(--bg); color: var(--ink); z-index: 1;
  box-shadow: inset 1px 1px var(--hi), inset 2px 2px var(--face), inset -1px 0 var(--dk), inset -2px 0 var(--lo); }
@media (min-width: 760px) { #nav { width: auto; margin-left: 0; } .top { padding-bottom: 0; } }

main { padding-top: 12px; }

/* Windows (cards) */
.card, .stats div, .chk, .ot-row, .chart, .deck-case, .staff-unit {
  background: var(--card); border: 0; border-radius: 0; box-shadow: var(--window);
}
.card { padding: 10px; }
.card > h3:first-child, .card > .row-between:first-child > h3, .sheet > .row-between > h3 {
  background: linear-gradient(90deg, var(--brand), var(--brand-2)); color: #fff; margin: -7px -7px 10px; padding: 4px 8px; font-size: 15px;
}
.card > .row-between:first-child { margin: -7px -7px 10px; background: linear-gradient(90deg, var(--brand), var(--brand-2)); color: #fff; padding: 2px 4px 2px 8px; align-items: center; }
.card > .row-between:first-child > h3 { margin: 0; padding: 2px 0; background: none; }
.card > .row-between:first-child .muted, .card > .row-between:first-child label { color: #fff; }
.card > .row-between:first-child .btn { min-height: 26px; padding: .1rem .6rem; }
.toolbar h2, main > h2 { color: #fff; text-shadow: 1px 1px 0 #000; }
.toolbar h2 .muted, main > h2 .muted { color: #e0ffff; }

/* Group boxes */
.form fieldset, .lab-group { border: 0; box-shadow: inset 1px 1px var(--lo), inset -1px -1px var(--hi), inset 2px 2px var(--hi), inset -2px -2px var(--lo); padding: 14px 10px 10px; margin-bottom: 12px; position: relative; }
.form fieldset > legend, .lab-group legend { color: var(--ink); background: var(--card); padding: 0 4px; font-weight: 700; }
.form > fieldset.card { box-shadow: var(--window); }
.form > fieldset.card > legend { background: linear-gradient(90deg, var(--brand), var(--brand-2)); color: #fff; padding: 3px 8px; }

/* Buttons */
.btn, .chip, .icon, .link.btn, .winbtn {
  font-family: var(--font); color: var(--ink); background: var(--bg); border: 0; border-radius: 0; box-shadow: var(--raised); min-height: 32px;
}
.btn:active:not(:disabled), .chip:active { box-shadow: var(--sunken); }
.btn.primary { background: var(--bg); color: var(--ink); font-weight: 700; box-shadow: inset 0 0 0 1px var(--dk), inset -2px -2px var(--dk), inset 2px 2px var(--hi), inset -3px -3px var(--lo); }
.btn.danger { color: var(--red); }
.btn:disabled { color: var(--lo); text-shadow: 1px 1px var(--hi); opacity: 1; }
.btn:focus-visible, .chip:focus-visible { outline: 1px dotted var(--ink); outline-offset: -5px; }
.chip { border-radius: 0; padding: .3rem .7rem; }
.chip.on { background: var(--bg); color: var(--ink); font-weight: 700; box-shadow: var(--sunken); }
.icon { background: none; box-shadow: none; min-height: auto; color: var(--ink); }
.icon:hover:not(:disabled) { box-shadow: var(--raised); background: var(--bg); }
.link { color: var(--brand); text-decoration: underline; }

/* Badges, pills, tags: plain boxed labels */
.badge, .badge-select, .pill, .tag, .bed { border-radius: 0; font-weight: 700; }
.badge, .badge-select { background: var(--field); color: var(--ink); box-shadow: var(--sunken); }
.st-preop { color: #7a5200; } .st-posted { color: var(--brand); } .st-postop { color: var(--ok); } .st-discharged { color: var(--muted); }
.pill { background: var(--field); color: var(--ink); box-shadow: var(--sunken); }
.pill.ok { color: var(--ok); }
.tag { background: var(--field); color: var(--ink); border: 1px solid var(--lo); }
.tag.inv, .tag.flag { color: var(--red); border-color: var(--red); }
.tag.flag { font-weight: 700; }
.tag.task { color: var(--brand); border-color: var(--brand); }
.tag.ok { color: var(--ok); border-color: var(--ok); }

/* Home: hospital heading */
.hosp { background: var(--card); box-shadow: var(--window); padding: 12px 10px; margin-bottom: 12px; text-align: center; line-height: 1.35; }
.hosp-l1 { font-weight: 700; font-size: 1.15rem; color: var(--brand); letter-spacing: .03em; }
.hosp-l2 { font-weight: 700; font-size: 1rem; }
.hosp-l3 { font-weight: 700; font-size: .95rem; color: var(--red); }
.hosp-l4 { font-size: .85rem; color: var(--muted); margin-top: 4px; }

/* Stats: sunken readouts */
.stats div { padding: .5rem; }
.stats b { font-size: 1.5rem; color: var(--brand); }
.stats span { color: var(--ink); }

/* Case cards */
.case-card { color: var(--ink); }
.case-card:hover { outline: 1px dotted var(--ink); outline-offset: -5px; }
.cc-plan { color: var(--brand); }

/* Win98 progress bar: navy blocks in a sunken trough */
.progress { height: 14px; background: var(--field); box-shadow: var(--sunken); border-radius: 0; padding: 2px; }
.progress i { background: repeating-linear-gradient(90deg, var(--brand) 0 8px, transparent 8px 10px); height: 100%; }
.progress i.ok { background: repeating-linear-gradient(90deg, var(--ok) 0 8px, transparent 8px 10px); }

/* List views / tables: white, sunken, grey raised headers */
.table-wrap { background: var(--field); border: 0; border-radius: 0; box-shadow: var(--sunken); padding: 2px; }
.board, .flow { background: var(--field); }
.board th, .flow thead th {
  background: var(--bg); color: var(--ink); box-shadow: var(--raised); font-weight: 700; border: 0;
}
.board.detail th.ph { background: var(--bg); }
.flow tr.grp th { background: #e8e8e8; color: var(--brand); box-shadow: none; }
.board tr[data-go]:hover, .picker tr[data-row]:hover { background: #e8e8f8; }
.picker tr.picked, .board tr.picked { background: var(--brand); color: #fff; }
.picker tr.picked .muted, .picker tr.picked .miss, .picker tr.picked a { color: #fff; }
.flow .set-acts .icon { color: var(--ink); }
.board td, .flow td { border-bottom: 1px solid #d0d0d0; }

/* Work-up rows, checklists */
.work-row { border-left: 4px solid var(--ok); }
.work-row.missing { border-left-color: var(--red); }

/* Sheets / dialogs / toast */
#modal.sheet-wrap { background: rgba(0, 64, 64, .55); }
.sheet { box-shadow: var(--window); background: var(--card); }
#toast { background: var(--warn-bg); color: var(--ink); border-radius: 0; box-shadow: 2px 2px 0 rgba(0,0,0,.5); border: 1px solid var(--ink); font-family: var(--font); }
.notice { background: var(--warn-bg); border: 1px solid var(--ink); border-radius: 0; }

/* Misc */
.empty { color: #fff; text-shadow: 1px 1px 0 #000; }
.card .empty, .table-wrap .empty { color: var(--muted); text-shadow: none; }
.muted { color: var(--muted); }
.flag, .is-flag input, .is-flag select, input.is-flag, .miss { color: var(--red) !important; }
.jump { background: var(--desk); }
.ot-preview-title { background: var(--field); box-shadow: var(--sunken); border-radius: 0; font-family: Arial, sans-serif; }
.chart-form, .impl-table tfoot td { background: var(--bg); border-radius: 0; }
.deck-previews { background: var(--desk); border-radius: 0; box-shadow: var(--sunken); }
.deck-previews .meta { color: #fff; }
.gate { box-shadow: var(--window); }
.lh-preview { border-radius: 0; box-shadow: var(--sunken); border: 0; }
.dthumb, .pthumb, .thumb { border-radius: 0; }
.hidden-cases summary { color: var(--ink); }
.po-table td:nth-child(6)::before { content: none; }
@media (max-width: 640px) { .po-table td:nth-child(6)::before { content: "Surgery "; } }
/* Keep printed documents in their own fonts */
#print, #print * { -webkit-font-smoothing: auto; }
@media print {
  body { background: #fff !important; }
}
@media (max-width: 640px) {
  .po-table { min-width: 0; }
}
.picker tr.picked td { color: #fff !important; }

/* Dictation button on text boxes */
.mic-host { position: relative; }
.mic-host > textarea { padding-right: 2.6rem; }
.mic { position: absolute; right: 6px; bottom: 6px; width: 32px; height: 30px; padding: 0; font-size: 15px; line-height: 1;
  background: var(--bg); border: 0; box-shadow: var(--raised); cursor: pointer; }
.mic.on { box-shadow: var(--sunken); background: #ffd0d0; animation: mic-pulse 1s steps(2) infinite; }
@keyframes mic-pulse { 50% { background: #ff8080; } }
@media (prefers-reduced-motion: reduce) { .mic.on { animation: none; } }
/* Report photo */
.ocr-row { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.ocr-status { flex: 1; min-width: 200px; }
.ocr-text { white-space: pre-wrap; font-size: .75rem; max-height: 220px; overflow: auto; background: var(--field); box-shadow: var(--sunken); padding: .4rem; }
.lab-in.from-photo input, .lab-in.from-photo select { background: #ffffcc; outline: 2px solid #000080; outline-offset: -2px; }
.lab-in.photo-unsure input { background: #ffd8a8; outline-color: #c00000; }
.lab-in.photo-unsure .lab-name::after { content: " ?"; color: #c00000; font-weight: 700; }

/* ECG / ECHO / PAC in the investigations section */
.workup { display: grid; grid-template-columns: 1fr; gap: .6rem; margin-top: .75rem; padding-top: .6rem; border-top: 1px solid var(--lo); }
.workup > label:nth-child(3) { max-width: 420px; } /* PAC */
.workup .pac-pending { grid-column: 1 / -1; }
.workup .pac-pending[hidden] { display: none; }
.ecg-check { display: flex; align-items: center; gap: .45rem; font-weight: 700; white-space: nowrap; }
.ecg-check input { transform: scale(1.3); }
@media (max-width: 640px) { .workup { grid-template-columns: 1fr; } }
.deck-uploads { margin-top: .6rem; align-items: center; }
.impl-how { margin-top: .2rem; font-size: .72rem; line-height: 1.25; }


/* ================================================================
   Alternative looks (Settings → Look; per device). Windows 98 is the
   default above; each block below re-skins it through the same tokens.
   ================================================================ */

/* ---- Windows XP ---- */
html[data-ui="xp"] {
  --desk: #3a6ea5; --bg: #ece9d8; --card: #ece9d8; --field: #fff; --ink: #000; --muted: #444;
  --brand: #0a246a; --brand-2: #3a6ea5; --lo: #aca899; --face: #f5f4ea;
  --font: Tahoma, Verdana, "Segoe UI", sans-serif; --field-font: Tahoma, Verdana, sans-serif;
  --raised: inset 0 0 0 1px #003c74; --sunken: inset 0 0 0 1px #7f9db9; --window: 0 0 0 1px #0831d9, 2px 3px 8px rgba(0,0,0,.35);
}
html[data-ui="xp"] body { background: linear-gradient(180deg, #2f6fd1 0%, #6ea6ea 38%, #9fd06a 62%, #4f9a2f 100%) fixed; -webkit-font-smoothing: auto; }
html[data-ui="xp"] .titlebar, html[data-ui="xp"] .card > h3:first-child, html[data-ui="xp"] .card > .row-between:first-child,
html[data-ui="xp"] .form > fieldset.card > legend, html[data-ui="xp"] .sheet > .row-between > h3 {
  background: linear-gradient(180deg, #0997ff 0%, #0053ee 10%, #0050ee 45%, #0066ff 90%, #0055e5 100%);
}
html[data-ui="xp"] .top { border-radius: 8px 8px 0 0; overflow: hidden; }
html[data-ui="xp"] .card, html[data-ui="xp"] .hosp, html[data-ui="xp"] .stats div { border-radius: 8px 8px 3px 3px; overflow: hidden; }
html[data-ui="xp"] .form > fieldset.card > legend { border-radius: 6px 6px 0 0; }
html[data-ui="xp"] .winbtns i { border-radius: 3px; background: linear-gradient(#fff, #d6d3c9); }
html[data-ui="xp"] .winbtns i:last-child { background: linear-gradient(#e8836c, #c0451f); color: #fff; }
html[data-ui="xp"] .btn, html[data-ui="xp"] .chip { border-radius: 3px; background: linear-gradient(180deg, #fff 0%, #ecebe6 85%, #d6d0c5 100%); }
html[data-ui="xp"] .btn.primary { box-shadow: inset 0 0 0 1px #003c74, inset 0 0 0 2px #7ab0f7; }
html[data-ui="xp"] #nav a { border-radius: 4px 4px 0 0; background: linear-gradient(#fff, #ecebe6); box-shadow: inset 0 0 0 1px #919b9c; }
html[data-ui="xp"] #nav a.on { box-shadow: inset 0 0 0 1px #919b9c, inset 0 3px 0 #e68b2c; }
html[data-ui="xp"] .progress i { background: repeating-linear-gradient(90deg, #2fd02f 0 8px, transparent 8px 10px); }
html[data-ui="xp"] .toolbar h2, html[data-ui="xp"] main > h2 { text-shadow: 1px 1px 2px rgba(0,0,0,.6); }

/* ---- Classic Mac (OS 9 Platinum) ---- */
html[data-ui="mac"] {
  --desk: #6f7fb1; --bg: #dddddd; --card: #eeeeee; --field: #fff; --ink: #000; --muted: #555;
  --brand: #000; --brand-2: #000; --lo: #888; --face: #fff;
  --font: Geneva, "Chicago", Charcoal, Verdana, sans-serif; --field-font: Geneva, Verdana, sans-serif;
  --raised: inset 0 0 0 1px #000, inset 1px 1px #fff, inset -2px -2px #aaa;
  --sunken: inset 0 0 0 1px #888, inset 1px 1px #555;
  --window: 0 0 0 1px #000, 2px 2px 0 rgba(0,0,0,.45);
}
html[data-ui="mac"] body { background: #6f7fb1 repeating-linear-gradient(45deg, rgba(255,255,255,.04) 0 2px, transparent 2px 4px); }
html[data-ui="mac"] .titlebar, html[data-ui="mac"] .card > h3:first-child, html[data-ui="mac"] .card > .row-between:first-child,
html[data-ui="mac"] .form > fieldset.card > legend, html[data-ui="mac"] .sheet > .row-between > h3 {
  background: repeating-linear-gradient(180deg, #e8e8e8 0 1px, #b8b8b8 1px 2px); color: #000;
}
html[data-ui="mac"] .titlebar { justify-content: center; position: relative; }
html[data-ui="mac"] .brand, html[data-ui="mac"] .card > h3:first-child, html[data-ui="mac"] .card > .row-between:first-child,
html[data-ui="mac"] .card > .row-between:first-child .muted, html[data-ui="mac"] .card > .row-between:first-child label { color: #000; }
html[data-ui="mac"] .brand { background: #e8e8e8; padding: 0 .5rem; }
html[data-ui="mac"] .card > h3:first-child { text-align: center; justify-content: center; }
html[data-ui="mac"] .winbtns { position: absolute; left: 8px; }
html[data-ui="mac"] .winbtns i { font-size: 0; width: 12px; height: 12px; background: #ddd; box-shadow: inset 0 0 0 1px #000; }
html[data-ui="mac"] .winbtns i:nth-child(2) { display: none; }
html[data-ui="mac"] .winbtns i:last-child { position: absolute; left: calc(100vw - 48px); }
html[data-ui="mac"] .btn, html[data-ui="mac"] .chip { border-radius: 6px; }
html[data-ui="mac"] .btn.primary { box-shadow: 0 0 0 3px #000, inset 0 0 0 1px #000, inset 1px 1px #fff; margin: 3px; }
html[data-ui="mac"] .hosp-l1, html[data-ui="mac"] .stats b { color: #000; }
html[data-ui="mac"] .picker tr.picked, html[data-ui="mac"] .board tr.picked { background: #000; }
html[data-ui="mac"] .progress i { background: repeating-linear-gradient(90deg, #6b6bd6 0 10px, #9a9aea 10px 20px); }

/* ---- DOS terminal ---- */
html[data-ui="dos"] {
  --desk: #000; --bg: #000; --card: #000; --field: #000; --ink: #33ff66; --muted: #1fbf4a; --line: #33ff66;
  --hi: #33ff66; --lo: #1a8a34; --dk: #33ff66; --face: #000; --brand: #33ff66; --brand-2: #33ff66; --brand-ink: #000;
  --red: #ff5f5f; --red-bg: #000; --ok: #33ff66; --ok-bg: #000; --warn: #ffd23f; --warn-bg: #000; --blue-bg: #000;
  --font: "VT323", "Courier New", monospace; --field-font: "VT323", "Courier New", monospace;
  --raised: inset 0 0 0 1px #33ff66; --sunken: inset 0 -1px 0 #33ff66; --window: inset 0 0 0 1px #33ff66, inset 0 0 0 3px #000, inset 0 0 0 4px #33ff66;
}
html[data-ui="dos"] body { background: #000; color: #33ff66; font-size: 19px; text-shadow: 0 0 4px rgba(51,255,102,.45); }
html[data-ui="dos"] input, html[data-ui="dos"] select, html[data-ui="dos"] textarea { font-size: 19px; color: #33ff66; background: #000; }
html[data-ui="dos"] .titlebar, html[data-ui="dos"] .card > h3:first-child, html[data-ui="dos"] .card > .row-between:first-child,
html[data-ui="dos"] .form > fieldset.card > legend, html[data-ui="dos"] .sheet > .row-between > h3 { background: #33ff66; color: #000; text-shadow: none; }
html[data-ui="dos"] .brand, html[data-ui="dos"] .card > .row-between:first-child .muted, html[data-ui="dos"] .card > .row-between:first-child label { color: #000; }
html[data-ui="dos"] .brand-ico, html[data-ui="dos"] .winbtns { display: none; }
html[data-ui="dos"] .top, html[data-ui="dos"] #nav a, html[data-ui="dos"] #nav a.on { background: #000; color: #33ff66; }
html[data-ui="dos"] #nav a.on { background: #33ff66; color: #000; }
html[data-ui="dos"] .btn, html[data-ui="dos"] .chip { background: #000; color: #33ff66; }
html[data-ui="dos"] .btn::before { content: "["; } html[data-ui="dos"] .btn::after { content: "]"; }
html[data-ui="dos"] .btn.primary { background: #33ff66; color: #000; text-shadow: none; }
html[data-ui="dos"] .chip.on { background: #33ff66; color: #000; }
html[data-ui="dos"] .hosp-l1, html[data-ui="dos"] .hosp-l2, html[data-ui="dos"] .stats b { color: #33ff66; }
html[data-ui="dos"] .hosp-l3 { color: #ffd23f; }
html[data-ui="dos"] .table-wrap, html[data-ui="dos"] .board, html[data-ui="dos"] .flow, html[data-ui="dos"] .board th, html[data-ui="dos"] .flow thead th { background: #000; color: #33ff66; }
html[data-ui="dos"] .board td, html[data-ui="dos"] .flow td { border-bottom: 1px dashed #1a8a34; }
html[data-ui="dos"] .picker tr.picked, html[data-ui="dos"] .board tr.picked { background: #33ff66; color: #000; }
html[data-ui="dos"] .tag, html[data-ui="dos"] .badge, html[data-ui="dos"] .badge-select, html[data-ui="dos"] .pill { background: #000; }
html[data-ui="dos"] .progress i, html[data-ui="dos"] .progress i.ok { background: repeating-linear-gradient(90deg, #33ff66 0 10px, transparent 10px 12px); }
html[data-ui="dos"] #toast { background: #000; color: #33ff66; border-color: #33ff66; }
html[data-ui="dos"] .lab-in.from-photo input, html[data-ui="dos"] .lab-in.from-photo select { background: #002a10; }
html[data-ui="dos"] .empty { text-shadow: none; }

/* ---- Modern looks (Modern clinical, Midnight, Glass, Material) ----
   html.flat turns off the retro window chrome; each look sets the tokens. */
html.flat {
  --top-bg: #13294b; --top-ink: #ffffff; --top-muted: #c9d4ea; --top-accent: #c8102e;
  --nav-on-bg: var(--bg); --nav-on-ink: var(--brand); --head-ink: var(--brand);
  --btn-bg: var(--card); --btn-ink: var(--ink); --primary-bg: var(--brand); --primary-ink: #fff;
  --rc: 10px; --rb: 8px; --body-bg: var(--bg); --blur: none; --th-bg: var(--brand); --th-ink: #fff;
  --raised: inset 0 0 0 1px var(--line); --sunken: inset 0 0 0 1px var(--line); --window: 0 0 0 1px var(--line), 0 1px 3px rgba(0,0,0,.06);
}
html.flat body { background: var(--body-bg); -webkit-font-smoothing: antialiased; }
html.flat .top { background: var(--top-bg); box-shadow: none; border-bottom: 3px solid var(--top-accent); padding: 0; backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); }
html.flat .titlebar { background: none; padding: .6rem 16px .2rem; }
html.flat .brand { color: var(--top-ink); }
html.flat .winbtns { display: none; }
html.flat .menubar { padding: 0 16px; }
html.flat .menubar .sync, html.flat .menubar .ver { color: var(--top-muted); }
html.flat #nav { padding: 4px 12px 0; }
html.flat #nav a { background: none; color: var(--top-muted); box-shadow: none; top: 0; border-radius: var(--rb) var(--rb) 0 0; }
html.flat #nav a.on { background: var(--nav-on-bg); color: var(--nav-on-ink); box-shadow: none; }
html.flat .card, html.flat .hosp, html.flat .stats div, html.flat .deck-case, html.flat .chart, html.flat .staff-unit, html.flat .ot-row, html.flat .sheet {
  border-radius: var(--rc); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
}
html.flat .card > h3:first-child, html.flat .card > .row-between:first-child, html.flat .sheet > .row-between > h3 { background: none; color: var(--head-ink); margin: 0 0 .6rem; padding: 0; }
html.flat .card > .row-between:first-child > h3 { color: var(--head-ink); }
html.flat .card > .row-between:first-child .muted, html.flat .card > .row-between:first-child label { color: var(--muted); }
html.flat .form > fieldset.card > legend { background: none; color: var(--head-ink); padding: 0; font-size: 1.05rem; }
html.flat .form fieldset, html.flat .lab-group { box-shadow: inset 0 0 0 1px var(--line); border-radius: var(--rb); }
html.flat .form > fieldset.card { box-shadow: var(--window); }
html.flat .btn, html.flat .chip { border-radius: var(--rb); background: var(--btn-bg); color: var(--btn-ink); }
html.flat .btn.primary, html.flat .chip.on { background: var(--primary-bg); color: var(--primary-ink); box-shadow: none; }
html.flat .btn:disabled { text-shadow: none; opacity: .5; }
html.flat input, html.flat select, html.flat textarea { border-radius: calc(var(--rb) - 1px); }
html.flat .toolbar h2, html.flat main > h2 { color: var(--ink); text-shadow: none; }
html.flat .toolbar h2 .muted, html.flat main > h2 .muted { color: var(--muted); }
html.flat .empty { color: var(--muted); text-shadow: none; }
html.flat .table-wrap { border-radius: var(--rc); overflow: auto; }
html.flat .board th, html.flat .flow thead th { background: var(--th-bg); color: var(--th-ink); box-shadow: none; }
html.flat .flow tr.grp th { background: var(--bg); color: var(--head-ink); }
html.flat .progress { border-radius: 4px; box-shadow: none; background: var(--line); }
html.flat .progress i { background: var(--red); border-radius: 3px; }
html.flat .progress i.ok { background: var(--ok); }
html.flat .jump { background: var(--body-bg); }
html.flat .picker tr.picked, html.flat .board tr.picked { background: var(--primary-bg); color: var(--primary-ink); }
html.flat .hosp-l1, html.flat .stats b { color: var(--head-ink); }
html.flat .tag, html.flat .badge, html.flat .badge-select, html.flat .pill { border-radius: 999px; }
html.flat .tag { padding: .12rem .55rem; }
html.flat #toast { border-radius: 10px; border: 0; background: var(--ink); color: var(--card); box-shadow: 0 6px 20px rgba(0,0,0,.25); }
html.flat .empty { text-shadow: none; }

/* Modern clinical — white, navy, red */
html[data-ui="modern"] {
  --desk: #f2f4f8; --bg: #f2f4f8; --card: #fff; --field: #fff; --ink: #111a2e; --muted: #5c6780; --line: #dde3ec;
  --hi: #fff; --lo: #d9dfea; --face: #fff; --brand: #13294b; --brand-2: #13294b; --red: #c8102e; --ok: #1d7a46;
  --font: Helvetica, "Helvetica Neue", Arial, sans-serif; --field-font: Helvetica, "Helvetica Neue", Arial, sans-serif;
}

/* Midnight — dark, for night duty */
html[data-ui="midnight"] {
  --desk: #0d1424; --bg: #0d1424; --card: #151f35; --field: #0f182b; --ink: #e6ebf5; --muted: #93a0bb; --line: #26324d;
  --hi: #26324d; --lo: #26324d; --dk: #000; --face: #151f35; --brand: #5ec2c6; --brand-2: #5ec2c6; --red: #ff6b7f; --red-bg: #2a1520;
  --ok: #6fd39a; --ok-bg: #12291f; --warn: #f3b860; --warn-bg: #2a2212; --blue-bg: #17233d;
  --top-bg: #0a1020; --top-accent: #5ec2c6; --nav-on-bg: #0d1424; --nav-on-ink: #e6ebf5; --head-ink: #e6ebf5;
  --primary-bg: #5ec2c6; --primary-ink: #06222a; --btn-bg: #1b2742; --th-bg: #1b2742; --th-ink: #cfe3f5;
  --window: 0 0 0 1px #22304c; --font: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; --field-font: var(--font);
  color-scheme: dark;
}
html[data-ui="midnight"] .tag { background: transparent; }
html[data-ui="midnight"] .lab-in.from-photo input, html[data-ui="midnight"] .lab-in.from-photo select { background: #2b2a12; color: var(--ink); }
html[data-ui="midnight"] .hosp-l3 { color: var(--red); }
html[data-ui="midnight"] .slide { color: #000; }

/* Glass — frosted cards on a soft gradient (iPhone style) */
html[data-ui="glass"] {
  --desk: #e9eefb; --bg: rgba(255,255,255,.45); --card: rgba(255,255,255,.62); --field: rgba(255,255,255,.85); --ink: #1c1c1e; --muted: #5d6370; --line: rgba(60,70,100,.14);
  --hi: #fff; --lo: rgba(60,70,100,.18); --face: #fff; --brand: #0a4fbf; --brand-2: #0a4fbf; --red: #e0283c; --ok: #1f9d55;
  --top-bg: rgba(255,255,255,.55); --top-ink: #1c1c1e; --top-muted: #4a5163; --top-accent: transparent; --nav-on-bg: rgba(255,255,255,.85); --nav-on-ink: #0a4fbf;
  --head-ink: #1c1c1e; --primary-bg: #0a84ff; --primary-ink: #fff; --btn-bg: rgba(255,255,255,.75); --th-bg: rgba(255,255,255,.7); --th-ink: #1c1c1e;
  --rc: 18px; --rb: 12px; --blur: saturate(160%) blur(18px);
  --body-bg: radial-gradient(1200px 700px at 10% -10%, #c7d7ff 0%, transparent 60%), radial-gradient(900px 600px at 110% 10%, #ffd6e7 0%, transparent 55%), radial-gradient(900px 700px at 50% 120%, #c9f2e6 0%, transparent 60%), #eef1f8;
  --window: 0 0 0 1px rgba(255,255,255,.7), 0 8px 24px rgba(30,40,80,.10);
  --font: -apple-system, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif; --field-font: var(--font);
}
html[data-ui="glass"] body { background-attachment: fixed; }
html[data-ui="glass"] .top { border-bottom: 1px solid rgba(255,255,255,.6); }
html[data-ui="glass"] .brand-ico { box-shadow: none; border-radius: 4px; }

/* Material — tonal surfaces, pill buttons (Android style) */
html[data-ui="material"] {
  --desk: #f7f2fa; --bg: #f7f2fa; --card: #ffffff; --field: #fff; --ink: #1d1b20; --muted: #625b71; --line: #e7e0ec;
  --hi: #fff; --lo: #cac4d0; --face: #fff; --brand: #4f378b; --brand-2: #4f378b; --red: #b3261e; --ok: #146c2e; --blue-bg: #eaddff;
  --top-bg: #4f378b; --top-accent: #d0bcff; --top-muted: #e8def8; --nav-on-bg: #f7f2fa; --nav-on-ink: #4f378b; --head-ink: #4f378b;
  --primary-bg: #6750a4; --primary-ink: #fff; --btn-bg: #eaddff; --btn-ink: #21005d; --th-bg: #eaddff; --th-ink: #21005d;
  --rc: 16px; --rb: 999px; --window: 0 1px 2px rgba(0,0,0,.08), 0 2px 6px rgba(79,55,139,.08);
  --font: Roboto, "Segoe UI", Helvetica, Arial, sans-serif; --field-font: var(--font);
}
html[data-ui="material"] input, html[data-ui="material"] select, html[data-ui="material"] textarea { border-radius: 8px; }
html[data-ui="material"] .stats div { background: #eaddff; box-shadow: none; }
html[data-ui="material"] .hosp { background: #eaddff; box-shadow: none; }
html.flat .flow .set-acts .icon { color: var(--th-ink); opacity: .85; }

/* ---- Gradient looks (flat base + gradients on chrome, buttons, tiles, headings) ---- */
html.grad {
  --gink: #fff; --tg1: var(--g1); --tg2: var(--g3);
  --card: #fff; --field: #fff; --ink: #141a2c; --muted: #5d6680; --line: #e3e7f0; --hi: #fff; --lo: #e3e7f0; --face: #fff;
  --rc: 14px; --rb: 10px; --th-ink: #fff; --top-ink: #fff; --top-muted: rgba(255,255,255,.78); --top-accent: transparent;
  --font: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; --field-font: var(--font);
  --window: 0 1px 2px rgba(20,26,44,.05), 0 6px 18px rgba(20,26,44,.07);
}
html[data-ui="crimson"] {
  --g1: #13294b; --g2: #8a1538; --g3: #c8102e; --brand: #13294b; --brand-2: #13294b; --red: #c8102e; --ok: #1d7a46;
  --bg: #f4f2f6; --head-ink: #13294b; --nav-on-ink: #13294b; --primary-ink: #fff;
  --body-bg: radial-gradient(1000px 500px at 100% 0%, rgba(200,16,46,.10), transparent 60%), radial-gradient(900px 500px at 0% 100%, rgba(19,41,75,.10), transparent 60%), #f6f4f8;
}
html[data-ui="aurora"] {
  --g1: #5b3df5; --g2: #2f80ed; --g3: #14b8a6; --brand: #4338ca; --brand-2: #4338ca; --red: #e11d48; --ok: #0f9d6e;
  --bg: #f3f4fb; --head-ink: #3730a3; --nav-on-ink: #4338ca; --primary-ink: #fff;
  --body-bg: radial-gradient(1100px 600px at -10% -10%, rgba(91,61,245,.16), transparent 60%), radial-gradient(900px 600px at 110% 20%, rgba(20,184,166,.16), transparent 55%), radial-gradient(900px 600px at 50% 120%, rgba(47,128,237,.14), transparent 60%), #f5f6fc;
}
html.grad body{ background-attachment: fixed; }
html.grad .top{ background: linear-gradient(110deg, var(--g1) 0%, var(--g2) 55%, var(--g3) 100%); }
html.grad #nav a.on{ background: var(--bg); }
/* buttons */
html.grad .btn.primary, html.grad .chip.on {
  background: linear-gradient(120deg, var(--g1), var(--g2) 60%, var(--g3)); color: var(--gink); box-shadow: 0 4px 14px color-mix(in srgb, var(--g2) 35%, transparent);
}
html.grad .btn{ transition: transform .08s, box-shadow .15s; }
html.grad .btn:active:not(:disabled){ transform: translateY(1px); }
/* hospital heading + stat tiles */
html.grad .hosp{
  background: linear-gradient(135deg, var(--g1) 0%, var(--g2) 60%, var(--g3) 100%); color: var(--gink); box-shadow: 0 10px 28px color-mix(in srgb, var(--g1) 30%, transparent);
}
html.grad .hosp *{ color: var(--gink) !important; }
html.grad .hosp-l3{ opacity: .95; letter-spacing: .02em; }
html.grad .hosp-l4{ opacity: .8; }
html.grad .stats div{ position: relative; overflow: hidden; }
html.grad .stats div::before{
  content: ""; position: absolute; inset: 0 0 auto 0; height: 4px; background: linear-gradient(90deg, var(--g1), var(--g2), var(--g3));
}
html.grad .stats b{
  background: linear-gradient(120deg, var(--tg1), var(--tg2)); -webkit-background-clip: text; background-clip: text; color: transparent;
}
/* gradient headings */
html.grad .card > h3:first-child, html.grad .card > .row-between:first-child > h3, html.grad .form > fieldset.card > legend, html.grad .toolbar h2 {
  background: linear-gradient(100deg, var(--tg1), var(--tg2)); -webkit-background-clip: text; background-clip: text; color: transparent;
}
/* case cards: gradient edge */
html.grad .case-card{ border-left: 0; position: relative; }
html.grad .case-card::before{
  content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 4px; border-radius: 0 4px 4px 0; background: linear-gradient(180deg, var(--g1), var(--g2), var(--g3));
}
html.grad .progress i{ background: linear-gradient(90deg, var(--g3), #f59e0b); }
html.grad .progress i.ok{ background: linear-gradient(90deg, #10b981, #22c55e); }
/* tables */
html.grad .board th, html.grad .flow thead th{ background: linear-gradient(110deg, var(--g1), var(--g2)); color: var(--gink); }
html.grad .flow tr.grp th{ background: color-mix(in srgb, var(--g2) 8%, #fff); }
html.grad .picker tr.picked{ background: linear-gradient(110deg, var(--g1), var(--g2)); }
html.grad .deck-previews{ background: linear-gradient(135deg, #1b2236, #2b2140); }
/* one continuous gradient across a table's header row */
html.grad .board thead tr, html.grad .flow thead tr{ background: linear-gradient(110deg, var(--g1), var(--g2) 70%, var(--g3)); }
html.grad .board thead th, html.grad .flow thead th{ background: transparent; position: static; }

/* ---- Pastel gradient looks: soft colours, dark ink on the gradients ---- */
html[data-ui="blossom"], html[data-ui="mint"], html[data-ui="sorbet"] {
  --gink: #2e2540; --th-ink: #2e2540; --top-ink: #2e2540; --top-muted: rgba(46,37,64,.7); --primary-ink: #2e2540;
  --ink: #2a2638; --muted: #6b6680; --line: #ece6f2; --lo: #ece6f2;
}
html[data-ui="blossom"] {
  --g1: #ffd8c8; --g2: #fbc8de; --g3: #d8cbf6; --tg1: #c45a7e; --tg2: #7a5cc6;
  --brand: #8c4f86; --brand-2: #8c4f86; --red: #d22d4f; --ok: #2f8a5c;
  --bg: #fdf7fa; --head-ink: #7a4a80; --nav-on-ink: #7a4a80;
  --body-bg: radial-gradient(1000px 520px at 100% 0%, rgba(251,200,222,.45), transparent 60%), radial-gradient(900px 520px at 0% 100%, rgba(216,203,246,.45), transparent 60%), #fdf8fb;
}
html[data-ui="mint"] {
  --g1: #c4f0dd; --g2: #c4e3f8; --g3: #d6d4fa; --tg1: #1f8d6c; --tg2: #4b5fc4;
  --brand: #2c6e8f; --brand-2: #2c6e8f; --red: #d22d4f; --ok: #1f8d5c;
  --bg: #f5fbfa; --head-ink: #2a6680; --nav-on-ink: #2a6680;
  --body-bg: radial-gradient(1000px 520px at 0% 0%, rgba(196,240,221,.5), transparent 60%), radial-gradient(900px 520px at 100% 100%, rgba(214,212,250,.45), transparent 60%), #f6fbfb;
}
html[data-ui="sorbet"] {
  --g1: #fff0b3; --g2: #ffd5b0; --g3: #ffc2c8; --tg1: #c27a12; --tg2: #cf4560;
  --brand: #a5582a; --brand-2: #a5582a; --red: #d0213f; --ok: #2f8a5c;
  --bg: #fffaf4; --head-ink: #94512a; --nav-on-ink: #94512a;
  --body-bg: radial-gradient(1000px 520px at 100% 0%, rgba(255,213,176,.5), transparent 60%), radial-gradient(900px 520px at 0% 100%, rgba(255,240,179,.5), transparent 60%), #fffaf5;
}
html[data-ui="blossom"] .hosp, html[data-ui="mint"] .hosp, html[data-ui="sorbet"] .hosp { box-shadow: 0 10px 28px color-mix(in srgb, var(--g2) 55%, transparent); }
html[data-ui="blossom"] .deck-previews, html[data-ui="mint"] .deck-previews, html[data-ui="sorbet"] .deck-previews { background: linear-gradient(135deg, #3a3350, #4a3a52); }

/* pastel fonts: Blossom = Nunito (soft, rounded), Mint = Quicksand (airy), Sorbet = Fredoka headings + Nunito text (playful) */
html[data-ui="blossom"] { --font: "Nunito", -apple-system, "Segoe UI", Roboto, sans-serif; --field-font: var(--font); }
html[data-ui="mint"]    { --font: "Quicksand", "Nunito", -apple-system, "Segoe UI", Roboto, sans-serif; --field-font: var(--font); }
html[data-ui="sorbet"]  { --font: "Nunito", -apple-system, "Segoe UI", Roboto, sans-serif; --field-font: var(--font); }
html[data-ui="mint"] body { font-weight: 500; }
html[data-ui="mint"] input, html[data-ui="mint"] select, html[data-ui="mint"] textarea { font-weight: 600; }
html[data-ui="blossom"] .hosp, html[data-ui="blossom"] h1, html[data-ui="blossom"] h2, html[data-ui="blossom"] h3, html[data-ui="blossom"] legend, html[data-ui="blossom"] .brand { font-weight: 800; letter-spacing: .01em; }
html[data-ui="mint"] .hosp, html[data-ui="mint"] h1, html[data-ui="mint"] h2, html[data-ui="mint"] h3, html[data-ui="mint"] legend, html[data-ui="mint"] .brand { font-weight: 700; letter-spacing: .02em; }
html[data-ui="sorbet"] .hosp, html[data-ui="sorbet"] h1, html[data-ui="sorbet"] h2, html[data-ui="sorbet"] h3, html[data-ui="sorbet"] legend, html[data-ui="sorbet"] .brand,
html[data-ui="sorbet"] .stats b, html[data-ui="sorbet"] .cc-name, html[data-ui="sorbet"] .btn.primary, html[data-ui="sorbet"] #nav a { font-family: "Fredoka", "Nunito", sans-serif; font-weight: 500; letter-spacing: .01em; }
html[data-ui="sorbet"] .hosp-l1, html[data-ui="sorbet"] h2, html[data-ui="sorbet"] .cc-name { font-weight: 600; }

/* ---- Tangerine: warm cream canvas, bold Poppins, tangerine rounded tiles, violet accent, big soft corners ---- */
html[data-ui="tangerine"] {
  --or: #ec7a12; --or-2: #f59a3a; --vio: #9a6ae0;
  --desk: #fcefdf; --bg: #fdf4e8; --card: #fffcf7; --field: #fffaf3; --ink: #141210; --muted: #7a6f66; --line: #f1e4d3;
  --hi: #fff; --lo: #f1e4d3; --face: #fffcf7; --brand: #141210; --brand-2: #141210; --red: #d0262f; --ok: #2f8a5c;
  --top-bg: #fffcf7; --top-ink: #141210; --top-muted: #7a6f66; --top-accent: transparent;
  --nav-on-bg: var(--or); --nav-on-ink: #fff; --head-ink: #141210;
  --btn-bg: #fff3e4; --btn-ink: #3a2a1c; --primary-bg: var(--or); --primary-ink: #fff;
  --th-bg: var(--or); --th-ink: #fff;
  --rc: 28px; --rb: 14px; --blur: none;
  --window: 0 2px 6px rgba(120,70,20,.04), 0 18px 40px rgba(160,95,30,.08);
  --body-bg: #fcefdf;
  --font: "Poppins", -apple-system, "Segoe UI", Roboto, sans-serif; --field-font: var(--font);
}
html[data-ui="tangerine"] .top { box-shadow: 0 6px 24px rgba(160,95,30,.06); }
html[data-ui="tangerine"] .brand { font-weight: 700; letter-spacing: -.01em; }
html[data-ui="tangerine"] #nav { gap: 4px; padding-bottom: 6px; }
html[data-ui="tangerine"] #nav a { border-radius: 999px; font-weight: 600; color: #141210; }
html[data-ui="tangerine"] #nav a.on { box-shadow: 0 6px 16px rgba(236,122,18,.3); }
html[data-ui="tangerine"] h1, html[data-ui="tangerine"] h2, html[data-ui="tangerine"] h3, html[data-ui="tangerine"] legend { font-weight: 700; letter-spacing: -.01em; }
/* signature button: tangerine disc tucked behind the start of the label */
html[data-ui="tangerine"] .btn.primary {
  background: radial-gradient(circle at 1.15em 50%, var(--or) 1.25em, transparent 1.3em), transparent;
  color: #141210; font-weight: 700; padding-left: .75em; box-shadow: none; border-radius: 999px;
}
html[data-ui="tangerine"] .btn.primary:hover { background: radial-gradient(circle at 1.15em 50%, var(--or) 1.25em, transparent 1.3em), #fff1df; }
html[data-ui="tangerine"] .chip.on { box-shadow: 0 6px 14px rgba(236,122,18,.28); }
html[data-ui="tangerine"] .btn, html[data-ui="tangerine"] .chip { font-weight: 600; }
/* hospital panel: big bold black type on cream with a soft halo */
html[data-ui="tangerine"] .hosp { background: radial-gradient(420px 220px at 85% 50%, #f7ebdd, transparent 70%), var(--card); }
html[data-ui="tangerine"] .hosp-l1 { font-weight: 800; letter-spacing: -.01em; }
html[data-ui="tangerine"] .hosp-l3, html[data-ui="tangerine"] .hosp-l4 { color: var(--muted); }
/* stat tiles: number in a tangerine rounded square, like the spec icons */
html[data-ui="tangerine"] .stats b {
  display: inline-grid; place-items: center; min-width: 2.3em; height: 2.3em; padding: 0 .3em; margin-bottom: .3rem;
  background: var(--or); color: #fff; border-radius: 14px; box-shadow: 0 8px 18px rgba(236,122,18,.3);
}
html[data-ui="tangerine"] .stats span, html[data-ui="tangerine"] .stats small { font-weight: 600; color: #141210; }
/* cards + accents */
html[data-ui="tangerine"] .case-card { border-left: 0; position: relative; }
html[data-ui="tangerine"] .case-card::before { content: ""; position: absolute; left: 0; top: 14px; bottom: 14px; width: 4px; border-radius: 0 4px 4px 0; background: var(--or); }
html[data-ui="tangerine"] .cc-name { font-weight: 700; }
html[data-ui="tangerine"] .cc-plan { color: var(--vio); font-weight: 600; }
html[data-ui="tangerine"] .progress i { background: var(--or); }
html[data-ui="tangerine"] .flow tr.grp th { background: #fff1df; color: #141210; }
html[data-ui="tangerine"] .picker tr.picked { background: var(--or); color: #fff; }
html[data-ui="tangerine"] .deck-previews { background: #2a211b; }
html[data-ui="tangerine"] input:focus, html[data-ui="tangerine"] select:focus, html[data-ui="tangerine"] textarea:focus { outline: 2px solid var(--or-2); outline-offset: 1px; }
html[data-ui="tangerine"] .stats span { display: block; }
html[data-ui="tangerine"] .stats div { border-radius: 22px; padding: .7rem .4rem; }
html[data-ui="tangerine"] .case-card::before { top: 26px; bottom: 26px; }
html[data-ui="tangerine"] .btn.primary { white-space: nowrap; text-align: left; }

/* ---- Andry tree emblem (orthopaedics): title bar + hospital panel; takes each look's colour ---- */
.brand-ico, html[data-ui] .brand-ico {
  width: 18px; height: 22px; background: currentColor; box-shadow: none; border-radius: 0;
  -webkit-mask: url(../assets/andry-tree.svg) center / contain no-repeat; mask: url(../assets/andry-tree.svg) center / contain no-repeat;
}
.brand-ico::before, .brand-ico::after { display: none; }
html[data-ui="dos"] .brand-ico { display: inline-block; }
.hosp-logo {
  width: 46px; height: 58px; margin: 0 auto 6px; background: var(--brand); color: var(--brand);
  -webkit-mask: url(../assets/andry-tree.svg) center / contain no-repeat; mask: url(../assets/andry-tree.svg) center / contain no-repeat;
}
html.grad .hosp-logo { background: var(--gink); }
html[data-ui="tangerine"] .hosp-logo { background: var(--or); }
html[data-ui="midnight"] .hosp-logo { background: var(--ink); }

/* ---- Graphite: monochrome dark, silver haze, white pill actions, mono eyebrows ---- */
html[data-ui="graphite"] {
  --desk: #0b0b0c; --bg: #0e0e0f; --card: #161617; --field: #111112; --ink: #f2f2f2; --muted: #8d8d92; --line: #26262a;
  --hi: #26262a; --lo: #26262a; --dk: #000; --face: #161617; --brand: #f2f2f2; --brand-2: #f2f2f2;
  --red: #ff5d62; --red-bg: #2a1416; --ok: #7ad69c; --ok-bg: #12241a; --warn: #f0c46a; --warn-bg: #272012; --blue-bg: #1c1c20;
  --top-bg: rgba(14,14,15,.82); --top-ink: #f2f2f2; --top-muted: #a1a1a6; --top-accent: transparent; --blur: blur(14px);
  --nav-on-bg: #f2f2f2; --nav-on-ink: #0e0e0f; --head-ink: #f2f2f2;
  --primary-bg: #f5f5f5; --primary-ink: #0e0e0f; --btn-bg: #1f1f22; --btn-ink: #ededed; --th-bg: #1c1c1f; --th-ink: #d6d6da;
  --rc: 16px; --rb: 10px;
  --window: 0 0 0 1px #232326, 0 12px 30px rgba(0,0,0,.35);
  --body-bg: radial-gradient(900px 420px at 15% -8%, rgba(255,255,255,.14), transparent 62%), radial-gradient(800px 500px at 110% 30%, rgba(200,200,205,.10), transparent 60%), radial-gradient(700px 400px at 40% 115%, rgba(255,255,255,.07), transparent 60%), #0b0b0c;
  --font: "Figtree", -apple-system, "Segoe UI", Roboto, sans-serif; --field-font: var(--font);
  --mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
  color-scheme: dark;
}
html[data-ui="graphite"] body { background-attachment: fixed; }
html[data-ui="graphite"] .top { border-bottom: 1px solid #1d1d20; }
html[data-ui="graphite"] .brand { font-weight: 800; letter-spacing: -.02em; }
html[data-ui="graphite"] .menubar .sync, html[data-ui="graphite"] .menubar .ver { font-family: var(--mono); font-size: .72rem; letter-spacing: .02em; }
html[data-ui="graphite"] #nav { background: #161617; margin: 2px 12px 8px; padding: 4px; border-radius: 12px; box-shadow: 0 0 0 1px #232326; }
html[data-ui="graphite"] #nav a { border-radius: 9px; font-weight: 500; }
html[data-ui="graphite"] .btn, html[data-ui="graphite"] .chip { border: 1px solid #2a2a2e; font-weight: 500; }
html[data-ui="graphite"] .btn.primary, html[data-ui="graphite"] .chip.on { border-color: transparent; font-weight: 600; }
html[data-ui="graphite"] .btn:hover:not(:disabled) { filter: brightness(1.12); }
html[data-ui="graphite"] h1, html[data-ui="graphite"] h2, html[data-ui="graphite"] h3, html[data-ui="graphite"] legend { font-weight: 600; letter-spacing: -.01em; }
/* hero-style hospital panel: big white line, grey second line, mono eyebrow */
html[data-ui="graphite"] .hosp { text-align: left; padding: 18px 18px 16px; background: radial-gradient(420px 200px at 100% 0%, rgba(255,255,255,.08), transparent 70%), var(--card); }
html[data-ui="graphite"] .hosp-logo { margin: 0 0 10px; background: #f2f2f2; width: 38px; height: 48px; }
html[data-ui="graphite"] .hosp-l1 { font-size: 1.35rem; font-weight: 600; letter-spacing: -.01em; color: #f5f5f5; line-height: 1.2; }
html[data-ui="graphite"] .hosp-l2 { font-size: 1.1rem; font-weight: 500; color: #8a8a90; }
html[data-ui="graphite"] .hosp-l3 { font-size: .9rem; font-weight: 500; color: #c9c9ce; margin-top: 6px; }
html[data-ui="graphite"] .hosp-l4 { font-family: var(--mono); font-size: .72rem; color: #7d7d83; letter-spacing: .01em; }
/* stat tiles like the sidebar counts */
html[data-ui="graphite"] .stats b { color: #f5f5f5; font-weight: 600; }
html[data-ui="graphite"] .stats span { font-family: var(--mono); font-size: .66rem; color: #8d8d92; }
/* cards, badges, tags */
html[data-ui="graphite"] .case-card { border-left: 1px solid var(--line); }
html[data-ui="graphite"] .cc-plan { color: #c9c9ce; }
html[data-ui="graphite"] .badge, html[data-ui="graphite"] .badge-select { background: #f2f2f2; color: #0e0e0f; }
html[data-ui="graphite"] .tag { background: transparent; }
html[data-ui="graphite"] .progress { background: #26262a; }
html[data-ui="graphite"] .progress i { background: #f2f2f2; }
html[data-ui="graphite"] .muted { color: var(--muted); }
html[data-ui="graphite"] .lab-in.from-photo input, html[data-ui="graphite"] .lab-in.from-photo select { background: #2b2a12; color: var(--ink); }
html[data-ui="graphite"] .slide { color: #000; }
html[data-ui="graphite"] .deck-previews { background: #0b0b0c; }
html[data-ui="graphite"] input:focus, html[data-ui="graphite"] select:focus, html[data-ui="graphite"] textarea:focus { outline: 1px solid #bdbdc2; outline-offset: 1px; }

/* WhatsApp share buttons: a small green dot marks them in every look */
.btn.wa::before { content: ""; display: inline-block; width: .55em; height: .55em; border-radius: 50%; background: #25d366; margin-right: .45em; vertical-align: .05em; box-shadow: 0 0 0 2px rgba(37,211,102,.25); }
.wa-row { display: flex; flex-wrap: wrap; gap: .4rem; margin: 0 0 .6rem; }

/* Import from WhatsApp */
.imp-steps { margin: 0 0 .8rem; padding-left: 1.2rem; line-height: 1.5; }
#imp-text { width: 100%; font: inherit; }
.imp-case { margin-bottom: .8rem; }
.imp-dup { opacity: .7; }
.imp-pick { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin-bottom: .5rem; }
.imp-pick input { width: 1.2rem; height: 1.2rem; }
.imp-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .4rem .6rem; }
.imp-grid .span2 { grid-column: span 2; }
.imp-grid label { display: flex; flex-direction: column; font-size: .8rem; }
.imp-grid textarea { font: inherit; }
.imp-photos { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .6rem; }
.imp-photos figure { margin: 0; width: 104px; display: flex; flex-direction: column; gap: .25rem; }
.imp-photos img { width: 104px; height: 104px; object-fit: cover; border-radius: 8px; background: #000; }
.imp-photos select { font-size: .75rem; }
.imp-doa label { display: flex; flex-direction: column; font-size: .85rem; max-width: 220px; }
.imp-doa p { margin: .4rem 0 0; }

/* Pre-op X-rays PDF (OT list): patient header on every page */
.xr-head { border: 1.5px solid #000; padding: 5pt 8pt; margin-bottom: 4mm; }
.xr-name { font: bold 17pt Arial, Helvetica, sans-serif; letter-spacing: .02em; }
.xr-no { font-weight: normal; }
.xr-as { margin-left: 8pt; }
.xr-dx { font: bold 12.5pt Arial, Helvetica, sans-serif; margin-top: 2pt; }
.xr-page .ip-imgs img { max-height: 238mm; }
.xr-foot { font: 8.5pt Arial, sans-serif; color: #444; text-align: right; margin-top: 2mm; }
.xr-page .ip-imgs img { height: 236mm; width: auto; object-fit: contain; }
@media print { html, body, html.flat body { background: #fff !important; } }
@media print { :root, html[data-ui] { color-scheme: light !important; } }
.xr-page .ip-title { margin: 0 0 3mm; }
.xr-part { font-size: 11pt; font-weight: normal; text-decoration: none; }
.xr-page .ip-imgs img { height: 222mm; }
input:not([type]), input[type="text"], input[type="search"], textarea { text-transform: uppercase; }
input[type="email"], input[autocomplete="username"], [data-nocaps] input, [data-nocaps] textarea { text-transform: none; }
input::placeholder, textarea::placeholder { text-transform: none; }
/* page wrapper for prints without browser header/footer */
.pg-wrap { width: 100%; border-collapse: collapse; }
.pg-wrap > thead > tr > td, .pg-wrap > tfoot > tr > td, .pg-wrap > tbody > tr > td { padding: 0; border: 0; }
/* case order */
.order-bar { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin: 0 0 .6rem; }
.order-bar .muted { margin-right: auto; }

.cc-move { position: absolute; right: .5rem; top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; gap: .3rem; z-index: 2; }
.cc-move .icon { width: 2.2rem; height: 2.2rem; font-size: 1.1rem; }
.case-card { position: relative; }
/* OT pick list: anaesthesia + scheme dropdowns wide enough for the full wording */
.picker td:has(> .ot-sel) { white-space: nowrap; }
.picker select.ot-sel { width: auto; min-width: max-content; max-width: none; padding-right: 2rem; text-overflow: clip; }
.picker select.ot-sel[data-f="work.anaes"] { min-width: 13.5em; }
.picker select.ot-sel[data-f="scheme"] { min-width: 10.5em; }
/* Ticked rows (OT pick list, ward board): a soft tint + accent bar, normal readable text */
html.flat .picker tr.picked, html.flat .board tr.picked {
  background: color-mix(in srgb, var(--primary-bg) 14%, var(--card));
  color: var(--ink);
  box-shadow: inset 4px 0 0 var(--primary-bg);
}
html.flat .picker tr.picked td, html.flat .board tr.picked td { color: var(--ink) !important; }
html.flat .picker tr.picked .muted { color: var(--muted); }
html[data-ui="graphite"] .picker tr.picked, html[data-ui="graphite"] .board tr.picked { background: #24242a; box-shadow: inset 4px 0 0 #f2f2f2; }
/* move buttons on the left of each case */
.case-row { display: flex; gap: .4rem; align-items: stretch; min-width: 0; }
.case-row > .case-card { flex: 1; min-width: 0; margin: 0; }
.case-row > .cc-move { position: static; transform: none; display: flex; flex-direction: column; justify-content: center; gap: .35rem; }
.case-row > .cc-move .icon { width: 2rem; height: 2.4rem; font-size: 1.05rem; }
.case-row > .cc-move .icon:disabled { opacity: .25; }
.ot-move { white-space: nowrap; }
.ot-move .icon { width: 1.9rem; height: 1.9rem; }
.ot-move .icon:disabled { opacity: .25; }
/* Row hover in the modern looks: a faint tint that keeps the text readable (Win98 keeps its own) */
html.flat .board tr[data-go]:hover, html.flat .picker tr[data-row]:hover { background: color-mix(in srgb, var(--ink) 6%, var(--card)); }
html.flat .picker tr.picked:hover { background: color-mix(in srgb, var(--primary-bg) 20%, var(--card)); }
html[data-ui="graphite"] .picker tr.picked:hover { background: #2c2c33; }

/* Ward notebook: editable To do's and Assessment / Scheme */
.nb-search { width: 100%; max-width: 420px; margin: 0 0 .6rem; }
.nb-edit td { vertical-align: top; }
.nb-lab { display: flex; flex-direction: column; gap: .15rem; font-size: .72rem; color: var(--muted); font-weight: 600; margin-bottom: .35rem; }
.nb-edit .nb-todo-cell { min-width: 240px; }
.nb-edit .nb-as-cell { min-width: 190px; }
.nb-edit textarea { width: 100%; min-height: 0; resize: none; overflow: hidden; font-size: .85rem; line-height: 1.35; }
.nb-edit select { width: 100%; font-size: .85rem; }
.nb-edit tr[data-go] { cursor: default; }
.nb-edit tr[data-go] td:nth-child(-n+3) { cursor: pointer; }
.nb-edit tr[hidden] { display: none; }
.kv-sel { width: auto; min-width: 11em; padding-top: .2rem; padding-bottom: .2rem; }
/* pending works: text editable in place */
.tasks .task-line { display: flex; align-items: center; gap: .5rem; }
.tasks .task-text { flex: 1; min-width: 0; border: 1px solid transparent; background: transparent; padding: .2rem .35rem; font-size: 1rem; color: var(--ink); border-radius: 6px; }
.tasks .task-text:hover { border-color: var(--line); }
.tasks .task-text:focus { border-color: var(--brand); background: var(--field); }
.tasks li.done .task-text { text-decoration: line-through; color: var(--muted); }
/* Ward notebook: drag to reorder */
.nb-edit .nb-sno { white-space: nowrap; }
.drag-handle { touch-action: none; cursor: grab; border: 0; background: transparent; color: var(--muted); font-size: 1.25rem; line-height: 1; padding: .15rem .3rem .15rem 0; margin-right: .15rem; vertical-align: -2px; user-select: none; -webkit-user-select: none; }
.drag-handle:hover { color: var(--ink); }
body.dragging, body.dragging * { cursor: grabbing !important; user-select: none !important; -webkit-user-select: none !important; }
.nb-edit tr.drag-row { outline: 2px solid var(--primary-bg); outline-offset: -2px; background: color-mix(in srgb, var(--primary-bg) 12%, var(--card)); position: relative; z-index: 2; box-shadow: 0 8px 24px rgba(0,0,0,.35); }

/* Labels instead of placeholders */
.mini-lab { display: flex; flex-direction: column; gap: .1rem; font-size: .7rem; font-weight: 600; color: var(--muted); min-width: 0; }
.mini-lab input { width: 100%; }
.custom-row { align-items: end; }
.inline-add { align-items: flex-end; }
.inline-add .mini-lab { flex: 1 1 180px; }
.search-lab { display: flex; align-items: center; gap: .5rem; flex: 1; min-width: 0; font-size: .85rem; font-weight: 600; color: var(--muted); }
.search-lab input { flex: 1; min-width: 0; }
.nb-search.search-lab { max-width: 460px; margin: 0 0 .6rem; }

/* Discharge page: AMA / absconded / expired = just a dispose button, no summary */
.dc-quick { display: none; }
main[data-quick="1"] .dc-quick { display: block; }
main[data-quick="1"] #dc-form > fieldset:not(:first-of-type),
main[data-quick="1"] #dc-form > .form-actions,
main[data-quick="1"] #dc-form > label.small,
main[data-quick="1"] #dc-form + .card { display: none; }
.dc-quick-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .6rem; }
.dc-quick-row label { display: flex; flex-direction: column; font-size: .8rem; }

/* ---- Bed number ---- */
.bed-lab { display: inline-flex; align-items: center; gap: .3rem; font-size: .7rem; font-weight: 700; color: var(--muted); margin-bottom: .25rem; }
.bed-lab input { width: 4.2em; padding: .15rem .35rem; font-size: .85rem; font-weight: 700; text-align: center; }
.nb-name .bed-lab { display: flex; }
.nb-edit.by-bed .drag-handle { display: none; }

/* ---- Rounds view: one patient per screen ---- */
.rounds { max-width: 760px; margin: 0 auto; }
.rd-nav { display: flex; align-items: center; gap: .5rem; margin: .4rem 0 .6rem; }
.rd-nav select { flex: 1; min-width: 0; font-size: .95rem; }
.rd-nav.rd-bottom { justify-content: space-between; margin-top: .6rem; }
.rd-btn { min-width: 6.5rem; min-height: 2.8rem; font-size: 1rem; font-weight: 700; }
.rd-card { padding: 14px; }
.rd-head { display: flex; align-items: flex-start; gap: .7rem; }
.rd-who { flex: 1; min-width: 0; }
.rd-name { font-size: 1.25rem; font-weight: 700; line-height: 1.2; }
.rd-bed { flex-direction: column; align-items: stretch; margin: 0; }
.rd-bed input { width: 4.6em; font-size: 1.15rem; padding: .3rem; }
.rd-dx { margin-top: .6rem; font-weight: 600; }
.rd-plan { color: var(--brand); font-weight: 600; margin-top: .15rem; }
.rd-sec { margin-top: .9rem; }
.rd-lab { font-size: .75rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: .3rem; }
.rounds textarea { width: 100%; font-size: 1rem; line-height: 1.4; resize: none; overflow: hidden; min-height: 2.8em; }
.rd-chips { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .4rem; }
.rd-chips .chip { font-size: .8rem; padding: .35rem .6rem; }
.rd-seg { display: flex; flex-wrap: wrap; gap: .35rem; }
.rd-seg .seg { border: 1px solid var(--line); background: var(--btn-bg, var(--face)); color: var(--btn-ink, var(--ink)); border-radius: var(--rb, 8px); padding: .5rem .75rem; font: inherit; font-size: .85rem; font-weight: 600; cursor: pointer; min-height: 2.5rem; }
.rd-seg .seg.on { background: var(--primary-bg, var(--brand)); color: var(--primary-ink, #fff); border-color: transparent; }

/* ---- Ward notebook on phones: one compact card per case instead of five columns ---- */
@media (max-width: 640px) {
  .nb-edit { min-width: 0 !important; width: 100%; }
  .nb-edit thead { display: none; }
  .nb-edit tbody, .nb-edit tr[data-nbcase] { display: block; }
  .nb-edit tr[data-nbcase] { display: grid; grid-template-columns: auto 1fr; grid-template-areas: "sno name" "dx dx" "todo todo" "as as"; gap: .25rem .55rem; padding: .7rem .55rem; border-bottom: 1px solid var(--line); }
  .nb-edit tr[data-nbcase] > td { border: 0; padding: 0; min-width: 0 !important; }
  .nb-edit td.nb-sno { grid-area: sno; }
  .nb-edit td.nb-name { grid-area: name; }
  .nb-edit td.nb-name .bed-lab { display: inline-flex; margin-right: .5rem; }
  .nb-edit td.nb-dx { grid-area: dx; }
  .nb-edit td.nb-todo-cell { grid-area: todo; }
  .nb-edit td.nb-as-cell { grid-area: as; display: flex; gap: .5rem; }
  .nb-edit td.nb-as-cell .nb-lab { flex: 1; min-width: 0; }
  .rd-btn { min-width: 5.5rem; }
}
/* Rounds: sideways swipes on the card change patient — not the browser's back gesture */
.rd-card { touch-action: pan-y; }
html, body { overscroll-behavior-x: none; }

/* Post-op ward: incoming transfers */
.incoming { border-left: 4px solid var(--primary-bg, var(--brand)); }
.inc-row { display: flex; justify-content: space-between; align-items: center; gap: .6rem; padding: .55rem 0; border-top: 1px solid var(--line); }
.inc-row:first-of-type { border-top: 0; }
.inc-acts { display: flex; gap: .4rem; flex: none; }

/* OT list: OT-only cases */
.ot-quick summary { cursor: pointer; font-weight: 700; color: var(--brand); }
.ot-quick[open] summary { margin-bottom: .5rem; }
.ot-only-acts { display: inline-flex; gap: .3rem; flex-wrap: wrap; }

/* Op-note builder */
.opn-wrap { border: 1px solid var(--line); border-radius: var(--rc, 10px); padding: .6rem .7rem; }
.opn-wrap summary { cursor: pointer; font-weight: 700; color: var(--brand); }
.opn-wrap[open] summary { margin-bottom: .6rem; }
.opn-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .45rem .6rem; }
.opn-grid > label { display: flex; flex-direction: column; font-size: .8rem; min-width: 0; }
.opn-grid .span2 { grid-column: 1 / -1; }
.opn-grid select, .opn-grid input { width: 100%; min-width: 0; }
.opn-lab { font-size: .8rem; margin-bottom: .25rem; }
.opn-screw { display: flex; gap: .35rem; align-items: flex-end; margin-bottom: .35rem; }
.opn-screw select { flex: 1; min-width: 0; }
.opn-screw > input { flex: 1; min-width: 0; }
.opn-n { display: flex; flex-direction: column; font-size: .7rem; width: 4.2rem; }
.opn-n input { width: 100%; }
@media (max-width: 520px) { .opn-grid { grid-template-columns: 1fr; } }
/* Op-note builder: procedures and implants */
.opn-proc { border: 1px solid var(--line); border-radius: var(--rc, 10px); padding: .6rem; margin: .6rem 0; }
.opn-proc-head, .opn-imp-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .45rem; }
.opn-proc-head b { font-size: .95rem; }
.opn-imp { border-left: 3px solid var(--primary-bg, var(--brand)); padding: .35rem 0 .35rem .6rem; margin: .6rem 0; }
.opn-end { margin-top: .6rem; }
.opn-add-proc { margin-top: .2rem; }

/* ---- Comorbidities card */
.cm-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 8px; }
.cm-row { display: grid; grid-template-columns: 74px 90px 1fr; gap: 8px; align-items: end; padding: 6px 0; border-top: 1px dashed var(--line, #ccc); }
.cm-row b { align-self: center; }
.cm-row label { margin: 0; }
.cm-other { display: block; margin-top: 8px; }
@media (max-width: 520px) { .cm-row { grid-template-columns: 1fr 1fr; } .cm-row b { grid-column: 1 / -1; } }
.rd-cm { font-size: .9em; margin-top: 4px; opacity: .85; }

/* ---- Rounds suggestion pop-up */
.sug-back { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; padding: 16px; }
.sug-box { width: 100%; max-width: 440px; max-height: 85vh; overflow: auto; margin: 0; }
.sug-box h3 { margin-top: 0; }
.sug-row { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-top: 1px solid var(--line, #ddd); cursor: pointer; }
.sug-row input { width: 20px; height: 20px; margin-top: 2px; flex: none; }
.sug-row span { display: flex; flex-direction: column; gap: 2px; }

/* ---- Tamil consent forms (print) */
.pr.cf { margin: 0; }
.cf-img { display: block; width: 210mm; height: 296.5mm; page-break-after: always; break-after: page; }
.cf-img:last-child { page-break-after: auto; break-after: auto; }

/* Reload button (menu bar) and the "new version" bar */
.reload-btn { font: inherit; font-size: 12px; padding: .15rem .55rem; margin-left: .5rem; border-radius: 6px; border: 1px solid var(--line, rgba(127,127,127,.4)); background: transparent; color: inherit; cursor: pointer; white-space: nowrap; }
.reload-btn:active { opacity: .6; }
#update-bar { position: fixed; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 80; display: flex; gap: .5rem; align-items: center; width: min(460px, calc(100% - 32px)); box-sizing: border-box; padding: .55rem .6rem .55rem .9rem; border-radius: 12px; background: var(--ink); color: var(--bg); box-shadow: 0 8px 28px rgba(0,0,0,.45); font-size: .9rem; }
#update-bar span { flex: 1; min-width: 0; }
#update-bar .btn { white-space: nowrap; }
@media print { .reload-btn, #update-bar { display: none !important; } }

/* Investigations table: values typed straight into the cells */
.flow td.v { padding: .15rem .25rem; position: relative; }
.flow .flow-in { width: 4.6rem; min-width: 0; box-sizing: border-box; padding: .25rem .3rem; text-align: center; font: inherit; font-variant-numeric: tabular-nums; border: 1px solid transparent; border-radius: 6px; background: transparent; color: inherit; }
.flow select.flow-in { width: 6.2rem; text-align-last: center; }
.flow .flow-in:hover { border-color: var(--line); }
.flow .flow-in:focus { border-color: var(--brand); background: var(--field, #fff); outline: none; }
.flow td.v.flag .flow-in { color: var(--red); font-weight: 700; }
.flow td.v[data-mark]:not([data-mark=""])::after { content: attr(data-mark); color: var(--red); font-weight: 700; position: absolute; right: .1rem; top: 50%; transform: translateY(-50%); pointer-events: none; }
.flow td.v[data-fv]:not([data-fv=""])::before { content: attr(data-fv); position: absolute; left: 0; right: 0; bottom: 0; font-size: .62rem; color: var(--muted); text-align: center; pointer-events: none; }
.flow .flow-date { font: inherit; font-size: .8rem; background: transparent; color: inherit; border: 1px solid transparent; border-radius: 6px; padding: .1rem .2rem; width: 6.9rem; max-width: 6.9rem; }
.flow .flow-date:focus { border-color: currentColor; outline: none; }
.flow th.add-col .icon { color: inherit; font-size: .8rem; white-space: nowrap; }
.flow-hint { margin: .2rem 0 .4rem; }
.row-acts { display: inline-flex; gap: .4rem; flex-wrap: wrap; }
@media print { .flow .flow-in, .flow .flow-date { border: 0; } .flow th.add-col, .flow .set-acts { display: none; } }
.flow thead th.d { padding: .3rem .25rem; }
.flow td.v { min-width: 0; padding-right: .9rem; }
@media (max-width: 640px) { .flow .flow-date { font-size: .72rem; width: 6.2rem; } .flow td.pn { white-space: normal; min-width: 6.5rem; } }

/* Transfer-out tabs (Plastic, Neurosurgery) */
.pl-row { display: flex; gap: .75rem; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.pl-main { flex: 1; min-width: 14rem; }
.pl-acts { display: inline-flex; gap: .4rem; flex-wrap: wrap; }
.pl-back-h { margin-top: 1.2rem; }
.pl-done { padding: .35rem 0; border-bottom: 1px solid var(--line); }
.pl-done:last-child { border-bottom: 0; }
.st-plastic { color: #a3264a; }
.st-neuro { color: #3b3fa3; }
.xfer-links { display: flex; gap: .4rem; flex-wrap: wrap; margin: 0 0 .6rem; }

/* Rounds mode: one patient at a time, filling the screen */
body.rounds-mode .top { display: none; }
body.rounds-mode main { max-width: 860px; padding: calc(env(safe-area-inset-top, 0px) + 0px) 12px calc(env(safe-area-inset-bottom, 0px) + 24px); }
body.rounds-mode .rounds { max-width: none; }
.rm-bar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: .6rem; padding: calc(env(safe-area-inset-top, 0px) + .55rem) 0 .55rem; background: var(--bg); border-bottom: 1px solid var(--line); margin-bottom: .3rem; }
.rm-title { min-width: 0; line-height: 1.25; }
.rm-bar .btn { white-space: nowrap; flex: none; }
body.rounds-mode .rd-card { min-height: calc(100dvh - 15rem); }
.op-quick { display: flex; gap: .4rem; flex-wrap: wrap; margin: .5rem 0 .3rem; }

/* Rounds mode entry: the screen opens as a circle from the button that was tapped, then the
   bar drops in and the patient card rises, its sections settling one after another. */
.rm-enter { animation: rm-iris .62s cubic-bezier(.22, .9, .25, 1) both; }
@keyframes rm-iris {
  from { clip-path: circle(0 at var(--rx, 50%) var(--ry, 0)); }
  to { clip-path: circle(150vmax at var(--rx, 50%) var(--ry, 0)); }
}
.rm-enter .rm-bar { animation: rm-drop .45s .18s cubic-bezier(.2, .9, .3, 1.15) both; }
@keyframes rm-drop { from { transform: translateY(-110%); opacity: 0; } to { transform: none; opacity: 1; } }
.rm-enter .rd-nav.rd-top { animation: rm-rise .45s .26s cubic-bezier(.2, .8, .2, 1) both; }
.rm-enter .rd-card { animation: rm-card .6s .3s cubic-bezier(.16, 1, .3, 1) both; transform-origin: 50% 0; }
@keyframes rm-card {
  from { transform: translateY(28px) scale(.94); opacity: 0; filter: blur(6px); }
  60% { filter: blur(0); }
  to { transform: none; opacity: 1; filter: none; }
}
.rm-enter .rd-card > * { animation: rm-rise .5s cubic-bezier(.2, .8, .2, 1) both; }
.rm-enter .rd-card > :nth-child(1) { animation-delay: .42s; }
.rm-enter .rd-card > :nth-child(2) { animation-delay: .48s; }
.rm-enter .rd-card > :nth-child(3) { animation-delay: .53s; }
.rm-enter .rd-card > :nth-child(4) { animation-delay: .58s; }
.rm-enter .rd-card > :nth-child(5) { animation-delay: .63s; }
.rm-enter .rd-card > :nth-child(6) { animation-delay: .68s; }
.rm-enter .rd-card > :nth-child(n+7) { animation-delay: .73s; }
.rm-enter .rd-nav.rd-bottom { animation: rm-rise .45s .78s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes rm-rise { from { transform: translateY(14px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .rm-enter, .rm-enter * { animation: none !important; }
}
.stats .st-inc { font-style: normal; font-weight: 700; color: var(--brand); }
.st-retained { background: #fff4e0; color: #8a5300; }

/* Census tiles as filters */
.stats .stat-btn { cursor: pointer; transition: transform .12s, box-shadow .12s, border-color .12s; -webkit-tap-highlight-color: transparent; }
.stats .stat-btn:active { transform: scale(.96); }
.stats .stat-btn.on { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand) inset; }
.stats .stat-btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.tile-filter { display: flex; align-items: center; justify-content: space-between; gap: .5rem; flex-wrap: wrap; margin: 0 0 .6rem; padding: .45rem .6rem; border: 1px solid var(--brand); border-radius: var(--radius, 8px); }

/* ==========================================================================================
   Neater layout (every look) — grouped actions, tidy toolbars, swipeable chip rows, folded help
   ========================================================================================== */
.more-acts { margin-top: .55rem; }
.more-acts > summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: .4rem; font-size: .9rem; font-weight: 600; color: var(--muted); padding: .35rem .1rem; -webkit-tap-highlight-color: transparent; }
.more-acts > summary::-webkit-details-marker { display: none; }
.more-acts > summary::after { content: ""; width: .45em; height: .45em; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg) translateY(-2px); transition: transform .15s; }
.more-acts[open] > summary::after { transform: rotate(-135deg) translateY(-1px); }
.more-acts > .actions { margin-top: .4rem; }
details.help { margin: .8rem 0 0; }
details.help > summary { cursor: pointer; font-size: .85rem; color: var(--muted); }
details.help > p { margin: .5rem 0 0; }
/* home toolbar: search with "+ New case" on the first line, the two imports side by side below */
.dash-tools { flex-wrap: wrap; }
.dash-tools .search-lab { flex: 1 1 52%; min-width: 9rem; display: flex; align-items: center; gap: .5rem; }
.dash-tools .search-lab input { flex: 1; min-width: 0; margin: 0; }
.dash-tools .btn.primary { flex: none; }
.dash-tools .btn:not(.primary) { flex: 1 1 40%; justify-content: center; text-align: center; }
/* ward toolbar: title line, then the actions */
.ward-tools { flex-wrap: wrap; }
.ward-tools h2 { flex: 1 1 100%; margin: 0; }
.ward-tools .btn { flex: 1 1 0; justify-content: center; text-align: center; }
/* rows of chips scroll sideways on a phone instead of stacking into blocks */
@media (max-width: 700px) {
  .dash-chips, .xfer-links, .wa-row { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; padding-bottom: 2px;
    -webkit-mask-image: linear-gradient(90deg, #000 86%, transparent); mask-image: linear-gradient(90deg, #000 86%, transparent); }
  .dash-chips::-webkit-scrollbar, .xfer-links::-webkit-scrollbar, .wa-row::-webkit-scrollbar { display: none; }
  .dash-chips > *, .xfer-links > *, .wa-row > * { flex: none; white-space: nowrap; }
}

/* ==========================================================================================
   Graphite refresh: calmer, a little bigger, with texture and pattern
   ========================================================================================== */
html[data-ui="graphite"] {
  /* film grain + a faint dot grid over the silver haze */
  --grain: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 .055 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  --pin: repeating-linear-gradient(135deg, rgba(255,255,255,.045) 0 1px, transparent 1px 8px);
  --body-bg: var(--grain) 0 0 / 180px 180px,
    radial-gradient(rgba(255,255,255,.05) 1px, transparent 1.4px) 0 0 / 22px 22px,
    radial-gradient(900px 420px at 15% -8%, rgba(255,255,255,.13), transparent 62%),
    radial-gradient(800px 500px at 110% 30%, rgba(200,200,205,.09), transparent 60%),
    radial-gradient(700px 400px at 40% 115%, rgba(255,255,255,.06), transparent 60%), #0b0b0c;
  --muted: #9a9aa0;
}
/* bigger, easier text (16px fields also stop the iPhone zooming in on every tap) */
html[data-ui="graphite"] body { font-size: 16px; line-height: 1.5; }
html[data-ui="graphite"] input, html[data-ui="graphite"] select, html[data-ui="graphite"] textarea,
html[data-ui="graphite"] label > input, html[data-ui="graphite"] label > select, html[data-ui="graphite"] label > textarea { font-size: 16px; }
html[data-ui="graphite"] .small { font-size: .9em; }
html[data-ui="graphite"] .btn.small { font-size: .9rem; min-height: 36px; }
html[data-ui="graphite"] h2 { font-size: 1.35rem; }
html[data-ui="graphite"] h3 { font-size: 1.12rem; }
html[data-ui="graphite"] main { padding-top: 16px; }
/* cards: soft top sheen + the same grain, so surfaces feel like paper rather than flat fills */
html[data-ui="graphite"] .card { background-image: linear-gradient(180deg, rgba(255,255,255,.03), rgba(255,255,255,0) 140px), var(--grain); background-size: auto, 180px 180px; }
/* section headings get a small hatched mark */
html[data-ui="graphite"] .card > h3::before, html[data-ui="graphite"] .card > .row-between > h3::before, html[data-ui="graphite"] fieldset.card > legend::before {
  content: ""; flex: none; display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: .1rem;
  background: repeating-linear-gradient(45deg, rgba(242,242,242,.75) 0 1.5px, transparent 1.5px 4px); box-shadow: 0 0 0 1px rgba(242,242,242,.35); vertical-align: -1px;
}
/* hospital header: compact, logo beside the text, pinstripe pattern fading in from the right */
html[data-ui="graphite"] .hosp { position: relative; overflow: hidden; display: grid; grid-template-columns: 34px 1fr; column-gap: 14px; align-items: center; padding: 14px 16px; }
html[data-ui="graphite"] .hosp::after { content: ""; position: absolute; inset: 0; background: var(--pin); pointer-events: none;
  -webkit-mask-image: linear-gradient(100deg, transparent 35%, #000); mask-image: linear-gradient(100deg, transparent 35%, #000); }
html[data-ui="graphite"] .hosp > * { position: relative; z-index: 1; }
html[data-ui="graphite"] .hosp-logo { grid-row: 1 / span 4; width: 30px; height: 40px; margin: 0; }
html[data-ui="graphite"] .hosp-l1 { font-size: 1.02rem; line-height: 1.25; }
html[data-ui="graphite"] .hosp-l2 { font-size: .86rem; line-height: 1.3; }
html[data-ui="graphite"] .hosp-l3 { font-size: .8rem; margin-top: 2px; line-height: 1.3; }
html[data-ui="graphite"] .hosp-l4 { font-size: .72rem; margin-top: 4px; }
/* census tiles: a corner glow and fine hatch, bigger labels */
html[data-ui="graphite"] .stats .stat-btn { position: relative; overflow: hidden; padding: .65rem .4rem .55rem;
  background-image: radial-gradient(circle at 100% 0, rgba(255,255,255,.08), transparent 60%), var(--pin); }
html[data-ui="graphite"] .stats b { font-size: 1.6rem; letter-spacing: -.02em; }
html[data-ui="graphite"] .stats span { font-size: .72rem; line-height: 1.3; display: block; }
/* case cards: quiet pending pills with a red dot instead of a wall of red outlines */
html[data-ui="graphite"] .case-card .pend { gap: .3rem; }
html[data-ui="graphite"] .case-card .tag { font-size: .78rem; font-weight: 500; padding: .12rem .5rem; border-radius: 999px; }
html[data-ui="graphite"] .case-card .tag.inv { background: rgba(255,255,255,.04); color: #d4d4d8; border: 1px solid #2e2e33; }
html[data-ui="graphite"] .case-card .tag.inv::before { content: ""; display: inline-block; width: .42em; height: .42em; border-radius: 50%; background: var(--red); margin-right: .38em; vertical-align: .08em; }
html[data-ui="graphite"] .case-card .tag:not(.inv):not(.ok) { color: var(--muted); border-color: #2e2e33; }
html[data-ui="graphite"] .case-card .progress { height: 4px; border-radius: 4px; margin: .55rem 0 .5rem; }
html[data-ui="graphite"] .case-card .cc-name { font-size: 1.08rem; }
html[data-ui="graphite"] .case-row > .cc-move .icon { opacity: .38; width: 1.8rem; }
html[data-ui="graphite"] .case-row > .cc-move .icon:hover:not(:disabled) { opacity: 1; }
html[data-ui="graphite"] .case-row > .cc-move .icon:disabled { opacity: .12; }
/* ward notebook: faint zebra rows; rounds bar: pinstripe */
html[data-ui="graphite"] .nb-edit tbody tr:nth-child(even) { background: rgba(255,255,255,.018); }
html[data-ui="graphite"] .rm-bar { background: var(--pin), var(--bg); }
/* toasts: a slim pill that doesn't shout */
html[data-ui="graphite"] #toast { background: rgba(32,32,35,.92); color: #ededed; border: 1px solid #2e2e33; border-radius: 999px; padding: .5rem 1rem; font-size: .9rem;
  box-shadow: 0 10px 30px rgba(0,0,0,.4); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
@media print { html[data-ui="graphite"] .card { background-image: none; } }
/* e-case sheet actions on a phone: the main action full width, the rest in even pairs */
@media (max-width: 700px) {
  .case-head > .actions { display: grid; grid-template-columns: 1fr 1fr; gap: .45rem; }
  .case-head > .actions > .btn { justify-content: center; text-align: center; margin: 0; }
  .case-head > .actions > .btn.primary, .case-head > .actions > .tag { grid-column: 1 / -1; order: -1; justify-self: stretch; text-align: center; }
}
@media (max-width: 700px) {
  .case-head > .actions > .btn { white-space: nowrap; padding-left: .5rem; padding-right: .5rem; }
  .case-head > .actions > .btn.wa { grid-column: 1 / -1; }
}


/* Pre-op ward: optional "procedure done" */
.nb-done { margin-top: .3rem; }
.nb-done > summary { list-style: none; cursor: pointer; display: inline-block; font-size: .82rem; color: var(--muted); padding: .1rem 0; -webkit-tap-highlight-color: transparent; }
.nb-done > summary::-webkit-details-marker { display: none; }
.nb-done.has > summary { color: var(--ok); font-weight: 600; font-size: .9rem; }
.nb-done > textarea { display: block; width: 100%; margin-top: .3rem; font: inherit; }
.rounds .nb-done > summary { font-size: .95rem; }

/* PAC works checklist */
.pac-pending > label { display: flex; flex-direction: column; }
.pac-list { margin-top: .5rem; border: 1px solid var(--line); border-radius: var(--rb, 8px); padding: .5rem .6rem; }
.pac-head { display: flex; justify-content: space-between; align-items: center; font-size: .8rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: .3rem; }
.pac-item { padding: .45rem 0; border-top: 1px dashed var(--line); }
.pac-item:first-of-type { border-top: 0; }
.pac-chk { display: flex !important; flex-direction: row !important; align-items: center; gap: .55rem; font-weight: 600; }
.pac-chk input { width: 1.25rem; height: 1.25rem; flex: none; margin: 0; }
.pac-item.done .pac-chk span { text-decoration: line-through; opacity: .6; }
.pac-note { width: 100%; margin-top: .35rem; box-sizing: border-box; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }

/* Ward: arrange by bed list */
details.arrange { margin: 0 0 .7rem; border: 1px solid var(--line); border-radius: var(--rc, 10px); padding: .2rem .7rem; }
details.arrange > summary { cursor: pointer; font-weight: 600; padding: .45rem 0; }
details.arrange[open] { padding-bottom: .7rem; }
.arrange-body p { margin: .2rem 0 .5rem; }
.arr-box { position: relative; }
.arr-box textarea { width: 100%; box-sizing: border-box; font: inherit; line-height: 1.5; padding-right: 2.6rem; }
.arr-box .mic { position: absolute; right: 6px; top: 6px; }
.arr-res { margin-top: .6rem; font-size: .9rem; }
.arr-res p { margin: .25rem 0; }
.arr-res .bad, .arr-res.bad { color: var(--red); }
.rd-head-acts { display: flex; flex-direction: column; align-items: stretch; gap: .35rem; flex: none; }
.rd-head-acts .btn { justify-content: center; white-space: nowrap; }
.rd-head-acts .muted { text-align: center; }

/* Image icon beside a patient's name (OT list, ward notebook) */
.img-ico { display: inline-flex; align-items: center; gap: .2rem; vertical-align: middle; margin-left: .3rem; padding: .12rem .4rem; min-height: 0;
  border: 1px solid var(--line); border-radius: 999px; background: transparent; color: var(--muted); font: inherit; font-size: .75rem; font-weight: 600; line-height: 1; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.img-ico:hover, .img-ico:active { color: var(--ink); border-color: var(--ink); }
.img-ico svg { flex: none; }
@media (max-width: 700px) { .ot-rg { display: none !important; } }

/* Posted for OT: "(POSTED)" after the name, and a light amber row in the ward */
.posted-mark { font-weight: 700; font-size: .85em; color: #b77900; letter-spacing: .02em; white-space: nowrap; }
.nb-edit tbody tr.is-posted, html[data-ui] .nb-edit tbody tr.is-posted { background: rgba(255, 196, 64, .10); box-shadow: inset 3px 0 0 rgba(255, 196, 64, .75); }
html[data-ui="graphite"] .posted-mark, html[data-ui="midnight"] .posted-mark, html[data-ui="dos"] .posted-mark { color: #ffcf66; }
@media (prefers-color-scheme: dark) { html:not([data-ui]) .posted-mark { color: #ffcf66; } }
.rd-name .posted-mark { font-size: .7em; vertical-align: .15em; }
/* printed ward board */
.pr-posted td { background: #fff3d6 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }

/* Op-note builder: screw rows with length + position */
.opn-screw { display: flex; flex-wrap: wrap; gap: .4rem; align-items: flex-end; padding: .4rem 0; border-bottom: 1px dashed var(--line); }
.opn-screw > select { flex: 1 1 100%; }
.opn-screw .opn-n { flex: 0 0 4.2rem; }
.opn-screw .opn-len { flex: 1 1 7rem; }
.opn-screw .opn-at { flex: 1 1 8rem; }
.opn-screw label { display: flex; flex-direction: column; font-size: .78rem; }
.opn-screw label input, .opn-screw label select { width: 100%; box-sizing: border-box; }

/* Discharge: condition on discharge helpers */
.dc-cond { display: flex; flex-direction: column; gap: .5rem; }
.dc-splints { display: flex; flex-wrap: wrap; gap: .5rem; }
.dc-splints label { flex: 1 1 14rem; display: flex; flex-direction: column; font-size: .85rem; }
.dc-power table { border-collapse: collapse; }
.dc-power th, .dc-power td { padding: .15rem .35rem; text-align: center; font-size: .85rem; }
.dc-power tbody th { text-align: left; font-family: var(--mono, monospace); }
.dc-power input { width: 3.2rem; text-align: center; }
.dc-adv-btns { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }

/* Discharge: comorbidity pop-up */
.cm-pop-row { cursor: default; }
.cm-pop-rv { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem; margin-top: .3rem; font-size: .85rem; }
.cm-pop-rv select { max-width: 11rem; }
.cm-pop-rv input { width: 3.2rem; text-align: center; }
.sug-row .cm-pop-rv { flex-direction: row; align-items: center; gap: .35rem; }

/* Rounds: bed-sore check */
.bs-sites { display: flex; flex-wrap: wrap; gap: .35rem; margin: .5rem 0; }
.bs-sites .chip { display: inline-flex; align-items: center; gap: .3rem; }
.bs-grade { display: inline-flex; align-items: center; gap: .4rem; }
.rd-bs { margin-top: .25rem; font-size: .85rem; }
.rd-bs.ok { color: var(--ok); }
.rd-bs.bad { color: var(--red); font-weight: 700; }

/* Radiographs saved on this phone */
.offline-line { margin: .2rem 0 .5rem; }
.offline-line:empty { display: none; }
.offline-line .ok { color: var(--ok); }
.offline-line .warn { color: var(--amber, #a86b00); }
.viewer-msg { position: absolute; inset: auto 1rem 45%; color: #fff; background: rgba(0,0,0,.6); padding: .8rem 1rem; border-radius: .6rem; text-align: center; }

/* Consent forms: check before printing */
.cf-pop .sug-box { max-height: 85vh; overflow: auto; }
.cf-row { display: grid; gap: .35rem; padding: .6rem 0; border-top: 1px solid var(--line, #ddd); }
.cf-row label { display: grid; gap: .15rem; font-size: .85rem; }
.cf-row input, .cf-row select { width: 100%; font-family: "Noto Sans Tamil", inherit; }

/* App name: Callus · Ortho Unit I */
.brand-sub { font-weight: 400; opacity: .65; }
@media (max-width: 380px) { .brand-sub { display: none; } }

/* Rounds: from earlier rounds */
.rd-review { margin: .6rem 0; padding: .5rem .7rem; border: 1px solid var(--line, #444); border-radius: .6rem; background: rgba(255, 200, 0, .06); }
.rd-review summary { font-weight: 700; cursor: pointer; }
.rv-item { padding: .45rem 0; border-top: 1px dashed var(--line, #444); }
.rv-item:first-of-type { border-top: 0; }
.rv-line { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; }
.rv-acts { margin-left: auto; display: flex; flex-wrap: wrap; gap: .4rem; justify-content: flex-end; }
.rv-what { flex: 1 1 10rem; }
.rv-form { margin-top: .4rem; }
.rv-form textarea { width: 100%; }
.rv-form .lab-grid { margin-bottom: .3rem; }

/* Rounds: the card flips over to the next / previous patient */
.rounds { perspective: 1400px; }
.rd-card.flip-next { animation: rd-flip-next .45s cubic-bezier(.2, .7, .2, 1) both; transform-origin: center; backface-visibility: hidden; }
.rd-card.flip-prev { animation: rd-flip-prev .45s cubic-bezier(.2, .7, .2, 1) both; transform-origin: center; backface-visibility: hidden; }
@keyframes rd-flip-next { from { transform: rotateY(95deg); opacity: .2; } 60% { opacity: 1; } to { transform: rotateY(0); opacity: 1; } }
@keyframes rd-flip-prev { from { transform: rotateY(-95deg); opacity: .2; } 60% { opacity: 1; } to { transform: rotateY(0); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .rd-card.flip-next, .rd-card.flip-prev { animation: none; } }
.icon-btn { min-width: 2.6rem; justify-content: center; font-size: 1.15rem; }

/* Crop screen */
.crop-wrap { position: fixed; inset: 0; z-index: 1000; background: #0b0b0c; color: #fff; display: flex; flex-direction: column; padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); }
.crop-top { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; padding: .7rem 1rem; font-size: .9rem; }
.crop-top span { opacity: .6; font-size: .8rem; }
.crop-stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 8px; touch-action: none; user-select: none; -webkit-user-select: none; }
.crop-frame { padding: 18px; overflow: hidden; }
.crop-area { position: relative; }
.crop-area canvas { display: block; }
.crop-box { position: absolute; box-shadow: 0 0 0 9999px rgba(0, 0, 0, .6); outline: 2px solid #fff; pointer-events: none; }
.crop-box::before, .crop-box::after { content: ''; position: absolute; inset: 33.3% 0; border-top: 1px solid rgba(255,255,255,.35); border-bottom: 1px solid rgba(255,255,255,.35); }
.crop-box::after { inset: 0 33.3%; border: 0; border-left: 1px solid rgba(255,255,255,.35); border-right: 1px solid rgba(255,255,255,.35); }
.crop-box i { position: absolute; width: 22px; height: 22px; border: 5px solid #fff; }
.crop-box i[data-h="tl"] { left: -5px; top: -5px; border-right: 0; border-bottom: 0; }
.crop-box i[data-h="tr"] { right: -5px; top: -5px; border-left: 0; border-bottom: 0; }
.crop-box i[data-h="bl"] { left: -5px; bottom: -5px; border-right: 0; border-top: 0; }
.crop-box i[data-h="br"] { right: -5px; bottom: -5px; border-left: 0; border-top: 0; }
.crop-box b { position: absolute; background: #fff; border-radius: 3px; }
.crop-box b[data-e="t"], .crop-box b[data-e="b"] { left: 50%; width: 30px; height: 5px; margin-left: -15px; }
.crop-box b[data-e="t"] { top: -3px; } .crop-box b[data-e="b"] { bottom: -3px; }
.crop-box b[data-e="l"], .crop-box b[data-e="r"] { top: 50%; height: 30px; width: 5px; margin-top: -15px; }
.crop-box b[data-e="l"] { left: -3px; } .crop-box b[data-e="r"] { right: -3px; }
.crop-box[data-active] { outline-color: #ffd34d; }
.crop-bar { display: flex; gap: .5rem; justify-content: center; flex-wrap: wrap; padding: .7rem 1rem 1rem; }
.crop-bar .btn { min-width: 3.2rem; }

/* Views by role */
#nav a[hidden] { display: none !important; }
.pill.new { background: var(--red, #c0392b); color: #fff; }
.todo-case .todo-head { display: flex; justify-content: space-between; gap: .6rem; align-items: flex-start; margin-bottom: .4rem; }
.updates { list-style: none; margin: 0; padding: 0; }
.updates li { display: flex; gap: .6rem; padding: .45rem 0; border-top: 1px solid var(--line, #333); }
.updates li:first-child { border-top: 0; }
.up-time { font-variant-numeric: tabular-nums; opacity: .7; min-width: 3rem; }
.folders { display: grid; grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr)); gap: .5rem; margin: .5rem 0 1rem; }
.folder { display: flex; align-items: center; gap: .45rem; padding: .7rem .8rem; border-radius: .7rem; border: 1px solid var(--line, #333); background: var(--card, transparent); color: inherit; font: inherit; text-align: left; cursor: pointer; }
.folder.on { outline: 2px solid currentColor; }
.folder .pill { margin-left: auto; }
.folder-ico { font-size: 1.2rem; }
.fold-list { display: grid; gap: .5rem; }
.fold-case { display: block; color: inherit; text-decoration: none; }
.op-row { padding: .45rem 0; border-top: 1px solid var(--line, #333); }
.op-row:first-of-type { border-top: 0; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .3rem .9rem; }
.kv dt { opacity: .65; }
.role-pick { padding: .1rem .3rem; font-size: .85rem; }
.crop-box i, .crop-box b { filter: drop-shadow(0 0 1.5px rgba(0, 0, 0, .95)) drop-shadow(0 0 3px rgba(0, 0, 0, .6)); }
.crop-box { box-shadow: 0 0 0 1px rgba(0, 0, 0, .7), 0 0 0 9999px rgba(0, 0, 0, .6); }

/* Discharge: upload a summary typed elsewhere */
.dc-upload { display: grid; gap: .6rem; }
.dc-upload-row { display: flex; flex-wrap: wrap; gap: .5rem; }
.dc-imp-pop .sug-box { max-height: 88vh; overflow: auto; }
.imp-rows { display: grid; gap: .1rem; margin: .4rem 0; }
.imp-row { display: flex; gap: .5rem; align-items: flex-start; padding: .35rem 0; border-top: 1px solid var(--line, #333); }
.imp-row > span { display: grid; }

/* the buttons stay in view while the list scrolls */
.dc-imp-pop .sug-box { padding-bottom: 0; }
.dc-imp-pop .form-actions { position: sticky; bottom: 0; margin: .4rem -1rem 0; padding: .7rem 1rem calc(.7rem + env(safe-area-inset-bottom)); background: var(--card, #1b1b1d); border-top: 1px solid var(--line, #333); z-index: 1; }

/* Specialty tab */
.spec-row { display: flex; gap: .6rem; align-items: flex-start; padding: .55rem 0; border-top: 1px solid var(--line, #333); }
.spec-row:first-of-type { border-top: 0; }
.spec-main { flex: 1; min-width: 0; }
.week-pick { display: flex; align-items: center; gap: .6rem; margin: .3rem 0 .5rem; }
.warn-text { color: var(--amber, #b26b00); }

/* Unit VI scheme report */
.sch-table td, .sch-table th { text-align: center; }
.sch-table tbody th, .sch-table tfoot th { text-align: left; }
.sch-table tfoot td, .sch-table tfoot th { font-weight: 700; border-top: 2px solid currentColor; }
.sch-reason { padding: .45rem 0; border-top: 1px solid var(--line, #333); }
.sch-title { font-weight: 700; text-align: center; margin: .3rem 0 .6rem; }
.sch-table .sch-ns { text-align: left; min-width: 14rem; font-size: .85rem; }
.sch-table .sch-total th, .sch-table .sch-total td { font-weight: 700; border-top: 2px solid currentColor; }
.sch-notes { margin: .5rem 0; padding-left: 1.1rem; }

/* Upload an OT list made outside the app */
.otup-pop .sug-box { max-height: 88vh; overflow: auto; padding-bottom: 0; }
.otup-pop .form-actions { position: sticky; bottom: 0; margin: .4rem -1rem 0; padding: .7rem 1rem calc(.7rem + env(safe-area-inset-bottom)); background: var(--card, #1b1b1d); border-top: 1px solid var(--line, #333); }
.otup-row { padding: .5rem 0; border-top: 1px solid var(--line, #333); display: grid; gap: .25rem; }
.otup-sel { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.otup-row input[data-rs] { width: 100%; }

/* Start page */
.home { max-width: 32rem; margin: 1.5rem auto; text-align: center; }
.home-hi { opacity: .7; margin: 0 0 .2rem; }
.home h2 { font-size: 1.7rem; margin: 0 0 1.1rem; }
.home-wards { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.home-ward { display: grid; gap: .35rem; justify-items: center; padding: 1.4rem .8rem; border-radius: 1rem; border: 1px solid var(--line, #333);
  background: var(--card, #1b1b1d); color: inherit; text-decoration: none; font-size: 1.15rem; }
.home-ward:active { transform: scale(.98); }
.home-ico { font-size: 2.2rem; }
.home-more { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center; margin-top: 1.3rem; }

.home-units { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; }
.home-unit { display: grid; gap: .25rem; justify-items: center; padding: 1.1rem .4rem; border-radius: 1rem; border: 1px solid var(--line, #333);
  background: var(--card, #1b1b1d); color: inherit; font: inherit; font-size: 1.1rem; cursor: pointer; }
.home-unit:active { transform: scale(.98); }
.home-unit-now { margin: 0 0 .2rem; font-weight: 600; }

/* Guest demo */
#guest-bar { background: #ffd34d; color: #1a1a1a; text-align: center; padding: .35rem .8rem; font-size: .85rem; font-weight: 600; }
#guest-bar .link { color: #1a1a1a; text-decoration: underline; font-weight: 700; }
.gate-keep { display: flex; gap: .4rem; align-items: center; }

/* Callus logo in the title bar */
.brand-ico { width: 18px; height: 18px; background: url(../assets/icons/logo.svg) center / contain no-repeat; box-shadow: none; border-radius: 4px; }
.brand-ico::before, .brand-ico::after { display: none; }
