/* Professional, lightweight styling. No animation/decoration for its own
   sake - just consistent spacing, clearer hierarchy, and readable type. */

/* -----------------------------------------------------------------------------
   Tokens come from public/pci-design-tokens.css, which is copied verbatim from
   website/styles.css. This file no longer defines its own colours.

   It used to. That is why the application looked like a separate product: the
   app's background was var(--bg) while the website's was var(--bg), its border was
   var(--border) against var(--border), its ink var(--ink) against var(--ink), and its radius 10px
   against 14px. Every one of those was a small independent choice, and together
   they read as a different design system.

   Do not add a colour, radius or spacing value to this file. Add it to the
   website, then copy it into the tokens file.
   ----------------------------------------------------------------------------- */
/* Tokens are linked directly in the document head (see src/views.js) so they
   load in parallel instead of behind a render-blocking @import. */

:root {
  /* --radius is kept only as an alias so existing rules keep working; the real
     value is the website's --r. */
  --radius: var(--r-sm);
}

* { box-sizing: border-box; }

/* Poppins is the approved PCI typeface. It is loaded from bundled woff2
   files if present in /public/fonts/ (see public/fonts/README.md - the
   files can't be fetched in the build sandbox, so they're a file-drop,
   no code change needed). If the files are absent OR Poppins isn't
   installed locally, the stack falls back cleanly to the OS UI font.
   No external font CDN is used, keeping the app fully offline. */
@font-face {
  font-family: "Poppins"; font-style: normal; font-weight: var(--weight-normal);
  font-display: swap; src: local("Poppins"), url("/public/fonts/poppins-400.woff2") format("woff2");
}
@font-face {
  font-family: "Poppins"; font-style: normal; font-weight: var(--weight-medium);
  font-display: swap; src: local("Poppins Medium"), local("Poppins"), url("/public/fonts/poppins-500.woff2") format("woff2");
}
@font-face {
  font-family: "Poppins"; font-style: normal; font-weight: var(--weight-semi);
  font-display: swap; src: local("Poppins SemiBold"), local("Poppins"), url("/public/fonts/poppins-600.woff2") format("woff2");
}

body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  margin: 0;
}

header.topbar {
  background: var(--navy);
  color: white;
  padding: 14px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
header.topbar h1 { font-size: var(--text-lg); font-weight: var(--weight-semi); margin: 0; letter-spacing: 0.01em; }
header.topbar .who { font-size: var(--text-sm); opacity: 0.9; white-space: nowrap; }
header.topbar a { color: var(--info-bg); text-decoration: none; }
header.topbar a:hover { text-decoration: underline; }
.version-badge { font-size: var(--text-2xs); font-weight: var(--weight-normal); opacity: 0.75; margin-left: 6px; vertical-align: middle; }

/* The website's page width, so a screen does not change width when somebody
   moves between the marketing site and the application. */
main { max-width: var(--maxw); margin: 0 auto; padding: 28px 24px 56px; }

.card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 22px 24px;
  margin-bottom: 20px;
}

h2 {
  margin: 0 0 14px;
  font-size: var(--text-lg);
  font-weight: var(--weight-semi);
  color: var(--navy);
  letter-spacing: 0.01em;
}

.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: var(--text-base); }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
th {
  color: var(--muted);
  font-weight: var(--weight-semi);
  font-size: var(--text-2xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 2px solid var(--border);
}
tbody tr:hover { background: var(--surface); }

.status {
  display: inline-block;
  padding: 3px 10px;
  border-radius: var(--r-full);
  font-size: var(--text-2xs);
  font-weight: var(--weight-bold);
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.status-SUBMITTED { background: var(--info-bg); color: var(--info); }
.status-IN_REVIEW { background: var(--warning-bg); color: var(--warning); }
.status-RETURNED { background: var(--danger-bg); color: var(--danger); }
.status-RESUBMITTED { background: var(--neutral-bg); color: var(--navy-700); }
.status-APPROVED { background: var(--success-bg); color: var(--success); }

button, input[type=submit] {
  background: var(--navy);
  color: white;
  border: 1px solid var(--navy);
  padding: 9px 18px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: var(--text-base);
  font-weight: var(--weight-semi);
  transition: background-color 0.15s ease, opacity 0.15s ease;
}
button:hover, input[type=submit]:hover { background: var(--navy-dark); }
button:focus-visible, input[type=submit]:focus-visible,
input:focus-visible, textarea:focus-visible, a:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}
button.secondary { background: white; color: var(--navy); border-color: var(--border); }
button.secondary:hover { background: var(--bg); }
button.danger { background: white; color: var(--danger); border-color: var(--danger-accent); }
button.danger:hover { background: var(--danger-bg); }
input[type=submit]:disabled, button:disabled { opacity: 0.55; cursor: default; background: var(--muted); border-color: var(--muted); }

/* Success/primary variant - used for the affirmative action on a screen
   (Submit, Resubmit, Approve) so the visually "positive" path stands out
   in green rather than the same navy as every other button. Sprint 3. */
button.success, input[type=submit].success {
  background: var(--success);
  border-color: var(--success);
}
button.success:hover, input[type=submit].success:hover { background: var(--success); }

/* Larger buttons for the review-decision screen, where Approve/Return are
   the single most important choice on the page. Sprint 3. */
.btn-large { padding: 13px 22px; font-size: var(--text-base); width: 100%; }
.actions-stacked { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }

/* Anchor-tag buttons, for primary link-actions like "Review Evaluation"
   in a table row, so they read as a clear next step rather than a plain
   text link. Sprint 3. */
a.btn {
  display: inline-block;
  background: var(--navy);
  color: white;
  border: 1px solid var(--navy);
  padding: 7px 14px;
  border-radius: var(--radius);
  font-size: var(--text-sm);
  font-weight: var(--weight-semi);
  text-decoration: none;
  white-space: nowrap;
}
a.btn:hover { background: var(--navy-dark); }
a.btn.btn-secondary { background: white; color: var(--navy); border-color: var(--border); }
a.btn.btn-secondary:hover { background: var(--bg); }

/* Every text-like input gets the same treatment. Historically this rule
   listed only text/file/textarea/select, so email, password, number, tel,
   date, url and search inputs rendered at the browser's default narrow
   width with no border or radius - the field-width inconsistency on the
   Organization Setup screen (email + both password fields) came from here. */
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=tel], input[type=date], input[type=url], input[type=search],
input[type=file], textarea, select {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: var(--text-base);
  margin-top: 4px;
  margin-bottom: 14px;
  font-family: inherit;
  background: white;
}
input[type=text]:focus, input[type=email]:focus, input[type=password]:focus,
input[type=number]:focus, input[type=tel]:focus, input[type=date]:focus,
input[type=url]:focus, input[type=search]:focus, textarea:focus { border-color: var(--teal); }

label { font-size: var(--text-sm); font-weight: var(--weight-semi); color: var(--ink); display: block; margin-bottom: 2px; }

.login-box { max-width: 400px; margin: 64px auto; }
.login-mode-toggle { display: flex; gap: 6px; margin-bottom: 16px; border-bottom: 1px solid var(--border); }
.login-mode-toggle a { padding: 8px 4px; color: var(--muted); text-decoration: none; font-size: var(--text-sm); font-weight: var(--weight-semi); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.login-mode-toggle a.active { color: var(--navy); border-bottom-color: var(--navy); }
.login-mode-toggle a:hover { color: var(--navy); }
.role-choice { display: flex; gap: 16px; margin-bottom: 14px; }
.role-choice label { display: flex; align-items: center; gap: 6px; font-weight: var(--weight-normal); margin-bottom: 0; }

.event { border-left: 3px solid var(--border); padding: 8px 14px; margin-bottom: 10px; font-size: var(--text-sm); }
.event .meta { color: var(--muted); font-size: var(--text-xs); margin-top: 2px; }
.event-comment { margin: 2px 0; }

.comment-box { background: var(--danger-bg); border-left: 3px solid var(--danger); padding: 10px 12px; margin-bottom: 12px; border-radius: 0 6px 6px 0; }
.comment-box-label { font-size: var(--text-xs); font-weight: var(--weight-bold); color: var(--danger); text-transform: uppercase; letter-spacing: 0.03em; margin-bottom: 4px; }
.empty { color: var(--muted); font-style: italic; }
.error-banner { background: var(--danger-bg); color: var(--danger); padding: 10px 14px; border-radius: var(--r-xs); margin-bottom: 16px; font-size: var(--text-base); }
.pill-link { font-size: var(--text-sm); color: var(--navy); font-weight: var(--weight-semi); text-decoration: none; }
.pill-link:hover { text-decoration: underline; }
.actions { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.meta-line { color: var(--muted); font-size: var(--text-sm); margin: 0; }

/* Sprint 3: single-screen review layout. The evaluation document and the
   Approve/Return decision sit side by side so the reviewer never has to
   open a separate tab or scroll hunting for either one. */
.review-header { display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: 10px; }
.review-grid {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 20px;
  align-items: start;
  margin-bottom: 20px;
}
.doc-panel, .decision-panel { margin-bottom: 0; }
.pdf-frame-wrap {
  border: 1px solid var(--border);
  border-radius: var(--r-xs);
  overflow: hidden;
  height: 70vh;
  min-height: 420px;
  background: var(--surface-sunk);
}
.pdf-frame { width: 100%; height: 100%; border: 0; display: block; }

/* Overnight sprint (v0.18.13): the combined document+decision workspace
   (documentReviewScreen()) - PDF is the primary focus (wider column,
   taller viewport), the AI findings summary + decision panel form one
   persistent sidebar that stays in view via position: sticky instead of
   requiring the reviewer to scroll past a long checklist to reach
   Approve/Return. Distinct from the plain .review-grid above (still
   used as-is elsewhere) via its own modifier class so nothing else on
   the site is affected. */
.review-grid-workspace { grid-template-columns: 1.6fr 1fr; }
.review-grid-workspace .pdf-frame-wrap { height: 78vh; min-height: 480px; }
.review-sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: sticky;
  top: 16px;
  max-height: 90vh;
  overflow-y: auto;
}
.ai-summary-panel .snapshot-headline { margin-bottom: 0; }
.decision-panel-sticky { position: sticky; bottom: 0; background: white; box-shadow: var(--shadow-up); }

@media (max-width: 900px) {
  .review-grid-workspace { grid-template-columns: 1fr; }
  .review-sidebar { position: static; max-height: none; }
  .decision-panel-sticky { position: static; box-shadow: none; }
}

.form-note { font-size: var(--text-sm); color: var(--muted); margin: -6px 0 16px; }
/* Phase 6B (2026-07-21): extracted from 18 duplicated instances of
   class="form-note" style="margin-top:-8px;" across src/*.js - same
   visual adjustment (pulling a form-note 2px closer to the element
   above it than .form-note's own default), now one named class instead
   of a repeated inline style. Must come after .form-note in this file:
   same specificity (one class each), source order decides the tie. */
.form-note-tight { margin-top: -8px; }
.form-error { background: var(--danger-bg); color: var(--danger); padding: 9px 12px; border-radius: var(--r-xs); margin-bottom: 12px; font-size: var(--text-sm); }

/* Phase 4a: Administrator interface */
.notice-banner { background: var(--success-bg); color: var(--success); padding: 10px 14px; border-radius: var(--r-xs); margin-bottom: 16px; font-size: var(--text-base); }
.secret-banner { background: var(--warning-bg); border: 1px solid var(--warning-accent); color: var(--warning); padding: 12px 14px; border-radius: var(--r-xs); margin-bottom: 16px; font-size: var(--text-base); }
.secret-banner code { background: white; padding: 2px 6px; border-radius: var(--r-xs); font-size: var(--text-base); border: 1px solid var(--warning-accent); }
.grant-pill { display: inline-block; padding: 3px 10px; border-radius: var(--r-full); font-size: var(--text-xs); font-weight: var(--weight-semi); margin: 2px 4px 2px 0; }
.grant-yes { background: var(--success-bg); color: var(--success); }
.grant-no { background: var(--bg); color: var(--muted); border: 1px solid var(--border); }
.inline-form { display: inline-block; margin: 0 4px 4px 0; }
.admin-nav { display: flex; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }
.filter-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 16px; }
.filter-form label { display: block; font-size: var(--text-xs); color: var(--muted); margin-bottom: 3px; }
.filter-form select, .filter-form input { min-width: 140px; }

.tag { display: inline-block; padding: 2px 9px; border-radius: var(--r-full); font-size: var(--text-2xs); font-weight: var(--weight-bold); letter-spacing: 0.02em; margin-left: 6px; text-transform: uppercase; }
.tag-action { background: var(--danger); color: white; }
.tag-needs-review { background: var(--navy); color: white; }
/* Phase 3: reviewer assignment and claiming */
.tag-claimed { background: var(--navy); color: white; margin-left: 0; }
.tag-assigned { background: var(--muted); color: white; margin-left: 0; }

/* QA Snapshot (Sprint 3: Intelligent QA Assistant) */
.snapshot-headline { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; }
.snapshot-status { font-size: var(--text-lg); font-weight: var(--weight-bold); }
.snapshot-meta { display: flex; gap: 16px; flex-wrap: wrap; font-size: var(--text-sm); color: var(--muted); }
.snapshot-recommendation { font-size: var(--text-lg); font-weight: var(--weight-bold); color: var(--navy); margin: 4px 0; }

.check-row { padding: 5px 0; font-size: var(--text-base); }
.check-ok { color: var(--ink); }
.check-warn { color: var(--danger); font-weight: var(--weight-semi); }

.confidence-details { margin-top: 14px; font-size: var(--text-sm); }
.confidence-details summary { cursor: pointer; color: var(--navy); font-weight: var(--weight-semi); }
.confidence-row { display: flex; justify-content: space-between; padding: 4px 0; border-bottom: 1px solid var(--border); max-width: 360px; }

.event-ai-summary { font-size: var(--text-sm); color: var(--navy); margin: 2px 0; }
.event-override { font-size: var(--text-xs); color: var(--danger); font-style: italic; margin: 2px 0; }

/* Review layout stacks (document above, decision below) once there isn't
   room for two comfortable columns - this triggers before the general
   640px breakpoint because a cramped two-column PDF viewer is worse than
   a full-width stacked one. Sprint 3. */
@media (max-width: 900px) {
  .review-grid { grid-template-columns: 1fr; }
  .pdf-frame-wrap { height: 60vh; min-height: 360px; }
}

@media (max-width: 640px) {
  header.topbar { flex-direction: column; align-items: flex-start; padding: 12px 16px; }
  main { padding: 18px 14px 36px; }
  .card { padding: 16px; }
  .login-box { margin: 32px auto; }
  .role-choice { flex-direction: column; gap: 8px; }
  .actions { flex-direction: column; }
  .actions button { width: 100%; }
  .review-header { flex-direction: column; }
}

/* ==========================================================
   Phase 4b: UI polish, usability, and release-candidate hardening
   ========================================================== */

/* Screen-reader-only text - used for context that sighted users get from
   layout/color but that assistive tech needs spelled out (e.g. "(current
   page)" on the active nav link, so status isn't communicated by
   highlighting alone). */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Skip link: hidden until keyboard-focused, then jumps straight to page
   content - the first tab stop on every page, so a keyboard user never has
   to tab through the full nav bar to reach what they came for. */
.skip-link {
  position: absolute;
  left: 8px;
  top: -48px;
  background: white;
  color: var(--navy);
  padding: 10px 16px;
  border-radius: var(--r-xs);
  font-weight: var(--weight-semi);
  font-size: var(--text-base);
  z-index: 100;
  transition: top 0.15s ease;
  box-shadow: var(--shadow-md);
}
.skip-link:focus { top: 8px; }

/* Standardized primary navigation (Phase 4b). Distinct from the old plain
   text-link nav: a real <nav> with clearly separated, clickable items and
   an explicit "you are here" marker via aria-current, not just an
   underline that a screen reader can't announce. */
nav.primary-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  font-size: var(--text-sm);
}
nav.primary-nav a {
  color: var(--info-bg);
  text-decoration: none;
  padding: 5px 10px;
  border-radius: var(--r-xs);
}
nav.primary-nav a:hover { background: rgba(255,255,255,0.12); text-decoration: none; }
nav.primary-nav a[aria-current="page"] {
  background: rgba(255,255,255,0.18);
  color: white;
  font-weight: var(--weight-semi);
}
nav.primary-nav .nav-sep { color: rgba(255,255,255,0.35); padding: 0 2px; }
.topbar-identity { font-size: var(--text-sm); opacity: 0.92; }
.topbar-identity a { color: var(--info-bg); }

/* Concise status/count cards for the QA queue and Administrator dashboard
   - "show concise counts and actionable status cards," deliberately not a
   dense analytics dashboard. Each card links straight to the filtered
   view it summarizes. */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.stat-card {
  background: white;
  border: 1px solid var(--border);
  border-left: 4px solid var(--navy);
  border-radius: var(--radius);
  padding: 14px 16px;
  text-decoration: none;
  color: inherit;
  display: block;
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}
a.stat-card:hover { box-shadow: 0 2px 8px rgba(23,50,77,0.12); border-left-color: var(--navy-dark); }
.stat-card .stat-number { font-size: var(--text-2xl); font-weight: var(--weight-bold); color: var(--navy); line-height: 1.1; }
.stat-card .stat-label { font-size: var(--text-xs); color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; margin-top: 4px; }
.stat-card.stat-warn { border-left-color: var(--danger); }
.stat-card.stat-warn .stat-number { color: var(--danger); }
.stat-card.stat-ok { border-left-color: var(--success); }
.stat-card.stat-ok .stat-number { color: var(--success); }

/* Warning banner - distinct from error (something failed) and notice
   (something succeeded): used for "this needs your attention but nothing
   is broken" states, e.g. a stale claim or an out-of-date document
   version. Never relies on color alone - always paired with a "Warning:"
   or similarly explicit text lead-in in the markup that uses this class. */
.warning-banner {
  background: var(--warning-bg);
  border: 1px solid var(--warning-accent);
  color: var(--warning);
  padding: 10px 14px;
  border-radius: var(--r-xs);
  margin-bottom: 16px;
  font-size: var(--text-base);
}

/* Destructive/high-impact action styling - already covered by
   button.danger for the button itself; this wraps a control (a form or a
   cell) that performs a destructive action so it reads as visually set
   apart even before the button is reached, per "make destructive or
   high-impact actions visually distinct." */
.destructive-zone {
  border: 1px solid var(--danger-accent);
  background: var(--danger-bg);
  border-radius: var(--r-xs);
  padding: 12px 14px;
  margin-top: 10px;
}

/* Sortable/filterable table header links - plain text with a visible
   sort-direction indicator, not color-only. */
th a.sort-link { color: inherit; text-decoration: none; }
th a.sort-link:hover { text-decoration: underline; }
th a.sort-link[aria-current="true"] { color: var(--navy); }

/* Simple, non-blocking toast-style container reserved for future use by
   the shared confirmAndLock/lockSubmit script if a page ever needs an
   inline "Saving..." indicator beyond a disabled button label change. */
[aria-live] { position: relative; }

/* Table zebra striping + slightly tighter row height improves scan-ability
   on long queues without changing the underlying data or column set. */
tbody tr:nth-child(even) { background: var(--surface); }
tbody tr:nth-child(even):hover { background: var(--bg); }

/* Ensure links inside table cells remain clearly distinguishable from
   plain text even at 13-14px table font sizes. */
td a { color: var(--navy); }

