/* VGHTransplantDB design system (docs/03 §3): tokens, components, the FileMaker-position canvas and the phone flow. */

:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #eef1f5;
  --border: #d5dbe3;
  --border-strong: #b7c0cc;
  --text: #17202b;
  --text-2: #4d5968;
  --muted: #7a8696;
  --accent: #1f5fa8;
  --accent-2: #0f7a6b;
  --accent-soft: #e3edf9;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --ok: #157f3c;
  --warn: #9a6700;
  --warn-soft: #fff4d6;
  --focus: #2f80ed;
  --input-bg: #ffffff;
  --shadow: 0 1px 2px rgb(16 24 40 / 6%), 0 1px 3px rgb(16 24 40 / 10%);
  --radius: 6px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
  --fs: 13px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f141a; --surface: #161c24; --surface-2: #1d2530; --border: #2a3441; --border-strong: #3a4656;
    --text: #e6ebf1; --text-2: #b3bdc9; --muted: #8592a3; --accent: #6ea8ff; --accent-2: #3cc4ae;
    --accent-soft: #1b2a3f; --danger: #ff7b72; --danger-soft: #3a1d1d; --ok: #4ac26b; --warn: #e3b341;
    --warn-soft: #3a2f12; --focus: #6ea8ff; --input-bg: #10161d; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f141a; --surface: #161c24; --surface-2: #1d2530; --border: #2a3441; --border-strong: #3a4656;
  --text: #e6ebf1; --text-2: #b3bdc9; --muted: #8592a3; --accent: #6ea8ff; --accent-2: #3cc4ae;
  --accent-soft: #1b2a3f; --danger: #ff7b72; --danger-soft: #3a1d1d; --ok: #4ac26b; --warn: #e3b341;
  --warn-soft: #3a2f12; --focus: #6ea8ff; --input-bg: #10161d; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: var(--fs)/1.35 var(--font); -webkit-text-size-adjust: 100%; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }

/* ---------- top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 50; display: flex; align-items: center; gap: 12px; padding: 8px 16px;
  background: var(--surface); border-bottom: 1px solid var(--border); }
.brand { font-weight: 650; letter-spacing: .2px; color: var(--text); text-decoration: none; white-space: nowrap; }
.brand span { color: var(--accent); }
.env { font-size: 11px; padding: 2px 6px; border-radius: 99px; background: var(--warn-soft); color: var(--warn); }
.topbar form.search { flex: 1; max-width: 420px; }
.topbar .spacer { flex: 1; }
.topbar nav { display: flex; gap: 10px; align-items: center; white-space: nowrap; }
.topbar nav a { color: var(--text-2); text-decoration: none; }
.topbar nav a:hover { color: var(--text); }

/* ---------- controls ---------- */
input, select, textarea, button { font: inherit; color: inherit; }
.in, .screen input[type=text], .screen input[type=date], .screen input[type=time], .screen input[type=datetime-local],
.screen select, .screen textarea, .form input, .form select, .form textarea {
  width: 100%; height: 100%; min-height: 20px; padding: 2px 6px; border: 1px solid var(--border-strong);
  border-radius: 4px; background: var(--input-bg); }
.screen textarea, .form textarea { resize: vertical; line-height: 1.3; }
/* FileMaker's pop-ups and calendars are 17–20 pt tall: no vertical padding, a small calendar button, so the value fits */
.screen select, .screen input[type=date] { padding-top: 0; padding-bottom: 0; padding-right: 2px; }
/* a slim drawn arrow instead the browser's wide one, so short FileMaker pop-ups (counts, Y / N) show their value */
.screen select { appearance: none; -webkit-appearance: none; padding-left: 4px; padding-right: 14px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='5'%3E%3Cpath d='M0 0l4 5 4-5z' fill='%23888'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 4px center; background-size: 8px 5px; }
.screen input[type=date] { padding-left: 4px; }
.screen input[type=date]::-webkit-calendar-picker-indicator { margin: 0; padding: 0; width: 12px; }
/* Meds / Allergies: the drug type-ahead sits above the list it adds to (D67) */
.drugpick { position: relative; display: flex; flex-direction: column; gap: 3px; width: 100%; height: 100%; }
.drugpick > input { flex: 0 0 24px; height: 24px; }
.drugpick > textarea { flex: 1 1 auto; min-height: 0; }
.drugpick-list { position: absolute; z-index: 40; top: 26px; left: 0; min-width: 100%; max-height: 220px; overflow-y: auto;
  margin: 0; padding: 2px 0; list-style: none; background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 4px; box-shadow: 0 4px 14px rgb(0 0 0 / 0.18); }
