/* portal.css — Unified clinic portal shell (capability-built) */

/* ---------------------------------------------------------------------------
   Vendored typefaces (no CDN — served from app/static/fonts/)

   Inter carries the whole interface: a face engineered for screen UI with
   true tabular-lining figures, which is what a numbers-dense clinical console
   lives on (dates, counts, rates, chart numbers line up in every column).
   JetBrains Mono handles the machine vocabulary — CPT/ICD codes, note text,
   auth numbers — where fixed advance width makes an identifier scannable.
   Both are variable fonts, loaded once and swapped in without external calls.
--------------------------------------------------------------------------- */
@font-face {
  font-family: "Inter var";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/fonts/inter-variable.woff2") format("woff2");
}
@font-face {
  font-family: "JetBrains Mono var";
  font-style: normal;
  font-weight: 100 800;
  font-display: swap;
  src: url("/fonts/jetbrains-mono-variable.woff2") format("woff2");
}

/* ---------------------------------------------------------------------------
   Palette variables
--------------------------------------------------------------------------- */
:root {
  /* Type roles — Inter for the interface, JetBrains Mono for machine tokens.
     System faces trail behind so nothing goes unstyled before the woff2 lands. */
  --portal-font-ui:   "Inter var", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --portal-font-mono: "JetBrains Mono var", "SF Mono", "Fira Code", "Fira Mono", "Roboto Mono", ui-monospace, monospace;

  --portal-navy:      #0A2240;
  --portal-teal:      #0B7A8A;
  --portal-sky:       #6CB4D9;
  --portal-ice:       #F7F9FC;
  --portal-soft-blue: #D6E8F2;
  --portal-warm-gray: #E8ECF1;
  --portal-dark-gray: #3D4A5C;
  --portal-mid-gray:  #6B7A8D;

  /* Semantic surfaces (remapped in dark mode) */
  --portal-surface:       #ffffff;
  --portal-surface-raised:#ffffff;
  --portal-heading:       #0A2240;
  --portal-input-bg:      #ffffff;
  --portal-input-border:  #c9d3df;
  --portal-hover:         #F7FBFD;
  --portal-chip-muted-bg: #EEF2F5;
  --portal-chip-bg:       #FAFCFE;
  --portal-line:          #E3EAF1;
  --portal-pass-bg:       #E4F5EA;
  --portal-pass-fg:       #1B6B3A;
  --portal-pass-edge:     #3FA76A;
  --portal-review-bg:     #FCEFE0;
  --portal-review-fg:     #9A4B12;
  --portal-review-edge:   #E0913C;
  --portal-fail-bg:       #FBE7E4;
  --portal-fail-fg:       #8F2A1E;
  --portal-fail-edge:     #C4483A;
  --portal-tier3-bg:      #E9F1F8;
  --portal-tier3-fg:      #1E4D7B;
}

/* ---------------------------------------------------------------------------
   Shell reset / base
--------------------------------------------------------------------------- */
/* Governance app.css paints body nearly black — override while portal is up. */
body.portal-active {
  background: var(--portal-ice) !important;
  color: var(--portal-dark-gray);
  color-scheme: light;
}

#portal-cc-btn,
.portal-header-link {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: transparent;
  color: #fff;
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
}
#portal-cc-btn:hover {
  background: rgba(255, 255, 255, 0.12);
}

#portal-shell-mount:not([hidden]) {
  display: block;
  min-height: 100vh;
  background: var(--portal-ice);
}

/* Two columns: a fixed navy rail + a scrolling content column. */
#portal-shell {
  display: flex;
  flex-direction: row;
  min-height: 100vh;
  background: var(--portal-ice);
  color: var(--portal-dark-gray);
  font-family: var(--portal-font-ui);
  font-size: 14px;
  line-height: 1.5;
  /* Inter refinements: contextual alternates for legibility, and default
     tabular figures so every count/date/rate aligns column-to-column. */
  font-feature-settings: "cv05" 1, "cv08" 1, "ss03" 1, "tnum" 1;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* ---------------------------------------------------------------------------
   Left rail
   Brand pinned top, section nav in the middle, account pinned bottom.
   Navy gradient with a teal seam echoes the old header identity.
--------------------------------------------------------------------------- */
#portal-sidebar {
  --rail-w: 248px;
  position: sticky;
  top: 0;
  align-self: flex-start;
  flex: 0 0 var(--rail-w);
  width: var(--rail-w);
  height: 100vh;
  display: flex;
  flex-direction: column;
  /* Match logo-white.png canvas (#0A2240) — gradient top was #0C284A and read as a box */
  background: var(--portal-navy);
  color: #fff;
  border-right: 1px solid rgba(11, 122, 138, 0.55);
  box-shadow: 2px 0 18px rgba(10, 34, 64, 0.16);
  z-index: 20;
}

#portal-sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 20px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

#portal-logo {
  width: 100%;
  height: auto;
  max-width: 100%;
  display: block;
}

/* ---- Nav list (was the top tab bar) ---- */
#portal-tab-bar {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 14px 12px;
  scrollbar-width: thin;
}
#portal-tab-bar::-webkit-scrollbar { width: 6px; }
#portal-tab-bar::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.14);
  border-radius: 6px;
}

.portal-tab {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
}
/* Access-gating sets [hidden] on a nav item; the flex rule above would other-
   wise keep it visible (class beats the UA [hidden] rule). Force it off. */
.portal-tab[hidden] { display: none !important; }
.portal-tab {
  padding: 10px 12px 10px 14px;
  background: transparent;
  border: none;
  border-radius: 9px;
  color: rgba(255, 255, 255, 0.62);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: 0.005em;
  text-align: left;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}

/* Signature: a sky "leading-edge" indicator on the active item — the bright
   left tick of a vital-sign monitor. Grows in from nothing on activation. */
.portal-tab::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 0;
  border-radius: 0 3px 3px 0;
  background: var(--portal-sky);
  transition: height 0.2s ease;
}

.portal-nav-ico {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.7);
  transition: color 0.15s ease;
}
.portal-nav-icon { display: block; }
.portal-nav-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.portal-tab:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
}
.portal-tab:hover .portal-nav-ico { color: var(--portal-sky); }
.portal-tab:focus-visible {
  outline: 2px solid var(--portal-sky);
  outline-offset: -2px;
}

.portal-tab--active {
  color: #fff;
  background: rgba(11, 122, 138, 0.24);
}
.portal-tab--active::before { height: 22px; }
.portal-tab--active .portal-nav-ico { color: var(--portal-sky); }

@media (prefers-reduced-motion: reduce) {
  .portal-tab, .portal-tab::before, .portal-nav-ico { transition: none; }
}

/* ---- Account block, pinned to the bottom of the rail ---- */
#portal-sidebar-account {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 16px 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

#portal-username-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 13px;
  color: rgba(255, 255, 255, 0.82);
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#portal-username-badge::before {
  content: "";
  flex-shrink: 0;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--portal-sky);
  box-shadow: 0 0 0 3px rgba(108, 180, 217, 0.22);
}

#portal-sidebar-account-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

#portal-cc-btn,
.portal-header-link {
  width: 100%;
  text-align: center;
}

.portal-theme-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  padding: 0;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: transparent;
  color: rgba(255, 255, 255, 0.9);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.portal-theme-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.5);
  color: #fff;
}
.portal-theme-btn:focus-visible {
  outline: 2px solid var(--portal-sky);
  outline-offset: 2px;
}
.portal-theme-icon { display: block; }

#portal-logout-btn {
  flex: 1 1 auto;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: transparent;
  color: #fff;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
#portal-logout-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.55);
}

/* ---------------------------------------------------------------------------
   Content column (right of the rail)
--------------------------------------------------------------------------- */
#portal-content {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Slim content head — holds the mobile nav toggle + any access banner.
   Collapses to nothing on desktop when it has no visible children. */
#portal-content-head {
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.portal-nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  margin: 12px 0 0 14px;
  padding: 0;
  border-radius: 8px;
  border: 1px solid var(--portal-line);
  background: var(--portal-surface);
  color: var(--portal-heading);
  cursor: pointer;
}
.portal-nav-toggle:focus-visible {
  outline: 2px solid var(--portal-teal);
  outline-offset: 2px;
}

/* Backdrop shown behind the drawer on narrow screens. */
#portal-shell::after { content: none; }

/* ---------------------------------------------------------------------------
   Panels
--------------------------------------------------------------------------- */
.portal-panel {
  flex: 1;
  overflow-y: auto;
}

/* ---------------------------------------------------------------------------
   Responsive rail
   >1000px: full labelled rail.
   641–1000px: icons-only rail (68px), labels hidden, brand centered.
   <=640px: rail becomes an off-canvas drawer toggled by the hamburger.
--------------------------------------------------------------------------- */
@media (max-width: 1000px) {
  #portal-sidebar { --rail-w: 68px; }
  #portal-sidebar-brand { padding: 14px 6px; justify-content: center; }
  #portal-logo { width: auto; height: 22px; max-width: 100%; }
  .portal-nav-label { display: none; }
  .portal-tab { justify-content: center; padding: 11px 0; gap: 0; }
  #portal-tab-bar { padding: 14px 8px; align-items: stretch; }
  #portal-username-badge {
    justify-content: center;
    padding: 6px;
    font-size: 0;          /* hide the name, keep the status dot */
    gap: 0;
  }
  #portal-sidebar-account { padding: 12px 8px 16px; align-items: center; }
  #portal-sidebar-account-actions { flex-direction: column; }
  #portal-logout-btn { font-size: 0; padding: 8px; }
  #portal-logout-btn::before {
    content: "\2192";       /* sign-out arrow when text is hidden */
    font-size: 15px;
  }
  #portal-cc-btn, .portal-header-link { font-size: 0; padding: 8px; }
}

@media (max-width: 640px) {
  #portal-sidebar {
    --rail-w: 248px;
    position: fixed;
    left: 0;
    top: 0;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
  }
  .portal-nav-label { display: inline; }
  .portal-tab { justify-content: flex-start; padding: 10px 12px 10px 14px; gap: 12px; }
  #portal-tab-bar { padding: 14px 12px; }
  #portal-sidebar-brand { padding: 0 20px; justify-content: flex-start; }
  #portal-logo { height: 30px; }
  #portal-username-badge { justify-content: flex-start; padding: 6px 12px; font-size: 13px; gap: 8px; }
  #portal-sidebar-account { padding: 14px 16px 18px; align-items: stretch; }
  #portal-sidebar-account-actions { flex-direction: row; }
  #portal-logout-btn { font-size: 13px; padding: 8px 14px; }
  #portal-logout-btn::before { content: none; }
  #portal-cc-btn, .portal-header-link { font-size: 12px; padding: 6px 10px; }
  .portal-nav-toggle { display: inline-flex; }

  .portal-nav-open #portal-sidebar { transform: translateX(0); }
  .portal-nav-open::after {
    content: "";
    position: fixed;
    inset: 0;
    background: rgba(8, 20, 40, 0.5);
    z-index: 15;
  }
}

@media (prefers-reduced-motion: reduce) {
  #portal-sidebar { transition: none; }
}