@media (max-width: 640px) {
  .stat-cards { grid-template-columns: repeat(2, 1fr); }
  nav.primary-nav { gap: 2px; }
}

/* ==========================================================
   Phase 5: Clinical Portal Foundation - application launcher
   ========================================================== */

.app-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}
.app-tile {
  text-decoration: none;
  color: inherit;
  display: block;
  transition: box-shadow 0.15s ease, transform 0.1s ease;
}
a.app-tile.app-tile-active:hover {
  box-shadow: 0 3px 10px rgba(23,50,77,0.14);
  border-color: var(--navy);
}
a.app-tile.app-tile-active:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}
.app-tile-disabled {
  opacity: 0.72;
  cursor: default;
}

@media (max-width: 640px) {
  .app-grid { grid-template-columns: 1fr; }
}

/* Kinnser/WellSky Workflow Bridge: drag-and-drop / browse import zone. */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 32px 20px;
  text-align: center;
  background: var(--bg);
  transition: border-color 0.15s ease, background 0.15s ease;
}
.drop-zone.drop-zone-active {
  border-color: var(--navy);
  background: var(--info-bg);
}
.drop-zone p { margin: 6px 0; color: var(--muted); }
.drop-zone input[type="file"] { margin-top: 10px; }
.import-channel-divider {
  text-align: center;
  color: var(--muted);
  font-size: var(--text-sm);
  margin: 20px 0;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.pending-imports-table td, .pending-imports-table th { vertical-align: top; }
.source-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: var(--r-full);
  font-size: var(--text-xs);
  font-weight: var(--weight-semi);
  margin-left: 8px;
  background: var(--info-bg);
  color: var(--navy);
  border: 1px solid var(--border);
}
.import-metadata-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px 20px;
  margin: 14px 0;
}
.import-metadata-grid div { font-size: var(--text-base); }
.import-metadata-grid dt { font-size: var(--text-xs); color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }
.import-metadata-grid dd { margin: 2px 0 0; font-weight: var(--weight-semi); }


/* =========================================================================
   PCI branding pass (v0.18.11)
   The mark used below (public/icons/mark.svg) is a placeholder built in
   this pass from the approved navy/teal palette - NOT the official
   Proximal Clinical Intelligence logo file. Swap public/icons/mark.svg
   (and regenerate packaging/icon.ico from it) for the real logo asset
   when it's available; nothing else here needs to change.
   ========================================================================= */

.brand-mark {
  display: flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
}
.brand-mark-icon { border-radius: var(--r-xs); flex-shrink: 0; }
.brand-mark-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-mark-name { font-size: var(--text-lg); font-weight: var(--weight-bold); letter-spacing: 0.01em; }
.brand-mark-sub { font-size: var(--text-2xs); font-weight: var(--weight-medium); opacity: 0.8; letter-spacing: 0.02em; text-transform: uppercase; }

.auth-screen {
  max-width: 420px;
  margin: 48px auto 32px;
  padding: 0 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.auth-brand { display: flex; flex-direction: column; align-items: center; text-align: center; margin-bottom: 28px; }
.auth-brand-mark { border-radius: var(--r); margin-bottom: 14px; }
.auth-brand-name { font-size: var(--text-xl); font-weight: var(--weight-bold); color: var(--pci-navy-900); margin: 0 0 4px; letter-spacing: 0.005em; }
.auth-brand-sub { font-size: var(--text-sm); font-weight: var(--weight-semi); color: var(--teal-dark); text-transform: uppercase; letter-spacing: 0.04em; margin: 0; }
.auth-screen .login-box { width: 100%; max-width: 400px; margin: 0 auto; background: white; border: 1px solid var(--border); box-shadow: 0 1px 3px rgba(13, 44, 78, 0.06); }
.auth-version { font-size: var(--text-xs); color: var(--muted); text-align: center; margin-top: 18px; }

.site-footer {
  max-width: 1100px;
  margin: 40px auto 0;
  padding: 18px 24px 28px;
  font-size: var(--text-xs);
  color: var(--muted);
  text-align: center;
  border-top: 1px solid var(--border);
}
.topbar-placeholders {
  font-size: var(--text-2xs);
  opacity: 0.55;
  margin-right: 14px;
  padding-right: 14px;
  border-right: 1px solid rgba(255,255,255,0.25);
  letter-spacing: 0.02em;
}
@media (max-width: 720px) { .topbar-placeholders { display: none; } }

/* =========================================================================
   Overnight sprint (v0.18.13): Administrator Setup screen polish + Review
   Workspace polish + design-system consolidation.
   ========================================================================= */

/* Setup screen: wider card (more fields than login), breathing room
   between fields instead of the tight default form spacing, no
   crowding around helper text, comfortable button spacing. */
.auth-screen-wide { max-width: 480px; }
.auth-screen-wide .login-box.setup-box { max-width: 460px; }
.setup-box h2 { margin-bottom: 8px; }
.setup-box > .form-note { margin-bottom: 22px; }
.form-section { margin-bottom: 18px; }
.form-section-last { margin-bottom: 22px; }
.form-section label { margin-bottom: 6px; }
.form-section input { margin-top: 0; margin-bottom: 0; }
.form-section .form-note-tight { margin-top: 6px; margin-bottom: 0; }
/* Right-padding keeps typed text clear of the browser's native
   password-reveal icon instead of visually overlapping it. */
input[type=password] { padding-right: 38px; }
.setup-box input[type=submit] { width: 100%; margin-top: 4px; }

@media (max-width: 540px) {
  .auth-screen-wide, .auth-screen-wide .login-box.setup-box { max-width: 100%; }
}

/* ===================================================================
   v0.18.14 - Enterprise polish + PCI design language
   Focused, additive refinements: consistent buttons, calmer cards,
   Poppins-aware headings, teal as the single accent color. No layout
   or markup changes - purely visual tightening.
   =================================================================== */

/* Headings: Poppins reads heavier, so dial weight back slightly and let
   spacing carry the hierarchy. */
h1, h2, h3 { font-weight: var(--weight-semi); letter-spacing: -0.01em; }
h2 { color: var(--pci-navy-900); }

/* Cards: softer, single elevation; consistent 12px corner. */
.card {
  border-radius: var(--r-sm);
  box-shadow: 0 1px 2px rgba(13, 44, 78, 0.04), 0 1px 3px rgba(13, 44, 78, 0.03);
}

/* Buttons: consistent shape + a subtle press state. Teal is the accent
   for the primary affirmative action; navy remains the default/structural
   button so screens don't turn into a wall of teal. */
button, input[type=submit], a.btn {
  border-radius: var(--r-sm);
  transition: background-color 0.15s ease, box-shadow 0.15s ease, transform 0.05s ease;
}
button:active, input[type=submit]:active, a.btn:active { transform: translateY(1px); }

/* `.cta` was dead: no markup in the app has ever carried it - the class actually used is
   `.btn--cta`. Removed rather than repointed, because a rule nothing selects is a place
   for future drift to hide. */

/* Inputs: calmer resting border, teal focus (already repointed above),
   with a soft focus ring for an enterprise feel. */
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=tel], input[type=date], input[type=url], input[type=search],
input[type=file], textarea, select { border-color: var(--border); }
input[type=text]:focus, input[type=email]:focus, input[type=password]:focus,
input[type=number]:focus, input[type=tel]:focus, input[type=date]:focus,
input[type=url]:focus, input[type=search]:focus, textarea:focus, select:focus {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgba(20,64,110,.15);
  outline: none;
}

/* Tables: a touch more row breathing room + clearer header rule. */
th, td { padding: 11px 10px; }
th { color: var(--pci-navy-800); }

/* Status badges retuned to sit against the navy/teal palette. */
.status-SUBMITTED { background: var(--info-bg); color: var(--navy-700); }
.status-IN_REVIEW { background: var(--warning-bg); color: var(--warning); }
.status-RESUBMITTED { background: var(--neutral-bg); color: var(--navy-700); }

/* Topbar: use the primary navy consistently. */
header.topbar { background: var(--pci-navy-900); }
nav.primary-nav a[aria-current="page"] { box-shadow: inset 0 -2px 0 var(--teal-light); }

/* Auth screen mark spacing with the real square icon. */
.auth-brand-mark { border-radius: var(--r); }

/* ===================================================================
   v0.18.16 — Review workspace: AI findings presentation + keyboard
   Presentation-only. Server actions, form fields, and the approve/return
   semantics are unchanged. Promotes the approved prototype into the app.
   =================================================================== */
.ai-head .ai-head-sub{font-size: var(--text-2xs);letter-spacing:.06em;text-transform:uppercase;color:var(--muted);font-weight: var(--weight-semi)}
.ai-head h2{font-size: var(--text-lg);color:var(--pci-navy-900);font-weight: var(--weight-semi)}
.ai-meta-row{display:flex;gap:8px;align-items:center;flex-wrap:wrap;margin-top:8px}
.ai-conf-pill{font-size: var(--text-2xs);font-weight: var(--weight-bold);color:var(--navy-700);background:var(--info-bg);border-radius: var(--r-full);padding:3px 9px}
.ai-time{font-size: var(--text-xs);color:var(--muted)}

/* AI recommendation banner — the single most important element */
.ai-rec{margin:14px 0;border-radius: var(--r-sm);padding:14px 16px;color:var(--surface);background:linear-gradient(135deg,var(--navy-900),var(--navy-800))}
.ai-rec-label{font-size: var(--text-2xs);letter-spacing:.08em;text-transform:uppercase;color:var(--teal-light);font-weight: var(--weight-bold)}
.ai-rec-text{font-size: var(--text-lg);font-weight: var(--weight-semi);margin:3px 0 4px}
.ai-rec-why{font-size: var(--text-xs);color:var(--border)}
.ai-rec-note{font-size: var(--text-2xs);color:var(--border-strong);margin-top:8px}
.ai-rec.rec-return{background:linear-gradient(135deg,var(--navy-900),var(--danger))}

/* finding cards grouped by severity */
.finding-group{margin-top:12px}
.finding-group-title{font-size: var(--text-2xs);text-transform:uppercase;letter-spacing:.05em;font-weight: var(--weight-bold);margin-bottom:7px}
.finding-group-title.crit{color:var(--danger)}
.finding-group-title.rev{color:var(--warning)}
.finding{border:1px solid var(--border);border-left:4px solid var(--muted);border-radius: var(--r-sm);padding:11px 13px;margin-bottom:8px;background:var(--surface)}
.finding-critical{border-left-color:var(--danger)}
.finding-review{border-left-color:var(--warning-accent)}
.finding-ok{border-left-color:var(--success)}
.finding-head{display:flex;justify-content:space-between;align-items:center;gap:10px}
.finding-label{font-size: var(--text-base);font-weight: var(--weight-semi);color:var(--ink)}
.finding-conf{font-size: var(--text-2xs);font-weight: var(--weight-bold);color:var(--muted)}

/* keyboard hint + kbd chips */
.kbd-hint kbd,.decision-panel kbd{background:var(--surface-sunk);border:1px solid var(--border);border-radius: var(--r-xs);padding:1px 6px;font-family:monospace;font-size: var(--text-xs);color:var(--pci-navy-900)}
.kbd-hint{color:var(--muted)}

/* v0.18.17 — review provenance line + polished empty-queue state (presentation only) */
.provenance-line{font-size: var(--text-xs);color:var(--muted);margin-top:6px;display:flex;align-items:center;gap:7px}
.provenance-line .prov-ico{color:var(--teal);font-size: var(--text-xs)}
.queue-empty{text-align:center;padding:48px 24px}
.queue-empty .qe-check{width:56px;height:56px;border-radius:50%;background:var(--okbg,var(--success-bg));color:var(--success);display:flex;align-items:center;justify-content:center;font-size: var(--text-2xl);font-weight: var(--weight-bold);margin:0 auto 14px}
.queue-empty .qe-title{font-size: var(--text-xl);font-weight: var(--weight-semi);color:var(--pci-navy-900);letter-spacing:-.01em}
.queue-empty .qe-sub{font-size: var(--text-base);color:var(--muted);max-width:420px;margin:6px auto 0}

/* v0.18.18 — review workspace responsive refinements + confidence legend (presentation only) */
/* prevent long finding labels or the iframe from blowing out the grid columns */
.review-grid-workspace > * { min-width: 0; }
.finding-label { word-break: break-word; }
/* fluid PDF height so it fits mid-size windows without a giant scroll */
.review-grid-workspace .pdf-frame-wrap { height: clamp(420px, 74vh, 900px); }
/* intermediate breakpoint: give the AI panel a bit more room before stacking */
@media (max-width: 1180px) and (min-width: 901px) {
  .review-grid-workspace { grid-template-columns: 1.4fr 1.05fr; }
}
/* stacked view: findings sit under the document, comfortable heights */
@media (max-width: 900px) {
  .review-grid-workspace .pdf-frame-wrap { height: clamp(340px, 56vh, 620px); }
  .review-sidebar { gap: 14px; }
}
@media (max-width: 560px) {
  .review-grid-workspace .pdf-frame-wrap { height: 46vh; min-height: 300px; }
  .ai-rec-text { font-size: var(--text-base); }
  .decision-panel .actions-stacked { gap: 8px; }
}
/* confidence legend */
.conf-legend { margin-top: 10px; }
.conf-legend summary { font-size: var(--text-xs); color: var(--teal-dark); cursor: pointer; font-weight: var(--weight-semi); }
.conf-legend p { font-size: var(--text-xs); color: var(--muted); margin-top: 6px; line-height: 1.55; }
.conf-legend-note { color: var(--pci-navy-900) !important; font-weight: var(--weight-medium); }

/* ============================================================
   Referral Intake screens. Usability standard: readable without
   training - status as words, next action always visible, amber
   only for things needing action today.
   ============================================================ */
.page-head{display:flex;justify-content:space-between;align-items:flex-start;gap:20px;flex-wrap:wrap;margin-bottom:18px}
.page-sub{color:var(--muted,var(--muted));margin:6px 0 0;font-size: var(--text-base);max-width:70ch}
.stat-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(160px,1fr));gap:14px;margin-bottom:20px}
.stat-card{background:var(--surface);border:1px solid var(--border);border-radius: var(--r-sm);padding:16px 18px;display:flex;flex-direction:column;gap:2px}
.stat-card--attention{border-color:var(--warning);background:var(--warning-bg)}
.stat-value{font-size: var(--text-2xl);font-weight: var(--weight-bold);line-height:1.1;color:var(--navy-900)}
.stat-label{font-size: var(--text-sm);font-weight: var(--weight-semi);color:var(--ink)}
.stat-hint{font-size: var(--text-xs);color:var(--muted)}
.filter-bar{display:flex;align-items:center;gap:12px;flex-wrap:wrap;background:var(--bg);border:1px solid var(--border);border-radius: var(--r-sm);padding:12px 14px;margin-bottom:16px}
.filter-bar label{font-size: var(--text-sm);font-weight: var(--weight-semi);color:var(--ink);margin:0}
/* Controls inside the bar align on one row; the base inputs' vertical margins
   would otherwise push them out of alignment. The search box is the primary
   control, so it grows to fill the free space. */
.filter-bar input, .filter-bar select { margin: 0; }
.filter-search { flex: 1 1 240px; min-width: 200px; max-width: 380px; }
/* Scoped to the bar so it outranks the base input[type=text] { width: 100% }. */
.filter-bar .filter-zip { flex: 0 0 auto; width: 10ch; }
.check-inline{display:inline-flex;align-items:center;gap:6px}
.pill{display:inline-block;padding:2px 10px;border-radius: var(--r-full);font-size: var(--text-xs);font-weight: var(--weight-bold);white-space:nowrap}
.pill--neutral{background:var(--neutral-bg);color:var(--muted)}
.pill--active{background:var(--info-bg);color:var(--info)}
.pill--good{background:var(--success-bg);color:var(--success)}
.pill--warn{background:var(--warning-bg);color:var(--warning)}
.row--attention{background:var(--warning-bg)}
.needs{color:var(--warning);font-style:normal;font-weight: var(--weight-semi)}
.muted-sm{display:block;font-size: var(--text-xs);color:var(--muted)}
.num{white-space:nowrap}
.empty-state{text-align:center;padding:34px 20px}
.empty-state strong{display:block;font-size: var(--text-lg);margin-bottom:6px}
.empty-state span{display:block;color:var(--muted);margin-bottom:14px}
.empty-inline{color:var(--muted);font-size: var(--text-base)}
.next-step{display:flex;justify-content:space-between;align-items:center;gap:18px;flex-wrap:wrap;
  background:var(--info-bg);border:1px solid var(--info-accent);border-left:4px solid var(--info);border-radius:0 10px 10px 0;padding:14px 18px;margin-bottom:20px}
.next-step p{margin:4px 0 0;font-size: var(--text-base);color:var(--ink)}
.detail-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(300px,1fr));gap:16px;margin-bottom:16px}
.panel{background:var(--surface);border:1px solid var(--border);border-radius: var(--r-sm);padding:18px 20px;margin-bottom:16px}
.panel h2{font-size: var(--text-lg);margin:0 0 4px}
.panel-sub{color:var(--muted);font-size: var(--text-sm);margin:0 0 12px}
.kv{display:grid;grid-template-columns:auto 1fr;gap:6px 16px;margin:0;font-size: var(--text-base)}
.kv dt{color:var(--muted);font-weight: var(--weight-semi)}
.kv dd{margin:0}
.workload{list-style:none;margin:0;padding:0}
.workload li{display:flex;justify-content:space-between;padding:7px 0;border-bottom:1px solid var(--neutral-bg);font-size: var(--text-base)}
.timeline{list-style:none;margin:0;padding:0}
.timeline li{display:flex;gap:14px;padding:8px 0;border-bottom:1px solid var(--surface-sunk);font-size: var(--text-base)}
.tl-when{color:var(--muted);white-space:nowrap;min-width:150px;font-size: var(--text-sm)}
.tl-what em{color:var(--muted);margin-left:6px}
.stacked-form{max-width:560px}
.stacked-form label{display:block;margin:16px 0 5px;font-weight: var(--weight-semi);font-size: var(--text-base)}
.stacked-form input,.stacked-form select{width:100%}
.field-hint{font-size: var(--text-xs);color:var(--muted);margin:4px 0 0}
.req{font-weight: var(--weight-medium);color:var(--warning);font-size: var(--text-xs)}
.inline-form{display:flex;gap:12px;align-items:flex-end;flex-wrap:wrap}
.inline-form label{display:block;font-size: var(--text-sm);font-weight: var(--weight-semi);margin-bottom:4px}
.verify-progress{background:var(--bg);border:1px solid var(--border);border-radius: var(--r-sm);padding:12px 16px;margin-bottom:16px;font-size: var(--text-base)}
.split-view{display:grid;grid-template-columns:1fr 1fr;gap:16px;align-items:start}
.split-pane{background:var(--surface);border:1px solid var(--border);border-radius: var(--r-sm);padding:14px}
.pdf-frame{width:100%;height:72vh;border:1px solid var(--border);border-radius: var(--r-xs)}
.vfield-list{list-style:none;margin:0;padding:0;max-height:72vh;overflow:auto}
.vfield{border:1px solid var(--border);border-radius: var(--r-sm);padding:12px 14px;margin-bottom:10px}
.vfield--proposed{border-left:4px solid var(--warning)}
.vfield--confirmed{border-left:4px solid var(--success)}
.vfield--corrected{border-left:4px solid var(--info)}
.vfield--not_present{border-left:4px solid var(--border-strong);opacity:.75}
.vfield-head{display:flex;justify-content:space-between;gap:10px;font-size: var(--text-base)}
.vstate{font-size: var(--text-xs);font-weight: var(--weight-bold);color:var(--muted)}
.vproposed{margin:6px 0;font-size: var(--text-base)}
.vfinal{margin:4px 0;font-size: var(--text-base);color:var(--success)}
.conf{display:inline-block;margin-left:8px;font-size: var(--text-2xs);font-weight: var(--weight-bold);padding:1px 8px;border-radius: var(--r-full)}
.conf--high{background:var(--success-bg);color:var(--success)}
.conf--med{background:var(--warning-bg);color:var(--warning)}
.conf--low{background:var(--warning-bg);color:var(--warning)}
.vactions{display:flex;gap:8px;flex-wrap:wrap;align-items:center;margin-top:8px}
.vactions input[type=text]{flex:1;min-width:150px}
.btn-sm{padding:5px 11px;font-size: var(--text-sm)}
.btn-link{background:none;border:none;color:var(--info);text-decoration:underline;padding:0;font-size: var(--text-base)}
.data-table.compact td,.data-table.compact th{padding:8px 10px;font-size: var(--text-sm)}
@media (max-width:900px){
  .split-view{grid-template-columns:1fr}
  .pdf-frame{height:52vh}
  .vfield-list{max-height:none}
  .data-table{display:block;overflow-x:auto}
  .next-step{flex-direction:column;align-items:flex-start}
}
.qa-scroll{max-height:56vh;overflow:auto;padding-right:4px}
.qa-section{font-size: var(--text-sm);text-transform:uppercase;letter-spacing:.06em;color:var(--muted);margin:14px 0 6px}
.qa-list{list-style:none;margin:0;padding:0}
.qa-item{border:1px solid var(--border);border-radius: var(--r-sm);padding:8px 10px;margin-bottom:6px}
.qa-item--pass{border-left:4px solid var(--success)}
.qa-item--fail{border-left:4px solid var(--warning);background:var(--warning-bg)}
.qa-item--na{border-left:4px solid var(--border-strong);opacity:.7}
.qa-label{display:block;font-size: var(--text-base);font-weight: var(--weight-semi);margin-bottom:5px}
.qa-actions{display:flex;gap:6px;align-items:center;flex-wrap:wrap}
.qa-actions input[type=text]{flex:1;min-width:120px}
.qa-decide{border-top:1px solid var(--border);margin-top:14px;padding-top:12px}

