/* DocuWiz web. One design, no build step.
   Rules of the design:
   1. The journey of an Rx is the structure: one rail, one station for each queue.
   2. Colour shows status only. One accent (ultramarine) shows "you are here" and the main action.
   3. Pattern shows "not real": a hatch marks demo records, a dashed line marks simulated results.
   4. Open sections on a cool paper; the sheet colour is for the places where a person types.
   5. Light or dark follows the system. Each colour is a token; the dark values are in one block below. */
:root {
  --paper: #f2f3f6;
  --sheet: #ffffff;
  --ink: #15172e;
  --ink-2: #454863;
  --ink-3: #5c5f7c;
  --line: #d3d5e0;
  --line-2: #e3e4ec;
  --ultra: #2b2fd6;
  --ultra-dark: #1e21a8;
  --ultra-tint: #e6e7fb;
  --ok: #0b6644;
  --ok-tint: #dff1e8;
  --warn: #7a4f00;
  --warn-tint: #faefcf;
  --bad: #ad231b;
  --bad-tint: #fae6e4;
  --off: #5c5f7c;
  --on-accent: #ffffff;
  --on-ink: #ffffff;
  --on-bad: #ffffff;
  --bad-stripe: #ffffff;
  --zero: #85889f;
  --invalid: #fffafa;
  --shadow: rgba(21, 23, 46, 0.18);
  --shadow-list: rgba(21, 23, 46, 0.12);
  --veil: rgba(21, 23, 46, 0.5);
  color-scheme: light dark;
  --hatch: repeating-linear-gradient(135deg, var(--ink) 0 2px, transparent 2px 6px);
  --display: Bahnschrift, "DIN Alternate", "Roboto Condensed", "Arial Narrow", "Segoe UI", sans-serif;
  --text: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  font-family: var(--text);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #101226;
    --sheet: #1a1d38;
    --ink: #eceefa;
    --ink-2: #c3c6dd;
    --ink-3: #a1a5c1;
    --line: #363a5a;
    --line-2: #272b49;
    --ultra: #9195ff;
    --ultra-dark: #adb0ff;
    --ultra-tint: #272a5c;
    --ok: #71d4a8;
    --ok-tint: #12372b;
    --warn: #e9c46a;
    --warn-tint: #3b3010;
    --bad: #ff9289;
    --bad-tint: #4a1c1a;
    --off: #7e82a3;
    --on-accent: #101226;
    --on-ink: #101226;
    --on-bad: #101226;
    --bad-stripe: #8f2a22;
    --zero: #6f7396;
    --invalid: #2c1618;
    --shadow: rgba(0, 0, 0, 0.5);
    --shadow-list: rgba(0, 0, 0, 0.5);
    --veil: rgba(0, 0, 0, 0.62);
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); min-height: 100vh; display: flex; flex-direction: column; }
h1, h2, .brand, .btn, .tab, .badge, .journey, table.list th, table.compare thead th { font-family: var(--display); }
h1 { font-size: 2.6rem; font-weight: 300; font-stretch: 80%; line-height: 1.05; margin: 0; }
h2 { font-size: 1.15rem; font-weight: 600; font-stretch: 90%; margin: 0 0 0.9rem; display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; }
h1:focus, h1:focus-visible { outline: none; }
p { margin: 0 0 0.65rem; max-width: 72ch; }
a { color: var(--ultra); text-underline-offset: 0.18em; }
:focus-visible { outline: 2px solid var(--ultra); outline-offset: 2px; }
[hidden] { display: none !important; }
.skip-link { position: absolute; left: -999px; top: 0; background: var(--sheet); padding: 0.5rem 1rem; z-index: 100; }
.skip-link:focus { left: 0.5rem; top: 0.5rem; }
.muted { color: var(--ink-3); }
.small { font-size: 0.87rem; }
.mono { font-family: var(--display); font-variant-numeric: tabular-nums; letter-spacing: 0.02em; }
.nowrap { white-space: nowrap; }