.drugpick-list li { padding: 3px 8px; white-space: nowrap; cursor: pointer; }
.drugpick-list li[aria-selected=true], .drugpick-list li[role=option]:hover { background: var(--accent); color: #fff; }
.drugpick-list li.none { color: var(--text-2); cursor: default; white-space: normal; }
.in:disabled, .screen [disabled], .screen [readonly] { background: var(--surface-2); color: var(--text-2); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 4px 12px; min-height: 26px;
  border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); cursor: pointer;
  text-decoration: none; color: var(--text); white-space: nowrap; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn.quiet { border-color: transparent; background: transparent; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 11px; font-weight: 600;
  background: var(--surface-2); color: var(--text-2); }
.badge.final { background: var(--accent-soft); color: var(--accent); }
.badge.draft { background: var(--warn-soft); color: var(--warn); }
.badge.deleted { background: var(--danger-soft); color: var(--danger); }

/* save state on a field */
.saving { box-shadow: 0 0 0 2px var(--accent-soft); }
.saved { box-shadow: 0 0 0 2px color-mix(in srgb, var(--ok) 35%, transparent); transition: box-shadow 1s; }
.error-field { border-color: var(--danger) !important; box-shadow: 0 0 0 2px var(--danger-soft); }

/* ---------- page ---------- */
main { padding: 16px; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 0 0 12px; }
.page-head h1 { font-size: 18px; margin: 0; font-weight: 650; }
.page-head .meta { color: var(--muted); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); }
.messages { list-style: none; margin: 0 0 12px; padding: 0; }
.messages li { padding: 8px 12px; border-radius: var(--radius); background: var(--accent-soft); margin-bottom: 6px; }
.messages li.error { background: var(--danger-soft); color: var(--danger); }
.toast { position: fixed; right: 16px; bottom: 16px; z-index: 100; padding: 10px 14px; border-radius: var(--radius);
  background: var(--text); color: var(--bg); box-shadow: var(--shadow); opacity: 0; transition: opacity .2s; pointer-events: none; }
.toast.show { opacity: 1; }
.toast.error { background: var(--danger); color: #fff; }

/* ---------- the screen canvas (desktop: FileMaker positions) ---------- */
.screen-wrap { overflow: auto; }
.screen { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: var(--shadow); transform-origin: 0 0; }
.screen .o { position: absolute; }
.screen .label { color: var(--text-2); font-size: 12px; white-space: pre-line; overflow: visible; line-height: 1.15;
  display: flex; align-items: flex-start; } /* FileMaker puts label text at the top of its box */
.screen .box { border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); }
.screen .box.title { background: var(--accent-soft); border-color: transparent; }
.screen .line { border-top: 1px solid var(--border); }
.screen .line.vertical { border-top: 0; border-left: 1px solid var(--border-strong); }
/* reviewed codes on the tab where that history is written (V22) */
.screen .codes { border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); padding: 4px 10px;
  overflow: hidden; font-size: 12px; }
.screen .codes-head { display: flex; justify-content: space-between; align-items: center; height: 18px;
  font-size: 11px; font-weight: 600; color: var(--muted); }