/* ---------------------------------------------- Referral Comments panel
   Operational conversation log. Visually distinct from the History timeline
   below it, because one is a working discussion and the other is a record. */
.comment-list { list-style: none; margin: 20px 0 0; padding: 0; }
.comment {
  border: 1px solid var(--border, var(--border));
  border-radius: var(--r-sm);
  padding: 14px 16px;
  margin-bottom: 12px;
  background: var(--surface);
}
.comment--pinned {
  border-color: var(--brand-teal, var(--teal));
  border-left-width: 4px;
  background: var(--info-bg);
}
.comment-pin-flag {
  margin: 0 0 6px; font-weight: var(--weight-semi); font-size: var(--text-sm);
  letter-spacing: .02em; color: var(--brand-navy, var(--navy-900));
}
.comment-meta { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; margin-bottom: 8px; }
.comment-author { font-weight: var(--weight-semi); color: var(--brand-navy, var(--navy-900)); }
.comment-role   { font-size: var(--text-sm); color: var(--muted); }
.comment-date,
.comment-time   { font-size: var(--text-sm); color: var(--muted); }
.comment-body   { white-space: pre-wrap; line-height: 1.55; }
.comment .mention {
  font-weight: var(--weight-semi); color: var(--brand-teal, var(--teal));
  background: rgba(12,44,78,.09); padding: 0 3px; border-radius: var(--r-xs);
}
.comment-pin-form { margin-top: 8px; }
.comment-form { margin-bottom: 4px; }
.comment-form textarea { width: 100%; font: inherit; padding: 10px; border-radius: var(--r-xs);
  border: 1px solid var(--border, var(--border)); resize: vertical; }
.comment-form .field-inline { display: inline-flex; align-items: center; gap: 8px; margin: 10px 14px 12px 0; }
.pill--tag { background: var(--neutral-bg); color: var(--muted); }
/* SECOND .btn-link definition removed - it duplicated the rule above with a different
   colour, so which one won depended purely on source order. One definition, at line ~839. */

/* Beta feedback prompt in the footer. Quiet by default - it must be findable
   without competing with the work on the page. */
.beta-feedback { margin-top: 10px; text-align: left; max-width: 640px; }
.beta-feedback summary { cursor: pointer; font-size: var(--text-sm); color: var(--brand-teal, var(--teal)); }
.beta-feedback-note { font-size: var(--text-sm); color: var(--muted); margin: 8px 0; }
.beta-feedback textarea { width: 100%; font: inherit; padding: 8px; border-radius: var(--r-xs);
  border: 1px solid var(--border, var(--border)); resize: vertical; }

/* Timing & priority: badges and attention colouring on the referral dashboard. */
.pill--badge { font-weight: var(--weight-bold); letter-spacing: .03em; font-size: var(--text-2xs); }
.txt-warn { color: var(--pci-danger, var(--danger)); font-weight: var(--weight-semi); }
.txt-attention { color: var(--warning); font-weight: var(--weight-semi); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 4px 0 14px; }
.kv dt { font-weight: var(--weight-semi); color: var(--muted); }
.kv dd { margin: 0; }
.edit-block { border-top: 1px solid var(--border, var(--border)); margin-top: 12px; padding-top: 10px; }
.edit-block summary { cursor: pointer; color: var(--brand-teal, var(--teal)); font-size: var(--text-base); }
.radio-row { display: block; margin: 4px 0; }
.alert-warn { background: var(--warning-bg); border: 1px solid var(--warning-accent); border-radius: var(--r-sm); padding: 12px 14px; }

/* Follow-Up Log. Visually distinct from Internal Comments and System History,
   because three logs on one page is exactly where people post in the wrong one. */
.fu-list { list-style: none; margin: 20px 0 0; padding: 0; }
.fu { border: 1px solid var(--border, var(--border)); border-left: 4px solid var(--brand-navy, var(--navy-900));
  border-radius: var(--r-sm); padding: 12px 14px; margin-bottom: 12px; background: var(--surface); }
.fu--superseded { opacity: .62; border-left-color: var(--border-strong); background: var(--surface); }
.fu--amendment { border-left-color: var(--brand-teal, var(--teal)); }
.fu-flag { margin: 0 0 6px; font-size: var(--text-xs); font-weight: var(--weight-semi); color: var(--muted); }
.fu-head { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; margin-bottom: 6px; }
.fu-when { font-weight: var(--weight-semi); color: var(--brand-navy, var(--navy-900)); }
.fu-org { font-weight: var(--weight-semi); }
.fu-outcome, .fu-next { font-size: var(--text-base); margin-top: 4px; }
.fu-note { white-space: pre-wrap; line-height: 1.55; margin-top: 6px; }
.fu-by { margin-top: 8px; }
.fu-amend { margin-top: 8px; }
.fu-amend summary { cursor: pointer; font-size: var(--text-sm); color: var(--brand-teal, var(--teal)); }
.fu-status { background: var(--bg); border-radius: var(--r-sm); padding: 12px 14px; margin-bottom: 14px; }
.quick-actions { margin: 12px 0; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px 16px; }
.checkbox-row { display: block; margin: 10px 0; font-size: var(--text-base); }
.auth-ladder { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 8px; font-size: var(--text-sm); }
.auth-rung { color: var(--border-strong); }
.auth-rung--done { color: var(--brand-navy, var(--navy-900)); font-weight: var(--weight-bold); }
.auth-arrow { color: var(--border); }

/* Build number. A .version-badge already existed in the topbar - strengthened
   rather than duplicated, so every screen and test report identifies the build. */
.version-badge { background: var(--brand-navy, var(--navy-900)); color: var(--surface); padding: 1px 7px;
  border-radius: var(--r-sm); font-size: var(--text-2xs); font-weight: var(--weight-bold); letter-spacing: .03em; }

/* --------------------- Therapist Directory + direct assignment ---------------
   Added with the fix for "put available and shows no therapist": the directory
   had no edit screen at all, and the assignment panel had no control that could
   assign anyone when the suggestion table came back empty. */
.notice-banner--warn { background: var(--warning-bg); color: var(--warning); }
.dir-card { margin-bottom: 18px; }
.dir-card-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
  border-bottom: 1px solid var(--border); padding-bottom: 10px; margin-bottom: 14px; }
.dir-card-head h3 { margin: 0; font-size: var(--text-lg); }
.dir-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; }
.dir-grid .field--wide { grid-column: span 2; }
@media (max-width: 700px) { .dir-grid .field--wide { grid-column: span 1; } }
.assign-direct { margin-top: 18px; padding: 16px; background: var(--bg);
  border: 1px solid var(--border); border-radius: var(--radius); }
.assign-direct h3 { margin: 0 0 4px; font-size: var(--text-base); }
.assign-direct .inline-form { display: flex; align-items: flex-end; gap: 12px;
  flex-wrap: wrap; margin-top: 12px; }
.assign-direct select { min-width: 280px; }

/* ------------------------- Executive Operations Center -----------------------
   Built to be read in under two minutes: dense tiles, urgency-ordered sections,
   and a reason printed next to every row that claims something is wrong. */
.exec-search { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; }
.exec-search input[type="search"] { flex: 1; min-width: 240px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: var(--r-sm); font-size: var(--text-base); }
.exec-jump { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 18px;
  font-size: var(--text-sm); }
.exec-jump a { background: var(--surface-sunk); border: 1px solid var(--border); border-radius: var(--r-full);
  padding: 4px 12px; text-decoration: none; }
.exec-jump a:hover { background: var(--info-bg); }
.exec-panel { margin-bottom: 20px; }
.exec-panel--first { border-left: 4px solid var(--brand-navy, var(--navy-900)); }
.exec-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-bottom: 6px; }
.exec-head h2 { margin: 0; }
.exec-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px; margin: 12px 0; }
.exec-tile { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px;
  border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--surface);
  text-decoration: none; color: inherit; }
a.exec-tile:hover { border-color: var(--border); background: var(--bg); }
.exec-tile-value { font-size: var(--text-2xl); font-weight: var(--weight-bold); line-height: 1.1; }
.exec-tile-label { font-size: var(--text-xs); color: var(--muted); }
.exec-tile-sub { font-size: var(--text-2xs); color: var(--muted); }
.exec-tile--warn { background: var(--danger-bg); border-color: var(--border); }
.exec-tile--warn .exec-tile-value { color: var(--danger); }
.exec-tile--active { background: var(--warning-bg); border-color: var(--border-warning, var(--border)); }
.exec-tile--good { background: var(--success-bg); border-color: var(--border); }
.exec-count { display: inline-block; min-width: 22px; padding: 0 7px; border-radius: var(--r-full);
  background: var(--brand-navy, var(--navy-900)); color: var(--surface); font-size: var(--text-xs);
  font-weight: var(--weight-bold); text-align: center; vertical-align: middle; }
.exec-att-group, .exec-bn { margin: 16px 0 4px; }
.exec-att-group h3, .exec-bn h3 { display: flex; align-items: center; gap: 8px;
  font-size: var(--text-base); margin: 0 0 4px; }
.exec-plain { list-style: none; padding: 0; margin: 8px 0; }
.exec-plain > li { padding: 8px 0; border-bottom: 1px solid var(--neutral-bg); }
.exec-plain > li.is-unread { background: var(--warning-bg); padding-left: 8px; }
.exec-provenance { font-size: var(--text-xs); color: var(--muted); background: var(--bg);
  border: 1px solid var(--border); border-radius: var(--r-sm); padding: 10px 12px; margin-top: 10px; }
.exec-perf { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.exec-perf-col h3 { font-size: var(--text-base); margin: 0 0 6px; }
.exec-metrics th { font-weight: var(--weight-medium); text-align: left; }
.exec-metric-value { font-weight: var(--weight-bold); white-space: nowrap; }
.exec-metric-n, .exec-metric-none { font-size: var(--text-xs); color: var(--muted); }
.exec-settings { margin-top: 8px; }
.exec-settings summary { cursor: pointer; font-size: var(--text-sm); color: var(--ink); }

/* Escalations: the staff-to-owner thread. */
.exec-esc-list { list-style: none; padding: 0; margin: 10px 0; }
.exec-esc { border: 1px solid var(--border); border-radius: var(--r-sm); padding: 12px 14px;
  margin-bottom: 12px; background: var(--surface); }
.exec-esc--waiting { border-left: 4px solid var(--warning-accent); background: var(--warning-bg); }
.exec-esc--closed { opacity: .8; }
.exec-esc-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.exec-esc-reason { margin: 8px 0 4px; font-size: var(--text-base); }
.exec-esc-thread { list-style: none; padding: 0; margin: 10px 0 6px;
  border-left: 3px solid var(--border); }
.exec-esc-thread > li { padding: 6px 0 6px 12px; }
.exec-esc-thread > li.is-owner { border-left: 3px solid var(--brand-navy, var(--navy-900));
  margin-left: -3px; padding-left: 12px; background: var(--bg); }
.exec-esc-resolution { background: var(--success-bg); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: 8px 10px; margin: 8px 0 0; font-size: var(--text-base); }
.exec-esc-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
.exec-esc-actions .inline-form { display: flex; gap: 6px; flex: 1; min-width: 240px; }
.exec-esc-actions input[type="text"] { flex: 1; }
.req { font-weight: var(--weight-semi); color: var(--danger); font-size: var(--text-2xs); text-transform: uppercase; }
.exec-metric-bad { display: block; color: var(--danger); font-size: var(--text-2xs); }

/* =============================================================================
   PORTAL SHELL - ported from website/styles.css
   =============================================================================
   These rules are the website's own shell, reused rather than reinvented. The
   selector names match the site (.nav-shell, .wrap, .brand, .btn, .btn--cta,
   .btn--ghostline) so that a change made on the site can be copied across by
   name instead of translated.
   ============================================================================= */

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }

/* Verbatim from website/styles.css .nav-shell */
.nav-shell {
  position: sticky; top: 0; z-index: 100;
  background: rgba(255, 255, 255, .72);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid rgba(228, 233, 239, .8);
  transition: box-shadow .3s;
}
.portal-bar { display: flex; align-items: center; justify-content: space-between;
  height: 70px; gap: 20px; }
.brand { display: inline-flex; align-items: center; text-decoration: none; flex: 0 0 auto; }
.brand-logo { height: 34px; width: auto; display: block; }

.portal-nav-wrap { flex: 1 1 auto; min-width: 0; }
.portal-nav { display: flex; align-items: center; gap: 4px; list-style: none;
  margin: 0; padding: 0; flex-wrap: wrap; }
.portal-nav a {
  display: inline-block; padding: 8px 13px; border-radius: var(--r-sm);
  font-size: var(--text-base); font-weight: var(--weight-medium); color: var(--navy-900);
  text-decoration: none; white-space: nowrap;
}
.portal-nav a:hover { background: rgba(12,44,78,.09); color: var(--teal-600); }
.portal-nav a[aria-current="page"] {
  background: var(--navy-900); color: var(--surface); font-weight: var(--weight-semi);
}
.portal-identity { display: flex; align-items: center; gap: 12px; flex: 0 0 auto; }
.portal-who { display: flex; flex-direction: column; line-height: 1.25; text-align: right; }
.portal-who strong { font-size: var(--text-sm); color: var(--ink); font-weight: var(--weight-semi); }
.portal-role { font-size: var(--text-2xs); color: var(--muted); }

/* Verbatim from website/styles.css .btn / .btn--cta / .btn--ghostline */
.btn {
  display: inline-flex; align-items: center; gap: 8px; font-weight: var(--weight-semi);
  font-size: var(--text-base); padding: 12px 22px; border-radius: var(--r-sm);
  border: 1px solid transparent; cursor: pointer; text-decoration: none;
  transition: transform .18s cubic-bezier(.2,.8,.2,1), box-shadow .18s, background .18s, color .18s;
  white-space: nowrap;
}
/* REGRESSION FIXED (v0.28.2). This was `background: var(--teal); color: var(--navy-900)`.
   When --teal was repointed onto the brand navy in v0.28.0, it became dark navy text on a
   dark navy fill: 1.64:1, across 8 buttons. The token guard missed it because it checked
   the DOCUMENTED token pairs, not the pairs actually written in CSS rules - so the guard
   now does rule-level contrast too (see e2e-design-tokens Part 7).
   Primary actions use the action tokens, which are contrast-checked by definition. */
.btn--cta { background: var(--action); color: var(--action-fg); border-color: var(--action); box-shadow: var(--shadow-md); }
.btn--cta:hover { background: var(--action-hover); border-color: var(--action-hover); transform: translateY(-1px); }
.btn--ghostline { background: transparent; color: var(--navy-800); border-color: var(--border-strong); }
.btn--ghostline:hover { background: var(--surface-sunk); }
.btn--sm { font-size: var(--text-sm); padding: var(--space-2) var(--space-4); border-radius: var(--radius); }

.site-footer .wrap { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

@media (max-width: 860px) {
  .portal-bar { height: auto; padding: 12px 0; flex-wrap: wrap; }
  .portal-nav-wrap { order: 3; flex-basis: 100%; }
  .portal-identity { margin-left: auto; }
}

/* =============================================================================
   EXECUTIVE LANDING - summary only. Cards are buttons, not headings.
   =============================================================================
   Jose: "See the number. Click the number. Review only the matching records.
   Take action. Return to the dashboard." So the landing page carries counts and
   nothing else; every detail lives behind its own URL.
   ============================================================================= */

.exec-hero { display: flex; align-items: flex-end; justify-content: space-between;
  gap: 20px; flex-wrap: wrap; margin: 4px 0 18px; }
.exec-hero h1 { margin: 0 0 2px; font-size: var(--text-2xl); letter-spacing: -.01em; }
.exec-hero-sub { margin: 0; color: var(--muted); font-size: var(--text-sm); }

.exec-cardgrid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(178px, 1fr));
  gap: 12px; margin: 0 0 26px;
}
/* A card is a link. It looks pressable, and the whole tile is the target. */
a.exec-card, .exec-card {
  display: flex; flex-direction: column; gap: 2px;
  padding: 16px 18px 14px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--r);
  box-shadow: var(--shadow-sm); text-decoration: none; color: inherit;
  transition: transform .16s cubic-bezier(.2,.8,.2,1), box-shadow .16s, border-color .16s;
}
a.exec-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md);
  border-color: var(--teal-300); }
a.exec-card:focus-visible { outline: 3px solid var(--teal); outline-offset: 2px; }
.exec-card-n { font-size: var(--text-3xl); font-weight: var(--weight-bold); line-height: 1.05; color: var(--navy-900); }
.exec-card-l { font-size: var(--text-sm); color: var(--muted); font-weight: var(--weight-medium); }
.exec-card-go { font-size: var(--text-2xs); color: var(--teal-600); font-weight: var(--weight-semi); margin-top: 4px; }
.exec-card--zero .exec-card-n { color: var(--border); }
.exec-card--zero .exec-card-go { visibility: hidden; }
.exec-card--warn { border-color: var(--danger-bg); background: var(--danger-bg); }
.exec-card--warn .exec-card-n { color: var(--danger); }
.exec-card--active { border-color: var(--border-warning, var(--border)); background: var(--warning-bg); }
.exec-card--active .exec-card-n { color: var(--warning); }
.exec-card--good .exec-card-n { color: var(--success); }