.portal-panel-inner {
  --portal-inset: 16px;
  --portal-stack: 20px;
  max-width: 800px;
  margin: 0 auto;
  padding: 32px 24px 48px;
}

/* ---------------------------------------------------------------------------
   Section labels / headings
--------------------------------------------------------------------------- */
.portal-section-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--portal-teal);
  margin-bottom: 6px;
}

.portal-section-heading {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.15;
  color: var(--portal-heading);
  margin: 0 0 7px;
}

.portal-section-sub {
  font-size: 13px;
  color: var(--portal-mid-gray);
  margin: 0 0 20px;
}

/* ---------------------------------------------------------------------------
   Cards
--------------------------------------------------------------------------- */
.portal-card {
  background: var(--portal-surface);
  border: 1px solid var(--portal-line);
  border-radius: 14px;
  padding: 22px 24px;
  margin-bottom: 20px;
  box-shadow: 0 1px 2px rgba(10, 34, 64, 0.04), 0 6px 20px rgba(10, 34, 64, 0.05);
}

body.portal-theme-dark .portal-card {
  box-shadow: none;
}

/* ---------------------------------------------------------------------------
   Forms
--------------------------------------------------------------------------- */
.portal-form-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.portal-form-row-top {
  align-items: flex-start;
}

.portal-select-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.portal-select-multi {
  min-height: 160px;
  padding: 6px 8px;
}

.portal-hint {
  font-size: 12px;
  color: var(--portal-mid-gray);
}

.portal-label {
  min-width: 130px;
  font-size: 13px;
  font-weight: 500;
  color: var(--portal-dark-gray);
  flex-shrink: 0;
}

.portal-required {
  color: #dc2626;
  margin-left: 2px;
}

.portal-optional {
  color: var(--portal-mid-gray);
  font-weight: 400;
  font-size: 12px;
}

.portal-input {
  flex: 1;
  padding: 7px 11px;
  border: 1px solid var(--portal-input-border);
  border-radius: 6px;
  font-size: 13px;
  color: var(--portal-dark-gray);
  background: var(--portal-input-bg);
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}

.portal-input:focus {
  border-color: var(--portal-teal);
  box-shadow: 0 0 0 2px rgba(11, 122, 138, 0.15);
}

.portal-textarea {
  min-height: 88px;
  resize: vertical;
  line-height: 1.45;
  font-family: inherit;
}

.portal-form-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
}

/* Quick range pills */
.portal-quick-ranges {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.portal-pill-btn {
  padding: 4px 12px;
  border-radius: 14px;
  border: 1px solid var(--portal-soft-blue);
  background: var(--portal-soft-blue);
  color: var(--portal-teal);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.portal-pill-btn:hover {
  background: var(--portal-sky);
  border-color: var(--portal-sky);
  color: #fff;
}

.portal-tab--disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.portal-access-banner {
  margin: 14px 24px 0;
  padding: 10px 16px;
  font-size: 13px;
  border-radius: 8px;
  color: var(--portal-review-fg);
  background: var(--portal-review-bg);
  border: 1px solid var(--portal-review-edge);
}

/* ---------------------------------------------------------------------------
   Buttons
--------------------------------------------------------------------------- */
.portal-primary-btn {
  padding: 9px 22px;
  background: var(--portal-teal);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(11, 122, 138, 0.25);
  transition: background 0.15s, box-shadow 0.15s, transform 0.05s;
}

.portal-primary-btn:hover {
  background: #0a6c7a;
  box-shadow: 0 3px 10px rgba(11, 122, 138, 0.3);
}
.portal-primary-btn:active { transform: translateY(1px); }
.portal-primary-btn:focus-visible {
  outline: 2px solid var(--portal-sky);
  outline-offset: 2px;
}

.portal-primary-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* ---------------------------------------------------------------------------
   Spinner / messages
--------------------------------------------------------------------------- */
.portal-spinner {
  font-size: 13px;
  color: var(--portal-mid-gray);
  font-style: italic;
}

.portal-msg {
  margin-top: 10px;
  font-size: 13px;
  padding: 8px 12px;
  border-radius: 6px;
}

.portal-msg--info {
  background: var(--portal-soft-blue);
  color: var(--portal-heading);
}

.portal-msg--ok {
  background: var(--portal-pass-bg);
  color: var(--portal-pass-fg);
}

.portal-msg--error {
  background: var(--portal-fail-bg);
  color: var(--portal-fail-fg);
}

.portal-loading {
  font-size: 13px;
  color: var(--portal-mid-gray);
  font-style: italic;
}

.portal-empty-state {
  font-size: 13px;
  color: var(--portal-mid-gray);
  font-style: italic;
  padding: 8px 0;
}

/* ---------------------------------------------------------------------------
   Results area
--------------------------------------------------------------------------- */
.portal-results-area {
  margin-top: 20px;
}

.portal-results-heading {
  font-size: 15px;
  font-weight: 600;
  color: var(--portal-heading);
  margin: 0 0 12px;
}

/* =========================================================================
   NOTE AUDIT — two screens inside the Note Audit tab

   #portal-na-list-view (filters + note rows)  <->  #portal-na-detail-view (one note).
   Same visual language as the provider portal, on the portal palette.
   ========================================================================= */
/* Status / line tokens live in the top :root block (light + dark remap). */

.portal-panel-inner--wide { max-width: 1040px; }

/* ---- Note audit browse UX --------------------------------------------- */
.portal-na-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: var(--portal-stack);
}
.portal-na-head .portal-section-label { margin-bottom: 4px; }
.portal-na-head .portal-section-heading { margin-bottom: 6px; }
.portal-na-head .portal-section-sub { max-width: 46rem; margin: 0; }
.portal-na-scope {
  flex: 0 0 auto;
  margin: 0;
  padding: 7px 12px;
  border-radius: 999px;
  background: var(--portal-surface);
  border: 1px solid var(--portal-line);
  color: var(--portal-mid-gray);
  font-size: 12px;
  white-space: nowrap;
}
.portal-na-scope strong { color: var(--portal-heading); font-weight: 700; }

.portal-na-controls {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: var(--portal-stack) var(--portal-inset);
  margin-bottom: var(--portal-stack);
}
.portal-na-browse {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 16px;
}
.portal-na-browse-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--portal-mid-gray);
}
.portal-na-seg {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px;
  border-radius: 12px;
  background: var(--portal-ice);
  border: 1px solid var(--portal-line);
}
.portal-na-seg-btn {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--portal-mid-gray);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  padding: 8px 13px;
  border-radius: 9px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.portal-na-seg-btn:hover {
  color: var(--portal-heading);
  background: var(--portal-surface-raised);
}
.portal-na-seg-btn--on {
  background: var(--portal-surface-raised);
  color: var(--portal-heading);
  border: 1px solid var(--portal-soft-blue);
}
.portal-na-refine {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 16px;
  align-items: flex-start;
  padding-top: 16px;
  border-top: 1px solid var(--portal-line);
}
.portal-na-runrow {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
  border-radius: 10px;
  background: var(--portal-ice);
  border: 1px solid var(--portal-line);
}
.portal-na-runrow-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.portal-na-runrow-copy strong {
  font-size: 13px;
  color: var(--portal-heading);
}
.portal-na-runrow-copy span {
  font-size: 12px;
  color: var(--portal-mid-gray);
}
.portal-na-runrow-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.portal-na-tally {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 0;
}
.portal-na-tile {
  appearance: none;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 3px;
  background: var(--portal-surface);
  border: 1px solid var(--portal-line);
  border-radius: 12px;
  padding: 14px var(--portal-inset);
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
  font: inherit;
  color: inherit;
}
.portal-na-tile:hover {
  border-color: var(--portal-soft-blue);
  box-shadow: 0 3px 10px rgba(10, 34, 64, 0.07);
}
.portal-na-tile--on {
  border-color: var(--portal-teal);
  box-shadow: 0 0 0 2px rgba(11, 122, 138, 0.12);
}
.portal-na-tile-n {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.1;
  color: var(--portal-heading);
  font-variant-numeric: tabular-nums;
}
.portal-na-tile-l {
  font-size: 11px;
  font-weight: 600;
  color: var(--portal-mid-gray);
}
.portal-na-tile--pass .portal-na-tile-n { color: var(--portal-pass-fg); }
.portal-na-tile--review .portal-na-tile-n { color: var(--portal-review-fg); }
.portal-na-tile--fail .portal-na-tile-n { color: var(--portal-fail-fg); }

.portal-na-day { margin-top: 16px; }
.portal-na-day + .portal-na-day { margin-top: 20px; }
.portal-na-day-h {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 8px;
  padding: 0 var(--portal-inset);
}
.portal-na-day-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--portal-heading);
}
.portal-na-day-n {
  font-size: 11px;
  font-weight: 600;
  color: var(--portal-mid-gray);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.portal-na-day-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  padding: 0;
  width: 100%;
}
/* Status chip already carries the result; the extra left dot was indenting
   row text past the date header / search axis. */
.portal-na-day-list .portal-note-dot { display: none; }

.portal-note-dot {
  flex: 0 0 auto;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #C9D3DF;
}
.portal-note-dot--pass { background: var(--portal-pass-edge); }
.portal-note-dot--review { background: var(--portal-review-edge); }
.portal-note-dot--fail { background: var(--portal-fail-edge); }
.portal-note-cta {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 700;
  color: var(--portal-teal);
  opacity: 0.85;
}
.portal-note:hover .portal-note-cta { opacity: 1; }
.portal-note--pass,
.portal-note--review,
.portal-note--fail { background: var(--portal-surface); }

.portal-na-empty {
  text-align: center;
  padding: 42px 24px;
  background: var(--portal-surface);
  border: 1px dashed var(--portal-line);
  border-radius: 14px;
}
.portal-na-empty--sm { padding: 28px 20px; }
.portal-na-empty-mark {
  width: 44px;
  height: 44px;
  margin: 0 auto 14px;
  border-radius: 14px;
  background: var(--portal-soft-blue);
  border: 1px solid var(--portal-line);
}
.portal-na-empty h3 {
  margin: 0 0 6px;
  font-size: 16px;
  color: var(--portal-heading);
}
.portal-na-empty p {
  margin: 0 auto;
  max-width: 28rem;
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--portal-mid-gray);
}
.portal-na-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 36px 16px;
  color: var(--portal-mid-gray);
  font-size: 13.5px;
}
.portal-na-loading-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--portal-teal);
  animation: portal-na-pulse 1s ease-in-out infinite;
}
@keyframes portal-na-pulse {
  0%, 100% { opacity: 0.35; transform: scale(0.85); }
  50% { opacity: 1; transform: scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .portal-na-loading-dot { animation: none; }
  .portal-na-tile, .portal-note, .portal-na-seg-btn { transition: none; }
}
@media (max-width: 720px) {
  .portal-na-head { flex-direction: column; align-items: flex-start; }
  .portal-na-tally { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .portal-note-cta { display: none; }
  .portal-na-runrow { align-items: stretch; }
  .portal-na-runrow-actions .portal-primary-btn { width: 100%; }
}

/* ---- Filter bar ------------------------------------------------------- */
.portal-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 16px;
}

.portal-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 140px;
}
.portal-field--wide { flex: 1 1 240px; min-width: 220px; }
.portal-field--full { flex: 1 1 100%; }

