/* All colours and sizes are defined once here.
   Status colours: .s-<status>   Lab stage colours: .st-<stage>   */
:root {
  --bg: #f3f5f8; --card: #fff; --ink: #0f1b2d; --mute: #5f6f85; --line: #dfe5ec; --line-2: #c5cfdb;
  --acc: #0b7a75; --acc-2: #096661; --acc-ink: #fff; --soft: #e3f4f2;
  --bad: #c0271b; --bad-soft: #fdecea; --warn: #b25e09; --warn-soft: #fff3df; --ok: #0a7a4b; --ok-soft: #e0f6ea;
  --info: #1d5fd1; --info-soft: #e5eefd; --vio: #6a35c9; --vio-soft: #f0e9fc;
  --nav: #0d1b2a; --nav-2: #16283b; --nav-ink: #b8c7d6;
  --r: 10px; --shadow: 0 1px 2px #0d1b2a0d, 0 4px 14px #0d1b2a0a;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 14.5px/1.45 "Segoe UI Variable Text", "Segoe UI", system-ui, Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4 { margin: 0; }
h2 { font-size: 21px; font-weight: 650; letter-spacing: -.01em; }
h3 { font-size: 16px; }
h4 { margin: 16px 0 8px; font-size: 12px; color: var(--mute); text-transform: uppercase; letter-spacing: .06em; font-weight: 650; }
.card > h4:first-child { margin-top: 0; }
a { color: var(--acc); }
.muted { color: var(--mute); font-size: 13px; }
.grow { flex: 1; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.error { color: var(--bad); font-style: normal; font-size: 13px; }
.icon { width: 18px; height: 18px; flex-shrink: 0; vertical-align: -3px; }
kbd { font: 600 10.5px ui-monospace, Consolas, monospace; border: 1px solid currentColor; border-radius: 4px; padding: 0 4px; opacity: .65; margin-left: 6px; }

/* ---------- shell ---------- */
.shell { display: flex; min-height: 100vh; }
.nav { width: 232px; background: var(--nav); color: var(--nav-ink); padding: 12px 10px 20px; flex-shrink: 0; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex !important; align-items: center; gap: 10px; font-weight: 700; font-size: 16.5px; color: #fff !important; padding: 6px 8px 16px !important; background: none !important; }
.logo { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; background: var(--acc); color: #fff; }
.nav-group { font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em; color: #7f93a8; padding: 16px 10px 5px; font-weight: 650; }
.nav a { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; padding: 8px 10px; border-radius: 8px; margin: 1px 0; }
.nav a:hover { background: var(--nav-2); color: #fff; }
.nav a.active { background: var(--acc); color: #fff; font-weight: 600; }
.nav a span { flex: 1; }
.nav-fold summary { cursor: pointer; list-style: none; display: flex; justify-content: space-between; }
.nav-fold summary::after { content: "+"; font-size: 14px; }
.nav-fold[open] summary::after { content: "−"; }
.nav-fold summary::-webkit-details-marker { display: none; }
.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 14px; background: var(--card); border-bottom: 1px solid var(--line); padding: 9px 22px; position: sticky; top: 0; z-index: 10; }
.org { display: flex; flex-direction: column; line-height: 1.25; }
.who { display: flex; align-items: center; gap: 9px; line-height: 1.2; }
.who > div { display: flex; flex-direction: column; }
.avatar { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--soft); color: var(--acc); font-weight: 700; font-size: 12.5px; }
main { padding: 20px 22px 40px; flex: 1; max-width: 1500px; width: 100%; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 14px; }
.page-head h2 small { font-weight: 400; color: var(--mute); font-size: 14px; margin-left: 6px; }

/* ---------- building blocks ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; margin-bottom: 14px; box-shadow: var(--shadow); }
.narrow-card { max-width: 760px; }
.two-col { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 14px; align-items: start; }
.side-col { display: grid; grid-template-columns: minmax(0, 1fr) 290px; gap: 14px; align-items: start; }
@media (max-width: 1100px) { .two-col, .side-col { grid-template-columns: 1fr; } }

input, select, textarea { font: inherit; color: inherit; background: var(--card); border: 1px solid var(--line-2); border-radius: 8px; padding: 7px 10px; max-width: 100%; transition: border-color .12s, box-shadow .12s; }
input:hover, select:hover, textarea:hover { border-color: #9fb0c3; }
input:focus, select:focus, textarea:focus { outline: 0; border-color: var(--acc); box-shadow: 0 0 0 3px #0b7a7526; }
input:disabled, select:disabled, textarea:disabled { background: var(--bg); color: var(--mute); }
textarea { width: 100%; }
input[type=checkbox] { width: 16px; height: 16px; vertical-align: -3px; accent-color: var(--acc); }
.narrow { width: 120px; }
.tiny { width: 78px; }
.search { position: relative; flex: 1; min-width: 220px; max-width: 420px; }
.search .icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--mute); }
.search input { width: 100%; padding-left: 34px; }

.btn { font: inherit; font-weight: 550; display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line-2); background: var(--card); color: var(--ink); border-radius: 8px; padding: 7px 13px; cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .12s, border-color .12s; }
.btn:hover { border-color: var(--acc); background: #f7fbfb; }
.btn.primary { background: var(--acc); border-color: var(--acc); color: var(--acc-ink); }
.btn.primary:hover { background: var(--acc-2); }
.btn.ghost { border-color: transparent; background: none; color: var(--mute); }
.btn.ghost:hover { background: var(--bg); color: var(--ink); }
.btn.danger { color: var(--bad); }
.btn.danger:hover { border-color: var(--bad); background: var(--bad-soft); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.wide { width: 100%; justify-content: center; padding: 11px; margin-top: 12px; font-weight: 650; }
.btn:disabled { opacity: .5; cursor: default; }

.field { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; font-weight: 550; color: var(--mute); }
.field > input, .field > select, .field > textarea { font-size: 14.5px; font-weight: 400; color: var(--ink); width: 100%; }
.grid { display: grid; gap: 12px 14px; margin: 8px 0; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span2 { grid-column: span 2; }
.span4 { grid-column: span 4; }
.row { display: flex; gap: 8px; align-items: center; margin: 8px 0; flex-wrap: wrap; }

.table { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; box-shadow: var(--shadow); }
.table th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--mute); text-align: left; background: #f6f8fa; font-weight: 650; }
.table th.num { text-align: right; }
.table th, .table td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: #fafcfd; }
.table.compact th, .table.compact td { padding: 6px 9px; }
.table.compact { box-shadow: none; }
.table tr.off { opacity: .5; }
.table td small { display: block; color: var(--mute); font-size: 12.5px; }
.actions { text-align: right; white-space: nowrap; }
.actions > * { margin-left: 4px; }
.due { color: var(--bad); font-weight: 650; }
.empty { color: var(--mute); text-align: center; padding: 28px; }

.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 650; border-radius: 20px; padding: 2px 10px; background: #e9edf2; color: var(--mute); white-space: nowrap; }
.s-pending { background: var(--bad-soft); color: var(--bad); }
.s-partial, .s-admitted { background: var(--warn-soft); color: var(--warn); }
.s-entered, .s-opd { background: var(--info-soft); color: var(--info); }
.s-approved, .s-discharged { background: var(--ok-soft); color: var(--ok); }
.s-cancelled { background: #e9edf2; color: var(--mute); }
.s-lab { background: var(--soft); color: var(--acc); }
.s-ipd { background: var(--vio-soft); color: var(--vio); }
/* lab stages: --c is the stage colour, --s its soft background */
.st-sample { --c: var(--warn); --s: var(--warn-soft); }
.st-entry { --c: var(--info); --s: var(--info-soft); }
.st-review { --c: var(--vio); --s: var(--vio-soft); }
.st-ready { --c: var(--ok); --s: var(--ok-soft); }
.st-delivered, .st-cancelled { --c: var(--mute); --s: #e9edf2; }
.badge[class*="st-"] { background: var(--s); color: var(--c); }

.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0; }
.chip { font: inherit; font-size: 13px; border: 1px solid var(--line-2); background: var(--card); border-radius: 20px; padding: 4px 12px; cursor: pointer; }
.chip:hover { border-color: var(--acc); }
.chip.on { background: var(--acc); color: #fff; border-color: var(--acc); }

#item-search { width: 100%; font-size: 15.5px; padding: 10px 12px; }
.pick-list { border: 1px solid var(--line); border-radius: 8px; max-height: 210px; overflow: auto; margin: 6px 0; }
.pick-list.tall { max-height: 330px; }
.pick-list button { display: flex; gap: 10px; align-items: baseline; width: 100%; text-align: left; font: inherit; background: none; border: 0; border-bottom: 1px solid var(--line); padding: 8px 11px; cursor: pointer; }
.pick-list button:last-child { border-bottom: 0; }
.pick-list button:hover { background: var(--soft); }
.pick-list .num { margin-left: auto; font-weight: 650; }
.picked { display: flex; justify-content: space-between; align-items: center; gap: 10px; background: var(--soft); border-radius: 8px; padding: 10px 13px; }
.note { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; background: var(--warn-soft); color: #6d3b06; border: 1px solid #f5d9a8; border-radius: 8px; padding: 9px 13px; font-size: 14px; margin: 0 0 14px; }
.note.bad { background: var(--bad-soft); border-color: #f5c4bf; color: #7d1a12; }
.totals { margin: 10px 0 0 auto; max-width: 330px; }
.totals > div { display: flex; justify-content: space-between; align-items: center; padding: 4px 0; gap: 10px; }
.totals .grand { border-top: 2px solid var(--ink); margin-top: 4px; font-size: 18px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin: 12px 0; }
.tile { position: relative; display: flex; flex-direction: column; gap: 4px; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; text-decoration: none; color: inherit; box-shadow: var(--shadow); }
.tile b { font-size: 20px; font-variant-numeric: tabular-nums; }
.tiles.big { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.tiles.big .tile b { font-size: 26px; line-height: 1.2; }
.tile span { color: var(--mute); font-size: 13px; }
.tile small { color: var(--mute); font-size: 12.5px; }
.tile.good b { color: var(--ok); }
h4 .plain { text-transform: none; letter-spacing: 0; font-weight: 400; margin-left: 6px; }
.page-head.sub { margin: 18px 0 8px; }
.page-head.sub h4 { margin: 0; }
a.tile:hover { border-color: var(--acc); }
.tile.primary { border-left: 4px solid var(--acc); }
.tile.warn b { color: var(--bad); }
.tile kbd { position: absolute; right: 10px; top: 10px; }

/* owner view */
.money-line { display: flex; flex-wrap: wrap; align-items: stretch; gap: 8px; margin: 10px 0 4px; }
.money-line > div { display: flex; flex-direction: column; gap: 2px; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 16px; box-shadow: var(--shadow); min-width: 120px; }
.money-line > div span { color: var(--mute); font-size: 12.5px; }
.money-line > div b { font-size: 22px; line-height: 1.2; font-variant-numeric: tabular-nums; }
.money-line > i { align-self: center; font-style: normal; font-size: 20px; color: var(--mute); }
.money-line .main { border-left: 4px solid var(--acc); flex: 1; }
.money-line .good { flex: 1; }
.money-line .good b { color: var(--ok); }
.money-line .warn b { color: var(--bad); }
.two-col.even { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.breakdown .progress { min-width: 90px; }
.trend td.bars { width: 38%; min-width: 120px; }
.trend td.bars u, .key { display: block; height: 7px; border-radius: 4px; margin: 2px 0; min-width: 2px; }
.billed { background: var(--acc); }
.got { background: #7bc4a0; }
.key { display: inline-block; width: 12px; margin: 0 2px 0 8px; }
.table tfoot th { background: #f6f8fa; border-bottom: 0; }
@media (max-width: 1100px) { .two-col.even { grid-template-columns: 1fr; } }

.beds { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.bed { display: flex; flex-direction: column; gap: 2px; text-align: left; font: inherit; border-radius: var(--r); padding: 12px; border: 1px solid var(--line); background: var(--card); cursor: pointer; text-decoration: none; color: inherit; }
.bed b { font-size: 17px; }
.bed.free { border-left: 4px solid var(--ok); }
.bed.busy { border-left: 4px solid var(--warn); background: #fffaf0; }
.checks { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px 12px; max-height: 260px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; padding: 10px; }

.overlay { position: fixed; inset: 0; background: #0d1b2a8c; backdrop-filter: blur(2px); display: grid; place-items: start center; padding: 6vh 12px; overflow: auto; z-index: 20; }
.modal { background: var(--card); border-radius: 14px; width: min(540px, 100%); padding: 20px; box-shadow: 0 20px 60px #0d1b2a40; }
.modal.wide { width: min(960px, 100%); }
.modal h3 { margin-bottom: 12px; font-size: 17px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.toast { position: fixed; right: 20px; bottom: 20px; background: var(--ok); color: #fff; padding: 11px 18px; border-radius: 10px; z-index: 30; box-shadow: 0 8px 24px #0004; font-weight: 550; }
.toast.bad { background: var(--bad); }

/* ---------- sign in ---------- */
.login { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(135deg, #0d1b2a 0%, #0b4f55 100%); padding: 16px; }
.login-box { display: grid; grid-template-columns: 1fr 1fr; width: min(760px, 100%); background: var(--card); border-radius: 16px; overflow: hidden; box-shadow: 0 30px 80px #0006; }
.login-side { background: var(--acc); color: #fff; padding: 34px 30px; }
.login-side .logo { background: #ffffff26; width: 44px; height: 44px; margin-bottom: 16px; }
.login-side .logo .icon { width: 24px; height: 24px; }
.login-side h1 { font-size: 24px; }
.login-side p { opacity: .85; margin: 4px 0 22px; }
.login-side ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 11px; }
.login-side li { display: flex; align-items: center; gap: 10px; opacity: .95; }
.login-form { padding: 34px 30px; display: flex; flex-direction: column; gap: 12px; justify-content: center; }
.login-form h2 { margin-bottom: 6px; }
@media (max-width: 640px) { .login-box { grid-template-columns: 1fr; } .login-side ul { display: none; } }

/* ---------- lab flow ---------- */
.flow { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin: 12px 0 18px; }
.flow-step { position: relative; display: flex; flex-direction: column; gap: 3px; background: var(--card); border: 1px solid var(--line); border-top: 3px solid var(--c); border-radius: var(--r); padding: 14px 16px; text-decoration: none; color: inherit; box-shadow: var(--shadow); cursor: pointer; font: inherit; text-align: left; }
.flow-step:hover, .flow-step.on { background: var(--s); border-color: var(--c); }
.flow-step .top { display: flex; align-items: center; gap: 8px; color: var(--c); font-weight: 650; font-size: 13px; }
.flow-step b { font-size: 28px; line-height: 1.15; font-variant-numeric: tabular-nums; }
.flow-step small { color: var(--mute); font-size: 12.5px; }
.flow-step kbd { position: absolute; right: 10px; top: 12px; color: var(--mute); }
.flow.slim .flow-step { flex-direction: row; align-items: center; gap: 10px; padding: 10px 14px; }
.flow.slim .flow-step b { font-size: 20px; margin-left: auto; }

.progress { display: flex; align-items: center; gap: 8px; min-width: 120px; font-size: 12.5px; color: var(--mute); font-variant-numeric: tabular-nums; }
.progress i { flex: 1; height: 6px; border-radius: 6px; background: #e3e8ee; overflow: hidden; }
.progress i u { display: block; height: 100%; background: var(--acc); border-radius: 6px; }
.abn-count { color: var(--bad); font-weight: 650; font-size: 12.5px; }

.steps { list-style: none; display: flex; flex-wrap: wrap; gap: 0; padding: 0; margin: 0; }
.steps li { flex: 1; min-width: 150px; display: flex; align-items: center; gap: 10px; position: relative; padding: 4px 14px 4px 0; color: var(--mute); }
.steps li::after { content: ""; flex: 1; height: 2px; background: var(--line); margin-left: 6px; min-width: 14px; }
.steps li:last-child::after { display: none; }
.steps .dot { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: #e9edf2; flex-shrink: 0; }
.steps .dot .icon { width: 16px; height: 16px; }
.steps li div { display: flex; flex-direction: column; line-height: 1.25; }
.steps li b { font-size: 13.5px; }
.steps li small { font-size: 12px; }
.steps li.done { color: var(--ink); }
.steps li.done .dot { background: var(--ok-soft); color: var(--ok); }
.steps li.done::after { background: var(--ok); }
.steps li.now { color: var(--ink); }
.steps li.now .dot { background: var(--acc); color: #fff; box-shadow: 0 0 0 4px #0b7a7526; }

.patient-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 22px; }
.patient-bar .name { font-size: 19px; font-weight: 650; }
.patient-bar dl { display: flex; flex-wrap: wrap; gap: 4px 22px; margin: 0; }
.patient-bar dl div { display: flex; flex-direction: column; }
.patient-bar dt { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--mute); }
.patient-bar dd { margin: 0; font-weight: 550; }

.results td.result { width: 190px; }
.results .result input, .results .result select { width: 100%; font-weight: 600; font-variant-numeric: tabular-nums; }
.results .result textarea { min-width: 420px; }
.results td.flag { font-weight: 700; width: 76px; white-space: nowrap; font-size: 12.5px; }
.results td.prev { color: var(--mute); font-size: 13px; white-space: nowrap; }
.results td.remark input { width: 100%; min-width: 120px; }
.results tr.sub td { background: #f6f8fa; font-weight: 650; font-size: 12.5px; color: var(--mute); padding: 5px 9px; }
.flag-high .result input, .flag-low .result input, .flag-abnormal .result select { color: var(--bad); border-color: var(--bad); background: var(--bad-soft); }
.flag-high .flag, .flag-low .flag, .flag-abnormal .flag { color: var(--bad); }
.action-bar { position: sticky; bottom: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 14px; box-shadow: 0 -4px 18px #0d1b2a14; z-index: 5; }
.dirty { color: var(--warn); font-weight: 650; font-size: 13px; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 12px 18px; border-left: 2px solid var(--line); margin-left: 5px; font-size: 13px; }
.timeline li:last-child { border-left-color: transparent; padding-bottom: 0; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 3px; width: 10px; height: 10px; border-radius: 50%; background: var(--acc); }
.timeline b { display: block; }
.timeline small { color: var(--mute); }

/* ---------- printed documents ---------- */
.paper { background: #fff; color: #000; max-width: 800px; margin: 0 auto; padding: 28px 32px; border: 1px solid var(--line); font-size: 14px; box-shadow: var(--shadow); }
.letterhead { text-align: center; border-bottom: 2px solid #000; padding-bottom: 8px; margin-bottom: 10px; }
.letterhead h1 { font-size: 22px; }
.letterhead p { margin: 2px 0; }
.patient-box { width: 100%; border: 1px solid #000; border-collapse: collapse; margin: 8px 0; }
.patient-box td { padding: 3px 8px; }
.patient-box td:nth-child(odd) { color: #444; width: 14%; }
.dept { text-align: center; font-size: 15px; margin: 16px 0 6px; text-decoration: underline; }
.paper h4 { color: #000; text-transform: none; letter-spacing: 0; font-size: 14px; }
.report-table { width: 100%; border-collapse: collapse; }
.report-table th { text-align: left; border-top: 1px solid #000; border-bottom: 1px solid #000; padding: 4px 6px; }
.report-table th.num { text-align: right; }
.report-table td { padding: 3px 6px; vertical-align: top; }
.report-table .sub { font-weight: 700; padding-top: 8px; text-decoration: underline; }
.report-table .sec { font-weight: 700; padding-top: 8px; font-size: 13px; }
.report-table thead { border: 1px solid #000; }
.report-table .dept-row th { text-align: center; border: 0; padding-bottom: 0; }
.report-table .cols th { border: 0; }
.report-table th:nth-child(1) { width: 40%; }
.report-table { margin-top: 12px; }
.abn { font-weight: 700; }
/* lab report sheet: the head and foot rows hold the blank space of a pre-printed page and repeat on every printed sheet */
.sheet { width: 100%; border-collapse: collapse; }
.sheet > * > tr > td { padding: 0; }
.sheet-gap { box-sizing: border-box; display: flex; align-items: center; justify-content: center; border: 1px dashed #bbb; color: #888; font-size: 12px; margin: 0 0 8px; }
.sheet tfoot .sheet-gap { margin: 8px 0 0; }
.report .patient-box td:nth-child(odd) { width: 1%; white-space: nowrap; padding-right: 14px; }
.report .sign { display: flex; justify-content: flex-end; gap: 40px; margin-top: 30px; }
.report .end { margin-top: 10px; }
.para { white-space: pre-line; margin: 4px 0 12px; }
.sign { text-align: right; margin-top: 34px; font-weight: 600; }
.end { text-align: center; margin-top: 18px; }
.paper footer { border-top: 1px solid #999; margin-top: 14px; padding-top: 6px; font-size: 12px; color: #444; }
.provisional { text-align: center; border: 1px dashed #000; padding: 4px; font-weight: 700; }
.totals.print { max-width: 280px; }
.receipts { font-size: 12px; color: #444; }
/* bill / receipt: A5 portrait sheet (148 mm wide, 210 mm high), shown at paper width on screen */
.paper.bill { max-width: 148mm; padding: 8mm; font-size: 12.5px; }
.paper.bill.wide { max-width: 210mm; } /* A5 sheet fed sideways */
.bill .letterhead { display: flex; align-items: center; justify-content: center; gap: 5mm; }
.bill .letterhead h1 { font-size: 18px; }
.org-logo { height: 16mm; max-width: 45mm; object-fit: contain; flex: none; }
.logo-pick { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.bill .dept { font-size: 13.5px; margin: 8px 0 4px; }
.bill .patient-box td { padding: 2px 6px; }
.bill .patient-box td:nth-child(odd) { width: 1%; white-space: nowrap; }
.bill .report-table { margin-top: 6px; }
.bill .report-table th:nth-child(1) { width: auto; }
.bill .totals.print { max-width: 62mm; }
.bill .totals > div { padding: 2px 0; }
.bill .totals .grand { font-size: 15px; }
.bill .sign { margin-top: 22px; }
/* day end report: label / figure tables, and the lines that only show on paper */
.table.kv td:first-child small { color: var(--mute); margin-left: 6px; }
.print-only { display: none; }
.sign-row { justify-content: space-between; gap: 20px; margin-top: 16mm; font-weight: 600; }
@media print {
  .no-print { display: none !important; }
  .print-only { display: block; }
  .sign-row.print-only { display: flex; }
  .card { break-inside: avoid; box-shadow: none; }
  body { background: #fff; }
  main { padding: 0; max-width: none; }
  .paper { border: 0; max-width: none; padding: 0; box-shadow: none; }
  .table { border: 0; box-shadow: none; }
  html, body { margin: 0; }
  .sheet > * > tr > td { padding: 0 var(--side, 10mm); }
  .sheet-gap, .sheet tfoot .sheet-gap { border: 0; margin: 0; }
  .paper.report { font-size: 12.5px; line-height: 1.3; }
  .report .patient-box td { padding: 2px 8px; }
  .report .sign { margin-top: 18px; }
  .report .provisional { margin: 6px 0; padding: 2px; }
  .report .report-table td { padding: 2px 6px; }
  .report .report-table .sub, .report .report-table .sec { padding-top: 6px; }
  .report .patient-box, .report .report-table { margin-top: 0; }
  .report .report-table { margin-top: 8px; }
  .report-table tr, .patient-box, .sign { break-inside: avoid; }
  .paper.bill { font-size: 11.5px; line-height: 1.3; max-width: none; padding: 0; } /* fill the sheet; the page margin is the only edge */
  .bill .totals.print { break-inside: avoid; }
}
td .muted, h2 + .muted { margin-left: 6px; }

/* ---------- fine tuning ---------- */
.nav a .logo { flex: none; }
.results { table-layout: fixed; }
.results th:nth-child(1) { width: 26%; }
.results th:nth-child(2) { width: 170px; }
.results th:nth-child(3) { width: 78px; }
.results th:nth-child(4) { width: 9%; }
.results th:nth-child(5) { width: 15%; }
.results th:nth-child(6) { width: 13%; }
.results td.result { width: auto; }
.results .result textarea { min-width: 0; }
.timeline span { display: block; }
.toast { top: 12px; bottom: auto; right: auto; left: 50%; transform: translateX(-50%); } /* top centre: never covers page buttons */
.search { min-width: 300px; }
.help { margin: 0 2px 12px; }
.nav { width: 244px; scrollbar-width: thin; scrollbar-color: #2b4157 transparent; }
.nav a span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.page-head > input:not([type]) { min-width: 280px; }
.totals > .note { margin: 8px 0 0; font-size: 13px; }