.screen .codes-head a { font-weight: 600; }
.screen .codes ul { margin: 0; padding: 0; list-style: none; }
.screen .codes[data-columns="2"] ul { columns: 2; column-gap: 24px; }
.screen .codes li { height: 20px; line-height: 20px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.screen .codes li.none { color: var(--muted); column-span: all; white-space: normal; }
.screen .codes .tag { padding: 0 6px; border-radius: 99px; background: var(--accent-soft); color: var(--accent);
  font-size: 11px; }
.screen .codes .when { color: var(--muted); }
/* the visit frame (V21): the patient card (with ABO and BMI), the visit band, the donor band */
.screen .box.s-web-patient-card { background: var(--surface); border: 1px solid var(--border);
  border-left: 4px solid var(--accent); border-radius: 10px; box-shadow: 0 1px 3px rgba(0, 0, 0, .05); }
.screen .box.s-web-visit-band { background: var(--accent-soft); border: 1px solid transparent; border-radius: 10px; }
.screen .box.s-web-donor-band { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; }
.screen .label.s-web-caption { font-size: 11px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.screen .label.s-web-stat { align-items: center; justify-content: center; font-size: 13px; font-weight: 700;
  color: var(--accent); background: var(--accent-soft); border-radius: 6px; white-space: nowrap; }
.screen .field.s-web-patient-name .value { font-size: 15px; font-weight: 650; background: transparent; padding-left: 0; }
/* the tabs (V23): white panels with a title, captions above fields, questions to the left of their answers */
.screen .box.s-web-section { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; }
.screen .label.s-web-section-title { font-size: 12px; font-weight: 650; color: var(--text); white-space: nowrap; }
.screen .label.s-web-question { font-size: 12px; color: var(--text-2); align-items: center; line-height: 1.2; }
.screen .btn { width: 100%; height: 100%; padding: 2px 6px; min-height: 0; font-size: 12px; }
.screen .btn.head { background: var(--surface-2); border-color: var(--border); color: var(--text-2); cursor: default;
  font-weight: 600; justify-content: flex-start; border-radius: 0; }
.screen .btn.accent1 { background: var(--accent-2); border-color: var(--accent-2); color: #fff; cursor: default; }
.screen .btn.accent2 { background: var(--accent); border-color: var(--accent); color: #fff; }
.screen .btn.stat { flex-direction: column; font-weight: 650; cursor: default; background: var(--surface-2); }
.screen .value { display: flex; align-items: center; width: 100%; height: 100%; padding: 2px 6px; border: 1px solid transparent;
  border-radius: 4px; background: var(--surface-2); color: var(--text); overflow: hidden; white-space: nowrap;
  text-overflow: ellipsis; }
/* nothing scrolls inside a screen: long read-only text is cut at the box (the whole text is in the record or file) */
.screen .value.multi { display: block; white-space: pre-wrap; overflow: hidden; font-size: 12px; line-height: 1.25; }
.portal .dropzone { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 6px; padding: 10px 12px;
  border: 2px dashed var(--border-strong); border-radius: 8px; background: var(--surface-2); }
.portal .dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.portal .dropzone .hint, .portal .dropzone .upload-state { color: var(--text-2); font-size: 13px; }
.portal .dropzone .btn { cursor: pointer; width: auto; height: auto; padding: 4px 12px; }
.portal .dropzone [data-record].recording { background: var(--danger, #c0392b); border-color: var(--danger, #c0392b); color: #fff; }
.camera { border: 0; border-radius: 10px; padding: 12px; background: var(--surface); max-width: min(92vw, 720px); }
.camera::backdrop { background: rgba(0, 0, 0, .5); }
.camera video { display: block; width: 100%; max-height: 70vh; background: #000; border-radius: 6px; }
.camera .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }
/* nothing scrolls inside a screen: a taller set's box is grown to fit it (screens._grow_to_fit); a one-line set
   (Y / N / ?) keeps every choice on its line, even past FileMaker's box */
.screen .choices { display: flex; flex-wrap: wrap; gap: 0 8px; align-content: flex-start; height: 100%;
  overflow: visible; padding: 1px 2px; }
.screen .field.short .choices { flex-wrap: nowrap; }
.screen .choices label { display: inline-flex; gap: 4px; align-items: center; max-width: 100%; font-size: 12px;
  line-height: 1.2; }
.screen .field.short .choices label { white-space: nowrap; }
.screen .unknown { background: repeating-linear-gradient(45deg, transparent 0 6px, var(--surface-2) 6px 12px);
  border: 1px dashed var(--border); border-radius: 4px; }

/* a lab result outside its reference range (V30): H in the danger colour, L in the accent colour, as a letter at the
   right of its box, so it does not rest on colour alone; the lab entry screen also shows the range, beside the box; never a unit */
.screen .field .flag { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); pointer-events: none;
  font-size: 10px; color: var(--muted); white-space: nowrap; }
.screen .field .flag-mark { font-size: 11px; font-weight: 700; }
.screen .field.flag-h .flag-mark, .screen .field.flag-h input, .screen .field.flag-h .value { color: var(--danger); font-weight: 650; }
.screen .field.flag-l .flag-mark, .screen .field.flag-l input, .screen .field.flag-l .value { color: var(--accent); font-weight: 650; }
.screen .field.flag-h input, .screen .field.flag-h .value { background: var(--danger-soft); }
.screen .field.flag-l input, .screen .field.flag-l .value { background: var(--accent-soft); }
/* elsewhere the letter sits small in the box's top right corner, so a narrow column still shows the whole value */
.screen .field[data-low]:not(.ranged) .flag { top: 1px; right: 3px; transform: none; line-height: 1; }
.screen .field[data-low]:not(.ranged) .flag-mark { font-size: 9px; }
.screen .field[data-low]:not(.ranged) input, .screen .field[data-low]:not(.ranged) .value { padding-right: 9px; }
.screen .field.ranged .flag { right: auto; left: calc(100% + 4px); } /* the lab screen: beside the box */

.flowlabel { display: none; }
.screen .label.one-line { white-space: nowrap; } /* a short label never wraps under its neighbour */
.screen .label.right { justify-content: flex-end; text-align: right; white-space: pre; overflow: visible; padding-right: 4px; }
/* pre: keep FileMaker's own line breaks ("Pregnancy⏎History") but never wrap more, so the text ends at its field */

/* tabs */
.screen .tabs { display: flex; flex-direction: column; }
.tabbar { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: thin; flex: none; }
.tabbar button { border: 1px solid var(--border); border-bottom: none; background: var(--surface-2); color: var(--text-2);
  padding: 0 12px; border-radius: 6px 6px 0 0; cursor: pointer; white-space: nowrap; font-size: 12px; }
.tabbar button[aria-selected=true] { background: var(--surface); color: var(--text); font-weight: 600;
  box-shadow: inset 0 2px 0 var(--accent); }
.tabpanel { position: relative; flex: 1; border: 1px solid var(--border); border-radius: 0 6px 6px 6px;
  background: var(--surface); }
.tabpanel[hidden] { display: none; }
.tabinner { position: absolute; left: 0; right: 0; height: 0; } /* FileMaker places tab contents from the tab control's top */

/* portals */
.portal { border: 1px solid var(--border); border-radius: 6px; overflow: hidden; background: var(--surface); }
.portal .row { position: relative; border-bottom: 1px solid var(--border); }
.portal .row:nth-child(even) { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
.portal .row.link { cursor: pointer; }
.portal .row.link:hover { background: var(--accent-soft); }
.portal .row-del { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); margin: 0; }
.portal .row-del .btn.minus { width: 22px; height: 22px; padding: 0; line-height: 20px; text-align: center;
  color: var(--danger, #c0392b); background: transparent; border-color: transparent; font-size: 16px; }
.portal .row-del .btn.minus:hover { border-color: var(--danger, #c0392b); background: var(--surface); }
/* where the operation falls among the draws (screens.py _with_operations) */
.portal .row.marker { display: flex; align-items: center; gap: 24px; padding-left: 8px; color: var(--danger);
  font-weight: 700; border-top: 1px solid var(--danger); border-bottom: 1px solid var(--danger); }
.portal .empty { padding: 8px; color: var(--muted); }
.portal .add { position: sticky; bottom: 0; display: flex; justify-content: flex-end; padding: 3px; background: var(--surface); }
/* clickable column headers (static/js/app.js sorts the rows under them: asc -> desc -> the server's order) */
.portal .phead { position: relative; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.portal .phead .hcol { position: absolute; top: 0; height: 100%; box-sizing: border-box; display: flex;
  align-items: center; padding: 0 4px; font-size: 12px; font-weight: 600; color: var(--muted); cursor: pointer;
  user-select: none; white-space: nowrap; overflow: hidden; }
.portal .phead .hcol.num { justify-content: flex-end; }
.portal .phead .hcol:hover { color: var(--text, #111); }
.portal .phead .hcol::after { content: " \2195"; opacity: 0.35; }  /* up-down arrow, dim when unsorted */
.portal .phead .hcol[aria-sort="ascending"]::after { content: " \25B2"; opacity: 1; }
.portal .phead .hcol[aria-sort="descending"]::after { content: " \25BC"; opacity: 1; }

/* popovers; a warning button sits on top of the label it replaces (FileMaker draws it in front) */
.screen .o.over { z-index: 3; }
.screen .btn.warn { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); font-weight: 600; }
.popover { display: none; position: absolute; top: calc(100% + 4px); z-index: 30; background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: 8px; box-shadow: 0 8px 24px rgb(0 0 0 / 18%); }
.popover.open { display: block; }

/* menus (Copy Text, New visit) */
.menu { position: relative; display: inline-block; }
.menu .items { display: none; position: absolute; bottom: 100%; left: 0; z-index: 40; min-width: 180px; padding: 4px;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 8px; box-shadow: var(--shadow); }
.menu.open .items { display: block; }
.menu .items button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 6px 10px;
  border-radius: 4px; cursor: pointer; }
.menu .items button:hover { background: var(--accent-soft); }

/* ---------- tables and forms (find, lists, admin-like pages) ---------- */
/* the sections under a trial screen (apps/research/templates, V25) */
.trial-section { box-sizing: border-box; width: 830px; margin: 14px 0; padding: 14px 16px; zoom: var(--screen-scale, 1); }
@media (max-width: 900px) { .trial-section { width: auto; zoom: 1; } }
.trial-section h2 { margin: 0 0 8px; font-size: 13px; }
.trial-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px 14px; align-items: start; }
.trial-input { display: flex; flex-direction: column; gap: 3px; }
.trial-input span { font-size: 11px; font-weight: 600; color: var(--muted); }
.trial-input .in { height: 32px; width: 100%; }
.trial-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; grid-column: 1 / -1; }
table.list { width: 100%; border-collapse: collapse; background: var(--surface); }
table.list th, table.list td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--border); }
table.list th { color: var(--muted); font-weight: 600; font-size: 12px; background: var(--surface-2); }
table.list tr.link { cursor: pointer; }
table.list tr.link:hover td { background: var(--accent-soft); }
table.sortable thead th { cursor: pointer; user-select: none; white-space: nowrap; }
table.sortable thead th:hover { color: var(--text, #111); }
table.sortable thead th::after { content: " \2195"; opacity: 0.35; }  /* up-down arrow, dim when unsorted */
table.sortable thead th[aria-sort="ascending"]::after { content: " \25B2"; opacity: 1; }
table.sortable thead th[aria-sort="descending"]::after { content: " \25BC"; opacity: 1; }
.form { display: grid; grid-template-columns: max-content minmax(0, 360px); gap: 8px 12px; align-items: center; }
.form label { color: var(--text-2); }
dialog { border: 1px solid var(--border-strong); border-radius: 10px; padding: 16px; background: var(--surface);
  color: var(--text); box-shadow: 0 10px 40px rgb(0 0 0 / 25%); max-width: min(760px, 94vw); }
dialog::backdrop { background: rgb(0 0 0 / 35%); }

/* ---------- auth pages ---------- */
.auth { max-width: 400px; margin: 8vh auto; padding: 28px; }
.auth h1 { font-size: 20px; margin-top: 0; }
.auth input:not([type=checkbox]) { width: 100%; padding: 8px 10px; border: 1px solid var(--border-strong);
  border-radius: var(--radius); background: var(--input-bg); }
.auth p { margin: 10px 0; }
.auth button { width: 100%; padding: 9px; }

/* ---------- phone and narrow tablet: the same objects, in reading order ---------- */
@media (max-width: 900px) {
  body { --fs: 15px; }
  main { padding: 10px; }
  .topbar { flex-wrap: wrap; padding: 8px 10px; }
  .topbar form.search { order: 3; max-width: none; flex-basis: 100%; }
  .screen-wrap { overflow: visible; }
  .screen { width: auto !important; height: auto !important; transform: none !important; padding: 10px; }
  .screen .o { position: static; width: auto !important; height: auto !important; margin: 0 0 6px; }
  .screen .o.label { margin: 10px 0 2px; font-weight: 600; }
  .screen .o.label.paired { display: none; }
  .flowlabel { display: block; margin: 8px 0 3px; font-weight: 600; color: var(--text-2); font-size: 13px; }
  .topbar nav { overflow-x: auto; max-width: 100%; gap: 14px; scrollbar-width: none; }
  body { overflow-x: hidden; }
  .screen .o.box, .screen .o.line, .screen .o.decor { display: none; }
  .screen input[type=text], .screen input[type=date], .screen input[type=time], .screen select { min-height: 40px; }
  .screen textarea { min-height: 96px; }
  .screen .btn { min-height: 40px; font-size: 14px; }
  .screen .tabs { display: block; }
  .tabbar { position: sticky; top: 92px; z-index: 5; background: var(--surface); padding-top: 4px; }
  .tabbar button { min-height: 36px; font-size: 14px; }
  .tabpanel { padding: 8px; }
  .tabinner { position: static; height: auto; }
  .portal { max-height: none !important; }
  .portal .phead { display: none; }  /* on a phone the rows become cards, so the column header is dropped */
  .portal .row { padding: 8px; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 8px; }
  .screen .choices { gap: 6px 14px; }
  .screen .choices label { font-size: 15px; min-height: 32px; }
  .popover { position: fixed; inset: auto 8px 8px 8px !important; width: auto !important; }
  .menu .items { bottom: auto; top: 100%; }
  .form { grid-template-columns: 1fr; }
  table.list .hide-sm { display: none; }
}
@media print {
  .topbar, .footer-actions { display: none; }
  body { background: #fff; }
}

/* CanODT pages (apps/clinical/canodt.py, V27) */
.canodt-section { box-sizing: border-box; max-width: 1000px; margin: 14px 0; padding: 14px 16px; }
.canodt-section h2 { margin: 0 0 8px; font-size: 13px; }
.canodt-counts { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.state { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 11px; font-weight: 600;
  white-space: nowrap; background: var(--surface-2); color: var(--muted); }
.state.filled { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); }
.state.empty, .state.required { background: var(--danger-soft); color: var(--danger); }
.state.not-collected { background: var(--warn-soft); color: var(--warn); }
.state.fixed, .state.odo { background: var(--accent-soft); color: var(--accent); }
table.canodt { table-layout: fixed; }
table.canodt td { vertical-align: top; overflow-wrap: anywhere; }
table.canodt .eid { color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; margin-right: 4px; }
table.canodt .req { font-size: 12px; color: var(--muted); }
table.canodt .req.rejected { color: var(--danger); font-weight: 600; }

/* ---------- home screen (V116): tabbed portal of lists + find band ---------- */
.home-portal { margin-bottom: 22px; }
.tabs-nav { display: flex; gap: 2px; flex-wrap: wrap; margin-bottom: 8px; }
.tabs-nav a { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border: 1px solid var(--border);
  border-radius: 8px 8px 0 0; background: var(--surface-2); color: var(--text-2); text-decoration: none; font-weight: 600;
  font-size: 14px; }
.tabs-nav a:hover { background: var(--accent-soft); }
.tabs-nav a[aria-selected=true] { background: var(--surface); color: var(--text); border-bottom-color: var(--surface); }
.tabs-nav a .n { font-size: 12px; color: var(--muted); background: var(--bg); border-radius: 99px; padding: 0 7px;
  min-width: 18px; text-align: center; }
.tabs-nav a[aria-selected=true] .n { color: var(--accent); }
.home-find { margin-top: 18px; }
td.marks-col, td.marks { width: 96px; white-space: nowrap; }
td.marks form { display: inline; }
button.mark { width: 26px; height: 24px; padding: 0; margin: 0 1px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--surface); color: var(--muted); cursor: pointer; font-size: 13px; line-height: 1; vertical-align: middle; }
button.mark:hover { border-color: var(--accent); color: var(--accent); }
button.mark.star.on { color: #e6a700; border-color: #e6a700; }
button.mark.ip { font-size: 11px; font-weight: 700; }
button.mark.ip.on { color: #fff; background: var(--accent); border-color: var(--accent); }
.daily-paste { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; max-width: 760px; }
.daily-paste textarea { font-family: inherit; }
.daily-paste .btn { align-self: flex-start; }
table.list.daily td { vertical-align: top; }
.date-nav { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.date-nav .btn.nav { width: 34px; padding: 4px 0; text-align: center; font-size: 16px; }
.date-nav .date-pick { display: inline-flex; }
.date-nav .date-in { width: auto; }
.admit-bar { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.admit-bar .admit-find { display: flex; gap: 6px; flex: 1; max-width: 460px; }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; max-width: 980px; }
.settings-grid h2 { font-size: 15px; margin: 0 0 10px; }
.settings-grid ul.links { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.settings-grid ul.links li { display: flex; flex-direction: column; gap: 2px; }
.settings-grid ul.links li .meta { font-size: 12px; }
button.mark.day { font-size: 11px; font-weight: 700; }
button.mark.day.on { color: #fff; background: #7a52c0; border-color: #7a52c0; }
