/* ============================================================================
   Billing-App design system (v1.10 visual refresh)

   One stylesheet, no build step, Chrome-only (extension pages). The extension
   CSP is `style-src 'self'` — inline style="" attributes are ignored, so
   EVERY style must live here.

   Structure:
     1. Design tokens        — single source of truth for color/type/space
     2. Base + accessibility — resets, focus rings, scrollbars, motion
     3. App frame            — header, alert strips, 3-column workspace
     4. Components           — left rail, bundle, cost summary, cards, …
     5. Checkout mode
     6. Settings page
     7. Responsive adjustments

   Conventions:
     - Semantic tokens only in component rules (--text-muted, not slate-500),
       so a future palette change happens in one block.
     - Money is always `font-variant-numeric: tabular-nums` and right-aligned.
     - Uppercase section labels share one pattern: --fs-xs / 600 / +0.05em.
     - Small text ≥ 4.5:1 contrast on its actual background (WCAG AA); the
       big checkout/estimate figures are display-size, where 3:1 applies.
   ========================================================================= */

/* ===== 1. Design tokens ===== */
:root {
  color-scheme: light;

  /* -- Neutrals (slate ramp) -- */
  --bg-page:          #ffffff;
  --bg-rail:          #f8fafc;   /* side panels, settings page backdrop */
  --bg-inset:         #f1f5f9;   /* hovered rows, decision-row footer */
  --bg-card:          #ffffff;
  --border:           #e2e8f0;
  --border-strong:    #cbd5e1;   /* input borders need more affordance */
  --divider:          #f1f5f9;   /* hairlines inside tables */
  --text:             #0f172a;
  --text-secondary:   #334155;
  --text-muted:       #64748b;   /* 4.7:1 on white, 4.6:1 on --bg-rail */
  --text-faint:       #94a3b8;   /* placeholders + decorative glyphs only */

  /* -- Accent (blue) -- */
  --accent:           #2563eb;   /* white text on this passes AA (5.2:1) */
  --accent-strong:    #1d4ed8;   /* hover + text links (6.3:1 on white) */
  --accent-text:      #1e40af;
  --accent-bg:        #eff6ff;
  --accent-border:    #93c5fd;

  /* -- Status hues -- */
  --warn:             #f59e0b;   /* borders/markers only — never small text */
  --warn-text:        #92400e;
  --warn-text-strong: #78350f;
  --warn-bg:          #fffbeb;
  --warn-border:      #fde68a;
  --ok:               #059669;   /* display-size figures (3.8:1, ≥24px ok) */
  --ok-text:          #047857;   /* small-text green (4.7:1) */
  --ok-bg:            #ecfdf5;
  --ok-border:        #6ee7b7;   /* tinted field border (emerald-300) */
  --danger:           #dc2626;
  --danger-strong:    #b91c1c;
  --danger-bg:        #fef2f2;
  --danger-border:    #fca5a5;   /* tinted field border (red-300) */
  --info-text:        #075985;
  --info-bg:          #f0f9ff;
  --info-border:      #bae6fd;
  --info-action:      #0284c7;
  --info-action-hover:#0369a1;
  --ready:            #4f46e5;

  /* -- Header (dark) -- */
  --header-bg:        #0f172a;
  --header-text:      #e2e8f0;
  --header-muted:     #94a3b8;
  --header-control:   #1e293b;
  --header-control-border: #334155;
  --header-control-hover:  #334155;
  --header-focus:     #60a5fa;   /* focus ring needs to be light on dark */

  /* -- Typography (compact UI ramp, ~1.2 ratio, px-snapped) -- */
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --fs-xs:   11px;  --lh-xs:   16px;   /* caps labels, fine print */
  --fs-sm:   12px;  --lh-sm:   18px;   /* secondary text, table meta */
  --fs-base: 13px;  --lh-base: 20px;   /* body + controls */
  --fs-md:   15px;  --lh-md:   22px;   /* panel titles */
  --fs-lg:   18px;  --lh-lg:   26px;   /* key figures */
  --fs-xl:   22px;  --lh-xl:   30px;   /* page titles (settings) */
  --fs-display: 34px; --lh-display: 40px; /* checkout grand total */
  --tracking-caps: 0.05em;

  /* -- Spacing (4px base) -- */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-8: 32px;

  /* -- Radii -- */
  --r-sm: 6px;     /* buttons, inputs, chips */
  --r-md: 8px;     /* cards, banners */
  --r-lg: 12px;    /* page-level cards (settings, checkout panels) */

  /* -- Elevation -- */
  --shadow-xs: 0 1px 2px rgb(15 23 42 / 0.05);
  --shadow-sm: 0 1px 2px rgb(15 23 42 / 0.06), 0 1px 3px rgb(15 23 42 / 0.08);
  --shadow-toast: 0 8px 24px rgb(15 23 42 / 0.22);

  /* -- Focus + motion -- */
  --ring: 0 0 0 3px rgb(37 99 235 / 0.18);
  --dur: 120ms;
  --ease: cubic-bezier(0.2, 0, 0, 1);
}

/* ===== 2. Base + accessibility ===== */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-font-smoothing: antialiased; }

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: var(--lh-base);
  background: var(--bg-page);
  color: var(--text);
}

/* Several containers set display:flex/grid, which overrides the user-agent
   [hidden] { display: none } rule — this bit three separate times (v1.4.3
   add-procedure picker, v1.5.3 workspace, the subsite row). One guard kills
   the whole bug class. */
[hidden] { display: none !important; }

button { font: inherit; cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.55; }
input, select, textarea { font: inherit; color: var(--text); }
::placeholder { color: var(--text-faint); }
::selection { background: #bfdbfe; color: var(--text); }

a { color: var(--accent-strong); }
a:hover { color: var(--accent-text); }

/* Keyboard focus: a ring you can actually see, only for keyboard users.
   Text fields swap the outline for a border + soft ring (less jumpy while
   typing); the dark header overrides the ring color for contrast. */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--ring);
}

/* Thin, quiet scrollbars inside the independently-scrolling panels */
.left-panel, .bundle-panel, .cost-summary, .payer-info,
.ll-search-results, .checkout-left, .checkout-right {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

a, button, input, select, summary {
  transition: background-color var(--dur) var(--ease),
              border-color    var(--dur) var(--ease),
              color           var(--dur) var(--ease),
              box-shadow      var(--dur) var(--ease);
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}

/* ===== 3. App frame =====
   The app is an operations surface: header, alert strips, and the decision
   cards stay pinned while each workspace column scrolls on its own. On a
   pathologically short window the page falls back to scrolling as a whole
   (min-height) rather than clipping. */
#app { display: flex; flex-direction: column; height: 100vh; min-height: 540px; }

.workspace {
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr) 340px;
  flex: 1;
  min-height: 0;   /* lets the grid shrink so the columns scroll internally */
}
.left-panel, .bundle-panel, .cost-summary { overflow-y: auto; }

