/* LabLoop
   A working tool for lab staff, nurses, phlebotomists and couriers: quiet surfaces,
   one typeface, structure carried by type and spacing rather than boxes. Navy is the
   action color (from the logo); teal is kept for the logo and live timing only. */

@font-face {
  font-family: 'Plex';
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url(/static/vendor/fonts/ibm-plex-sans-latin-wght-normal.woff2) format('woff2-variations');
}

:root {
  --ink: #16213a;
  --ink-2: #4b5666;
  --ink-3: #5f6876;
  --line: #e2e6ec;
  --line-2: #eef1f5;
  --bg: #f4f6f8;
  --card: #ffffff;
  --navy: #0d2a5c;
  --navy-deep: #082045;
  --accent: #0d2a5c;
  --accent-ink: #ffffff;
  --accent-soft: #e9eef7;
  --brand-navy: #0d2a5c;
  --brand-teal: #0a8f8f;
  --teal: #0b7373;
  --ok: #1d7a4c;
  --ok-soft: #e6f4ec;
  --warn: #8a5200;
  --warn-soft: #fbf1df;
  --bad: #b3261e;
  --bad-soft: #fbe9e7;
  --info: #2a5db0;
  --info-soft: #e9eff9;
  --radius: 8px;
  --radius-sm: 6px;
  --radius-lg: 12px;
  --field-line: #8a93a1;
  --field-bg: #ffffff;
  --btn-line: #cfd6df;
  --hover: #eef1f5;
  --well: #f6f8fa;
  --paper: #ffffff;
  --muted-fill: #b8c3ce;
  --bad-deep: #961f18;
  --ok-ink: #14532d; --ok-line: #c3e4d0;
  --bad-ink: #7f1d1d; --bad-line: #f0c7c3;
  --warn-ink: #6b3f00; --warn-line: #efd9ab;
  --code-bg: #141b26; --code-ink: #e6eef3;
  --ups: #6b4a1f; --ups-ink: #ffffff; --ups-soft: #fffbf2;
  --c1-bg: #e6f0fb; --c1-ink: #1d4f91;
  --c2-bg: #e8f6ee; --c2-ink: #1f6b3a;
  --c3-bg: #fdeee6; --c3-ink: #8a3b12;
  --c4-bg: #f1eafb; --c4-ink: #5b2d91;
  /* Map markers sit on light map tiles in both themes. */
  --map-pin: #1f6feb; --map-halo: #ffffff; --map-ink: #1f2a44; --map-stat: #fee2e2;
  --scrim: #000000;
  --shadow: none;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 400 15px/1.5 'Plex', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-feature-settings: 'tnum' 1, 'cv11' 1;
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--navy); text-decoration-thickness: 1px; text-underline-offset: 2px; }
h1 { font-size: 24px; font-weight: 600; line-height: 1.2; margin: 0 0 4px; letter-spacing: -0.02em; color: var(--ink); }
h2 { font-size: 15px; font-weight: 600; margin: 0 0 12px; letter-spacing: -0.005em; }
h3 { font-size: 13px; font-weight: 600; margin: 0 0 10px; color: var(--ink-2); }
p { margin: 0 0 12px; }
.muted { color: var(--ink-3); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; word-break: break-all; }
:focus-visible { outline: 2px solid var(--navy); outline-offset: 2px; }

/* Header: one row. Logo, section links with an underline marker, account. */
.top {
  display: flex; align-items: stretch; gap: 28px;
  padding: 0 24px; background: var(--card); border-bottom: 1px solid var(--line);
  min-height: 56px;
}
.brand { display: flex; align-items: center; color: var(--ink); text-decoration: none; flex: none; }
.brand .logo { height: 28px; width: auto; display: block; }
.nav { display: flex; gap: 2px; flex: 0 1 auto; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
  display: flex; align-items: center; padding: 0 10px; white-space: nowrap;
  text-decoration: none; color: var(--ink-2); font-weight: 500; font-size: 14px;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.nav a:hover { color: var(--ink); }
.nav a.on { color: var(--navy); border-bottom-color: var(--navy); font-weight: 600; }
.who { display: flex; align-items: center; gap: 14px; margin-left: auto; font-size: 14px; flex: none; }
.who a { color: var(--ink-2); text-decoration: none; }
.who a:hover { color: var(--ink); }
.who form { margin: 0; }
.themebtn { background: none; border: 0; padding: 0; font: inherit; font-size: 13px; color: var(--ink-3); cursor: pointer; white-space: nowrap; }
.themebtn:hover { color: var(--ink); }
@media (max-width: 760px) {
  /* Phones: logo and Log out on one row, the sections as a swipeable strip under it.
     The name and theme control live on the account page instead. */
  .top { flex-wrap: wrap; gap: 0 16px; padding: 0 16px; min-height: 0; }
  .brand { height: 48px; }
  .brand .logo { height: 24px; }
  .who { height: 48px; gap: 12px; }
  .who .themebtn, .who > a { display: none; }
  .nav { order: 3; flex-basis: 100%; border-top: 1px solid var(--line-2); margin: 0 -16px; padding: 0 10px; }
  .nav a { padding: 10px 8px; font-size: 14px; }
  .nav a.on { border-bottom-width: 2px; }
}

main { width: 100%; max-width: 1120px; margin: 0 auto; padding: 28px 24px 48px; flex: 1; }
main.narrow { max-width: 420px; padding-top: 64px; }
main.narrow .card { padding: 28px; }
main.narrow h1 { font-size: 28px; margin-bottom: 16px; }
.formfoot { margin: 14px 0 0; font-size: 14px; text-align: center; }
.formfoot a { color: var(--ink-2); }
.foot { text-align: center; color: var(--ink-3); font-size: 12px; padding: 20px 16px 24px; }
@media (max-width: 760px) { main { padding: 20px 16px 40px; } }

/* Demo site */
.demo-bar { background: var(--navy); color: var(--accent-ink); text-align: center; font-size: 13px; padding: 6px 12px; }
.demo-card { border-color: var(--navy); }
.demo-roles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.demo-roles .btn { flex-direction: column; gap: 0; padding: 10px 8px; line-height: 1.3; }
.demo-roles .btn .small { font-weight: 400; }
main.narrow:has(.demo-card) { max-width: 520px; }

/* Page head */
.pagehead { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.pagehead .sub { color: var(--ink-3); font-size: 14px; }
.pagehead .actions input, .pagehead .actions select { width: auto; }

/* Cards: a hairline and white, nothing else. Grouping comes from space. */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; }
.card.tight { padding: 0; overflow: hidden; }
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.stats { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); margin-bottom: 18px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat .n { font-size: 28px; font-weight: 500; line-height: 1.1; letter-spacing: -0.02em; }
.stat .l { color: var(--ink-3); font-size: 13px; }
.stat.warn .n { color: var(--warn); }
.stat.bad .n { color: var(--bad); }

dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 7px 18px; margin: 0; }
dl.kv dt { color: var(--ink-3); font-size: 14px; padding-top: 1px; }
dl.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
dl.kv { grid-template-columns: max-content minmax(0, 1fr); }