.exec-group-label { font-size: var(--text-2xs); font-weight: var(--weight-bold); letter-spacing: .13em;
  text-transform: uppercase; color: var(--teal); margin: 0 0 10px; }

/* Focused view */
.focus-head { margin-bottom: 16px; }
.focus-back { font-size: var(--text-sm); }
.focus-head h1 { margin: 8px 0 2px; font-size: var(--text-xl); }
.focus-count { color: var(--muted); font-size: var(--text-sm); margin: 0; }
.focus-empty { background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); padding: 28px; text-align: center; color: var(--muted); }

/* Compact owner-review block on the landing page */
.exec-owner { background: var(--surface); border: 1px solid var(--border);
  border-left: 4px solid var(--navy-900); border-radius: var(--r);
  padding: 16px 18px; margin: 0 0 26px; box-shadow: var(--shadow-sm); }
.exec-owner h2 { margin: 0 0 10px; font-size: var(--text-lg); }
.exec-owner-row { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
  padding: 9px 0; border-top: 1px solid var(--border); }
.exec-owner-row:first-of-type { border-top: 0; }
.exec-owner-why { color: var(--muted); font-size: var(--text-sm); flex: 1 1 260px; min-width: 0; }
.exec-owner-hist { margin-top: 10px; }
.exec-owner-hist summary { cursor: pointer; font-size: var(--text-sm); color: var(--muted); }

/* =============================================================================
   REFERRAL WORKSPACE - summary, actions, history. Forms live in dialogs.
   ============================================================================= */
.ws-head { margin: 4px 0 20px; }
.ws-head h1 { margin: 6px 0 2px; font-size: var(--text-xl); letter-spacing: -.01em; }
.ws-sub { margin: 0; color: var(--muted); font-size: var(--text-sm); }

.ws-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(268px, 1fr));
  gap: 14px; margin-bottom: 22px; }
.ws-panel { background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); padding: 15px 17px; box-shadow: var(--shadow-sm); }
.ws-panel-head { display: flex; align-items: baseline; justify-content: space-between;
  gap: 10px; margin-bottom: 9px; }
.ws-panel-head h2 { margin: 0; font-size: var(--text-xs); font-weight: var(--weight-bold); letter-spacing: .1em;
  text-transform: uppercase; color: var(--teal); }
/* A two-word action must not break across lines. `.ws-row dd` sets overflow-wrap:anywhere so
 * long values wrap inside a narrow column, and that willingly split "Start next period" into
 * "Start next" / "period" the moment a row carried a date range and an action together. The
 * value still wraps; the action stays one phrase. */
.ws-panel-action { font-size: var(--text-xs); font-weight: var(--weight-semi); color: var(--teal-600);
  white-space: nowrap; }
.ws-rows { margin: 0; }
.ws-row { display: flex; gap: 10px; padding: 4px 0; font-size: var(--text-base); align-items: baseline; }
.ws-row dt { flex: 0 0 42%; color: var(--muted); font-size: var(--text-xs); margin: 0; }
.ws-row dd { flex: 1 1 auto; margin: 0; min-width: 0; overflow-wrap: anywhere; }
.ws-row--warn dd { color: var(--warning); font-weight: var(--weight-semi); }
.ws-none { color: var(--border-strong); }

/* Actions: one row of buttons, the only way a form is reached. */
.ws-actions { display: flex; flex-wrap: wrap; gap: 9px; padding: 15px 17px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); box-shadow: var(--shadow-sm); margin-bottom: 22px; }
.ws-action { display: inline-flex; align-items: center; padding: 10px 16px;
  border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--surface);
  font-size: var(--text-base); font-weight: var(--weight-semi); color: var(--navy-900); text-decoration: none;
  transition: transform .16s cubic-bezier(.2,.8,.2,1), box-shadow .16s, border-color .16s; }
.ws-action:hover { transform: translateY(-1px); border-color: var(--teal-300);
  box-shadow: var(--shadow-md); }
.ws-action--primary { background: var(--action); color: var(--action-fg); border-color: var(--action); }
.ws-action--off { opacity: .45; cursor: not-allowed; }

/* Dialogs */
.ws-dialog { border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 22px 24px; max-width: 560px; width: calc(100vw - 32px);
  /* Bound the modal to the viewport and scroll INTERNALLY, so a tall dialog (e.g. a Return
     with several correction suggestions) never pushes its submit button off-screen. */
  max-height: calc(100vh - 32px); overflow-y: auto;
  box-shadow: 0 30px 70px -20px rgba(13,44,78,.45); background: var(--surface); }
.ws-dialog::backdrop { background: rgba(13,44,78,.42); }
.ws-dialog h3 { margin: 0 0 4px; font-size: var(--text-lg); }
.ws-dialog-sub { margin: 0 0 16px; color: var(--muted); font-size: var(--text-sm); }
.ws-dialog-note { background: var(--bg); border-radius: var(--r-sm); padding: 9px 11px;
  font-size: var(--text-xs); color: var(--muted); margin: 0 0 14px; }
.ws-dialog-x { position: absolute; top: 12px; right: 14px; }
.ws-dialog-x button { border: 0; background: transparent; font-size: var(--text-xl); line-height: 1;
  color: var(--muted); cursor: pointer; padding: 2px 6px; }
.ws-dialog-x button:hover { color: var(--ink); }
.ws-form .field { display: block; margin-bottom: 13px; }
.ws-form .field-label { display: block; font-size: var(--text-xs); font-weight: var(--weight-semi);
  color: var(--ink); margin-bottom: 4px; }
.ws-form input[type="text"], .ws-form input[type="date"], .ws-form select,
.ws-form textarea { width: 100%; padding: 9px 11px; border: 1px solid var(--border);
  border-radius: var(--r-sm); font: inherit; font-size: var(--text-base); background: var(--surface); }
.ws-form select { appearance: auto; }
.ws-two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ws-form-actions { display: flex; gap: 10px; align-items: center; margin-top: 6px; }
.ws-more { margin: 0 0 13px; }
.ws-more summary { cursor: pointer; font-size: var(--text-sm); color: var(--teal-600);
  font-weight: var(--weight-semi); }
.ws-more-body { padding-top: 11px; }

/* History: collapsed by default. */
.ws-history h2 { font-size: var(--text-xs); font-weight: var(--weight-bold); letter-spacing: .1em;
  text-transform: uppercase; color: var(--teal); margin: 0 0 10px; }
.ws-hist { background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); margin-bottom: 10px; }
.ws-hist > summary { cursor: pointer; padding: 13px 17px; font-weight: var(--weight-semi);
  font-size: var(--text-base); display: flex; align-items: center; gap: 9px; }
.ws-hist[open] > summary { border-bottom: 1px solid var(--border); }
.ws-hist > *:not(summary) { padding: 4px 17px 15px; }
.ws-hist-n { display: inline-block; min-width: 21px; padding: 0 7px; border-radius: var(--r-full);
  background: var(--bg); color: var(--muted); font-size: var(--text-xs); font-weight: var(--weight-bold);
  text-align: center; }
/* The panels reused inside dialogs and history must not repaint themselves. */
.ws-dialog .panel, .ws-hist .panel { border: 0; box-shadow: none; padding: 0;
  margin: 0; background: transparent; }
.ws-dialog .panel h2, .ws-hist .panel h2 { display: none; }
.exec-owner-row .ws-more { flex-basis: 100%; }
/* The one thing to do next, named. Action buttons make the options obvious but
   not the order; a brand-new referral offers eight and needs a starting point. */
.ws-next { display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--warning-bg); border: 1px solid var(--border-warning, var(--border)); border-left: 4px solid var(--warning);
  border-radius: var(--r-sm); padding: 11px 14px; margin: 0 0 18px; font-size: var(--text-base); }
.ws-next-go { font-weight: var(--weight-semi); color: var(--teal-600); white-space: nowrap; }

/* ================= UI Polish v2 (2026-08-01) - additive: palette + spacing + components ================= */
body{ font-size: var(--text-base); line-height:1.6; -webkit-font-smoothing:antialiased; }
main{ padding:36px 24px 64px; }

.card{
  background:var(--surface);
  border:1px solid var(--border);
  border-radius: var(--r);
  box-shadow:var(--shadow-sm);
  padding:22px 24px;
}
.card + .card{ margin-top:18px; }

/* Tables: soft container, zebra, breathing room, sticky headers inside scroll */
.table-scroll{ border:1px solid var(--border); border-radius: var(--r); overflow:auto; max-height:72vh; box-shadow:var(--shadow-sm); }
th,td{ padding:13px 16px; border-bottom:1px solid var(--border); }
thead th{ background:var(--bg); color:var(--muted); font-size: var(--text-xs); text-transform:uppercase; letter-spacing:.04em; }
.table-scroll thead th{ position:sticky; top:0; z-index:1; }
tbody tr:nth-child(even){ background:var(--surface); }
tbody tr:hover{ background:var(--info-bg); }
tbody tr:last-child td{ border-bottom:0; }

/* Status badges - standardized semantic palette, pill + colored dot */
.status,.pill{ display:inline-flex; align-items:center; gap:7px; padding:4px 12px; border-radius: var(--r-full); font-size: var(--text-xs); font-weight: var(--weight-semi); line-height:1.4; }
.status::before{ content:""; width:8px; height:8px; border-radius:50%; background:currentColor; }
.status-APPROVED{ background:var(--success-bg); color:var(--success); }     /* complete */
.status-SUBMITTED{ background:var(--info-bg); color:var(--info); }          /* assigned/new */
.status-IN_REVIEW{ background:var(--info-bg); color:var(--info); }
.status-RESUBMITTED{ background:var(--warning-bg); color:var(--warning); }  /* waiting */
.status-RETURNED{ background:var(--danger-bg); color:var(--danger); }       /* action required */
.pill--good{ background:var(--success-bg); color:var(--success); }
.pill--active{ background:var(--info-bg); color:var(--info); }
.pill--warn{ background:var(--warning-bg); color:var(--warning); }
.pill--neutral,.pill--tag{ background:var(--neutral-bg); color:var(--neutral); }
.grant-pill{ padding:4px 11px; border-radius: var(--r-full); }
.grant-no{ background:var(--neutral-bg); color:var(--neutral); }

/* Buttons - navy primary, softer, subtle lift */
button,input[type=submit],a.btn{ border-radius: var(--r-sm); transition:transform .08s ease, box-shadow .15s ease, background .15s ease; }
button:hover,input[type=submit]:hover,a.btn:hover{ box-shadow:var(--shadow-md); }
button:active,a.btn:active{ transform:translateY(1px); }

/* Card / tile hover lift */
a.app-tile.app-tile-active{ transition:transform .12s ease, box-shadow .15s ease, border-color .15s ease; }
a.app-tile.app-tile-active:hover{ transform:translateY(-2px); box-shadow:var(--shadow-md); border-color:var(--teal-300); }

/* Navigation - calmer, more spacing, subtle active */
.nav-shell{ box-shadow:var(--shadow-sm); }
.portal-nav a{ padding:8px 12px; border-radius: var(--r-sm); transition:background .12s ease, color .12s ease; }
.portal-nav a:hover{ background:rgba(42,111,151,.08); }
.portal-nav a[aria-current="page"]{ background:rgba(42,111,151,.12); color:var(--navy-700); }

/* ============ WORKSPACE MODERNIZATION (Executive + Office Manager) — v0.27.5 ============
   Structure-preserving: restyles the existing exec-*/table/card markup onto the design
   tokens with enterprise spacing, hierarchy and status treatment. No markup changes. */

/* --- Page rhythm & headings --- */
main h1 { font-size: var(--text-xl); font-weight: var(--weight-bold); letter-spacing: -.01em; color: var(--ink); margin: 0 0 4px; }
main h2 { font-size: var(--text-lg); font-weight: var(--weight-bold); color: var(--ink); margin: 0 0 var(--space-3); letter-spacing: -.005em; }
main h3 { font-size: var(--text-base); font-weight: var(--weight-bold); color: var(--ink); }
main section { margin-bottom: var(--space-6); }

/* --- KPI tiles: quieter surface, stronger number, clear affordance --- */
.exec-tiles { gap: var(--space-4); grid-template-columns: repeat(auto-fit, minmax(178px, 1fr)); }
.exec-tile {
  padding: 18px 20px; border-radius: var(--r); background: var(--surface);
  border: 1px solid var(--border); box-shadow: var(--shadow-sm);
  transition: transform .12s ease, box-shadow .15s ease, border-color .15s ease;
}
a.exec-tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--teal-300); background: var(--surface); }
.exec-tile-value { font-size: var(--text-3xl); font-weight: var(--weight-bold); letter-spacing: -.02em; color: var(--ink); }
.exec-tile-label { font-size: var(--text-sm); color: var(--muted); margin-top: 2px; }
.exec-tile-sub { font-size: var(--text-2xs); color: var(--muted); opacity: .85; }
/* Status is carried by a left rule, not a full color wash - far calmer at scale */
.exec-tile--warn   { background: var(--surface); border-left: 4px solid var(--danger-accent); }
.exec-tile--warn .exec-tile-value { color: var(--danger); }
.exec-tile--active { background: var(--surface); border-left: 4px solid var(--warning-accent); }
.exec-tile--active .exec-tile-value { color: var(--warning); }
.exec-tile--good   { background: var(--surface); border-left: 4px solid var(--success-accent); }
.exec-tile--good .exec-tile-value { color: var(--success); }

/* --- Summary cards --- */
.exec-card {
  padding: 18px 20px; border-radius: var(--r); border: 1px solid var(--border);
  background: var(--surface); box-shadow: var(--shadow-sm);
  transition: transform .12s ease, box-shadow .15s ease, border-color .15s ease;
}
.exec-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--teal-300); }
.exec-card-n { font-size: var(--text-2xl); font-weight: var(--weight-bold); letter-spacing: -.02em; color: var(--ink); }
.exec-card-l { font-size: var(--text-sm); color: var(--muted); }
.exec-card-go { font-size: var(--text-xs); font-weight: var(--weight-semi); color: var(--teal-600); }
/* A zero card should recede, not compete for attention */
.exec-card--zero { opacity: .62; box-shadow: none; }
.exec-card--zero .exec-card-n { color: var(--muted); }

/* --- "Waiting on you" worklist --- */
.exec-owner { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--navy-700);
  border-radius: var(--r); padding: 20px 22px; box-shadow: var(--shadow-sm); }
.exec-owner-row { padding: 12px 0; border-bottom: 1px solid var(--border); }
.exec-owner-row:last-child { border-bottom: 0; }
.exec-owner-why { color: var(--muted); font-size: var(--text-sm); }
.exec-count { display: inline-flex; align-items: center; justify-content: center; min-width: 24px; height: 24px;
  padding: 0 8px; border-radius: var(--r-full); background: var(--danger-bg); color: var(--danger);
  font-size: var(--text-xs); font-weight: var(--weight-bold); margin-left: 8px; }

/* --- Metrics table --- */
.exec-metrics { font-size: var(--text-sm); }
.exec-metrics th { color: var(--muted); font-size: var(--text-2xs); text-transform: uppercase; letter-spacing: .05em; }
.exec-metric-value { font-size: var(--text-lg); color: var(--ink); }
.exec-metric-n { color: var(--muted); font-size: var(--text-xs); }
.exec-metric-none { color: var(--muted); font-style: italic; }

/* --- Progressive disclosure: quiet, consistent, everywhere --- */
details > summary { cursor: pointer; font-size: var(--text-sm); font-weight: var(--weight-semi); color: var(--teal-600);
  padding: 8px 0; }
details > summary:hover { color: var(--navy-700); }

/* --- Action placement: primary action reads as primary --- */
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
a.btn, button { font-weight: var(--weight-semi); }
a.pill-link { color: var(--teal-600); font-weight: var(--weight-semi); }
a.pill-link:hover { color: var(--navy-700); }

/* --- Filters / toolbars --- */
.filters, .toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
  padding: 14px 16px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-sm); margin-bottom: var(--space-4); box-shadow: var(--shadow-sm); }

/* --- Empty states read as calm, not broken --- */
.empty-state { padding: 40px 24px; color: var(--muted); }
.empty-state strong { color: var(--ink); font-size: var(--text-lg); }


/* v0.27.10 - PDF preview. iframe replaces object (see intakeViews.pdfEmbed). */
.pdf-embed { display: flex; flex-direction: column; height: 100%; min-height: 420px; }
.pdf-embed .pdf-frame { flex: 1 1 auto; width: 100%; min-height: 420px; border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--surface); }
.pdf-embed-fallback { font-size: var(--text-xs); color: var(--muted); margin: 8px 0 0; }
.pdf-embed-fallback a { color: var(--navy-700, var(--navy)); font-weight: var(--weight-semi); }


/* v0.28.0 - the centrally injected page heading (see views.layout).
   Sized from the type scale so it matches every hand-written <h1> already in the app. */
.page-title{font-family:var(--font-brand);font-size:var(--text-2xl);font-weight:var(--weight-semi);
  line-height:var(--leading-tight);color:var(--ink);margin:0 0 var(--space-5)}


/* ============================================================================
   COMPONENT LAYER (Milestone B)
   Two naming conventions grew side by side - `btn-primary` and `btn--ghostline` -
   plus `.cta` and `.btn--cta` as separate rules for the same idea. Rather than
   rename classes across 150+ call sites (churn, and every rename is a chance to
   break a selector a test depends on), the legacy names are ALIASED onto one
   canonical set here. Markup is untouched; the visual language is now single.
   ========================================================================= */

/* --- Buttons: one base, four variants ------------------------------------ */
.btn, button, input[type=submit], a.btn {
  font-family: var(--font-ui);
  border-radius: var(--r-sm);
}
.btn-primary, a.btn:not(.btn-secondary):not(.btn-link), .btn--primary {
  background: var(--action); color: var(--action-fg); border: 1px solid var(--action);
}
.btn-primary:hover, a.btn:not(.btn-secondary):not(.btn-link):hover, .btn--primary:hover {
  background: var(--action-hover); border-color: var(--action-hover);
}
.btn-secondary, a.btn.btn-secondary, .btn--ghostline {
  background: var(--surface); color: var(--navy-800); border: 1px solid var(--border-strong);
}
.btn-secondary:hover, a.btn.btn-secondary:hover { background: var(--surface-sunk); }
.btn-sm, .btn--sm { font-size: var(--text-sm); padding: var(--space-2) var(--space-3); }
.btn-large { padding: var(--space-3) var(--space-5); font-size: var(--text-base); }
.btn:disabled, button:disabled, .btn[aria-disabled="true"] {
  opacity: .55; cursor: not-allowed; transform: none;
}

/* --- Cards: five idioms, one geometry ------------------------------------ */
.panel, .ws-panel, .split-pane, .stat-card, .rcard, .exec-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--shadow-sm);
}

/* --- Empty states: three variants, one voice ----------------------------- */
.empty-inline, .queue-empty, .empty-state {
  color: var(--muted); font-size: var(--text-sm); line-height: var(--leading-normal);
}

/* --- Alerts / banners ---------------------------------------------------- */
.notice-banner, .error-banner, .warn-banner {
  border-radius: var(--r-sm); padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm); border-left: 4px solid transparent;
}
.notice-banner { background: var(--success-bg); color: var(--success); border-left-color: var(--success); }
.error-banner  { background: var(--danger-bg);  color: var(--danger);  border-left-color: var(--danger); }
.warn-banner   { background: var(--warning-bg); color: var(--warning); border-left-color: var(--warning); }