/* shell */
.topbar { display: flex; align-items: center; gap: 2rem; width: 100%; max-width: 1320px; margin: 0 auto; padding: 0 2rem; height: 64px; }
.brand { display: flex; align-items: center; gap: 0.6rem; font-weight: 600; font-size: 1.2rem; font-stretch: 90%; color: var(--ink); text-decoration: none; }
/* the mark is drawn with the colour tokens, so it follows light and dark */
.brand-mark { position: relative; flex: none; width: 26px; height: 26px; border-radius: 2px; background: var(--ink); }
.brand-mark::before { content: ""; position: absolute; left: 4px; right: 4px; top: 12px; height: 2px; background: var(--paper); }
.brand-mark::after { content: ""; position: absolute; right: 4px; top: 7px; width: 8px; height: 8px; border-radius: 50%; background: var(--ultra); border: 2px solid var(--paper); }
.topnav { display: flex; gap: 1.5rem; flex: 1; min-width: 0; }
.topnav a { padding: 0.5rem 0; color: var(--ink-2); text-decoration: none; border-bottom: 2px solid transparent; }
.topnav a:hover { color: var(--ink); border-bottom-color: var(--line); }
.topnav a[aria-current="page"] { color: var(--ink); font-weight: 600; border-bottom-color: var(--ink); }
.topbar-user { display: flex; align-items: center; gap: 1rem; }
.user-name { text-align: right; line-height: 1.25; }
.user-name strong { display: block; font-weight: 600; }
.demo-banner { position: relative; background: var(--sheet); color: var(--ink); padding: 0.5rem 2rem 0.5rem 4.2rem; font-size: 0.92rem; font-weight: 600; border-block: 1px solid var(--ink); }
.demo-banner::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 3.2rem; background: var(--hatch); border-right: 1px solid var(--ink); }
main { flex: 1; width: 100%; max-width: 1320px; margin: 0 auto; padding: 2rem 2rem 3rem; }
main:focus:not(:focus-visible) { outline: none; }
main:focus-visible { outline-offset: -2px; }

/* buttons */
.btn { font-size: 1rem; font-weight: 600; font-stretch: 95%; line-height: 1.2; padding: 0.55rem 1.1rem; border-radius: 2px; border: 1px solid var(--ink); background: transparent; color: var(--ink); cursor: pointer; min-height: 40px; text-decoration: none; display: inline-flex; align-items: center; }
.btn:hover { background: var(--sheet); }
.btn.primary { background: var(--ultra); border-color: var(--ultra); color: var(--on-accent); }
.btn.primary:hover { background: var(--ultra-dark); border-color: var(--ultra-dark); }
.btn.danger { color: var(--bad); border-color: var(--bad); }
.btn.danger:hover { background: var(--bad-tint); }
.btn.quiet { border-color: transparent; color: var(--ink-2); padding-inline: 0; font-weight: 500; }
.btn.quiet:hover { background: transparent; color: var(--ultra); }
.btn:disabled, .btn:disabled:hover { color: var(--off); border-color: var(--line); background: transparent; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: 0.7rem; align-items: center; }
form > .btn-row { margin-top: 1.5rem; padding-top: 1.25rem; border-top: 1px solid var(--line); }

/* sections: open, with one rule above; no boxes */
.card { border-top: 1px solid var(--ink); padding: 1rem 0 0.5rem; }
.card + .card { margin-top: 2rem; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem 1rem; margin-bottom: 1.5rem; }
.page-head .spacer { flex: 1; }
.page-head .back { flex-basis: 100%; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 4fr) minmax(0, 7fr); gap: 3.5rem; align-items: start; }
.stack > * + * { margin-top: 2rem; }
/* the order as received is a document: it is the one white sheet on the page */
.card.source { background: var(--sheet); border: 1px solid var(--line); border-top: 1px solid var(--ink); padding: 1.1rem 1.25rem 1.25rem; }

/* marks */
.badge { display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.12rem 0.5rem; border-radius: 2px; font-size: 0.82rem; font-weight: 600; line-height: 1.35; border: 1px solid transparent; white-space: nowrap; }
.badge.neutral { background: var(--line-2); color: var(--ink-2); }
.badge.info { background: var(--ultra-tint); color: var(--ultra-dark); }
.badge.ok { background: var(--ok-tint); color: var(--ok); }
.badge.warn { background: var(--warn-tint); color: var(--warn); }
.badge.bad { background: var(--bad-tint); color: var(--bad); }
.badge.demo { background: var(--sheet); color: var(--ink); border-color: var(--ink); padding-left: 0; overflow: hidden; }
.badge.demo::before { content: ""; align-self: stretch; width: 0.9rem; margin-block: -0.12rem; background: var(--hatch); border-right: 1px solid var(--ink); }
.badge.sim { background: transparent; color: var(--ink); border: 1px dashed var(--ink); }