.left-panel {
  background: var(--bg-rail);
  border-right: 1px solid var(--border);
  padding: var(--sp-4);
  font-size: var(--fs-sm);
}
.bundle-panel { padding: var(--sp-4) var(--sp-5); background: var(--bg-page); }
.cost-summary {
  background: var(--bg-rail);
  border-left: 1px solid var(--border);
  padding: var(--sp-4);
  font-size: var(--fs-sm);
}

/* --- Header --- */
.app-header {
  background: var(--header-bg);
  color: var(--header-text);
  padding: var(--sp-2) var(--sp-4);
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  align-items: center;
  font-size: var(--fs-sm);
  flex: none;
}
.app-header :focus-visible { outline-color: var(--header-focus); }

.app-brand {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding-right: var(--sp-3);
  margin-right: var(--sp-1);
  border-right: 1px solid var(--header-control-border);
  font-size: var(--fs-base);
  font-weight: 600;
  letter-spacing: 0.01em;
  color: #f1f5f9;
  white-space: nowrap;
}
.app-brand img { width: 18px; height: 18px; display: block; }

/* Shared recipe for the dark header controls */
.reset-btn, .print-btn {
  background: var(--header-control);
  color: var(--header-text);
  border: 1px solid var(--header-control-border);
  border-radius: var(--r-sm);
  font-size: var(--fs-sm);
  font-weight: 500;
  line-height: 1;
  padding: 7px 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}
a.print-btn { text-decoration: none; }
.reset-btn:hover, .print-btn:hover {
  background: var(--header-control-hover);
  border-color: #475569;
  color: #ffffff;
}
/* "New patient" is the one header control staff hit on every encounter, and it
   sat in the same dark grey as the two charge-sheet buttons — three identical
   pills, and the one that starts the workflow read as another print action.
   Accent fill + a divider groups the print pair away from it. */
.reset-btn {
  background: var(--accent);
  border-color: var(--accent-strong);
  color: #ffffff;
  font-weight: 600;
}
.reset-btn:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}
.header-divider {
  width: 1px;
  align-self: stretch;
  margin: 2px var(--sp-1);
  background: var(--header-control-border);
}

/* --- Patient context bar (below the header) ---
   Payer is the first input for a new patient, so it leads the flow here
   instead of hiding top-right; the view switch picks the workspace. */
.context-bar {
  flex: none;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--sp-4);
  padding: var(--sp-2) var(--sp-4);
  background: var(--bg-page);
  border-bottom: 1px solid var(--border);
}
.ctx-field { display: flex; align-items: center; gap: var(--sp-2); }
.ctx-field > span {
  font-size: var(--fs-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: var(--tracking-caps);
  color: var(--text-muted);
}
.ctx-field select {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border-strong);
  padding: 6px 10px;
  border-radius: var(--r-sm);
  font-size: var(--fs-base);
  font-weight: 500;
  min-width: 300px;
  max-width: 440px;
}
.ctx-field select:hover { border-color: var(--text-faint); }

/* Two-segment workspace switch (Auth & Estimate | Checkout) */
.view-switch {
  margin-left: auto;
  display: inline-flex;
  gap: 2px;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 2px;
}
.view-switch button {
  border: none;
  background: none;
  border-radius: var(--r-sm);
  font-size: var(--fs-sm);
  line-height: var(--lh-sm);
  font-weight: 500;
  color: var(--text-muted);
  padding: 3px 12px;
  white-space: nowrap;
}
.view-switch button:hover { color: var(--text); }
.view-switch button[aria-pressed="true"] {
  background: var(--bg-card);
  color: var(--text);
  font-weight: 600;
  box-shadow: var(--shadow-xs);
}