/* --- Inputs: one resting border, one focus treatment --------------------- */
input[type=text], input[type=email], input[type=password], input[type=date],
input[type=time], input[type=search], input[type=number], input[type=file],
textarea, select {
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  font-family: var(--font-ui);
  font-size: var(--text-base);
  color: var(--ink);
  background: var(--surface);
}
input:focus-visible, textarea:focus-visible, select:focus-visible,
button:focus-visible, a:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* --- Tables -------------------------------------------------------------- */
.data-table th { background: var(--surface-sunk); color: var(--muted);
  font-size: var(--text-2xs); letter-spacing: var(--tracking-caps); text-transform: uppercase;
  font-weight: var(--weight-bold); }
.data-table td { font-variant-numeric: tabular-nums; }

/* =========================================================================
   ORGANIZATION SETUP — modernization
   Same navy palette and tokens as the rest of the app; no new theme, no
   gradients, no decorative cards. The field-width fix is global (see the
   input rules above); the polish here is scoped to the auth/setup screens
   so it reads as current without becoming a one-off design.
   ========================================================================= */

/* Brand block: prominent but elegant - a hair more presence, calmer sub. */
.auth-brand-mark { box-shadow: var(--shadow-sm); }
.auth-brand-name { font-family: var(--font-brand); color: var(--navy-900); letter-spacing: -0.01em; }
.auth-brand-sub  { color: var(--navy-600); letter-spacing: var(--tracking-wide); }

/* The setup card: the product's front door. A single soft elevation and
   real internal breathing room - not a bare form, not a busy panel. */
.auth-screen .login-box.setup-box {
  padding: 32px 32px 28px;
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--shadow-md);
}
.setup-box h2 { font-size: var(--text-xl); color: var(--navy-900); margin-bottom: 6px; }
.setup-box > .form-note { color: var(--muted); line-height: var(--leading-normal); }
.setup-box .form-section label { color: var(--ink); font-weight: var(--weight-semi); }

/* Controls on the auth/setup screens: full width, consistent height, a
   control-grade (3:1) border, and a navy focus ring. The brand carried
   through the states rather than bolted on as an accent colour. */
.auth-screen input[type=text],
.auth-screen input[type=email],
.auth-screen input[type=password] {
  padding: 11px 13px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink);
}
.auth-screen input[type=text]:focus,
.auth-screen input[type=email]:focus,
.auth-screen input[type=password]:focus {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgba(20,64,110,.16);
  outline: none;
}
.auth-screen input::placeholder { color: var(--navy-500); opacity: .7; }

/* Primary action: full-width, taller, unmistakably the primary, with a
   clear hover, a navy focus ring, and a real disabled state (it locks on
   submit). Cleaner radius to match the buttons and cards elsewhere. */
.setup-box .btn-large {
  width: 100%;
  padding: 13px 18px;
  margin-top: 8px;
  border-radius: var(--r-sm);
  background: var(--action);
  border: 1px solid var(--action);
  color: var(--action-fg);
  font-size: var(--text-base);
  font-weight: var(--weight-semi);
  letter-spacing: .01em;
  box-shadow: var(--shadow-sm);
}
.setup-box .btn-large:hover { background: var(--action-hover); border-color: var(--action-hover); }
.setup-box .btn-large:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(20,64,110,.32); }
.setup-box .btn-large:disabled { background: var(--muted); border-color: var(--muted); opacity: .6; box-shadow: none; }

/* --- Kinnser import confirmation: document-read context + reject disclosure ---- */
.read-from-doc { background: var(--surface-sunk); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: 12px 14px; margin: 0 0 16px; }
.read-from-doc h3 { margin: 0 0 8px; font-size: var(--text-sm); color: var(--navy-700);
  font-weight: var(--weight-semi); }
.read-from-doc dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 3px 16px; }
.read-from-doc dl > div { display: contents; }
.read-from-doc dt { color: var(--muted); font-size: var(--text-sm); }
.read-from-doc dd { margin: 0; color: var(--ink); font-size: var(--text-sm); font-weight: var(--weight-medium); }
.reject-block { margin-top: 18px; border-top: 1px solid var(--border); padding-top: 12px; }
.reject-block summary { cursor: pointer; color: var(--muted); font-size: var(--text-sm); font-weight: var(--weight-semi); }
.reject-block form { margin-top: 10px; }

/* --- QA landing: simple work queue (Kinnser-simple on entry) ------------------ */
.qa-summary { display: flex; gap: 10px; flex-wrap: wrap; margin: 0 0 14px; }
.qa-chip { display: inline-flex; align-items: baseline; gap: 6px; text-decoration: none;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-full);
  padding: 6px 14px; font-size: var(--text-sm); font-weight: var(--weight-semi); color: var(--muted); }
.qa-chip b { color: var(--ink); font-size: var(--text-base); }
.qa-chip:hover { border-color: var(--border-strong); }
.qa-chip--on { background: var(--navy-800); border-color: var(--navy-800); color: var(--on-brand); }
.qa-chip--on b { color: var(--on-brand); }
.qa-queue-filter { display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: 10px 12px; margin-bottom: 16px; }
.qa-queue-filter input[type=search] { flex: 1 1 240px; min-width: 200px; max-width: 420px; margin: 0; }
.qa-queue-filter select { margin: 0; }
.qa-queue-filter .qa-filter span { display: none; }
.qa-more-filters { flex-basis: 100%; margin-top: 4px; }
.qa-more-filters > summary { cursor: pointer; color: var(--muted); font-size: var(--text-sm);
  font-weight: var(--weight-semi); }
.qa-more-body { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
.qa-more-body .qa-filter { display: flex; flex-direction: column; gap: 3px; font-size: var(--text-xs); color: var(--muted); }

/* --- QA review: PDF | Items requiring attention ------------------------------- */
.qa-review-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(320px, 1fr);
  gap: 20px; align-items: start; }
.qa-review-doc { position: sticky; top: 12px; }
.qa-pdf-frame { width: 100%; height: 78vh; border: 1px solid var(--border-strong);
  border-radius: var(--r-sm); background: var(--surface); }
.qa-pdf-fallback { margin: 6px 2px 0; }
.qa-side-h { margin: 0 0 10px; font-size: var(--text-lg); color: var(--navy-900); }
.qa-scan { border: 1px solid var(--border); border-left: 4px solid var(--neutral-accent);
  border-radius: var(--r-sm); padding: 10px 12px; margin-bottom: 14px; background: var(--surface); }
.qa-scan-timing { margin: 4px 0 2px; }
.qa-scan--blocked { border-left-color: var(--danger); background: var(--danger-bg); }
.qa-scan--needs_review { border-left-color: var(--warning); background: var(--warning-bg); }
.qa-scan--clear { border-left-color: var(--success-accent); }
.qa-scan--not_scanned { border-left-color: var(--neutral-accent); }
.qa-scan--not_configured { border-left-color: var(--warning); background: var(--warning-bg); }
.qa-scan--profile_not_configured { border-left-color: var(--warning); background: var(--warning-bg); }
.qa-scan-head { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.qa-scan-list { margin: 8px 0 0; padding-left: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; }
.qa-scan-list li { font-size: var(--text-sm); display: flex; gap: 8px; align-items: baseline; }
/* OT QA profile engine - exceptions-first scan pane */
.qa-scan-profile { font-size: var(--text-sm); color: var(--navy-700); font-weight: var(--weight-semi); margin: 2px 0 6px; }
.qa-scan-verdict { font-size: var(--text-sm); font-weight: var(--weight-semi); }
.qa-scan-verdict--blocked { color: var(--danger); }
.qa-scan-verdict--needs_review { color: var(--warning); }
.qa-scan-verdict--clear { color: var(--success-accent); }
.qa-scan-count { font-weight: var(--weight-bold); color: var(--navy-900); margin: 6px 0 4px; }
.qa-scan-group { margin-top: 10px; }
.qa-scan-h4 { margin: 6px 0 6px; font-size: var(--text-sm); color: var(--navy-900); text-transform: none; }
.qa-scan-note { font-size: var(--text-sm); color: var(--navy-700); margin: 6px 0 0; }
.qa-scan-summary { font-size: var(--text-sm); color: var(--success-accent); margin: 10px 0 0; font-weight: var(--weight-semi); }
.qa-ex-list { margin: 6px 0 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; }
.qa-ex { border: 1px solid var(--border); border-radius: var(--r-sm); padding: 8px 10px; background: var(--surface); }
.qa-ex--bad { border-left: 3px solid var(--danger); }
.qa-ex--warn { border-left: 3px solid var(--warning); }
.qa-ex--neutral { border-left: 3px solid var(--neutral-accent); }
.qa-ex-h { display: flex; gap: 8px; align-items: center; font-size: var(--text-sm); }
.qa-ex-h strong { font-size: var(--text-xs); letter-spacing: .02em; text-transform: uppercase; color: var(--navy-900); }
.qa-dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; display: inline-block; }
.qa-dot--bad { background: var(--danger); }
.qa-dot--warn { background: var(--warning); }
.qa-dot--neutral { background: var(--neutral-accent); }
.qa-ex-why { margin: 4px 0 0; font-size: var(--text-sm); color: var(--navy-800); }
.qa-ex-ev { margin: 4px 0 0; font-size: var(--text-xs); color: var(--navy-600); font-style: italic; }
.qa-more { margin-top: 8px; }
.qa-more > summary { cursor: pointer; font-size: var(--text-sm); color: var(--navy-700); }

/* Referral Log — e-referral extracted-fields panel (original PDF beside PCI's reading). */
.eref-flags { margin: 0 0 14px; }
.eref-flag { margin: 4px 0; padding: 8px 11px; border-radius: var(--r-sm);
  background: var(--surface); border-left: 3px solid var(--warning);
  font-size: var(--text-sm); color: var(--navy-900); }
.eref-fields { display: flex; flex-direction: column; gap: 8px; margin: 0 0 14px; }
.eref-field { border: 1px solid var(--border); border-radius: var(--r-sm); padding: 8px 10px; background: var(--surface); }
.eref-field--review { border-left: 3px solid var(--warning); }
.eref-field-label { font-size: var(--text-2xs, var(--text-xs)); text-transform: uppercase; letter-spacing: .03em; color: var(--navy-600); }
.eref-field-value { display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  font-size: var(--text-sm); color: var(--navy-900); margin-top: 2px; }

/* Correction-suggestion drafts in the Return dialog (QA-CORRECTION-SUGGESTIONS).
   Each is include-by-default + editable; the reviewer curates one combined message. */
.qa-return-lead { font-size: var(--text-sm); color: var(--navy-700); margin: 0 0 12px; }
.qa-sugg-list { display: flex; flex-direction: column; gap: 12px; margin: 0 0 14px; }
.qa-sugg { border: 1px solid var(--border); border-left: 3px solid var(--neutral-accent);
  border-radius: var(--r-sm); padding: 10px 12px; background: var(--surface); }
.qa-sugg-h { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; cursor: pointer; margin: 0 0 8px; }
.qa-sugg-h input[type="checkbox"] { flex: 0 0 auto; }
.qa-sugg-h strong { font-size: var(--text-xs); letter-spacing: .02em; text-transform: uppercase; color: var(--navy-900); }
.qa-sugg-text { width: 100%; box-sizing: border-box; resize: vertical;
  font: inherit; font-size: var(--text-sm); color: var(--navy-800);
  border: 1px solid var(--border); border-radius: var(--r-sm); padding: 8px 10px; background: var(--bg); }
.qa-sugg-text:focus { outline: 2px solid var(--focus, var(--warning)); outline-offset: 1px; }
/* A de-selected suggestion visibly recedes, so "what will be sent" reads at a glance. */
.qa-sugg:has(input[type="checkbox"]:not(:checked)) { opacity: .5; }
.qa-sugg:has(input[type="checkbox"]:not(:checked)) .qa-sugg-text { background: var(--surface); }

/* Acknowledge-to-approve box in the Approve dialog (DEC-APPROVE-BLOCKING). Warning-toned,
   so the reviewer registers that PCI flagged something critical before intentionally approving. */
.qa-ack { border: 1px solid var(--border-danger, var(--danger)); border-left: 3px solid var(--danger);
  border-radius: var(--r-sm); padding: 10px 12px; margin: 0 0 14px; background: var(--surface); }
.qa-ack-lead { margin: 0 0 8px; font-size: var(--text-sm); color: var(--navy-900); }
.qa-ack-list { margin: 0 0 10px; padding-left: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; }
.qa-ack-list li { font-size: var(--text-sm); color: var(--navy-800); }
.qa-ack-check { display: flex; gap: 9px; align-items: flex-start; cursor: pointer;
  font-size: var(--text-sm); color: var(--navy-900); font-weight: var(--weight-medium); }
.qa-ack-check input[type="checkbox"] { flex: 0 0 auto; margin-top: 2px; }
@media (max-width: 900px) {
  /* `minmax(0, 1fr)`, NOT `1fr` — the same guard the desktop tracks above already use.
     A bare `1fr` track leaves its item at the default `min-width: auto`, so the item refuses
     to shrink below its content and wide content pushes the whole PAGE sideways instead of
     scrolling inside its own container. The goal-comparison table is what exposed it: at
     375px the review page's scrollWidth was 800 against a 375 client width, and it drops to
     exactly 375 with this. It also resolves a smaller pre-existing overflow from the same
     cause (449 before the goal table existed at all). Measured on the live build. */
  .qa-review-grid { grid-template-columns: minmax(0, 1fr); }
  .qa-review-doc { position: static; }
  .qa-pdf-frame { height: 60vh; }
}

/* ── PHI Readiness (Administration → Tools) ─────────────────────────────── */
.phi-verdict { display:flex; align-items:center; gap:10px; padding:14px 16px; border-radius:var(--r-xs); font-weight:var(--weight-bold); font-size:var(--text-lg); margin:2px 0 10px; }
.phi-verdict.ready    { background:var(--success-bg); color:var(--success); }
.phi-verdict.notready { background:var(--danger-bg);  color:var(--danger); }
.phi-pill { display:inline-block; padding:3px 10px; border-radius:var(--r-full); font-size:var(--text-xs); font-weight:var(--weight-semi); white-space:nowrap; }
.phi-pill.ok   { background:var(--success-bg); color:var(--success); }
.phi-pill.warn { background:var(--warning-bg); color:var(--warning); }
.phi-pill.fail { background:var(--danger-bg);  color:var(--danger); }
.phi-meta { color:var(--muted); font-size:var(--text-sm); margin:0 0 10px; }
.phi-fix  { font-size:var(--text-sm); }