/* sign-in */
.signin { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 4rem; align-items: start; padding-top: 8vh; }
.signin-mark { font-family: var(--display); font-size: clamp(3.5rem, 9vw, 7rem); font-weight: 300; font-stretch: 75%; line-height: 0.95; margin: 0 0 1.5rem; }
.signin-rail { height: 2px; background: var(--ink); position: relative; margin-bottom: 1.5rem; transform-origin: left; animation: draw 0.7s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
.signin-rail::before { content: ""; position: absolute; left: 0; top: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--ultra); }
.signin .card { border-top: none; padding-top: 0; }
.signin h1 { font-size: 1.6rem; font-weight: 600; font-stretch: 90%; margin-bottom: 1rem; }
.signin-form .field { margin-top: 1.1rem; max-width: 24rem; }
.signin-form .btn-row { margin-top: 1.5rem; }
.user-list { list-style: none; margin: 1.5rem 0 0; padding: 0; border-top: 1px solid var(--ink); }
.user-pick { width: 100%; display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; text-align: left; padding: 0.95rem 0.25rem; min-height: 56px; border: none; border-bottom: 1px solid var(--line); border-radius: 0; font-size: 1.25rem; }
.user-pick:hover { background: var(--sheet); color: var(--ultra); }
.user-pick span:last-child { color: var(--ink-3); font-family: var(--text); font-size: 0.92rem; font-weight: 400; }
.notice { border-left: 3px solid var(--ink); background: var(--sheet); padding: 0.7rem 1rem; font-size: 0.93rem; max-width: none; }
main > .notice, form > .notice { margin-bottom: 1.25rem; }
.notice p:last-child { margin-bottom: 0; }
.card > .notice { margin-bottom: 0.9rem; }
.notice.warn { border-color: var(--warn); background: var(--warn-tint); }
.notice.bad { border-color: var(--bad); background: var(--bad-tint); }
.notice.info { border-color: var(--ultra); background: var(--ultra-tint); }
.notice.ok { border-color: var(--ok); background: var(--ok-tint); }
.notice.btn-row { justify-content: space-between; }

/* the rail: one station for each queue */
.tabs { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); margin-bottom: 2.25rem; padding-top: 6px; }
.tab { position: relative; display: flex; flex-direction: column-reverse; justify-content: flex-end; align-items: flex-start; gap: 0.3rem; padding: 1.1rem 0.75rem 0.4rem 0; border-top: 2px solid var(--ink); color: var(--ink-2); font-size: 0.95rem; font-weight: 500; line-height: 1.25; text-decoration: none; }
.tab::before { content: ""; position: absolute; top: -6px; left: 0; width: 10px; height: 10px; border-radius: 50%; background: var(--paper); border: 2px solid var(--ink); }
.tab[data-status="REJECTED"], .tab[data-status="DISCARDED"] { border-top-style: dashed; }
.tab:hover { color: var(--ink); }
.tab:focus-visible { outline-offset: -3px; }
.tab:hover::before { background: var(--ink); }
.tab[aria-current="page"] { color: var(--ink); font-weight: 600; }
.tab[aria-current="page"]::before { background: var(--ultra); border-color: var(--ultra); box-shadow: 0 0 0 4px var(--ultra-tint); }
.count { font-size: 3rem; font-weight: 300; font-stretch: 75%; line-height: 1; color: var(--ink); font-variant-numeric: tabular-nums; }
.count.zero { color: var(--zero); }
.tab[aria-current="page"] .count { color: var(--ultra); }
.search { font: inherit; padding: 0.5rem 0.2rem; border: none; border-bottom: 1px solid var(--ink); border-radius: 0; background: transparent; color: var(--ink); min-width: 320px; min-height: 40px; }
.search::placeholder, .field input::placeholder { color: var(--ink-3); opacity: 1; }

