/* =========================================================================
   SteadyPaw (standalone) — Clinical Dosing & Treatment Protocols
   Look & feel carried over from the Dr. Libby Ramirez Treatments app:
   clinical blue palette, dark navy sidebar, white "sheet" cards,
   right-aligned tabular dose columns, red/amber warning banners.
   ========================================================================= */

:root {
  --blue-50:  #f2f9fc;
  --blue-100: #daeef3;
  --blue-200: #c4e2ea;
  --blue-300: #92cddc;
  --blue-500: #4f9fc0;
  --blue-600: #548dd4;
  --blue-700: #2f6ba8;
  --blue-900: #173a56;
  --ink:      #1c2b36;
  --ink-soft: #48596a;
  --line:     #d4e4ec;
  --red:      #c0392b;
  --red-bg:   #fdeeec;
  --amber:    #b9770e;
  --amber-bg: #fff6e6;
  --green:    #1e7d4f;
  --green-bg: #e9f6ef;
  --white:    #ffffff;
  /* Semantic surfaces (dark-mode aware): --surface = card/sheet/control
     background, --surface-2 = subtle fill (zebra rows, hovers). ~40 controls
     reference these instead of a hard-coded #fff, so a theme swap is one
     variable block away. */
  --surface:  #ffffff;
  --surface-2:#fafdff;
  --radius:   10px;
  --shadow:   0 1px 2px rgba(23,58,86,.06), 0 8px 24px rgba(23,58,86,.07);
  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}

/* ============================ DARK MODE ================================
   Optional per-machine theme: toggle in the sidebar footer, persisted in
   localStorage, and applied before first paint by the inline <head> script
   in index.html (so there is no light flash on load). It re-defines the
   whole :root palette for dark surfaces; the controls already converted to
   var(--surface) / var(--surface-2) follow automatically. The navy sidebar
   is already dark and reads well here. */