/* Tables (become stacked cards on phones) */
table.list { width: 100%; border-collapse: collapse; }
table.list th { text-align: left; font-size: 13px; color: var(--ink-3); font-weight: 500; padding: 10px 16px; border-bottom: 1px solid var(--line); }
table.list td { padding: 12px 16px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
table.list tr:last-child td { border-bottom: 0; }
table.list tr.rowlink { cursor: pointer; }
table.list tr.rowlink:hover td { background: var(--hover); }
table.list .num { font-variant-numeric: tabular-nums; }
table.list td a { text-decoration: none; font-weight: 500; }
table.list td a:hover { text-decoration: underline; }
.empty { padding: 32px; text-align: center; color: var(--ink-3); }
@media (max-width: 720px) {
  /* Each row becomes a compact record: the first cell (the name) on its own line,
     the rest as label / value pairs. Empty cells vanish. */
  table.list thead { display: none; }
  table.list, table.list tbody, table.list tr, table.list td { display: block; width: 100%; }
  table.list tr { border-bottom: 1px solid var(--line); padding: 12px 0 10px; }
  table.list tr:last-child { border-bottom: 0; }
  table.list td { border: 0; padding: 2px 16px; }
  table.list td:empty, table.list td.none { display: none; }
  table.list td[data-label] { position: relative; padding-left: 112px; min-height: 22px; }
  table.list td[data-label]::before { content: attr(data-label); position: absolute; left: 16px; top: 3px; width: 88px; font-size: 13px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  table.list td[data-label="Patient"]:first-child, table.list td[data-label="Name"]:first-child, table.list td[data-label="Order"]:first-child, table.list td[data-label="Document"]:first-child { padding-left: 16px; padding-bottom: 6px; }
  table.list td[data-label="Patient"]:first-child::before, table.list td[data-label="Name"]:first-child::before, table.list td[data-label="Order"]:first-child::before, table.list td[data-label="Document"]:first-child::before { display: none; }
  table.list td[data-label="Select"] { padding-left: 16px; padding-bottom: 4px; }
  table.list td[data-label="Select"]::before { display: none; }
  table.list td.small { font-size: 14px; }
  .card { padding: 16px; }
  .pagehead { margin-bottom: 14px; }
  .pagehead h1 { font-size: 22px; }
  .setgrid, .routegrid { gap: 10px; }
  .stats { gap: 8px; grid-template-columns: 1fr 1fr; }
  .grid.two, .grid.three { gap: 12px; }
  dl.kv { grid-template-columns: 96px minmax(0, 1fr); gap: 6px 12px; }
  .filters { margin: 0 -16px 12px; padding: 0 16px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .filters::-webkit-scrollbar { display: none; }
  .filters a { white-space: nowrap; }
  .btn { padding: 10px 16px; }
  .actions .btn { flex: 1 1 auto; }
}

/* Pills: tinted text on a soft field; status reads at a glance, never shouts. */
.pill { display: inline-block; padding: 2px 8px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 500; white-space: nowrap; line-height: 1.5; }
.s-pending_signature { background: var(--warn-soft); color: var(--warn); }
.s-signed { background: var(--ok-soft); color: var(--ok); }
.s-received { background: var(--info-soft); color: var(--info); }
.s-declined { background: var(--bad-soft); color: var(--bad); }
.s-cancelled { background: var(--line-2); color: var(--ink-2); }
.pill.stat { background: var(--bad); color: var(--accent-ink); margin-left: 6px; font-weight: 600; letter-spacing: 0.02em; }
.pill.neutral { background: var(--line-2); color: var(--ink-2); }
.wait { font-size: 13px; color: var(--ink-3); margin-left: 6px; white-space: nowrap; }
.wait.warn { color: var(--warn); font-weight: 500; }
.wait.late { color: var(--bad); font-weight: 500; }

/* Forms */
form { margin: 0; }
label { display: block; font-weight: 500; font-size: 14px; margin: 0 0 5px; color: var(--ink-2); }
.field { margin-bottom: 14px; }
.field .hint { font-size: 13px; color: var(--ink-3); margin-top: 4px; font-weight: 400; }
input:not([type]), input[type=text], input[type=email], input[type=password], input[type=tel], input[type=date], input[type=datetime-local],
input[type=number], input[type=url], input[type=search], select, textarea {
  width: 100%; padding: 9px 12px; font: inherit; color: var(--ink);
  border: 1px solid var(--field-line); border-radius: var(--radius-sm); background: var(--field-bg);
}
input[type=search] { -webkit-appearance: none; appearance: none; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--navy); outline-offset: -1px; border-color: var(--navy); }
textarea { min-height: 80px; resize: vertical; }
.row { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; color: var(--ink); font-size: 14px; margin-bottom: 8px; }
.check input { margin-top: 3px; width: 17px; height: 17px; flex: none; accent-color: var(--navy); }
.checks { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 2px 16px; }
.checkgroup { margin-bottom: 10px; }
.checkgroup .gl { font-size: 13px; color: var(--ink-3); margin: 6px 0; }
fieldset { border: 0; padding: 0; margin: 0; }
legend { font-weight: 600; font-size: 15px; margin-bottom: 12px; padding: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; font: inherit; font-weight: 500; border-radius: var(--radius-sm); border: 1px solid var(--navy);
  background: var(--navy); color: var(--accent-ink); cursor: pointer; text-decoration: none; line-height: 1.4;
}
.btn:hover { background: var(--navy-deep); border-color: var(--navy-deep); }
.btn.secondary { background: var(--card); color: var(--navy); border-color: var(--btn-line); }
.btn.secondary:hover { background: var(--accent-soft); border-color: var(--btn-line); }
.btn.danger { background: var(--bad); border-color: var(--bad); }
.btn.danger:hover { background: var(--bad-deep); border-color: var(--bad-deep); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }
.btn:disabled:hover { background: var(--navy); border-color: var(--navy); }
.btn.secondary:disabled:hover { background: var(--card); border-color: var(--btn-line); }
.btn.big { width: 100%; padding: 13px 16px; font-size: 16px; }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.linkish { background: none; border: 0; padding: 0; font: inherit; color: var(--ink-2); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* Flash */
.flash { padding: 12px 14px; border-radius: var(--radius); margin-bottom: 16px; font-size: 14px; border: 1px solid transparent; }
.flash ul { margin: 6px 0 0; padding-left: 18px; }
.flash.ok { background: var(--ok-soft); color: var(--ok-ink); border-color: var(--ok-line); }
.flash.err { background: var(--bad-soft); color: var(--bad-ink); border-color: var(--bad-line); }
.flash.warn { background: var(--warn-soft); color: var(--warn-ink); border-color: var(--warn-line); }

/* Order header + signing */
.orderhead { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.orderhead .meta { color: var(--ink-3); font-size: 14px; }
.signbox { border: 1.5px solid var(--navy); }
.signbox .attest { background: var(--accent-soft); border-radius: var(--radius-sm); padding: 12px; margin: 12px 0; }
.tests li { margin-bottom: 4px; }
.tests { padding-left: 18px; margin: 0; }
details.start { margin: -6px 0 12px; font-size: 14px; }
details.start summary { cursor: pointer; color: var(--ink-2); padding: 4px 0; list-style: none; }
details.start summary::-webkit-details-marker { display: none; }
details.start summary::after { content: ' · change'; color: var(--navy); }
details.start[open] summary::after { content: ''; }
.startform { max-width: 520px; padding: 8px 0 4px; }
details.more { margin-top: 12px; }
details.more summary { cursor: pointer; font-weight: 500; color: var(--ink-2); padding: 6px 0; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 150px 1fr; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line-2); font-size: 14px; }
.timeline li:last-child { border-bottom: 0; }
.timeline .t { color: var(--ink-3); font-size: 13px; }
@media (max-width: 560px) { .timeline li { grid-template-columns: 1fr; gap: 0; } }

.secret { background: var(--code-bg); color: var(--code-ink); padding: 12px 14px; border-radius: var(--radius-sm); font-family: ui-monospace, Menlo, monospace; font-size: 13px; word-break: break-all; }
.qr { display: block; width: 200px; height: 200px; margin: 8px auto 12px; image-rendering: pixelated; }
.code-input { font-size: 22px !important; letter-spacing: 0.3em; text-align: center; font-variant-numeric: tabular-nums; }
.age-ok { color: var(--teal); }
.age-warn { color: var(--warn); font-weight: 500; }
.age-bad { color: var(--bad); font-weight: 500; }
.seg { display: inline-flex; background: var(--line-2); padding: 3px; border-radius: var(--radius-sm); gap: 2px; margin-bottom: 4px; }
.seg label { margin: 0; cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: inline-block; padding: 7px 18px; border-radius: var(--radius-sm); font-weight: 500; color: var(--ink-2); font-size: 15px; }
.seg input:checked + span { background: var(--card); color: var(--ink); box-shadow: 0 1px 2px rgba(22, 33, 58, 0.12); }
.seg input:focus-visible + span { outline: 2px solid var(--navy); outline-offset: 2px; }
.who-box { display: grid; gap: 10px 16px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; margin: 12px 0; }
.who-box strong { display: block; font-size: 14px; }
.who-box .small { color: var(--ink-2); }
.lbl-a { font-size: 13px; font-weight: 600; color: var(--navy); }
[hidden] { display: none !important; }
.pill.type { background: var(--line-2); color: var(--ink-2); margin-right: 6px; }
.track-tiles { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); margin-bottom: 18px; }
.track-tile { display: flex; gap: 14px; align-items: flex-start; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; text-decoration: none; color: var(--ink); }
.track-tile:hover { border-color: var(--ink-3); }
.track-tile .ico { display: grid; place-items: center; width: 40px; height: 40px; border-radius: var(--radius-sm); background: var(--accent-soft); color: var(--navy); flex: none; }
.track-tile.warn .ico { background: var(--warn-soft); color: var(--warn); }
.track-tile.bad .ico { background: var(--bad-soft); color: var(--bad); }
.track-tile .n { display: block; font-size: 28px; font-weight: 500; line-height: 1.1; letter-spacing: -0.02em; }
.track-tile.warn .n { color: var(--warn); }
.track-tile .l { display: block; font-weight: 600; }
.track-tile .s { display: block; font-size: 13px; color: var(--ink-3); }
.pill.missing { background: var(--bad-soft); color: var(--bad); text-decoration: none; margin-left: 4px; }
tr.late-row td:first-child { box-shadow: inset 3px 0 0 var(--bad); }
table.mini { margin-top: 6px; border-collapse: collapse; font-size: 13px; }
table.mini td { padding: 2px 10px 2px 0; border: 0; }
.filters { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 14px; }
.filters a { padding: 5px 10px; border-radius: var(--radius-sm); text-decoration: none; color: var(--ink-2); font-size: 14px; background: transparent; border: 1px solid transparent; }
.filters a:hover { background: var(--line-2); }
.filters a.on { background: var(--card); color: var(--ink); border-color: var(--line); font-weight: 500; }
.inline-form { display: inline; }
hr.sep { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }

/* The pipeline: the order's journey as one connected strip. Each stage is a
   step the specimen takes; the hairline between them says so, so no numbering. */
.steps-tiles { display: grid; gap: 0; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-bottom: 20px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.step-tile { display: flex; flex-direction: column; gap: 2px; padding: 16px 18px 14px; color: inherit; text-decoration: none; border-right: 1px solid var(--line-2); position: relative; min-height: 132px; }
.step-tile:last-child { border-right: 0; }
.step-tile:hover { background: var(--hover); }
.step-tile:focus-visible { background: var(--line-2); outline: 2px solid var(--navy); outline-offset: 2px; }
.step-tile .top { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0; margin-bottom: 10px; background: none; border: 0; min-height: 0; }
.step-tile .ico, .step-ico { display: grid; place-items: center; width: 30px; height: 30px; border-radius: var(--radius-sm); background: var(--accent-soft); color: var(--navy); flex: none; }
.step-tile .num { display: none; }
.step-tile .n { font-size: 28px; font-weight: 500; line-height: 1.05; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.step-tile .l { font-weight: 600; font-size: 14px; margin-top: 4px; }
.step-tile .s { font-size: 13px; color: var(--ink-3); line-height: 1.4; }
.step-tile.warn .ico { background: var(--warn-soft); color: var(--warn); }
.step-tile.warn .n { color: var(--warn); }
.step-tile.bad .ico { background: var(--bad-soft); color: var(--bad); }
.step-tile.bad .n { color: var(--bad); }
.step-head { display: flex; gap: 12px; align-items: center; }
@media (max-width: 760px) {
  .steps-tiles { grid-template-columns: 1fr 1fr; }
  .step-tile { border-bottom: 1px solid var(--line-2); min-height: 0; }
  .step-tile:nth-child(2n) { border-right: 0; }
  .step-tile:last-child, .step-tile:nth-last-child(2):nth-child(odd) { border-bottom: 0; }
}

/* Route sketch + field app */
.routemap { width: 100%; height: auto; background: var(--well); border-radius: var(--radius); border: 1px solid var(--line); }
.routemap .leg { fill: none; stroke: var(--navy); stroke-width: 3; stroke-dasharray: 6 6; stroke-linecap: round; opacity: .7; }
.routemap .start { fill: var(--ink); }
.routemap .pin circle { fill: var(--teal); stroke: var(--card); stroke-width: 3; }
.routemap .pin.stat circle, .routemap .pin.late circle { fill: var(--bad); }
.routemap .pin.issue circle { fill: var(--warn); }
.routemap .pin text { fill: var(--accent-ink); font-size: 13px; font-weight: 600; }
.route-sum { display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center; }
.route-sum .big { font-size: 22px; font-weight: 600; }
.stop { display: grid; grid-template-columns: 40px 1fr; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line-2); }
.stop:last-child { border-bottom: 0; }
.stop .badge { width: 32px; height: 32px; border-radius: 50%; background: var(--navy); color: var(--accent-ink); display: grid; place-items: center; font-weight: 600; }
.stop.stat .badge, .stop.late .badge { background: var(--bad); }
.stop.issue .badge { background: var(--warn); }
.stop .place { font-weight: 600; }
.stop .addr { color: var(--ink-2); font-size: 14px; }
.stop .meta { font-size: 13px; color: var(--ink-3); margin-top: 2px; }
.stop .orders { margin: 8px 0 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.stop .orders a { display: flex; justify-content: space-between; gap: 8px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); text-decoration: none; color: var(--ink); background: var(--card); }
.stop .acts { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.photos { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.photos img { width: 92px; height: 92px; object-fit: cover; border-radius: var(--radius-sm); border: 1px solid var(--line); }
.camera input[type=file] { padding: 14px; border: 1.5px dashed var(--navy); border-radius: var(--radius-sm); width: 100%; background: var(--accent-soft); }
.geo-note { font-size: 13px; color: var(--ink-3); }
a.back { display: inline-block; margin-bottom: 12px; text-decoration: none; font-weight: 500; font-size: 14px; color: var(--ink-2); }
a.back:hover { color: var(--navy); }
.stop .orders a span:last-child { color: var(--ink-3); align-self: center; }

/* In-app navigation */
.nav-app { display: grid; gap: 10px; }
.nav-banner { display: flex; gap: 14px; align-items: center; background: var(--navy); color: var(--accent-ink); border-radius: var(--radius); padding: 14px 16px; position: sticky; top: 0; z-index: 5; }
.nav-dist { font-size: 28px; font-weight: 600; min-width: 72px; }
.nav-text { font-size: 17px; font-weight: 600; line-height: 1.3; }
.nav-map { height: 52vh; min-height: 300px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); background: var(--well); }
.nav-nomap { padding: 24px; color: var(--ink-3); text-align: center; }
.nav-pin { width: 30px; height: 30px; border-radius: 50%; background: var(--navy); color: var(--accent-ink); font-weight: 600; display: grid; place-items: center; border: 3px solid var(--card); box-shadow: 0 2px 6px rgba(0,0,0,.25); }
.nav-pin.stat { background: var(--bad); }
.nav-stop { display: grid; grid-template-columns: 40px 1fr; gap: 12px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.nav-stop .badge { width: 32px; height: 32px; border-radius: 50%; background: var(--navy); color: var(--accent-ink); display: grid; place-items: center; font-weight: 600; }
.nav-stop.stat .badge { background: var(--bad); }
.nav-stop .place { font-weight: 600; } .nav-stop .addr { color: var(--ink-2); font-size: 14px; } .nav-stop .meta { color: var(--ink-3); font-size: 13px; }
.nav-pat { display: flex; justify-content: space-between; gap: 8px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); margin-top: 8px; text-decoration: none; color: var(--ink); }
.nav-stop .acts { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.nav-tools { display: flex; gap: 8px; flex-wrap: wrap; }
.nav-steps { margin: 0; padding: 0; list-style: none; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.nav-steps li { display: flex; justify-content: space-between; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line-2); font-size: 14px; }
.nav-steps li.on { background: var(--accent-soft); font-weight: 600; }
.nav-pat2 { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; margin-top: 8px; }
.nav-pat-h { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.nav-pat-acts { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.nav-pat-acts .btn { flex: 1 1 auto; }
.nav-panel { display: grid; gap: 8px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line-2); }
.nav-panel .camera { display: block; border: 1.5px dashed var(--navy); background: var(--accent-soft); color: var(--accent); border-radius: var(--radius-sm); padding: 12px; text-align: center; font-weight: 600; }
.nav-panel .camera input { display: block; width: 100%; margin-top: 6px; }
.nav-toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--navy); color: var(--accent-ink); padding: 10px 16px; border-radius: var(--radius-sm); z-index: 50; max-width: calc(100% - 32px); }
.nav-notes { background: var(--warn-soft); border-radius: var(--radius-sm); padding: 8px 10px; display: grid; gap: 4px; font-size: 14px; }
.nav-order dl.kv { font-size: 14px; }
.checklist { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 8px; }
.checklist li { display: grid; grid-template-columns: 24px 1fr; gap: 8px; align-items: start; font-size: 14px; }
.checklist .ic { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 600; color: var(--card); background: var(--ink-3); }
.checklist li.ok .ic { background: var(--ok); }
.checklist li.missing .ic { background: var(--bad); }
.checklist li.check .ic { background: var(--warn); }
.checklist li.na .ic { background: var(--muted-fill); }
.medicare form.row { align-items: end; }
.later-row { display: flex; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line-2); }
.later-row:last-child { border-bottom: 0; }
.label-links a { white-space: nowrap; }

/* Patients: companies, filters, bulk move */
.pill.tag { background: var(--accent-soft); color: var(--navy); font-weight: 500; margin: 0 4px 4px 0; white-space: normal; }
.ptfilters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.ptfilters > * { margin: 0; }
.ptfilters input[name="q"] { flex: 2 1 220px; }
.ptfilters select { flex: 1 1 160px; }
.bulkbar { align-items: center; margin: 0 0 8px; flex-wrap: wrap; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
.tagform { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.tagform select, .tagform input { flex: 1 1 150px; }
.inline-btn { display: inline; }
.inline-btn button { background: none; border: 0; color: var(--ink-3); cursor: pointer; padding: 0 2px; font-size: 13px; }
.movehist li { margin-bottom: 6px; }

/* Settings */
.setgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
a.setcard { display: flex; flex-direction: column; gap: 6px; text-decoration: none; color: var(--ink); margin: 0; }
a.setcard:hover { border-color: var(--ink-3); }
a.setcard h2 { margin: 0; }
.versioncard { display: flex; flex-direction: column; gap: 6px; margin: 0; }
.versioncard h2 { margin: 0; }
.setstat { font-size: 13px; margin-top: 6px; color: var(--ink-2); }
.setcta { margin-top: auto; padding-top: 12px; color: var(--navy); font-weight: 500; font-size: 14px; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.checklist2 { padding-left: 18px; margin: 6px 0 10px; }
.checklist2 li { margin-bottom: 6px; }

/* County routes */
.routegrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; margin-bottom: 14px; }
a.routecard { display: flex; flex-direction: column; gap: 8px; text-decoration: none; color: var(--ink); margin: 0; }
a.routecard:hover { border-color: var(--ink-3); }
a.routecard.warnbox { border-color: var(--warn-line); background: var(--warn-soft); }
.rc-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.rc-stats { display: flex; gap: 14px; font-size: 13px; color: var(--ink-2); }
.pill.county { background: var(--line-2); color: var(--ink-2); }
.pill.c-weber { background: var(--c1-bg); color: var(--c1-ink); }
.pill.c-davis { background: var(--c2-bg); color: var(--c2-ink); }
.pill.c-salt_lake { background: var(--c3-bg); color: var(--c3-ink); }
.pill.c-utah { background: var(--c4-bg); color: var(--c4-ink); }
.stopctl { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; align-items: center; }
.stopctl select { max-width: 220px; }
pre.hl7 { white-space: pre-wrap; word-break: break-all; font: 12px/1.5 ui-monospace, Menlo, monospace; background: var(--well); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px; max-height: 360px; overflow: auto; }
.stop.ups { background: var(--ups-soft); }
.stop.ups .badge { background: var(--ups); color: var(--ups-ink); font-size: 11px; }
.pill.ups-pill { background: var(--ups); color: var(--ups-ink); }
.dropform { margin-top: 10px; display: grid; gap: 8px; max-width: 460px; }




/* ---------- Dark theme ----------
   Follows the device (prefers-color-scheme) unless the person picks Light or Dark
   with the header toggle (stored in the "theme" cookie -> <html data-theme>).
   Only the tokens change; every component reads them. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #e8ecf2; --ink-2: #b4bcc8; --ink-3: #8a93a1; --line: #2b3240; --line-2: #222835; --bg: #12161d; --card: #191e27;
    --navy: #8fb0e8; --navy-deep: #a9c3f0; --accent: #8fb0e8; --accent-ink: #0d1a33; --accent-soft: #1e2a3f; --brand-navy: #8fb0e8; --brand-teal: #4fbdbb; --teal: #4fbdbb;
    --ok: #62c48d; --ok-soft: #16301f; --warn: #e3ac55; --warn-soft: #33270f; --bad: #f0857d; --bad-soft: #3a1b19;
    --info: #86adf0; --info-soft: #182640;
    --field-bg: #12161d; --field-line: #6f7887; --btn-line: #2b3240; --hover: #1f2531; --well: #12161d; --muted-fill: #4a5860; --bad-deep: #f4a39c;
    --ok-ink: #b9ebcd; --ok-line: #24563a; --bad-ink: #ffc7c2; --bad-line: #6a2b27; --warn-ink: #f5d49a; --warn-line: #5e4518;
    --code-bg: #0c0f14; --ups: #e0b26a; --ups-ink: #1a1408; --ups-soft: #2c2312;
    --c1-bg: #1b2b44; --c1-ink: #9cc0f2; --c2-bg: #16301f; --c2-ink: #8fd4a8; --c3-bg: #3a2116; --c3-ink: #f0b08f; --c4-bg: #2a1f3d; --c4-ink: #c9aef0;
    color-scheme: dark;
  }
  :root:not([data-theme="light"]) .brand .logo { filter: invert(1) hue-rotate(180deg) brightness(1.15); }
}
:root[data-theme="dark"] {
    --ink: #e8ecf2; --ink-2: #b4bcc8; --ink-3: #8a93a1; --line: #2b3240; --line-2: #222835; --bg: #12161d; --card: #191e27;
    --navy: #8fb0e8; --navy-deep: #a9c3f0; --accent: #8fb0e8; --accent-ink: #0d1a33; --accent-soft: #1e2a3f; --brand-navy: #8fb0e8; --brand-teal: #4fbdbb; --teal: #4fbdbb;
    --ok: #62c48d; --ok-soft: #16301f; --warn: #e3ac55; --warn-soft: #33270f; --bad: #f0857d; --bad-soft: #3a1b19;
    --info: #86adf0; --info-soft: #182640;
    --field-bg: #12161d; --field-line: #6f7887; --btn-line: #2b3240; --hover: #1f2531; --well: #12161d; --muted-fill: #4a5860; --bad-deep: #f4a39c;
    --ok-ink: #b9ebcd; --ok-line: #24563a; --bad-ink: #ffc7c2; --bad-line: #6a2b27; --warn-ink: #f5d49a; --warn-line: #5e4518;
    --code-bg: #0c0f14; --ups: #e0b26a; --ups-ink: #1a1408; --ups-soft: #2c2312;
    --c1-bg: #1b2b44; --c1-ink: #9cc0f2; --c2-bg: #16301f; --c2-ink: #8fd4a8; --c3-bg: #3a2116; --c3-ink: #f0b08f; --c4-bg: #2a1f3d; --c4-ink: #c9aef0;
    color-scheme: dark;
}
:root[data-theme="dark"] .brand .logo { filter: invert(1) hue-rotate(180deg) brightness(1.15); }


/* NIIMBOT label printing */
.linkbtn { background: none; border: 0; padding: 0; font: inherit; color: var(--navy); text-decoration: underline; cursor: pointer; }
dialog.niim { border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; max-width: 560px; width: calc(100% - 32px); background: var(--card); color: var(--ink); }
dialog.niim::backdrop { background: rgba(0, 0, 0, 0.45); }
dialog.niim h3 { margin: 0 0 10px; }
.niim-row { display: flex; flex-wrap: wrap; gap: 12px; }
.niim-row label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.niim-preview { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.niim-preview canvas { width: 160px; height: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--paper); image-rendering: pixelated; }
.niim-status.bad { color: var(--bad); }
.niim-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.nav-traffic { color: var(--warn); font-weight: 600; }
.grouphead { margin: 22px 0 8px; font-size: 15px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3); }
.field { position: relative; }
.icd-list { position: absolute; z-index: 30; left: 0; right: 0; margin: 2px 0 0; padding: 4px 0; list-style: none; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm); box-shadow: 0 6px 18px rgba(0,0,0,.12); max-height: 280px; overflow: auto; }
.icd-list li { padding: 7px 12px; cursor: pointer; font-size: 14px; }
.icd-list li strong { margin-right: 6px; }
.icd-list li.on, .icd-list li:hover { background: var(--line-2); }

/* Route schedule grid */
.sched-wrap { overflow-x: auto; }
.sched th, .sched td { vertical-align: top; }
.sched td { min-width: 150px; }
.sched-pick { display: block; margin-bottom: 6px; }
.sched-pick span { display: block; font-size: 12px; color: var(--ink-3); }
.sched-pick select { width: 100%; font-size: 13px; padding: 4px 6px; }
.sched th.today, .sched td.today { background: var(--accent-soft); }
.sched td.sched-gap { background: var(--warn-soft); }
.sched td.sched-changed { box-shadow: inset 3px 0 0 var(--accent); }
.sched .wkend { background: var(--line-2); }
.staffsched td select { width: 100%; min-width: 130px; font-size: 13px; padding: 4px 6px; }
.sched td.sched-on { background: var(--accent-soft); }
.sched-gaps { padding: 10px 14px; border-top: 1px solid var(--line); color: var(--warn); }

/* "Other" tests: checkbox plus what was ordered */
.other-tests { display: flex; align-items: center; gap: 10px; margin: 6px 0 14px; flex-wrap: wrap; }
.other-tests .check { margin: 0; }
.other-tests input[name="other_tests"] { flex: 1; min-width: 200px; }

/* Order list search and filters */
.orderfilter { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 0 14px; }
.orderfilter input[type="search"] { flex: 1 1 260px; min-width: 200px; }
.orderfilter select { flex: 1 1 160px; width: auto; max-width: 240px; }
.orderfilter input[type="search"], .orderfilter select, .orderfilter .btn { height: 40px; }
table.sortable thead th { cursor: pointer; user-select: none; white-space: nowrap; }
table.sortable thead th:hover { color: var(--ink); }
table.sortable thead th[aria-sort="ascending"]::after { content: " \25B2"; font-size: 11px; }
table.sortable thead th[aria-sort="descending"]::after { content: " \25BC"; font-size: 11px; }
.tablefilter { margin-top: 4px; }
.tablefilter input[type="search"] { flex: 1 1 260px; }

/* Collapsible organization groups (Users) */
details.orggroup > summary { display: flex; align-items: center; gap: 12px; cursor: pointer; list-style: none; padding: 4px 0; }
details.orggroup > summary::-webkit-details-marker { display: none; }
details.orggroup > summary::before { content: '▸'; color: var(--ink-2); width: 12px; transition: transform .15s; }
details.orggroup[open] > summary::before { transform: rotate(90deg); }
details.orggroup[open] > summary { margin-bottom: 10px; }
details.orggroup .grouptitle { font-size: 17px; font-weight: 600; }
details.orggroup { position: relative; }
details.orggroup > summary { padding: 8px 220px 8px 16px; }
details.orggroup > .groupactions { position: absolute; top: 6px; right: 12px; height: 36px; display: flex; align-items: center; gap: 12px; }
@media (max-width: 760px) { details.orggroup > summary { padding: 8px 16px; } details.orggroup > .groupactions { position: static; height: auto; margin: 0 0 10px 40px; } }
.filters .groupall { margin-left: auto; display: flex; gap: 8px; }
.radios { display: flex; gap: 6px 18px; flex-wrap: wrap; }
.updates td { padding: 6px 8px; } .updates select { min-width: 150px; }
/* On/off switch */
.switch { position: relative; display: inline-block; width: 44px; height: 24px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch span { position: absolute; inset: 0; border-radius: var(--radius-lg); background: var(--line); transition: background .15s; pointer-events: none; }
.switch span::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--card); transition: transform .15s; }
.switch input:checked + span { background: var(--navy); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:focus-visible + span { outline: 2px solid var(--navy); outline-offset: 2px; }
.automations td { padding: 10px 8px; }
code.wrap { word-break: break-all; }
.pushsign { display:flex; align-items:center; justify-content:space-between; gap:12px; flex-wrap:wrap; }
.portalscreen { border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; margin: 8px 0; background: var(--paper); }
.portalscreen img { display: block; width: 100%; height: auto; cursor: pointer; }
.portaltype { gap: 8px; align-items: center; }
.portaltype input { flex: 1; }
.portalcode { align-items: flex-end; gap: 10px; } .portalcode .field { margin-bottom: 0; }

/* patient conversation */
.convo { display: flex; flex-direction: column; gap: 10px; overflow-y: auto; padding: 4px 2px 12px;
  /* Same size for every conversation: fills the window, the send box stays at the bottom. */
  height: calc(100vh - 380px); height: calc(100dvh - 380px); min-height: 320px; }
.convo > .muted:only-child { margin: auto; }
.convo > .msg:first-child { margin-top: auto; }
.convo .msg { display: flex; flex-direction: column; max-width: 78%; }
.convo .msg.inbound { align-self: flex-start; }
.convo .msg.outbound { align-self: flex-end; align-items: flex-end; }
.convo .bubble { padding: 9px 13px; border-radius: var(--radius-lg); white-space: pre-wrap; word-break: break-word; line-height: 1.4; }
.convo .inbound .bubble { background: var(--line-2); color: var(--ink); border-bottom-left-radius: 4px; }
.convo .outbound .bubble { background: var(--navy); color: var(--accent-ink); border-bottom-right-radius: 4px; }
.convo .outbound .bubble a { color: var(--accent-ink); }
.convo .meta { font-size: 12px; color: var(--ink-3); margin-top: 3px; }
.convo-send { display: flex; gap: 10px; align-items: flex-end; border-top: 1px solid var(--line); padding-top: 12px; }
.convo-send textarea { flex: 1; }

/* missed-visit signature */
.sigpad { display: block; width: 100%; height: 180px; background: var(--paper); border: 1px dashed var(--ink-3); border-radius: var(--radius-sm); touch-action: none; }
.sigview { margin: 8px 0; }
.sigview img { max-width: 320px; width: 100%; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.printbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding-top: 12px; padding-bottom: 12px; }
.printbar strong { margin-right: 4px; }
.daypick { display: flex; flex-wrap: wrap; gap: 4px 14px; }
.daypick .check { margin: 0; }
.navbadge { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 2px; border-radius: var(--radius); background: var(--bad); color: var(--accent-ink); font-size: 11px; font-weight: 600; line-height: 18px; text-align: center; vertical-align: 2px; }
.convo .msg.new .bubble { box-shadow: 0 0 0 2px var(--bad); }
.ackform { display: flex; gap: 6px; align-items: center; }
.ackform input { width: 140px; padding: 6px 8px; font-size: 13px; }

/* field: master tracking */
.fieldmap { height: 420px; border-radius: var(--radius-sm); overflow: hidden; }
.maplegend { display: flex; flex-wrap: wrap; gap: 6px 16px; padding: 10px 4px 2px; }
.maplegend i { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; }
.maplegend i.done, .fm-visit.done { background: var(--ok); }
.maplegend i.miss, .fm-visit.miss { background: var(--bad); }
.fm-visit { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--map-halo); box-shadow: 0 1px 3px rgba(0,0,0,.4); }
.fm-me { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--map-halo); color: var(--map-halo); font: 600 11px/24px sans-serif; text-align: center; box-shadow: 0 1px 4px rgba(0,0,0,.4); }
.stats .stat .n { font-size: 28px; font-weight: 600; }
.fieldmap { height: 560px; }
.fm-stop { width: 22px; height: 22px; border-radius: 50%; background: var(--map-halo); border: 3px solid var(--map-pin); color: var(--map-ink); font: 600 11px/16px sans-serif; text-align: center; box-shadow: 0 1px 3px rgba(0,0,0,.35); }
.fm-stop.stat { background: var(--map-stat); }
.fm-me { width: 32px; height: 32px; font-size: 12px; line-height: 28px; z-index: 5; animation: fmpulse 2s infinite; }
.fm-me.stale { animation: none; opacity: .55; filter: grayscale(.6); }
@keyframes fmpulse { 0% { box-shadow: 0 0 0 0 rgba(31,111,235,.55); } 70% { box-shadow: 0 0 0 12px rgba(31,111,235,0); } 100% { box-shadow: 0 0 0 0 rgba(31,111,235,0); } }
.maplegend i.sq { border-radius: var(--radius-sm); }
.maplegend i.me { background: var(--map-pin); box-shadow: 0 0 0 3px rgba(31,111,235,.3); }
@media (max-width: 700px) { .fieldmap { height: 420px; } }
.fieldmap { position: relative; }
.fm-styles { position: absolute; top: 10px; left: 10px; z-index: 2; display: flex; background: var(--map-halo); border-radius: var(--radius); box-shadow: 0 1px 4px rgba(0,0,0,.3); overflow: hidden; }
.fm-styles button { border: 0; background: var(--map-halo); color: var(--map-ink); padding: 7px 12px; font: 600 13px/1 inherit; cursor: pointer; }
.fm-styles button.on { background: var(--map-ink); color: var(--map-halo); }

/* Order lifecycle: four tracks, tests, chain of custody */
.tracks { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
.track { border: 1px solid var(--line); border-top: 4px solid var(--line); border-radius: var(--radius); padding: 10px 12px; background: var(--card); }
.track-name { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-3); }
.track-label { font-weight: 600; margin-top: 2px; }
.track-at { font-size: 13px; color: var(--ink-3); margin-top: 2px; }
.track.t-done { border-top-color: var(--ok); }
.track.t-active { border-top-color: var(--info); }
.track.t-warn { border-top-color: var(--warn); background: var(--warn-soft); }
.track.t-bad { border-top-color: var(--bad); background: var(--bad-soft); }
.track.t-bad .track-label { color: var(--bad); }
.tubes { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 10px; }
.tube { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.tube-head { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.tube-head .pill { margin-left: auto; }
ul.custody { list-style: none; margin: 8px 0; padding: 0; font-size: 13px; }
ul.custody li { padding: 3px 0; border-top: 1px solid var(--line-2); }
ul.custody .t { color: var(--ink-3); margin-right: 4px; }
form.inline { display: inline-block; margin: 0 6px 0 0; }
.btn.small { padding: 5px 10px; font-size: 13px; }
details.reject { display: inline-block; font-size: 13px; }
details.reject summary { cursor: pointer; color: var(--bad); }
span.label { display: block; font-weight: 500; margin-bottom: 4px; }
@media (max-width: 720px) { .tracks { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Work queue */
a.stat { text-decoration: none; color: inherit; }
a.stat:hover { border-color: var(--ink-3); }
.due { display: inline-block; font-size: 13px; font-weight: 600; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.due.ok { background: var(--line-2); color: var(--ink-2); }
.due.warn { background: var(--warn-soft); color: var(--warn); }
.due.bad { background: var(--bad-soft); color: var(--bad); }
table.worklist tr.esc td:first-child { box-shadow: inset 3px 0 0 var(--bad); }
.actions.wrap { flex-wrap: wrap; }
ul.custody .note { margin: 4px 0 2px; padding: 6px 10px; background: var(--line-2); border-radius: var(--radius-sm); white-space: pre-wrap; }
.rules td input[type=number] { width: 90px; }
.opentasks li { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.mt { margin-top: 16px; }
.tubes-need { margin: 0 0 10px; font-size: 15px; }

/* Tube scanning at the stop */
.scanbox h3 { margin: 14px 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-3); }
.check.big { font-size: 16px; padding: 6px 0; }
.check.big input { width: 20px; height: 20px; }
ul.scanlist { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 6px; }
ul.scanlist li { display: flex; justify-content: space-between; gap: 8px; align-items: center; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--line-2); }
ul.scanlist li.done { background: var(--ok-soft); color: var(--ok); }
ul.scanlist .code { font-family: ui-monospace, monospace; font-size: 13px; }
.scanmsg { min-height: 0; margin: 6px 0 10px; padding: 0; border-radius: var(--radius-sm); }
.scanmsg.ok, .scanmsg.bad { padding: 10px 12px; }
.scanmsg.ok { background: var(--ok-soft); color: var(--ok); }
.scanmsg.bad { background: var(--bad-soft); color: var(--bad); border: 2px solid var(--bad); }
.scanner { position: fixed; inset: 0; z-index: 50; background: var(--scrim); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; }
.scanner[hidden] { display: none; }
.scanner video { width: 100%; max-height: 80vh; object-fit: cover; }
.scanframe { position: absolute; top: 30%; left: 10%; right: 10%; height: 25%; border: 3px solid var(--map-halo); border-radius: var(--radius-lg); pointer-events: none; }
.row.tight { display: flex; gap: 8px; }
.row.tight input { flex: 1; }
button[disabled] { opacity: 0.5; cursor: not-allowed; }

/* Dispatch board */
ul.dlist { list-style: none; margin: 0; padding: 0; }
ul.dlist li { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 0; border-top: 1px solid var(--line-2); }
ul.dlist li:first-child { border-top: 0; }
ul.dlist li.stat { box-shadow: inset 3px 0 0 var(--bad); padding-left: 10px; }
ul.dlist .fit { color: var(--ok); font-weight: 600; margin-top: 2px; }
form.assignform { display: flex; gap: 6px; align-items: center; }
.bar { height: 6px; background: var(--line-2); border-radius: var(--radius-sm); margin-top: 6px; overflow: hidden; }
.bar i { display: block; height: 6px; background: var(--ok); width: 0; }

/* Facility roster and provider review */
.needbox { background: var(--warn-soft); border-color: var(--warn); }
.needbox h2 { color: var(--warn); }
.roster { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; }
.winhead { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.tomorrow { display: flex; flex-wrap: wrap; gap: 24px; }
tr.crit-row td:first-child { box-shadow: inset 3px 0 0 var(--bad); }
details.signall summary { cursor: pointer; }

/* ⌘K search */
.searchbtn { display: inline-flex; align-items: center; background: transparent; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 5px 7px; color: var(--ink-2); cursor: pointer; font: inherit; font-size: 13px; }
.searchbtn kbd { font-family: inherit; font-size: 11px; color: var(--ink-3); margin-left: 4px; }
.cmdk { position: fixed; inset: 0; z-index: 60; background: rgba(15, 23, 42, 0.45); display: flex; justify-content: center; align-items: flex-start; padding: 12vh 16px 16px; }
.cmdk[hidden] { display: none; }
.cmdk-box { width: 100%; max-width: 620px; background: var(--card); border-radius: var(--radius); box-shadow: 0 20px 60px rgba(0,0,0,0.3); overflow: hidden; }
.cmdk-box input { width: 100%; border: 0; border-bottom: 1px solid var(--line); padding: 16px 18px; font-size: 17px; background: transparent; color: var(--ink); outline: none; }
ul.cmdk-list { list-style: none; margin: 0; padding: 6px; max-height: 50vh; overflow: auto; }
ul.cmdk-list li a { display: flex; flex-direction: column; padding: 10px 12px; border-radius: var(--radius-sm); text-decoration: none; color: var(--ink); }
ul.cmdk-list li a span { font-size: 13px; color: var(--ink-3); }
ul.cmdk-list li.on a, ul.cmdk-list li a:hover { background: var(--line-2); }
ul.cmdk-list li.none { padding: 12px; color: var(--ink-3); }
form.recollect { margin: 8px 0 12px; }

/* Phase 5: connections, duplicates, metrics */
pre.payload { background: var(--line-2); padding: 12px; border-radius: var(--radius-sm); overflow: auto; max-height: 420px; font-size: 13px; }
ol.steps { margin: 0; padding-left: 20px; line-height: 1.7; }
.pmgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 10px 0; }
.pm { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; }
.btn.warnbtn { background: var(--warn-soft); color: var(--warn); border: 1px solid var(--warn); }
.bars .barrow { display: grid; grid-template-columns: 190px 1fr 56px; gap: 10px; align-items: center; padding: 6px 0; font-size: 14px; }
.bars .bar { height: 12px; margin: 0; }
.bars .bar i { height: 12px; background: var(--info); }
.metricsf select { width: auto; }
tr.warnrow td { background: var(--warn-soft); }
@media (max-width: 720px) { .pmgrid { grid-template-columns: 1fr; } .bars .barrow { grid-template-columns: 1fr 60px; } .bars .barrow .bar { grid-column: 1 / -1; } }

/* More menu in the top bar */
.navmore { position: relative; flex: none; align-self: stretch; display: flex; margin-left: -20px; }
.navmore summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 4px; padding: 0 12px; font-size: 14px; color: var(--ink-2); border-bottom: 2px solid transparent; height: 100%; }
.navmore summary::-webkit-details-marker { display: none; }
.navmore summary::after { content: ''; width: 6px; height: 6px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(45deg) translateY(-2px); margin-left: 4px; }
.navmore summary:hover { color: var(--ink); }
.navmore summary.on { color: var(--navy); border-bottom-color: var(--navy); font-weight: 600; }
.navmenu { position: absolute; top: 100%; left: 0; z-index: 40; min-width: 200px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm); box-shadow: 0 10px 30px rgba(15, 23, 42, 0.14); padding: 6px; display: flex; flex-direction: column; }
.navmenu a { padding: 9px 12px; border-radius: var(--radius-sm); color: var(--ink); text-decoration: none; font-size: 14px; display: flex; justify-content: space-between; gap: 10px; }
.navmenu a:hover { background: var(--line-2); }
.navmenu a.on { font-weight: 600; color: var(--navy); background: var(--line-2); }
.nav a.phone-only { display: none; }
@media (max-width: 1240px) { .top { gap: 18px; } .nav a { padding: 0 8px; } .navmore { margin-left: -12px; } .navmore summary { padding: 0 8px; } .who .themebtn { display: none; } }
@media (max-width: 1060px) { .who > a[title="Account"] { display: none; } }
@media (max-width: 720px) { .navmore { display: none; } .nav a.phone-only { display: flex; } }

/* Spacing utilities (the security policy blocks inline style attributes). */
.m-0 { margin: 0; }
.mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; } .mb-12 { margin-bottom: 12px; } .mb-16 { margin-bottom: 16px; }
.my-8 { margin-top: 8px; margin-bottom: 8px; } .my-12 { margin-top: 12px; margin-bottom: 12px; }
.self-center { align-self: center; }
.gap-18 { flex: 0 0 18px; }
.pre-wrap { white-space: pre-wrap; }
.w-6em { width: 6em; }
.btn.block { display: flex; width: 100%; justify-content: center; }
.card.soft { background: var(--accent-soft); border: 0; }

/* Phones: 16px fields so iOS doesn't zoom in on focus. */
@media (max-width: 760px) {
  input:not([type=checkbox]):not([type=radio]):not(.code-input), select, textarea { font-size: 16px !important; }
}

/* Confirmation dialog (replaces the browser's confirm box). */
dialog.confirm { border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 20px; width: min(420px, calc(100% - 32px)); background: var(--card); color: var(--ink); }
dialog.confirm::backdrop { background: rgba(10, 16, 28, 0.45); }
dialog.confirm p { margin: 0 0 16px; font-size: 15px; }
dialog.confirm .actions { display: flex; justify-content: flex-end; gap: 8px; margin: 0; }
@media (max-width: 760px) { dialog.confirm { margin: auto auto 16px; } dialog.confirm .actions .btn { flex: 1; justify-content: center; } }

/* Line icons (src/views/icons.js): text-sized, drawn in the text colour. */
.ico { width: 1em; height: 1em; display: inline-block; vertical-align: -0.14em; flex-shrink: 0; }
.btn .ico { width: 1.1em; height: 1.1em; }
label.camera { display: inline-flex; align-items: center; gap: 8px; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }

/* Keyboard: skip straight to the page content. */
.skip { position: absolute; left: 12px; top: -48px; z-index: 100; background: var(--card); color: var(--navy); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 12px; }
.skip:focus { top: 8px; }
main:focus { outline: none; }

/* Phones: compact stat strips, tighter empty states, full-width filters, and a fade
   on the section strip so it reads as swipeable. */
@media (max-width: 760px) {
  .stats, .grid.three.stats { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .stats .stat { padding: 10px 12px; margin: 0; }
  .stats .stat .n { font-size: 22px; }
  .stats .stat .l, .stats .stat .small { font-size: 12px; line-height: 1.3; }
  .empty { padding: 16px; }
  .orderfilter select, .orderfilter input[type="search"] { flex: 1 1 100%; width: 100%; max-width: none; min-width: 0; }
  .nav { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 32px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 32px), transparent); }
}
@media (max-width: 760px) {
  table.list td[data-label]::before { white-space: normal; line-height: 1.3; }
  .setgrid { gap: 8px; }
  a.setcard { padding: 14px 16px; gap: 4px; }
  .filters select { flex: 1 1 100%; max-width: none; }
}
/* File pickers: the button matches the secondary button instead of the browser default. */
input[type=file] { font: inherit; font-size: 14px; color: var(--ink-2); max-width: 100%; }
input[type=file]::file-selector-button { font: inherit; font-weight: 500; color: var(--navy); background: var(--card); border: 1px solid var(--btn-line); border-radius: var(--radius-sm); padding: 7px 12px; margin-right: 10px; cursor: pointer; }
input[type=file]::file-selector-button:hover { background: var(--accent-soft); }
@media (max-width: 760px) { table.list td .pill { white-space: normal; } }

/* Offline field screen */
.offline-status { color: var(--ink-2); }
.offline-app .stopcard { padding: 16px; }
.offline-app .stop { display: flex; gap: 12px; }
.offline-app .grow { flex: 1; min-width: 0; }
.routeorder { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); color: var(--ink); text-decoration: none; }
.routeorder:hover { background: var(--hover); }
.block { display: block; }
.steplabel { font-size: 12px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-3); margin: 12px 0 6px; }
.stoph { font-size: 22px; margin: 8px 0 2px; }
.nav-toast.bad { background: var(--bad); }
.off-lock { position: fixed; inset: 0; z-index: 90; background: var(--bg); display: grid; place-items: center; text-align: center; cursor: pointer; }
.flash.info { background: var(--info-soft); color: var(--ink); border-color: var(--line); }
.routeorder { flex-wrap: wrap; }
.routeorder > span:first-child { flex: 1 1 180px; min-width: 0; }
.routeorder .pill { flex-shrink: 0; }