.settings-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: var(--r-sm);
  color: var(--header-muted);
  text-decoration: none;
  font-size: 17px;
}
.settings-link:hover { background: var(--header-control); color: #ffffff; }

/* Right-side header group: not-signed-in warning + indicator/menu + gear. The
   group owns the auto-margin so it stays pinned right whether the warning shows. */
.header-right {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
  justify-content: flex-end;
}
/* Loud not-signed-in warning, to the LEFT of the indicator. Bright red for the
   dark header; larger than the small header text so it reads as an alert. */
.signin-warning {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: #f87171;            /* red-400 — high contrast on the navy header */
  font-size: 0.95rem;
  font-weight: 700;
}
.signin-warning[hidden] { display: none; }
.signin-warning .warn-ico { font-size: 1.05em; }

/* Signed-in indicator + auth menu (header, before ⚙). It's a <button>; clicking
   opens the auth menu. */
.signin-status {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  max-width: 18rem;
  font: inherit;
  font-size: 0.8rem;
  color: var(--header-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 3px 6px;
  border-radius: var(--r-sm);
}
.signin-status:hover { background: var(--header-control); color: #ffffff; }
.signin-status .signin-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--ok); flex: none;
}
.signin-status.is-out .signin-dot { background: var(--header-muted); }
.signin-status .signin-email { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.signin-status .signin-caret { font-size: 0.7em; opacity: 0.8; flex: none; }

.auth-menu {
  position: fixed;
  z-index: 60;
  min-width: 12rem;
  background: var(--bg-surface, #fff);
  border: 1px solid var(--border, #d7dee8);
  border-radius: var(--r-md, 8px);
  box-shadow: 0 6px 24px rgba(15, 23, 42, 0.18);
  padding: var(--sp-1);
  display: flex;
  flex-direction: column;
}
.auth-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  border-radius: var(--r-sm);
  padding: var(--sp-2) var(--sp-3);
  font: inherit;
  color: var(--text);
  cursor: pointer;
}
.auth-menu-item:hover { background: var(--accent-bg); color: var(--accent-text); }

/* --- Settings slide-over drawer --- */
.drawer-overlay {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 70;
}
.settings-drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: min(440px, 92vw);
  background: var(--bg-surface, #fff);
  box-shadow: -8px 0 28px rgba(15, 23, 42, 0.22);
  z-index: 71;
  display: flex;
  flex-direction: column;
}
.settings-drawer .drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border, #d7dee8);
}
.settings-drawer .drawer-head h2 { margin: 0; font-size: 1.05rem; }
.drawer-close {
  background: transparent; border: none; cursor: pointer;
  font-size: 22px; line-height: 1; color: var(--text-muted);
  width: 32px; height: 32px; border-radius: var(--r-sm);
}
.drawer-close:hover { background: var(--accent-bg); color: var(--accent-text); }
.settings-drawer .drawer-body {
  padding: var(--sp-4);
  overflow-y: auto;
  flex: 1;
}

/* --- Alert strips (between header and workspace) --- */
.requirements-banner {
  flex: none;
  padding: 10px var(--sp-4);
  font-size: var(--fs-base);
  background: var(--warn-bg);
  color: var(--warn-text-strong);
  border-left: 4px solid var(--warn);
  border-bottom: 1px solid var(--warn-border);
}
.requirements-banner a {
  color: var(--warn-text-strong);
  font-weight: 500;
  text-underline-offset: 2px;
}

/* "We haven't been getting paid on these" (core/payFlags.js): same amber alarm as the
   requirements banner, one line per code, capped so it can't squeeze the workspace. */
.pay-flags {
  flex: none;
  max-height: 9.5em;
  overflow-y: auto;
  padding: 8px var(--sp-4);
  font-size: var(--fs-base);
  background: var(--warn-bg);
  color: var(--warn-text-strong);
  border-left: 4px solid var(--warn);
  border-bottom: 1px solid var(--warn-border);
}
.pay-flags-list { margin: 4px 0 0; padding-left: 1.2em; }
.pay-flags-list li { margin: 2px 0; }
.pay-flags .pf-action { color: var(--warn-text); }

/* Always-on payer reference (portal + phone + notes) for any selected payer,
   including when auth is NOT required. Blue = reference, amber = alarm; the
   two strips must never be confusable. Capped height so a long payer note
   can't squeeze the workspace — the strip scrolls instead. */
.payer-info {
  flex: none;
  padding: var(--sp-2) var(--sp-4);
  font-size: var(--fs-sm);
  line-height: var(--lh-sm);
  background: var(--accent-bg);
  color: var(--text-secondary);
  border-left: 4px solid var(--accent);
  border-bottom: 1px solid var(--border);
  max-height: 140px;
  overflow-y: auto;
}
.payer-info .pi-head { font-weight: 600; color: var(--text); }
.payer-info .pi-status { color: var(--text-muted); margin-top: 1px; }
.payer-info .pi-status.pi-required { color: var(--warn-text); font-weight: 600; }
.payer-info .pi-status.pi-verify   { color: var(--warn-text); }
.payer-info .pi-portal { margin-top: 2px; }
.payer-info a { text-underline-offset: 2px; }
.payer-info .pi-notes { margin-top: var(--sp-1); color: var(--text-muted); }
/* Active subplan note (TRICARE program / MA plan variant) — slightly stronger
   than the muted notes since it carries the cost-share caveat for the pick. */
.payer-info .pi-subplan { margin-top: var(--sp-1); color: var(--text-secondary); }
.payer-info .pi-subplan b { color: var(--text); }
.payer-info .pi-subplan.pi-subplan-prompt { color: var(--warn-text); }
.payer-info .pi-subplan.pi-subplan-prompt b { color: var(--warn-text-strong); }
.payer-info .pi-actions { margin-top: var(--sp-1); }
.payer-info .pi-copy {
  font: inherit; font-size: 0.85em; padding: 2px 8px; border-radius: 6px;
  border: 1px solid var(--border, #cbd5e1); background: var(--surface, #fff);
  color: var(--text); cursor: pointer;
}
.payer-info .pi-copy:hover { background: var(--surface-hover, #f1f5f9); }

/* ===== 4. Components ===== */

/* --- Shared: uppercase section label (left rail, cost summary, bundle) --- */
.ll-step-label, .cs-label, .bundle-heading {
  font-size: var(--fs-xs);
  line-height: var(--lh-xs);
  text-transform: uppercase;
  letter-spacing: var(--tracking-caps);
  font-weight: 600;
  color: var(--text-muted);
}

/* --- Left rail: procedure + body-site picker --- */
.ll-step { margin-bottom: var(--sp-5); }
.ll-step-label { margin-bottom: var(--sp-2); }
.ll-list { display: flex; flex-direction: column; gap: var(--sp-1); }

/* Selectable chips: white resting, blue selected. The selected state keys
   on bg + border + weight, not color alone. */
.ll-proc-btn, .ll-site-btn, .subsite-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  text-align: left;
}
.ll-proc-btn:hover, .ll-site-btn:hover, .subsite-btn:hover {
  border-color: var(--border-strong);
  background: var(--bg-rail);
  color: var(--text);
}
.ll-proc-btn.active, .ll-site-btn.active, .subsite-btn.active {
  background: var(--accent-bg);
  border-color: var(--accent-border);
  color: var(--accent-text);
  font-weight: 600;
}
.ll-proc-btn { padding: 7px 10px; }
.ll-site-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-1);
  margin-bottom: var(--sp-2);
}
.ll-site-btn { padding: 5px 8px; text-align: center; text-transform: capitalize; }
.subsite-row { display: flex; flex-wrap: wrap; gap: var(--sp-1); margin-top: var(--sp-2); }
.subsite-btn { padding: 3px 8px; font-size: var(--fs-xs); text-transform: capitalize; }

.ll-field {
  display: block;
  font-size: var(--fs-sm);
  color: var(--text-muted);
  margin-top: var(--sp-2);
}
.ll-hint { font-size: var(--fs-sm); color: var(--text-muted); margin-top: 4px; line-height: 1.3; }
.ll-field select, .ll-field input,
.ll-step-search input {
  display: block;
  width: 100%;
  padding: 6px var(--sp-2);
  font-size: var(--fs-base);
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  margin-top: 3px;
}

.ll-search-results {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  margin-top: var(--sp-2);
  max-height: 320px;
  overflow-y: auto;
}
.ll-result {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: var(--sp-2);
  border-radius: var(--r-md);
  font-size: var(--fs-sm);
}
.ll-result-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); }
.ll-result-head b { font-variant-numeric: tabular-nums; }
.ll-result-add {
  background: var(--accent);
  color: #ffffff;
  border: 1px solid var(--accent);
  padding: 2px 8px;
  border-radius: var(--r-sm);
  font-size: var(--fs-sm);
  font-weight: 500;
}
.ll-result-add:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.ll-result-desc { color: var(--text); margin: 2px 0; }
.ll-result-meta { color: var(--text-muted); }

/* --- Bundle panel (center) --- */
.bundle-heading { margin: 0 0 var(--sp-3); }