[data-theme="dark"] {
  color-scheme: dark;
  --blue-50:  #15283a;   /* light-tint fills -> dark fill */
  --blue-100: #1c3448;
  --blue-200: #274663;
  --blue-300: #37608a;   /* borders / accents stay legible */
  --blue-500: #4f9fc0;
  --blue-600: #5b9bd5;   /* primary solid (buttons) — white text stays readable */
  --blue-700: #9cc4ec;   /* mostly TEXT -> light for contrast on dark */
  --blue-900: #dcebfa;   /* headings (text only) -> light */
  --ink:      #e9f0f6;
  --ink-soft: #a7bdcf;
  --line:     #2b4359;
  --red:      #e5786a;
  --red-bg:   #3a211d;
  --amber:    #e2a94e;
  --amber-bg: #372b17;
  --green:    #5bbd8e;
  --green-bg: #1b3327;
  --white:    #ffffff;   /* keep pure white for "on" text */
  --surface:  #142634;
  --surface-2:#1b3040;
  --shadow:   0 1px 2px rgba(0,0,0,.45), 0 10px 30px rgba(0,0,0,.5);
}
[data-theme="dark"] body {
  background: linear-gradient(180deg, #0e1d2b 0%, #0d1c2a 60%, #0c1a26 100%);
}
/* The purple "Load" tag is hard-coded light; give it a dark-native fill so
   it doesn't read as a pale patch in dark mode. */
[data-theme="dark"] .tag-load,
[data-theme="dark"] .tag.tag-load { background: #2c2338; color: #c9a8e6; }
[data-theme="dark"] .pair-note { background: #2c2338; color: #c9a8e6; }
/* "How the Math Works" uses .note with a hard-coded olive (#5a4d30) that
   reads as near-invisible on the dark surface; lift it to the dark ink-soft
   tone. (The bold ml/hr / ml units already inherit the light blue-700.) */
[data-theme="dark"] .note { color: var(--ink-soft); }

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: linear-gradient(180deg, var(--blue-50) 0%, #eaf4f8 60%, #e2eef4 100%);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.45;
}

.hidden { display: none !important; }

/* ============================ BUTTONS ================================= */
.btn {
  font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
  border: 1px solid var(--blue-300); background: var(--surface); color: var(--blue-700);
  padding: 8px 16px; border-radius: 8px; transition: all .13s;
}
.btn:hover { background: var(--blue-50); border-color: var(--blue-500); }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-primary { background: var(--blue-600); border-color: var(--blue-600); color: #fff; }
.btn-primary:hover { background: var(--blue-600); border-color: var(--blue-700); }
.btn.wide { width: 100%; padding: 10px; font-size: 14px; }
.btn.mini { font-size: 11.5px; padding: 5px 10px; border-radius: 7px; }
.btn.danger { color: var(--red); border-color: #e5b8b2; }
.btn.danger:hover { background: var(--red-bg); border-color: var(--red); }

/* ============================ KEYBOARD FOCUS (a11y) =================== */
/* One consistent focus ring for keyboard users. :focus-visible matches
   keyboard focus only in modern browsers, so mouse clicks stay clean.
   :where() keeps the rule at zero specificity so existing component focus
   styles (border + glow) win where they exist. Text inputs/selects already
   have a visible focus style — the ring would be double decoration. */
:where(button, a, [tabindex], [role="button"]):focus-visible {
  outline: 2.5px solid var(--blue-600);
  outline-offset: 2px;
}
input:focus-visible, textarea:focus-visible { outline: none; }

/* ============================ AUTH SCREEN ============================= */
#authScreen { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  box-shadow: var(--shadow); padding: 28px; width: 100%; max-width: 440px;
}
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.auth-brand .paw {
  width: 44px; height: 44px; border-radius: 12px; flex: none;
  background: linear-gradient(135deg, var(--blue-300), var(--blue-600));
  display: grid; place-items: center; font-size: 23px;
}
.auth-brand b { font-size: 19px; color: var(--blue-900); display: block; letter-spacing: .4px; }
.auth-brand span { font-size: 10.5px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 1.2px; }
.auth-card h2 { margin: 0 0 6px; font-size: 20px; color: var(--blue-900); }
.auth-sub { margin: 0 0 16px; font-size: 13px; color: var(--ink-soft); line-height: 1.5; }
.auth-err { color: var(--red); font-size: 12.5px; font-weight: 600; margin-top: 10px; min-height: 16px; }
.auth-foot { font-size: 11px; color: var(--ink-soft); margin-top: 12px; line-height: 1.5; }
.auth-foot.verified-foot { color: var(--green); font-weight: 700; }
.auth-link {
  background: none; border: 0; padding: 0; margin-top: 12px;
  color: var(--blue-600); cursor: pointer; font: inherit; font-size: 11px; text-decoration: underline;
}
.auth-link:hover { color: var(--blue-700); }

/* ============================ FIELDS (shared) ========================= */
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.field span { font-size: 11.5px; font-weight: 700; color: var(--ink); }
.field input, .field select, .field textarea {
  font: inherit; font-size: 14px; padding: 7px 10px;
  border: 1.5px solid var(--line); border-radius: 8px; background: var(--surface);
  transition: border .12s, box-shadow .12s; width: 100%;
}
.field textarea { resize: vertical; line-height: 1.5; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 0; border-color: var(--blue-500); box-shadow: 0 0 0 3px rgba(84,141,212,.15);
}
.unit-inline { font-weight: 500; color: var(--ink-soft); font-style: normal; font-size: 11px; }

/* ============================ LAYOUT ================================== */
#app { display: grid; grid-template-columns: 272px 1fr; min-height: 100vh; }

/* ---- sidebar ---- */
#sidebar {
  background: linear-gradient(180deg, #123a56 0%, #0d2c42 100%);
  color: #dcebf5;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  /* No visible scrollbar: it used to steal ~15px in modes that overflow
     (Use) but not in modes that fit (Org), so the footer line wrapped
     differently per mode. Hiding the bar (wheel/touch/keyboard scrolling
     all still work) makes the content width — and the wrapping —
     identical in every mode. */
  scrollbar-width: none;         /* Firefox */
  -ms-overflow-style: none;     /* legacy Edge */
}
#sidebar::-webkit-scrollbar { width: 0; height: 0; display: none; }
.brand { padding: 20px 18px 14px; border-bottom: 1px solid rgba(255,255,255,.1); }
.brand .logo { font-size: 16px; font-weight: 700; letter-spacing: .5px; color: #fff; display: flex; align-items: center; gap: 8px; }
.brand .logo .paw {
  width: 30px; height: 30px; border-radius: 8px; flex: none;
  background: linear-gradient(135deg, var(--blue-300), var(--blue-600));
  display: grid; place-items: center; font-size: 16px;
}
.brand .sub { font-size: 11px; color: #9fc2d8; margin-top: 6px; line-height: 1.4; }

.modeseg { display: flex; gap: 5px; padding: 12px 14px 4px; }
.modeseg button {
  flex: 1; border: 1px solid rgba(255,255,255,.15); background: rgba(255,255,255,.06);
  color: #bcd9ea; font: inherit; font-size: 12.5px; font-weight: 700;
  padding: 8px 0; border-radius: 8px; cursor: pointer; transition: all .12s;
}
.modeseg button:hover:not(:disabled) { background: rgba(255,255,255,.14); color: #fff; }
.modeseg button.on { background: var(--blue-500); color: #fff; border-color: var(--blue-500); }
.modeseg button:disabled { opacity: .35; cursor: not-allowed; }

#nav { padding: 8px 10px 18px; flex: 1; }

/* edges align with the navitems/drug-rows above and below (no extra inset);
   vertical breathing room separates it from the sections above and below */
.libsearch { padding: 12px 0 14px; }
.libsearch input {
  width: 100%; border: 1px solid rgba(255,255,255,.15);
  background: rgba(255,255,255,.07); color: #fff;
  border-radius: 8px; padding: 7px 10px; font: inherit; font-size: 12.5px;
}
.libsearch input::placeholder { color: #8fb2c9; }
.libsearch input:focus { outline: none; border-color: var(--blue-300); background: rgba(255,255,255,.12); }

/* Quick-add from search results (punch-list #18) */
.quickadd { display: flex; flex-wrap: wrap; gap: 6px; padding: 2px 6px 4px; }
.qa-chip {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 12px; font-weight: 700; padding: 5px 10px; border-radius: 14px;
  border: 1.5px solid var(--blue-300); background: rgba(255,255,255,.10);
  color: #eaf4fb; cursor: pointer; transition: all .12s;
}
.qa-add:hover { background: var(--blue-500); border-color: var(--blue-500); color: #fff; }
.qa-alias { font-weight: 500; color: #a9c9dd; }
.qa-add:hover .qa-alias { color: #eaf4fb; }
.qa-done { cursor: default; border-style: dashed; color: #9fc3da; background: rgba(255,255,255,.05); }
.qa-more { font-size: 11px; color: #8fb2c9; align-self: center; }
.qa-empty { font-size: 11.5px; color: #8fb2c9; }

.navgroup { margin-top: 14px; --h: 210; --s: 50%; }
.navgroup-title {
  font-size: 10px; font-weight: 700; letter-spacing: 1.2px; text-transform: uppercase;
  color: #7fb0cd; padding: 4px 10px 6px;
}
.navitem {
  display: flex; align-items: center; gap: 8px;
  width: 100%; text-align: left; border: 0; cursor: pointer;
  background: hsl(var(--h) var(--s) 55% / .16); color: #cfe4f0;
  padding: 9px 10px; border-radius: 8px; font-size: 13px; font-family: inherit;
  transition: background .12s, color .12s;
}
.navitem:hover { background: hsl(var(--h) var(--s) 60% / .42); color: #fff; }

.drug-row {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px; margin: 2px 0; border-radius: 8px;
  background: hsl(var(--h) var(--s) 55% / .14); color: #cfe4f0;
  font-size: 13px; cursor: grab; user-select: none;
  transition: background .12s;
}
.drug-row:hover { background: hsl(var(--h) var(--s) 60% / .4); color: #fff; }
.drug-row:active { cursor: grabbing; }
.drug-row.dragging { opacity: .45; }
.drug-row .dname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drug-row .inmark { font-size: 11px; color: #8fe0b0; font-weight: 700; }
.addbtn {
  flex: none; width: 22px; height: 22px; border-radius: 6px; padding: 0;
  border: 1px solid rgba(255,255,255,.25); background: rgba(255,255,255,.08);
  color: #fff; font-size: 14px; line-height: 1; cursor: pointer; transition: all .12s;
}
.addbtn:hover { background: var(--blue-500); border-color: var(--blue-500); }
.addbtn.favbtn { font-size: 13px; color: #cfe4f0; }
.addbtn.favbtn:hover { background: #4a6b84; border-color: #4a6b84; }
.addbtn.favbtn.on { color: #ffd76a; border-color: rgba(255,215,106,.6); background: rgba(255,215,106,.14); }

.sidebar-foot { padding: 12px 16px 16px; border-top: 1px solid rgba(255,255,255,.1); font-size: 10.5px; color: #8fb2c9; line-height: 1.5; }
.sidebar-foot b { color: #bcd9ea; }
.sidebar-foot .buildstamp { margin-top: 4px; opacity: .6; }
/* sync status line sits on the navy sidebar — keep it bright enough to read */
.sidebar-foot .rnote { color: #cfe4f0; }
/* Footer: the status line is its OWN line (a single text span — even the
   longest variant, "session expired · cached …", fits the ~240px content
   width), and the action row carries only the two compact buttons (which
   always fit together) — so "📮 Feedback" can never dangle alone under
   the status text. */
.sidefoot-status { margin-top: 4px; }
.sidefoot-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; row-gap: 2px; margin-top: 4px; }
.sidefoot-row .linkbtn { margin-top: 0; flex: 0 1 auto; min-width: 0; }
.linkbtn {
  background: none; border: 0; padding: 2px 0; margin-top: 4px;
  color: #9fc2d8; font: inherit; font-size: 11px; text-decoration: underline; cursor: pointer;
}
.linkbtn:hover { color: #fff; }
/* Sign out: distinct full-width button so it's easy to find in the footer */
.signoutbtn {
  width: 100%; margin-top: 10px; padding: 8px 10px; border-radius: 8px;
  border: 1px solid rgba(255,255,255,.35); background: rgba(255,255,255,.10);
  color: #fff; font: inherit; font-size: 12.5px; font-weight: 700; cursor: pointer;
  transition: background .12s, border-color .12s;
}
.signoutbtn:hover { background: rgba(255,255,255,.22); border-color: rgba(255,255,255,.5); }

/* ---- universal search (top of sidebar, above the page list) ---- */
#sideSearch { padding: 10px 12px 2px; }
.searchbtn {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.16);
  color: #cfe4f0; padding: 8px 12px; border-radius: 9px;
  font-size: 12.5px; cursor: pointer; font-family: inherit;
  transition: background .12s, color .12s;
}
.searchbtn:hover { background: rgba(255,255,255,.14); color: #fff; }
.searchbtn .kbd {
  font-size: 10px; color: #9fc2d8; border: 1px solid rgba(255,255,255,.22);
  border-radius: 5px; padding: 1px 6px; white-space: nowrap;
}

/* ---- main ---- */
#main { padding: 18px 22px 40px; min-width: 0; }

/* ---- patient bar ---- */
#patientbar {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px 14px; margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.pf { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.pf span { font-size: 10px; font-weight: 700; letter-spacing: .8px; text-transform: uppercase; color: var(--ink-soft); }
.pf input {
  border: 1px solid transparent; background: var(--blue-50); border-radius: 7px;
  padding: 6px 9px; font: inherit; font-size: 13.5px; color: var(--ink);
  transition: border .12s, background .12s; width: 100%;
}
.pf input:hover { background: var(--surface); }
.pf input:focus { outline: 0; border-color: var(--blue-500); background: var(--surface); box-shadow: 0 0 0 3px rgba(84,141,212,.15); }

/* ============================ SHEET =================================== */
.sheet {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; box-shadow: var(--shadow);
  padding: 24px 26px 20px; max-width: 1400px; margin: 0 auto;
}
.sheet-head { border-bottom: 3px solid var(--blue-100); padding-bottom: 16px; margin-bottom: 18px; }
.sheet-kicker { font-size: 11px; font-weight: 700; letter-spacing: 1.6px; text-transform: uppercase; color: var(--blue-600); }
.sheet-head h1 { margin: 4px 0 6px; font-size: 27px; color: var(--blue-900); letter-spacing: -.3px; }
.sheet-sub { font-size: 12px; color: var(--ink-soft); }
.sheet-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }

/* Hospital branding block (punch-list #10): logo + name + site number,
   first row of every sheet header (and the pump sheet). Prints with the
   sheet — it carries no .no-print. */
.sheet-brand { display: flex; align-items: center; gap: 9px; margin-bottom: 9px; }
.sheet-brand-logo { height: 30px; max-width: 170px; object-fit: contain; display: block; }
.sheet-brand-name { font-size: 14.5px; font-weight: 700; color: var(--blue-900); letter-spacing: -.1px; }
.sheet-brand-site { font-size: 11px; font-weight: 700; color: var(--blue-700, #1d4f8f); background: var(--blue-50); border: 1px solid var(--blue-200, #bcd4ec); border-radius: 999px; padding: 2px 9px; white-space: nowrap; }
.br-preview { margin: 10px 0 4px; padding: 12px; background: var(--blue-50, #f2f7fd); border: 1px dashed var(--blue-300, #9ec3e8); border-radius: 9px; display: flex; align-items: center; }
.br-preview img { max-height: 64px; max-width: 260px; object-fit: contain; display: block; }
/* Org console: "logo set" pill in the Hospitals table (the row carries
   only the has_logo flag — the image itself is org-only preview data). */
.logotag { font-size: 10.5px; font-weight: 700; color: var(--blue-700, #1d4f8f); background: var(--blue-50, #f2f7fd); border: 1px solid var(--blue-200, #bcd4ec); border-radius: 999px; padding: 1px 7px; white-space: nowrap; margin-left: 3px; vertical-align: 1px; }

.intro { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.intro-line { font-size: 12.5px; color: var(--ink-soft); background: var(--blue-50); border-left: 3px solid var(--blue-300); padding: 7px 12px; border-radius: 0 7px 7px 0; }

/* ---- two-column grid ---- */
.grid2 { display: grid; grid-template-columns: 300px 1fr; gap: 16px; align-items: start; }
.col-left { position: sticky; top: 14px; display: flex; flex-direction: column; gap: 14px; }
.col-right { display: flex; flex-direction: column; gap: 14px; min-width: 0; }

/* ---- cards ---- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
/* Consistent vertical rhythm between the stacked top-level sections in a
   sheet (results -> syringe builder -> PIMS -> foot). Nested cards in
   col-left / col-right keep their own flex gap; only direct children of
   .sheet get this, so the drug list and the Syringe Mix Builder no longer
   sit flush against each other. */
.sheet > .card { margin-top: 16px; }
.card-title {
  margin: 0 0 10px; font-size: 12px; font-weight: 800; letter-spacing: 1px; text-transform: uppercase;
  color: var(--blue-700); border-bottom: 2px solid var(--blue-100); padding-bottom: 7px;
}
.inputs-card { background: var(--surface); }
.count-pill { background: var(--blue-100); color: var(--blue-700); border-radius: 20px; padding: 1px 9px; font-size: 11px; margin-left: 6px; vertical-align: 1px; }

/* ---- weight row ---- */
.weight-row { display: flex; align-items: center; gap: 8px; }
.weight-row input {
  flex: 1; font: inherit; font-weight: 700; font-size: 16px; padding: 7px 10px;
  border: 1.5px solid var(--line); border-radius: 8px; background: var(--surface); min-width: 0;
}
.weight-row input:focus { outline: 0; border-color: var(--blue-500); box-shadow: 0 0 0 3px rgba(84,141,212,.15); }
.weight-row .unit { font-weight: 700; color: var(--blue-700); font-size: 14px; }
.unit-toggle {
  border: 1.5px solid var(--line); background: var(--surface); cursor: pointer;
  border-radius: 7px; padding: 6px 9px; font-size: 13px; color: var(--ink-soft);
}
.unit-toggle:hover { border-color: var(--blue-500); color: var(--blue-700); }

/* ---- species / y-n toggles ----
   Wrapping rounded buttons (not one clipped bar) so multi-species
   hospitals (canine + feline + avian + rabbit + …) wrap onto extra rows
   instead of hiding the last species. Also used by the 2-option CRI
   rate-display toggle, where it simply reads as two buttons. */
.yn-toggle { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.yn-toggle button {
  border: 1.5px solid var(--line); background: var(--surface); font: inherit; font-size: 13px; font-weight: 700;
  padding: 7px 14px; border-radius: 8px; cursor: pointer; color: var(--ink-soft);
  white-space: nowrap;
}
.yn-toggle button.on { background: var(--blue-600); border-color: var(--blue-600); color: #fff; }

/* ---- dose table (results) ---- */
table.dose, table.ref { width: 100%; border-collapse: collapse; font-size: 13px; }
table.dose th {
  font-size: 10px; letter-spacing: .9px; text-transform: uppercase; color: var(--ink-soft);
  text-align: right; padding: 4px 8px 8px; font-weight: 700;
}
table.dose th:first-child { text-align: left; }
table.dose td { padding: 8px; border-top: 1px solid var(--blue-50); vertical-align: middle; }
table.dose tr:nth-child(even) td { background: var(--surface-2); }
td.lbl { font-weight: 600; color: var(--ink); }
.rnote { font-weight: 400; font-size: 11px; color: var(--ink-soft); }
td.val { font-weight: 800; color: var(--blue-700); text-align: right; font-variant-numeric: tabular-nums; font-size: 13.5px; white-space: nowrap; }
td.val.pending { color: #b7c6d2; font-weight: 600; }
/* Deterministic fit: `table-layout: fixed` makes the table exactly the width
   of its container (a max-width cap on the Drug cell proved unreliable in
   some browsers in auto layout), with a min-width so narrow windows scroll
   (.dosewrap) instead of crushing the columns. */
table.dose { table-layout: fixed; min-width: 860px; }
/* Deterministic column widths (fixed layout + fixed px on the must-fit
   columns): Dose / Calculated / Volume get guaranteed pixel widths so their
   values NEVER wrap (base `white-space: nowrap`), the Actions column is wide
   enough for ⚠ ↑ ↓ ✕ on one line (never clipped), and the Drug column takes
   the remaining space — name + tags + concentration on as few lines as the
   name allows, wrapping at word boundaries (no mid-unit breaks). Below
   860px the .dosewrap scroller takes over instead of crushing the columns;
   on wide windows the sheet (max-width 1400px) gives the Drug column room
   to breathe. */
table.dose th:nth-child(2) { width: 100px; }
table.dose th:nth-child(3) { width: 150px; }
table.dose th:nth-child(4) { width: 170px; }
table.dose th.acts-th { width: 112px; }
/* Consistent per-drug controls: a dedicated right-most Actions column
   (screen only) so EVERY drug group shows the same buttons in the same
   place — warnings ⚠ (when the drug has curated warnings), then
   move up / down / remove — and the Drug cell keeps only name + tags +
   concentration + the compatibility badge. Fixes the wrapped button row
   that collided with the centered dose value on rows carrying a wide
   compatibility badge. */
table.dose .acts { text-align: center; vertical-align: middle; }
table.dose .acts .rowacts { display: inline-flex; flex-wrap: nowrap; gap: 4px; justify-content: center; margin: 0; }
table.dose .acts .rowacts button { flex: none; }
/* compatibility badge: its own full-width row under the name, left-aligned */
table.dose .xact-row { display: block; width: 100%; text-align: left; margin: 5px 0 0; white-space: normal; overflow-wrap: break-word; }
.sec-extra { margin-top: 10px; font-size: 12px; color: var(--ink-soft); border-top: 1px solid var(--blue-50); padding-top: 9px; }

/* drug name + tags in results */
.drugname { font-weight: 700; color: var(--ink); cursor: pointer; }
.drugname:hover { color: var(--blue-700); text-decoration: underline; }
.tag {
  font-size: 9.5px; font-weight: 800; letter-spacing: .6px; text-transform: uppercase;
  border-radius: 5px; padding: 2px 6px; margin-left: 6px; vertical-align: 1px; white-space: nowrap;
}
.tag-cri { background: var(--blue-100); color: var(--blue-700); }
.tag-bolus { background: var(--green-bg); color: var(--green); }
.tag-load { background: #efe0f5; color: #6d3a94; }
.tag-maint { background: var(--amber-bg); color: var(--amber); }
.tag-admin { background: var(--amber-bg); color: var(--amber); }
.tag-user { background: var(--surface-2); color: var(--ink-soft); }
/* consortium verification badge (DVM sign-off vs a named reference) */
.tag-verified { background: var(--green-bg); color: var(--green); }

/* import preview status tags (punch-list #7) */
.tag-create { background: var(--green-bg); color: var(--green); }
.tag-update { background: var(--blue-100); color: var(--blue-700); }
.tag-unchanged { background: var(--surface-2); color: var(--ink-soft); }
.tag-error { background: var(--red-bg); color: var(--red); }
.impsum {
  margin: 10px 0 4px; font-size: 13px; font-weight: 700; color: var(--ink);
  padding: 8px 11px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 9px;
}

/* load→maintain pairs: the two rows read as one linked group */
tr.pairrow td:first-child { box-shadow: inset 3px 0 0 #6d3a94; }
.pair-note {
  background: #efe0f5; color: #6d3a94; font-weight: 800;
  border-radius: 5px; padding: 2px 6px; margin-left: 6px; white-space: nowrap;
}
.pair-check { margin-top: 8px; font-size: 12.5px; }
/* maint dose row has an extra freq input */
.doserow-maint { grid-template-columns: 56px 1fr 1fr 64px 64px 1fr; }

/* titration (punch-list #3): session set-point chip on the row */
.titertag {
  background: var(--blue-100); color: var(--blue-700); font-weight: 800;
  border-radius: 5px; padding: 2px 6px; margin-left: 6px; white-space: nowrap;
}
.titertag + .icobtn { margin-left: 3px; }
/* titration table in the drug modal */
.titerbox {
  margin: 8px 0 4px; padding: 8px 10px;
  border: 1px dashed var(--blue-500); border-radius: 8px; background: var(--blue-50);
  font-size: 12.5px;
}
.titerlvls { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.titerlvl {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  border-radius: 6px; padding: 3px 8px; font-size: 12px; font-weight: 700; cursor: pointer;
  transition: all .12s;
}
.titerlvl:hover { border-color: var(--blue-500); color: var(--blue-700); }
.titerlvl.on { background: var(--blue-600); border-color: var(--blue-700); color: #fff; }
.titeract { margin-top: 6px; font-weight: 800; color: var(--blue-700); }

/* row action buttons */
.rowacts { margin-left: 8px; display: inline-flex; gap: 3px; vertical-align: middle; }
.icobtn {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-soft);
  border-radius: 6px; width: 22px; height: 22px; font-size: 12px; line-height: 1; cursor: pointer; padding: 0;
  transition: all .12s;
}
.icobtn:hover { border-color: var(--blue-500); color: var(--blue-700); background: var(--blue-50); }
.rowwarn {
  border: 0; cursor: pointer; background: var(--amber-bg);
  color: var(--amber); font-size: 12px; line-height: 1;
  border-radius: 6px; padding: 3px 6px; transition: background .12s;
}
.rowwarn:hover { background: var(--amber-bg); }

tr.dragging td { opacity: .4; }
.muted { color: #a8b8c4; font-size: 12px; font-weight: 400; }

/* ---- drop zone ---- */
.dz { border: 2px dashed transparent; border-radius: 10px; padding: 3px; transition: all .12s; min-height: 60px; }
.dz.over { border-color: var(--blue-500); background: var(--blue-50); }
.dz-empty {
  text-align: center; padding: 44px 20px; color: var(--ink-soft);
  border: 2px dashed var(--blue-200); border-radius: 12px; background: var(--blue-50);
}
.dz-empty .big { font-size: 34px; margin-bottom: 8px; }
.dz-empty b { display: block; color: var(--ink); font-size: 15px; margin-bottom: 4px; }
.dz-empty span { font-size: 12.5px; }

/* Dose-table scroll wrapper: the Drug column carries name + tags + inline
   action buttons, so on narrower screens the table is wider than the card.
   This wrapper scrolls ONLY the table horizontally (the compatibility / max /
   vial strips above it stay full-width) so the Calculated + Volume columns
   are always reachable and never pour off the page. */
.dosewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 2px -3px 0; padding: 0 3px; }
.dosewrap table.dose { min-width: 860px; } /* matches the table's own min-width (narrow windows scroll instead of crushing) */
.dosewrap::-webkit-scrollbar { height: 8px; }
.dosewrap::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }

/* ---- ref / admin tables ---- */
table.ref th { font-size: 10px; letter-spacing: .8px; text-transform: uppercase; color: var(--ink-soft); text-align: left; padding: 4px 10px 7px; }
table.ref td { padding: 7px 10px; border-top: 1px solid var(--blue-50); vertical-align: top; }
table.ref tr:nth-child(even) td { background: var(--surface-2); }
table.ref .doses { font-size: 12.5px; line-height: 1.5; }
td.acts { white-space: nowrap; text-align: right; }
td.acts .btn + .btn { margin-left: 6px; }
.table-note { margin-top: 9px; font-size: 11.5px; color: var(--ink-soft); }
.tbl-wrap { overflow-x: auto; }
.tblfilter {
  display: block; width: 100%; max-width: 340px; margin: 2px 0 10px;
  border: 1px solid var(--blue-100); border-radius: 8px;
  padding: 8px 12px; font: inherit; font-size: 13px; background: var(--surface);
}
.tblfilter:focus { outline: none; border-color: var(--blue-300); box-shadow: 0 0 0 3px var(--blue-50); }

/* ---- notes ---- */
.note { font-size: 12.5px; color: #5a4d30; padding: 6px 0; border-top: 1px dashed var(--blue-50); }
.inputs-card .note { color: var(--ink-soft); }
.note b { color: var(--blue-700); }

/* ---- footer ---- */
.sheet-foot { margin-top: 20px; border-top: 2px solid var(--blue-100); padding-top: 14px; }
.patient-line { font-size: 12.5px; color: var(--ink); margin-bottom: 10px; }
.patient-line b { color: var(--blue-700); }
.disclaimer { font-size: 11px; color: var(--ink-soft); line-height: 1.5; margin-bottom: 8px; }
.credit { font-size: 11px; color: var(--ink-soft); }

/* ============================ ADD-USER ROW ============================ */
.adduser {
  display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; padding-top: 14px;
  border-top: 2px solid var(--blue-100); align-items: center;
}
.adduser-title { font-size: 11px; font-weight: 800; letter-spacing: 1px; text-transform: uppercase; color: var(--ink-soft); margin-right: 4px; }
.adduser input, .adduser select {
  border: 1.5px solid var(--line); border-radius: 8px; padding: 7px 10px; font: inherit; font-size: 13px; background: var(--surface);
}
.adduser input:focus, .adduser select:focus { outline: none; border-color: var(--blue-500); box-shadow: 0 0 0 3px rgba(84,141,212,.15); }
.adduser .btn { margin-left: auto; }

/* ============================ MODALS ================================== */
.warn-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(13, 44, 66, .55); backdrop-filter: blur(2px);
  display: none; align-items: center; justify-content: center; padding: 20px;
}
.warn-overlay.show { display: flex; }
.modal {
  background: var(--surface); border-radius: 14px; max-width: 560px; width: 100%;
  box-shadow: 0 24px 60px rgba(10, 30, 48, .45);
  border-top: 6px solid var(--red);
  animation: modalIn .18s ease-out;
  max-height: 90vh; overflow-y: auto;
}
@keyframes modalIn { from { transform: translateY(14px) scale(.98); opacity: 0; } to { transform: none; opacity: 1; } }
.modal.tone-info, .modal-drug, .modal-form { border-top-color: var(--blue-600); }
.modal-head { font-size: 16.5px; font-weight: 700; color: var(--red); padding: 16px 20px 4px; letter-spacing: .2px; }
.modal.tone-info .modal-head, .modal-drug .modal-head, .modal-form .modal-head { color: var(--blue-700); }
.modal-body { padding: 10px 20px 6px; font-size: 13.5px; line-height: 1.55; color: var(--ink); }
.modal-body p { margin: 8px 0; }
.modal-actions { padding: 12px 20px 18px; display: flex; justify-content: flex-end; gap: 8px; align-items: center; flex-wrap: wrap; }

/* page form (New Page / Edit Page): wider, with the BODY as the single
   scroll surface — head and actions stay pinned, the drug list scrolls
   inside it, and the page behind the overlay never scrolls. */
.modal.modal-pageform {
  max-width: 760px;
  max-height: 92vh;
  display: flex; flex-direction: column;
}
.modal.modal-pageform .modal-head { flex: none; }
.modal.modal-pageform .modal-body { flex: 1 1 auto; overflow-y: auto; min-height: 0; }
.modal.modal-pageform .modal-actions { flex: none; }
/* lock the page behind any open modal (toggled by openModal / hideModal) */
body.modal-open { overflow: hidden; }

/* global search palette: wider so long typed queries don't clip, and the
   input itself is a proper full-width field */
.modal.modal-gs { max-width: 720px; }
.modal-gs #gsInput {
  width: 100%; padding: 9px 12px; border: 1px solid rgba(0,0,0,.22);
  border-radius: 8px; font: inherit; font-size: 14px; color: var(--ink);
}
.modal-gs #gsInput::placeholder { color: var(--ink-soft); }
.modal-gs #gsInput:focus { outline: none; border-color: var(--blue-500); box-shadow: 0 0 0 3px rgba(84,141,212,.15); }

/* org console: go-live readiness checklist modal */
.readyscore {
  display: inline-block; font-size: 14px; font-weight: 800;
  padding: 6px 14px; border-radius: 10px; margin: 4px 0 10px;
}
.readylist { list-style: none; margin: 0; padding: 0; }
.readylist li {
  padding: 8px 4px; border-top: 1px dashed var(--line);
  font-size: 13.5px; display: flex; gap: 7px; align-items: baseline; flex-wrap: wrap;
}
.readylist li:first-child { border-top: 0; }
.ready-ok b { color: var(--blue-700); }
.ready-missing b { color: var(--ink); }

/* org console: system status card (support's first stop) */
.sysstatus { margin-top: 14px; border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; background: var(--blue-50); }
.sstit { font-size: 12.5px; font-weight: 700; color: var(--blue-900); margin-bottom: 4px; }
.ssrow { display: flex; gap: 10px; align-items: baseline; font-size: 12.5px; padding: 4px 0; border-top: 1px dashed var(--line); }
.ssrow:first-of-type { border-top: none; }
.ssl { flex: 0 0 175px; color: var(--ink-soft); }
.ssv { flex: 1; line-height: 1.6; }

/* drug detail modal */
.conc-line { margin: 4px 0 12px; font-size: 13px; }
/* dose-row citation — the source of the doses shown, on the dose surface */
.drugsrcline { margin: -6px 0 10px; font-size: 11.5px; color: var(--ink-soft); }
.srctag { font-size: 11px; }
.mwarns { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.warn { font-size: 12.5px; font-weight: 600; color: var(--red); background: var(--red-bg); border-left: 3px solid var(--red); padding: 8px 12px; border-radius: 0 8px 8px 0; }
.spgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.spcard { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: var(--blue-50); }
.spcard b { font-size: 12.5px; display: block; margin-bottom: 6px; color: var(--blue-900); }
.sprow { display: flex; justify-content: space-between; gap: 8px; font-size: 12.5px; padding: 4px 0; border-top: 1px dashed var(--line); }
.sprow span { color: var(--ink-soft); }
.sprow b { color: var(--ink); font-variant-numeric: tabular-nums; text-align: right; }
.mnotes { display: flex; flex-direction: column; gap: 2px; }

/* drug edit form */
.form { display: flex; flex-direction: column; }
.frow { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.conc-row { display: flex; gap: 6px; }
.conc-row input { flex: 1; min-width: 0; }
.conc-row select {
  border: 1.5px solid var(--line); border-radius: 8px; padding: 7px 8px; font: inherit; font-size: 13px; background: var(--surface);
}
.conc-row select:focus { outline: none; border-color: var(--blue-500); }
.species-block { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin: 4px 0 12px; background: var(--surface-2); }
.sp-check { margin-bottom: 8px; }
.check { display: flex; align-items: center; gap: 9px; padding: 4px 0; font-size: 13px; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--blue-600); flex: none; }
.doserow { display: grid; grid-template-columns: 56px 1fr 1fr 72px 72px; gap: 6px; align-items: center; margin-bottom: 6px; }
.doselabel { font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .6px; color: var(--ink-soft); }
.doserow input {
  border: 1.5px solid var(--line); border-radius: 7px; padding: 6px 8px; font: inherit; font-size: 13px; width: 100%; min-width: 0;
}
.doserow select {
  border: 1.5px solid var(--line); border-radius: 7px; padding: 6px 8px; font: inherit; font-size: 12.5px; background: var(--surface); width: 100%; min-width: 0;
}
.doserow input:focus, .doserow select:focus { outline: none; border-color: var(--blue-500); box-shadow: 0 0 0 3px rgba(84,141,212,.15); }

/* 🌐 Master drug form (Curator): wide enough for the 6-column dose rows,
   the BODY is the scroll surface (head + actions stay pinned), and the
   CRI titration sub-row + caption lines keep their full width. */
.modal.modal-masterdrug {
  /* 940 px: wide enough that the longest single line — the
     "🔗 Load → maintain pair — … in every hospital" caption — stays on
     one row (≈810 px of text at 12.5 px) instead of wrapping. */
  max-width: 940px;
  max-height: 92vh;
  display: flex; flex-direction: column;
}
.modal-masterdrug .modal-head { flex: none; }
.modal-masterdrug .modal-body { flex: 1 1 auto; overflow-y: auto; min-height: 0; }
.modal-masterdrug .modal-actions { flex: none; }
/* 6th column = context cell (CRI cap / Maint freq). Scoped to this modal
   so the hospital drug form's 5-column rows are untouched. */
.modal-masterdrug .doserow { grid-template-columns: 52px minmax(0,1fr) minmax(0,1.15fr) 84px 84px minmax(0,1fr); gap: 6px 8px; }
.modal-masterdrug .doserow .titnote { grid-column: 4 / -1; }
.modal-masterdrug .dosenote { font-size: 11px; margin: 0 0 8px 52px; }
.form-err { color: var(--red); font-size: 12.5px; font-weight: 600; margin-right: auto; }

/* ============================ AUTH TABS (device vs hospital) ========= */
.authtabs {
  display: flex; gap: 4px; margin-bottom: 18px;
  background: var(--blue-50); border: 1px solid var(--line); border-radius: 10px; padding: 4px;
}
.authtab {
  flex: 1; border: 0; background: transparent; cursor: pointer;
  font: inherit; font-size: 12.5px; font-weight: 700; color: var(--ink-soft);
  padding: 7px 10px; border-radius: 7px; transition: all .12s;
}
.authtab:hover { color: var(--blue-700); }
.authtab.on { background: var(--surface); color: var(--blue-700); box-shadow: 0 1px 3px rgba(23,58,86,.14); }
.auth-invite { margin-top: 4px; }

/* ============================ SYNC BANNER (top of main) =============== */
.syncbanner {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-size: 12.5px; line-height: 1.45;
  border-radius: var(--radius); padding: 9px 14px; margin-bottom: 14px;
  border: 1px solid; box-shadow: var(--shadow);
}
.syncbanner .linkbtn { margin: 0 0 0 auto; padding: 0; font-size: 12px; }
.syncbanner.ok { background: var(--green-bg); border-color: #bfe3cf; color: #14563a; }
.syncbanner.ok .linkbtn { color: #14563a; }
.syncbanner.ok .linkbtn:hover { color: #0c3a25; }
.syncbanner.bad { background: var(--amber-bg); border-color: #ecd3a0; color: #6e4a12; }
.syncbanner.bad b { color: var(--amber); }
.syncbanner.bad .linkbtn { color: var(--amber); }
.syncbanner.bad .linkbtn:hover { color: #8f5a0a; }

/* ============================ UPDATE BANNER (top of main) ============ */
.updatebanner {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-size: 12.5px; line-height: 1.45;
  border-radius: var(--radius); padding: 9px 14px; margin-bottom: 14px;
  border: 1px solid var(--blue-300); box-shadow: var(--shadow);
  background: var(--blue-50); color: var(--blue-700);
  border-left: 4px solid var(--blue-500);
}
.updatebanner .linkbtn { margin: 0; padding: 0; font-size: 12px; color: var(--blue-700); }
.updatebanner .linkbtn:hover { color: var(--blue-500); text-decoration: underline; }
.updatebanner-actions { margin-left: auto; display: inline-flex; gap: 2px; }

/* ---- sync status dot (sidebar footer) ---- */
.syncdot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; vertical-align: 0; }
.syncdot.ok { background: #8fe0b0; box-shadow: 0 0 0 2px rgba(143,224,176,.25); }
.syncdot.bad { background: var(--amber-bg); box-shadow: 0 0 0 2px rgba(240,179,92,.25); }

/* ---- hospital page buttons (sidebar, USE mode) ---- */
.navitem.pageitem { font-weight: 600; }
.navitem.pageitem .rnote { margin-left: auto; font-weight: 600; }
.navitem.on {
  background: rgba(255,255,255,.22); color: #fff;
  box-shadow: inset 3px 0 0 var(--blue-300);
}

/* ---- org console pages (sidebar switches cards; no long scroll) -------- */
.orgpage-off { display: none; }

/* ---- invite code + result (admin users card) ------------------------- */
.invite-code {
  font-family: Consolas, "SF Mono", Menlo, monospace;
  font-size: 12.5px; letter-spacing: .5px; word-break: break-all;
  background: var(--blue-50); border: 1.5px dashed var(--blue-300);
  border-radius: 8px; padding: 9px 12px; margin: 8px 0;
  user-select: all; cursor: text;
}
.invite-result { margin-top: 12px; font-size: 13px; line-height: 1.5; }
.invite-result:empty { display: none; }

/* ============================ COMPATIBILITY + TOX (curated) ========== */
/* row badge button inside .rowacts — worst flagged pair for that drug */
.xact {
  border: 1.5px solid; cursor: pointer; font: inherit; font-size: 11px; font-weight: 700;
  border-radius: 6px; padding: 2px 7px; white-space: nowrap; transition: all .12s;
}
.xact.sev-info { color: var(--blue-700); border-color: var(--blue-300); background: var(--blue-50); }
.xact.sev-info:hover { background: var(--blue-100); border-color: var(--blue-500); }
.xact.sev-caution { color: var(--amber); border-color: #e3c284; background: var(--amber-bg); }
.xact.sev-caution:hover { background: var(--amber-bg); }
.xact.sev-contraindicated { color: var(--red); border-color: #e5b8b2; background: var(--red-bg); }
.xact.sev-contraindicated:hover { background: var(--red-bg); }

/* compatibility strip above the results table */
.xactstrip {
  border: 1px solid var(--blue-200); background: var(--surface-2);
  border-radius: 10px; padding: 9px 14px 8px; margin-bottom: 14px;
  font-size: 12.5px; line-height: 1.5;
}
.xactstrip > b { font-size: 12px; letter-spacing: .2px; color: var(--blue-900); }

/* flagged-pair item — strip, drug modal, and curator workspace */
.xact-item {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px;
  border-left: 3px solid; border-radius: 0 7px 7px 0;
  padding: 7px 11px; margin-top: 7px; font-size: 12px; color: var(--ink);
}
.xact-item .xact-name { font-weight: 700; color: var(--ink); }
.xact-item.sev-info { background: var(--blue-50); border-color: var(--blue-300); }
.xact-item.sev-caution { background: var(--amber-bg); border-color: #d9a94e; }
.xact-item.sev-contraindicated { background: var(--red-bg); border-color: #d98a80; }

/* severity tags (curator compatibility table) */
.tag.sev-info { background: var(--blue-100); color: var(--blue-700); }
.tag.sev-caution { background: var(--amber-bg); color: var(--amber); }
.tag.sev-contraindicated { background: var(--red-bg); color: var(--red); }

/* drug-modal sections (compatibility + toxicology) */
.msec {
  border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 13px 9px; margin: 0 0 12px; background: var(--surface-2);
}
.msec-title {
  margin: 0 0 5px; font-size: 11.5px; font-weight: 800; letter-spacing: .8px;
  text-transform: uppercase; color: var(--blue-700);
}
.toxrow { padding: 7px 0; font-size: 12.5px; }
.toxrow + .toxrow { border-top: 1px dashed var(--line); }

/* ============================ PAGES (manager + form) =================== */
.page-desc { margin-top: 5px; font-size: 12.5px; font-style: italic; color: var(--ink-soft); }

.pagedrug {
  border: 1px solid var(--line); border-radius: 9px;
  padding: 8px 12px; margin-top: 8px; background: var(--surface-2);
}
.pgdrugs {
  max-height: min(420px, 44vh); overflow-y: auto;
  margin: 2px 2px 8px 0; padding: 2px 4px 2px 0;
}
.pmeta {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px;
  margin-top: 8px; padding-top: 9px; border-top: 1px dashed var(--line);
}
.pmeta input {
  width: 100%; min-width: 0;
  border: 1.5px solid var(--line); border-radius: 7px; padding: 6px 8px;
  font: inherit; font-size: 12.5px; background: var(--surface);
}
.pmeta input:focus { outline: 0; border-color: var(--blue-500); box-shadow: 0 0 0 3px rgba(84,141,212,.15); }

/* page-form drug picker — search + class chips + Selected/Add zones */
.pgpick-head { display: flex; align-items: center; gap: 8px; margin: 2px 0 8px; }
.pgpick-head .msec-title { margin: 0; }
.pgpick-count { font-size: 12px; font-weight: 600; color: var(--ink-soft); }
.pgpick-clear {
  margin-left: auto; border: 0; background: none; cursor: pointer;
  font: inherit; font-size: 12px; font-weight: 700; color: var(--blue-700);
  padding: 3px 8px; border-radius: 6px;
}
.pgpick-clear:hover { background: var(--blue-100); }
#pgPickSearch {
  width: 100%; box-sizing: border-box;
  border: 1.5px solid var(--line); border-radius: 8px; padding: 8px 10px;
  font: inherit; font-size: 13px; background: var(--surface);
}
#pgPickSearch:focus { outline: 0; border-color: var(--blue-500); box-shadow: 0 0 0 3px rgba(84,141,212,.15); }
.pgpick-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 2px; }
.pgchip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 14px;
  border: 1.5px solid var(--line); background: var(--surface); color: var(--ink-soft);
  cursor: pointer; transition: all .12s;
}
.pgchip:hover { border-color: var(--blue-300); }
.pgchip.on { border-color: var(--blue-500); background: var(--blue-100); color: var(--blue-700); }
.pgbadge {
  font-style: normal; font-size: 10.5px; font-weight: 800;
  background: var(--blue-500); color: #fff; border-radius: 9px; padding: 1px 6px;
}
.pgpick-sel { margin: 4px 0 0; }
.pgsel {
  border: 1.5px solid var(--blue-300); background: var(--surface-2);
  border-radius: 9px; padding: 8px 12px; margin-top: 8px;
}
.pgsel-top { display: flex; align-items: center; gap: 6px; }
.pgsel-x {
  margin-left: auto; border: 0; background: none; cursor: pointer;
  font-size: 16px; line-height: 1; color: var(--blue-700);
  padding: 1px 7px; border-radius: 6px;
}
.pgsel-x:hover { background: rgba(84,141,212,.22); }
.pgsel-empty { font-size: 12.5px; font-style: italic; color: var(--ink-soft); padding: 10px 4px; }
.pgadd.hl { border-color: var(--blue-500); box-shadow: 0 0 0 3px rgba(84,141,212,.18); }

/* crash-cart Location / Vial column (results table) */
.meta-cell {
  font-size: 11.5px; line-height: 1.55; text-align: left; color: var(--ink);
  border-left: 1px solid var(--blue-100);
}
.meta-cell b { display: block; font-size: 12px; color: var(--ink); }

/* ============================ CURATOR WORKSPACE ======================= */
.curform {
  margin-top: 12px; padding: 12px 2px 2px; border-top: 2px solid var(--blue-100);
  display: flex; flex-direction: column; align-items: flex-start; gap: 9px;
}

/* ============================ ORG CONSOLE (super admin) =============== */
.orgstats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px;
}
.orgstat {
  background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px;
  display: flex; flex-direction: column; gap: 2px; min-width: 0;
}
.orgstat-n {
  font-size: 19px; font-weight: 800; color: var(--blue-700);
  font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.orgstat-l {
  font-size: 10.5px; font-weight: 700; letter-spacing: .7px; text-transform: uppercase;
  color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* species picker (Add-Hospital) reuses the department-dropdown pattern;
   only the Select-all row needs its own touch — a divider under it. */
.sppick-all { padding-bottom: 6px; margin-bottom: 2px; border-bottom: 1px solid var(--line, #d4e4ec); }

/* org-wide audit list */
.orgaudit { display: flex; flex-direction: column; }
.orgaudit-row {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px;
  padding: 7px 2px; font-size: 12.5px;
}
.orgaudit-row + .orgaudit-row { border-top: 1px dashed var(--line); }
.orgaudit-when {
  font-size: 11px; color: var(--ink-soft); font-variant-numeric: tabular-nums;
  min-width: 132px;
}
.orgaudit-actor { font-weight: 700; color: var(--ink); }
.orgaudit-act { color: var(--blue-700); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 11.5px; word-break: break-all; }
.orgaudit-detail { flex-basis: 100%; margin-top: 2px; }
.orgaudit-detail summary {
  font-size: 11px; color: var(--blue-700); cursor: pointer; user-select: none;
}
.orgaudit-json {
  margin-top: 5px; padding: 7px 10px;
  background: #0f2438; color: #cfe3f5; border-radius: 8px;
  font: 11px/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  word-break: break-all;
}

/* per-drug change history (punch-list #12) */
.histlist { display: flex; flex-direction: column; gap: 6px; max-height: 55vh; overflow-y: auto; }
.hist-row {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px;
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--blue-50);
  font-size: 12.5px;
}
.hist-when { font-size: 11px; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.hist-actor { font-weight: 700; color: var(--ink); }
.hist-act { color: var(--blue-700); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 11.5px; }
.hist-detail {
  flex-basis: 100%; font-size: 11px; color: var(--ink-soft);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  word-break: break-all;
}
.hist-revert { margin-left: auto; }

/* audit export preview (punch-list #11) — shown when no download primitive */
.xpreview {
  max-height: 55vh; overflow: auto; white-space: pre-wrap; word-break: break-all;
  font: 11px/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: #0f2438; color: #cfe3f5; padding: 10px 12px; border-radius: 8px;
}

/* ============================ WEIGHT GUARD ============================ */
.wguard { display: none; margin-top: 10px; }
.wguard.show { display: block; }
.wguard-msg {
  background: var(--amber-bg); border: 1px solid #e3c284; color: #6e4a12;
  border-radius: 8px; padding: 8px 11px; font-size: 12.5px; line-height: 1.45;
}
.wguard-msg + .wguard-msg { margin-top: 6px; }

/* ============================ MAX-RATE WARNINGS ======================= */
.maxwarn {
  display: inline-block; vertical-align: 1px; margin-left: 6px;
  background: var(--amber-bg); color: var(--amber); border: 1px solid #e3c284;
  border-radius: 5px; padding: 2px 6px; font-size: 10.5px; font-weight: 700;
  letter-spacing: .3px; white-space: nowrap; cursor: help;
}
.maxstrip {
  background: var(--amber-bg); border: 1px solid #e3c284; border-radius: 10px;
  padding: 10px 12px; margin-bottom: 12px; font-size: 12.5px; color: #6e4a12;
}
.maxstrip b { color: var(--amber); }
.maxstrip-item {
  display: flex; gap: 8px; align-items: baseline; margin-top: 4px;
  background: var(--surface); border: 1px solid #ecd9b0; border-radius: 7px;
  padding: 5px 9px; color: #6e4a12;
}
.maxstrip-item .xact-name { flex: none; min-width: 130px; }

/* ============================ VIAL CROSS-CHECK (punch-list #5) ========= */
.vialstrip {
  background: var(--amber-bg); border: 1px solid #e3c284; border-radius: 10px;
  padding: 10px 12px; margin-bottom: 12px; font-size: 12.5px; color: #6e4a12;
}
.vialstrip b { color: var(--amber); }
.vialstrip-item {
  display: flex; gap: 8px; align-items: baseline; margin-top: 4px;
  background: var(--surface); border: 1px solid #ecd9b0; border-radius: 7px;
  padding: 5px 9px; color: #6e4a12;
}
.vialstrip-item .xact-name { flex: none; min-width: 130px; }
/* Drug modal: "Vials we stock" list */
.vialrow {
  display: flex; gap: 8px; align-items: baseline; padding: 5px 9px; margin-top: 5px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 7px; font-size: 12.5px;
}
.vialrow.vialmatch { border-color: #9fd3a8; background: var(--green-bg); }
.vialok { color: var(--green); font-weight: 700; margin-left: auto; white-space: nowrap; }
/* Drug form: vial editor rows */
.vialrow-e {
  display: flex; gap: 6px; align-items: center; margin-top: 6px; flex-wrap: wrap;
}
.vialrow-e .vconc { width: 90px; }
.vialrow-e .vunit { width: 150px; }
.vialrow-e .vpack { flex: 1; min-width: 150px; }

/* ============================ HIGH-ALERT (TWO-PERSON VERIFY) =========== */
.hrisk {
  display: inline-block; vertical-align: 1px; margin-left: 6px;
  background: var(--red-bg); color: var(--red); border: 1px solid #e5b8b2;
  border-radius: 5px; padding: 2px 6px; font-size: 10.5px; font-weight: 800;
  letter-spacing: .3px; white-space: nowrap; cursor: help;
}
.hriskline {
  margin: 10px 16px 0; padding: 8px 12px;
  background: var(--red-bg); border: 1px solid #e5b8b2; border-left: 4px solid var(--red);
  border-radius: 8px; font-size: 12.5px; font-weight: 700; color: var(--red); line-height: 1.45;
}

/* ============================ HANDLING & STORAGE (punch-list #6) ======= */
.hchips { display: inline-flex; gap: 3px; margin-left: 6px; vertical-align: 1px; }
.hchip {
  display: inline-flex; align-items: center;
  background: var(--blue-50); color: var(--blue-700);
  border: 1px solid var(--blue-200); border-radius: 5px;
  padding: 1px 5px; font-size: 11px; cursor: help;
}
/* The row chips are buttons (click → handling popup); keep the base look. */
button.hchip { cursor: pointer; font: inherit; line-height: 1.3; }
button.hchip:hover { background: var(--blue-100); border-color: var(--blue-500); }
button.hchip:active { transform: scale(0.96); }
button.hchip:focus-visible { outline: 2px solid var(--blue-500); outline-offset: 1px; }
.hchiprow {
  display: flex; gap: 8px; align-items: baseline; padding: 5px 9px; margin-top: 5px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 7px; font-size: 12.5px;
}
.hchiprow .hchip { font-size: 13px; padding: 0 3px; }
.handlingline {
  margin: 10px 16px 0; padding: 8px 12px;
  background: var(--blue-50); border: 1px solid var(--blue-200); border-left: 4px solid var(--blue-500);
  border-radius: 8px; font-size: 12.5px; font-weight: 600; color: var(--blue-900); line-height: 1.5;
}
/* Curator form: handling editor rows */
.hrow-e { display: flex; gap: 6px; align-items: center; margin-top: 6px; flex-wrap: wrap; }
.hrow-e .htype { width: 160px; }
.hrow-e .hdetail { flex: 1; min-width: 180px; }

/* ============================ SYRINGE MIX BUILDER ===================== */
.syringe-card { border-color: var(--blue-300); }
.syrintro { font-size: 12.5px; color: var(--ink-soft); line-height: 1.5; margin-bottom: 10px; }
.syrintro b { color: var(--ink); }
.syrinputs {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  margin-bottom: 12px; max-width: 560px;
}
.syrout .syrhint {
  background: var(--blue-50); border: 1px dashed var(--line); border-radius: 8px;
  padding: 9px 12px; font-size: 12.5px; color: var(--ink-soft);
}
.syrtable td.draw {
  background: var(--surface-2); font-size: 14.5px; color: var(--blue-700);
  border-left: 2px solid var(--blue-300);
}
.syrsummary {
  display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: baseline;
  margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--blue-50);
  font-size: 12.5px; color: var(--ink-soft);
}
.syrsummary b { color: var(--ink); font-variant-numeric: tabular-nums; }
.syrerr {
  background: var(--red-bg); border: 1px solid #e5b8b2; color: var(--red);
  border-radius: 7px; padding: 6px 10px; font-weight: 600;
}

/* ============================ PUMP SHEET (#17) ========================
   Worksheet in the hospital syringe-pump layout. Printed via the
   body.print-pumpsheet mode (below the @media print block). */
.pumpsheet-modal { max-width: 760px; }
.pumpsheet-head { margin-bottom: 10px; }
.pumpsheet-title { font-size: 16px; font-weight: 800; color: var(--blue-700); margin-bottom: 4px; }
.pumpsheet-pat { font-size: 13px; color: var(--ink); }
.pumpsheet-pat b { color: var(--blue-700); }
table.pumpsheet { width: 100%; border-collapse: collapse; font-size: 13px; }
table.pumpsheet th {
  text-align: left; font-size: 10px; letter-spacing: .6px; text-transform: uppercase;
  color: var(--ink-soft); padding: 6px 8px; border-bottom: 1.5px solid var(--line);
}
table.pumpsheet td { padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.pumpsheet td.val { font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.pumpsheet td.draw {
  background: var(--surface-2); font-weight: 800; color: var(--blue-700);
  border-left: 2px solid var(--blue-300);
}
table.pumpsheet tr:last-child td { border-bottom: 0; }
.pumpsheet-summary {
  display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: baseline;
  margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--blue-50);
  font-size: 12.5px; color: var(--ink-soft);
}
.pumpsheet-summary b { color: var(--ink); font-variant-numeric: tabular-nums; }
.pumpsheet-sign { margin-top: 12px; font-size: 12.5px; color: var(--ink-soft); letter-spacing: .2px; }
.pumpsheet-foot { margin-top: 10px; font-size: 12px; color: var(--ink-soft); }

/* ============================ CURATOR CAP FIELD ======================= */
.doserow .dosecap { border-color: #e3c284; background: var(--surface); }
.doserow .dosecap:focus { border-color: var(--amber); box-shadow: 0 0 0 3px rgba(217,169,78,.18); }

/* ============================ TOAST =================================== */
#toast {
  position: fixed; left: 50%; bottom: 26px; z-index: 200;
  transform: translateX(-50%) translateY(10px);
  background: #12304a; color: #fff; font-size: 13px; font-weight: 600;
  padding: 10px 18px; border-radius: 30px; box-shadow: 0 10px 30px rgba(10,30,48,.35);
  opacity: 0; pointer-events: none; transition: all .18s;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ============================ COMBO-CRI PROTOCOLS ===================== */

/* sheet tag chip (sidebar + h1) */
.prototag {
  display: inline-block; flex: none;
  background: linear-gradient(135deg, var(--blue-300), var(--blue-600));
  color: #fff; font-weight: 800; font-size: 10.5px; letter-spacing: .6px;
  padding: 2px 8px; border-radius: 6px; vertical-align: 1px; white-space: nowrap;
}
.navitem .prototag { background: rgba(255,255,255,.18); color: #dcecf6; font-size: 9.5px; padding: 1px 6px; }
.prototag.big { font-size: 13px; padding: 3px 11px; vertical-align: 2px; }

/* section sub-headings (edit-mode cards) */
.subhead {
  margin: 14px 0 4px; font-size: 11px; font-weight: 800; letter-spacing: 1px;
  text-transform: uppercase; color: var(--ink-soft);
}
.subhead:first-of-type { margin-top: 4px; }

/* one component block on the protocol sheet */
.protocomp { padding: 10px 0; border-top: 1px solid var(--blue-50); }
.protocomp:first-child { border-top: 0; padding-top: 2px; }
.protocomp-head { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; margin-bottom: 6px; }
.protocomp-head .dname { font-weight: 700; color: var(--ink); font-size: 14px; flex: none; }

.prototbl { width: 100%; border-collapse: collapse; table-layout: fixed; }
.prototbl th, .prototbl td { border-top: 1px solid var(--blue-50); padding: 6px 8px; vertical-align: top; text-align: left; }
.prototbl .pkind {
  width: 52px; font-size: 10px; font-weight: 800; letter-spacing: .8px;
  text-transform: uppercase; color: var(--ink-soft); white-space: nowrap;
}
.prototbl td:nth-child(2) { width: 42%; }
.prototbl td.val { text-align: left; white-space: normal; font-size: 12.5px; }

/* set-point input + sheet range */
.protoset { display: inline-flex; align-items: baseline; gap: 5px; }
.protoset input {
  width: 74px; font: inherit; font-weight: 700; font-size: 13px;
  padding: 4px 7px; border: 1.5px solid var(--line); border-radius: 7px; background: var(--surface);
}
.protoset input:focus { outline: 0; border-color: var(--blue-500); box-shadow: 0 0 0 3px var(--blue-50); }
.protorange { margin-top: 3px; }
.protonote { margin-top: 6px; }
.proto-amt b { color: var(--blue-700); }

/* warnings card */
.proto-warns { background: var(--surface); border-color: #ecd9b5; }
.proto-warns .wguard-msg { margin-bottom: 6px; }
.proto-warns .wguard-msg:last-child { margin-bottom: 0; }

/* ============================ PROTOCOL EDITOR FORM ==================== */
.modal.pfmodal { max-width: 860px; border-top-color: var(--blue-600); max-height: 92vh; display: flex; flex-direction: column; }
.modal.pfmodal .modal-head { color: var(--blue-700); flex: none; }
.modal.pfmodal .pf-body { overflow-y: auto; flex: 1 1 auto; }
.pf-body .frow { display: flex; gap: 12px; flex-wrap: wrap; }
.pf-body .frow .field { flex: 1 1 220px; }
.pf-body textarea { width: 100%; }

.pf-scope-row { display: flex; flex-wrap: wrap; gap: 4px 14px; padding-top: 4px; }
.pf-check { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--ink-soft); cursor: pointer; }
.pf-check input { accent-color: var(--blue-600); }

.pf-comps { margin-top: 14px; display: flex; flex-direction: column; gap: 12px; }
.pfcomp {
  border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px;
  background: var(--surface);
}
.pfcomp-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.pfcomp-head select { flex: 1 1 260px; min-width: 200px; font-weight: 600; }
.pf-dose { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 6px 0; border-top: 1px dashed var(--blue-50); }
.pf-dose-kind {
  flex: none; width: 44px; font-size: 10px; font-weight: 800; letter-spacing: .8px;
  text-transform: uppercase; color: var(--ink-soft);
}
.pf-dose select { font-size: 12.5px; }
.pf-range { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--ink-soft); }
.pf-range input {
  width: 68px; font: inherit; font-weight: 700; padding: 5px 7px;
  border: 1.5px solid var(--line); border-radius: 7px; background: var(--surface);
}
.pf-range input:focus { outline: 0; border-color: var(--blue-500); box-shadow: 0 0 0 3px var(--blue-50); }
.pfcomp > input { width: 100%; margin-top: 8px; }

/* Print header (pre-ZIP #1): screen-hidden; the @media print block below
   reveals it above the sheet head on every dose sheet. */
.print-head { display: none; }

/* ============================ PRINT =================================== */
@media print {
  /* Print is always light, regardless of the on-screen dark theme: pin the
     dark-aware surface vars back to white so no dark fill lands on paper. */
  :root, [data-theme="dark"] { --surface: #ffffff; --surface-2: #ffffff; }
  body { background: var(--surface); font-size: 11.5px; }
  #app { display: block; }
  #sidebar, .sheet-actions, .rowacts, .addbtn, .no-print, #modeSwitch, .dz { border: 0 !important; }
  #main { padding: 0; }
  .sheet { box-shadow: none; border: 0; border-radius: 0; padding: 0; max-width: none; }
  .grid2 { display: block; }
  .col-left { position: static; margin-bottom: 12px; display: block; }
  .col-left .card { margin-bottom: 12px; }
  .card { break-inside: avoid; box-shadow: none; }
  .btn { display: none; }
  .sheet-head { border-bottom: 2px solid #333; }
  .sheet-head h1 { font-size: 20px; }
  /* Print header (pre-ZIP #1): self-contained page-one header — patient,
     species, weight, hospital, date/time, verify-in-hand safety line. */
  .print-head { display: block; margin-bottom: 10px; padding-bottom: 8px;
    border-bottom: 1px solid #888; font-size: 11px; color: #000; }
  .print-head .ph-row1 { font-size: 12px; font-weight: 600; }
  .print-head .ph-row2 { margin-top: 2px; }
  .print-head .ph-row2 b { color: #000; }
  .print-head .ph-verify { margin-top: 4px; color: #900; font-weight: 600; }
  table.dose { font-size: 11px; min-width: 0; }
  .dosewrap table.dose { min-width: 0; } /* paper fits A4/Letter, no scroll */
  /* paper is narrower than a laptop screen: relax the fixed numeric widths
     so the sheet fits A4/Letter (the Actions column is hidden below). */
  table.dose th:nth-child(2) { width: 80px; }
  table.dose th:nth-child(3) { width: 120px; }
  table.dose th:nth-child(4) { width: 140px; }
  /* Actions column (warnings ⚠ + move up / down / remove) is screen-only:
     hide header + cells so the printed sheet stays clean. (The .no-print
     class has no global display rule, so scope the hiding to this table —
     other no-print elements, like the wall-sheet safety footer, keep
     printing as they always have.) */
  table.dose .no-print { display: none !important; }
  .val { color: #000 !important; }
  .note, .intro-line, .tag { color: #222; }
  .warn { color: #900; }
  .dz-empty { border-style: solid; }
  .protoset input, .pfcomp, .pf-dose input { border-color: #999; }
  .protocomp, .prototbl th, .prototbl td { break-inside: avoid; }
  .prototag.big { background: var(--surface); color: #000; border: 1.5px solid #333; }

  /* #26 — treatment-sheet print pass + general print hygiene:
     screen-only controls out, chips legible on paper, tables keep their
     headers across page breaks and never split a row. */
  #patientbar .pims-pf { display: none !important; } /* PIMS search/pin is screen-only */
  .unit-toggle { display: none !important; }
  #wInput, .pf-dose input, .pfcomp input { border-color: #999 !important; }
  .yn-toggle { border-color: #999 !important; }
  .yn-toggle button { color: #333; }
  .yn-toggle button.on { background: #000; color: #fff; }
  .count-pill { background: var(--surface); color: #000; border: 1px solid #666; }
  .warn { background: var(--surface); border-left-color: #900; }
  .note { border-top-color: #bbb; color: #333; }
  .note b { color: #000; }
  .rnote { color: #444; }
  .muted { color: #666; }
  .trconc b { color: #000; }
  .sec-extra { display: none !important; }
  .pims-simbadge { background: var(--surface); color: #900; border: 1px solid #900; }
  table.ref { font-size: 11px; }
  table.ref thead { display: table-header-group; } /* repeat header across pages */
  table.ref tr { break-inside: avoid; }

  /* #26 — with a modal open (drug record etc.), print the modal on its own:
     the app behind it (sheet + patient bar) is hidden and the overlay prints
     statically at full height — same pattern as body.print-pumpsheet. */
  body:has(.warn-overlay.show) #app { display: none !important; }
  body:has(.warn-overlay.show) .warn-overlay {
    position: static !important; display: block !important; padding: 0 !important;
    background: var(--surface) !important; backdrop-filter: none !important;
  }
  body:has(.warn-overlay.show) .warn-overlay .modal {
    box-shadow: none; border: 0; border-radius: 0; max-height: none; overflow: visible;
    max-width: none; animation: none;
  }
  body:has(.warn-overlay.show) .modal-actions { display: none; }
  @page { margin: 12mm; }
}

/* Pump-sheet print mode (#17): print ONLY the pump-sheet modal — the
   app behind it (including the syringe card, which is no-print anyway)
   is hidden, so the deliverable matches the worksheet exactly. */
body.print-pumpsheet #app { display: none !important; }
body.print-pumpsheet .warn-overlay {
  position: static !important; display: block !important; padding: 0 !important;
  background: var(--surface) !important; backdrop-filter: none !important;
}
body.print-pumpsheet .warn-overlay .modal {
  box-shadow: none; border: 0; border-radius: 0; max-height: none; overflow: visible;
  max-width: none; animation: none;
}
body.print-pumpsheet .modal-actions { display: none; }
body.print-pumpsheet .pumpsheet-foot { display: none; }
body.print-pumpsheet table.pumpsheet { font-size: 11.5px; }
body.print-pumpsheet table.pumpsheet td.draw { background: none; color: #000; border-left-color: #333; }
body.print-pumpsheet .pumpsheet-summary .syrerr, body.print-pumpsheet .syrerr {
  background: var(--surface); color: #900; border-color: #900;
}

/* ============================ RESPONSIVE ============================== */
/* Tablet pass (#24): 768–1024px — Use sheet, sidebar, modals.
   `screen and` so none of this leaks into @media print (an A4 page is
   ~794px wide and would otherwise match a plain max-width: 1024px). */
@media screen and (max-width: 1024px) {
  #app { grid-template-columns: 220px 1fr; }
  .brand { padding: 14px 12px 10px; }
  .brand .logo { font-size: 13.5px; }
  .brand .sub { font-size: 10px; }
  #main { padding: 14px 14px 32px; }
  .sheet { padding: 20px 18px; }
  .sheet-head h1 { font-size: 24px; }
  #patientbar { padding: 10px 12px; }
  .pims-pf { min-width: 200px; }
  /* 16px inputs: stops focus-zoom on tablet browsers (iOS/Safari quirk) */
  .pf input, .pims-search input { font-size: 16px; }
  .grid2 { grid-template-columns: 260px 1fr; }
}

@media (max-width: 980px) {
  #app { grid-template-columns: 196px 1fr; }
  .brand { padding: 14px 12px 10px; }
  .brand .logo { font-size: 13.5px; }
  .brand .sub { font-size: 10px; }
  #nav { padding: 8px 8px 12px; }
  .navgroup-title { font-size: 9px; padding: 3px 8px 4px; }
  .drug-row { font-size: 12px; padding: 6px 8px; }
  .sidebar-foot { font-size: 9.5px; padding: 10px 12px; }
  #patientbar { grid-template-columns: repeat(2, 1fr); }
  .grid2 { grid-template-columns: 1fr; }
  .col-left { position: static; }
  #main { padding: 12px 12px 30px; }
  .sheet { padding: 16px 14px; }
  .frow { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  #app { grid-template-columns: 156px 1fr; }
  .brand .sub { display: none; }
  .drug-row { font-size: 11.5px; padding: 6px 7px; }
  .sidebar-foot { display: none; }
  #patientbar { grid-template-columns: 1fr; }
  #main { padding: 10px 8px 24px; }
  .sheet { padding: 14px 10px; }
  .spgrid { grid-template-columns: 1fr; }
  .doserow { grid-template-columns: 48px 1fr 1fr; grid-auto-rows: auto; }
  .doserow .doselabel { grid-column: 1 / -1; }
  .modal-masterdrug .doserow .titnote { grid-column: 1 / -1; }
  .modal-masterdrug .dosenote { margin-left: 0; }
}

/* ============================ PIMS (ezyVet) submission ================= */

/* status chips (reuse the .tag system) */
.tag-delivered { background: var(--green-bg); color: var(--green); }
.tag-failed { background: var(--red-bg); color: var(--red); }
.tag-pending { background: var(--amber-bg); color: var(--amber); }
.tag-pinned { background: var(--blue-100); color: var(--blue-700); text-transform: none; letter-spacing: 0; font-size: 11px; margin-left: 0; margin-right: 6px; padding: 3px 8px; }

/* patient search (top patient bar) */
.pims-pf { min-width: 240px; flex: 1 1 240px; }
.pims-search { position: relative; }
.pims-search input { width: 100%; }
.pims-search input:disabled { opacity: .7; background: var(--surface-2); }
.pims-results {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 40;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 10px 28px rgba(15, 36, 56, .14); padding: 5px; max-height: 260px; overflow: auto;
}
.pims-pat {
  display: flex; flex-wrap: wrap; gap: 2px 8px; width: 100%; text-align: left;
  font: inherit; font-size: 13px; padding: 7px 9px; border: 0; background: none;
  border-radius: 7px; cursor: pointer; color: var(--ink);
}
.pims-pat:hover { background: var(--blue-50); }
.pims-pat .muted { color: var(--ink-soft); font-size: 11.5px; }
.pims-pin { display: flex; align-items: center; margin-top: 4px; min-height: 0; }

/* send preview modal */
.pims-preview { margin: 8px 0; }

/* submissions card (Use mode) */
.pims-sublist { display: flex; flex-direction: column; }
.pims-sub {
  padding: 9px 2px; font-size: 13px;
  border-top: 1px dashed var(--line);
}
.pims-sub:first-child { border-top: 0; }
.pims-sub-top { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
.pims-sub-main { flex: 1 1 220px; min-width: 180px; }
.pims-ref {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11.5px; font-weight: 700; color: var(--blue-700);
  background: var(--blue-50); border-radius: 6px; padding: 2px 7px;
}

/* #25 — PIMS honesty badge (Phase A = simulated gateway) */
.pims-sim { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: 0 0 8px; }
.pims-simbadge {
  font-size: 11px; font-weight: 800; letter-spacing: .4px; white-space: nowrap;
  color: #7a5400; background: var(--amber-bg); border: 1px solid #e5bd55;
  border-radius: 999px; padding: 2px 10px;
}

/* admin connection card (Edit mode) */
.checkline { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; color: var(--ink); cursor: pointer; }
.checkline input { margin-top: 3px; accent-color: var(--blue-600); }

/* 📮 feedback (bug reports + suggestions) */
.tag.sev-bug { background: var(--red-bg); color: var(--red); }
.fb-types { display: flex; gap: 16px; flex-wrap: wrap; margin: 4px 0 8px; }
.fb-type { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ink); cursor: pointer; }
.fb-msg { font-size: 12.5px; color: var(--ink); }

/* ============================ DEPARTMENTS (docs/departments.md) ========= */

/* Department filter — one compact dropdown above the Hospital Pages list
   (Use mode, remote only). Replaces the old chip grid, which got busy for
   a multi-specialty hospital (10+ departments): one glance, no reflow,
   and the page list below keeps its place. */
.deptpick {
  width: 100%; margin: 2px 0 8px;
  border: 1px solid rgba(255,255,255,.2);
  background: rgba(255,255,255,.08); color: #fff;
  border-radius: 8px; padding: 8px 10px;
  font: inherit; font-size: 12.5px; cursor: pointer;
}
.deptpick:hover { background: rgba(255,255,255,.15); }
.deptpick:focus { outline: none; border-color: var(--blue-300); background: rgba(255,255,255,.12); }
.deptpick option { color: #0d2c42; background: #fff; }

/* small department tag — sidebar page items, sheet header, tables, rows */
.depttag {
  display: inline-block; vertical-align: 1px; white-space: nowrap;
  background: var(--blue-50); color: var(--blue-700);
  border: 1px solid #bcd6ea; border-radius: 6px;
  font-size: 10px; font-weight: 700; letter-spacing: .4px;
  padding: 1px 7px; margin-left: 4px;
}
.navitem .depttag { background: rgba(255,255,255,.14); border-color: rgba(255,255,255,.28); color: #dcecf6; margin-left: 5px; }

/* Users & Access — per-user department checkboxes */
.userdepts { display: flex; flex-direction: column; gap: 3px; max-width: 210px; }

/* print: dept tags stay legible on paper (they are part of the sheet header) */
@media print {
  .depttag { background: var(--surface); color: #000; border: 1px solid #555; }
}

/* ---- department picker (org console → Add Hospital) --------------------
   Checkbox dropdown over the standard department list + a custom-entry row;
   the picked departments show as removable chips next to the toggle. */
.deptpick { position: relative; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.deptpick-chips { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.deptpick-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px;
  background: var(--blue-50, #f2f9fc); border: 1px solid var(--line, #d4e4ec);
  font-size: 13px; color: var(--ink, #1c2b36);
}
.deptpick-x { border: 0; background: none; cursor: pointer; font-size: 14px; line-height: 1; color: inherit; padding: 0 2px; }
.deptpick-x:hover { color: var(--red, #c0392b); }
.deptpick-panel {
  position: absolute; z-index: 40; top: calc(100% + 4px); left: 0;
  min-width: 280px; max-height: 320px; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line, #d4e4ec);
  border-radius: var(--radius, 10px); box-shadow: var(--shadow, 0 8px 24px rgba(23,58,86,.12));
  padding: 10px; display: grid; gap: 6px;
}
.deptpick-panel[hidden] { display: none; }
/* .field input { width: 100% } would otherwise blow the row checkboxes up to
   full width and push the label text to the right edge — keep them native. */
.deptpick-panel .pf-check { display: flex; align-items: center; gap: 7px; width: 100%; text-align: left; font-size: 13.5px; color: var(--ink, #1c2b36); padding: 3px 2px; border-radius: 6px; cursor: pointer; }
.deptpick-panel .pf-check:hover { background: var(--blue-50, #f2f9fc); }
.deptpick-panel .pf-check input { width: auto; padding: 0; border: 0; background: none; font: inherit; margin: 0; cursor: pointer; flex: 0 0 auto; }
.deptpick-custom { display: flex; gap: 6px; margin-top: 6px; padding-top: 8px; border-top: 1px solid var(--line, #d4e4ec); }

/* 📈 Metrics (docs/metrics.md) — the org-leader dashboard. Screen-only admin
   UI; the print rules above target the clinical sheets, so nothing here
   needs print overrides (and none are added). */
.msect {
  margin: 20px 0 8px; padding-bottom: 6px;
  font-size: 12px; font-weight: 800; letter-spacing: .8px; text-transform: uppercase;
  color: var(--blue-700); border-bottom: 2px solid var(--blue-100, #dbeaf4);
}
.dashcols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 10px 0; }
.dashcols.three { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 900px) { .dashcols, .dashcols.three { grid-template-columns: 1fr; } }
.dashsub {
  font-size: 11px; font-weight: 800; letter-spacing: .5px; text-transform: uppercase;
  color: var(--ink-soft); margin-bottom: 6px;
}
.dashrow {
  display: flex; justify-content: space-between; gap: 10px;
  font-size: 12.5px; padding: 3px 0; border-bottom: 1px dashed var(--line);
}
.dashrow:last-child { border-bottom: 0; }

/* CSS bar chart (no chart library) — vertical bars across the day range. */
.dashbars {
  display: flex; align-items: flex-end; gap: 2px;
  height: 72px; padding: 4px 2px 0;
  border-bottom: 2px solid var(--line);
}
.dashbar { flex: 1 1 0; min-width: 2px; height: 100%; display: flex; align-items: flex-end; cursor: default; }
.dashbar-fill {
  width: 100%; border-radius: 2px 2px 0 0;
  background: linear-gradient(180deg, var(--blue-400, #6db3dc), var(--blue-600));
}
.dashbar:hover .dashbar-fill { background: var(--blue-600); }
.dashbars-axis { display: flex; justify-content: space-between; font-size: 10px; color: var(--ink-soft); margin-top: 3px; }

/* ✨ What's new — one-time card at the top of Use mode (per-browser
   dismissal, keyed on the release tag). */
.whatsnew {
  margin: 0 0 14px; padding: 12px 16px;
  border: 1px solid var(--blue-100, #cfe3f0); border-left: 4px solid var(--blue-500);
  border-radius: 10px; background: var(--blue-50, #eef6fb);
}
.whatsnew-head { font-weight: 800; font-size: 13.5px; margin-bottom: 8px; color: var(--blue-700); }
.whatsnew ul { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 5px; }
.whatsnew li { font-size: 13px; line-height: 1.45; display: flex; gap: 8px; align-items: baseline; }
.whatsnew .wn-ic { flex: 0 0 auto; }

/* 🔍 metrics drill-down tabs (Tier 3, docs/metrics.md) — light-surface
   segmented control, mirrors .modeseg but for the card body. */
.drilltabs { display: flex; gap: 6px; margin: 4px 0 12px; flex-wrap: wrap; }
.drilltab {
  border: 1px solid var(--line); background: var(--surface-2);
  color: var(--ink-soft); font: inherit; font-size: 12.5px; font-weight: 700;
  padding: 7px 14px; border-radius: 8px; cursor: pointer; transition: all .12s;
}
.drilltab:hover { background: var(--blue-50); color: var(--blue-700); }
.drilltab.on { background: var(--blue-500); color: #fff; border-color: var(--blue-500); }
/* CSV export row under the Metrics title */
.mexport { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 10px 0 4px; }
/* inline mini-bar in the Total column */
.drillbar {
  display: inline-block; vertical-align: middle;
  width: 64px; height: 8px; margin-right: 7px; border-radius: 4px;
  background: var(--blue-50, #e8f2f8); overflow: hidden;
}
.drillbar > span { display: block; height: 100%; border-radius: 4px; background: var(--blue-500); }

/* ranked lists (most-used calculators / drug categories) */
.dastrank { display: flex; flex-direction: column; gap: 7px; }
.dastrank-row {
  display: grid; grid-template-columns: minmax(90px, 1.2fr) 2fr 34px; gap: 8px;
  align-items: center; font-size: 12.5px;
}
.dastrank-sub {
  grid-column: 1 / -1; font-size: 10px; font-weight: 700; letter-spacing: .4px;
  text-transform: uppercase; color: var(--ink-soft); margin-top: 2px;
}
.dastrank-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dastrank-track { height: 8px; border-radius: 4px; background: var(--blue-50, #f2f9fc); overflow: hidden; }
.dastrank-fill { display: block; height: 100%; border-radius: 4px; background: linear-gradient(90deg, var(--blue-400, #6db3dc), var(--blue-600)); }
.dastrank-n { font-weight: 800; color: var(--blue-700); text-align: right; font-variant-numeric: tabular-nums; }


/* 🚀 Admin onboarding card (pilot sweep #5) — hospital-side first-run checklist */
.onbhead { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.onbhead .card-title { margin-bottom: 4px; }
.onblist { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.onbrow { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.onbmark { width: 18px; flex: none; }
.onbrow.todo .onbhint { display: block; flex-basis: 100%; margin-left: 26px; color: var(--ink-soft); font-size: 0.85em; }
.onbscore { font-weight: 700; margin-top: 12px; }


/* 🧳 ICU Wall Sheet (pilot sweep #6) — the printable ICU deliverable */
.wallsheet { display: flex; flex-direction: column; gap: 14px; }
.wallsheet-head { display: flex; align-items: center; gap: 12px; border-bottom: 2px solid var(--blue-200); padding-bottom: 10px; }
.wallsheet-logo { max-height: 56px; max-width: 120px; object-fit: contain; }
.wallsheet-title { font-size: 16px; font-weight: 800; color: var(--blue-700); }
.wallsheet-sec { break-inside: avoid; }
.wallsheet-sec h3 { margin: 0 0 6px; font-size: 14px; color: var(--blue-700); }
table.wallsheet-tbl { font-size: 12.5px; }

/* print: only the wall sheet (same pattern as body.print-pumpsheet) */
body.print-wallsheet #app { display: none !important; }
body.print-wallsheet .warn-overlay {
  position: static !important; display: block !important; padding: 0 !important;
  background: var(--surface) !important; backdrop-filter: none !important;
}
body.print-wallsheet .warn-overlay .modal {
  box-shadow: none; border: 0; border-radius: 0; max-height: none; overflow: visible;
  max-width: none; animation: none;
}
body.print-wallsheet .modal-actions { display: none; }
body.print-wallsheet .wallsheet-foot { display: none; }

/* global search palette (pilot sweep #9) */
.gsbody {
  margin-top: 10px; max-height: 320px; overflow: auto;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface);
}
.gsrow {
  display: flex; align-items: baseline; gap: 8px; width: 100%;
  text-align: left; background: none; border: 0;
  border-bottom: 1px dashed var(--line);
  padding: 8px 11px; font-size: 13px; cursor: pointer;
}
.gsrow:last-child { border-bottom: 0; }
.gsrow:hover, .gsrow.hl { background: var(--blue-50); }
.gsicon { width: 20px; text-align: center; flex: none; }
.gslabel { font-weight: 600; color: var(--ink); }
.gs-sub { margin-left: auto; text-align: right; }

/* ================== TABLET & TOUCH PATH (pilot sweep #10) ==============
   Keyed on COARSE pointers (touchscreens) rather than width, so a mouse
   desktop is never given inflated targets. Every rule is screen-scoped
   so nothing leaks into @media print. Sizes follow ~44px touch-target
   guidance for primary controls (buttons, rows, inputs); secondary
   controls (chips, ×, small links) get 34px. 16px input fonts stop the
   iOS/Safari focus-zoom on tablets. The width-based breakpoints above
   (1024/980/640) are untouched — this block only enlarges hit areas and
   fonts on touch hardware. */
@media screen and (pointer: coarse) {
  html { -webkit-text-size-adjust: 100%; }
  body { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }

  /* primary buttons + text links */
  .btn { min-height: 42px; padding: 10px 16px; }
  .btn.wide { min-height: 46px; }
  .btn.mini { min-height: 34px; padding: 6px 12px; }
  .linkbtn { min-height: 34px; display: inline-flex; align-items: center; }
  .signoutbtn { min-height: 42px; display: flex; align-items: center; justify-content: center; }
  .searchbtn { min-height: 40px; }
  .drilltab { min-height: 40px; padding: 10px 16px; }
  .auth-link { min-height: 34px; display: inline-flex; align-items: center; }
  .pgpick-clear { min-height: 34px; min-width: 34px; }

  /* sidebar rows */
  .navitem { min-height: 42px; }
  .drug-row { min-height: 42px; }
  .addbtn { width: 34px; height: 34px; font-size: 16px; }
  .deptpick { min-height: 40px; font-size: 16px; }
  .sidebar-foot { font-size: 11.5px; }

  /* form inputs — 16px stops focus-zoom; taller hit area. Checkboxes and
     radios keep their native size (min-height would turn them into bars). */
  .field input:not([type=checkbox]):not([type=radio]),
  .field select, .field textarea,
  .pf input, .weight-row input, .libsearch input, #pgPickSearch {
    font-size: 16px;
  }
  .field input:not([type=checkbox]):not([type=radio]),
  .field select, .pf input, .weight-row input {
    min-height: 44px; padding-top: 9px; padding-bottom: 9px;
  }

  /* picker + palette rows and chips */
  .gsrow { min-height: 44px; }
  .pgchip { min-height: 34px; }
  .qa-chip { min-height: 36px; }
  .pgsel-x { min-width: 34px; min-height: 34px; }
}

/* very narrow touch screens: keep the sidebar footer (🔎 Search / ℹ️
   About / 📮 Feedback / Sign out) reachable — there is no keyboard for
   Ctrl+K, so hiding these (as the 640px breakpoint does) would strand
   touch users without a search entry point. */
@media screen and (pointer: coarse) and (max-width: 640px) {
  .sidebar-foot { display: block; font-size: 11px; }
}