.portal-field > label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--portal-mid-gray);
}

.portal-field input,
.portal-field select {
  font: inherit;
  font-size: 13px;
  color: var(--portal-heading);
  background: var(--portal-input-bg);
  border: 1px solid var(--portal-input-border);
  border-radius: 6px;
  padding: 8px 11px;
  width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.portal-field input:focus,
.portal-field select:focus {
  outline: none;
  border-color: var(--portal-teal);
  box-shadow: 0 0 0 2px rgba(11, 122, 138, 0.15);
}
.portal-field select[multiple] { min-height: 104px; padding: 6px 8px; }

.portal-field-hint {
  font-size: 12px;
  color: var(--portal-mid-gray);
}

.portal-filters-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}

.portal-quick-ranges { margin-bottom: 0; }

/* ---- Summary tiles ---------------------------------------------------- */
.portal-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 12px;
  margin-top: 18px;
}
.portal-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--portal-surface);
  border: 1px solid var(--portal-line);
  border-radius: 10px;
  padding: 13px 15px;
}
.portal-stat-n {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.1;
  color: var(--portal-heading);
  font-variant-numeric: tabular-nums;
}
.portal-stat-l {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--portal-mid-gray);
}
.portal-stat--pass   .portal-stat-n { color: var(--portal-pass-fg); }
.portal-stat--review .portal-stat-n { color: var(--portal-review-fg); }
.portal-stat--fail   .portal-stat-n { color: var(--portal-fail-fg); }

/* ---- List toolbar ---------------------------------------------------- */
.portal-list-toolbar {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: var(--portal-stack) 0 16px;
}
.portal-search {
  flex: 1;
  font: inherit;
  font-size: 13px;
  color: var(--portal-heading);
  background: var(--portal-input-bg);
  border: 1px solid var(--portal-input-border);
  border-radius: 8px;
  padding: 10px var(--portal-inset);
}
.portal-search:focus {
  outline: none;
  border-color: var(--portal-sky);
  box-shadow: 0 0 0 3px rgba(108, 180, 217, 0.18);
}
.portal-list-count {
  font-size: 12px;
  color: var(--portal-mid-gray);
  white-space: nowrap;
}

/* ---- Note rows ------------------------------------------------------- */
.portal-notelist {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  padding: 0;
  width: 100%;
}

.portal-note {
  appearance: none;
  -webkit-appearance: none;
  display: flex;
  align-items: center;
  align-self: stretch;
  gap: 12px;
  width: 100%;
  max-width: 100%;
  margin: 0;
  box-sizing: border-box;
  text-align: left;
  font: inherit;
  color: inherit;
  background: var(--portal-surface);
  border: 1px solid var(--portal-line);
  border-radius: 12px;
  padding: 12px var(--portal-inset);
  cursor: pointer;
  transition: box-shadow 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}
.portal-note:hover {
  border-color: var(--portal-soft-blue);
  box-shadow: 0 4px 14px rgba(10, 34, 64, 0.08);
  transform: translateY(-1px);
}
.portal-note:focus-visible {
  outline: 2px solid var(--portal-teal);
  outline-offset: 2px;
}
.portal-note--static { cursor: default; }

.portal-note-idx {
  flex: 0 0 auto;
  width: 25px;
  height: 25px;
  border-radius: 50%;
  background: var(--portal-ice);
  color: var(--portal-mid-gray);
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.portal-note-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}
.portal-note-date {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--portal-heading);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.portal-note-provider {
  display: block;
  font-size: 12px;
  color: var(--portal-mid-gray);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.portal-note-meta {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.78rem;
  color: var(--portal-muted, #6b7280);
  font-weight: 400;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.portal-note-key,
.portal-note-run {
  font-variant-numeric: tabular-nums;
}
.portal-note-counts {
  display: flex;
  gap: 4px;
  flex: 0 0 auto;
}
.portal-note-go {
  flex: 0 0 auto;
  font-size: 20px;
  line-height: 1;
  color: var(--portal-sky);
}
.portal-note:hover .portal-note-go { color: var(--portal-teal); }

/* ---- Status chips / pills ------------------------------------------- */
.portal-chip {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.portal-chip--lg { font-size: 13px; padding: 6px 15px; }
.portal-chip--pass   { background: var(--portal-pass-bg);   color: var(--portal-pass-fg); }
.portal-chip--review { background: var(--portal-review-bg); color: var(--portal-review-fg); }
.portal-chip--fail   { background: var(--portal-fail-bg);   color: var(--portal-fail-fg); }
.portal-chip--muted  { background: var(--portal-chip-muted-bg);             color: var(--portal-mid-gray); }

.portal-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 5px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}
.portal-pill--pass   { background: var(--portal-pass-bg);   color: var(--portal-pass-fg); }
.portal-pill--review { background: var(--portal-review-bg); color: var(--portal-review-fg); }
.portal-pill--fail   { background: var(--portal-fail-bg);   color: var(--portal-fail-fg); }
.portal-pill--muted  { background: var(--portal-chip-muted-bg);             color: var(--portal-mid-gray); }

/* Count chips (module tallies on a list row) */
.portal-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  padding: 1px 7px;
  border-radius: 9px;
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.portal-count--pass   { background: var(--portal-pass-bg);   color: var(--portal-pass-fg); }
.portal-count--review { background: var(--portal-review-bg); color: var(--portal-review-fg); }
.portal-count--fail   { background: var(--portal-fail-bg);   color: var(--portal-fail-fg); }

/* ---- Detail screen header ------------------------------------------- */
.portal-back {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: transparent;
  border: 1px solid var(--portal-soft-blue);
  border-radius: 999px;
  padding: 6px 15px 6px 12px;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--portal-teal);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.portal-back:hover {
  background: var(--portal-soft-blue);
  border-color: var(--portal-sky);
}
.portal-back-arrow { font-size: 14px; line-height: 1; }

.portal-detail-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  padding-bottom: 18px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--portal-line);
}
.portal-detail-head .portal-back { flex: 0 0 100%; margin-bottom: 6px; }
.portal-detail-headline { flex: 1 1 220px; min-width: 0; }
.portal-detail-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--portal-heading);
  margin: 0;
}
/* Patient identity — deliberately the most prominent line under the title:
   the clinician has to be certain whose chart they are correcting. */
.portal-detail-patient {
  font-size: 14px;
  font-weight: 600;
  color: var(--portal-heading);
  margin: 5px 0 0;
}
.portal-detail-meta {
  font-size: 12px;
  color: var(--portal-mid-gray);
  margin: 3px 0 0;
}

/* ---- Module status strip ------------------------------------------- */
.portal-modstrip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}
.portal-modstrip-item {
  display: flex;
  align-items: center;
  gap: 9px;
  background: var(--portal-surface);
  border: 1px solid var(--portal-line);
  border-radius: 10px;
  padding: 11px 13px;
}
.portal-modstrip-item--review { border-color: var(--portal-review-edge); background: var(--portal-review-bg); }
.portal-modstrip-item--fail   { border-color: var(--portal-fail-edge); background: var(--portal-fail-bg); }
.portal-modstrip-letter,
.portal-mod-letter {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  border-radius: 7px;
  background: var(--portal-soft-blue);
  color: var(--portal-teal);
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 800;
}
.portal-modstrip-label {
  flex: 1;
  font-size: 12.5px;
  color: var(--portal-dark-gray);
  line-height: 1.3;
}

/* ---- Content blocks ----------------------------------------------- */
.portal-block {
  background: var(--portal-surface);
  border: 1px solid var(--portal-line);
  border-radius: 10px;
  padding: 20px 22px;
  margin-bottom: 16px;
}
.portal-block-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.portal-block-head h2 {
  font-size: 15px;
  font-weight: 700;
  color: var(--portal-heading);
  margin: 0;
}
.portal-block-count {
  font-size: 11px;
  font-weight: 700;
  color: var(--portal-mid-gray);
  background: var(--portal-ice);
  border-radius: 999px;
  padding: 3px 10px;
}
.portal-block-hint {
  margin-left: auto;
  font-size: 11px;
  color: var(--portal-mid-gray);
}

/* ---- Issues ------------------------------------------------------- */
.portal-issues {
  list-style: none;
  padding: 0;
  margin: 0;
  border: 1px solid var(--portal-line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--portal-surface);
}
.portal-issues > li + li {
  border-top: 1px solid var(--portal-line);
}
.portal-issue {
  display: grid;
  grid-template-columns: 4.25rem minmax(0, 1fr) 1rem;
  align-items: center;
  column-gap: 12px;
  width: 100%;
  min-height: 52px;
  text-align: left;
  font: inherit;
  color: inherit;
  padding: 10px 12px;
  border: 0;
  border-radius: 0;
  background: transparent;
  cursor: pointer;
  transition: background 0.12s;
}
.portal-issue:hover { background: var(--portal-hover); }
.portal-issue:focus-visible {
  outline: 2px solid var(--portal-teal);
  outline-offset: -2px;
}
.portal-issue--fail,
.portal-issue--review { background: transparent; }
.portal-issue-go {
  color: var(--portal-mid-gray);
  font-size: 1.1rem;
  line-height: 1;
  justify-self: end;
}
.portal-issue:hover .portal-issue-go { color: var(--portal-teal); }
.portal-noteblock {
  scroll-margin-top: 16px;
}
.portal-mod {
  scroll-margin-top: 16px;
}

/* =========================================================================
   Fix detail screen (#portal-na-fix-view) — problem + note corroboration.
   Status lives in chips/badges, never a colored side stripe.
   ========================================================================= */
.portal-problem {
  padding: 4px 0 0;
}
.portal-problem-text {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.45;
  color: var(--portal-heading);
}

.portal-corro {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.portal-corro-item h4 {
  margin: 0 0 6px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--portal-mid-gray);
}
.portal-quote {
  margin: 0;
  padding: 12px 14px;
  background: var(--portal-ice);
  border: 1px solid var(--portal-line);
  border-radius: 10px;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--portal-dark-gray);
  white-space: pre-wrap;
  word-break: break-word;
}
.portal-quote mark {
  background: #FFF3C4;
  color: inherit;
  padding: 0 2px;
  border-radius: 2px;
}
.portal-corro-empty {
  margin: 0;
  font-size: 13px;
  color: var(--portal-mid-gray);
}

.portal-more {
  border: 1px solid var(--portal-line);
  border-radius: 10px;
  overflow: hidden;
  background: var(--portal-surface);
  margin-bottom: 8px;
}
.portal-more > summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--portal-ice);
  cursor: pointer;
  list-style: none;
}
.portal-more > summary::-webkit-details-marker { display: none; }
.portal-more[open] > summary { border-bottom: 1px solid var(--portal-line); }
.portal-more .portal-mod-body { padding: 14px; }
.portal-fix .portal-notebody { margin-bottom: 16px; }