/* the list: an open ledger */
table.list { width: 100%; border-collapse: collapse; }
table.list th { text-align: left; font-size: 0.85rem; color: var(--ink-3); font-weight: 500; padding: 0 1rem 0.5rem 0; border-bottom: 1px solid var(--ink); }
table.list td { padding: 0.95rem 1rem 0.95rem 0; border-bottom: 1px solid var(--line); vertical-align: top; }
table.list tbody tr:hover { background: var(--sheet); }
.rx-link { font-family: var(--display); font-size: 1.35rem; font-weight: 600; font-stretch: 80%; line-height: 1.1; color: var(--ink); text-decoration: none; font-variant-numeric: tabular-nums; }
tr:hover .rx-link, .rx-link:hover { color: var(--ultra); }
.cell-sub { color: var(--ink-3); font-size: 0.87rem; }
.empty { padding: 3rem 0; color: var(--ink-2); font-size: 1.1rem; max-width: 60ch; }
.tag-row { display: flex; flex-wrap: wrap; gap: 0.3rem; }

/* journey of one Rx */
.journey { list-style: none; display: flex; margin: 0 0 2.25rem; padding: 6px 0 0; }
.journey li { position: relative; flex: 1; border-top: 2px solid var(--line); padding: 0.75rem 0.75rem 0 0; color: var(--ink-3); font-size: 0.92rem; line-height: 1.25; }
.journey li::before { content: ""; position: absolute; top: -6px; left: 0; width: 10px; height: 10px; border-radius: 50%; background: var(--paper); border: 2px solid var(--line); }
.journey li.done { border-top-color: var(--ink); color: var(--ink-2); }
.journey li.done::before { background: var(--ink); border-color: var(--ink); }
.journey li[aria-current="step"] { color: var(--ink); font-weight: 600; }
.journey li[aria-current="step"]::before { background: var(--ultra); border-color: var(--ultra); box-shadow: 0 0 0 4px var(--ultra-tint); }
.journey li.stop[aria-current="step"]::before { background: var(--bad); border-color: var(--bad); box-shadow: 0 0 0 4px var(--bad-tint); }
.journey li.wait[aria-current="step"]::before { background: var(--warn); border-color: var(--warn); box-shadow: 0 0 0 4px var(--warn-tint); }

/* facts */
dl.facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 0.4rem 1.25rem; margin: 0; }
dl.facts dt { color: var(--ink-3); font-size: 0.87rem; padding-top: 0.1rem; }
dl.facts dd { margin: 0; overflow-wrap: anywhere; }

/* form */
.form-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 1rem 1.1rem; }
.field { grid-column: span 2; display: flex; flex-direction: column; gap: 0.3rem; position: relative; }
.field.w3 { grid-column: span 3; }
.field.w6 { grid-column: span 6; }
.field label, .field .label { font-size: 0.85rem; font-weight: 600; color: var(--ink-2); }
.field input, .field select, .field textarea { font: inherit; padding: 0.5rem 0.65rem; border: 1px solid var(--line); border-bottom: 1px solid var(--ink); border-radius: 2px; background: var(--sheet); color: var(--ink); min-height: 40px; width: 100%; }
.field input:hover, .field select:hover, .field textarea:hover { border-color: var(--ink-3); }
.field textarea { min-height: 72px; resize: vertical; }
.field input:disabled, .field select:disabled, .field textarea:disabled { background: transparent; border-color: var(--line); color: var(--ink-2); opacity: 1; }
.field input[aria-invalid="true"], .field select[aria-invalid="true"] { border-color: var(--bad); border-bottom-width: 2px; background: var(--invalid); }
.field .hint { font-size: 0.85rem; color: var(--ink-3); min-height: 1.25em; }
.field .hint.err { color: var(--bad); font-weight: 600; }
.check { flex-direction: row; align-items: center; gap: 0.55rem; padding-top: 1.5rem; }
.check input { flex: none; width: 20px; height: 20px; min-height: 0; accent-color: var(--ultra); }
.check label { font-size: 0.95rem; font-weight: 400; color: var(--ink); }
.listbox { position: absolute; top: 100%; left: 0; right: 0; z-index: 20; margin: 2px 0 0; padding: 0; list-style: none; background: var(--sheet); border: 1px solid var(--ink); border-radius: 2px; box-shadow: 6px 6px 0 var(--shadow-list); max-height: 300px; overflow-y: auto; }
.listbox li { padding: 0.5rem 0.7rem; cursor: pointer; border-bottom: 1px solid var(--line-2); }
.listbox li:last-child { border-bottom: none; }
.listbox li[aria-selected="true"] { background: var(--ultra-tint); box-shadow: inset 3px 0 0 var(--ultra); }
.listbox li .cell-sub { display: block; }