.bundle-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-base);
  font-variant-numeric: tabular-nums;
}
.bundle-table th {
  text-align: left;
  padding: var(--sp-1) var(--sp-2) 6px;
  color: var(--text-muted);
  font-size: var(--fs-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: var(--tracking-caps);
  border-bottom: 1px solid var(--border);
}
.bundle-table td {
  padding: 7px var(--sp-2);
  border-bottom: 1px solid var(--divider);
}
.bundle-table tbody tr:hover td { background: var(--bg-rail); }
.bundle-table .num { text-align: right; }
.mpr-note { color: var(--text-muted); font-size: var(--fs-sm); font-style: italic; }
/* "MPR" eligibility tag in the auth list: marks codes that participate in
   multiple-procedure reduction. The list itself always shows FULL rates —
   the reduction is applied in the estimate scenarios and checkout. */
.mpr-tag {
  display: inline-block;
  font-size: 10px;
  line-height: 14px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0 5px;
  vertical-align: 1px;
  cursor: help;
}

.remove-btn, .addl-proc-remove, .scenario-remove {
  background: none;
  border: none;
  color: var(--text-faint);
  font-size: 14px;
  line-height: 1;
  padding: 3px 6px;
  border-radius: var(--r-sm);
}
.remove-btn:hover, .addl-proc-remove:hover, .scenario-remove:hover {
  color: var(--danger);
  background: var(--danger-bg);
}

.bundle-meta {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  margin-top: var(--sp-3);
  border-top: 1px solid var(--border);
  padding-top: var(--sp-3);
}

/* Amber asterisk on codes priced with a placeholder rate */
.placeholder-marker { color: #d97706; font-weight: 700; margin-left: 1px; }
.placeholder-footnote {
  display: block;
  margin-top: var(--sp-1);
  color: var(--text-muted);
  font-size: var(--fs-xs);
}

/* --- Additional procedures (multi-procedure estimate, v1.4) --- */
.addl-procs { margin: 0 0 var(--sp-3); display: flex; flex-direction: column; gap: var(--sp-1); }
.addl-procs .addl-proc-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  padding: 6px 10px;
  background: var(--bg-rail);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-size: var(--fs-sm);
  color: var(--text-secondary);
}
.add-procedure-btn {
  align-self: flex-start;
  padding: 5px 12px;
  font-size: var(--fs-sm);
  font-weight: 500;
  background: none;
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-md);
  color: var(--text-muted);
}
.add-procedure-btn:hover {
  border-color: var(--accent-border);
  color: var(--accent-strong);
  background: var(--accent-bg);
}
.add-procedure-draft {
  display: flex;
  gap: var(--sp-2);
  align-items: center;
  flex-wrap: wrap;
  padding: var(--sp-2);
  background: var(--bg-rail);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.add-procedure-draft select {
  font-size: var(--fs-sm);
  padding: 4px var(--sp-2);
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
}
.draft-add {
  background: var(--accent);
  color: #ffffff;
  border: 1px solid var(--accent);
  border-radius: var(--r-sm);
  font-size: var(--fs-sm);
  font-weight: 500;
  padding: 4px 12px;
}
.draft-add:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.draft-cancel {
  background: none;
  color: var(--text-muted);
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  font-size: var(--fs-sm);
  padding: 4px 10px;
}
.draft-cancel:hover { color: var(--text); background: var(--bg-inset); }
.addl-note {
  flex-basis: 100%;
  margin: 2px 0 0;
  font-size: var(--fs-xs);
  font-style: italic;
  color: var(--text-muted);
}

/* --- Cost summary (right rail) --- */
.cs-empty { color: var(--text-muted); font-style: italic; padding: var(--sp-2) 0; }
/* Insurance panel held until a plan is picked (force-pick payers) — amber, matching
   the payer-info "select a plan" prompt. */
.ins-subplan-prompt { color: var(--warn-text); font-style: italic; padding: var(--sp-2) 0; }
/* Held "—" in the codes table money column until a plan is picked. */
.num-held { color: var(--text-muted); }
.cs-label { margin-bottom: var(--sp-2); }

.cs-copy-group { display: flex; gap: var(--sp-1); flex-wrap: wrap; margin-bottom: var(--sp-3); }
.cs-copy-summary {
  background: var(--bg-card);
  border: 1px solid var(--accent-border);
  color: var(--accent-strong);
  padding: 3px 8px;
  border-radius: var(--r-sm);
  font-size: var(--fs-xs);
  font-weight: 500;
}
.cs-copy-summary:hover { background: var(--accent-bg); border-color: var(--accent); }

.cs-tier-label { font-size: var(--fs-sm); color: var(--text-muted); }
.cs-value {
  font-size: var(--fs-lg);
  line-height: var(--lh-lg);
  font-weight: 650;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.cs-foot {
  margin-top: var(--sp-3);
  color: var(--text-muted);
  font-size: var(--fs-sm);
  border-top: 1px solid var(--border);
  padding-top: var(--sp-2);
}

/* Insurance math breakdown (deductible / coinsurance / OOP rows) */
.cs-breakdown {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  margin-bottom: var(--sp-3);
  line-height: 1.55;
}
/* The breakdown figures come from the HIGH scenario — the title says so */
.cs-breakdown-title {
  font-size: var(--fs-xs, 11px);
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 2px;
}
/* Fee-schedule vintage note in the cost-summary footer */
.cs-rates-vintage { font-size: var(--fs-xs, 11px); color: var(--text-muted); }
.cs-breakdown-row { display: flex; justify-content: space-between; align-items: baseline; gap: var(--sp-2); }
.cs-breakdown-amount { font-variant-numeric: tabular-nums; color: var(--text-secondary); }
.cs-secondary { color: var(--text); font-weight: 500; margin-top: 2px; }
.cs-caveats { font-style: italic; color: var(--warn-text); margin-top: var(--sp-1); font-size: var(--fs-sm); }

/* Workspace sign-in banner (and its amber stale-rates variant) */
.signin-banner {
  background: var(--info-bg);
  border: 1px solid var(--info-border);
  color: var(--info-text);
  padding: var(--sp-2) 10px;
  border-radius: var(--r-md);
  margin-bottom: var(--sp-3);
  font-size: var(--fs-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
}
.signin-btn {
  background: var(--info-action);
  color: #ffffff;
  border: none;
  padding: 5px 10px;
  border-radius: var(--r-sm);
  font-size: var(--fs-sm);
  font-weight: 500;
  flex: none;
}
.signin-btn:hover { background: var(--info-action-hover); }
.signin-banner-stale {
  background: var(--warn-bg);
  border-color: var(--warn-border);
  color: var(--warn-text-strong);
}

/* Insurance details disclosure */
.ins-panel { margin-bottom: var(--sp-3); padding-bottom: var(--sp-2); border-bottom: 1px solid var(--border); }
.ins-panel summary {
  cursor: pointer;
  font-size: var(--fs-xs);
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: var(--tracking-caps);
  padding: var(--sp-1) 0;
  user-select: none;
  border-radius: var(--r-sm);
}
.ins-panel summary:hover { color: var(--text-secondary); }
.ins-panel summary::marker { color: var(--text-faint); }
.ins-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-2); margin-top: var(--sp-2); }
.ins-field { display: flex; flex-direction: column; font-size: var(--fs-sm); color: var(--text-muted); }
.ins-field-wide { grid-column: 1 / -1; }

/* Quick-benefits strip — the four patient-responsibility numbers in one compact
   row so staff key them straight off a ModMed eligibility check (Tab or Enter to
   advance) instead of clicking field to field. Secondary insurance sits on its
   own line below. */
.ins-quick { display: flex; gap: var(--sp-2); margin-top: var(--sp-2); align-items: flex-end; }
.ins-qfield {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  flex: 1 1 0;
  min-width: 0;
  gap: 2px;
  font-size: var(--fs-xs);
  color: var(--text-muted);
  /* Bottom-align the inputs even if a label wraps in a narrow column. */
  white-space: nowrap;
}
.ins-qinput { margin-top: 0; text-align: right; }
.ins-field-secondary {
  display: flex;
  flex-direction: column;
  margin-top: var(--sp-2);
  font-size: var(--fs-sm);
  color: var(--text-muted);
}
.ins-input {
  padding: 5px var(--sp-2);
  font-size: var(--fs-base);
  color: var(--text);
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  margin-top: 3px;
  width: 100%;
  font-variant-numeric: tabular-nums;
}
/* Hide the number-input spinners: staff type values directly, and the
   arrows are easy to click by accident while editing. */
.ins-input::-webkit-outer-spin-button,
.ins-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.ins-input[type="number"] { -moz-appearance: textfield; appearance: textfield; }

/* Cost-share confidence tints — prefill provenance for the four patient-
   responsibility inputs. Green = confident or staff-entered, amber = plan
   default to verify, red = no public source (enter manually). Light fills via
   the --*-bg tokens; a same-hue border firms the signal without shouting.
   Both insurance UIs use .ins-input, so .ins-input.cs-* covers the cost-summary
   panel and the checkout block. Source → class mapping: core/costShare.js. */
.ins-input.cs-confident { background: var(--ok-bg);     border-color: var(--ok-border); }
.ins-input.cs-verify    { background: var(--warn-bg);   border-color: var(--warn-border); }
.ins-input.cs-none      { background: var(--danger-bg); border-color: var(--danger-border); }

/* Legend under the cost-summary insurance grid. */
.ins-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-1) var(--sp-3);
  margin-top: var(--sp-2);
  font-size: var(--fs-xs);
  color: var(--text-muted);
}
.ins-legend-item { display: inline-flex; align-items: center; gap: 4px; }
.cs-swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  border: 1px solid;
  flex: none;
}
.cs-swatch.cs-confident { background: var(--ok-bg);     border-color: var(--ok-border); }
.cs-swatch.cs-verify    { background: var(--warn-bg);   border-color: var(--warn-border); }
.cs-swatch.cs-none      { background: var(--danger-bg); border-color: var(--danger-border); }