/* ---- Evidence sub-sections (inside More detail) --------------------- */
.portal-evi + .portal-evi {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--portal-line);
}
.portal-evi > h3 {
  margin-bottom: 10px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--portal-mid-gray);
}
.portal-evi-note { margin-top: 10px; color: var(--portal-mid-gray); }
.portal-codechip--focus {
  border-color: var(--portal-teal);
  box-shadow: 0 0 0 2px rgba(11, 122, 138, 0.13);
}

/* ---- Previous / next item pager ------------------------------------- */
.portal-pager {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--portal-surface);
  border: 1px solid var(--portal-line);
  border-radius: 12px;
}
.portal-pager-pos {
  margin: 0 auto;
  font-size: 12px;
  font-weight: 700;
  color: var(--portal-mid-gray);
  font-variant-numeric: tabular-nums;
}
.portal-pager-btn {
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--portal-teal);
  background: transparent;
  border: 1px solid var(--portal-soft-blue);
  border-radius: 999px;
  padding: 6px 14px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.portal-pager-btn:hover {
  background: var(--portal-soft-blue);
  border-color: var(--portal-sky);
}
.portal-pager-btn--off {
  color: #A9B7C4;
  border-color: var(--portal-line);
  cursor: default;
  padding: 7px 14px;
}

.portal-issue-sev {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 22px;
  padding: 0;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.portal-issue--fail   .portal-issue-sev { background: var(--portal-fail-bg);   color: var(--portal-fail-fg); }
.portal-issue--review .portal-issue-sev { background: var(--portal-review-bg); color: var(--portal-review-fg); }

.portal-issue-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.portal-issue-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--portal-heading);
  line-height: 1.3;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.portal-issue-meta {
  font-size: 11.5px;
  color: var(--portal-mid-gray);
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.portal-allclear {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 14px 16px;
  border-radius: 9px;
  background: var(--portal-pass-bg);
  color: var(--portal-pass-fg);
  font-size: 13px;
  font-weight: 600;
  margin: 0;
}
.portal-allclear-mark {
  flex: 0 0 auto;
  width: 23px;
  height: 23px;
  border-radius: 50%;
  background: var(--portal-pass-edge);
  display: grid;
  place-items: center;
  font-size: 11px;
}

/* ---- Coaching tips ------------------------------------------------ */
.portal-tips {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.portal-tips li {
  position: relative;
  padding-left: 24px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--portal-dark-gray);
}
.portal-tips li::before {
  content: "\2192";
  position: absolute;
  left: 2px;
  top: 0;
  color: var(--portal-teal);
  font-weight: 700;
}

/* ---- Collapsible module sections --------------------------------- */
.portal-mod,
.portal-notebody {
  border: 1px solid var(--portal-line);
  border-radius: 9px;
  overflow: hidden;
  background: var(--portal-surface);
}
.portal-mod { margin-bottom: 8px; }
.portal-mod:last-of-type { margin-bottom: 0; }

.portal-mod > summary,
.portal-notebody > summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 13px;
  background: var(--portal-ice);
  cursor: pointer;
  list-style: none;
}
.portal-mod > summary::-webkit-details-marker,
.portal-notebody > summary::-webkit-details-marker { display: none; }
.portal-mod > summary:hover,
.portal-notebody > summary:hover { background: var(--portal-hover); }
.portal-mod--review > summary { background: var(--portal-review-bg); }
.portal-mod--fail   > summary { background: var(--portal-fail-bg); }

.portal-mod-label {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  color: var(--portal-heading);
}
.portal-mod-caret {
  flex: 0 0 auto;
  margin-left: auto;
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid var(--portal-mid-gray);
  transition: transform 0.15s;
}
details[open] > summary .portal-mod-caret { transform: rotate(180deg); }

.portal-mod-body {
  padding: 14px;
  border-top: 1px solid var(--portal-line);
}

/* ---- Module body pieces ------------------------------------------ */
.portal-subcard {
  background: var(--portal-ice);
  border-radius: 8px;
  padding: 11px 13px;
}
.portal-subcard + .portal-subcard { margin-top: 8px; }
.portal-subcard-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  color: var(--portal-heading);
}
.portal-subcard-head + * { margin-top: 8px; }

.portal-score {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
}
.portal-score--full { background: var(--portal-pass-bg);   color: var(--portal-pass-fg); }
.portal-score--part { background: var(--portal-review-bg); color: var(--portal-review-fg); }
.portal-score--low  { background: var(--portal-fail-bg);   color: var(--portal-fail-fg); }

.portal-els { display: flex; flex-wrap: wrap; gap: 6px; }
.portal-el {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 6px;
}
.portal-el--present { background: var(--portal-pass-bg); color: var(--portal-pass-fg); }
.portal-el--missing { background: var(--portal-fail-bg); color: var(--portal-fail-fg); }

.portal-subline { font-size: 12.5px; color: var(--portal-dark-gray); margin: 0; }
.portal-subline + .portal-subline { margin-top: 4px; }
.portal-subline--warn { color: var(--portal-review-fg); }

.portal-checks { display: flex; flex-direction: column; gap: 9px; }
.portal-check {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--portal-dark-gray);
}
.portal-check-mark {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 10px;
  font-weight: 700;
}
.portal-check--pass .portal-check-mark { background: var(--portal-pass-bg); color: var(--portal-pass-fg); }
.portal-check--fail .portal-check-mark { background: var(--portal-fail-bg); color: var(--portal-fail-fg); }

.portal-alert {
  font-size: 12.5px;
  padding: 10px 12px;
  border-radius: 8px;
  line-height: 1.45;
  margin: 0;
}
.portal-alert + .portal-alert,
.portal-checks + .portal-alert { margin-top: 8px; }
.portal-alert b {
  display: block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 2px;
  opacity: 0.85;
}
.portal-alert--fail   { background: var(--portal-fail-bg); color: var(--portal-fail-fg); }
.portal-alert--review { background: var(--portal-review-bg); color: var(--portal-review-fg); }

.portal-chipgrid { display: flex; flex-wrap: wrap; gap: 6px; }
.portal-alert + .portal-chipgrid { margin-top: 10px; }
.portal-codechip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--portal-surface);
  border: 1px solid var(--portal-line);
  border-radius: 7px;
  padding: 4px 10px;
  font-size: 12px;
  font-family: var(--portal-font-mono);
  color: var(--portal-heading);
}
.portal-codechip em {
  font-style: normal;
  font-family: inherit;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--portal-mid-gray);
}
.portal-codechip--pass   { border-color: #BFE3CD; } .portal-codechip--pass   em { color: var(--portal-pass-fg); }
.portal-codechip--review { border-color: #F0D8B4; } .portal-codechip--review em { color: var(--portal-review-fg); }
.portal-codechip--fail   { border-color: #EDC4BD; } .portal-codechip--fail   em { color: var(--portal-fail-fg); }

.portal-flaglist {
  margin: 12px 0 0;
  padding-left: 18px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--portal-mid-gray);
}
.portal-summary-flags {
  margin: 14px 0 0;
  font-size: 11.5px;
  color: var(--portal-mid-gray);
  line-height: 1.5;
}
.portal-summary-flags b {
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-right: 7px;
}

/* ---- Note text (collapsed by default) --------------------------- */
.portal-noteblock + .portal-noteblock { margin-top: 16px; }
.portal-noteblock h4 {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--portal-teal);
  margin: 0 0 6px;
}
.portal-notepre {
  margin: 0;
  padding: 12px 14px;
  background: var(--portal-ice);
  border-radius: 8px;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--portal-font-mono);
  font-size: 12px;
  line-height: 1.55;
  color: var(--portal-heading);
}

.portal-empty-state--sm { padding: 4px 0; font-style: normal; }
.portal-empty-state--error { color: var(--portal-fail-fg); font-style: normal; }

/* ---- Tablet / phone -------------------------------------------- */
@media (max-width: 760px) {
  .portal-filters { flex-direction: column; align-items: stretch; }
  .portal-filters-actions { margin-left: 0; }
  .portal-filters-actions .portal-primary-btn { flex: 1; }
  .portal-stats { grid-template-columns: repeat(2, 1fr); }
  .portal-note { gap: 10px; padding: 11px 12px; }
  .portal-note-go { display: none; }
  .portal-block { padding: 16px 14px; }
  .portal-detail-title { font-size: 18px; }
  .portal-facts { grid-template-columns: 1fr; }
  .portal-pager { flex-wrap: wrap; gap: 9px; }
  .portal-pager-pos { order: -1; width: 100%; margin: 0; text-align: center; }
  .portal-pager-btn { flex: 1 1 auto; }
}

/* ---------------------------------------------------------------------------
   Status chips (generic, spec-required names)
--------------------------------------------------------------------------- */
.chip-pass    { background: var(--portal-pass-bg); color: var(--portal-pass-fg); }
.chip-review  { background: var(--portal-review-bg); color: var(--portal-review-fg); }
.chip-fail    { background: var(--portal-fail-bg); color: var(--portal-fail-fg); }
.chip-ok      { background: var(--portal-pass-bg); color: var(--portal-pass-fg); }
.chip-flagged { background: var(--portal-fail-bg); color: var(--portal-fail-fg); }

/* ---------------------------------------------------------------------------
   Coverage tab
--------------------------------------------------------------------------- */
.portal-cov-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.portal-cov-textarea {
  width: 100%;
  flex: none;
  min-height: 110px;
  box-sizing: border-box;
}

.portal-cov-actions {
  margin-top: 0;
}

.portal-cov-card .portal-results-area {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--portal-warm-gray);
}

.portal-cov-section-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--portal-teal);
  margin: 14px 0 8px;
}

.portal-cov-appt {
  font-size: 13px;
  color: var(--portal-dark-gray);
  margin: 0 0 10px;
}

.portal-cov-answer {
  font-size: 15px;
  line-height: 1.5;
  color: var(--portal-heading);
  margin: 0 0 14px;
  padding: 12px 14px;
  background: var(--portal-soft-blue);
  border: 1px solid var(--portal-warm-gray);
  border-radius: 6px;
  white-space: pre-wrap;
}

.portal-cov-parsed {
  font-size: 13px;
  color: var(--portal-dark-gray);
  margin: 0 0 8px;
}

.portal-cov-scope {
  font-size: 12px;
  color: var(--portal-mid-gray);
  margin: 0 0 12px;
  line-height: 1.4;
}

.portal-cov-fact-row {
  display: grid;
  grid-template-columns: 7.5rem minmax(6rem, auto) 1fr;
  gap: 8px 12px;
  align-items: baseline;
  padding: 8px 0;
  border-bottom: 1px solid var(--portal-warm-gray);
  font-size: 13px;
}

@media (max-width: 640px) {
  .portal-cov-fact-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }
}

.portal-cov-fact-row:last-child {
  border-bottom: none;
}

.portal-cov-fact-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--portal-mid-gray);
}

.portal-cov-tone {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border: 1px solid var(--portal-warm-gray);
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  width: fit-content;
}