/* ── Referral Log — editable e-referral fields + 3-state status ─────────────── */
.pill--muted { background: var(--neutral-bg); color: var(--muted); }
.eref-field-label { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.eref-input { width: 100%; box-sizing: border-box; padding: 6px 8px; font-size: var(--text-sm);
  border: 1px solid var(--border); border-radius: var(--r-xs); background: var(--bg); color: var(--ink); }
.eref-input:disabled { background: var(--neutral-bg); color: var(--muted); }
.eref-field--not_in_document { border-left: 3px solid var(--border); }
.eref-field--unrecognized  { border-left: 3px solid var(--warning); }
.eref-field--partial       { border-left: 3px solid var(--warning); }
.eref-field--no_text       { border-left: 3px solid var(--danger); }
.eref-field--found, .eref-field--manual { border-left: 3px solid var(--success); }
.eref-reprocess { display: flex; align-items: center; gap: 10px; margin: 0 0 12px; flex-wrap: wrap; }
.eref-edit-actions { display: flex; align-items: center; gap: 10px; margin: 4px 0 14px; flex-wrap: wrap; }
/* Imported e-referrals awaiting review, surfaced inside the ONE referral workspace so the office
   never has to decide which of two areas an arriving referral lives in. */
.intake-strip { display: flex; align-items: center; gap: 14px; margin: 0 0 16px;
  padding: 12px 16px; text-decoration: none; color: inherit;
  background: var(--warning-bg); border: 1px solid var(--border-warning);
  border-left: 4px solid var(--warning); border-radius: var(--radius); }
.intake-strip:hover, .intake-strip:focus-visible { background: var(--surface); }
.intake-strip-count { flex: 0 0 auto; min-width: 2rem; height: 2rem; padding: 0 .4rem;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: var(--weight-bold); font-variant-numeric: tabular-nums; color: var(--on-brand);
  background: var(--warning); border-radius: var(--r-full); }
.intake-strip-text { flex: 1 1 auto; display: flex; flex-direction: column; gap: 2px; }
.intake-strip-go { flex: 0 0 auto; font-weight: var(--weight-semi); color: var(--warning); white-space: nowrap; }

/* Typed date entry (date of birth, certification period) — see src/dateFields.js for why a
   date the user knows from memory is typed rather than picked from a calendar. */
.dob-field { display: block; margin: 0 0 10px; }
.dob-field .field-label { display: flex; align-items: baseline; gap: 8px; margin-bottom: 4px; }
.dob-format { font-size: var(--text-xs); font-weight: var(--weight-normal); color: var(--muted);
  letter-spacing: .04em; text-transform: none; }
.dob-input { width: 100%; max-width: 15rem; box-sizing: border-box; padding: 8px 10px;
  font-size: var(--text-base); font-variant-numeric: tabular-nums; letter-spacing: .04em;
  border: 1px solid var(--border); border-radius: var(--r-xs); background: var(--bg); color: var(--ink); }
.dob-input:disabled { background: var(--neutral-bg); color: var(--muted); }
.dob-hint { margin: 4px 0 0; }
.dob-error { margin: 4px 0 0; font-size: var(--text-sm); color: var(--danger); }
.dob-jump { margin: 6px 0 0; }
.dob-jump > summary { cursor: pointer; font-size: var(--text-sm); color: var(--navy-700); }
.dob-jump-body { display: flex; flex-wrap: wrap; gap: 10px; margin: 8px 0 0; }
.dob-jump-label { display: flex; flex-direction: column; gap: 4px;
  font-size: var(--text-xs); color: var(--navy-600); text-transform: uppercase; letter-spacing: .03em; }
.dob-jump-label select { padding: 6px 8px; font-size: var(--text-sm);
  border: 1px solid var(--border); border-radius: var(--r-xs); background: var(--bg); color: var(--ink); }
.cert-two { display: flex; flex-wrap: wrap; gap: 16px; }
.cert-col { flex: 1 1 15rem; min-width: 0; }
.cert-calc { margin: 4px 0 0; }
.cert-override { display: block; margin: 8px 0 0; }
.cert-reason { width: 100%; box-sizing: border-box; padding: 6px 8px; font-size: var(--text-sm);
  border: 1px solid var(--border); border-radius: var(--r-xs); background: var(--bg); color: var(--ink); }

/* ============================================================================
   GUIDED REFERRAL JOURNEY (Jose 2026-08-12) — card states, workflow summary,
   teaching lines, and the post-save Continue affordance.
   ============================================================================ */
.pill--bad { background: var(--danger-bg); color: var(--danger); }
.ws-guide { background: var(--surface, var(--bg)); border: 1px solid var(--border);
  border-radius: var(--r-sm, var(--r-xs)); padding: 12px 16px; margin-bottom: 16px; }
.ws-guide-stage { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.ws-guide-progress { font-size: var(--text-sm); color: var(--muted); }
.ws-guide .ws-next { margin: 0; }
.ws-guide-meta { margin: 6px 0 0; font-size: var(--text-sm); color: var(--muted); }
.ws-guide-meta strong { color: var(--ink); font-weight: var(--weight-semi); }
.ws-state { margin-left: auto; white-space: nowrap; }
.ws-panel-head .ws-state + .ws-panel-action { margin-left: 10px; }
.ws-teach { margin: 2px 0 6px; font-size: var(--text-xs); color: var(--muted); }
.ws-why { margin: 0 0 8px; font-size: var(--text-sm); padding: 6px 10px; border-radius: var(--r-xs); }
.ws-why--attention { background: var(--warning-bg); color: var(--warning); }
.ws-why--current { background: var(--info-bg); color: var(--info); }
.ws-why--blocked { background: var(--danger-bg); color: var(--danger); }
.ws-why--later, .ws-why--complete { background: var(--neutral-bg); color: var(--muted); }
/* The current card is visibly THE place to look — accent rail, same language as the sidebar. */
.ws-panel--current { border-left: 3px solid var(--info); }
.ws-panel--blocked { opacity: .92; }
.ws-panel:focus-visible, .ws-panel:focus { outline: 2px solid var(--info); outline-offset: 2px; }
.ws-continue { display: inline-block; margin-left: 10px; font-weight: var(--weight-semi);
  color: var(--info); text-decoration: underline; }
.ws-continue:focus-visible, .ws-next-go:focus-visible, .ws-panel-action:focus-visible {
  outline: 2px solid var(--info); outline-offset: 2px; }
/* -------- In-card forms (Jose 2026-08-12): dialogs render IN FLOW inside their card -------- */
.ws-card-form { margin-top: 10px; border-top: 1px solid var(--border); padding-top: 10px; }
.ws-card-form dialog.ws-dialog { position: static; display: block; width: 100%; max-width: none;
  margin: 0 0 12px; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--r-xs);
  background: var(--surface, var(--bg)); box-shadow: none; }
.ws-card-form dialog.ws-dialog:not([open]) { display: none; }
.ws-card-form .ws-dialog-x { display: none; }   /* the card collapses via its header, not an X */
.ws-card-toggle { display: flex; align-items: center; gap: 8px; background: none; border: 0;
  padding: 0; cursor: pointer; font: inherit; color: inherit; text-align: left; }
.ws-card-toggle h2 { margin: 0; }
.ws-card-toggle:focus-visible { outline: 2px solid var(--info); outline-offset: 2px; }
.ws-chevron { color: var(--muted); font-size: var(--text-sm); }
.ws-tool { border: 1px solid var(--border); border-radius: var(--r-xs); margin: 0 0 8px; }
.ws-tool > summary { cursor: pointer; padding: 8px 12px; font-weight: var(--weight-semi);
  color: var(--navy-600); }
.ws-tool > summary:focus-visible { outline: 2px solid var(--info); outline-offset: 2px; }
.ws-tool[open] > summary { border-bottom: 1px solid var(--border); }
.ws-tool > *:not(summary) { padding: 0 12px 8px; }
.ws-exceptions { margin-top: 14px; border: 1px dashed var(--warning); border-radius: var(--r-xs);
  padding: 10px 12px; background: var(--warning-bg); }
.ws-exceptions h4 { margin: 0 0 2px; font-size: var(--text-sm); text-transform: uppercase;
  letter-spacing: .04em; color: var(--warning); }
.ws-exceptions .ws-tool { background: var(--bg); }
.ws-missing { margin: 4px 0 8px 18px; padding: 0; }
.ws-missing li { margin: 2px 0; }
.ws-utility { display: flex; gap: 14px; align-items: center; margin: 0 0 10px; }
.ws-utility-link { font-size: var(--text-sm); text-decoration: underline; color: var(--navy-600); }
.ws-utility-link:focus-visible { outline: 2px solid var(--info); outline-offset: 2px; }

.ws-fulog { margin-top: 10px; border-top: 1px solid var(--border); padding-top: 8px; }
/* The three stages of a follow-up entry — the contact, the outcome, the next step — read as
   three visibly separate groups, in the form AND in each logged entry. */
.fu-sec { border: 1px solid var(--border); border-radius: var(--r-xs); padding: 10px 12px; margin: 0 0 12px; }
.fu-sec legend { font-size: var(--text-xs); font-weight: var(--weight-semi);
  color: var(--navy-600); text-transform: uppercase; letter-spacing: .03em; padding: 0 6px; }
.fu-outcome { border-top: 1px dashed var(--border); margin-top: 6px; padding-top: 6px; }
.fu-next { border-top: 1px dashed var(--border); margin-top: 6px; padding-top: 6px; }
.ws-fulog > summary { cursor: pointer; font-size: var(--text-sm); color: var(--navy-600); }
.ws-fulog > summary:focus-visible { outline: 2px solid var(--info); outline-offset: 2px; }

/* Structured patient name (Jose 2026-08-11): legal first / middle (optional) / legal last as
   three boxes wherever a person enters or confirms a name — review screen and the workspace
   dialogs. Wraps to a single column when narrow. */
.eref-name-parts { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
/* Address: two full-width lines, then city / state / ZIP on one row. */
.eref-addr-parts { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 10px; }
.eref-addr-wide { grid-column: 1 / -1; }
@media (max-width: 700px) { .eref-addr-parts { grid-template-columns: 1fr; } }
.eref-name-part { min-width: 0; }
.eref-sublabel { display: block; margin-bottom: 2px; font-size: var(--text-2xs, var(--text-xs));
  text-transform: uppercase; letter-spacing: .03em; color: var(--navy-600); }
@media (max-width: 700px) { .eref-name-parts { grid-template-columns: 1fr; } }
.field-group { display: grid; gap: 8px; }

/* Requested-discipline picker — a referral can request more than one discipline, so this is a
   multi-select, not a single choice. Mirrors the manual-creation form's PT/OT/ST checkboxes so
   both ways of creating a referral offer the same control. */
.eref-disc { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.eref-disc-opt { display: flex; align-items: center; gap: 8px; padding: 4px 0; margin: 0;
  font-size: var(--text-sm); font-weight: var(--weight-normal); cursor: pointer; color: var(--ink); }
.eref-disc-opt input { width: 16px; height: 16px; margin: 0; cursor: pointer; }
.eref-disc-opt input:disabled { cursor: default; }
.eref-disc-opt input:disabled + span { color: var(--muted); }
.eref-disc-opt b { color: var(--navy-700); }

/* ============================================================================
   APPLICATION SHELL — persistent left sidebar + slim top bar (approved REV 2.3)
   ============================================================================
   Jose 2026-08-11: "Replace the two-row top navigation with a persistent left
   sidebar." An Administrator was seeing TEN primary links wrapped onto two rows.
   The sidebar treatment (236px, navy ground, accent rail on the current item,
   outlined global action at the top) is taken from PCI_PROTOTYPE_REV2-3.html.

   These rules come LAST on purpose: they re-purpose .portal-nav, which the old
   horizontal bar also styles. Ordering, not !important, is what wins here —
   keep this block at the end of the file. */

.app-shell { display: flex; align-items: flex-start; gap: 0; min-height: calc(100vh - 70px); }
.app-shell--bare { display: block; }

.app-side {
  flex: 0 0 236px; width: 236px; align-self: stretch;
  background: var(--navy-800); color: var(--on-brand);
  padding: 16px 12px; display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 70px; max-height: calc(100vh - 70px); overflow-y: auto;
}
/* The global action: outlined rather than filled, so the ONE filled primary
   button on a screen is still the page's own main action, not the chrome's. */
.side-action {
  display: block; text-align: center; text-decoration: none;
  border: 1.5px solid var(--accent); color: var(--on-brand); background: transparent;
  border-radius: var(--r-sm); padding: 10px 12px; margin-bottom: 12px;
  font-weight: var(--weight-semi); font-size: var(--text-sm);
}
.side-action:hover, .side-action:focus-visible { background: var(--accent); color: var(--on-brand); }

.app-side .portal-nav { display: flex; flex-direction: column; align-items: stretch;
  gap: 2px; flex-wrap: nowrap; margin: 0; padding: 0; list-style: none; }
.app-side .portal-nav a {
  display: block; position: relative; padding: 9px 12px; border-radius: var(--r-sm);
  color: var(--side-ink); font-size: var(--text-sm); font-weight: var(--weight-medium);
  text-decoration: none; white-space: normal; background: none;
}
.app-side .portal-nav a:hover { background: var(--side-hover); color: var(--on-brand); }
.app-side .portal-nav a.is-current,
.app-side .portal-nav a[aria-current="page"] {
  background: var(--side-active); color: var(--on-brand); font-weight: var(--weight-bold);
}
.app-side .portal-nav a.is-current::before,
.app-side .portal-nav a[aria-current="page"]::before {
  content: ""; position: absolute; left: -4px; top: 8px; bottom: 8px;
  width: 3px; border-radius: var(--r-xs); background: var(--accent);
}
.app-side .portal-nav a:focus-visible { outline: 2px solid var(--side-focus); outline-offset: 2px; }

.app-shell > #main-content { flex: 1 1 auto; min-width: 0; padding: 26px 30px 60px; }
.app-shell--bare > #main-content { padding: 0; }

/* Top bar now carries ONLY logo · PHI status · who + role · Sign out. */
.phi-pill {
  display: inline-block; padding: 3px 10px; border-radius: var(--r-full);
  font-size: var(--text-2xs); font-weight: var(--weight-bold); letter-spacing: .04em;
  background: var(--neutral-bg); color: var(--muted); white-space: nowrap;
}
.phi-pill--ok { background: var(--success-bg); color: var(--success); }
.phi-pill--warn { background: var(--warning-bg); color: var(--warning); }
.nav-shell .portal-bar { max-width: none; padding: 0 20px; height: 70px; }

/* Narrow screens: the sidebar becomes a scrollable strip above the content
   rather than disappearing, so no destination becomes unreachable. */
@media (max-width: 860px) {
  /* align-items must STRETCH here: the desktop shell's flex-start, kept in the column
     layout, sized the nav strip to max-content (617px at 375px viewport) and produced a
     page-level horizontal scrollbar — found at 375px in the live hands-on run (§20). The
     strip itself scrolls internally; the page never does. */
  .app-shell { flex-direction: column; align-items: stretch; }
  .app-side { position: static; flex: 0 0 auto; width: auto; min-width: 0; max-width: 100%;
    max-height: none;
    align-self: auto; flex-direction: row; align-items: center; gap: 8px;
    overflow-x: auto; padding: 10px 12px; }
  .side-action { margin: 0; flex: 0 0 auto; }
  .app-side .portal-nav { flex-direction: row; gap: 4px; }
  .app-side .portal-nav a { white-space: nowrap; }
  .app-side .portal-nav a.is-current::before,
  .app-side .portal-nav a[aria-current="page"]::before { display: none; }
  /* Same clamp as the nav strip: without it the main column stretches to its
     min-content (the 15-column referral table) and the PAGE scrolls sideways —
     the table's own .table-scroll wrapper is what should scroll (§20). */
  .app-shell > #main-content { padding: 18px 16px 60px; min-width: 0; max-width: 100%;
    width: 100%; box-sizing: border-box; }
}

/* Workspace header actions — a real, sized primary button pair, replacing the tiny
   "Add referral" text link Jose flagged. */
.ws-head-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.btn-lg { padding: 11px 18px; font-size: var(--text-base); font-weight: var(--weight-semi);
  border-radius: var(--r-sm); min-height: 42px; display: inline-flex; align-items: center; }
/* Sub-navigation INSIDE a workspace (QA History, Insights) — these are destinations within
   the QA Dashboard, deliberately not competing top-level nav entries. */
.qa-subnav { display: flex; gap: 16px; flex-wrap: wrap; margin: 0 0 16px; font-size: var(--text-sm); }
.qa-subnav a { color: var(--navy-700); font-weight: var(--weight-medium); }
/* LB-2 batch upload results: one row per file, name | outcome | message | action; stacks on phones. */
.qa-batch { margin: 0 0 16px; }
.qa-batch-title { margin: 0 0 4px; font-size: var(--text-base); }
.qa-batch-list { list-style: none; margin: 8px 0 0; padding: 0; }
.qa-batch-row { display: grid; grid-template-columns: minmax(0, 2fr) auto minmax(0, 3fr) auto; gap: 10px; align-items: center;
  padding: 6px 0; border-top: 1px solid var(--border); }
.qa-batch-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 640px) {
  .qa-batch-row { grid-template-columns: minmax(0, 1fr) auto; }
  .qa-batch-msg, .qa-batch-act { grid-column: 1 / -1; }
}

/* An error raised by a save that was REJECTED, shown inside the dialog that raised it so the
   person's typing survives (see src/dateFields.js for why this is not a redirect). */
.form-error-banner { margin: 0 0 12px; padding: 10px 12px; border-radius: var(--r-xs);
  background: var(--danger-bg); border: 1px solid var(--border-danger); color: var(--danger);
  font-size: var(--text-sm); font-weight: var(--weight-medium); }

/* An already-decided e-referral. The fields below it are a read-only RECORD of what was
   confirmed; without this the screen reads as "everything is mysteriously locked". */
.eref-decided { display: flex; flex-direction: column; gap: 3px; margin: 0 0 14px;
  padding: 12px 14px; border-radius: var(--r-sm);
  background: var(--info-bg); border: 1px solid var(--border-info); color: var(--ink);
  font-size: var(--text-sm); }
.eref-decided strong { color: var(--info); }

/* PERSISTENT REVIEW FOOTER — the finishing action used to be the last item in a column of
   twenty-one field cards, so on a normal desktop it sat below the fold and the screen offered
   no visible way to complete the task. Pinned to the bottom of the viewport and OUTSIDE the
   scrolling field list, so it cannot disappear at any scroll position, zoom, or window height. */
.eref-footer { position: sticky; bottom: 0; z-index: 40; margin: 18px 0 0;
  background: var(--surface); border-top: 2px solid var(--border-strong);
  box-shadow: 0 -6px 18px -12px rgba(7, 27, 51, .35); }
.eref-footer-inner { display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 4px; }
.eref-footer-status { flex: 1 1 16rem; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.eref-footer-status strong { font-size: var(--text-sm); color: var(--warning); }
.eref-footer--ready .eref-footer-status strong { color: var(--success); }
.eref-footer .ws-action { margin: 0; }
/* The primary action is never hidden and never disabled — a greyed-out button with no
   explanation is its own dead end. */
.eref-footer .ws-action--primary { background: var(--navy-800); color: var(--on-brand);
  border-radius: var(--r-sm); padding: 11px 18px; font-weight: var(--weight-semi); text-decoration: none; }
.eref-footer--ready .ws-action--primary { background: var(--success); }
.eref-field--unresolved { border-left: 3px solid var(--warning); }
.eref-field--flash { outline: 2px solid var(--warning); outline-offset: 2px; }
.eref-absent { display: flex; align-items: center; gap: 7px; margin: 6px 0 0;
  font-size: var(--text-sm); color: var(--muted); cursor: pointer; }
.eref-absent input { width: 15px; height: 15px; margin: 0; cursor: pointer; }
@media (max-height: 700px) {
  .qa-pdf-frame { height: 55vh; }
}

/* THE CARE-TEAM DRAWER (CARE-TEAM-SIMPLIFY, Jose 2026-08-12) — the clinician-selection
   workspace lives OUTSIDE the Care Team card: a fixed side panel on desktop, full-width on
   phones. The card itself stays a compact list of role rows; this drawer is the only place
   the directory, its filters and match guidance appear on the referral page. */
/* Above the sticky topbar (z-index 100) — at 60 the drawer's title row and Cancel rendered
   UNDERNEATH the header, found in the 2026-08-12 screenshot review (41/45/33), not by any
   DOM assertion: the title was "visible" to the test and hidden to the person. */
.ct-drawer { position: fixed; top: 0; right: 0; bottom: 0; z-index: 120;
  width: min(420px, 100vw); overflow-y: auto; background: var(--surface);
  border-left: 1px solid var(--border-strong);
  box-shadow: -14px 0 34px -18px rgba(7, 27, 51, .45); padding: 16px 18px 24px; }
.ct-drawer-head { display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin: 0 0 6px; }
.ct-drawer-head h2 { margin: 0; font-size: var(--text-lg); }
.ct-drawer-filters { margin: 10px 0 4px; padding: 10px; background: var(--bg);
  border: 1px solid var(--border); border-radius: var(--radius); }
.ct-drawer-count { margin: 8px 2px 4px; }
.ct-results { list-style: none; margin: 0; padding: 0; display: flex;
  flex-direction: column; gap: 10px; }
.ct-result { border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; }
.ct-result--not_recommended { opacity: .75; }
.ct-result-who { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ct-result .ct-select { align-self: flex-start; margin-top: 4px; }
/* Pending selections on the card: visibly provisional until Save Care Team commits them. */
.ct-save { margin-top: 10px; border-top: 1px dashed var(--border-strong); padding-top: 10px; }
[data-ct-pending] { outline: 1px dashed var(--warning); outline-offset: 1px; }
@media (max-width: 640px) {
  .ct-drawer { width: 100vw; border-left: 0; }
}

/* ONE FORM AT A TIME (MERGED-REPAIR E19). In the UA stylesheet dialog[open] BEATS [hidden]
   on specificity, so an author rule must say it everywhere a requested-one dialog can render
   — scoping this to card regions left every other page's dialogs stacked open (caught by the
   Playwright run, three specs at once). */
dialog.ws-dialog[hidden] { display: none; }

/* THERAPIST DIRECTORY as a workforce module (MERGED-REPAIR §8–§10): the Add form and the
   filter bar sit above the cards; deactivation is a reasoned action, not a dropdown flip. */
.dir-add { margin-bottom: 14px; padding: 12px 14px; }
.dir-add-summary { cursor: pointer; font-size: var(--text-base); }
.dir-add form { margin-top: 12px; }
.dir-filters { display: flex; align-items: end; gap: 12px; flex-wrap: wrap; margin: 0 0 14px;
  padding: 10px 12px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); }
.dir-filters .field { margin: 0; min-width: 9rem; }
.dir-filters .form-actions { display: flex; gap: 8px; align-items: center; margin: 0; }
.dir-lifecycle { margin-top: 10px; border-top: 1px dashed var(--border); padding-top: 8px; }
.dir-lifecycle summary { cursor: pointer; color: var(--muted); font-size: var(--text-sm); }
.dir-lifecycle-form { display: flex; align-items: end; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.dir-openwork { border-left: 3px solid var(--warning); padding-left: 10px; }
.btn-danger { background: var(--danger); color: var(--on-brand); border: 0;
  border-radius: var(--r-sm); padding: 9px 14px; font-weight: var(--weight-semi); cursor: pointer; }

/* CARD WIDTH & OVERFLOW (MERGED-REPAIR §20). Wider columns (the narrow three-across layout
   crowded every form), full-row expansion for any card whose work area is open, and nothing
   painting outside its card. Expanded work areas cap at the existing two-column grid-2. */
.ws-grid { grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); }
.ws-panel { min-width: 0; }
.ws-panel-head { flex-wrap: wrap; row-gap: 4px; }
.ws-panel-head .ws-panel-action { white-space: nowrap; }
.ws-panel :is(a, button, .pill) { max-width: 100%; overflow-wrap: anywhere; }
/* A card with its form region open owns the whole row — forms get real width instead of a
   268px column, and no third card squeezes beside working fields. */
.ws-panel:has(.ws-card-form:not([hidden])) { grid-column: 1 / -1; }
.ws-card-form { overflow-x: visible; }
.ws-card-form form { max-width: 560px; }
.ws-card-form .grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 700px) {
  .ws-card-form .grid-2 { grid-template-columns: 1fr; }
}

/* Narrow topbar: the 70px fixed-height bar crowded longer account names against the
   Sign out button at 375px (seen in the responsive screenshot pass). Let it wrap. */
@media (max-width: 640px) {
  .nav-shell .portal-bar { height: auto; min-height: 70px; flex-wrap: wrap;
    row-gap: 2px; padding: 8px 14px; }
  .nav-shell .who { min-width: 0; overflow-wrap: anywhere; }
}

/* --- CORRECTED DOCUMENTS: the version chain (Jose's ruling, 2026-08-19) -----
   A correction is a new LINKED version, never an overwrite. Three surfaces:
   the superseded banner (you are reading a replaced version), the version
   history table, and the upload door's dialog. Uses the existing warning /
   pill / table language rather than introducing a new one. */
.qa-superseded {
  background: var(--warning-bg); color: var(--warning);
  border-left: 4px solid var(--warning-accent, var(--warning));
  border-radius: var(--r-sm); padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm); margin-bottom: var(--space-4);
}
.qa-superseded-link { margin-left: 8px; font-weight: var(--weight-semi); white-space: nowrap; }
.qa-chain { margin: 22px 0 18px; }
.qa-chain-h { font-size: var(--text-lg); margin: 0 0 4px; }
.qa-chain .muted-sm { margin: 0 0 10px; }
/* Wide content scrolls INSIDE its own box - the page itself must never scroll
   horizontally (the standing responsive rule, verified at 375px). */