/* Print prefilled charge sheet — sits directly under the Insurance details
   panel so staff verify/enter benefits before printing. Full-width accent
   action to read as the panel's primary follow-up. */
.ins-print-prefilled {
  display: block;
  width: 100%;
  margin: 0 0 var(--sp-3);
  padding: 7px 12px;
  background: var(--accent);
  color: #ffffff;
  border: 1px solid var(--accent);
  border-radius: var(--r-sm);
  font-size: var(--fs-sm);
  font-weight: 500;
  cursor: pointer;
}
.ins-print-prefilled:hover { background: var(--accent-strong); border-color: var(--accent-strong); }

/* Scenario disclosures (Low end / High end editable code lists) */
.cs-scenario { margin-bottom: var(--sp-3); }
.cs-scenario-head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--sp-2); }
.cs-scenario-details { margin-top: 2px; }
.cs-scenario-details summary {
  cursor: pointer;
  font-size: var(--fs-sm);
  color: var(--text-muted);
  padding: 2px 0;
  user-select: none;
}
.cs-scenario-details summary:hover { color: var(--text-secondary); }
.scenario-edit-toggle, .scenario-copy-toggle {
  background: none;
  border: none;
  color: var(--accent-strong);
  font-size: var(--fs-sm);
  padding: 0 var(--sp-1);
  margin-left: var(--sp-1);
  border-radius: 4px;
}
.scenario-edit-toggle:hover, .scenario-copy-toggle:hover { text-decoration: underline; }
/* "edited" tag on a hand-modified scenario — informational, not a warning */
.scenario-dirty { color: var(--text-muted); font-style: italic; margin: 0 var(--sp-1); font-size: var(--fs-xs); cursor: help; }
.scenario-stale-note { color: var(--warn-text); font-size: var(--fs-xs); margin: var(--sp-1) 0; }
.scenario-list { list-style: none; padding: var(--sp-1) 0 0; margin: 0; }
.scenario-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: var(--fs-sm);
  padding: 2px 0;
  gap: var(--sp-2);
}
.scenario-code { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scenario-unit-idx { color: var(--text-muted); font-size: var(--fs-xs); }
.scenario-meta { color: var(--text-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.scenario-meta em { font-style: normal; font-size: var(--fs-xs); }
.scenario-add { display: flex; gap: var(--sp-1); margin-top: var(--sp-2); }
.scenario-add-input {
  flex: 1;
  min-width: 0;
  padding: 3px 6px;
  font-size: var(--fs-sm);
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
}
.scenario-reset {
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  color: var(--text-secondary);
  padding: 3px 8px;
  border-radius: var(--r-sm);
  font-size: var(--fs-xs);
  white-space: nowrap;
}
.scenario-reset:hover { background: var(--bg-rail); border-color: var(--text-faint); }

/* --- Cosmetic mode --- */
.cos-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  padding: var(--sp-2) 0;
  border-bottom: 1px solid var(--divider);
  font-size: var(--fs-base);
}
.cos-item-label { flex: 1; }
.cos-item-main { flex: 1; }
.cos-item-main .cos-item-label { flex: none; }
.cos-item-note { font-size: var(--fs-xs); color: var(--text-muted); margin-top: 2px; }
.cos-group-head {
  font-size: var(--fs-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin: var(--sp-3) 0 var(--sp-1);
}
.cos-item.is-active {
  background: var(--accent-bg);
  box-shadow: inset 3px 0 0 var(--accent);
  padding-left: var(--sp-2);
  margin-left: calc(var(--sp-2) * -1);
}
.cos-item-price {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  margin-top: 1px;
}
.cos-quote-tag {
  font-size: var(--fs-xs);
  color: var(--text-faint);
  font-style: italic;
  white-space: nowrap;
}

/* Quantity stepper. The native <input type=number> spinners this replaces were
   ~10px tall, appeared on all 15 rows at once, and were a coin-flip to hit —
   these are real buttons with a proper target, and the field is a text input so
   no browser draws its own arrows on top. */
.cos-stepper {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: none;
}
.cos-step {
  width: 26px;
  height: 26px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--fs-base);
  line-height: 1;
  color: var(--text-secondary);
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  cursor: pointer;
  user-select: none;
}
.cos-step:hover:not(:disabled) { background: var(--bg-inset); border-color: var(--text-faint); }
.cos-step:disabled { opacity: 0.35; cursor: default; }
.cos-qty {
  width: 46px;
  padding: 4px var(--sp-1);
  font-size: var(--fs-base);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  text-align: center;
  font-variant-numeric: tabular-nums;
}
/* Belt-and-braces: if one of these ever goes back to type=number, still no
   spinners. Chrome/Safari use the pseudo-element, Firefox the property. */
.cos-qty::-webkit-outer-spin-button,
.cos-qty::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.cos-qty[type="number"] { -moz-appearance: textfield; appearance: textfield; }

/* Custom-priced rows (benign mole removal): the amount is quoted at the
   consultation, so staff type it. Text input, not type=number — see the
   stepper note above. */
.cos-price-wrap {
  display: flex;
  align-items: center;
  gap: 3px;
  margin-top: var(--sp-1);
}
.cos-price-prefix { font-size: var(--fs-xs); color: var(--text-muted); }
.cos-price {
  width: 96px;
  padding: 3px var(--sp-1);
  font-size: var(--fs-sm);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  font-variant-numeric: tabular-nums;
}

/* Consultation-fee credit toggle, shown under the consult row once it's on the
   estimate. The fee is charged and then credited rather than dropped, so the
   patient's estimate shows both halves. */
.cos-credit {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-1);
  margin-top: var(--sp-1);
  font-size: var(--fs-xs);
  color: var(--text-secondary);
  cursor: pointer;
}
.cos-credit input { margin: 1px 0 0; flex: none; }
.cos-credit-row td { color: var(--ok-text); font-style: italic; }

/* Amount + date for a consult fee collected at an earlier visit. Sits under
   its checkbox, indented to the checkbox's label so the pair reads as one
   control rather than two stacked ones. */
.cos-prior-fields {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-left: 18px;
}
.cos-prior-fields .cos-price-wrap { margin-top: var(--sp-1); }
.cos-prior-date {
  margin-top: var(--sp-1);
  padding: 3px var(--sp-1);
  font-size: var(--fs-sm);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  font-variant-numeric: tabular-nums;
}

/* Filter box — 15+ items across four groups is too many to scan by eye. */
.cos-filter-wrap { position: sticky; top: 0; z-index: 2; background: var(--bg-rail); padding-bottom: var(--sp-2); }
.cos-filter {
  width: 100%;
  padding: 6px var(--sp-2);
  font-size: var(--fs-base);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
}
.cos-no-match { font-size: var(--fs-sm); color: var(--text-muted); padding: var(--sp-3) 0; }

/* Running total pinned under the picker, so the number stays on screen while
   the price list scrolls. */
.cos-running {
  position: sticky;
  bottom: 0;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-2);
  margin-top: var(--sp-2);
  padding: var(--sp-2);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
}
.cos-running-label { font-size: var(--fs-xs); color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.cos-running-amt { font-size: var(--fs-lg); font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }

/* Center table */
.cos-center-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); }
.cos-clear {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  background: none;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  padding: 2px var(--sp-2);
  cursor: pointer;
}
.cos-clear:hover { background: var(--bg-inset); color: var(--text); }
.cos-table .cos-detail { font-size: var(--fs-sm); color: var(--text-muted); }
.cos-remove {
  background: none;
  border: none;
  color: var(--text-faint);
  font-size: var(--fs-base);
  line-height: 1;
  padding: 2px 4px;
  cursor: pointer;
  border-radius: var(--r-sm);
}
.cos-remove:hover { color: var(--danger); background: var(--danger-bg); }