.portal-cov-tone--yes  { background: var(--portal-review-bg); color: var(--portal-review-fg); border-color: var(--portal-review-edge); }
.portal-cov-tone--no   { background: var(--portal-pass-bg); color: var(--portal-pass-fg); border-color: var(--portal-pass-edge); }
.portal-cov-tone--na   { background: var(--portal-warm-gray); color: var(--portal-dark-gray); }
.portal-cov-tone--info { background: var(--portal-soft-blue); color: var(--portal-heading); border-color: transparent; }

.portal-cov-rationale {
  font-size: 12px;
  color: var(--portal-dark-gray);
  line-height: 1.45;
  margin: 0 0 8px;
  white-space: pre-wrap;
}

.portal-cov-req-row,
.portal-cov-gap-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid var(--portal-warm-gray);
  font-size: 13px;
}

.portal-cov-req-row:last-child,
.portal-cov-gap-row:last-child {
  border-bottom: none;
}

.portal-cov-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  flex-shrink: 0;
}

.portal-cov-badge--referral { background: var(--portal-soft-blue); color: var(--portal-heading); }
.portal-cov-badge--pa       { background: var(--portal-review-bg); color: var(--portal-review-fg); }
.portal-cov-badge--network  { background: var(--portal-warm-gray); color: var(--portal-dark-gray); }
.portal-cov-badge--other    { background: var(--portal-warm-gray); color: var(--portal-mid-gray);  }

.portal-cov-gap-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--portal-mid-gray);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}

.portal-cov-detail {
  font-size: 13px;
  color: var(--portal-dark-gray);
}

.portal-cov-auth-val {
  font-size: 13px;
  color: var(--portal-dark-gray);
  font-family: var(--portal-font-mono);
  padding: 4px 0 8px;
}

.portal-cov-result-inner {
  padding-top: 4px;
}

/* ---------------------------------------------------------------------------
   Adam iframe
--------------------------------------------------------------------------- */
#portal-adam-frame {
  width: 100%;
  height: calc(100vh - 72px);
  border: 0;
  display: block;
}

/* =========================================================================
   APPOINTMENT VALIDATOR — pre-visit exceptions worklist

   A clinical-ops worklist, not a dashboard: one filter block, one dense
   table, and a quiet collapsed run history. Urgency reads from a badge +
   dot pair and a hairline break between tiers — never a side stripe.
   Patient identity is deliberately on screen, so it gets stable typographic
   hierarchy (name in navy, identifiers muted beneath) and nothing flashy.
   ========================================================================= */
.portal-panel-inner--val {
  max-width: 1440px;
  margin: 0 auto;
  padding: 32px 24px 48px;
}

/* ---- Heading row ----------------------------------------------------- */
.portal-val-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: var(--portal-stack);
}
.portal-val-head .portal-section-sub { margin-bottom: 0; }

.portal-val-lastrun {
  margin: 0 0 3px;
  font-size: 12px;
  color: var(--portal-mid-gray);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* ---- Filter block ---------------------------------------------------- */
.portal-val-filters {
  margin-top: 0;
  padding: var(--portal-stack) var(--portal-inset);
  background: var(--portal-surface);
  border: 1px solid var(--portal-line);
  border-radius: 12px;
}

.portal-val-urgency {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 16px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--portal-line);
}

.portal-val-urgency-label,
.portal-val-field > label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--portal-mid-gray);
}

/* Segmented urgency switch — applies immediately (coarse triage). */
.portal-val-seg {
  display: inline-flex;
  padding: 2px;
  background: var(--portal-ice);
  border: 1px solid var(--portal-line);
  border-radius: 8px;
}

.portal-val-seg-btn {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 6px;
  padding: 5px 14px;
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--portal-mid-gray);
  cursor: pointer;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.portal-val-seg-btn:hover { color: var(--portal-heading); }
.portal-val-seg-btn:focus-visible {
  outline: 2px solid var(--portal-teal);
  outline-offset: 1px;
}
.portal-val-seg-btn--on {
  background: var(--portal-surface);
  border-color: var(--portal-soft-blue);
  color: var(--portal-heading);
}

.portal-val-filter-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px 14px;
}

.portal-val-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}
.portal-val-field--search { grid-column: span 2; }

.portal-val-input {
  font: inherit;
  font-size: 13px;
  width: 100%;
  color: var(--portal-heading);
  background: var(--portal-input-bg);
  border: 1px solid var(--portal-input-border);
  border-radius: 7px;
  padding: 7px 10px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.portal-val-input:focus {
  outline: none;
  border-color: var(--portal-teal);
  box-shadow: 0 0 0 2px rgba(11, 122, 138, 0.15);
}

.portal-val-filter-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

.portal-val-btn {
  appearance: none;
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  border-radius: 7px;
  padding: 7px 15px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.portal-val-btn--apply {
  border: 1px solid var(--portal-teal);
  background: var(--portal-teal);
  color: #fff;
}
.portal-val-btn--apply:hover {
  background: var(--portal-navy);
  border-color: var(--portal-heading);
}
.portal-val-btn--quiet {
  border: 1px solid var(--portal-line);
  background: var(--portal-surface);
  color: var(--portal-mid-gray);
}
.portal-val-btn--quiet:hover {
  border-color: var(--portal-soft-blue);
  color: var(--portal-heading);
}
.portal-val-btn:focus-visible {
  outline: 2px solid var(--portal-teal);
  outline-offset: 2px;
}

/* ---- Worklist toolbar ------------------------------------------------ */
.portal-val-toolbar {
  display: flex;
  align-items: baseline;
  gap: 16px;
  margin: var(--portal-stack) 0 16px;
  padding: 0;
}

.portal-export-btn {
  appearance: none;
  margin-left: auto;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: inherit;
  font-size: 11px;
  font-weight: 500;
  border-radius: 6px;
  padding: 5px 10px;
  cursor: pointer;
  border: 1px solid transparent;
  background: transparent;
  color: var(--portal-mid-gray);
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.portal-export-btn:hover {
  border-color: var(--portal-line);
  background: var(--portal-hover);
  color: var(--portal-heading);
}
.portal-export-btn:focus-visible {
  outline: 2px solid var(--portal-teal);
  outline-offset: 2px;
}
.portal-export-icon {
  flex-shrink: 0;
  opacity: 0.75;
}
.portal-export-btn:hover .portal-export-icon {
  opacity: 1;
}
.portal-export-label {
  line-height: 1;
}
.portal-export-btn:disabled,
.portal-export-btn[hidden] { display: none; }

.portal-pk-providers-head .portal-export-btn {
  font-size: 11px;
  padding: 4px 9px;
}
.portal-val-history-body .portal-export-btn {
  margin: 0 0 10px auto;
  display: inline-flex;
}

.portal-val-count {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  color: var(--portal-heading);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.portal-val-count-hint {
  margin-left: 8px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--portal-mid-gray);
}

.portal-val-tally {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 14px;
  font-size: 12px;
  color: var(--portal-mid-gray);
}
.portal-val-tally-item { white-space: nowrap; }
.portal-val-tally-item b {
  color: var(--portal-dark-gray);
  font-variant-numeric: tabular-nums;
}
.portal-val-tally-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: 1px;
}
.portal-val-tally-dot--1 { background: var(--portal-fail-edge); }
.portal-val-tally-dot--2 { background: var(--portal-review-edge); }
.portal-val-tally-dot--3 { background: var(--portal-sky); }

.portal-val-syncing {
  font-size: 12px;
  color: var(--portal-mid-gray);
  white-space: nowrap;
}
.portal-val-syncing::after {
  content: "…";
  animation: portal-val-pulse 1.4s ease-in-out infinite;
}

/* ---- Worklist table ------------------------------------------------- */
.portal-val-table-scroll {
  overflow: auto;
  max-height: 72vh;
  border: 1px solid var(--portal-line);
  border-radius: 12px;
  background: var(--portal-surface);
}

.portal-val-table {
  width: 100%;
  min-width: 1080px;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}

.portal-val-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 10px var(--portal-inset);
  text-align: left;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--portal-mid-gray);
  background: var(--portal-ice);
  border-bottom: 1px solid var(--portal-line);
  white-space: nowrap;
}

.portal-val-table td {
  padding: 12px var(--portal-inset);
  vertical-align: top;
  border-top: 1px solid var(--portal-line);
}
.portal-val-table tbody tr:first-child td { border-top: 0; }

.portal-val-table tbody tr.portal-val-row:hover td { background: var(--portal-hover); }

/* Tier boundary: a full-width hairline break, never a coloured side bar. */
.portal-val-row--tier-start td { border-top: 1px solid #CFDBE6; }

.portal-val-row--openable { cursor: pointer; }
.portal-val-row--openable:hover td { background: var(--portal-hover); }
.portal-val-row--openable:focus-visible td {
  outline: 2px solid var(--portal-teal);
  outline-offset: -2px;
}
.portal-val-clamp {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.portal-val-detail-label {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--portal-mid-gray);
  margin-bottom: 4px;
}
.portal-val-detail-body {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
  color: var(--portal-heading);
}
.portal-val-detail-muted {
  margin: 4px 0 0;
  font-size: 12.5px;
  color: var(--portal-mid-gray);
  line-height: 1.4;
}

.portal-val-c-tier    { width: 1%; white-space: nowrap; }
.portal-val-c-when    { width: 12%; }
.portal-val-c-patient { width: 14%; }
.portal-val-c-visit   { width: 13%; }
.portal-val-c-provider{ width: 13%; }
.portal-val-c-gaps    { width: 12%; }
.portal-val-c-action  { width: 16%; }
.portal-val-c-esc     { width: 16%; }
.portal-val-c-go      { width: 1%; text-align: right; padding-right: 20px; }
.portal-val-go {
  display: inline-block;
  font-size: 20px;
  line-height: 1;
  color: var(--portal-sky);
}
.portal-val-row--openable:hover .portal-val-go { color: var(--portal-teal); }

.portal-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;
}

/* ---- Exception detail screen ---------------------------------------- */
.portal-val-detail-screen {
  max-width: 880px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-bottom: 40px;
}
.portal-val-detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 4px 0 8px;
}
.portal-val-detail-kicker {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--portal-teal);
  margin-bottom: 6px;
}
.portal-val-detail-title {
  margin: 0;
  font-size: 28px;
  line-height: 1.15;
  color: var(--portal-heading);
  letter-spacing: -0.02em;
}
.portal-val-detail-sub {
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--portal-mid-gray);
}
.portal-val-detail-head-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  flex: 0 0 auto;
}
.portal-val-detail-when {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  font-size: 13px;
  color: var(--portal-mid-gray);
}
.portal-val-detail-when strong {
  color: var(--portal-heading);
  font-size: 14px;
}

.portal-val-detail-facts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.portal-val-fact {
  background: var(--portal-surface);
  border: 1px solid var(--portal-line);
  border-radius: 12px;
  padding: 14px 16px;
}