.qa-chain-scroll { overflow-x: auto; }
.qa-chain-table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.qa-chain-table th, .qa-chain-table td {
  text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.qa-chain-table th { font-weight: var(--weight-semi); color: var(--muted); white-space: nowrap; }
.qa-chain-current { background: var(--bg); }
.qa-chain-reason { display: block; max-width: 34ch; overflow-wrap: anywhere; }
.qa-corr-status { margin-top: 8px; }

/* --- Doc-vs-doc side-by-side (Jose's ruling 2, 2026-08-19) -----------------
   Evidence for the UNCHANGED_FROM_PRIOR warning. Collapsed by default: the
   message is the sentence, this is the proof behind it. */
.qa-cmp { margin-top: 8px; }
.qa-cmp > summary { cursor: pointer; font-size: var(--text-sm); font-weight: var(--weight-semi); }
.qa-cmp-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 8px; }
@media (max-width: 700px) { .qa-cmp-cols { grid-template-columns: 1fr; } }
.qa-cmp-h { font-size: var(--text-xs); text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); margin: 0 0 4px; }
.qa-cmp-lines { margin: 0; padding-left: 16px; font-size: var(--text-sm); }
.qa-cmp-lines li { margin-bottom: 3px; overflow-wrap: anywhere; }

/* --- Measure-level side-by-side (Jose's ruling 5) --------------------------
   Numbers, not lines: previous value against current value, one row per
   measurement. Scrolls rather than squashing on a narrow screen — a truncated
   measurement is worse than one the reviewer has to scroll to. */
.qa-mcmp-table { width: 100%; border-collapse: collapse; margin-top: 8px;
  font-size: var(--text-sm); display: block; overflow-x: auto; }
.qa-mcmp-table th, .qa-mcmp-table td { text-align: left; padding: 4px 8px 4px 0;
  border-bottom: 1px solid var(--border); vertical-align: top; }
.qa-mcmp-table thead th { color: var(--muted); font-weight: var(--weight-semi);
  font-size: var(--text-xs); text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
.qa-mcmp-table tbody th { font-weight: var(--weight-medium); }
.qa-mcmp-skipped { margin-top: 10px; }

/* --- Goal-level side-by-side (goal-level reassessment comparison, 2026-08-21) --
   Five columns, in the order the reviewer's question runs: the prior goal, what
   this document says about it, achievement, trajectory, why. Achievement and
   trajectory are separate columns because they are separate clinical facts —
   NOT MET and IMPROVING is a different situation from NOT MET and REGRESSED.
   Scrolls rather than squashing, same as its sibling above. */
/* `max-width: 100%` IS LOAD-BEARING, not belt-and-braces.
   Without it, `display:block; overflow-x:auto` still let the table size itself to its
   content and push its ancestors wider: at 375px the whole REVIEW PAGE scrolled sideways
   (body scrollWidth 800 against a 375 client width), and hiding this one block dropped it
   to 449. The container is supposed to scroll, never the page — a reviewer who has to pan
   the entire screen to read one column has lost the document alongside it. Measured on the
   live build rather than assumed; the desktop case hid it completely, because there the
   table was already narrower than its column and scrolled internally as intended. */
.qa-gcmp-table { width: 100%; max-width: 100%; border-collapse: collapse; margin-top: 8px;
  font-size: var(--text-sm); display: block; overflow-x: auto; }
.qa-gcmp-table th, .qa-gcmp-table td { text-align: left; padding: 6px 10px 6px 0;
  border-bottom: 1px solid var(--border); vertical-align: top; }
.qa-gcmp-table thead th { color: var(--muted); font-weight: var(--weight-semi);
  font-size: var(--text-xs); text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
.qa-gcmp-table tbody th { font-weight: var(--weight-medium); white-space: nowrap; }
.qa-goal-label { margin-bottom: 2px; }
/* ON A PHONE, EACH GOAL STACKS (2026-10-29). At 375px the table scrolled sideways inside its
   box and the Achievement and Trajectory columns — the reason the table exists — sat off-screen,
   while the no-page-overflow check passed. Same rule as the Referral Log: never pass that check
   by hiding essentials. Every cell carries its own label; the markup is unchanged. */
@media (max-width: 700px) {
  .qa-gcmp-table, .qa-gcmp-table tbody, .qa-gcmp-table tr, .qa-gcmp-table td { display: block; width: auto; }
  .qa-gcmp-table { overflow-x: visible; }
  .qa-gcmp-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip: rect(0 0 0 0); white-space: nowrap; }
  .qa-gcmp-table tr { border: 1px solid var(--border); border-radius: var(--r-lg);
    margin-bottom: 10px; padding: 8px 10px; background: var(--surface); }
  .qa-gcmp-table td { padding: 4px 0; border: 0; border-bottom: 1px solid var(--border); }
  .qa-gcmp-table td:last-child { border-bottom: 0; }
  .qa-gcmp-table td::before { content: attr(data-label); display: block; color: var(--muted);
    font-size: var(--text-xs); text-transform: uppercase; letter-spacing: .03em; margin-bottom: 2px; }
  .qa-gcmp-table td:empty { display: none; }
  .qa-gcmp-table tbody th[scope="row"] { display: block; padding: 0 0 4px; border: 0; }
}
/* A REFUSAL MUST NOT READ AS A FAILURE. PCI says "not determined" on purpose — no
   baseline was stated, the note contradicts itself, two goals matched equally well.
   Rendering that in the same red as a real problem teaches a reviewer that PCI is
   noisy, and these are the rows most in need of a human. Neutral, and phrased as an
   ask rather than a verdict. */
.qa-goal-ask { margin: 4px 0 0; font-size: var(--text-sm); color: var(--navy-700); }

/* --- Clinical judgment checklist determinations (Jose's ruling 2, 2026-08-20) --
   The control that was missing: the screen asked the reviewer to record a
   determination and nothing could store one. Collapsed per question so 29 of
   them do not bury the findings that PCI actually detected. */
.qa-judge { margin-top: 6px; }
.qa-judge > summary { cursor: pointer; font-size: var(--text-sm); color: var(--navy-700); }
.qa-judge .field { margin-top: 8px; }
.qa-judge--done { background: var(--bg); border-radius: var(--r-xs); padding: 6px 10px; }

/* ── Referral Log simplification (RL-CLEAN, Fabiola interview 2026-08-24) ───────
   Fifteen persistent columns became eight. Nothing was deleted: the deadline trio
   collapsed into one derived urgency badge, and follow-ups, scheduling detail,
   the exact received timestamp and coverage history moved into the row's own
   <details>. The office should read a row, not decode a spreadsheet. */
.rl-urg { display: inline-block; padding: 1px 8px; border-radius: var(--r-full);
  font-size: var(--text-xs); font-weight: var(--weight-semi); white-space: nowrap; }
.rl-urg--late { background: var(--danger-bg, var(--warning-bg)); color: var(--danger); }
.rl-urg--soon { background: var(--warning-bg); color: var(--warning); }
.rl-urg--ok   { background: var(--success-bg); color: var(--success); }
.rl-urg--none { color: var(--muted); }
.rl-urg-txt { display: block; margin-top: 2px; }
.rl-sched { display: block; margin-top: 2px; }
.rl-care-eval { display: block; }
.rl-actions { white-space: nowrap; }
/* Closed by default: the point of moving these fields was to stop them consuming
   the reader's attention, not merely to move them a few pixels right. */
.rl-more { margin-top: 6px; }
.rl-more > summary { cursor: pointer; font-size: var(--text-xs); color: var(--navy-700); }
.rl-more-dl { margin: 6px 0 0; font-size: var(--text-xs); }
.rl-more-dl > div { display: flex; gap: 6px; padding: 2px 0;
  border-bottom: 1px solid var(--border); }
.rl-more-dl dt { color: var(--muted); flex: 0 0 44%; }
.rl-more-dl dd { margin: 0; flex: 1 1 auto; }

/* ── Referral Log on a phone: stack, do not scroll sideways ────────────────────
   At 375px nine columns still meant scrolling INSIDE the table to reach Urgency
   and Status — the two things Fabiola opens the log to see. The page did not
   overflow, so the responsive test passed, but passing that test by making the
   important columns unreachable is exactly what §16 forbids.

   So each row becomes a block and every cell carries its own label. Nothing is
   hidden: the same nine facts are all on screen, stacked, in reading order. The
   table markup is unchanged — this is presentation only, so sorting, semantics
   and the desktop layout are untouched. */
@media (max-width: 700px) {
  .table-scroll { overflow-x: visible; }
  .data-table, .data-table tbody, .data-table tr, .data-table td { display: block; width: auto; }
  /* The header row is meaningless once cells carry their own labels, and reading
     it aloud after every block would make a screen reader worse, not better. */
  .data-table thead { position: absolute; width: 1px; height: 1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .data-table tr { border: 1px solid var(--border); border-radius: var(--r-lg);
    margin-bottom: 10px; padding: 8px 10px; background: var(--surface); }
  .data-table td { display: flex; gap: 10px; align-items: baseline;
    padding: 4px 0; border: 0; border-bottom: 1px solid var(--border); }
  .data-table td:last-child { border-bottom: 0; }
  .data-table td::before { content: attr(data-label); flex: 0 0 38%;
    color: var(--muted); font-size: var(--text-xs); text-transform: uppercase;
    letter-spacing: .03em; }
  /* The patient is the row's identity, not one field among nine. */
  .data-table td[data-label="Patient"] { display: block; padding-bottom: 6px; }
  .data-table td[data-label="Patient"]::before { content: none; }
  /* A STACKED CELL IS A LABEL AND A COLUMN OF VALUES, NOT A ROW OF THEM.
     Found on the live instance at 375px, and only there: several cells carry more than one
     child — the Status cell is a pill plus the scheduling state plus a decline reason, and
     Action is a button plus a Details disclosure. As bare flex items they all competed for
     the 62% beside the label, so the decline reason wrapped into a ~110px ribbon and was
     clipped mid-word while the Details marker ran off the card edge.

     The page-level overflow check passed the whole time, which is why this survived: the
     card scrolls inside its own container, so nothing "overflowed" by that measure. It was
     simply unreadable. Each secondary value now takes its own full line under the first,
     and long text wraps instead of being cut. */
  .data-table td { flex-wrap: wrap; }
  .data-table td > * { min-width: 0; overflow-wrap: anywhere; }
  .data-table td .rl-sched,
  .data-table td .rl-cert,
  .data-table td .rl-decline,
  .data-table td .rl-recvby,
  .data-table td .rl-next,
  .data-table td .rl-care-asst,
  .data-table td .rl-care-line + .rl-care-line,
  .data-table td .rl-more { flex: 1 0 100%; margin-top: 2px;
    /* PADDING, NOT MARGIN. A flex-basis of 100% already fills the line, so a left MARGIN
       is added on top of it and the item overflows by exactly that much — which is what
       the first attempt at this fix did, pushing the decline reason 120px past the card.
       Padding sits inside the box under border-box, so the indent costs nothing. */
    padding-left: calc(38% + 10px); }
  .rl-more-dl dt { flex-basis: 50%; }
}

/* ── Quick views (RL-EVAL) ─────────────────────────────────────────────────────
   "How many evaluations are pending, and which patients?" is one question with two
   halves, so the chip carries the count AND filters to the rows. That is why this
   is a view rather than a sixteenth column. */
.rl-views { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 10px; }
.rl-view { display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; border: 1px solid var(--border); border-radius: var(--r-full);
  font-size: var(--text-sm); color: var(--navy-700); text-decoration: none; }
.rl-view:hover { border-color: var(--navy-700); }
.rl-view--on { background: var(--navy-700); color: white; border-color: var(--navy-700); }
.rl-view-count { font-weight: var(--weight-bold); font-variant-numeric: tabular-nums; }

/* Post-op / same-day surfacing (Fabiola §4, §14). It shares the Urgency cell rather than
   taking a column, because it answers the same question the reader is already asking there.
   "Check diagnosis" is deliberately calmer than the same-day marker: it is a question for a
   person, not an emergency, and colouring it identically would train the office to ignore
   both. */
.rl-urg--sameday { background: var(--danger-bg); color: var(--danger);
  font-weight: var(--weight-bold); display: block; margin-bottom: 2px; }
.rl-urg--check { background: var(--warning-bg); color: var(--warning);
  display: block; margin-bottom: 2px; }
.rl-view--urgent { border-color: var(--danger); color: var(--danger); }
.rl-view--urgent.rl-view--on { background: var(--danger); color: white; border-color: var(--danger); }
.rl-view-sub { font-size: var(--text-xs); opacity: .85; }

/* The treating assistant sits under the evaluator: two roles, one cell, because the office
   asks "who is on this patient" as one question (§11). Labelled with the role — "PTA Diaz"
   and "Diaz" are not equally useful when deciding who to call. */
.rl-care-asst { display: block; font-size: var(--text-xs); color: var(--muted); margin-top: 2px; }
/* A referral with more than one discipline: one line per discipline, its assistant inline. */
.rl-care-line { display: block; }
.rl-care-line + .rl-care-line { margin-top: 2px; }
.rl-care-disc { font-size: var(--text-xs); font-weight: var(--weight-semi); color: var(--muted); }
.rl-care-line-asst { font-size: var(--text-xs); color: var(--muted); }

/* RL-NEXT, as the interview amended it: the next ACTION, never a named owner. Fabiola,
   Karina and Regina cover for each other, so "Next: Set Agency" is true for whoever picks
   it up — "Next: Fabiola" would invent an ownership the office does not have. It shares the
   Waiting on cell because "what are we waiting on" and "what happens next" are one thought. */
.rl-next { display: block; margin-top: 2px; font-weight: var(--weight-semi); color: var(--navy-700); }
/* WHO RECEIVED IT (Jose 2026-08-28). A second muted line under the timestamp rather than a
   tenth column: "when" and "who took it" are one fact about the referral's arrival, and the
   log has just finished reclaiming its width. */
.rl-recvby { display: block; margin-top: 2px; color: var(--muted); }

/* THE DECLINE REASON, PREVIEWED ON THE ROW. Declined referrals stay in the log, so the
   reason has to be legible without opening anything — but it is a preview of a value the
   Details list also carries in full, never the only copy. */
.rl-decline { display: block; margin-top: 2px; color: var(--navy-700); }

/* CERTIFICATION COVERAGE RUNNING OUT. Same two tones as the urgency badge, because it is
   the same reader asking the same kind of question — is this one about to bite. It sits in
   the Status cell beneath the scheduling line; a row with nothing to say renders nothing,
   so a quiet log stays quiet. */
/* The workspace's own coverage line. Same two tones as the log so one reader learns one
   colour language, and NEUTRAL when there is simply a date to state. */
.ws-cert-cover { font-weight: var(--weight-semi); }
.ws-cert-cover--late { color: var(--danger); }
.ws-cert-cover--soon { color: var(--warning); }

.rl-cert { display: block; margin-top: 2px; font-weight: var(--weight-semi); }
.rl-cert--late { color: var(--danger); }
.rl-cert--soon { color: var(--warning); }

/* The Details summary says whether opening it is worth it — a row carrying a note or a
   decline reason is exactly the row somebody needs to open. */
.rl-more-mark { color: var(--muted); font-weight: var(--weight-semi); }
/* AGENCY COLOUR CODING (Jose 2026-08-31). Schedulers work by agency all day — "Advanced sends
   OT, Align sends PT" — and scanning a column of identical grey text for the one they want is
   the slowest part of reading the log.

   SIX FIXED SWATCHES, CHOSEN BY A HASH OF THE AGENCY NAME, so an agency is the same colour on
   every screen, every session, on every machine, with nothing stored and nothing to configure.
   A seventh agency reuses a colour rather than inventing one — a generated palette drifts into
   unreadable contrast, and colour here is a scanning aid, never the information itself: the
   agency name is always written out beside it. That also means the log still works for anyone
   who cannot distinguish the colours.

   Every pair is drawn from the existing token palette, so it inherits the contrast the
   design-token suite already enforces. */
.rl-agency { display: inline-flex; align-items: center; gap: 6px; }
.rl-agency-dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; }
.rl-agency--0 .rl-agency-dot { background: var(--info-accent); }
.rl-agency--1 .rl-agency-dot { background: var(--success-accent); }
.rl-agency--2 .rl-agency-dot { background: var(--accent); }
.rl-agency--3 .rl-agency-dot { background: var(--warning-accent); }
.rl-agency--4 .rl-agency-dot { background: var(--navy-700); }
.rl-agency--5 .rl-agency-dot { background: var(--danger-accent); }


/* QA upload: source system choice beside the button (2026-11-08). Global select styles carry a
   bottom margin and full-width habits; inside the header row it sits level with the button. */
.ws-head-actions .qa-upload-emr { margin: 0; width: auto; min-width: 170px; }
@media (max-width: 600px) { .ws-head-actions .qa-upload-emr, .ws-head-actions #qa-upload-btn { flex: 1 1 100%; } }

/* Late-documentation memos (src/memoViews.js). Phone first: one column, full-width Sign. */
.memo-banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  background: var(--warning-bg); color: var(--warning); border: 1px solid var(--warning-accent);
  padding: 10px 14px; border-radius: var(--r-xs); margin-bottom: 16px; font-weight: var(--weight-semi); }
.memo-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.memo-head h1 { margin: 0; }
.memo-card { margin-bottom: 16px; }
.memo-card > summary { cursor: pointer; font-weight: var(--weight-semi); }
.memo-back { margin: 0 0 8px; }
.memo-meta { color: var(--muted); display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.memo-list { list-style: none; margin: 0; padding: 0; }
.memo-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  padding: 12px 0; border-bottom: 1px solid var(--border); }
.memo-item:last-child { border-bottom: 0; }
.memo-item-link { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1 1 220px; text-decoration: none; color: inherit; }
.memo-item-title { font-weight: var(--weight-semi); overflow-wrap: anywhere; }
.memo-item-meta { color: var(--muted); font-size: var(--text-sm); }
.memo-text { line-height: 1.6; overflow-wrap: anywhere; }
.memo-sign { display: grid; gap: 10px; }
.memo-sign h2 { margin: 0; }
.memo-attest { display: flex; align-items: flex-start; gap: 10px; font-weight: var(--weight-normal); font-size: var(--text-base); }
.memo-attest input { width: 22px; height: 22px; margin-top: 2px; flex: 0 0 auto; }
.memo-sign-btn { width: 100%; min-height: 48px; font-size: var(--text-lg); }
.memo-receipt { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0 0 16px; }
.memo-receipt dt { font-weight: var(--weight-semi); }
.memo-receipt dd { margin: 0; overflow-wrap: anywhere; }
.memo-hash { font-size: var(--text-xs); overflow-wrap: anywhere; word-break: break-all; }
.memo-delivery { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: 6px 0 12px; flex-basis: 100%; }
.memo-recipients { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 6px 16px; }
.memo-recipient { display: flex; align-items: center; gap: 8px; font-weight: var(--weight-normal); }
.memo-form { display: grid; gap: 14px; }
@media (max-width: 560px) {
  .memo-receipt { grid-template-columns: 1fr; }
  .memo-receipt dd { margin-bottom: 8px; }
}
/* Signing link (shown once). */
.memo-link { display: grid; gap: 10px; }
.memo-link input[readonly] { font-family: ui-monospace, Consolas, monospace; font-size: var(--text-sm); }
.memo-link-actions { display: flex; flex-wrap: wrap; gap: 8px; }
@media (max-width: 560px) { .memo-link-actions .btn { flex: 1 1 100%; text-align: center; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; } }
/* "Text it" (sms:) only works where there is a Messages app: show it only on a touch screen (phone, tablet);
   a computer answered it with a Windows "pick an app" box (Jose 2026-11-17). */
.memo-link-actions .memo-text-btn { display: none; }
@media (pointer: coarse) { .memo-link-actions .memo-text-btn { display: inline-flex; align-items: center; justify-content: center; } }
.memo-emailed { margin: 4px 0 10px; font-weight: var(--weight-semi); color: var(--success); }
@media (max-width: 560px) { .memo-banner .btn { min-height: 44px; flex: 1 1 100%; display: inline-flex; align-items: center; justify-content: center; } }

/* Staff Mail (src/staffMailViews.js). Phone first; message text is shown as plain text only. */
.mail-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px 12px; flex-wrap: wrap; margin-bottom: 8px; }
.mail-h1 { margin: 0 0 8px; overflow-wrap: anywhere; }
.mail-h2 { margin: 0 0 8px; font-size: var(--text-base); }
.mail-account { overflow-wrap: anywhere; }
.mail-search { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0 4px; }
.mail-search input[type="search"] { flex: 1 1 220px; min-height: 44px; }
.mail-search .btn { min-height: 44px; }
.mail-count { margin: 4px 0 8px; }
.mail-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--border); }
.mail-item { border-bottom: 1px solid var(--border); }
.mail-item-link { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 12px 4px; min-height: 44px;
  text-decoration: none; color: inherit; }
