:root {
  --bg: #F4F3EE;
  --surface: #FFFFFF;
  --surface-2: #FAF9F5;
  --ink: #18221F;
  --ink-2: #3C4844;
  --muted: #69756F;
  --line: #E1DFD7;
  --line-2: #ECEAE3;
  --accent: #0E6B5C;
  --accent-ink: #0A4F44;
  --accent-soft: #E2F0EB;
  --side: #13211E;
  --side-ink: #B9C7C1;
  --blue: #2F5D8A;   --blue-soft: #E5EDF6;
  --amber: #9A6412;  --amber-soft: #FBF0DC;
  --red: #A93C2C;    --red-soft: #F8E6E2;
  --green: #2D6A31;  --green-soft: #E4F1E3;
  --grey-soft: #EEEDE8;
  --radius: 10px;
  --font: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.5 var(--font); color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
.mono, .num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.num { text-align: right; white-space: nowrap; }
.muted { color: var(--muted); }
svg.ic { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar { background: var(--side); color: var(--side-ink); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; gap: 10px; align-items: center; padding: 20px 20px 18px; color: #fff; text-decoration: none !important; }
.brand strong { display: block; font-size: 15px; }
.brand small { display: block; color: var(--side-ink); font-size: 12px; }
#nav { padding: 4px 10px 16px; flex: 1; }
.nav-group { margin-top: 14px; }
.nav-group > span { display: block; padding: 0 10px 4px; font-size: 12px; color: #7F918A; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 7px; color: var(--side-ink); text-decoration: none !important; position: relative; }
.nav-item:hover { background: rgba(255,255,255,.05); color: #fff; }
.nav-item.active { background: rgba(255,255,255,.09); color: #fff; }
.nav-item.active::before { content: ""; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: #6CC4AC; }
.sidebar-foot { padding: 14px 20px 18px; border-top: 1px solid rgba(255,255,255,.07); font-size: 12px; }
.sidebar-foot b { color: #fff; font-weight: 500; display: block; font-size: 13px; }

.workspace { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px; padding: 12px 28px; background: rgba(244,243,238,.92); backdrop-filter: blur(6px); border-bottom: 1px solid var(--line); }
.search { flex: 1; max-width: 440px; position: relative; }
.search input { width: 100%; padding: 8px 12px 8px 34px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); font: inherit; }
.search-ic { position: absolute; left: 10px; top: 9px; color: var(--muted); }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.role-pick { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.role-pick select { padding: 5px 8px; font-size: 13px; }
.mode-badge { font-size: 12px; padding: 3px 9px; border-radius: 99px; white-space: nowrap; }
.mode-badge.demo { background: var(--amber-soft); color: var(--amber); }
.mode-badge.live { background: var(--green-soft); color: var(--green); }
.icon-btn { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 6px; cursor: pointer; color: var(--ink); display: inline-flex; }
.menu-btn { display: none; }
.main { padding: 24px 28px 64px; max-width: 1280px; width: 100%; }
.scrim { display: none; }

/* ---------- Page pieces ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; }
.page-head .sub { margin: 4px 0 0; color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.card > h2, .card-head { font-size: 14px; padding: 14px 16px 10px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.card-head h2 { font-size: 14px; }
.kpi-inline { text-align: right; white-space: nowrap; font-size: 15px; }
.kpi-inline .sub { display: block; color: var(--muted); font-size: 12.5px; }
tr.cost-cycle td { background: var(--surface-2); }
.card-body { padding: 0 16px 16px; }
.stack { display: grid; gap: 16px; }
.cols-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { padding: 14px 16px; }
.kpi .label { color: var(--muted); font-size: 13px; }
.kpi .value { font-size: 26px; font-weight: 600; font-family: var(--mono); letter-spacing: -0.02em; margin-top: 2px; }
.kpi .hint { font-size: 12px; color: var(--muted); }
.kpi.kpi-warn .value { color: var(--amber); }

.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 13px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); font: 500 13.5px var(--font); cursor: pointer; text-decoration: none !important; white-space: nowrap; }
.btn:hover { background: var(--surface-2); border-color: #CFCCC2; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-ink); }
.btn.danger { color: var(--red); }
.btn.sm { padding: 4px 9px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg.ic { width: 16px; height: 16px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-weight: 500; font-size: 12.5px; color: var(--muted); padding: 8px 16px; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; }
td { padding: 10px 16px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tr[data-href] { cursor: pointer; }
tr[data-href]:hover td { background: var(--surface-2); }
td .sub { display: block; color: var(--muted); font-size: 12.5px; }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); }

.chip { display: inline-block; font-size: 12px; font-weight: 500; padding: 2px 8px; border-radius: 99px; background: var(--grey-soft); color: var(--ink-2); white-space: nowrap; }
.chip-submitted, .chip-booked { background: var(--blue-soft); color: var(--blue); }
.chip-returned, .chip-arrived, .chip-warn { background: var(--amber-soft); color: var(--amber); }
.chip-verified, .chip-prepared, .chip-Haematology { background: var(--accent-soft); color: var(--accent-ink); }
.chip-administered, .chip-seen { background: var(--green-soft); color: var(--green); }
.chip-cancelled, .chip-no-show, .chip-danger { background: var(--red-soft); color: var(--red); }
.chip-Oncology { background: #EFE8F4; color: #5B3F78; }

.tabs { display: flex; gap: 4px; flex-wrap: wrap; padding: 0 12px 12px; }
.tab { padding: 5px 10px; border-radius: 7px; color: var(--ink-2); font-size: 13px; text-decoration: none !important; }
.tab:hover { background: var(--grey-soft); }
.tab.active { background: var(--ink); color: #fff; }
.tab .n { font-family: var(--mono); font-size: 11.5px; opacity: .7; margin-left: 4px; }
.step-tabs { padding: 0 0 14px; gap: 6px; }
.step-tabs .tab { border: 1px solid var(--line); background: var(--surface); padding: 7px 14px; font-weight: 500; }
.step-tabs .tab.active { border-color: var(--ink); background: var(--ink); }

/* ---------- Forms ---------- */
input, select, textarea { font: inherit; color: var(--ink); border: 1px solid var(--line); border-radius: 8px; background: var(--surface); padding: 8px 10px; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(14,107,92,.25); border-color: var(--accent); }
.form { padding: 4px 20px 20px; }
fieldset { border: 0; padding: 0; margin: 16px 0 0; min-width: 0; }  /* min-width 0: wide tables scroll inside instead of pushing past the card */
legend { font-weight: 600; font-size: 14px; padding: 0; margin-bottom: 10px; }
.grid { display: grid; gap: 12px 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span2 { grid-column: span 2; } .span3 { grid-column: span 3; } .spanall { grid-column: 1 / -1; }
.fld { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.fld > span { font-size: 12.5px; color: var(--ink-2); font-weight: 500; }
.fld input, .fld select, .fld textarea { width: 100%; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; padding-top: 22px; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line-2); }
input.pct { width: 70px; text-align: right; padding: 4px 6px; font-family: var(--mono); }

.param-strip { display: flex; flex-wrap: wrap; gap: 8px 22px; margin-top: 12px; padding: 10px 14px; border-radius: 8px; background: var(--surface-2); border: 1px dashed var(--line); }
.param-strip div { font-size: 12.5px; color: var(--muted); }
.param-strip b { display: block; font: 500 16px var(--mono); color: var(--ink); }
.dose-table td, .dose-table th { padding: 8px 10px; }
.dose-final { font-weight: 600; }
.flag { color: var(--amber); font-size: 12px; display: block; }

.order-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; align-items: start; }
.side { padding: 16px; position: sticky; top: 76px; max-height: calc(100vh - 92px); overflow-y: auto; }
.side h3 { font-size: 13px; color: var(--muted); font-weight: 500; margin: 14px 0 4px; }
.side h3:first-child { margin-top: 0; }
.alert { padding: 10px 12px; border-radius: 8px; background: var(--red-soft); color: var(--red); font-size: 13px; }
.note { padding: 10px 12px; border-radius: 8px; background: var(--amber-soft); color: #6E4A10; font-size: 13px; }

/* ---------- Patient header ---------- */
.pt-head { display: flex; gap: 16px; align-items: flex-start; justify-content: space-between; padding: 18px 20px; flex-wrap: wrap; }
.pt-head h1 { font-size: 22px; }
.pt-meta { display: flex; flex-wrap: wrap; gap: 6px 18px; color: var(--ink-2); margin-top: 6px; font-size: 13.5px; }
.pt-meta span b { font-weight: 500; color: var(--muted); margin-right: 4px; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); border-top: 1px solid var(--line-2); }
.facts div { padding: 12px 20px; border-right: 1px solid var(--line-2); font-size: 12.5px; color: var(--muted); }
.facts div:last-child { border-right: 0; }
.facts b { display: block; color: var(--ink); font-weight: 500; font-size: 14px; margin-top: 2px; }

.timeline { list-style: none; margin: 0; padding: 0 16px 16px; }
.timeline li { position: relative; padding: 0 0 12px 18px; font-size: 13px; }
.timeline li::before { content: ""; position: absolute; left: 3px; top: 7px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.timeline li::after { content: ""; position: absolute; left: 6px; top: 16px; bottom: -2px; width: 1px; background: var(--line); }
.timeline li:last-child::after { display: none; }

/* ---------- Bars ---------- */
.bars { list-style: none; margin: 0; padding: 0 16px 16px; display: grid; gap: 8px; }
.bars li { display: grid; grid-template-columns: minmax(90px, 38%) 1fr 44px; gap: 10px; align-items: center; font-size: 13px; }
.bl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bt { height: 10px; background: var(--grey-soft); border-radius: 3px; overflow: hidden; }
.bt i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.bv { font-family: var(--mono); text-align: right; }

dialog { border: 1px solid var(--line); border-radius: 12px; padding: 0; width: min(560px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(19,33,30,.35); }
dialog .form { padding: 18px 20px 20px; }
dialog h2 { font-size: 17px; }

.toasts { position: fixed; bottom: 20px; right: 20px; display: grid; gap: 8px; z-index: 50; }
.toast { background: var(--ink); color: #fff; padding: 10px 14px; border-radius: 8px; font-size: 13.5px; box-shadow: 0 6px 20px rgba(0,0,0,.15); }
.toast.err { background: var(--red); }
.loading { padding: 40px; color: var(--muted); }
.matrix td, .matrix th { text-align: center; }
.matrix td:first-child, .matrix th:first-child { text-align: left; }
.yes { color: var(--accent); font-weight: 600; }

/* ---------- Responsive ---------- */
@media (max-width: 1000px) {
  .order-layout { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; }
  .cols-2 { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; z-index: 30; width: 260px; transform: translateX(-100%); transition: transform .2s; }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.3); z-index: 20; }
  .menu-btn { display: inline-flex; }
  .topbar { padding: 10px 16px; flex-wrap: wrap; }
  .role-pick span { display: none; }
  .main { padding: 18px 16px 48px; }
  .g3, .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .span3 { grid-column: span 2; }
  th, td { padding: 8px 10px; }
}
@media (max-width: 520px) {
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .span2, .span3 { grid-column: auto; }
  .search { order: 3; flex-basis: 100%; max-width: none; }
}
@media print {
  .sidebar, .topbar, .actions, .no-print, .toasts { display: none !important; }
  .shell { display: block; }
  body { background: #fff; }
  .main { padding: 0; max-width: none; }
  .card { border-color: #bbb; break-inside: avoid; }
}

/* ═══════ v2 additions ═══════ */
.chip.t-blue { background: var(--blue-soft); color: var(--blue); }
.chip.t-teal { background: var(--accent-soft); color: var(--accent-ink); }
.chip.t-green { background: var(--green-soft); color: var(--green); }
.chip.t-amber { background: var(--amber-soft); color: var(--amber); }
.chip.t-red { background: var(--red-soft); color: var(--red); }
.chip.t-grey { background: var(--grey-soft); color: var(--ink-2); }
.chip.t-violet { background: #EFE8F4; color: #5B3F78; }
.tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.section-title { font-size: 16px; margin: 4px 0 12px; }
table.compact td, table.compact th { padding: 6px 12px; font-size: 13px; }
.banner { margin-top: 10px; padding: 9px 12px; border-radius: 8px; background: var(--blue-soft); color: #23466A; font-size: 13px; }
.note + .fld, .note + .note { margin-top: 8px; }
#lateBox .note { margin-top: 10px; }
.radios { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; font-size: 13.5px; }
.radios label, .radio { display: flex; gap: 8px; align-items: center; }
.daypicks { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 8px 0 0 24px; font-size: 13px; }
.daypicks label { display: flex; gap: 4px; align-items: center; }
.ic-row { display: flex; gap: 10px; align-items: flex-end; padding-top: 16px; }
.ic-row .fld { flex: 1; }
input.big { font-size: 18px; padding: 10px 12px; letter-spacing: .02em; }
.found { padding: 12px 14px; border: 1px solid var(--line); border-radius: 8px; margin-top: 12px; background: var(--surface-2); }
.combo { position: relative; }
.combo > input { width: 100%; }
.combo-list { position: absolute; z-index: 10; left: 0; right: 0; top: calc(100% + 4px); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.08); max-height: 340px; overflow-y: auto; }
.combo-list button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 8px 12px; font: inherit; cursor: pointer; border-bottom: 1px solid var(--line-2); }
.combo-list button:hover { background: var(--surface-2); }
.combo-list button .sub { display: block; margin-top: 2px; color: var(--muted); font-size: 12.5px; }
.chosen { margin-top: 10px; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--accent); background: var(--accent-soft); }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding: 12px; margin-bottom: 16px; }
.filters input { flex: 1; min-width: 220px; }
.course .cycle { border-top: 1px solid var(--line-2); }
.cycle-head { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; padding: 10px 16px 6px; font-size: 13px; }
.round-card .drugline { font-size: 13.5px; padding: 8px 10px; background: var(--surface-2); border-radius: 6px; }
.labs { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px 10px; margin-top: 10px; }
.labs input { width: 100%; padding: 6px 8px; }
.labs output { padding: 7px 0; font-weight: 500; }
ul.plain { list-style: none; margin: 0 0 10px; padding: 0; }
ul.plain li { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line-2); }
.inline-add { display: flex; gap: 8px; }
.inline-add input { flex: 1; }
.edit-table input, .edit-table select { padding: 5px 6px; font-size: 13px; }
.date-nav { padding: 6px 8px; }
#printArea { display: none; }
@media print {
  body.print-sheet .shell { display: none !important; }
  body.print-sheet #printArea { display: block; font: 12px/1.4 var(--font); color: #000; }
  #printArea h1 { font-size: 18px; margin: 0 0 4px; }
  #printArea table.sheet { width: 100%; border-collapse: collapse; margin-top: 10px; }
  #printArea .sheet th, #printArea .sheet td { border: 1px solid #555; padding: 5px 7px; text-align: left; vertical-align: top; background: none; color: #000; }
  #printArea .box { width: 70px; }
  #printArea .sign { display: flex; justify-content: space-between; margin-top: 28px; }
}

/* ═══════ Nurse check-in & regimen extras ═══════ */
.loc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.loc-card { display: flex; flex-direction: column; gap: 4px; padding: 18px; text-align: left; font: inherit; color: var(--ink); cursor: pointer; }
.loc-card b { font-size: 16px; }
.loc-card span { font-size: 13px; color: var(--muted); }
.loc-card:hover { border-color: var(--accent); background: var(--accent-soft); }
.checkin-card td.ck { width: 44px; }
.big-check { width: 22px; height: 22px; accent-color: var(--accent); cursor: pointer; }
.checkin-card tr.is-in td { background: var(--surface-2); }
.bed-btn { font: inherit; border: 1px solid var(--line); background: var(--surface); border-radius: 6px; padding: 3px 8px; cursor: pointer; }
.bed-btn:hover { border-color: var(--accent); }
.print-btns { display: flex; flex-direction: column; align-items: stretch; gap: 6px; width: max-content; }
.bed-btn { white-space: nowrap; }
.extras { display: flex; flex-wrap: wrap; gap: 6px 24px; margin: 4px 16px 12px; font-size: 13px; }
.extras > div { display: flex; flex-direction: column; gap: 2px; }
.extras i { color: var(--muted); font-style: normal; font-size: 12px; }
.extras-grid h4 { margin: 0 0 6px; font-size: 13px; }
@media print {
  #printArea .page + .page { break-before: page; }
  #printArea .sh-top { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 2px solid #000; padding-bottom: 6px; }
  #printArea .sh-sub { font-size: 13px; }
  #printArea .sh-loc { text-align: right; font-size: 12px; }
  #printArea .sh-loc b { display: block; font-size: 20px; }
  #printArea h2 { font-size: 14px; margin: 16px 0 0; }
  #printArea h2 small { font-weight: 400; font-size: 11px; }
  #printArea table.pt th { width: 1%; white-space: nowrap; }
  #printArea .tick { width: 24px; text-align: center; font-size: 15px; }
  #printArea .sh-warn { border: 2px solid #000; padding: 6px 8px; margin-top: 10px; font-weight: 600; }
  #printArea .sh-none { font-style: italic; margin: 6px 0 0; }
  #printArea .sh-trail { margin-top: 14px; }
  #printArea .sh-lines { height: 70px; border: 1px solid #555; margin-top: 6px; }
  #printArea .sh-foot { margin-top: 18px; font-size: 10px; color: #444; }
}

/* ── Regimen phases, editor tables, order options ── */
.help { font-size: 12.5px; margin: -2px 0 8px; }
.phase-block { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px 14px; margin-top: 14px; background: var(--surface); }
.phase-block > legend { display: flex; align-items: center; gap: 10px; padding: 0 6px; }
.sub-table { margin-top: 14px; }
.sub-table h4 { margin: 0 0 4px; font-size: 13px; }
.sub-table [data-add] { margin-top: 6px; }
.edit-table input[type=checkbox] { width: 16px; height: 16px; }
.phase-view + .phase-view { border-top: 1px dashed var(--line); padding-top: 6px; }
.phase-title { margin: 6px 16px 4px; font-weight: 600; font-size: 13.5px; }
.opt-box { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 18px; padding: 10px 12px; margin-bottom: 12px; border-radius: 8px; background: var(--amber-soft); }
.opt-box .check { padding-top: 0; }
.opt-box .help { flex-basis: 100%; margin: 4px 0 0; }
ul.plain li.off { opacity: .45; text-decoration: line-through; }
input.level { width: 72px; padding: 4px 6px; text-align: right; font: inherit; }
.req-lab span { font-weight: 600; color: var(--accent-ink); }

@media print {
  #printArea .hpp-head { text-align: center; position: relative; margin-bottom: 6px; }
  #printArea .hpp-head .code { position: absolute; right: 0; top: 0; font-size: 10px; }
  #printArea .hpp-head h1 { font-size: 15px; margin: 0; }
  #printArea .hpp-head .reg { font-size: 14px; font-weight: 700; text-transform: uppercase; }
  #printArea .hpp-pt .reg-box { width: 36%; font-size: 11px; }
  #printArea .cyc-band { margin-top: 12px; padding: 5px 8px; background: #ddd !important; border: 1px solid #555; font-size: 15px; font-weight: 700; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  #printArea th.stage { width: 1%; white-space: nowrap; text-align: center; font-weight: 600; vertical-align: middle; }
  #printArea table.admin .box { width: 80px; }
  #printArea .remarks { border: 1px solid #555; padding: 6px 8px; margin-top: 10px; font-size: 11px; }
  #printArea .rota table.grid-rota th:first-child { width: 22%; }
  #printArea .rota td.na { background: #bbb !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  #printArea .rota tr.comments td { height: 70px; }
  #printArea .rota tr.sec th { background: none; }
}

.demo-list { margin: 0 0 8px; padding-left: 18px; font-size: 13px; }
.demo-list li { margin: 2px 0; }

/* Administration flow (order form) and home pre-medication check (check-in) */
.flow-home { padding: 10px 12px; margin: 6px 0 10px; border-radius: 8px; background: var(--amber-soft); font-size: 13px; }
.flow-home ul.plain { margin: 4px 0 0; }
.flow-home ul.plain li { border-color: rgba(0,0,0,.06); }
.flow-days { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 10px; }
.flow-day { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.flow-head { padding: 6px 10px; font-weight: 600; background: var(--line-2); }
table.flow-table { width: 100%; }
table.flow-table td { vertical-align: top; font-size: 12.5px; }
table.flow-table td.stage { white-space: nowrap; color: var(--muted, #667); font-size: 12px; width: 1%; }
table.flow-table tr.chemo-row td { background: var(--accent-soft, #EAF4F1); }
.flow-dc { padding: 6px 10px 2px; border-top: 1px solid var(--line); font-size: 12.5px; }
.flow-dc ul.plain { margin: 2px 0 4px; }
.dose-table tr.off td { opacity: .5; }
dialog.wide { width: min(760px, calc(100vw - 32px)); }
table.premed-q { width: 100%; }
table.premed-q td.yn { white-space: nowrap; }
table.premed-q td.yn label { display: inline-flex; gap: 4px; align-items: center; margin-right: 12px; }
@media (max-width: 640px) { .flow-days { grid-template-columns: 1fr; } }
@media print {
  #printArea .sh-ok { border: 1px solid #000; padding: 6px 8px; margin-top: 10px; }
  #printArea table.admin td.num { width: 1%; text-align: right; }
  #printArea table.admin tr.chemo-row td { height: 34px; }
  #printArea table.admin tr.rescue-row td { font-weight: 700; border-width: 2px; }
}

/* ---------- Patient history timeline (oldest at top, latest at bottom) ---------- */
.tl-scroll { max-height: min(70vh, 640px); overflow-y: auto; border-top: 1px solid var(--line-2); overscroll-behavior: contain; }
.tl { list-style: none; margin: 0; padding: 8px 16px 16px 44px; position: relative; }
.tl::before { content: ""; position: absolute; left: 25px; top: 18px; bottom: 26px; width: 2px; background: var(--line); }
.tl-item { position: relative; margin: 0 0 10px; }
.tl-item::before { content: ""; position: absolute; left: -24px; top: 15px; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); border: 2px solid var(--muted); }
.tl-mark { font-size: 13px; color: var(--ink-2); padding: 8px 0 2px; }
.tl-mark::before { top: 13px; width: 8px; height: 8px; left: -23px; border-color: var(--line); background: var(--line); }
.tl-mark .sub, .tl-card .sub { display: block; color: var(--muted); font-size: 12.5px; }
.tl-stop::before { background: var(--red); border-color: var(--red); }
.tl-completed::before { background: var(--green); border-color: var(--green); }
.tl-active::before { background: var(--accent); border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.tl-stopped::before { background: var(--red); border-color: var(--red); }
.tl-year { position: sticky; top: 0; z-index: 1; margin: 6px 0 8px -44px; padding: 6px 16px; background: var(--surface); font-size: 12px; font-weight: 600; color: var(--muted); border-bottom: 1px solid var(--line-2); }
.tl-edge { margin: 4px 0 12px -28px; font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tl-card { display: grid; gap: 4px; width: 100%; text-align: left; font: inherit; color: inherit; cursor: pointer; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.tl-card:hover { border-color: var(--accent); background: var(--surface-2); }
.tl-card:focus-visible { outline: 2px solid rgba(14,107,92,.35); outline-offset: 1px; }
.tl-active .tl-card { border-color: var(--accent); }
.tl-row { display: flex; justify-content: space-between; align-items: center; gap: 6px 8px; flex-wrap: wrap; }
.tl-row b { font-weight: 500; }

/* Cycle popup */
.cycle-dlg { max-height: calc(100vh - 32px); }
.dlg-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 8px; }
.dlg-sec { font-size: 13px; font-weight: 600; color: var(--ink-2); margin: 16px 0 8px; }
.seg-bar { display: flex; gap: 4px; }
.seg-bar .seg { flex: 1; height: 10px; border-radius: 3px; background: var(--grey-soft); }
.seg-completed { background: var(--green) !important; }
.seg-active { background: var(--accent) !important; }
.seg-stopped { background: var(--red) !important; }
.seg-sel { outline: 2px solid var(--ink); outline-offset: 1px; }
.lab-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.lab-card { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px 4px; }
.lab-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 12.5px; }
.lab-chart { display: block; width: 100%; height: auto; margin-top: 4px; }
.lab-chart text { font: 10px var(--mono); fill: var(--muted); }
.lab-chart text.on { fill: var(--ink); font-weight: 600; }
.lab-chart .grid { stroke: var(--line-2); stroke-width: 1; }
.lab-chart .line { fill: none; stroke: var(--blue); stroke-width: 1.6; stroke-linejoin: round; }
.lab-chart .pt { fill: var(--surface); stroke: var(--blue); stroke-width: 1.6; }
.lab-chart .pt.sel { fill: var(--accent); stroke: var(--accent); }
@media (max-width: 520px) {
  .tl { padding-left: 36px; }
  .tl::before { left: 17px; }
  .tl-year { margin-left: -36px; }
  .lab-grid { grid-template-columns: 1fr; }
}
@media print { .tl-scroll { max-height: none; overflow: visible; } }

/* Comorbidities & concurrent medications editor */
.extras-ed { margin-top: 18px; }
.extras-ed .ed-title { font-size: 14px; margin: 16px 0 6px; }
table.rows-ed td { padding: 4px 6px; }
table.rows-ed input, table.rows-ed select { width: 100%; }
table.rows-ed td:last-child { width: 1%; }
.extras-view { padding: 0 16px 14px; }
.side .side-item { margin-bottom: 4px; }

/* ═══════ Pharmacy preparation workflow ═══════ */
td.ck, th.ck { width: 44px; }
.iso-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding-top: 0; }
.iso-tools .help { margin: 0; }
.iso-now { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.iso-now > div { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 13.5px; }
.dlg-h { font-size: 14px; margin: 16px 0 6px; }
details.card > summary { cursor: pointer; list-style: none; }
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary h2::before { content: '▸ '; color: var(--muted); }
details.card[open] > summary h2::before { content: '▾ '; }
details.card > .table-wrap + .table-wrap { margin-top: 12px; }
ol.prio { margin: 0 0 12px; padding-left: 22px; }
ol.prio li { padding: 6px 0; border-bottom: 1px solid var(--line-2); }
ol.prio li { display: list-item; }
ol.prio li > span:first-child { display: inline-block; min-width: 180px; font-weight: 500; }
ol.prio li > span + span { float: right; }
@media (max-width: 700px) { .iso-now { grid-template-columns: 1fr; } }
@media print {
  #printArea .sheet.big th, #printArea .sheet.big td { font-size: 13px; padding: 7px 8px; }
  #printArea .sheet.big td.num { text-align: right; }
  #printArea .prep-sheet { font-size: 15px; }
  #printArea .prep-sheet h1 { font-size: 22px; }
  #printArea .prep-sheet .pg { border-top: 4px solid #000; margin-top: 14px; padding-top: 8px; break-inside: avoid; }
  #printArea .prep-sheet .pg-head { font-size: 22px; }
  #printArea .prep-sheet .pg-head b { text-transform: uppercase; letter-spacing: .02em; }
  #printArea .prep-sheet .pg-head span { font-size: 15px; font-weight: 400; margin-left: 8px; }
  #printArea .prep-sheet .pg-sub { font-size: 15px; margin: 4px 0 6px; }
  #printArea .prep-sheet table.pt-rows { width: 100%; border-collapse: collapse; }
  #printArea .prep-sheet .pt-rows th { font-size: 12px; text-align: left; border-bottom: 2px solid #000; padding: 4px 6px; }
  #printArea .prep-sheet .pt-rows td { font-size: 16px; padding: 10px 6px; border-bottom: 1.5px solid #444; vertical-align: top; }
  #printArea .prep-sheet .pt-rows td small { display: block; font-size: 12px; }
  #printArea .prep-sheet .cb { display: inline-block; width: 22px; height: 22px; border: 2px solid #000; }
  #printArea .sign.big { font-size: 15px; margin-top: 36px; }
}

/* Order form: per-cycle diluent / volume / infusion time, dose % shortcuts, recent cycles */
.dose-table .inf-d { max-width: 170px; }
.dose-table .inf-n { width: 72px; }
.dose-table .inf-t { width: 100px; }
.dose-table .fc-cell { min-width: 130px; max-width: 220px; }
.nowrap { white-space: nowrap; }
.dose-table .fc-bad, .fc-bad { color: var(--red, #B42318); }
.dose-table .changed { border-color: var(--amber); background: var(--amber-soft); }
.pct-chips { display: flex; flex-wrap: wrap; gap: 6px; }
details.recent { margin-bottom: 8px; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; background: var(--surface-2); }
details.recent summary { cursor: pointer; font-size: 13.5px; padding: 2px 0; }
details.recent .table-wrap { margin-top: 6px; }

/* Pharmacy: CDR review screening, allocation, worksheets */
dialog.screen-dlg { width: min(1100px, calc(100vw - 32px)); max-height: calc(100vh - 32px); }
dialog.screen-dlg .form { padding-bottom: 0; }
.scr-top { padding-bottom: 2px; }
.scr-regbar { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px 18px; margin-top: 12px; padding: 12px 14px; border-radius: 8px; background: var(--accent-soft); border: 1px solid var(--line); font-size: 14px; }
.scr-regbar .l { display: block; font-size: 12px; color: var(--ink-2); margin-bottom: 2px; }
.scr-regbar .sub { display: block; font-size: 12px; color: var(--ink-2); }
.scr-top h2 { margin: 0 0 2px; font-size: 19px; }
.scr-allergy { margin-top: 10px; }
.scr-h { display: flex; align-items: center; gap: 8px; margin-top: 20px; padding-top: 14px; border-top: 1px solid var(--line-2); }
.scr-h .n { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--ink); color: #fff; font-size: 12px; font-family: var(--mono); flex: none; }
.scr-sub { font-size: 12.5px; font-weight: 600; color: var(--ink-2); margin: 12px 0 6px; }
.cum-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 8px; }
.cum-box { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.cum-box.warn { border-color: var(--amber); }
.cum-box.over { border-color: var(--red); }
.cum-t { font-size: 12.5px; font-weight: 600; margin-bottom: 4px; }
.scr-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 8px; }
.scr-regbar + .scr-h { border-top: 0; padding-top: 4px; }
.scr-tiles.old .scr-tile { background: var(--grey-soft); }
.scr-tile { position: relative; display: flex; flex-direction: column; align-items: stretch; text-align: left; font: inherit; color: inherit; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: var(--surface); min-width: 0; cursor: pointer; }
.scr-tile:hover { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.scr-tile:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.scr-tile .k { display: block; font-size: 12px; color: var(--ink-2); line-height: 1.3; min-height: 2.6em; padding-right: 18px; }
.scr-tile .tr { position: absolute; top: 7px; right: 8px; color: var(--ink-2); opacity: .5; }
.scr-tile .tr svg { width: 14px; height: 14px; }
.scr-tile:hover .tr { opacity: 1; color: var(--accent); }
.scr-tile .v { display: block; font-size: 19px; font-weight: 600; font-family: var(--mono); }
.scr-tile .u { font-size: 12px; font-weight: 400; color: var(--ink-2); font-family: inherit; }
.scr-tile .d { display: block; font-size: 11.5px; color: var(--ink-2); margin-top: 2px; }
.scr-tile.warn { border-color: var(--amber); background: var(--amber-soft); }
.scr-tile.warn .d { color: var(--amber); font-weight: 500; }
ul.remarks { list-style: none; margin: 6px 0 8px; padding: 0; font-size: 13px; }
ul.remarks li { display: grid; grid-template-columns: 170px 1fr; gap: 8px; align-items: baseline; padding: 5px 0; border-bottom: 1px solid var(--line-2); }
ul.remarks li:last-child { border-bottom: 0; }
ul.remarks li > .chip { justify-self: start; }
.screen-table tr.ticked td { background: var(--green-soft); }
.scr-actions { position: sticky; bottom: 0; background: var(--surface); margin: 16px -20px 0; padding: 12px 20px; border-top: 1px solid var(--line); align-items: center; }
.scr-actions [data-tickcount] { margin-right: auto; }
dialog.trend-dlg { width: min(720px, calc(100vw - 32px)); }
.trend-chart { position: relative; margin: 6px 0 14px; }
.trend-chart svg { display: block; width: 100%; height: auto; }
.trend-chart .grid { stroke: var(--line-2); stroke-width: 1; }
.trend-chart .ax { fill: var(--ink-2); font-size: 11px; font-family: var(--mono); }
.trend-chart .ln { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.trend-chart .dot { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.trend-chart .lbl { fill: var(--ink); font-size: 12px; font-weight: 600; font-family: var(--mono); }
.trend-chart .xh { stroke: var(--ink-2); stroke-width: 1; stroke-dasharray: 3 3; }
.trend-chart .hit { fill: transparent; cursor: crosshair; }
.trend-tip { position: absolute; transform: translate(-50%, calc(-100% - 14px)); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; font-size: 12.5px; box-shadow: 0 4px 14px rgba(0,0,0,.12); pointer-events: none; white-space: nowrap; display: flex; flex-direction: column; gap: 1px; }
@media (max-width: 640px) { ul.remarks li { grid-template-columns: 1fr; gap: 2px; } }
.screen-head { margin-top: 8px; padding: 10px 12px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--line); font-size: 13.5px; line-height: 1.55; }
.screen-table td, .screen-table th { vertical-align: middle; }
.amend-list { margin: 6px 0 0; padding: 6px 10px; border-left: 3px solid var(--amber); background: var(--amber-soft); font-size: 12.5px; }
.amend-list > div + div { margin-top: 2px; }
.prev-cyc { margin-bottom: 10px; border: 1px solid var(--line); border-radius: 8px; padding: 0 12px; }
.prev-cyc > summary { cursor: pointer; padding: 10px 0; display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; }
.prev-cyc > summary .prev-flags { margin-left: auto; display: flex; gap: 4px; flex-wrap: wrap; }
.prev-cyc[open] > summary { border-bottom: 1px solid var(--line-2); }
.prev-cyc .table-wrap { margin: 4px 0 10px; }
.prev-cyc tr.day-first td { border-top: 1px solid var(--line); }
tr.muted-row td { color: var(--muted); }
select.iso-pick.unset { border-color: var(--amber); background: var(--amber-soft); }
.recon-box { align-items: end; }
#printArea .page-break { break-after: page; height: 0; }

/* Order form: one table per day */
.day-block { border: 1px solid var(--line); border-radius: 8px; margin-bottom: 12px; overflow: hidden; }
.day-head { display: flex; gap: 10px; align-items: baseline; padding: 8px 12px; background: var(--surface-2); border-bottom: 1px solid var(--line); font-size: 14px; }
.day-block .dose-table { width: 100%; }
.dose-table .reg { color: var(--muted); }
.dose-table .vol-chg { color: #6E4A10; font-weight: 600; }
.dose-table .vol-bad { color: var(--red); font-weight: 600; }
.dose-table tr.row-warn td { background: var(--red-soft); }
.dose-table td.acts { white-space: nowrap; }
.dose-table td.acts .btn + .btn { margin-left: 4px; }
.btn.warn { border-color: var(--red); color: var(--red); }
.not-given { font-size: 13px; padding: 8px 12px; border: 1px dashed var(--line); border-radius: 8px; margin-bottom: 8px; }
.not-given ul { margin: 4px 0 0; padding-left: 18px; }
.advice { padding: 10px 12px; border-radius: 8px; background: var(--surface-2); font-size: 13px; }
.advice .rec { margin-top: 6px; }
.advice .rec .btn { margin-left: 6px; }
ul.plain.warn-list li { display: block; margin-bottom: 6px; }
ul.plain.warn-list .sub { display: block; color: var(--muted); font-size: 13px; }
.side details.recent { padding: 6px 8px; }
.side details.recent summary .sub { display: block; color: var(--muted); font-size: 12px; }
.recent-list { list-style: none; padding: 0; margin: 6px 0 2px; font-size: 12.5px; }
.recent-list li { margin-bottom: 5px; }
.recent-list .sub { display: block; color: var(--muted); font-size: 12px; }
.flag-in { color: var(--amber); font-size: 12px; }

/* Day colours on the order form (Day 1, Day 2 … each its own tint) */
.day-head .day-no { font-size: 15px; }
.day-head .day-no b { font-size: 22px; line-height: 1; margin-left: 2px; }
.day-head .day-date { color: var(--muted); font-size: 13px; }
.day-block { border-left-width: 5px; }
.day-c0 { border-left-color: #2E75B6; } .day-c0 .day-head { background: #EAF2FA; }
.day-c1 { border-left-color: #548235; } .day-c1 .day-head { background: #EDF4E7; }
.day-c2 { border-left-color: #C55A11; } .day-c2 .day-head { background: #FBEEE6; }
.day-c3 { border-left-color: #7B5EA7; } .day-c3 .day-head { background: #F1ECF7; }
.day-c4 { border-left-color: #BF8F00; } .day-c4 .day-head { background: #FBF4DF; }
.day-c5 { border-left-color: #1F7A7A; } .day-c5 .day-head { background: #E5F3F3; }
/* Edit drip dialog */
dialog.drip-dialog { width: min(720px, 94vw); max-width: 94vw; }
dialog.drip-dialog .form { overflow-x: hidden; }
.drip-row { display: grid; grid-template-columns: minmax(0, 2.2fr) minmax(0, 1fr) minmax(0, 1.6fr); gap: 12px; margin-top: 12px; align-items: start; }
.drip-row .rate-fld { grid-column: span 2; }
.drip-row .live { padding: 7px 0 0; font-size: 15px; }
.drip-row .live .sub { display: block; color: var(--muted); font-size: 12.5px; }
.drip-row .dur { display: flex; gap: 6px; }
.drip-row .dur input { width: 90px; }
.drip-row select { width: 100%; }
.fc-ok { color: var(--accent, #2E6B4F); }
.drip-alert { margin-top: 10px; padding: 10px 12px; border-radius: 8px; background: var(--red-soft); color: var(--red); font-size: 13px; }
.drip-alert .rec { margin-top: 6px; color: var(--ink); }
.drip-alert .rec .btn { margin-left: 6px; }
@media (max-width: 640px) { .drip-row { grid-template-columns: minmax(0, 1fr); } .drip-row .rate-fld { grid-column: auto; } }

.appt-link { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.appt-act { margin-top: 6px; }
.appt-act .btn { white-space: nowrap; }
.fld[hidden], .check[hidden] { display: none; }

/* ---------- Order remarks ---------- */
.remark-fld .pills { display: flex; flex-wrap: wrap; gap: 6px; margin: 2px 0 6px; }
.pill { font: inherit; font-size: 12.5px; padding: 4px 10px; border-radius: 99px; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink-2); cursor: pointer; }
.pill:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); }
.remark-fld textarea { width: 100%; }
ul.remarks .rm-text { display: block; }
ul.remarks .rm-by { display: block; font-size: 12px; color: var(--muted); }
ul.remarks li.rm-fixed .rm-text { text-decoration: line-through; color: var(--muted); }
ul.remarks li.rm-sub { padding-left: 18px; border-left: 2px solid var(--line); }
.link-btn { border: 0 !important; background: none !important; color: var(--accent) !important; padding: 0 4px !important; min-height: 0 !important; font-size: 12px !important; }
.remark-req { margin-top: 12px; padding: 10px 12px; border: 1px solid var(--amber); border-radius: 8px; background: var(--amber-soft); }
.remark-req > b { display: block; font-size: 13px; color: var(--amber); margin-bottom: 6px; }
.rm-flags { display: flex; flex-wrap: wrap; gap: 4px; }