.portal-val-card {
  background: var(--portal-surface);
  border: 1px solid var(--portal-line);
  border-radius: 14px;
  padding: 18px 20px;
}
.portal-val-card--action {
  background: var(--portal-surface);
}
.portal-val-card--esc {
  background: var(--portal-review-bg);
  border-color: #F0DFC8;
}
.portal-val-card-kicker {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--portal-mid-gray);
  margin-bottom: 8px;
}
.portal-val-card-title {
  margin: 0 0 6px;
  font-size: 20px;
  line-height: 1.25;
  color: var(--portal-heading);
}
.portal-val-card-lead {
  margin: 0;
  font-size: 15px;
  line-height: 1.5;
  color: var(--portal-dark-gray);
}
.portal-val-card-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 24px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid #F0E4D4;
}
.portal-val-card-meta {
  margin: 14px 0 0;
  font-size: 12.5px;
  color: var(--portal-mid-gray);
}
.portal-val-gaps--lg { gap: 8px; }
.portal-val-gaps--lg .portal-val-gap {
  font-size: 13px;
  padding: 5px 11px;
}
.portal-val-empty-detail {
  background: var(--portal-surface);
  border: 1px dashed var(--portal-line);
  border-radius: 14px;
  padding: 32px 24px;
  text-align: center;
}
.portal-val-empty-detail h2 {
  margin: 0 0 6px;
  color: var(--portal-heading);
  font-size: 18px;
}
.portal-val-empty-detail p {
  margin: 0;
  color: var(--portal-mid-gray);
  font-size: 14px;
}

@media (max-width: 820px) {
  .portal-val-detail-head { flex-direction: column; }
  .portal-val-detail-head-side { align-items: flex-start; }
  .portal-val-detail-when { align-items: flex-start; }
  .portal-val-detail-facts,
  .portal-val-card-grid { grid-template-columns: 1fr; }
  .portal-val-c-go { display: none; }
}

.portal-val-date {
  font-size: 13px;
  font-weight: 600;
  color: var(--portal-heading);
  white-space: nowrap;
}
.portal-val-patient {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--portal-heading);
  line-height: 1.3;
}
.portal-val-line {
  color: var(--portal-dark-gray);
  line-height: 1.35;
}
.portal-val-sub {
  margin-top: 2px;
  font-size: 11.5px;
  color: var(--portal-mid-gray);
  line-height: 1.35;
}
.portal-val-c-when .portal-val-sub { white-space: nowrap; font-variant-numeric: tabular-nums; }
.portal-val-rel { font-weight: 600; }
.portal-val-rel--now  { color: var(--portal-fail-fg); }
.portal-val-rel--past { color: var(--portal-mid-gray); font-style: italic; }

.portal-val-c-action {
  color: var(--portal-dark-gray);
  line-height: 1.4;
}
.portal-val-none { color: #A9B7C4; }

/* ---- Urgency badge --------------------------------------------------- */
.portal-val-tier {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px 3px 8px;
  border-radius: 6px;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--portal-chip-muted-bg);
  color: var(--portal-mid-gray);
  white-space: nowrap;
}
.portal-val-tier-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-right: 7px;
  background: currentColor;
  opacity: 0.75;
}
.portal-val-tier--1 { background: var(--portal-fail-bg);   color: var(--portal-fail-fg); }
.portal-val-tier--2 { background: var(--portal-review-bg); color: var(--portal-review-fg); }
.portal-val-tier--3 { background: var(--portal-tier3-bg); color: var(--portal-tier3-fg); }

/* ---- Gap chips ------------------------------------------------------- */
.portal-val-gaps {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.portal-val-gap {
  display: inline-block;
  padding: 2px 8px;
  border: 1px solid var(--portal-line);
  border-radius: 6px;
  background: var(--portal-chip-bg);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--portal-dark-gray);
  white-space: nowrap;
}
.portal-val-gap--more { color: var(--portal-mid-gray); cursor: default; }

/* ---- Escalation (secondary) ----------------------------------------- */
.portal-val-esc-cause {
  display: block;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--portal-heading);
  line-height: 1.3;
}
.portal-val-esc-detail {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-top: 3px;
  font-size: 12px;
  line-height: 1.4;
  color: var(--portal-mid-gray);
}

/* ---- Empty / error states ------------------------------------------- */
.portal-val-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 48px 24px 52px;
  background: var(--portal-surface);
  border: 1px solid var(--portal-line);
  border-radius: 12px;
  text-align: center;
}
.portal-val-state-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--portal-heading);
}
.portal-val-state-sub {
  margin: 0;
  max-width: 46ch;
  font-size: 13px;
  color: var(--portal-mid-gray);
  line-height: 1.5;
}
.portal-val-state .portal-val-btn { margin-top: 14px; }
.portal-val-state--error { border-color: var(--portal-fail-edge); background: var(--portal-fail-bg); }
.portal-val-state--error .portal-val-state-title { color: var(--portal-fail-fg); }

/* ---- Loading skeleton ------------------------------------------------ */
.portal-val-sk {
  border: 1px solid var(--portal-line);
  border-radius: 12px;
  background: var(--portal-surface);
  overflow: hidden;
}
.portal-val-sk-row {
  display: grid;
  grid-template-columns: 84px 1.1fr 1.2fr 1fr 1.1fr 1.6fr;
  gap: 16px;
  align-items: center;
  padding: 14px 13px;
}
.portal-val-sk-row + .portal-val-sk-row { border-top: 1px solid var(--portal-line); }
.portal-val-sk-bar {
  height: 9px;
  border-radius: 5px;
  background: var(--portal-line);
  animation: portal-val-pulse 1.5s ease-in-out infinite;
}
.portal-val-sk-row:first-child .portal-val-sk-bar { background: var(--portal-warm-gray); animation: none; }
.portal-val-sk-row .portal-val-sk-bar:nth-child(3) { width: 78%; }
.portal-val-sk-row .portal-val-sk-bar:nth-child(5) { width: 64%; }
@keyframes portal-val-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.45; }
}

/* ---- Run history (secondary, collapsed) ------------------------------ */
.portal-val-history {
  margin-top: 24px;
  border: 1px solid var(--portal-line);
  border-radius: 10px;
  background: var(--portal-surface);
  overflow: hidden;
}
.portal-val-history-summary {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  cursor: pointer;
  list-style: none;
}
.portal-val-history-summary::-webkit-details-marker { display: none; }
.portal-val-history-summary:hover { background: var(--portal-ice); }
.portal-val-history-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--portal-mid-gray);
}
.portal-val-history-latest {
  font-size: 12px;
  color: var(--portal-mid-gray);
  font-variant-numeric: tabular-nums;
}
.portal-val-history-summary .portal-mod-caret { margin-left: auto; }

.portal-val-history-body {
  padding: 4px 14px 14px;
  border-top: 1px solid var(--portal-line);
}
.portal-val-history-note {
  margin: 10px 0 0;
  font-size: 12.5px;
  color: var(--portal-mid-gray);
}

.portal-val-runs {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
.portal-val-runs th {
  padding: 8px 10px 6px 0;
  text-align: left;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--portal-mid-gray);
  white-space: nowrap;
}
.portal-val-runs td {
  padding: 7px 10px 7px 0;
  color: var(--portal-dark-gray);
  border-top: 1px solid var(--portal-line);
  vertical-align: top;
}
.portal-val-run-ts {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: var(--portal-heading);
  font-weight: 600;
}
.portal-val-run-status { color: var(--portal-pass-fg); font-weight: 600; }
.portal-val-run-status--bad { color: var(--portal-fail-fg); }
.portal-val-run-counts { color: var(--portal-mid-gray); }

/* ---- Narrow screens -------------------------------------------------- */
@media (max-width: 1080px) {
  .portal-val-filter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 980px) {
  .portal-srt-split--open { grid-template-columns: 1fr; }
  .portal-srt-detail { position: static; }
}

@media (max-width: 760px) {
  .portal-panel-inner--val { padding: 24px 14px 40px; }
  .portal-val-head { align-items: flex-start; }
  .portal-val-lastrun { margin-bottom: 0; }
  .portal-val-urgency { flex-wrap: wrap; gap: 8px; }
  .portal-val-seg { width: 100%; }
  .portal-val-seg-btn { flex: 1; padding: 6px 4px; }
  .portal-val-filter-grid { grid-template-columns: 1fr; }
  .portal-val-field--search { grid-column: auto; }
  .portal-val-filter-actions .portal-val-btn { flex: 1; }
  .portal-val-toolbar { flex-wrap: wrap; gap: 8px 14px; }
  .portal-val-syncing { margin-left: 0; }
  .portal-val-table-scroll { max-height: none; }
  .portal-val-table th { position: static; }
}

@media (prefers-reduced-motion: reduce) {
  .portal-val-sk-bar,
  .portal-val-syncing::after { animation: none; }
}

/* ---- SRT Auths roster (reuses validator worklist chrome) ---------------
   Surfaces/text MUST use --portal-* tokens so light + dark both work.
   Do not hardcode #fff / #eee / light blues here (INV-PORTAL-THEME). */