/* issues, compare, history */
ul.issues { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.5rem; }
ul.issues li { display: flex; gap: 0.7rem; align-items: baseline; }
table.compare { width: 100%; border-collapse: collapse; margin-bottom: 1rem; }
table.compare th, table.compare td { text-align: left; padding: 0.5rem 0.75rem 0.5rem 0; border-bottom: 1px solid var(--line); vertical-align: top; overflow-wrap: break-word; }
table.compare thead th { font-size: 0.85rem; color: var(--ink-3); font-weight: 500; border-bottom-color: var(--ink); }
table.compare tbody th { font-weight: 400; color: var(--ink-3); font-size: 0.87rem; width: 9rem; }
table.compare tr.diff td { background: var(--warn-tint); padding-left: 0.5rem; }
ol.history { list-style: none; margin: 0; padding: 0; }
ol.history li { display: grid; grid-template-columns: 9rem minmax(0, 1fr); gap: 1rem; padding: 0.55rem 0; border-bottom: 1px solid var(--line); }
ol.history li:last-child { border-bottom: none; }
.amounts { display: flex; flex-wrap: wrap; gap: 2rem; margin: 0.75rem 0 1rem; }
.amounts div span { display: block; font-size: 0.85rem; color: var(--ink-3); }
.amounts div strong { font-family: var(--display); font-size: 1.7rem; font-weight: 300; font-stretch: 80%; line-height: 1.1; font-variant-numeric: tabular-nums; }

/* switch */
.switch { display: inline-flex; align-items: center; gap: 1rem; font-family: var(--display); font-size: 1.6rem; font-weight: 300; font-stretch: 80%; margin-bottom: 0.75rem; }
.switch button, .option-value button[role="switch"] { width: 64px; height: 34px; border-radius: 2px; border: 1px solid var(--ink); background: var(--sheet); position: relative; cursor: pointer; padding: 0; }
.switch button::after, .option-value button[role="switch"]::after { content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 1px; background: var(--ink); transition: left 0.14s; }
.switch button[aria-checked="true"], .option-value button[role="switch"][aria-checked="true"] { background: var(--hatch), var(--sheet); }
.switch button[aria-checked="true"]::after, .option-value button[role="switch"][aria-checked="true"]::after { left: 33px; background: var(--ultra); }

/* dialog and toasts */
dialog { border: 1px solid var(--ink); border-top: 4px solid var(--ink); border-radius: 0; padding: 1.5rem; max-width: 480px; width: calc(100% - 2rem); box-shadow: 10px 10px 0 var(--shadow); color: var(--ink); background: var(--sheet); }
dialog::backdrop { background: var(--veil); }
dialog h2 { font-size: 1.35rem; }
dialog .field { margin-bottom: 1rem; }
.toast-region { position: fixed; right: 1.25rem; bottom: 1.25rem; display: grid; gap: 0.5rem; z-index: 50; max-width: min(440px, calc(100vw - 2rem)); }
.toast { background: var(--ink); color: var(--on-ink); padding: 0.75rem 1rem; border-left: 4px solid var(--ultra); border-radius: 2px; animation: rise 0.18s ease-out both; }
.toast.bad { background: var(--bad); color: var(--on-bad); border-left-color: var(--bad-stripe); }
.noscript { padding: 2rem; }