/* The grand total. This is the number the whole tab exists to produce, so it
   gets display weight rather than sitting in a caption line. */
.cos-grand {
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: var(--sp-3);
  margin-top: var(--sp-2);
  padding-top: var(--sp-2);
  border-top: 2px solid var(--text);
}
.cos-grand-label { font-size: var(--fs-sm); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-secondary); }
.cos-grand-amt { font-size: 24px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.cos-grand-hint { font-size: var(--fs-sm); color: var(--text-muted); font-weight: 400; }

/* Cosmetic items inside the checkout register (left column) and the collect
   breakdown (right column). */
.checkout-cosmetic { margin-bottom: var(--sp-3); }
.checkout-cosmetic table { width: 100%; border-collapse: collapse; }
.checkout-cosmetic th {
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  text-align: left;
  font-weight: 600;
  padding-bottom: var(--sp-1);
}
.checkout-cosmetic td { padding: var(--sp-1) 0; border-bottom: 1px solid var(--divider); }
.checkout-cosmetic .num, .ck-cosmetic-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.cos-qty-read {
  min-width: 28px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-size: var(--fs-base);
}
.ck-cosmetic-table { width: 100%; border-collapse: collapse; margin-bottom: var(--sp-2); }
.ck-cosmetic-table th {
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  text-align: left;
  font-weight: 600;
}
.ck-cosmetic-table td { padding: 2px 0; border-bottom: 1px solid var(--divider); }
.ck-cos-detail { font-size: var(--fs-sm); color: var(--text-muted); }

/* --- Decision cards (pinned footer) ---
   Glanceable status rail: every card carries a colored left bar + dot.
   All four green = nothing to do; amber = action before treatment. VERIFY
   uses a dashed bar so it stays distinct from REQUIRED for color-blind
   users; the state word is always spelled out in the card head anyway. */
.decision-row {
  flex: none;
  background: var(--bg-inset);
  padding: var(--sp-3) var(--sp-4);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  font-size: var(--fs-sm);
  border-top: 1px solid var(--border);
}
.decision-card {
  --card-accent: var(--border-strong);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--card-accent);
  border-radius: var(--r-md);
  padding: 10px var(--sp-3);
  box-shadow: var(--shadow-xs);
  min-width: 0;
}
.decision-card.required   { --card-accent: var(--warn); }
.decision-card.verify     { --card-accent: var(--warn); border-left-style: dashed; }
.decision-card.not-needed { --card-accent: var(--ok); }
.decision-card.optional   { --card-accent: var(--border-strong); }
.decision-card.ready      { --card-accent: var(--ready); }
.decision-card .head {
  font-size: var(--fs-xs);
  line-height: var(--lh-xs);
  text-transform: uppercase;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: var(--tracking-caps);
  display: flex;
  align-items: center;
  gap: 6px;
}
.decision-card .head::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--card-accent);
  flex: none;
}
.decision-card.required .head { color: var(--warn-text); }
.decision-card .title { font-weight: 600; margin-top: 2px; color: var(--text); }
/* Inline nudge under a card's title (e.g. verify-benefits-in-ModMed on Estimate). */
.decision-card .card-note {
  margin-top: 4px;
  font-size: var(--fs-xs);
  line-height: var(--lh-xs);
  font-weight: 500;
  color: var(--warn-text);
}
.decision-card .meta { font-size: var(--fs-sm); color: var(--text-muted); }
.decision-card .card-actions { margin-top: var(--sp-2); display: flex; flex-wrap: wrap; gap: var(--sp-1); }
.decision-card .card-action {
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  color: var(--text-secondary);
  font-size: var(--fs-sm);
  font-weight: 500;
  padding: 3px 8px;
  border-radius: var(--r-sm);
}
.decision-card .card-action:hover {
  background: var(--bg-rail);
  border-color: var(--text-faint);
  color: var(--text);
}
.decision-card .card-action.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}
.decision-card .card-action.primary:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

