/* NBC Practice Manager — component styles. Desktop-first clinical UI. */

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  font-size: 13px;
}
a { color: inherit; text-decoration: none; }
.mono { font-family: var(--font-mono); }
.muted { color: var(--ink-4); }
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-thumb { background: #C7D2E0; border-radius: 6px; border: 3px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }
@keyframes nbcpulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

/* ===== top bar ===== */
.topbar {
  position: sticky; top: 0; z-index: 30; height: 56px;
  display: flex; align-items: center; padding: 0 20px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 2px rgba(16, 36, 59, .03);
}
.brand {
  display: flex; align-items: center; gap: 11px;
  padding-right: 18px; margin-right: 8px; border-right: 1px solid #E6EBF2;
}
.brand img { height: 30px; width: auto; display: block; }
.brand .b-title { font-size: 13px; font-weight: 600; color: var(--nbc-navy); letter-spacing: .01em; white-space: nowrap; line-height: 1.05; }
.brand .b-sub { font-size: 10px; font-weight: 500; color: var(--ink-4); letter-spacing: .05em; text-transform: uppercase; white-space: nowrap; line-height: 1.05; }

.mainnav { display: flex; align-items: stretch; gap: 1px; height: 100%; }
.mainnav a {
  position: relative; height: 100%; display: flex; align-items: center; gap: 7px;
  padding: 0 15px; font-size: 13px; font-weight: 500; color: var(--ink-3);
  transition: color .12s, background .12s;
}
.mainnav a:hover { background: #F4F8FC; }
.mainnav a.active { color: var(--nbc-navy); font-weight: 600; }
.mainnav a.active::after {
  content: ""; position: absolute; left: 8px; right: 8px; bottom: 0;
  height: 2.5px; border-radius: 3px 3px 0 0; background: var(--nbc-blue);
}
.nav-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 17px; padding: 0 5px; border-radius: 9px;
  background: var(--surface-3); color: var(--ink-4); font-size: 11px; font-weight: 600;
}
.mainnav a.active .nav-badge { background: var(--run-bg); color: var(--run-fg); }
.nav-badge.err { background: var(--err-bg); color: var(--err-fg); }

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.searchbox {
  display: flex; align-items: center; gap: 8px; width: 230px; height: 34px;
  padding: 0 12px; background: var(--surface-3); border: 1px solid #E2E8F0; border-radius: var(--r-ctl);
}
.searchbox input { border: none; background: transparent; outline: none; font-family: inherit; font-size: 12.5px; color: var(--ink); width: 100%; }
.searchbox .ico { width: 13px; height: 13px; border: 1.6px solid #97A4B8; border-radius: 50%; flex: none; position: relative; }
.searchbox .ico::after { content: ""; position: absolute; right: -3px; bottom: -3px; width: 5px; height: 1.6px; background: #97A4B8; transform: rotate(45deg); }
.topbar-divider { width: 1px; height: 26px; background: #E6EBF2; }
.userchip { display: flex; align-items: center; gap: 9px; }
.userchip .avatar { width: 31px; height: 31px; border-radius: 50%; background: var(--nbc-navy); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; }
.userchip .u-name { font-size: 12.5px; font-weight: 600; color: var(--ink); line-height: 1.18; }
.userchip .u-role { font-size: 10.5px; color: var(--ink-4); line-height: 1.18; }

/* ===== layout ===== */
.main { padding: 22px 24px 60px; max-width: 1340px; margin: 0 auto; }
.page-head { margin-bottom: 15px; }
.page-head h1 { font-size: 19px; font-weight: 600; color: var(--ink); margin: 0 0 2px; }
.page-head p { margin: 0; font-size: 12.5px; color: var(--ink-4); }
.row-between { display: flex; align-items: flex-end; justify-content: space-between; }

/* ===== cards & tables ===== */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); box-shadow: var(--shadow-card); overflow: hidden; }
/* `.card` clips to keep the table's rounded corners, which also clips any
   popover opened from a row. Opted in per card rather than changed globally,
   so only the queues that need an escaping popover give up corner clipping. */
.card.card-popover { overflow: visible; }
.card-head { display: flex; align-items: center; justify-content: space-between; padding: 13px 16px; border-bottom: 1px solid var(--border-2); }
.card-head h2 { font-size: 13px; font-weight: 600; color: var(--ink); margin: 0; letter-spacing: .01em; }
.card-body { padding: 14px 16px; }
.card-note { font-family: var(--font-mono); font-size: 11.5px; color: var(--ink-4); }

table.grid { width: 100%; border-collapse: collapse; font-size: 13px; }
table.grid thead tr { background: var(--surface-2); text-align: left; }
table.grid th { padding: 9px 12px; font-size: 10.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-4); }
table.grid tbody tr { border-top: 1px solid var(--border-2); }
table.grid td { padding: 11px 12px; color: var(--ink-2); vertical-align: top; }
table.grid tr.clickable { cursor: pointer; }
table.grid tr.clickable:hover { background: #F5F9FE; }

/* Results card: the abnormal tally and the per-row marker are the whole point of
   the card — what was tested, and is any of it abnormal — so give abnormal rows a
   standing accent rather than relying on spotting a badge in a column of badges. */
.results-tally { padding: 12px 16px 0; font-size: 13px; color: var(--ink-2); display: flex; align-items: center; gap: 8px; }

/* The model's stated reason for its proposal, under the clinical summary. Muted:
   it is context for the clinician's decision, not a finding competing with one. */
.triage-why { display: flex; gap: 8px; align-items: baseline; margin: 8px 0 12px; padding: 8px 10px;
  background: var(--surface-2); border-radius: var(--r-input); font-size: 12.5px; line-height: 1.45; color: var(--ink-3); }
.triage-why .why-tag { flex: none; font-family: var(--font-mono); font-size: 10.5px; font-weight: 600;
  letter-spacing: .06em; text-transform: uppercase; color: var(--ink-4); padding-top: 1px; }
table.grid.results-grid tr.row-abnormal { background: var(--asap-bg); }
table.grid.results-grid tr.row-abnormal td:first-child { box-shadow: inset 3px 0 0 var(--urg-asap); }
.t-primary { font-weight: 600; color: var(--ink); }
.t-muted { font-size: 11.5px; color: var(--ink-4); }
.chev { color: var(--ink-6); font-size: 18px; text-align: center; }

/* ===== badges & pills ===== */
.urg { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 20px; font-size: 11.5px; font-weight: 600; }
.urg .dot { width: 7px; height: 7px; border-radius: 50%; }
.urg.asap    { background: var(--asap-bg); color: var(--asap-fg); }
.urg.asap .dot    { background: var(--urg-asap); }
.urg.soon    { background: var(--soon-bg); color: var(--soon-fg); }
.urg.soon .dot    { background: var(--urg-soon); }
.urg.routine { background: var(--rout-bg); color: var(--rout-fg); }
.urg.routine .dot { background: var(--urg-routine); }
.urg.none { background: var(--surface-3); color: var(--ink-4); }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 5px; font-size: 11px; font-weight: 600; }
.pill .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.ok   { background: var(--ok-bg);   color: var(--ok-fg); }
.pill.run  { background: var(--run-bg);  color: var(--run-fg); }
.pill.warn { background: var(--warn-bg); color: var(--warn-fg); }
.pill.err  { background: var(--err-bg);  color: var(--err-fg); }
.pill.pend { background: var(--pend-bg); color: var(--pend-fg); }
.pill.muted { background: var(--pend-bg); color: var(--pend-fg); }
/* A date inside a status pill: present but subordinate to the status word,
   which is what the eye scans for. Slightly lighter weight and a touch of
   transparency rather than a second colour, so the pill still reads as one
   object. */
.pill .pill-date { font-weight: 500; opacity: .72; letter-spacing: .1px; }

.tag { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 20px; font-size: 11.5px; font-weight: 600; }
.tag.flag { background: var(--flag-bg); color: var(--flag-fg); }
.tag.clear { background: var(--ok-bg); color: var(--ok-fg); }

.flag-dot { display: inline-flex; align-items: center; justify-content: center; width: 19px; height: 19px; border-radius: 50%; background: var(--flag-bg); color: var(--flag-fg); font-size: 12px; font-weight: 700; font-family: var(--font-mono); }
.flag-dot.sm { width: 15px; height: 15px; font-size: 10px; }

/* Inline "needs checking" marker on a details-form field label (validator flag). */
.field-flag { display: inline-flex; align-items: center; gap: 3px; margin-left: 6px; padding: 1px 6px; border-radius: 999px; background: var(--flag-bg); color: var(--flag-fg); font-size: 10.5px; font-weight: 700; font-family: var(--font-mono); letter-spacing: .02em; vertical-align: middle; text-transform: uppercase; cursor: help; }

/* ===== buttons ===== */
.btn { font-family: inherit; cursor: pointer; border-radius: var(--r-ctl); font-size: 13px; font-weight: 600; padding: 10px 20px; border: none; transition: background .12s, color .12s, border-color .12s; }
.btn-primary { background: var(--nbc-action); color: #fff; }
.btn-primary:not(:disabled):hover { background: var(--nbc-action-hover); }
.btn-secondary { background: var(--surface); color: var(--nbc-navy); border: 1px solid var(--border); font-weight: 500; }
.btn-secondary:not(:disabled):hover { background: #EAF1FB; }
.btn-danger { background: var(--surface); color: var(--danger-fg); border: 1px solid var(--danger-border); font-weight: 500; }
.btn-danger:not(:disabled):hover { background: var(--danger-bg-hover); border-color: var(--danger-border-hover); }
/* A gated control must LOOK gated: without this a disabled button keeps its full
   brand colour and pointer cursor, so the click is silently ignored rather than
   loudly refused — worse than the 409 the status gating replaced. */
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-sm { font-size: 11.5px; font-weight: 500; padding: 5px 11px; border-radius: var(--r-input); }
.btn-xs { font-size: 11px; font-weight: 500; padding: 5px 10px; border-radius: 6px; }
.btn-link { background: transparent; border: none; cursor: pointer; font-family: inherit; color: var(--ink-4); padding: 0; }
.btn-link:hover { color: var(--nbc-navy); }
.link-blue { color: var(--nbc-action); font-weight: 500; }

/* ===== forms ===== */
.lbl { display: block; font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-4); margin: 0 0 5px; }
.sel, select.sel {
  width: 100%; font-family: inherit; font-size: 13px; color: var(--ink);
  padding: 8px 32px 8px 11px;
  border: 1px solid var(--border); border-radius: var(--r-input);
  background-color: var(--surface);
  -webkit-appearance: none; -moz-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none' stroke='%238593A8' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 4.5 6 7.5 9 4.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center;
  cursor: pointer; transition: border-color .12s ease, box-shadow .12s ease;
}
.sel:hover, select.sel:hover { border-color: var(--nbc-blue-100); }
.sel:focus, select.sel:focus { outline: none; border-color: var(--nbc-action); box-shadow: 0 0 0 3px rgba(14, 118, 189, .12); }
.sel-inline { width: auto; font-size: 12.5px; padding: 7px 28px 7px 11px; background-position: right 9px center; }
.details-form input, .details-form select, .details-form textarea { width: 100%; box-sizing: border-box; font-family: inherit; font-size: 13px; padding: 8px 10px; margin-bottom: 10px; border: 1px solid var(--border); border-radius: var(--r-input); background: var(--surface); color: var(--ink); }
.details-form textarea { min-height: 90px; resize: vertical; line-height: 1.5; }
.details-form .lbl { margin-top: 2px; }
/* Beta feedback capture: give the HTMX form fields + dashboard note input the
   same look as .details-form inputs (they live outside a .details-form wrapper). */
#feedback-form .txt, .grid .txt { width: 100%; box-sizing: border-box; font-family: inherit; font-size: 13px; padding: 7px 10px; border: 1px solid var(--border); border-radius: var(--r-input); background: var(--surface); color: var(--ink); }
#feedback-form textarea.txt { min-height: 80px; resize: vertical; line-height: 1.5; }
#feedback-form .txt:focus, .grid .txt:focus { outline: none; border-color: var(--nbc-action); box-shadow: 0 0 0 3px rgba(14, 118, 189, .12); }
#feedback-form .danger { color: var(--danger-fg); font-size: 12px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--nbc-blue); cursor: pointer; }

/* ===== settings two-pane rail ===== */
.settings-shell { display: grid; grid-template-columns: 224px 1fr; gap: 18px; align-items: start; }
.settings-rail { position: sticky; top: 72px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); padding: 7px; box-shadow: var(--shadow-card); display: flex; flex-direction: column; gap: 2px; }
.settings-rail a { position: relative; display: block; padding: 9px 12px 9px 15px; border-radius: 8px; }
.settings-rail a:hover { background: #F4F8FC; }
.settings-rail a .r-label { display: block; font-size: 12.5px; font-weight: 500; color: var(--ink-3); }
.settings-rail a .r-desc { display: block; font-size: 11px; color: var(--ink-5); margin-top: 1px; }
.settings-rail a.active { background: #EAF1FB; }
.settings-rail a.active .r-label { color: var(--nbc-navy); font-weight: 600; }
.settings-rail a.active::before { content: ""; position: absolute; left: 5px; top: 9px; bottom: 9px; width: 3px; border-radius: 3px; background: var(--nbc-action); }
.settings-panel { display: flex; flex-direction: column; gap: 14px; }

/* ===== review list / detail ===== */
.seg { display: flex; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-ctl); padding: 3px; font-size: 12px; }
.seg span { padding: 5px 12px; border-radius: 6px; color: var(--ink-3); }
.seg span.on { background: var(--nbc-navy); color: #fff; font-weight: 600; }

.backlink { font-size: 12.5px; color: var(--ink-4); margin-bottom: 13px; display: inline-flex; align-items: center; gap: 6px; }
.banner { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); padding: 16px 18px; box-shadow: var(--shadow-card); display: flex; align-items: center; gap: 18px; margin-bottom: 13px; }
.banner .pt-avatar { width: 46px; height: 46px; border-radius: 11px; background: #EAF1FB; color: var(--nbc-navy); display: flex; align-items: center; justify-content: center; font-size: 16px; font-weight: 600; flex: none; }
.banner h1 { font-size: 20px; font-weight: 600; color: var(--ink); margin: 0; }
.banner .id-chip { font-family: var(--font-mono); font-size: 11.5px; color: var(--ink-4); background: var(--surface-3); padding: 2px 8px; border-radius: 5px; }
.banner .meta { display: flex; gap: 16px; margin-top: 5px; font-size: 12.5px; color: var(--ink-3); flex-wrap: wrap; }
.banner .meta .k { color: var(--ink-5); }

.alert { background: var(--alert-bg); border: 1px solid var(--alert-border); border-radius: 10px; padding: 11px 15px; display: flex; align-items: center; gap: 12px; margin-bottom: 13px; }
.alert .mark { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 50%; background: var(--urg-soon); color: #fff; font-size: 13px; font-weight: 700; font-family: var(--font-mono); flex: none; }
.alert .txt { font-size: 12.5px; color: var(--alert-fg); }
.alert .txt strong { color: var(--alert-strong); }

.detail-grid { display: grid; grid-template-columns: 1.55fr 1fr; gap: 14px; align-items: start; }
/* source PDF card; sized by its .review-shell column on the review screen */
.pdf-card { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.pdf-toolbar { flex: none; height: 46px; padding: 0 14px; display: flex; align-items: center; gap: 11px; background: #F1F4F9; border-bottom: 1px solid #E2E8F0; }
.pdf-icon { width: 14px; height: 16px; border-radius: 2px; background: #97A4B8; display: inline-block; flex: none; }
.pdf-filename { font-family: var(--font-mono); font-size: 12px; color: var(--ink-3); }
.pdf-badge { font-size: 11px; color: var(--ink-4); }
.pdf-onprem { display: inline-flex; align-items: center; gap: 5px; font-size: 10.5px; color: var(--ok-fg); cursor: help; }
.pdf-onprem .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--urg-routine); }
.pdf-toolbar-spacer { flex: 1; }
.pdf-zoom { display: flex; align-items: center; gap: 6px; font-family: var(--font-mono); font-size: 12px; color: #51607A; }
.pdf-zoom-btn { width: 22px; height: 22px; border: 1px solid var(--border); border-radius: 6px; background: #fff; cursor: pointer; line-height: 1; font-family: inherit; }
.pdf-zoom-btn:hover { background: #EAF1FB; }
.pdf-toolbar-divider { width: 1px; height: 20px; background: #E2E8F0; }
.pdf-surface { flex: 1; min-height: 0; overflow: auto; padding: 16px; display: flex; justify-content: center; background: var(--surface-2); }
.pdf-frame-wrap { width: 100%; height: 100%; flex: none; transition: width .15s ease; }
.source-frame { width: 100%; height: 100%; border: 1px solid var(--border); border-radius: 8px; display: block; }
.source-image { width: 100%; height: auto; display: block; }
.col { display: flex; flex-direction: column; gap: 14px; }
.field { display: grid; grid-template-columns: 148px 1fr; gap: 14px; padding: 9px 0; border-bottom: 1px solid var(--surface-3); align-items: baseline; }
.field:last-child { border-bottom: none; }
.field .f-label { font-size: 11.5px; color: var(--ink-4); font-weight: 500; display: flex; align-items: center; gap: 6px; }
.field .f-value { font-size: 13px; color: var(--ink); }
.field .f-value.flagged { background: var(--alert-bg); padding: 3px 8px; border-radius: 6px; }
.details-form .field { align-items: center; }
.details-form .field .f-value input,
.details-form .field .f-value select,
.details-form .field .f-value textarea { margin-bottom: 0; }

.pdf-thumb { width: 120px; height: 152px; border-radius: 7px; flex: none; border: 1px solid var(--border); background: repeating-linear-gradient(135deg, #F7F9FC, #F7F9FC 7px, #EEF2F7 7px, #EEF2F7 14px); display: flex; align-items: flex-end; justify-content: center; padding-bottom: 9px; }
.pdf-thumb span { font-family: var(--font-mono); font-size: 10px; color: #A6B1C2; }

/* triage panel */
.triage-card { border-color: #C9DDF0; }
.triage-card .card-head { background: #F4F9FD; border-bottom: 1px solid #DCEAF6; padding: 12px 16px; }
.triage-card .card-head h2 { color: var(--nbc-navy); display: flex; align-items: center; gap: 7px; }
.triage-card .card-head h2 .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--nbc-blue); }
.proposed { font-size: 11.5px; color: var(--ink-4); margin-bottom: 11px; line-height: 1.5; }
.proposed strong { color: var(--ink-3); }
.derived { display: flex; align-items: center; justify-content: space-between; padding: 11px 13px; border-radius: var(--r-ctl); margin-bottom: 13px; }
.derived .d-lab { font-size: 12px; font-weight: 500; }
.derived .d-val { display: inline-flex; align-items: center; gap: 7px; font-size: 14px; font-weight: 700; }
.derived .d-val .dot { width: 9px; height: 9px; border-radius: 50%; }
.derived.asap    { background: var(--asap-bg); color: var(--asap-fg); }
.derived.asap .dot    { background: var(--urg-asap); }
.derived.soon    { background: var(--soon-bg); color: var(--soon-fg); }
.derived.soon .dot    { background: var(--urg-soon); }
.derived.routine { background: var(--rout-bg); color: var(--rout-fg); }
.derived.routine .dot { background: var(--urg-routine); }
.derived.none { background: var(--surface-3); color: var(--ink-3); }
.preplist { display: flex; flex-direction: column; gap: 7px; margin-bottom: 15px; }
.preplist label { display: flex; align-items: center; gap: 9px; font-size: 12.5px; color: var(--ink-2); cursor: pointer; }
.btn-block { width: 100%; }

/* match panel */
.sub-label { font-size: 10.5px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-5); margin-bottom: 9px; }
.match-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 11px; border: 1px solid var(--border-2); border-radius: var(--r-ctl); margin-bottom: 9px; }
.match-row.candidate { border-style: dashed; border-color: var(--border); }
.match-row .m-title { font-size: 12.5px; color: var(--ink); font-weight: 500; }
.match-row .m-sub { font-size: 11px; color: var(--ink-4); font-family: var(--font-mono); }

/* ===== stat cards ===== */
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 15px; }
/* The booking queue carries a fifth card (attempts). Opted in per screen rather
   than making the default auto-fit, so the existing four-card rows keep their
   exact proportions. The narrow-screen rule below collapses both to two. */
.stat-row.cols-5 { grid-template-columns: repeat(5, 1fr); }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); padding: 13px 15px; box-shadow: 0 1px 3px rgba(16, 36, 59, .04); }
.stat .n { font-size: 24px; font-weight: 700; color: var(--ink); line-height: 1; }
.stat .l { font-size: 11.5px; color: var(--ink-4); margin-top: 4px; }
.stat.b-asap { border-left: 3px solid var(--urg-asap); }
.stat.b-soon { border-left: 3px solid var(--urg-soon); }
.stat.b-routine { border-left: 3px solid var(--urg-routine); }
.stat.danger { background: #FCF1EF; border: 1px solid #F0CFCA; }
.stat.danger .n { color: var(--danger-fg); }
.stat.danger .l { color: #C5564C; }
.stat .n.ok { color: var(--ok-fg); }
.stat .n.run { color: var(--nbc-action); }
.stat .n.pend { color: var(--ink-4); }

.filters { display: flex; align-items: center; gap: 9px; margin-bottom: 13px; flex-wrap: wrap; }
.filters .f-lab { font-size: 11.5px; color: var(--ink-4); font-weight: 500; }
.filters .f-count { font-size: 11.5px; color: var(--ink-6); margin-left: auto; }
.triage-filters { align-items: end; flex-wrap: nowrap; padding: 9px 11px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); }
.filter-fields { display: grid; grid-template-columns: minmax(80px, .7fr) minmax(135px, 1.3fr) minmax(100px, .9fr) minmax(100px, .9fr) minmax(108px, .95fr) minmax(104px, .9fr); gap: 8px; flex: 1 1 auto; min-width: 0; }
.filter-field { display: flex; min-width: 0; flex-direction: column; gap: 3px; }
.filter-label { color: var(--ink-4); font-size: 10px; font-weight: 600; letter-spacing: .04em; line-height: 1; text-transform: uppercase; }
.filter-field .sel { width: 100%; min-width: 0; height: 31px; padding: 4px 25px 4px 8px; font-size: 11.5px; }
.filter-actions { display: flex; align-items: center; gap: 9px; flex: 0 0 auto; min-height: 31px; }
.filters .filter-actions .f-count { margin-left: 0; white-space: nowrap; }

/* Reject-with-reason popover (review footer) */
.reject-pop { position: relative; display: inline-block; }
.reject-pop > summary { list-style: none; cursor: pointer; }
.reject-pop > summary::-webkit-details-marker { display: none; }
.reject-pop-body { position: absolute; bottom: calc(100% + 6px); right: 0; width: 320px; padding: 12px; z-index: 40; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); box-shadow: 0 10px 28px rgba(16, 36, 59, .16); }
.reject-pop-body .lbl { display: block; margin-bottom: 6px; }
.reject-pop-body .sel { width: 100%; margin-bottom: 8px; }
.reject-pop-body textarea.sel { resize: vertical; min-height: 44px; }
.reject-pop-actions { display: flex; justify-content: flex-end; }
.filter-reset { color: var(--nbc-action); font-size: 11.5px; font-weight: 500; white-space: nowrap; }

/* Booking queue.
   The row-level popover reuses the reject popover's mechanics (a <details>, so
   it works with no JS) but opens DOWNWARD and is wider: it holds three separate
   forms — book, log a call, close — where the reject one holds a single field,
   and a table row has space below it that a pinned footer does not. */
.popover { position: relative; display: inline-block; }
.popover > summary { list-style: none; cursor: pointer; }
.popover > summary::-webkit-details-marker { display: none; }
.popover-panel { position: absolute; top: calc(100% + 6px); right: 0; width: 300px; padding: 12px; z-index: 40; text-align: left; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); box-shadow: 0 10px 28px rgba(16, 36, 59, .16); }
.popover-panel .lbl { display: block; margin-bottom: 4px; }
.popover-panel input, .popover-panel .sel { width: 100%; margin-bottom: 8px; }
.popover-rule { border: 0; border-top: 1px solid var(--border-2); margin: 10px 0; }
.col-actions { text-align: right; white-space: nowrap; }
/* Booking rows are read top-down against a phone, so the wait column earns
   emphasis when a patient is well past target rather than a uniform grey. */
.t-danger { color: var(--danger-fg); font-weight: 600; }
.booking-grid td { vertical-align: top; }
/* A phone number is read aloud digit by digit; wrapping it mid-number is how
   you misdial. */
.booking-grid .col-phone { font-size: 12px; white-space: nowrap; }
.booking-grid .wait-days { font-variant-numeric: tabular-nums; }


/* category-rule settings matrix */
.settings-intro { max-width: 780px; margin: -6px 0 16px; color: var(--ink-3); font-size: 12.5px; }
.rule-card { margin-bottom: 16px; }
.rule-card .card-head { display: flex; align-items: center; justify-content: space-between; }
.rule-card-body { padding: 6px 16px 16px; }
.rule-matrix th[scope="row"] { width: 15%; color: var(--ink); font-weight: 600; }
.rule-matrix td:nth-child(2) { width: 16%; }
.rule-matrix td:nth-child(3) { width: 22%; }
.rule-matrix .rule-missing { background: #FFFCF4; }
.rule-matrix .rule-missing th[scope="row"] { border-left: 3px solid var(--urg-soon); }
.rule-matrix .rule-configured th[scope="row"] { border-left: 3px solid var(--urg-routine); }
.rule-urgency { width: 100%; min-width: 145px; }
.rule-flags { display: flex; align-items: center; gap: 8px 16px; flex-wrap: wrap; }
.rule-flags label { display: inline-flex; align-items: center; gap: 5px; color: var(--ink-2); cursor: pointer; font-size: 12px; white-space: nowrap; }
.rule-save { display: flex; justify-content: flex-end; margin-top: 10px; }

/* triage dashboard rows */
tr.overdue { background: #FDF5F4; }
td .wait-over { color: var(--danger-fg); font-weight: 600; }

/* ===== pipeline ===== */
.stages { display: flex; align-items: center; gap: 4px; }
.stages .node { width: 9px; height: 9px; border-radius: 50%; }
.stages .seg { width: 14px; height: 2px; }
.stages .node.done, .stages .seg.done { background: var(--urg-routine); }
.stages .node.run  { background: var(--nbc-action); }
.stages .node.err  { background: var(--urg-asap); }
.stages .node.pend { background: #C7D2E0; }
.stages .node.off,  .stages .seg.off,
.stages .node.run ~ .seg, .stages .seg.pend, .stages .seg.err, .stages .seg.run { background: #E2E8F0; }
.stages .seg.done { background: var(--urg-routine); }
.stages .stage-name { margin-left: 7px; font-size: 11px; font-family: var(--font-mono); color: var(--ink-4); }
.job-msg { font-size: 11px; color: var(--danger-fg); margin-top: 2px; }
tr.job-error { background: #FDF7F6; }
.is-running { animation: nbcpulse 1.1s infinite; }

/* ===== style guide ===== */
.ds-section { margin-bottom: 14px; }
.ds-section h2 { font-size: 12px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-4); margin: 0 0 14px; }
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.swatch { border: 1px solid var(--border-2); border-radius: 9px; overflow: hidden; }
.swatch .chip { height: 54px; border-bottom: 1px solid rgba(0, 0, 0, .05); }
.swatch .meta { padding: 8px 10px; }
.swatch .s-name { font-size: 12px; font-weight: 600; color: var(--ink); }
.swatch .s-hex { font-size: 10.5px; color: var(--ink-4); font-family: var(--font-mono); }
.swatch .s-var { font-size: 10px; color: var(--ink-6); font-family: var(--font-mono); margin-top: 1px; }
.brand-marks { display: flex; gap: 18px; flex-wrap: wrap; align-items: center; }
.brand-mark { border: 1px solid var(--border-2); border-radius: 9px; padding: 16px 22px; background: #fff; }
.brand-mark.navy { border-color: var(--nbc-navy); background: var(--nbc-navy); }
.ds-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

@media (max-width: 1000px) {
  .detail-grid, .ds-cols, .settings-shell { grid-template-columns: 1fr; }
  .settings-rail { position: static; flex-direction: row; overflow-x: auto; }
  .stat-row { grid-template-columns: repeat(2, 1fr); }
  .triage-filters { align-items: end; flex-wrap: wrap; }
  .filter-fields { flex-basis: 100%; grid-template-columns: repeat(3, minmax(120px, 1fr)); }
  .filter-actions { width: 100%; justify-content: flex-end; }
}

/* ---- single-screen review workspace (review_detail) ---- */
body.review-screen { height: 100vh; overflow: hidden; display: flex; flex-direction: column; }
body.review-screen .main { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 12px 24px 14px; width: 100%; max-width: 1600px; box-sizing: border-box; }
/* feedback form/success cards load into #feedback-slot above .main; float them
   so they can't push the fixed-height workspace off-screen */
body.review-screen #feedback-slot > .card { position: fixed; top: 70px; right: 24px; width: 430px; z-index: 60; box-shadow: var(--shadow-bar); }

.banner-compact { padding: 9px 14px; gap: 12px; margin-bottom: 10px; }
.banner-compact .pt-avatar { width: 34px; height: 34px; font-size: 13px; border-radius: 8px; }
.banner-compact h1 { font-size: 16px; }
.banner-compact .meta { margin-top: 0; }
.banner-compact .ban-main { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; flex-wrap: wrap; }

.alert-strip { padding: 6px 14px; margin-bottom: 10px; border-radius: 8px; }
.alert-strip .mark { width: 18px; height: 18px; font-size: 11px; }
.alert-strip .txt { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.review-shell { flex: 1; min-height: 0; display: grid; grid-template-columns: 1.1fr 1fr; gap: 14px; align-items: stretch; }
.review-shell .col { min-height: 0; display: flex; flex-direction: column; }
.pdf-stagebar { display: flex; gap: 7px; flex-wrap: wrap; font-family: var(--font-mono); font-size: 10.5px; padding: 8px 12px; border-top: 1px solid var(--border-2); }
.pdf-stagebar span { background: var(--ok-bg); color: var(--ok-fg); padding: 2px 7px; border-radius: 5px; }

.workspace-card { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.tab-strip { display: flex; border-bottom: 1px solid var(--border-2); background: var(--surface-2); }
.tab-strip .tab { appearance: none; background: none; border: 0; border-bottom: 2px solid transparent; padding: 11px 18px; font: inherit; font-size: 13px; font-weight: 600; color: var(--ink-4); cursor: pointer; display: flex; align-items: center; gap: 7px; }
.tab-strip .tab.active { color: var(--nbc-navy); border-bottom-color: var(--nbc-action); background: var(--surface); }
.tab-state { font-size: 11px; color: var(--ink-5); }
.tab-state.done { color: var(--ok-fg); }

.tab-body { flex: 1; min-height: 0; overflow-y: auto; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
/* partials keep their .card wrappers for reuse; flatten the chrome inside tabs.
   !important: _results_card.html sets an inline margin-top that must be beaten. */
.tab-panel > .card { border: 0; box-shadow: none; border-radius: 0; margin: 0 !important; }
.tab-panel > .card + .card { border-top: 1px solid var(--border-2); }

.workspace-footer { border-top: 1px solid var(--border-2); padding: 10px 14px; display: flex; align-items: center; gap: 9px; background: var(--surface); }
.workspace-footer .footer-group { display: none; align-items: center; gap: 9px; flex: 1; min-width: 0; flex-wrap: wrap; }
.workspace-footer .footer-group.active { display: flex; }
.footer-accepted { color: var(--ok-fg); font-size: 13px; font-weight: 600; white-space: nowrap; }

/* tighter details rows so 11 fields fit the vertical budget */
.review-shell .details-form .field { padding: 6px 0; }

/* narrow viewports: single column, page scrolls normally */
@media (max-width: 1000px) {
  .review-shell { grid-template-columns: 1fr; }
  .review-shell .pdf-card { min-height: 480px; }
  body.review-screen { height: auto; overflow: auto; display: block; }
}

/* ---- hold resolution (update_resolve) ---- */
/* Reuses the review screen's shell — source document left, decision and its
   evidence right, actions pinned — so the two screens read the same way. The
   difference is that the left card holds BOTH source documents, tab-switched,
   which keeps each one at full pane width. */
body.compare-screen { height: 100vh; overflow: hidden; display: flex; flex-direction: column; }
body.compare-screen .main { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 12px 24px 14px; width: 100%; max-width: 1600px; box-sizing: border-box; }
body.compare-screen #feedback-slot > .card { position: fixed; top: 70px; right: 24px; width: 430px; z-index: 60; box-shadow: var(--shadow-bar); }

.chip-hold { flex: none; font-size: 11px; font-weight: 600; background: var(--warn-bg); color: var(--warn-fg); border-radius: 6px; padding: 4px 9px; white-space: nowrap; }
.chip-outage { display: inline-block; font-size: 11px; font-weight: 600; background: var(--warn-bg); color: var(--warn-fg); border-radius: 5px; padding: 2px 8px; }

/* left card: one document at a time */
.doc-card .tab-strip .tab-meta { font-family: var(--font-mono); font-size: 11px; font-weight: 400; color: var(--ink-4); }
.doc-card .tab-strip .tab.active .tab-meta { color: var(--ink-3); }
.doc-body { flex: 1; min-height: 0; display: flex; }
.doc-panel { display: none; flex: 1; min-width: 0; flex-direction: column; }
.doc-panel.active { display: flex; }
.doc-panel .pdf-surface { flex: 1; min-height: 0; }
.pane-empty { margin: auto; padding: 28px; text-align: center; color: var(--ink-4); font-size: 13px; }

/* right card: the verdict, then the deltas that support it */
.compare-body { padding: 14px 16px; }
.compare-section { margin-top: 16px; }
.compare-note { font-size: 12.5px; color: var(--ink-3); background: var(--surface-2); border: 1px solid var(--border-2); border-radius: 8px; padding: 10px 13px; line-height: 1.55; }
.compare-note strong { color: var(--ink-2); }
/* A hold nobody judged must not look like a considered opinion. */
.compare-note.note-warn { background: var(--warn-bg); border-color: var(--urg-soon); color: var(--warn-fg); }
.compare-note.note-warn strong { color: var(--warn-fg); }
.compare-section .sub-label { display: flex; align-items: center; gap: 8px; }
.compare-section .ev-count { font-weight: 600; letter-spacing: 0; font-size: 10.5px; color: var(--ink-4); background: var(--surface-3); border-radius: 5px; padding: 1px 7px; }

/* narrow viewports: single column, page scrolls normally */
@media (max-width: 1000px) {
  body.compare-screen { height: auto; overflow: auto; display: block; }
  .review-shell .doc-card { min-height: 480px; }
}


.compare-evidence { background: var(--surface); border: 1px solid var(--border-2); border-radius: 8px; }
.compare-evidence > summary { cursor: pointer; padding: 8px 14px; font-size: 12.5px; font-weight: 600; display: flex; align-items: center; gap: 10px; }
.compare-evidence .ev-count { font-weight: 400; font-size: 11.5px; color: var(--ink-4); background: var(--surface-3); border-radius: 5px; padding: 2px 8px; }
.compare-evidence-body { padding: 0 14px 13px; max-height: 42vh; overflow-y: auto; }

.compare-panes { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.compare-pane { min-height: 0; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border-2); border-radius: 10px; overflow: hidden; }
.pane-head { flex: none; display: flex; align-items: center; gap: 9px; padding: 7px 12px; border-bottom: 1px solid var(--border-2); font-size: 12px; color: var(--ink-3); }
.pane-head .id-chip { font-family: var(--font-mono); font-size: 11.5px; color: var(--ink-4); background: var(--surface-3); padding: 2px 8px; border-radius: 5px; }
.pane-role { font-weight: 600; color: var(--ink-2); }
.pane-role.is-new { color: var(--brand); }
.pane-body { flex: 1; min-height: 0; overflow: auto; background: var(--surface-3); }
.pane-body iframe { width: 100%; height: 100%; border: 0; display: block; }
.pane-body img { width: 100%; height: auto; display: block; }
.pane-empty { padding: 28px; text-align: center; color: var(--ink-4); font-size: 13px; }

.compare-actions { flex: none; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding: 10px 0 12px; background: var(--bg); }

/* --- review screen: status banner (non-NEEDS_REVIEW referrals) --------------- */
.status-banner { display: flex; align-items: flex-start; gap: 14px; background: var(--surface); border: 1px solid var(--border-2); border-radius: 8px; padding: 9px 14px; margin-bottom: 10px; font-size: 12.5px; color: var(--ink-3); }
.status-banner strong { color: var(--ink-2); }
.status-banner .sb-main { flex: 1; min-width: 0; }
.status-banner .sb-sub { margin-top: 4px; font-size: 12px; }
.status-banner .sb-sub .k { color: var(--ink-5); }
.status-banner > a { flex: none; }
.status-banner.warn { background: var(--warn-bg); border-color: var(--urg-soon); color: var(--warn-fg); }
.status-banner.warn strong, .status-banner.warn .sb-sub .k { color: var(--warn-fg); }