/* Patient portal */
main.narrow:has(.porder), main.narrow:has(.pday) { max-width: 640px; }
.psec { font-size: 13px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-3); margin: 20px 0 8px; }
.porder-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.porder-head h2 { margin: 0 0 2px; font-size: 16px; }
.pvisit { margin: 12px 0; font-size: 16px; }
.porder h3 { margin: 16px 0 8px; }
.presult { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 10px; }
.presult-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 6px; }
.ptable { margin: 6px 0 8px; }
.pday { border: 0; padding: 0; margin: 0 0 14px; }
.pday legend { font-weight: 600; margin-bottom: 6px; }
.pwindows { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }
.pwin { display: block; margin: 0; }
.pwin input { position: absolute; opacity: 0; }
.pwin span { display: block; text-align: center; padding: 12px 8px; border: 1px solid var(--btn-line); border-radius: var(--radius-sm); background: var(--card); color: var(--ink); font-weight: 500; cursor: pointer; }
.pwin input:checked + span { border-color: var(--navy); background: var(--accent-soft); color: var(--navy); box-shadow: inset 0 0 0 1px var(--navy); }
.pwin input:focus-visible + span { outline: 2px solid var(--navy); outline-offset: 2px; }
.pill.info { background: var(--info-soft); color: var(--info); }