/* --- Toast --- */
#toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: var(--header-bg);
  color: #f8fafc;
  padding: 10px var(--sp-4);
  border-radius: var(--r-md);
  font-size: var(--fs-base);
  box-shadow: var(--shadow-toast);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms var(--ease), transform 180ms var(--ease);
  z-index: 1000;
  max-width: min(560px, calc(100vw - 48px));
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
@media (prefers-reduced-motion: reduce) {
  #toast { transform: translateX(-50%); }
}

/* ===== 5. Checkout mode ===== */
.checkout-workspace {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-4);
  padding: var(--sp-4);
  flex: 1;
  min-height: 0;
  background: var(--bg-rail);
}
.checkout-left, .checkout-right {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  padding: var(--sp-4) 18px;
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xs);
  overflow-y: auto;
  min-width: 0;
}
.checkout-left h3, .checkout-right h3 {
  margin: 0 0 var(--sp-3);
  font-size: var(--fs-md);
  line-height: var(--lh-md);
  font-weight: 600;
  color: var(--text);
}
.checkout-left h4 {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: var(--tracking-caps);
  font-weight: 600;
  margin: var(--sp-4) 0 var(--sp-2);
}
.checkout-insurance label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--fs-sm);
  margin: 6px 0;
  color: var(--text-secondary);
}
.checkout-insurance input, .checkout-insurance select {
  width: 132px;
  padding: 5px var(--sp-2);
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  font-size: var(--fs-base);
}
.checkout-insurance input { font-variant-numeric: tabular-nums; }

.checkout-codes table, .ck-breakdown {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-base);
  margin-top: var(--sp-2);
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.checkout-codes th, .ck-breakdown th {
  text-align: left;
  color: var(--text-muted);
  font-size: var(--fs-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: var(--tracking-caps);
}
.checkout-codes th, .checkout-codes td,
.ck-breakdown th, .ck-breakdown td {
  border-bottom: 1px solid var(--divider);
  padding: 6px var(--sp-1);
}
.checkout-add { margin-top: var(--sp-3); display: flex; gap: var(--sp-2); }
.checkout-add input {
  flex: 1;
  min-width: 0;
  padding: 6px var(--sp-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
}
/* Primary action of the panel: the receptionist's main entry path */
.checkout-add button {
  background: var(--accent);
  color: #ffffff;
  border: 1px solid var(--accent);
  border-radius: var(--r-sm);
  font-size: var(--fs-base);
  font-weight: 500;
  padding: 6px 14px;
}
.checkout-add button:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
/* Per-row ✕ in the codes-billed table (class-less in the JS template) */
.checkout-codes td button {
  background: none;
  border: none;
  color: var(--text-faint);
  font-size: 13px;
  line-height: 1;
  padding: 3px 6px;
  border-radius: var(--r-sm);
}
.checkout-codes td button:hover { color: var(--danger); background: var(--danger-bg); }
.ck-warn { color: var(--warn-text); font-size: var(--fs-xs); }
/* Explains a credit that did not fully apply. Muted, not a warning: nothing is
   wrong, the number just needs a reason attached. */
.ck-note { font-size: var(--fs-xs); color: var(--text-secondary); margin-left: 18px; }
.ck-units-input,
.bundle-units-input {
  width: 56px;
  padding: 4px 6px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Bundle table units cell: keep the "×" glyph snug against its input */
.bundle-table .units-cell {
  white-space: nowrap;
}
.bundle-units-input {
  width: 48px;
  margin-left: 2px;
}

/* Right column: the number the receptionist actually collects */
.checkout-total {
  font-size: var(--fs-display);
  line-height: var(--lh-display);
  font-weight: 700;
  color: var(--ok);
  text-align: center;
  margin: var(--sp-5) 0;
  font-variant-numeric: tabular-nums;
}
.checkout-split {
  font-size: var(--fs-base);
  text-align: center;
  margin: var(--sp-4) 0;
  color: var(--text-secondary);
}
.checkout-split b {
  color: var(--ok-text);
  font-size: var(--fs-lg);
  font-variant-numeric: tabular-nums;
}
.checkout-split hr { border: none; border-top: 1px dashed var(--border-strong); margin: var(--sp-2) auto; max-width: 220px; }
.ck-bundled { color: var(--text-muted); font-style: italic; }
.ck-mpr { color: var(--warn-text); font-size: var(--fs-xs); }
.ck-ins-breakdown {
  width: 100%;
  font-size: var(--fs-sm);
  margin-top: var(--sp-3);
  color: var(--text-secondary);
}
.ck-ins-breakdown td { padding: 2px 0; }
.ck-ins-breakdown td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.ck-caveats { font-size: var(--fs-xs); color: var(--warn-text); margin-top: var(--sp-2); }
.ck-empty {
  font-size: var(--fs-base);
  color: var(--text-muted);
  font-style: italic;
  padding: var(--sp-6) var(--sp-4);
  text-align: center;
}
.checkout-actions { margin-top: var(--sp-3); display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.checkout-actions button {
  font-size: var(--fs-sm);
  font-weight: 500;
  padding: 6px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  color: var(--text-secondary);
  border-radius: var(--r-sm);
}
.checkout-actions button:hover {
  background: var(--bg-rail);
  border-color: var(--text-faint);
  color: var(--text);
}

/* ===== 6. Settings page + in-app drawer =====
   Typography/controls use .settings-page so BOTH the Options page and the in-app
   settings drawer pick them up; the full-page card layout stays body-scoped. */
body.settings-page { background: var(--bg-rail); }
.settings-page #app {
  display: block;            /* override the app-frame flex column */
  height: auto;
  min-height: 0;
  max-width: 640px;
  margin: var(--sp-8) auto;
  padding: var(--sp-6) 36px var(--sp-6);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}
.settings-page h2 {
  margin: 0 0 var(--sp-1);
  font-size: var(--fs-xl);
  line-height: var(--lh-xl);
  font-weight: 650;
  letter-spacing: -0.01em;
  color: var(--text);
}
.settings-page h3 {
  margin: var(--sp-6) 0 var(--sp-2);
  padding-top: var(--sp-5);
  border-top: 1px solid var(--border);
  font-size: var(--fs-md);
  line-height: var(--lh-md);
  font-weight: 600;
  color: var(--text);
}
.settings-page label {
  display: block;
  margin: var(--sp-4) 0 0;
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--text-secondary);
}
.settings-page label .optional { font-weight: 400; color: var(--text-muted); }
.settings-page label > input,
.settings-page label > select {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 7px 10px;
  font-size: var(--fs-base);
  color: var(--text);
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
}
.settings-page .input-with-button { display: flex; gap: var(--sp-2); margin-top: 6px; }
.settings-page .input-with-button > input { flex: 1; margin-top: 0; }
.settings-page p.help {
  margin: 6px 0 0;
  font-size: var(--fs-sm);
  line-height: 1.55;
  color: var(--text-muted);
}
.settings-page .actions {
  margin-top: var(--sp-6);
  padding-top: var(--sp-5);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}
.settings-page #save {
  background: var(--accent);
  color: #ffffff;
  border: 1px solid var(--accent);
  padding: 7px 18px;
  border-radius: var(--r-sm);
  font-size: var(--fs-base);
  font-weight: 500;
}
.settings-page #save:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.settings-page #status { font-size: var(--fs-sm); color: var(--ok-text); min-height: 1em; }
.settings-page .action-secondary,
.settings-page #practiceTinShow {
  background: var(--bg-card);
  color: var(--text-secondary);
  border: 1px solid var(--border-strong);
  padding: 6px 12px;
  border-radius: var(--r-sm);
  font-size: var(--fs-sm);
  font-weight: 500;
}
.settings-page .action-secondary:hover,
.settings-page #practiceTinShow:hover { background: var(--bg-rail); color: var(--text); }