.mail-item-link:hover, .mail-item-link:focus-visible { background: var(--bg); }
.mail-item-from { font-weight: var(--weight-normal); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.mail-item-date { color: var(--muted); font-size: var(--text-sm); white-space: nowrap; }
.mail-item-subject { grid-column: 1 / -1; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.mail-item--unread .mail-item-from, .mail-item--unread .mail-item-subject { font-weight: var(--weight-bold); color: inherit; }
.mail-empty { color: var(--muted); padding: 16px 0; }
.mail-pager { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 12px 0; }
.mail-settings { margin-top: 24px; }
.mail-settings > summary { cursor: pointer; color: var(--muted); min-height: 44px; display: flex; align-items: center; }
.mail-connect { display: grid; gap: 14px; max-width: 480px; }
.mail-btn { min-height: 48px; }
.mail-msg { overflow-wrap: anywhere; }
.mail-meta { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; margin: 0 0 12px; color: var(--muted); font-size: var(--text-sm); }
.mail-meta dt { font-weight: var(--weight-semi); }
.mail-meta dd { margin: 0; overflow-wrap: anywhere; }
.mail-body { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.55; border-top: 1px solid var(--border); padding-top: 12px; }
.mail-atts ul { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 8px; }
.mail-atts li { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.mail-att { min-height: 44px; display: inline-flex; align-items: center; overflow-wrap: anywhere; max-width: 100%; }
@media (max-width: 560px) {
  .mail-meta { grid-template-columns: 1fr; }
  .mail-search .btn { flex: 1 1 auto; }
}
/* Text a signing link: the therapist's mobile number beside the button (no therapist login). */
.memo-text-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; flex-basis: 100%; }
.memo-text-form input[type="tel"] { flex: 1 1 160px; max-width: 220px; min-height: 44px; }
.memo-text-form .btn { min-height: 44px; }
@media (max-width: 560px) { .memo-text-form input[type="tel"], .memo-text-form .btn { flex: 1 1 100%; max-width: none; } }
/* Sign in with Google (src/googleAuth.js): an "or" divider and a full-width button under the password form. */
.login-or { display: flex; align-items: center; gap: 10px; margin: 16px 0 12px; color: var(--muted); }
.login-or::before, .login-or::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
.login-google { display: flex; width: 100%; min-height: 44px; align-items: center; justify-content: center; }
/* Two-step verification (src/twoFactor.js): QR code, setup key and recovery codes on the sign-in card. */
.two-step-steps { padding-left: 20px; margin: 8px 0; }
.two-step-qr { display: flex; justify-content: center; margin: 8px 0 12px; }
.two-step-qr svg { max-width: 100%; height: auto; }
.two-step-secret { display: block; word-break: break-all; font-size: var(--text-sm); padding: 8px; border: 1px solid var(--border); border-radius: var(--radius); }
.two-step-codes { list-style: none; padding: 0; margin: 12px 0 16px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 12px; }
.two-step-codes code { font-size: var(--text-lg); letter-spacing: 1px; }
#two-step-code { letter-spacing: 3px; font-size: var(--text-lg); text-align: center; }

/* =====================================================================
   STAFF PORTAL FRAME (views.staffPortalShell; Jose 2026-11-17: keep the look of the old website
   portal page). Left: the Proximal brand panel with "Powered by PCI". Right: the sign-in card.
   Tokens only; stacks on a phone.
   ===================================================================== */
.sp-stage { min-height: 100vh; display: grid; grid-template-columns: 1.1fr .9fr; background: var(--surface); }
.sp-brand { position: relative; overflow: hidden; display: grid; place-items: center;
  background: radial-gradient(120% 120% at 20% 10%, var(--navy-700), var(--navy-800) 55%, var(--navy-900)); }
.sp-brand::before { content: ""; position: absolute; inset: 0; background: radial-gradient(45% 40% at 70% 30%, rgba(127,212,206,.28), transparent 60%); }
.sp-watermark { position: absolute; width: 820px; max-width: none; opacity: .05; filter: brightness(0) invert(1); right: -14%; bottom: -10%; pointer-events: none; }
.sp-brandwrap { position: relative; z-index: 1; text-align: center; color: var(--on-brand); padding: 40px 24px; }
.sp-logo { width: 230px; max-width: 70%; filter: brightness(0) invert(1); margin: 0 auto 26px; display: block; }
.sp-tagline { color: var(--on-brand); font-size: var(--text-3xl); line-height: 1.2; max-width: 16ch; margin: 0 auto 12px; font-weight: var(--weight-bold); }
.sp-apps { color: var(--side-ink); max-width: 38ch; margin: 0 auto; line-height: 1.6; }
.sp-apps-note { color: var(--chart-4); font-size: var(--text-sm); margin: 10px auto 0; }
.sp-badges { margin-top: 28px; display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; color: var(--chart-4); font-size: var(--text-sm); letter-spacing: .06em; }
.sp-badges span { display: inline-flex; gap: 6px; align-items: center; border: 1px solid rgba(255,255,255,.18); padding: 6px 12px; border-radius: var(--r-full); }
.sp-powered { margin-top: 32px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.sp-powered span { font-size: var(--text-2xs); letter-spacing: .18em; text-transform: uppercase; color: var(--side-ink); opacity: .75; }
.sp-powered img { width: 150px; }
.sp-side { display: grid; place-items: center; background: var(--surface); padding: 40px 24px; }
.sp-card { width: min(420px, 100%); }
.sp-kick { font-size: var(--text-2xs); letter-spacing: .2em; text-transform: uppercase; color: var(--navy-600); font-weight: var(--weight-bold); }
.sp-heading { font-size: var(--text-3xl); color: var(--navy-900); margin: 8px 0 6px; font-weight: var(--weight-bold); }
.sp-sub { color: var(--muted); margin: 0 0 24px; }
.sp-card .login-box { background: transparent; border: 0; box-shadow: none; padding: 0; margin: 0; max-width: none; }
.sp-card form { display: block; }
.sp-card label { display: block; font-size: var(--text-sm); font-weight: var(--weight-semi); color: var(--navy-800); margin: 14px 0 6px; }
.sp-card input[type=text], .sp-card input[type=email], .sp-card input[type=password] {
  width: 100%; box-sizing: border-box; padding: 13px 16px; border: 1px solid var(--border-strong); border-radius: var(--r-lg);
  background: var(--surface); color: var(--ink); font-size: var(--text-base); }
.sp-card input[type=text]:focus, .sp-card input[type=email]:focus, .sp-card input[type=password]:focus {
  outline: none; border-color: var(--navy-600); box-shadow: 0 0 0 4px rgba(29,90,148,.14); }
.sp-forgot { margin: 10px 0 0; text-align: right; font-size: var(--text-sm); color: var(--muted); }
.sp-card .sp-submit, .sp-card input[type=submit] { display: flex; width: 100%; min-height: 50px; margin-top: 20px; justify-content: center; align-items: center;
  border: 0; border-radius: var(--r-full); background: var(--action); color: var(--action-fg); font-size: var(--text-base); font-weight: var(--weight-semi);
  box-shadow: var(--shadow-md); cursor: pointer; text-decoration: none; }
.sp-card .sp-submit:hover, .sp-card input[type=submit]:hover { background: var(--action-hover); }
.sp-card .login-google { margin-top: 0; border-radius: var(--r-full); }
.sp-card .login-mode-toggle { margin-bottom: 4px; }
.sp-secure { margin-top: 20px; color: var(--muted); font-size: var(--text-sm); }
.sp-foot { margin-top: 26px; padding-top: 16px; border-top: 1px solid var(--border); font-size: var(--text-sm); color: var(--muted); line-height: 1.7; }
.sp-foot-pci { color: var(--navy-600); white-space: nowrap; }
.sp-foot-pci img { height: 18px; width: 18px; vertical-align: middle; margin-right: 6px; }
.sp-version { display: block; font-size: var(--text-2xs); opacity: .8; }
@media (max-width: 860px) {
  .sp-stage { grid-template-columns: 1fr; min-height: 0; }
  .sp-brandwrap { padding: 28px 16px 24px; }
  .sp-logo { width: 150px; margin-bottom: 14px; }
  .sp-tagline { font-size: var(--text-2xl); }
  .sp-badges { margin-top: 16px; }
  .sp-powered { margin-top: 18px; }
  .sp-powered img { width: 110px; }
  .sp-side { padding: 28px 16px 36px; }
  .sp-heading { font-size: var(--text-2xl); }
}
/* The frame fills the whole window (main is normally width-capped and padded). */
.app-shell--bare > #main-content:has(> .sp-stage) { max-width: none; padding: 0; margin: 0; }
/* Sign in with Google: the first, full-width choice when it is set up. */
.sp-card .sp-google { display: flex; width: 100%; min-height: 50px; gap: 10px; justify-content: center; align-items: center; border-radius: var(--r-full);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--ink); font-weight: var(--weight-semi); text-decoration: none; }
.sp-card .sp-google:hover { border-color: var(--navy-600); }
.sp-g { font-weight: var(--weight-bold); color: var(--navy-600); font-size: var(--text-lg); }
.sp-google-note { text-align: center; margin: 8px 0 0; }
/* The frame has its own footer; the site-wide one would repeat it. */
body:has(.sp-stage) .site-footer { display: none; }
/* On a phone the sign-in comes first on screen: a short brand header, the full panel text hidden. */
@media (max-width: 860px) {
  .sp-watermark, .sp-apps, .sp-apps-note, .sp-badges { display: none; }
  .sp-brandwrap { padding: 20px 16px 18px; display: flex; flex-direction: column; align-items: center; }
  .sp-logo { width: 120px; margin-bottom: 10px; }
  .sp-tagline { font-size: var(--text-lg); max-width: none; margin-bottom: 0; }
  .sp-powered { margin-top: 12px; flex-direction: row; gap: 10px; }
  .sp-powered img { width: 84px; }
  .sp-side { padding: 22px 16px 32px; place-items: start center; }
}
.sp-heading { line-height: 1.15; }
.sp-card .two-step .form-note { margin-top: 14px; }
/* Read & Sign: one line saying what the app is for, under its heading. */
.memo-purpose { color: var(--muted); max-width: 70ch; margin: 0 0 16px; line-height: 1.5; }
/* Read & Sign: the discipline picker on the sign form. */
.memo-sign select { width: 100%; box-sizing: border-box; padding: 10px 12px; border: 1px solid var(--border-strong); border-radius: var(--r-sm); background: var(--surface); color: var(--ink); font-size: var(--text-base); min-height: 44px; }

/* =============================================================================
   MODERN REFRESH (2026-11-17)
   Jose: "update the inside of staff portal, make it more modern as well" - once the
   proximalrehab.com refresh was live. Same structure, same permissions, same pages:
   this block only changes how the shell and the common surfaces LOOK, so the inside
   matches the new outside (deeper navy, the website's teal as an accent, softer depth,
   line icons in the sidebar). Kept last so it layers over the rules above without
   !important. Teal is decoration only - it never carries text on white.
   ============================================================================= */

/* Page: a faint teal glow at the top instead of a flat grey field. */
body { background: var(--page-glow), var(--bg); }

/* Sidebar: gradient ground, an icon on every destination, a teal rail on the current one. */
.app-side { background: var(--side-grad); padding: 20px 12px; }
.app-side .portal-nav { gap: 4px; }
.app-side .portal-nav a {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px;
  transition: background-color .15s ease, color .15s ease;
}
/* The icon follows the label in the markup (tests and screen readers read the label
   first); `order` puts it visually in front. */
.app-side .nav-ic { order: -1; display: inline-flex; flex: 0 0 auto;
  width: var(--icon); height: var(--icon); opacity: .72; transition: opacity .15s ease, color .15s ease; }
.app-side .nav-ic svg { width: 100%; height: 100%; display: block; }
.app-side .portal-nav a:hover .nav-ic { opacity: 1; }
.app-side .portal-nav a.is-current .nav-ic,
.app-side .portal-nav a[aria-current="page"] .nav-ic { opacity: 1; color: var(--side-focus); }
.app-side .portal-nav a.is-current::before,
.app-side .portal-nav a[aria-current="page"]::before { background: var(--brand-teal); left: -6px; width: 4px; }

/* Top bar: a hairline that matches the cards, a little more air. */
.nav-shell { box-shadow: var(--shadow-sm); }

/* Headings use the brand face, tighter tracking - the website's voice. */
#main-content h1, .page-title, .ws-head h1 { font-family: var(--font-brand); letter-spacing: -.01em; color: var(--navy-800); }
#main-content h2 { font-family: var(--font-brand); }

/* Cards and panels: rounder, softer depth; clickable ones lift on hover. */
.card, .panel { border-radius: var(--r); box-shadow: var(--shadow-card); }
a.card, .ph-ws-active, .ph-quick { transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease; }
a.card:hover, .ph-ws-active:hover, .ph-quick:hover { transform: translateY(-2px); box-shadow: var(--shadow-card-hover); }
/* .ph-ico look lives with the home page (portalHomeViews) - navy gradient well, white icon. */
@media (prefers-reduced-motion: reduce) {
  a.card, .ph-ws-active, .ph-quick, .app-side .portal-nav a { transition: none; }
  a.card:hover, .ph-ws-active:hover, .ph-quick:hover { transform: none; }
}

/* Primary actions: the website's navy gradient over the solid navy (the solid colour
   stays underneath, so contrast is unchanged if gradients are off). Link-styled buttons
   are buttons, not links: no underline. */
.btn-primary, a.btn:not(.btn-secondary):not(.btn-link), .btn--primary, .btn--cta,
button:not([class]), input[type=submit]:not([class]) {
  background-image: var(--btn-grad); box-shadow: var(--shadow-sm);
}
.btn-primary:hover, a.btn:not(.btn-secondary):not(.btn-link):hover, .btn--primary:hover, .btn--cta:hover,
button:not([class]):hover, input[type=submit]:not([class]):hover { background-image: var(--btn-grad-hover); }
a[class*="btn"]:not(.btn-link) { text-decoration: none; }
.btn-secondary, a.btn.btn-secondary { transition: border-color .15s ease, box-shadow .15s ease; }
.btn-secondary:hover, a.btn.btn-secondary:hover { border-color: var(--navy-700); box-shadow: var(--shadow-sm); }

/* Form controls: consistent height and radius, a soft focus halo. */
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=tel], input[type=date], input[type=url], input[type=search], select {
  min-height: 42px; border-radius: var(--r-sm);
}
textarea { border-radius: var(--r-sm); }
input:focus, select:focus, textarea:focus { box-shadow: var(--ring-focus); }

/* Filter bars: the controls sit on wrapping rows instead of each select taking the full
   width (the Referral Log showed five full-width dropdowns stacked down the page). */
.filter-bar { background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow-card); padding: 14px 16px; gap: 10px 14px; }
.filter-bar select { width: auto; min-width: 14ch; max-width: 100%; flex: 0 1 auto; }
.filter-bar .field-inline { display: inline-flex; align-items: center; gap: 8px; }

/* Tables: a sunk header row and a gentle row hover. */
thead th { background: var(--surface-sunk); }
tbody tr { transition: background-color .12s ease; }

/* Plain text links inside the work area use the brand ink, not browser blue. */
#main-content a:not([class]) { color: var(--navy-700); text-underline-offset: 3px; text-decoration-thickness: 1px; }
#main-content a:not([class]):hover { color: var(--navy-600); }

@media (max-width: 860px) {
  .app-side { padding: 10px 12px; }
  .app-side .portal-nav a { padding: 8px 10px; gap: 8px; }
  .app-side .nav-ic { width: var(--icon-sm); height: var(--icon-sm); }
  .filter-bar select { flex: 1 1 100%; width: 100%; }
}
/* A filter's label and its control wrap TOGETHER - never a label alone at a row's end. */
.filter-pair { display: inline-flex; align-items: center; gap: 8px; flex: 0 1 auto; min-width: 0; }
@media (max-width: 860px) { .filter-pair { flex: 1 1 100%; } .filter-pair select { flex: 1 1 auto; } }
/* PCI icon set (src/icons.js): duotone - the soft "d" shape under the outline. */
.pci-ic { width: 100%; height: 100%; display: block; }
.pci-ic .d { fill: currentColor; opacity: .22; stroke: none; }
.pci-ic .dot { fill: var(--brand-teal); stroke: var(--surface); stroke-width: 1.6; }
.app-side .pci-ic .d { opacity: .26; }