.portal-srt-loc-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 10px;
  margin: 0 0 14px;
}
.portal-srt-loc-label {
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--portal-mid-gray);
}
.portal-srt-loc-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.portal-srt-loc-chip {
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--portal-input-border);
  background: var(--portal-surface);
  color: var(--portal-dark-gray);
  cursor: pointer;
}
.portal-srt-loc-chip:hover {
  background: var(--portal-hover);
  border-color: var(--portal-line);
  color: var(--portal-heading);
}
.portal-srt-loc-chip--on {
  background: var(--portal-soft-blue);
  border-color: var(--portal-soft-blue);
  color: var(--portal-heading);
}
.portal-srt-loc {
  font-variant-numeric: tabular-nums;
  color: var(--portal-dark-gray);
  white-space: nowrap;
}
.portal-srt-how {
  margin: 0 0 18px;
  padding: 12px 14px;
  border: 1px solid var(--portal-line);
  border-radius: 10px;
  background: var(--portal-surface);
  color: var(--portal-dark-gray);
}
.portal-srt-how > summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--portal-heading);
}
.portal-srt-how-list {
  margin: 10px 0 0;
  padding-left: 1.2rem;
  color: var(--portal-mid-gray);
  font-size: 0.86rem;
  line-height: 1.45;
}
.portal-srt-how-list li + li { margin-top: 6px; }
.portal-srt-how code {
  font-size: 0.82em;
  color: var(--portal-heading);
}
.portal-srt-split {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  align-items: start;
}
.portal-srt-split--open {
  grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
}
.portal-srt-detail {
  border: 1px solid var(--portal-line);
  border-radius: 12px;
  background: var(--portal-surface-raised);
  color: var(--portal-dark-gray);
  padding: 16px 16px 18px;
  position: sticky;
  top: 12px;
}
.portal-srt-detail-head { margin-bottom: 12px; }
.portal-srt-detail-close {
  float: right;
  border: 1px solid var(--portal-line);
  background: var(--portal-surface);
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 0.8rem;
  cursor: pointer;
  color: var(--portal-mid-gray);
}
.portal-srt-detail-close:hover {
  background: var(--portal-hover);
  color: var(--portal-heading);
  border-color: var(--portal-input-border);
}
.portal-srt-detail-name {
  margin: 0 2.5rem 4px 0;
  font-size: 1.05rem;
  font-weight: 650;
  color: var(--portal-heading);
}
.portal-srt-detail-meta {
  margin: 0 0 8px;
  font-size: 0.84rem;
  color: var(--portal-mid-gray);
}
.portal-srt-detail-badge { margin-top: 4px; }
.portal-srt-dl {
  margin: 0;
}
.portal-srt-dl > div {
  padding: 8px 0;
  border-top: 1px solid var(--portal-line);
}
.portal-srt-dl dt {
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--portal-mid-gray);
  margin-bottom: 2px;
}
.portal-srt-dl dd {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.4;
  color: var(--portal-dark-gray);
}
.portal-srt-detail-loading,
.portal-srt-detail-error {
  margin: 0;
  font-size: 0.9rem;
  color: var(--portal-mid-gray);
}
.portal-srt-table tbody tr.portal-srt-row--need {
  background: color-mix(in srgb, var(--portal-fail-bg) 55%, transparent);
}
.portal-srt-table tbody tr.portal-srt-row--verify {
  background: color-mix(in srgb, var(--portal-review-bg) 50%, transparent);
}
.portal-srt-table tbody tr.portal-srt-row--open {
  background: color-mix(in srgb, var(--portal-soft-blue) 45%, var(--portal-hover));
  outline: 1px solid var(--portal-line);
}
.portal-srt-table tbody tr.portal-srt-row--click {
  cursor: pointer;
}
.portal-srt-table tbody tr:hover {
  background: var(--portal-hover);
}
.portal-srt-table tbody tr.portal-srt-row--open:hover {
  background: color-mix(in srgb, var(--portal-soft-blue) 55%, var(--portal-hover));
}
.portal-srt-comment-cell {
  min-width: 12rem;
  max-width: 18rem;
  vertical-align: top;
}
.portal-srt-comment {
  display: block;
  width: 100%;
  min-height: 2.5rem;
  max-height: 8rem;
  resize: vertical;
  font: inherit;
  font-size: 0.82rem;
  line-height: 1.35;
  padding: 6px 8px;
  border: 1px solid var(--portal-input-border);
  border-radius: 8px;
  background: var(--portal-input-bg);
  color: var(--portal-dark-gray);
  box-sizing: border-box;
}
.portal-srt-comment:focus {
  border-color: var(--portal-teal);
  box-shadow: 0 0 0 2px rgba(11, 122, 138, 0.15);
  outline: none;
}
.portal-srt-comment-status {
  display: block;
  margin-top: 3px;
  min-height: 0.9rem;
  font-size: 0.7rem;
  color: var(--portal-mid-gray);
}
.portal-srt-name {
  font-weight: 600;
  color: var(--portal-heading);
}
.portal-srt-sub {
  margin-top: 2px;
  font-size: 0.78rem;
  color: var(--portal-mid-gray);
}
.portal-srt-date,
.portal-srt-auth,
.portal-srt-dob,
.portal-srt-site {
  font-variant-numeric: tabular-nums;
  color: var(--portal-dark-gray);
}
.portal-srt-date,
.portal-srt-auth {
  white-space: nowrap;
}
.portal-srt-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  border: 1px solid transparent;
}
.portal-srt-badge--need {
  background: var(--portal-fail-bg);
  color: var(--portal-fail-fg);
}
.portal-srt-badge--ok {
  background: var(--portal-pass-bg);
  color: var(--portal-pass-fg);
}
.portal-srt-badge--verify {
  background: var(--portal-review-bg);
  color: var(--portal-review-fg);
}
.portal-srt-badge--neutral {
  background: var(--portal-hover);
  color: var(--portal-mid-gray);
}
.portal-srt-tally-chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  margin-right: 6px;
}
.portal-srt-tally-chip--need {
  background: var(--portal-fail-bg);
  color: var(--portal-fail-fg);
}
.portal-srt-tally-chip--verify {
  background: var(--portal-review-bg);
  color: var(--portal-review-fg);
}
.portal-srt-tally-chip--ok {
  background: var(--portal-pass-bg);
  color: var(--portal-pass-fg);
}
.portal-srt-skel {
  display: inline-block;
  height: 12px;
  width: 9rem;
  border-radius: 4px;
  background: linear-gradient(
    90deg,
    var(--portal-hover) 25%,
    var(--portal-warm-gray) 50%,
    var(--portal-hover) 75%
  );
  background-size: 200% 100%;
  animation: portal-srt-shimmer 1.2s ease-in-out infinite;
}
.portal-srt-skel--sm { width: 4.5rem; }
.portal-srt-skel--md { width: 7rem; }
@keyframes portal-srt-shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}
@media (prefers-reduced-motion: reduce) {
  .portal-srt-skel { animation: none; }
}

/* Unified portal — empty / nothing-enabled state */
.portal-dark {
  max-width: 40rem;
  margin: 4rem auto;
  padding: 0 1.5rem;
  text-align: left;
}

/* ---------------------------------------------------------------------------
   Dark mode — neutral charcoal canvas; navy / teal / sky accents unchanged
--------------------------------------------------------------------------- */
body.portal-active.portal-theme-dark {
  color-scheme: dark;
  --portal-ice:            #141414;
  --portal-soft-blue:      #2a3540;
  --portal-warm-gray:      #2e2e2e;
  --portal-dark-gray:      #e8e8e8;
  --portal-mid-gray:       #9a9a9a;
  --portal-surface:        #1c1c1c;
  --portal-surface-raised: #252525;
  --portal-heading:        #f0f0f0;
  --portal-input-bg:       #252525;
  --portal-input-border:   #2e2e2e;
  --portal-hover:          #252525;
  --portal-chip-muted-bg:  #252525;
  --portal-chip-bg:        #252525;
  --portal-line:           #2e2e2e;
  --portal-pass-bg:        rgba(34, 197, 94, 0.15);
  --portal-pass-fg:        #4ade80;
  --portal-pass-edge:      #4ade80;
  --portal-review-bg:      rgba(245, 158, 11, 0.15);
  --portal-review-fg:      #fbbf24;
  --portal-review-edge:    #fbbf24;
  --portal-fail-bg:        rgba(239, 68, 68, 0.15);
  --portal-fail-fg:        #f87171;
  --portal-fail-edge:      #f87171;
  --portal-tier3-bg:       rgba(108, 180, 217, 0.15);
  --portal-tier3-fg:       #6CB4D9;
}

body.portal-active.portal-theme-dark .portal-na-seg-btn--on,
body.portal-active.portal-theme-dark .portal-val-seg-btn--on {
  background: rgba(108, 180, 217, 0.16);
  border-color: var(--portal-sky);
  color: var(--portal-sky);
}

body.portal-active.portal-theme-dark .portal-cov-answer {
  background: #1a2228;
  border-color: #2a3a44;
  color: #e0e8ee;
}

body.portal-active.portal-theme-dark .portal-quote mark {
  background: rgba(245, 158, 11, 0.35);
  color: #fde68a;
}

body.portal-active.portal-theme-dark .portal-note-dot {
  background: #4a5568;
}

body.portal-active.portal-theme-dark .portal-val-card--esc {
  border-color: #4a3a28;
}
body.portal-active.portal-theme-dark .portal-val-card-grid {
  border-top-color: #3a3a3a;
}

/* =========================================================================
   PRACTICE DASHBOARD (Practice KPIs) — the portal landing tab.

   Portal-native reskin of the KPI panel: navy/teal on the light ice canvas
   (charcoal in dark). The signature is the hero figure — a large navy
   tabular-lining number with a teal unit, set over a hand-rolled teal trend
   whose area fades into the card. Everything else stays quiet so that one
   figure per card carries the eye. The Chart Compliance card is the hero:
   it spans the full width and carries the per-provider mini-table.
   PHI-CLOSED: only closed /api/kpis/* fields; provider_id is a STAFF name.
   ========================================================================= */

/* ---- Header row (title + window control) ----------------------------- */
.portal-pk-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}
.portal-pk-head .portal-section-sub { max-width: 52rem; margin: 0; }
.portal-pk-head-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}
.portal-pk-generated {
  font-size: 11.5px;
  color: var(--portal-mid-gray);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

/* Window segmented control */
.portal-pk-window {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  background: var(--portal-ice);
  border: 1px solid var(--portal-line);
  border-radius: 999px;
}
.portal-pk-win-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--portal-mid-gray);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  padding: 6px 15px;
  border-radius: 999px;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
  transition: background 0.14s, color 0.14s;
}
.portal-pk-win-btn:hover { color: var(--portal-heading); }
.portal-pk-win-btn:focus-visible {
  outline: 2px solid var(--portal-teal);
  outline-offset: 1px;
}
.portal-pk-win-btn--on {
  background: var(--portal-surface);
  color: var(--portal-heading);
  box-shadow: 0 1px 2px rgba(10, 34, 64, 0.12);
}
.portal-pk-window--card {
  margin-left: auto;
  padding: 2px;
}
.portal-pk-window--card .portal-pk-win-btn {
  font-size: 11px;
  padding: 4px 10px;
}

/* ---- Card grid: hero spans full width; the rest tile two-up ----------- */
.portal-pk-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  transition: opacity 0.14s;
}
.portal-pk-grid.is-loading { opacity: 0.5; pointer-events: none; }
.portal-pk-card.is-loading { opacity: 0.5; pointer-events: none; }
.portal-pk-card--hero { grid-column: 1 / -1; }

/* A single enabled (non-hero) section shouldn't sit half-width. */
.portal-pk-grid[data-count="1"] .portal-pk-card { grid-column: 1 / -1; }

/* Empty state: no dashboard sections enabled for this account. */
.portal-pk-grid--empty { display: block; }
.portal-pk-none {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 48px 24px;
  text-align: center;
  border: 1px dashed var(--portal-border, rgba(10, 34, 64, 0.18));
  border-radius: 14px;
  background: var(--portal-surface, rgba(10, 34, 64, 0.03));
}
.portal-pk-none-mark {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid var(--portal-border, rgba(10, 34, 64, 0.25));
  opacity: 0.5;
}
.portal-pk-none-text {
  margin: 0;
  max-width: 34ch;
  font-size: 14px;
  line-height: 1.5;
  color: var(--portal-text-dim, rgba(10, 34, 64, 0.65));
}

@media (max-width: 860px) {
  .portal-pk-grid { grid-template-columns: 1fr; }
}

/* ---- Card ------------------------------------------------------------- */
.portal-pk-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
  padding: 22px 24px 24px;
  background: var(--portal-surface);
  border: 1px solid var(--portal-line);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(10, 34, 64, 0.04), 0 8px 24px rgba(10, 34, 64, 0.05);
  transition: border-color 0.16s, box-shadow 0.16s;
}
body.portal-theme-dark .portal-pk-card { box-shadow: none; }
.portal-pk-card:hover {
  border-color: var(--portal-soft-blue);
}
/* A hairline accent along the top; brighter teal on the hero card marks the
   one section the practice reads first — structural, not decorative. */
.portal-pk-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--portal-line);
}
.portal-pk-card--hero::before {
  background: linear-gradient(90deg, var(--portal-teal), var(--portal-sky));
}