/* Fee-schedule section inside settings */
.settings-page #fs-section { font-size: var(--fs-base); line-height: 1.55; }
.settings-page #fs-section p { margin: var(--sp-1) 0; }
.settings-page #fs-section strong { color: var(--text); }
.settings-page #fs-section h4 {
  margin: var(--sp-4) 0 6px;
  font-size: var(--fs-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: var(--tracking-caps);
  color: var(--text-muted);
}
.settings-page #fs-section button {
  background: var(--accent);
  color: #ffffff;
  border: 1px solid var(--accent);
  padding: 6px 14px;
  border-radius: var(--r-sm);
  font-size: var(--fs-sm);
  font-weight: 500;
  margin-right: 6px;
  margin-top: var(--sp-2);
}
.settings-page #fs-section button:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.settings-page #fs-section #fs-signout-button,
.settings-page #fs-section #fs-refresh-button {
  background: var(--bg-card);
  color: var(--text-secondary);
  border: 1px solid var(--border-strong);
}
.settings-page #fs-section #fs-signout-button:hover,
.settings-page #fs-section #fs-refresh-button:hover { background: var(--bg-rail); color: var(--text); }
.settings-page #fs-section [data-testid="fs-coverage"] {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
  margin-top: var(--sp-1);
  font-variant-numeric: tabular-nums;
}
.settings-page #fs-section [data-testid="fs-coverage"] td {
  padding: 5px var(--sp-3) 5px 0;
  border-bottom: 1px solid var(--divider);
  color: var(--text);
}
.settings-page #fs-section [data-testid="fs-coverage"] td:last-child {
  text-align: right;
  color: var(--text-muted);
}

/* These used to be inline style="" attributes; the extension CSP is
   style-src 'self', which ignores those. */
.fs-coverage-heading { margin-top: var(--sp-4); }
.fs-coverage-table { font-size: var(--fs-xs); width: 100%; }

/* ===== 7. Responsive adjustments =====
   The app runs in a full browser tab; these keep laptop-width windows
   usable rather than targeting phones. */
@media (max-width: 1180px) {
  .workspace { grid-template-columns: 250px minmax(0, 1fr) 300px; }
}
@media (max-width: 1000px) {
  .decision-row { grid-template-columns: repeat(2, 1fr); }
}

/* --- Office context (2026-09-03) ------------------------------------------
   The office is not a preference, it is a fact that changes the answers: it
   decides which CPT families reach an auth request and which closure an
   estimate quotes (data/officePolicy.js). Getting it wrong quotes a patient a
   procedure the office does not perform, so it is stated three ways at once —
   a colored badge in the header, a colored rule under the context bar, and the
   pressed segment of the switch — and #app carries data-office so every
   workspace (medical, checkout, cosmetic) inherits the same signal. */
:root {
  --office-mohs:      #1d4ed8;   /* blue  — Tampa Mohs, the full surgical set */
  --office-mohs-bg:   #eff6ff;
  --office-tbderm:    #a16207;   /* amber — TB Derm, general derm only */
  --office-tbderm-bg: #fefce8;
  --office-color:     var(--office-mohs);
  --office-bg:        var(--office-mohs-bg);
}
#app[data-office="tbderm"] {
  --office-color: var(--office-tbderm);
  --office-bg:    var(--office-tbderm-bg);
}

/* Header badge — the office name sits in the brand line, always on screen. */
.office-badge {
  margin-left: var(--sp-2);
  padding: 2px 8px;
  border-radius: var(--r-sm);
  background: var(--office-color);
  color: #ffffff;
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  white-space: nowrap;
}
.office-badge:empty { display: none; }

/* The context bar carries the office's color as a rule you can't miss. */
.context-bar { border-bottom: 2px solid var(--office-color); }

.ctx-office { padding-right: var(--sp-4); border-right: 1px solid var(--border); }
.office-switch {
  display: inline-flex;
  gap: 2px;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 2px;
}
.office-switch button {
  border: none;
  background: none;
  border-radius: var(--r-sm);
  font-size: var(--fs-sm);
  line-height: var(--lh-sm);
  font-weight: 500;
  color: var(--text-muted);
  padding: 3px 12px;
  white-space: nowrap;
}
.office-switch button:hover { color: var(--text); }
.office-switch button[aria-pressed="true"] {
  background: var(--office-color);
  color: #ffffff;
  font-weight: 600;
  box-shadow: var(--shadow-xs);
}

/* Why a code is missing from a TB Derm bundle, said once under the table
   rather than as a warning per absent code. */
.office-scope-note {
  margin-top: var(--sp-2);
  padding: 6px 10px;
  border-left: 3px solid var(--office-color);
  background: var(--office-bg);
  color: var(--text-secondary);
  font-size: var(--fs-xs);
  line-height: var(--lh-sm);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
}

/* A partner office: one neutral tint (its own name is in the badge). */
#app[data-office="partner"] {
  --office-color: #475569;
  --office-bg:    #f1f5f9;
}
#office-select { font-size: var(--fs-sm); max-width: 16rem; }