@keyframes draw { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes rise { from { transform: translateY(6px); opacity: 0; } to { transform: none; opacity: 1; } }

@media (max-width: 1000px) {
  .grid-2 { grid-template-columns: minmax(0, 1fr); gap: 2rem; }
  .signin { grid-template-columns: minmax(0, 1fr); gap: 1.5rem; padding-top: 3vh; }
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .field, .field.w3 { grid-column: span 1; }
  .field.w6 { grid-column: span 2; }
  .count { font-size: 2.4rem; }
}
@media (max-width: 700px) {
  h1 { font-size: 2rem; }
  main { padding: 1.25rem 1rem 2rem; }
  .topbar { padding: 0 1rem; gap: 0.6rem; height: 56px; }
  .topbar .btn { padding-inline: 0.7rem; }
  .demo-banner { padding: 0.45rem 1rem 0.45rem 2.4rem; font-size: 0.85rem; }
  .demo-banner::before { width: 1.6rem; }
  .user-name { display: none; }
  .topnav { gap: 0.75rem; }
  .topnav a, .topbar .btn { white-space: nowrap; }
  .brand span { display: none; }
  .field.w3 { grid-column: span 2; }
  .search { min-width: 0; width: 100%; }
  /* touch sizes */
  .btn, .field input, .field select, .search { min-height: 44px; font-size: 16px; }
  .field textarea { font-size: 16px; }
  .topnav a { padding: 0.75rem 0; }
  .rx-link { display: inline-flex; align-items: center; min-height: 44px; padding: 0 0.6rem 0 0; font-size: 1.5rem; }
  .field.check input { width: 24px; height: 24px; min-height: 0; }
  .brand { min-height: 44px; min-width: 44px; }
  .switch button, .option-value button[role="switch"] { width: 84px; height: 44px; }
  .switch button::after, .option-value button[role="switch"]::after { width: 36px; height: 36px; }
  .switch button[aria-checked="true"]::after, .option-value button[role="switch"][aria-checked="true"]::after { left: 43px; }
  /* the rail folds into two rows of three stations */
  .tabs { grid-auto-flow: row; grid-template-columns: repeat(3, minmax(0, 1fr)); row-gap: 1.25rem; margin-bottom: 1.5rem; }
  .tab { padding-top: 0.8rem; font-size: 0.85rem; min-height: 44px; }
  .count { font-size: 2rem; }
  .journey li { font-size: 0.8rem; padding-right: 0.4rem; }
  /* the comparison becomes one block for each field */
  table.compare thead { position: absolute; left: -9999px; }
  table.compare, table.compare tbody, table.compare tr, table.compare th, table.compare td { display: block; width: 100%; }
  table.compare tr { padding: 0.45rem 0; border-bottom: 1px solid var(--line); }
  table.compare th, table.compare td { border: none; padding: 0.1rem 0.4rem; }
  table.compare td:nth-of-type(1)::before { content: "As received: "; color: var(--ink-3); font-size: 0.82rem; }
  table.compare td:nth-of-type(2)::before { content: "Entered: "; color: var(--ink-3); font-size: 0.82rem; }
  table.compare td[data-label]:nth-of-type(n)::before { content: attr(data-label) ": "; }
  table.compare tbody th { width: auto; }
  /* the list becomes one block for each Rx */
  table.list thead { position: absolute; left: -9999px; }
  table.list, table.list tbody, table.list tr, table.list td { display: block; width: 100%; }
  table.list tr { padding: 0.8rem 0; border-bottom: 1px solid var(--ink); }
  table.list td { padding: 0.12rem 0; border: none; }
  table.list td[data-label]::before { content: attr(data-label) ": "; color: var(--ink-3); font-size: 0.82rem; }
  table.list td[data-label="Rx #"]::before { content: none; }
  ol.history li { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .toast-region { right: 1rem; left: 1rem; bottom: 1rem; }
}
@media (max-width: 520px) {
  /* a narrow screen: the navigation gets its own row, so no link is under the button */
  .topbar { flex-wrap: wrap; height: auto; padding-block: 0.3rem; justify-content: space-between; row-gap: 0; }
  .topnav { order: 3; flex-basis: 100%; flex-wrap: wrap; row-gap: 0; }  /* four links of the manager do not fit one line at 320 px */
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }

.signin .user-list + .btn-row { margin-top: 1.5rem; }

/* Facility options */
ul.options { list-style: none; margin: 0; padding: 0; }
ul.options li { display: grid; grid-template-columns: minmax(0, 1fr) 14rem 14rem; gap: 0.5rem 1.5rem; align-items: center; padding: 0.55rem 0; border-bottom: 1px solid var(--line); min-height: 3.4rem; }
ul.options li:last-child { border-bottom: none; }
ul.options li.differs { box-shadow: inset 3px 0 0 var(--ultra); padding-left: 0.9rem; }
.option-value select, .option-number input { font: inherit; padding: 0.5rem 0.65rem; border: 1px solid var(--line); border-bottom: 1px solid var(--ink); border-radius: 2px; background: var(--sheet); color: var(--ink); min-height: 44px; }
.option-value select { width: 100%; }
.option-number { display: flex; align-items: center; gap: 0.5rem; }
.option-number input { width: 7rem; }
.option-default { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; }
ul.plain { list-style: none; margin: 0.4rem 0 0; padding: 0; }
@media (max-width: 760px) {
  ul.options li { grid-template-columns: minmax(0, 1fr); gap: 0.4rem; }
  .option-default { justify-content: flex-start; }
}
/* The hatch is the mark of demo records only: an option that is on has the plain accent tint. */
.option-value button[role="switch"][aria-checked="true"] { background: var(--ultra-tint); }

/* Labels, pack and final check */
table.labels { width: 100%; border-collapse: collapse; margin-bottom: 1rem; }
table.labels th, table.labels td { text-align: left; padding: 0.5rem 0.75rem 0.5rem 0; border-bottom: 1px solid var(--line); vertical-align: top; overflow-wrap: anywhere; }
table.labels thead th { font-family: var(--display); font-size: 0.85rem; color: var(--ink-3); font-weight: 500; border-bottom-color: var(--ink); }
table.labels tbody th { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pack-form, .scan-form { margin: 1rem 0; max-width: 46rem; }
.pack-form h3, .card h3 { font-family: var(--display); font-size: 1.05rem; margin: 1.25rem 0 0.6rem; }
.pack-form .field, .scan-form .field { grid-column: span 3; }
.scan-form .hint { margin-top: 0.4rem; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; padding: 0; }
@media (max-width: 700px) {
  /* On a phone each label is a block: the barcode, then each value with its name. */
  table.labels thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  table.labels tr { display: block; padding: 0.5rem 0; border-bottom: 1px solid var(--line); }
  table.labels th, table.labels td { display: block; border: 0; padding: 0.1rem 0; }
  table.labels td[data-label]:not(:empty)::before { content: attr(data-label) ": "; color: var(--ink-3); }
  .pack-form .field, .scan-form .field { grid-column: span 2; }
}

/* Claim reject work */
.reject-work { margin-top: 0.9rem; }
.page-head select { font: inherit; padding: 0.5rem 0.2rem; border: none; border-bottom: 1px solid var(--ink); border-radius: 0; background: transparent; color: var(--ink); min-height: 40px; }
.page-head select option { background: var(--sheet); color: var(--ink); }
@media (max-width: 700px) { .page-head select { min-height: 44px; font-size: 16px; width: 100%; } }

/* Clinical checks and the allergy record */
ul.alerts { list-style: none; margin: 0; padding: 0; }
ul.alerts li { display: flex; flex-wrap: wrap; gap: 0.35rem 0.7rem; align-items: baseline; padding: 0.55rem 0; border-bottom: 1px solid var(--line); }
ul.alerts li:last-child { border-bottom: none; }
ul.alerts .alert-text { flex: 1 1 12rem; min-width: 0; overflow-wrap: anywhere; }
ul.alerts .alert-text .cell-sub { display: block; }
ul.alerts .btn { align-self: center; }
details.fold { margin-top: 0.6rem; }
details.fold > summary { cursor: pointer; padding: 0.5rem 0; color: var(--ink-2); font-size: 0.93rem; font-weight: 600; }
dl.allergy { margin-top: 0.4rem; }
dl.allergy .badge { white-space: normal; overflow-wrap: anywhere; max-width: 100%; }
.allergy-list li span, ol.history li, dialog p { overflow-wrap: anywhere; min-width: 0; }
.allergy-list li { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.2rem 1rem; padding: 0.2rem 0; border-bottom: 1px solid var(--line); }
#allergy-edit .field { margin: 0.75rem 0; max-width: 26rem; }
@media (max-width: 700px) { details.fold > summary { padding: 0.85rem 0; } }

/* Intake */
.figures { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 1.5rem; margin-bottom: 2.25rem; }
.figure { display: flex; flex-direction: column; gap: 0.2rem; border-top: 1px solid var(--ink); padding-top: 0.6rem; }
.figure strong { font-family: var(--display); font-size: 1.5rem; font-weight: 600; }
.figure span { color: var(--ink-3); font-size: 0.87rem; }
.coverage-form { margin-top: 1.5rem; border-top: 1px solid var(--line); padding-top: 1rem; }
.coverage-form h3 { font-size: 1rem; margin: 0 0 0.75rem; }
@media (max-width: 700px) {
  .figures { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
}
table.list td, table.compare th, table.compare td, .page-head h1, ul.plain li { overflow-wrap: anywhere; }
@media (max-width: 700px) { table.compare .nowrap { white-space: normal; } }