.portal-pk-card-head { display: flex; flex-direction: column; gap: 4px; }
.portal-pk-eyebrow-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-height: 28px;
}
.portal-pk-eyebrow {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--portal-teal);
}
.portal-pk-basis {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--portal-mid-gray);
  padding: 2px 8px;
  border: 1px solid var(--portal-line);
  border-radius: 999px;
  background: var(--portal-ice);
}
.portal-pk-card-title {
  margin: 2px 0 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--portal-heading);
}
.portal-pk-card--hero .portal-pk-card-title { font-size: 20px; }
.portal-pk-card-lede {
  margin: 3px 0 0;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--portal-mid-gray);
  max-width: 46rem;
}

/* ---- Card body: figure column + chart -------------------------------- */
.portal-pk-card-body {
  display: grid;
  grid-template-columns: minmax(140px, 200px) minmax(0, 1fr);
  gap: 26px;
  align-items: center;
}
.portal-pk-card:not(.portal-pk-card--hero) .portal-pk-card-body {
  grid-template-columns: minmax(120px, 170px) minmax(0, 1fr);
  gap: 20px;
}
@media (max-width: 560px) {
  .portal-pk-card-body { grid-template-columns: 1fr; gap: 16px; }
}

.portal-pk-figure {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

/* The hero number — the one bold move. Tight tabular lining, teal unit. */
.portal-pk-hero {
  display: flex;
  align-items: baseline;
  gap: 5px;
  line-height: 1;
}
.portal-pk-hero-num {
  font-size: 46px;
  font-weight: 800;
  letter-spacing: -0.035em;
  color: var(--portal-heading);
  font-variant-numeric: tabular-nums lining-nums;
}
.portal-pk-card--hero .portal-pk-hero-num { font-size: 66px; }
.portal-pk-hero-unit {
  font-size: 20px;
  font-weight: 700;
  color: var(--portal-teal);
}
.portal-pk-card--hero .portal-pk-hero-unit { font-size: 26px; }

/* Trend direction chip */
.portal-pk-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  width: fit-content;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--portal-line);
  background: var(--portal-chip-bg);
  color: var(--portal-mid-gray);
  font-variant-numeric: tabular-nums;
}
.portal-pk-chip-glyph { font-size: 12px; font-weight: 800; }
.portal-pk-chip-since {
  color: var(--portal-mid-gray);
  font-weight: 500;
  font-size: 10.5px;
  opacity: 0.8;
}
.portal-pk-chip--up   { border-color: var(--portal-pass-edge); background: var(--portal-pass-bg); color: var(--portal-pass-fg); }
.portal-pk-chip--up   .portal-pk-chip-since { color: var(--portal-pass-fg); }
.portal-pk-chip--down { border-color: var(--portal-fail-edge); background: var(--portal-fail-bg); color: var(--portal-fail-fg); }
.portal-pk-chip--down .portal-pk-chip-since { color: var(--portal-fail-fg); }
.portal-pk-chip--flat .portal-pk-chip-glyph { color: var(--portal-mid-gray); }

/* Worklist secondary stat */
.portal-pk-worklist {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding-top: 12px;
  margin-top: 2px;
  border-top: 1px solid var(--portal-line);
}
.portal-pk-worklist-num {
  font-size: 20px;
  font-weight: 700;
  color: var(--portal-heading);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.portal-pk-worklist-label {
  font-size: 12px;
  color: var(--portal-mid-gray);
  line-height: 1.3;
}

/* ---- Chart (hand-rolled SVG) ----------------------------------------- */
.portal-pk-chart { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.portal-pk-spark {
  width: 100%;
  height: 128px;
  display: block;
}
.portal-pk-card:not(.portal-pk-card--hero) .portal-pk-spark { height: 100px; }

/* SVG element styling (colours from tokens so both themes read right). */
.portal-pk-line { stroke: var(--portal-teal); }
.portal-pk-dot  { fill: var(--portal-teal); stroke: var(--portal-surface); stroke-width: 1.5; }
.portal-pk-base { stroke: var(--portal-line); stroke-width: 1; }
.portal-pk-grad-top { stop-color: rgba(11, 122, 138, 0.18); }
.portal-pk-grad-bot { stop-color: rgba(11, 122, 138, 0); }
body.portal-theme-dark .portal-pk-grad-top { stop-color: rgba(108, 180, 217, 0.22); }
body.portal-theme-dark .portal-pk-line { stroke: var(--portal-sky); }
body.portal-theme-dark .portal-pk-dot  { fill: var(--portal-sky); }

.portal-pk-axis {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--portal-mid-gray);
  letter-spacing: 0.02em;
  padding: 0 2px;
  font-variant-numeric: tabular-nums;
}

/* Per-section empty state */
.portal-pk-empty {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 100px;
  padding: 16px 18px;
  border: 1px dashed var(--portal-line);
  border-radius: 10px;
  background: var(--portal-ice);
  color: var(--portal-mid-gray);
  font-size: 12.5px;
  line-height: 1.5;
}
.portal-pk-empty-mark {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--portal-soft-blue);
  border: 1px solid var(--portal-sky);
  flex-shrink: 0;
}

/* ---- Per-provider mini-table (hero card only) ------------------------- */
.portal-pk-providers {
  border-top: 1px solid var(--portal-line);
  padding-top: 18px;
}
.portal-pk-providers[hidden] { display: none; }
.portal-pk-providers-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 12px;
}
.portal-pk-providers-title {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--portal-mid-gray);
}
.portal-pk-providers-note {
  font-size: 11px;
  color: var(--portal-mid-gray);
  opacity: 0.75;
}
.portal-pk-providers-scroll { overflow-x: auto; }
.portal-pk-providers-table {
  width: 100%;
  min-width: 460px;
  border-collapse: collapse;
  font-size: 12.5px;
}
.portal-pk-providers-table th {
  text-align: left;
  padding: 6px 12px 8px;
  color: var(--portal-mid-gray);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--portal-line);
  white-space: nowrap;
}
.portal-pk-providers-table th.portal-pk-th-r { text-align: right; }
.portal-pk-providers-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--portal-line);
  vertical-align: middle;
}
.portal-pk-providers-table tr:last-child td { border-bottom: 0; }
.portal-pk-providers-table tbody tr:hover td { background: var(--portal-hover); }
.portal-pk-prov-id {
  white-space: nowrap;
  color: var(--portal-heading);
  font-weight: 600;
}
.portal-pk-prov-bar { width: 42%; }
.portal-pk-prov-track {
  display: block;
  height: 7px;
  border-radius: 999px;
  background: var(--portal-warm-gray);
  overflow: hidden;
}
.portal-pk-prov-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--portal-teal);
}
.portal-pk-prov-fill--good { background: var(--portal-pass-edge); }
.portal-pk-prov-fill--warn { background: var(--portal-review-edge); }
.portal-pk-prov-fill--low  { background: var(--portal-fail-edge); }
.portal-pk-prov-rate {
  text-align: right;
  white-space: nowrap;
  color: var(--portal-heading);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.portal-pk-prov-unit { color: var(--portal-mid-gray); font-size: 10px; margin-left: 1px; font-weight: 500; }
.portal-pk-prov-n {
  text-align: right;
  color: var(--portal-mid-gray);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

@media (max-width: 760px) {
  .portal-pk-head { align-items: flex-start; }
  .portal-pk-head-side { align-items: flex-start; }
  .portal-pk-card--hero .portal-pk-hero-num { font-size: 52px; }
}

@media (prefers-reduced-motion: reduce) {
  .portal-pk-grid, .portal-pk-win-btn, .portal-pk-card { transition: none; }
}

/* =========================================================================
   COHESION LAYER — a final typographic + interaction pass that unifies
   every panel now that Inter/JetBrains Mono carry the interface. Nothing
   here renames or removes a selector the JS relies on; it only refines
   presentation on classes already emitted by the tool modules.
   ========================================================================= */

/* ---- Display headings: let Inter's tight tracking + lining figures read
   as a deliberate scale across every screen's title. -------------------- */
.portal-section-heading,
.portal-detail-title,
.portal-val-detail-title,
.portal-val-card-title,
.portal-pk-card-title {
  font-feature-settings: "cv05" 1, "cv08" 1, "ss03" 1, "lnum" 1;
}

/* Every raw figure — hero numbers, tallies, table counts, rates — rides
   on true tabular lining so columns and stat rows never shift width. */
.portal-pk-hero-num,
.portal-pk-worklist-num,
.portal-stat-n,
.portal-na-tile-n,
.portal-note-idx,
.portal-count,
.portal-val-count,
.portal-pager-pos {
  font-feature-settings: "tnum" 1, "lnum" 1;
}

/* ---- Eyebrows / uppercase labels: nudge weight + tracking so the small
   caps line reads as a considered label, not shouting. ------------------ */
.portal-section-label,
.portal-pk-eyebrow,
.portal-val-detail-kicker,
.portal-na-browse-label,
.portal-field > label {
  font-feature-settings: "ss03" 1;
}

/* ---- Buttons: one shared easing + a hair of lift on the primary so the
   whole portal's press feedback feels like one product. ----------------- */
.portal-primary-btn,
.portal-val-btn--apply {
  transition: background 0.15s ease, box-shadow 0.18s ease, transform 0.08s ease;
}
.portal-primary-btn:hover { transform: translateY(-1px); }
.portal-primary-btn:active,
.portal-val-btn--apply:active { transform: translateY(0); }

/* Secondary / ghost surfaces share the primary's focus ring language. */
.portal-back:focus-visible,
.portal-pager-btn:focus-visible,
.portal-na-seg-btn:focus-visible,
.portal-pk-win-btn:focus-visible,
.portal-search:focus-visible,
.portal-pill-btn:focus-visible {
  outline: 2px solid var(--portal-teal);
  outline-offset: 2px;
}

/* ---- Cards: a slightly warmer, layered shadow gives the whole surface
   set the same quiet depth the dashboard hero cards already have. ------- */
.portal-card,
.portal-val-card,
.portal-val-fact,
.portal-block {
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}
.portal-card:hover {
  border-color: var(--portal-soft-blue);
}

/* Coverage answer: lead the eye with an accent edge rather than a flat
   fill, matching the hero-card top-rule idiom used on the dashboard. */
.portal-cov-answer {
  position: relative;
  padding-left: 18px;
}
.portal-cov-answer::before {
  content: "";
  position: absolute;
  top: 12px;
  bottom: 12px;
  left: 8px;
  width: 3px;
  border-radius: 3px;
  background: linear-gradient(180deg, var(--portal-teal), var(--portal-sky));
}

/* ---- Empty states: quiet, centered, consistent voice across tools. ---- */
.portal-empty-state,
.portal-cov-scope {
  font-feature-settings: "ss03" 1;
}

/* ---- Reduced-motion respect for the added lift. ----------------------- */
@media (prefers-reduced-motion: reduce) {
  .portal-primary-btn,
  .portal-val-btn--apply,
  .portal-card,
  .portal-val-card,
  .portal-block { transition: none; }
  .portal-primary-btn:hover { transform: none; }
}
