:root {
  --bg: #dde5ef;          /* app background — light blue-gray (deeper, for card contrast) */
  --panel: #ffffff;        /* cards / panels */
  --panel-2: #f1f5fa;      /* table headers, hovers, alt rows */
  --border: #d7e0ea;       /* light borders */
  --text: #1d2733;         /* dark slate text */
  --muted: #6b7888;        /* muted slate */
  --accent: #2f9bf0;       /* light blue accent */
  --accent-dim: #1f7fd0;   /* deeper blue (button bg / hover, white text) */
  --accent-soft: #e3f1fd;  /* light blue tint (hover / selected / chips) */
  --ok: #15976a;
  --warn: #c2410c;         /* burnt orange — overdue */
  --yellow: #ca8a04;       /* soft / wiggle-room (recent note, not yet overdue) */
  --err: #d92d20;
  --pk: #7c3aed;
  --fk: #2563eb;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font: 14px/1.45 -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text);
  /* App shell: header across the top, side menu on the left, one workspace panel filling the
     rest. Every main.panel occupies the same grid cell — only the .active one is displayed.
     Modal overlays are position:fixed, so the grid never affects them. */
  display: grid; grid-template-columns: 224px 1fr; grid-template-rows: auto 1fr; height: 100vh;
}
header {
  grid-column: 1 / -1;
  display: flex; align-items: center; justify-content: space-between;
  padding: 7px 16px; background: var(--panel); border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(15, 30, 50, .06);
}
.brand { display: flex; align-items: center; gap: 11px; }
.brand-logo { width: 36px; height: 36px; flex: none; }
.brand-text { line-height: 1.25; }
.brand-name { font-weight: 650; font-size: 14.5px; letter-spacing: .2px; }
.brand-sub { font-size: 11px; color: var(--muted); font-weight: 500; letter-spacing: .3px; }
.status { font-size: 12px; color: var(--muted); }
.status.ok { color: var(--ok); }
.status.bad { color: var(--err); }

/* Left side-panel menu. NOTE: no overflow on the nav — sub-menus fly out PAST its right edge
   and would be clipped by any overflow rule. Every item shares ONE type treatment (same family,
   size and weight) whether top-level or inside a flyout. */
.side-nav {
  grid-row: 2; grid-column: 1;
  display: flex; flex-direction: column; gap: 2px;
  padding: 14px 10px; background: var(--panel); border-right: 1px solid var(--border);
}
.snav-item {
  text-align: left; background: none; border: none; border-radius: 8px;
  padding: 9px 12px; font: inherit; font-size: 13.5px; font-weight: 400;
  color: var(--muted); cursor: pointer; white-space: nowrap;
}
.snav-item:hover { background: var(--panel-2); color: var(--text); }
.snav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
/* Groups: a normal menu row whose sub-menu appears as a second tier of buttons to the RIGHT. */
.snav-group { position: relative; }
.snav-parent { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.snav-caret { font-size: 16px; line-height: 1; color: var(--text); opacity: .75; }
.snav-group:hover .snav-caret, .snav-parent.active .snav-caret { opacity: 1; color: var(--accent); }
.snav-flyout {
  position: absolute; left: calc(100% - 2px); top: 0; min-width: 195px; z-index: 60;
  display: flex; flex-direction: column; gap: 2px; padding: 6px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 8px 26px rgba(15, 30, 50, .16);
  opacity: 0; visibility: hidden; transform: translateX(-4px);
  transition: opacity .13s ease, transform .13s ease, visibility .13s;
}
.snav-group:hover .snav-flyout, .snav-flyout:hover { opacity: 1; visibility: visible; transform: none; }

/* CPSI Scheduling - the MD-interval worklist as a full workspace (moved out of the admin popup;
   its admMd* ids are unchanged so all of its logic carried over untouched). */
#scheduling.panel.active { display: block; overflow-y: auto; }
.sched-pane { display: flex; flex-direction: column; gap: 10px; padding: 14px 18px; }

/* A nav item that is NOT published to staff yet — red so it is unmistakable that whoever can
   see it is seeing something the rest of the practice cannot. */
.snav-item.snav-restricted { color: #b3261e; }
.snav-item.snav-restricted:hover { background: #fdecea; color: #8c1d18; }
.snav-item.snav-restricted.active { background: #fdecea; color: #8c1d18; box-shadow: inset 2px 0 0 #b3261e; }
.snav-lock { font-size: 9.5px; font-weight: 700; letter-spacing: .4px; border: 1px solid currentColor;
  border-radius: 999px; padding: 0 4px; margin-left: 6px; vertical-align: 1px; }

/* Messages workspace */
#messages.panel.active { display: flex; min-height: 0; }
.msg-wrap { display: grid; grid-template-columns: 310px minmax(0, 1fr) 340px; width: 100%; min-height: 0; }
/* Below ~1250px the context column folds under the conversation rather than crushing all three.
   The panel must NOT become the scroller — the composer stays glued to the bottom at every width —
   so the conversation row keeps the remaining height and the folded context gets its own cap. */
@media (max-width: 1250px) {
  .msg-wrap { grid-template-columns: 290px minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; }
  .msg-context { max-height: 34vh; }
}
.msg-left { min-width: 0; border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; }
.msg-bar { gap: 6px; }
/* The search fills the conversations column — results render IN the panel below, not a dropdown. */
.msg-bar .search-box { flex: 1; min-width: 0; max-width: none; }
.msg-consent { font-size: 10px; font-weight: 700; border-radius: 999px; padding: 0 6px; border: 1px solid currentColor; display: inline-block; margin-top: 3px; }
.msg-consent-opted-in { color: #14652c; }
.msg-consent-opted-out { color: #b3261e; }
.msg-consent-unknown { color: #7a5c07; }
/* The conversation column is a fixed frame, not a scroller: status + thread head pinned at the
   top, the composer pinned at the bottom, and ONLY the message log (.thrv-log) scrolling between
   them — the way every texting app behaves. overflow-y:auto here was the bug: the whole column
   scrolled as one piece, carrying the composer off-screen with the history. */
.msg-right { min-width: 0; overflow: hidden; padding: 12px 16px; border-right: 1px solid var(--border); display: flex; flex-direction: column; }
.msg-status { flex: 0 0 auto; }
.msg-context { min-width: 0; overflow-y: auto; padding: 12px 14px; background: var(--panel); }
@media (max-width: 1250px) { .msg-context { grid-column: 1 / -1; border-top: 1px solid var(--border); } }
.msg-context-head { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 0 0 8px; }
.msg-banner { padding: 8px 11px; border-radius: 8px; font-size: 12.5px; font-weight: 600; margin-bottom: 10px; }
.msg-banner-off { background: #fdecea; color: #8c1d18; border: 1px solid #f5c6c2; }
.msg-banner-dry { background: #fdf3c4; color: #7a5c07; border: 1px solid #eedb8a; }
.msg-banner-live { background: #eaf7ee; color: #14652c; border: 1px solid #bfe3ca; }
.msg-authrow { display: flex; gap: 8px; margin: -4px 0 10px; }
.msg-authnote { font-size: 12px; color: var(--muted); margin: -4px 0 10px; word-break: break-all; }
.msg-head-name { font-size: 17px; font-weight: 650; }
.msg-consent-btns { display: flex; gap: 8px; margin-top: 7px; }
.msg-row { display: flex; gap: 8px; align-items: center; margin-bottom: 7px; }
/* Send row: count left, "Sending from" centered in the remaining space, Send right — and no
   bottom margin, so the compose ends tight under the button. */
.msg-row-end { justify-content: flex-end; margin-bottom: 0; }
.msg-row-end .msg-count { margin-right: 0; }
.msg-row-end .msg-fromline { margin: 0 auto; }
.msg-phone, .msg-tpl { flex: 1; font: inherit; font-size: 12.5px; padding: 5px; border: 1px solid var(--border); border-radius: 6px; background: var(--panel-2); color: var(--text); }
.msg-body { width: 100%; box-sizing: border-box; font: inherit; font-size: 13px; padding: 8px; border: 1px solid var(--border); border-radius: 6px; resize: vertical; background: var(--panel); color: var(--text); }
.msg-count { font-size: 11.5px; color: var(--muted); margin-right: auto; }
.msg-count-over { color: var(--err); font-weight: 700; }
.msg-sendmsg { font-size: 12px; margin-top: 4px; min-height: 0; }
.msg-sendmsg:empty { display: none; } /* reserve no space until there is a result to show */
.msg-sendmsg-ok { color: #14652c; font-weight: 600; }
.msg-sendmsg-err { color: var(--err); font-weight: 600; }
.msg-locknote { font-size: 12px; color: #8c1d18; margin-top: 7px; font-weight: 600; }
/* In-row variant: rides the send row, immediately left of the (disabled) button. */
.msg-locknote-inline { margin: 0 2px 0 0; white-space: nowrap; }

/* Landing screen */
#home.panel.active { display: flex; align-items: center; justify-content: center; }
.home-hero { text-align: center; padding-bottom: 6vh; }
.home-logo { width: 118px; height: 118px; margin-bottom: 20px; }
.home-hero h1 { margin: 0 0 6px; font-size: 30px; font-weight: 650; letter-spacing: .2px; }
.home-date { color: var(--muted); font-size: 14px; margin-bottom: 26px; }
.home-hint { color: var(--muted); font-size: 13px; }

/* Right side of the header: connection status + the signed-in AD user chip */
.header-right { display: flex; align-items: center; gap: 16px; }
.user-chip { display: flex; align-items: center; gap: 8px; padding: 3px 12px 3px 3px; border: 1px solid var(--border); border-radius: 999px; background: var(--panel-2); cursor: default; }
.user-chip .uc-avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 12px; font-weight: 700; letter-spacing: .3px; display: flex; align-items: center; justify-content: center; flex: none; }
.user-chip .uc-text { display: flex; flex-direction: column; line-height: 1.15; }
.user-chip .uc-name { font-size: 12.5px; font-weight: 600; color: var(--text); white-space: nowrap; }
.user-chip .uc-sub { font-size: 10px; color: var(--muted); }


/* Every workspace shares the one content cell right of the menu; only the active one shows.
   min-width 0: grid/flex items must never refuse to shrink (wide tables scroll inside). */
.panel { display: none; grid-row: 2; grid-column: 2; min-height: 0; min-width: 0; }
.panel.active { display: flex; }

/* Explore */
.sidebar {
  width: 320px; min-width: 260px; border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 12px; gap: 10px; background: var(--panel);
}
.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.field.inline { flex-direction: row; align-items: center; gap: 8px; }
select, input, textarea {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--border);
  border-radius: 6px; padding: 7px 9px; font-size: 13px; font-family: inherit;
}
select:focus, input:focus, textarea:focus { outline: 1px solid var(--accent-dim); border-color: var(--accent-dim); }
.table-list { list-style: none; margin: 0; padding: 0; overflow: auto; flex: 1; }
.table-list li {
  padding: 6px 8px; border-radius: 6px; cursor: pointer; display: flex;
  justify-content: space-between; gap: 8px; align-items: center;
}
.table-list li:hover { background: var(--panel-2); }
.table-list li.active { background: var(--accent-soft); }
.table-list .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table-list .ty { font-size: 10px; color: var(--muted); }
.table-list .rc { font-size: 11px; color: var(--muted); }
.table-list .view .nm { color: var(--accent); }
.search-hits {
  max-height: 220px; overflow: auto; border: 1px solid var(--border);
  border-radius: 6px; padding: 6px; background: var(--panel-2); font-size: 12px;
}
.search-hits .hit { padding: 3px 4px; cursor: pointer; border-radius: 4px; }
.search-hits .hit:hover { background: var(--panel); }
.search-hits .col { color: var(--accent); }

.detail { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: hidden; }
.detail-head { padding: 14px 16px; border-bottom: 1px solid var(--border); font-size: 15px; }
.detail-head .sub { color: var(--muted); font-size: 12px; }
#detailBody { overflow: auto; padding: 0 16px 24px; }

h3.section { font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin: 18px 0 6px; }
table.grid { border-collapse: collapse; width: 100%; font-size: 12.5px; }
table.grid th, table.grid td {
  border: 1px solid var(--border); padding: 5px 8px; text-align: left;
  white-space: nowrap; max-width: 360px; overflow: hidden; text-overflow: ellipsis;
}
table.grid th { background: var(--panel-2); position: sticky; top: 0; z-index: 3; color: var(--muted); font-weight: 600; } /* z-index so scrolling positioned cells (e.g. sticky-left group labels) never paint over the sticky header */
table.grid tr:nth-child(even) td { background: rgba(15,30,50,.022); }
.badge { font-size: 10px; padding: 0 5px; border-radius: 4px; margin-left: 6px; }
.badge.pk { color: var(--pk); border: 1px solid var(--pk); }
.badge.fk { color: var(--fk); border: 1px solid var(--fk); }
.btn-sm { font-size: 12px; padding: 4px 10px; margin-top: 10px; }
.null { color: var(--muted); font-style: italic; }

/* Console */
#console { flex-direction: column; padding: 12px; gap: 10px; }
.console-bar { display: flex; align-items: center; gap: 12px; }
.meta { font-size: 12px; color: var(--muted); margin-left: auto; }
#sqlInput { width: 100%; height: 160px; resize: vertical; font-family: ui-monospace, "Cascadia Code", Consolas, monospace; }
.result-wrap { flex: 1; min-width: 0; overflow: auto; border: 1px solid var(--border); border-radius: 8px; background: var(--panel); box-shadow: 0 2px 8px rgba(15, 30, 50, .10); }

button {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--border);
  border-radius: 6px; padding: 7px 14px; font-size: 13px; cursor: pointer;
}
button:hover:not(:disabled) { border-color: var(--accent-dim); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.primary { background: var(--accent-dim); border-color: var(--accent); color: #fff; }

.error { color: var(--err); background: rgba(224,108,117,.1); border: 1px solid var(--err); border-radius: 6px; padding: 8px 12px; font-size: 13px; white-space: pre-wrap; }
.hidden { display: none !important; }
.empty { color: var(--muted); padding: 24px; text-align: center; }
.warn-banner { color: var(--warn); font-size: 12px; padding: 6px 16px; }

/* AR Work: patient list + per-patient detail */
#arwork, #watchlist { flex-direction: column; padding: 12px; gap: 10px; }
.ar-view { flex: 1; display: flex; flex-direction: column; min-height: 0; gap: 10px; }
.ar-patient-name { font-weight: 800; font-size: 19px; color: var(--text); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-header .seg-toggle { margin-left: auto; }
.modal-header .seg-toggle button { padding: 4px 11px; font-size: 11px; }
table.grid th.num, table.grid td.num { text-align: right; }
table.grid tr.clickable { cursor: pointer; }
table.grid tr.clickable:hover td { background: var(--accent-soft); }
td.overdue-cell { color: var(--warn); font-weight: 700; }
tr.row-overdue td { background: rgba(224, 108, 117, .10); }
tr.row-grace td { background: rgba(70, 192, 138, .07); }
.balance-cards { display: flex; flex-wrap: wrap; gap: 12px; }
.balance-card { background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 16px; min-width: 190px; box-shadow: 0 1px 2px rgba(15, 30, 50, .05); }
.bc-title { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; font-weight: 700; margin-bottom: 6px; }
.bc-row { display: flex; justify-content: space-between; gap: 16px; font-size: 14px; line-height: 1.7; }
.bc-k { color: var(--muted); }
.bc-v { font-weight: 600; font-variant-numeric: tabular-nums; }
.bc-v.bc-zero { color: var(--muted); font-weight: 400; }

/* Aging "box" — blends into the background (no card chrome); rows align with the balance boxes */
.aging-card { min-width: auto; background: transparent; border-color: transparent; box-shadow: none; }
.aging-head, .aging-row { display: flex; }
.aging-head { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; font-weight: 700; margin-bottom: 6px; }
.aging-row { font-size: 14px; line-height: 1.7; }
.aging-head .ag-k, .aging-row .ag-k { width: 78px; flex: none; }
.aging-row .ag-k { color: var(--muted); }
.ag-c { width: 88px; flex: none; text-align: right; font-variant-numeric: tabular-nums; }
.aging-row .ag-c.bc-zero { color: var(--muted); }

/* Grouped ticket table: CPSI / BSC section dividers (single table = aligned columns) */
tr.group-row td.group-label { background: var(--panel-2); font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--text); border-top: 2px solid var(--accent); position: sticky; left: 0; z-index: 1; padding: 6px 8px; } /* sticky-left, but BELOW the sticky top header (z-index 3) */

/* Resizable, fixed-layout ticket grid */
table.grid-fixed { table-layout: fixed; }
table.grid-fixed td { max-width: none; }
table.grid-fixed th { overflow: hidden; text-overflow: ellipsis; }
.col-resize { position: absolute; top: 0; right: 0; width: 7px; height: 100%; cursor: col-resize; user-select: none; }
.col-resize:hover { background: var(--accent); opacity: .5; }
td.due-cell { white-space: nowrap; }
td.due-cell .due-ic { margin-right: 5px; }
.ok-check { color: var(--ok); font-weight: 700; font-size: 15px; }
.dot-bad { color: var(--err); font-size: 14px; }

/* Analytics tab */
#analytics { flex-direction: column; padding: 12px; gap: 10px; }
.stat-tiles { display: flex; flex-wrap: wrap; gap: 10px; }
.stat-tile { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 9px 16px; min-width: 150px; box-shadow: 0 1px 2px rgba(15, 30, 50, .05); }
.st-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.st-value { font-size: 20px; font-weight: 700; margin-top: 3px; font-variant-numeric: tabular-nums; }
.chart-wrap { flex: 1; display: flex; flex-direction: column; min-height: 0; min-width: 0; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; box-shadow: 0 1px 4px rgba(15, 30, 50, .06); }
.chart-area { flex: 1; min-height: 0; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 16px; padding: 2px 4px 10px; font-size: 12px; color: var(--text); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.line-chart .axis { stroke: var(--border); stroke-width: 1; }
.line-chart .grid { stroke: var(--border); stroke-width: 1; opacity: .55; }
.line-chart .y-lbl, .line-chart .x-lbl { fill: var(--muted); font-size: 11px; }
/* Aging chart hover: dashed day-guide, enlarged dots, and a per-day value tooltip */
.chart-inner { position: relative; }
.chart-hit { cursor: crosshair; }
.line-chart .chart-guide { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; pointer-events: none; }
.line-chart .chart-hi { stroke: var(--panel); stroke-width: 1.5; pointer-events: none; }
.chart-tip { position: absolute; z-index: 6; pointer-events: none; min-width: 152px; background: var(--panel); border: 1px solid var(--border); border-radius: 6px; padding: 6px 9px; font-size: 12px; color: var(--text); box-shadow: 0 3px 10px rgba(15, 30, 50, .18); white-space: nowrap; }
.chart-tip .ct-date { font-weight: 700; margin-bottom: 4px; }
.chart-tip .ct-row { display: flex; align-items: center; gap: 7px; line-height: 1.65; }
.chart-tip .ct-row b { margin-left: auto; font-variant-numeric: tabular-nums; }
.chart-tip .ct-sw { width: 9px; height: 9px; border-radius: 2px; flex: none; }
.chart-tip .ct-lbl { color: var(--muted); }
/* Analytics ▸ Payor Reimbursement */
.reimb-controls { display: flex; flex-direction: column; gap: 8px; padding: 0 2px 10px; }
.reimb-groups { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.reimb-group { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 6px; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 5px 8px; box-shadow: 0 1px 2px rgba(15, 30, 50, .05); }
.reimb-and { font-size: 11px; font-weight: 800; letter-spacing: .5px; color: var(--accent-dim); }
.reimb-op { background: var(--panel-2); color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 3px 4px; font-size: 12px; font-weight: 700; }
.reimb-chip { display: inline-flex; align-items: center; gap: 4px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 999px; padding: 2px 6px 2px 10px; font-size: 12.5px; font-weight: 700; color: var(--text); }
.reimb-chip-x { border: none; background: none; color: var(--muted); font-size: 14px; line-height: 1; cursor: pointer; padding: 0 2px; }
.reimb-chip-x:hover { color: var(--err); }
.reimb-cpt-input { width: 128px; background: var(--panel-2); color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 3px 8px; font-size: 12.5px; }
/* Procedure-name suggestion dropdown under a group's input */
.reimb-input-wrap { position: relative; display: inline-flex; }
.reimb-suggest { position: absolute; top: calc(100% + 3px); left: 0; z-index: 60; min-width: 320px; max-width: 440px; max-height: 280px; overflow-y: auto; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 8px 24px rgba(15, 30, 50, .18); }
.reimb-suggest.hidden { display: none !important; }
.reimb-sug-row { padding: 6px 10px; cursor: pointer; display: flex; flex-direction: column; gap: 1px; border-bottom: 1px solid var(--border); }
.reimb-sug-row:last-child { border-bottom: none; }
.reimb-sug-row:hover { background: var(--accent-soft); }
.reimb-sug-label { font-size: 12.5px; font-weight: 700; color: var(--text); }
.reimb-sug-codes { font-size: 11px; color: var(--muted); }
.reimb-group-x { border: none; background: none; color: var(--muted); font-size: 12px; cursor: pointer; padding: 0 2px; }
.reimb-group-x:hover { color: var(--err); }
.reimb-add-group { white-space: nowrap; }
.reimb-filterbar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.reimb-backbar { padding: 8px 0 6px; }
.reimb-lbl { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); }
.reimb-lbl input, #reimbSetting, #reimbScope { background: var(--panel-2); color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 3px 6px; font-size: 12.5px; }
/* Encounter drill-down: one header + grid per same-day ticket */
.reimb-enc-head { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; padding: 12px 2px 6px; }
.reimb-enc-title { font-weight: 800; font-size: 13.5px; color: var(--text); }
.reimb-enc-meta { font-size: 12px; color: var(--muted); }
.reimb-enc-tot { font-size: 12px; color: var(--text); font-variant-numeric: tabular-nums; }
.reimb-enc-bad { background: #6b1a1a; color: #fff; font-size: 10px; font-weight: 800; letter-spacing: .5px; border-radius: 4px; padding: 1px 7px; }
.reimb-note { padding: 8px 10px; font-size: 11.5px; color: var(--muted); border-bottom: 1px solid var(--border); }

/* Owner admin panel (account chip) */
.user-chip.uc-clickable { cursor: pointer; }
.user-chip.uc-clickable:hover { background: var(--panel-2); }
.admin-window { width: min(1400px, 96vw); }
.admin-tabs { display: flex; gap: 6px; margin-left: 14px; }
.adm-tab { font: inherit; font-size: 12px; padding: 3px 10px; border: 1px solid var(--border); border-radius: 999px; background: transparent; color: var(--muted); cursor: pointer; }
.adm-tab.active { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.admin-body { display: flex; flex-direction: column; gap: 10px; }
.adm-controls { display: flex; align-items: center; gap: 14px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.adm-controls select { font: inherit; font-size: 12px; color: var(--text); background: var(--panel); border: 1px solid var(--border); border-radius: 6px; padding: 3px 6px; margin-left: 5px; }
.adm-provlist { border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; background: var(--panel-2); font-size: 12px; }
.adm-provlist.hidden { display: none !important; }
.adm-prov { display: flex; align-items: center; gap: 8px; margin: 3px 0; }
.adm-prov-role { font-size: 10.5px; font-weight: 600; padding: 1px 7px; border-radius: 999px; white-space: nowrap; }
.adm-role-md { background: var(--accent-soft); color: var(--accent); }
.adm-role-midlevel { background: rgba(214,158,46,.16); color: #92400e; }
.adm-role-other { background: var(--panel); color: var(--muted); }
.adm-gap { color: var(--err); font-weight: 600; white-space: nowrap; }
.adm-room { color: var(--ok); font-weight: 600; white-space: nowrap; }
/* Rows where the right provider on the opposite side has an open template slot at that exact
   time. Same specificity as the even-row striping tint but later in the file, so the yellow
   wins on striped rows too. */
table.grid tr.adm-slot-open td { background: #fdf3c4; }
.adm-slot-tag { color: #a16207; font-weight: 600; font-size: .86em; white-space: nowrap; }
/* Combined-worklist instruction column + the "Only matching openings" checkbox. */
.adm-instr-interval { color: var(--err); font-weight: 600; }
.adm-instr-offload { color: var(--ok); font-weight: 600; }
.adm-check { white-space: nowrap; cursor: pointer; }
.adm-check input { vertical-align: -2px; }
/* Necessity verdict badge row in the Grid modal */
.nec-vchip-row { margin-bottom: 8px; }

/* SCS/PNS: the implant product when it differs from the trial device. */
.stim-permprod { font-size: .82em; color: var(--accent); margin-top: 2px; }

/* Referral tracking: 12 compact month cards (+ a year total) instead of mixed stats. */
.adm-stat.ref-mon { min-width: 62px; padding: 6px 8px; text-align: center; }
.adm-stat.ref-mon-zero .adm-stat-v { color: var(--muted); }
.adm-stat.ref-mon-now { outline: 2px solid var(--accent); outline-offset: -2px; }
.adm-stat.ref-mon-total { background: var(--accent-soft); font-weight: 700; }

/* Referral tracking: inline-edit cells, the add-a-returning-patient box, manual-row tint. */
.ref-cell { min-width: 150px; }
.ref-in { width: 100%; box-sizing: border-box; font: inherit; font-size: 12.5px; padding: 3px 5px;
  border: 1px solid var(--border); border-radius: 5px; background: var(--panel); color: var(--text); }
.ref-in:focus { outline: 1px solid var(--accent-dim); border-color: var(--accent-dim); }
.ref-prefill { color: var(--muted); font-style: italic; }
.ref-override { border-color: var(--accent); font-weight: 600; }
.ref-ins { max-width: 260px; white-space: normal; }
table.grid tr.ref-manual td { background: #f3f7fd; }
.ref-tag { font-size: 10px; color: var(--accent); font-weight: 600; }
.ref-addbox { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 9px 11px; margin: 6px 0;
  border: 1px solid var(--border); border-radius: 8px; background: var(--panel-2); }
.ref-addbox label { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 5px; }
.ref-addbox input[type=search] { min-width: 260px; }
.ref-results { flex: 0 0 100%; max-height: 190px; overflow-y: auto; }
.ref-hit { padding: 4px 7px; border-radius: 5px; cursor: pointer; font-size: 12.5px; }
.ref-hit:hover { background: var(--accent-soft); color: var(--accent); }

/* Auth-check verdict chips + detail lines. */
.adm-authv { display: inline-block; padding: 1px 8px; border-radius: 9px; font-weight: 700; font-size: .82em; margin: 4px 0 2px; }
.authv-ready { background: #d7f5dd; color: #14652c; }
.authv-noneed { background: #dcebfb; color: #1d4f8f; }
.authv-gaps { background: #fbdddd; color: #8f1d1d; }
.authv-unclear { background: #fdf3c4; color: #7a5c07; }
.adm-authv-line { font-size: .84em; margin-top: 3px; line-height: 1.4; }
.authk-ic { font-weight: 700; margin-right: 5px; }
.authk-ok { color: #16a34a; }
.authk-fail { color: #dc2626; }
.authk-unk { color: #b45309; }
/* Evidence-basis badge: is the verdict grounded in the PDFs or only the staff-typed record? */
.adm-authv-ev { margin-left: 6px; font-size: .76em; padding: 0 6px; border-radius: 8px; border: 1px solid; white-space: nowrap; vertical-align: 1px; }
.ev-pdf { color: #14652c; border-color: #14652c; }
.ev-staff { color: #7a5c07; border-color: #7a5c07; }
.ev-mixed { color: #1d4f8f; border-color: #1d4f8f; }
.ev-none { color: #8f1d1d; border-color: #8f1d1d; }
/* Grayed retained-date next to the re-check button (never a badge). */
.adm-retained { color: var(--muted); font-size: .78em; margin-left: 7px; white-space: nowrap; }

/* Auth-document hyperlinks + the show/hide toggle for AI-filtered documents. */
.adm-doc-link { color: var(--accent, #1d4f8f); text-decoration: none; }
.adm-doc-link:hover { text-decoration: underline; }
.adm-doc-more { color: var(--muted); cursor: pointer; font-size: .9em; margin-top: 2px; text-decoration: underline dotted; }
/* NPR rows: the pre-built medical-necessity review, scrollable inside the cell. */
.adm-nec-box { max-height: 260px; overflow-y: auto; border: 1px solid var(--border); border-radius: 6px; padding: 6px 8px; margin-top: 4px; background: var(--panel-2, rgba(15,30,50,.03)); font-size: .9em; }
.adm-nec-box p, .adm-nec-box li { margin: 3px 0; }
/* The base table.grid td rule (nowrap + ellipsis) outranks a bare class — qualify with the td
   so the AI verdict and the case-notes columns actually WRAP instead of clipping to one line. */
table.grid td.adm-ai-cell { min-width: 300px; max-width: 460px; white-space: normal; overflow: visible; vertical-align: top; }
table.grid td.adm-note-cell { max-width: 320px; white-space: normal; overflow: visible; vertical-align: top; }
.adm-policy { font-size: 12px; color: var(--muted); }
/* SCS/PNS trial flow (Sankey) — an in-panel admin page, not a separate modal */
#admFlowWrap svg { display: block; }
.flow-head { font-size: 11px; font-weight: 600; fill: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.flow-lbl { font-size: 11.5px; fill: var(--text); }
.flow-num { fill: var(--muted); font-size: 10.5px; }
#admFlowWrap path.flow-hit:hover { fill-opacity: .62; }
#admFlowWrap .flow-hit { cursor: pointer; }
#admFlowWrap rect.flow-hit:hover { stroke: var(--text); stroke-width: 1; }
.adm-back { margin-right: 10px; }
.adm-note-cell { max-width: 300px; white-space: normal; }
.adm-apptnote { color: var(--text); font-style: italic; line-height: 1.35; }
.adm-sub { color: var(--muted); font-size: 11.5px; }
.adm-link { color: var(--accent); cursor: pointer; }
.adm-link:hover { text-decoration: underline; }
.adm-stim-permanent { color: var(--ok); white-space: nowrap; }
.adm-stim-pending { color: var(--muted); white-space: nowrap; }
.adm-stim-no-permanent { color: var(--err); font-weight: 600; white-space: nowrap; }
.adm-reason { white-space: nowrap; }
.adm-outcome, .adm-outcome-note { font: inherit; font-size: 11.5px; color: var(--text); background: var(--panel); border: 1px solid var(--border); border-radius: 6px; padding: 2px 5px; }
.adm-outcome-note { width: 120px; margin-left: 4px; }
.adm-ai { max-width: 280px; }
.adm-aicat { display: inline-block; font-size: 10.5px; font-weight: 600; padding: 1px 7px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.adm-aitext { font-size: 11.5px; line-height: 1.4; white-space: normal; margin: 2px 0; }
.adm-mini { font: inherit; font-size: 11px; padding: 1px 7px; border: 1px solid var(--border-strong); border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer; }
.adm-mini:hover { background: var(--panel-2); color: var(--text); }
.adm-summary { display: flex; flex-wrap: wrap; gap: 10px; align-items: stretch; }
.adm-stat { border: 1px solid var(--border); border-radius: 8px; padding: 6px 12px; min-width: 78px; background: var(--panel-2); }
.adm-stat-v { font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; }
.adm-stat-l { font-size: 11px; color: var(--muted); }
.adm-byuser { flex: 1 1 100%; font-size: 11.5px; color: var(--muted); }
.adm-fail { color: var(--err); }
/* Admin ▸ incoming fax queue */
.fax-pill { display: inline-block; font-size: 10.5px; font-weight: 600; padding: 1px 8px; border-radius: 999px; white-space: nowrap; }
.fax-new { background: var(--warn-soft, var(--accent-soft)); color: var(--warn, var(--accent)); }
.fax-seen { background: var(--panel-2); color: var(--muted); }
.fax-old { color: var(--err); font-weight: 600; }
.fax-subject { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fax-doclist { display: flex; flex-direction: column; gap: 2px; }
.fax-doclist a { font-size: 11.5px; color: var(--accent); }
/* AI reading of a fax: category pill, one-line summary, and the structured read-out beneath the row */
.fax-cat { display: inline-block; font-size: 10.5px; font-weight: 600; padding: 1px 8px; border-radius: 999px; white-space: nowrap; }
.fc-referral { background: #e3f1fd; color: #1c4f80; }
.fc-request  { background: #fdf0e3; color: #8a5b12; }
.fc-received { background: #e6f5ea; color: #1d6b39; }
.fc-auth     { background: #ede3fd; color: #543a8a; }
.fc-other    { background: #f0e3e3; color: #8a2f2f; }
.fc-imaging  { background: #e8e3fd; color: #45368a; }
.fc-remit    { background: #e3f0ee; color: #14655c; }
.fc-refill   { background: #f5eede; color: #7a5a13; }
.fc-ma       { background: #ece4f5; color: #55307a; }
.fc-psych    { background: #e4eff5; color: #1f5a72; }
/* The outcome of the last action, in the page rather than in a dialog nobody wants to dismiss. */
.fax-flash { margin: 6px 0 10px; padding: 8px 12px; border-radius: 5px; font-size: 13px; line-height: 1.45;
  border: 1px solid var(--border-strong); background: var(--panel-2); white-space: pre-line; }
.fax-flash-ok   { border-color: #1d6b39; background: #e9f6ed; color: #14532a; }
.fax-flash-warn { border-color: #9a6b00; background: #fbf3e0; color: #6b4a00; }
.fax-plan { border-top: 1px dashed var(--border-strong); margin-top: 10px; padding-top: 8px; }
.fax-plan-line { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin: 2px 0 6px; }
.fax-plan-badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 9px; border-radius: 4px; white-space: nowrap; }
.plan-ok   { background: #e6f5ea; color: #1d6b39; }
.plan-new  { background: #e3f1fd; color: #1c4f80; }
.plan-warn { background: #fdf0e3; color: #8a5b12; }
.fax-approve { border-top: 1px dashed var(--border-strong); margin-top: 10px; padding-top: 10px;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.fax-steps { border-top: 1px dashed var(--border-strong); margin-top: 10px; padding-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.fax-step { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12.5px; }
.fax-step-locked { opacity: 0.55; }
.fax-step-num { display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px;
  border-radius: 999px; background: var(--panel-2); border: 1px solid var(--border-strong); color: var(--muted);
  font-size: 11px; font-weight: 700; flex: 0 0 auto; }
.fax-step-num.done { background: #e6f5ea; border-color: #1d6b39; color: #1d6b39; }
/* One authorization filing as several documents — each copy boxed so they read as distinct filings. */
.fax-copy { border-left: 3px solid var(--accent); padding: 6px 0 6px 10px; margin: 8px 0; }
.fax-related { margin-top: 8px; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.fax-chart-h { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; margin: 6px 0 2px; }
.fax-doclist-full { margin: 4px 0 8px; }
.fax-doclist-full summary { font-size: 11.5px; color: var(--accent); cursor: pointer; }
.fax-doc-table { margin-top: 5px; font-size: 11.5px; }
.fax-doc-table td, .fax-doc-table th { padding: 3px 8px; }
.fax-note { font-family: Consolas, "Cascadia Mono", monospace; font-size: 11.5px; line-height: 1.5;
  background: var(--panel); border: 1px solid var(--border); border-radius: 4px; padding: 7px 9px;
  white-space: pre-wrap; overflow-wrap: anywhere; }
.fax-review { font-size: 10.5px; font-weight: 600; color: var(--err); margin-left: 4px; white-space: nowrap; }
/* Overruling the AI's category. Deliberately quiet until hovered — it is a correction, not a step. */
.fax-recat { display: block; margin-top: 2px; padding: 0; border: 0; background: none; cursor: pointer;
  font: inherit; font-size: 10.5px; color: var(--muted); text-decoration: underline dotted; }
.fax-recat:hover { color: var(--accent); }
.fax-recat-sel, .fax-recat-note { font: inherit; font-size: 11.5px; padding: 3px 5px; margin: 0 4px 4px 0;
  border: 1px solid var(--border-strong); border-radius: 4px; background: var(--panel); color: var(--fg); }
.fax-recat-note { width: 150px; }
.fax-corrected { font-style: italic; }
.btn-mini { font: inherit; font-size: 11.5px; padding: 3px 9px; border-radius: 4px; cursor: pointer;
  border: 1px solid var(--accent); background: var(--accent); color: #fff; }
.btn-mini:disabled { opacity: 0.6; cursor: default; }
.btn-mini.btn-quiet { background: var(--panel); color: var(--muted); border-color: var(--border-strong); }
.fax-summary { max-width: 320px; white-space: normal; line-height: 1.35; }
/* Buttons WRAP rather than widening the table. With nowrap, a third button (Ignore) pushed the
   whole 10-column table past the viewport and forced horizontal scrolling on every row. */
.fax-actions { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; max-width: 132px; }
.fax-actions button { flex: 0 0 auto; }
.fax-detail-row td { background: var(--panel-2); border-top: none; padding: 8px 12px 12px; }
.fax-detail-h { font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin: 6px 0 4px; }
.fax-detail-warn { font-size: 11.5px; color: var(--err); margin-bottom: 4px; }
.fax-facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 6px 14px; }
.fax-fact-k { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.fax-fact-v { font-size: 12.5px; line-height: 1.35; white-space: normal; overflow-wrap: anywhere; }
/* Grid ▸ medical-necessity Q&A modal */
.nec-window { width: min(880px, 96vw); }
.nec-body { display: flex; flex-direction: column; gap: 10px; }
.nec-topline { display: flex; align-items: center; gap: 12px; }
.nec-topline .nec-status { flex: 1; min-width: 0; }
.nec-editor { display: flex; flex-direction: column; gap: 10px; border-bottom: 1px solid var(--border); padding-bottom: 10px; }
.nec-editor.hidden, .nec-sources.hidden { display: none !important; } /* their display:flex would otherwise out-cascade the earlier .hidden rule */
.nec-sec-h { font-weight: 600; font-size: 12.5px; color: var(--muted); border-bottom: 1px solid var(--border); padding-bottom: 3px; }
#necEvalWrap { display: flex; flex-direction: column; gap: 6px; }
#necEvalWrap.hidden { display: none !important; } /* same cascade guard as .nec-editor */
.nec-warn { background: rgba(214, 158, 46, .12); border: 1px solid rgba(214, 158, 46, .45); border-radius: 6px; padding: 7px 10px; font-size: 12px; }
.nec-field { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); }
.nec-field input, .nec-field textarea { font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--border); border-radius: 6px; padding: 6px 8px; }
.nec-field textarea { resize: vertical; }
.nec-actions { display: flex; align-items: center; gap: 12px; }
.nec-status { font-size: 12px; color: var(--muted); }
.nec-inputs { font-size: 12px; color: var(--muted); margin: 0 0 8px; line-height: 1.45; }
.nec-inputs b { color: var(--text); font-weight: 600; }
.nec-answer { border: 1px solid var(--border); border-radius: 8px; background: var(--panel-2); padding: 10px 14px; font-size: 13px; line-height: 1.55; }
.nec-answer p { margin: 6px 0; }
.nec-answer ul, .nec-answer ol { margin: 6px 0 6px 20px; padding: 0; }
.nec-answer li { margin: 3px 0; }
/* Indentation-aware lists: each nesting level steps in and sub-bullets get a distinct marker. */
.nec-answer ul.nl-1, .nec-answer ol.nl-1 { margin-left: 36px; }
.nec-answer ul.nl-2, .nec-answer ol.nl-2 { margin-left: 52px; }
.nec-answer ul.nl-1 li { list-style: circle; }
.nec-answer ul.nl-2 li { list-style: square; }
.nec-answer .nec-h { font-weight: 600; margin-top: 12px; }
.nec-answer hr { border: 0; border-top: 1px solid var(--border); margin: 8px 0; }
/* Verdict words carry the attention — color instead of a wall of bold. */
.nec-v-met { color: var(--ok); }
.nec-v-notmet { color: var(--err); }
.nec-v-notdoc { color: #b45309; }
.nec-sources { display: flex; flex-direction: column; gap: 3px; font-size: 12px; }
.nec-sources .nec-src-h { font-weight: 600; color: var(--muted); margin-bottom: 2px; }
.nec-sources a { color: var(--accent); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nec-sources a:hover { text-decoration: underline; }
.nec-disclaimer { font-size: 11px; color: var(--muted); border-top: 1px solid var(--border); padding-top: 8px; }
/* Content-sized columns: the table takes ONLY the width its data needs (no stretch-to-fill —
   one CPT selected means one narrow table) and grows past the viewport (horizontal scroll in
   .result-wrap) when there are many codes. Transposed layout: payor rows, CPT columns — the code
   header carries a small wrapped description line so a column stays narrow but identifiable. */
table.reimb-table { width: max-content; }
table.reimb-table th, table.reimb-table td { white-space: nowrap; }
table.reimb-table td { overflow: hidden; text-overflow: ellipsis; }
table.reimb-table th.rb-cpt-h { min-width: 88px; max-width: 150px; white-space: normal; vertical-align: bottom; text-align: right; }
table.reimb-table th.rb-cpt-h .rb-cpt-descr { font-weight: 400; color: var(--muted); font-size: 10.5px; line-height: 1.15; margin-top: 2px; max-height: 3.5em; overflow: hidden; }
/* Sticky payor column — pinned while the CPT columns scroll horizontally underneath.
   The background MUST be opaque or scrolling columns show through: the zebra rule
   (table.grid tr:nth-child(even) td, a 2% translucent tint) out-ranks a plain class selector,
   so even rows are overridden explicitly with the SAME tint layered over a solid base. */
table.reimb-table tr td.rb-payor { position: sticky; left: 0; z-index: 2; background: var(--panel); font-weight: 700; max-width: 220px; overflow: hidden; text-overflow: ellipsis; box-shadow: 2px 0 3px rgba(15, 30, 50, .12); }
table.reimb-table tr:nth-child(even) td.rb-payor { background-color: var(--panel); background-image: linear-gradient(rgba(15,30,50,.022), rgba(15,30,50,.022)); }
table.reimb-table th:first-child { position: sticky; left: 0; z-index: 4; box-shadow: 2px 0 3px rgba(15, 30, 50, .12); } /* the corner: above both sticky axes; keeps the opaque th background */
/* Uniform alignment inside a CPT column: payments, denials, and the no-data dash all sit on the
   same right edge so a column reads as one line of figures. */
table.reimb-table td.rb-val { text-align: right; font-variant-numeric: tabular-nums; }
table.reimb-table td.rb-empty { color: var(--muted); text-align: right; }
table.reimb-table td.rb-denied { color: var(--err); font-size: 11.5px; text-align: right; }
table.reimb-table td.rb-click { cursor: pointer; }
table.reimb-table td.rb-click:hover { background: var(--panel-2); text-decoration: underline; }
/* Drag-resizable columns: after first paint the measured widths are frozen into a fixed-layout
   colgroup (class rb-fixed) so dragging a header grip moves ONE column edge; the CSS min/max
   bounds that shaped the initial auto layout must then get out of the way. */
table.reimb-table thead th { position: relative; }
table.reimb-table.rb-fixed th.rb-cpt-h { min-width: 0; max-width: none; }
table.reimb-table.rb-fixed td.rb-payor { max-width: none; }
.rb-grip { position: absolute; top: 0; right: 0; width: 8px; height: 100%; cursor: col-resize; z-index: 6; }
.rb-grip::after { content: ''; position: absolute; top: 0; bottom: 0; right: 2px; width: 2px; background: transparent; }
.rb-grip:hover::after, .rb-grip.dragging::after { background: var(--accent); }

/* Sortable column headers */
table.grid th.sortable { cursor: pointer; user-select: none; }
table.grid th.sortable:hover { color: var(--text); }
table.grid th.sort-asc::after { content: ' ▲'; color: var(--accent); font-size: 10px; }
table.grid th.sort-desc::after { content: ' ▼'; color: var(--accent); font-size: 10px; }

/* Patient detail modal (popup) */
.modal-overlay { position: fixed; inset: 0; background: rgba(15, 30, 50, .45); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.modal-overlay.hidden { display: none !important; }
.modal-window { width: auto; min-width: 600px; max-width: 90vw; height: auto; max-height: 88vh; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 16px 48px rgba(15, 30, 50, .22); }
.modal-header { display: flex; align-items: center; gap: 12px; padding: 14px 18px; background: var(--accent-soft); border-bottom: 2px solid var(--accent); }
.modal-close { margin-left: auto; }
.fc-chip { font-size: 12px; font-weight: 600; padding: 3px 11px; border-radius: 999px; background: #fff; color: var(--accent-dim); border: 1px solid #cfe6fb; white-space: nowrap; }

/* Insurance / Patient / Both working-mode toggle */
.ar-zero-toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); white-space: nowrap; cursor: pointer; user-select: none; }
.ar-zero-toggle.hidden { display: none !important; } /* .ar-zero-toggle's display would otherwise out-cascade the earlier .hidden rule */
.ar-zero-toggle input { margin: 0; cursor: pointer; }

/* "Group patients by ins" (Insurance working view): sortable per-carrier table + nested patient table */
.ar-ins-table td.ins-name-cell { font-weight: 600; white-space: nowrap; }
.ar-ins-table td.ins-name-cell .cw-caret { margin-right: 4px; }
/* Expansion cell: NO horizontal padding — the nested table's right edge must land exactly on the
   outer table's, so the fixed-width money/count columns align edge-for-edge. The left indent
   (.ar-ins-nest margin) is absorbed entirely by the flexible Patient Name column. */
.ar-ins-exp > td { background: var(--panel-2); padding: 2px 0 10px; }
.ar-ins-nest { margin: 6px 0 4px 24px; }
/* Ticket detail: tickets belonging to the carrier the patient was opened from (wins over the
   row-overdue/row-grace tints declared earlier — the user is hunting THIS carrier's tickets). */
tr.ins-hl td { background: #fdf0b0; }
tr.ins-hl td:first-child { box-shadow: inset 3px 0 0 #e0b400; }

/* Owner watchlists: the patient cell opens the account (the rest of the row opens corr notes) */
td.owner-patient { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; font-weight: 600; }
/* Patient workflow help — the how-overdue-works flowchart page */
.pat-help-btn { background: var(--panel-2); color: var(--accent-dim); border: 1px solid var(--border); border-radius: 999px; padding: 3px 12px; font-size: 12px; font-weight: 700; cursor: pointer; white-space: nowrap; }
.pat-help-btn:hover { color: var(--text); border-color: var(--accent-dim); }
.pat-help-btn.hidden { display: none !important; }
.modal-window.pat-help-window { max-width: 780px; width: 90vw; }
.pat-help-body .ph-lead { font-size: 13px; color: var(--text); margin: 6px 2px 12px; line-height: 1.5; }
.pat-help-body svg { width: 100%; height: auto; display: block; margin: 0 auto; }
.pat-help-body .ph-box { fill: var(--panel-2); stroke: var(--border); }
.pat-help-body .ph-th { font: 600 13.5px Arial, sans-serif; fill: var(--text); }
.pat-help-body .ph-ts { font: 11.5px Arial, sans-serif; fill: var(--muted); }
.pat-help-body .ph-arr { stroke: var(--muted); fill: none; stroke-width: 1.5; }
.pat-help-body .ph-gray rect { fill: #f1efe9; stroke: #cfccc2; }
.pat-help-body .ph-gray .ph-th { fill: #55534d; }
.pat-help-body .ph-red rect { fill: #fdecec; stroke: #e8b4b4; }
.pat-help-body .ph-red .ph-th { fill: #a32d2d; }
.pat-help-body .ph-red .ph-ts { fill: #8a4a4a; }
.pat-help-body .ph-green rect { fill: #eaf5ec; stroke: #b5d9bd; }
.pat-help-body .ph-green .ph-th { fill: #1e6b34; }
.pat-help-body .ph-green .ph-ts { fill: #4a7a56; }
.pat-help-body .ph-notes { margin: 14px 4px 6px; padding-left: 18px; font-size: 12.5px; color: var(--text); line-height: 1.6; }
.pat-help-body .ph-notes li { margin-bottom: 7px; }

/* Oregon prompt-pay interest (ORS 743B.452) — its own green "Interest" column (Insurance mode) */
td.int-cell .cur, td.int-cell .amt { color: var(--ok); font-weight: 700; }

/* Bad-debt account badge (Patient working mode) — the whole account is closed to follow-up */
.bd-badge { display: inline-block; margin-left: 7px; padding: 0 6px; border-radius: 4px; background: #6b1a1a; color: #fff; font-size: 9.5px; font-weight: 800; letter-spacing: .5px; line-height: 15px; vertical-align: 1px; }

/* Owner-bucket chip beside a ticket number in the patient view (Audit / Appeal / Code / Cov / MedRec / Reg) */
.owner-chip { display: inline-block; margin-left: 6px; padding: 0 5px; border-radius: 999px; background: #ece8fd; color: #5b3fb8; border: 1px solid #cfc4f4; font-size: 9.5px; font-weight: 700; line-height: 14px; vertical-align: 1px; }

/* Corr notes drill-down (click a ticket row in the patient view) */
.modal-window.corr-window { max-width: 860px; }
.corr-note { border: 1px solid var(--border); border-radius: 8px; background: var(--panel); padding: 8px 12px; margin-bottom: 8px; }
.corr-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 4px; }
.corr-user { font-weight: 700; font-size: 13px; }
.corr-when { font-size: 11.5px; color: var(--muted); }
.corr-text { font-size: 13px; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }

/* Packets — surgery-day schedule */
#packets { flex-direction: column; padding: 12px; gap: 10px; }
#packetDate { padding: 5px 8px; }
table.packet-table { table-layout: auto; }
table.packet-table th, table.packet-table td { white-space: normal; max-width: none; vertical-align: top; }
table.packet-table th { white-space: nowrap; } /* keep every column header (e.g. "Follow-up") on one line */
table.packet-table td.pk-time { white-space: nowrap; font-weight: 600; color: var(--accent-dim); width: 1%; }
table.packet-table td.pk-patient { white-space: nowrap; font-weight: 600; }
table.packet-table td.pk-type { white-space: nowrap; color: var(--accent-dim); }
table.packet-table td.pk-lat { white-space: nowrap; }
table.packet-table td.pk-loc { white-space: nowrap; }
table.packet-table td.pk-case,
table.packet-table td.pk-fu { text-align: center; color: var(--ok); font-weight: 700; font-size: 15px; width: 1%; }
table.packet-table td.pk-case.pk-case-missing,
table.packet-table td.pk-fu.pk-fu-missing { color: var(--err); }   /* red ✗ when no case / no follow-up */
/* Per-row Laterality / Locality checkbox dropdowns (fixed options, no free text) */
.pk-cbdd { display: inline-block; }
.pk-cbdd.hidden, .ms-dropdown.hidden { display: none !important; } /* .pk-cbdd/.ms-dropdown's display would otherwise out-cascade the earlier .hidden rule */
.pk-cbdd > summary.pk-cbsum {
  list-style: none; cursor: pointer; user-select: none; display: inline-block;
  background: var(--panel-2); color: var(--text); border: 1px solid var(--border);
  border-radius: 6px; padding: 3px 22px 3px 8px; font-size: 12px;
  min-width: 56px; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: middle;
}
.pk-cbdd > summary.pk-cbsum::-webkit-details-marker { display: none; }
.pk-cbdd > summary.pk-cbsum::after { content: '▾'; position: absolute; margin-left: 4px; color: var(--muted); }
.pk-cbdd[open] > summary.pk-cbsum { border-color: var(--accent-dim); outline: 1px solid var(--accent-dim); }
.pk-cbmenu { position: fixed; z-index: 60; }
.pk-lat-sel { padding: 3px 6px; font-size: 12px; border-radius: 6px; border: 1px solid var(--border); background: var(--panel-2); color: var(--text); }
/* type-to-filter box + clickable rows for the per-row Locality / Procedure dropdowns */
.pk-cbsearch { position: sticky; top: 0; z-index: 1; box-sizing: border-box; width: 100%; margin: 0 0 4px; padding: 5px 8px; font-size: 12px; border: 1px solid var(--border); border-radius: 6px; background: var(--panel); color: var(--text); }
.pk-cbsearch:focus { outline: 1px solid var(--accent-dim); border-color: var(--accent-dim); }
.pk-opt-row.sel { font-weight: 600; color: var(--accent-dim); }
.pk-opt-clear { color: var(--muted); }
.pk-cbdd > summary.pk-proc-sum { max-width: 340px; min-width: 120px; }
.pk-cbdd > summary.pk-proc-sum.pk-proc-unset { border-color: #d97706; background: #fffbeb; }
/* Any leftover blank in the day table glows the same orange as an unset procedure —
   a blank laterality/locality prints an under-specified packet (e.g. "Left TPI" with no site). */
.pk-lat-sel.pk-unset, .pk-cbdd > summary.pk-cbsum.pk-unset { border-color: #d97706; background: #fffbeb; }
.pk-sij-note { color: var(--muted); cursor: help; } /* SIJ: single-locality procedure — no locality control at all */
table.packet-table td.pk-note { color: var(--text); }
/* Keep the Note to one line (truncate + hover tooltip) so it doesn't crowd out the wider
   Procedure column. The full note is still available on hover (title attr). */
.pk-note-text { display: block; max-width: 240px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
table.packet-table td.pk-actions { white-space: nowrap; width: 1%; }
.pk-sed-badge { display: inline-block; margin-left: 6px; font-size: 9px; font-weight: 700; color: #fff; background: #c2410c; border-radius: 3px; padding: 1px 4px; vertical-align: middle; }
.pk-link { background: none; border: 1px solid var(--border); color: var(--accent-dim); border-radius: 5px; padding: 2px 7px; font-size: 11px; cursor: pointer; margin-right: 4px; }
.pk-link:hover:not(:disabled) { border-color: var(--accent-dim); background: var(--panel-2); }
.packet-status { font-size: 12px; color: var(--muted); }
#packetPdfAll { font-weight: 600; }
/* Day-packet progress overlay + missing-procedure error popup */
.pk-progress-overlay { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; background: rgba(15, 30, 50, .45); }
.pk-progress-box { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 22px 30px; text-align: center; box-shadow: 0 10px 34px rgba(0, 0, 0, .28); min-width: 300px; max-width: 460px; }
.pk-spinner { width: 34px; height: 34px; margin: 2px auto 12px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: pk-spin .8s linear infinite; }
@keyframes pk-spin { to { transform: rotate(360deg); } }
.pk-progress-title { font-size: 15px; font-weight: 600; color: var(--text); }
.pk-progress-sub { font-size: 12px; color: var(--muted); margin-top: 3px; }
.pk-progress-bar { height: 6px; background: var(--panel-2); border-radius: 4px; overflow: hidden; margin: 14px 0 8px; }
.pk-progress-bar > span { display: block; height: 100%; width: 35%; background: var(--accent); border-radius: 4px; animation: pk-indet 1.1s ease-in-out infinite; }
@keyframes pk-indet { 0% { transform: translateX(-120%); } 100% { transform: translateX(360%); } }
.pk-progress-elapsed { font-size: 11px; color: var(--muted); }
.pk-error-box { border-color: #d97706; }
.pk-error-icon { font-size: 30px; color: #d97706; line-height: 1; margin-bottom: 4px; }
.pk-error-msg { font-size: 12.5px; color: var(--text); margin-top: 6px; }
.pk-error-list { text-align: left; margin: 8px auto 14px; max-height: 200px; overflow: auto; font-size: 13px; color: var(--text); padding-left: 22px; }
.pk-error-list li { margin: 2px 0; }
.pk-error-ok { padding: 6px 18px; font-size: 13px; }

/* Packet template editor (reuses .proc-edit-* window/list/actions) */
.tpl-edit-form { flex: 1; display: flex; flex-direction: column; gap: 8px; min-width: 0; padding: 4px 2px; }
.tpl-edit-head { display: flex; align-items: center; gap: 10px; }
.tpl-edit-head strong { font-size: 15px; }
.tpl-toolbar { display: flex; flex-wrap: wrap; gap: 4px; }
.tpl-toolbar button { padding: 3px 9px; font-size: 12px; }
.tpl-source-toggle.on { background: var(--accent-dim); color: #fff; border-color: var(--accent); }
.tpl-wysiwyg { flex: 1; min-height: 320px; max-height: 60vh; overflow: auto; background: #fff; border: 1px solid var(--border); border-radius: 6px; padding: 14px 18px; font-size: 13px; line-height: 1.4; color: #111; }
.tpl-wysiwyg:focus { outline: 1px solid var(--accent-dim); }
.tpl-wysiwyg h1 { font-size: 17px; } .tpl-wysiwyg h2 { font-size: 14px; }
.tpl-html { flex: 1; min-height: 320px; max-height: 60vh; font-family: ui-monospace, Consolas, monospace; font-size: 12px; line-height: 1.45; padding: 12px; border: 1px solid var(--border); border-radius: 6px; resize: vertical; }
.tpl-tokens { font-size: 11px; color: var(--muted); }
.tpl-tokens code { background: var(--panel-2); border: 1px solid var(--border); border-radius: 3px; padding: 0 4px; margin: 0 1px; color: var(--accent-dim); }
.tpl-item { cursor: pointer; padding: 7px 10px; border-radius: 6px; font-size: 13px; display: flex; align-items: center; gap: 6px; }
.tpl-item:hover { background: var(--panel-2); }
.tpl-item.active { background: var(--accent-dim); color: #fff; }
.tpl-tag { font-size: 9px; text-transform: uppercase; letter-spacing: .3px; background: var(--border); color: var(--text); border-radius: 3px; padding: 1px 4px; }
.tpl-item.active .tpl-tag { background: rgba(255,255,255,.25); color: #fff; }

/* Packet preview modal */
.preview-window { width: min(96vw, 1000px); height: 92vh; display: flex; flex-direction: column; }
.preview-frame { flex: 1; width: 100%; border: 0; background: #eef2f7; border-radius: 0 0 8px 8px; }
#packetPreviewDownload { margin-left: auto; margin-right: 8px; }

/* Packets — per-patient Specific-Risks procedure dropdown */
table.packet-table td.pk-proc { white-space: nowrap; width: 1%; }
.pk-proc-sel { max-width: 340px; padding: 3px 6px; font-size: 12px; }
.pk-proc-sel.pk-proc-unset { border-color: #d97706; background: #fffbeb; }

/* Risks-procedures editor (inside the template editor) */
.rp-editor { border-top: 1px solid var(--border); margin-top: 10px; padding-top: 10px; }
.rp-editor h3 { font-size: 13px; margin: 0 0 8px; }
.rp-hint { font-weight: 400; font-size: 11px; color: var(--muted); }
.rp-hint code { background: var(--panel-2); border: 1px solid var(--border); border-radius: 3px; padding: 0 3px; }
#riskProcList { max-height: 38vh; overflow: auto; display: flex; flex-direction: column; gap: 6px; }
.rp-row, .rp-head { display: grid; grid-template-columns: 1.4fr 1fr 2fr 62px 28px; gap: 6px; align-items: start; } /* +Steroid/LA checkbox column */
/* Locality-risk rows: name · match terms · risks text · delete (no injectate column) */
.lr-row, .lr-head { grid-template-columns: 1fr 1.2fr 2fr 28px; }
#locRiskEditor { margin-top: 18px; border-top: 1px solid var(--border); padding-top: 10px; }
#locRiskEditor h3 { margin: 0 0 6px; }
.rp-inj { display: flex; justify-content: center; padding-top: 6px; cursor: pointer; }
.rp-inj input { margin: 0; cursor: pointer; }
.rp-inj-h { text-align: center; }
.rp-head { position: sticky; top: 0; background: var(--panel); padding-bottom: 4px; margin-bottom: 2px; font-size: 11px; font-weight: 600; color: var(--muted); border-bottom: 1px solid var(--border); z-index: 1; }
.rp-row input, .rp-row textarea { padding: 4px 6px; font-size: 12px; }
.rp-risks { min-height: 34px; resize: vertical; font-family: inherit; }
.rp-del { align-self: start; padding: 3px 8px; color: #b00; }
.rp-actions { display: flex; align-items: center; gap: 8px; margin-top: 8px; }

/* Edit Templates modal — larger than the shared proc-edit window (lots to see, esp. risks) */
#packetTplModal .proc-edit-window { width: 1180px; max-width: 97vw; }
#packetTplModal .proc-edit-body { min-height: 80vh; max-height: 90vh; }
#packetTplModal .proc-edit-list { width: 280px; }
#packetTplModal .tpl-edit-form { overflow-y: auto; }
#packetTplModal .tpl-wysiwyg, #packetTplModal .tpl-html { max-height: 48vh; min-height: 300px; }
#packetTplModal #riskProcList { max-height: 42vh; }

/* multi-select dropdown (Packets resource picker) */
.ms-dropdown { position: relative; display: inline-block; }
.ms-dropdown > summary {
  list-style: none; cursor: pointer; user-select: none;
  background: var(--panel-2); color: var(--text); border: 1px solid var(--border);
  border-radius: 6px; padding: 5px 26px 5px 10px; font-size: 13px; min-width: 160px;
}
.ms-dropdown > summary::-webkit-details-marker { display: none; }
.ms-dropdown > summary::after {
  content: '▾'; position: absolute; right: 9px; color: var(--muted); pointer-events: none;
}
.ms-dropdown[open] > summary { border-color: var(--accent-dim); outline: 1px solid var(--accent-dim); }
.ms-menu {
  position: absolute; z-index: 20; top: calc(100% + 4px); left: 0; min-width: 220px;
  max-height: 280px; overflow: auto; background: var(--panel); border: 1px solid var(--border);
  border-radius: 8px; box-shadow: 0 6px 18px rgba(15, 30, 50, .18); padding: 4px;
}
.ms-opt { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; cursor: pointer; font-size: 13px; white-space: nowrap; }
.ms-opt:hover { background: var(--panel-2); }
.ms-opt input { margin: 0; cursor: pointer; }
.ms-empty { padding: 8px; color: var(--muted); font-size: 12px; }

/* analytics sub-tabs (Aging Receivables | AR Work Activity) */
.analytics-view { flex: 1; min-height: 0; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.analytics-view.hidden { display: none !important; }
#activityWrap { padding: 10px; }
.activity-summary { font-size: 13px; color: var(--text); margin-bottom: 10px; }
.activity-src { color: var(--muted); font-size: 12px; }
/* per-user accountability ribbons */
.aw-group { margin-bottom: 8px; }
.aw-ribbon { display: flex; align-items: center; gap: 10px; padding: 9px 12px; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; cursor: pointer; user-select: none; }
.aw-ribbon:hover { background: var(--accent-soft); }
.aw-user { font-weight: 700; font-size: 14px; }
.aw-meta { margin-left: auto; font-size: 12px; color: var(--muted); white-space: nowrap; }
table.aw-table { margin: 4px 0 2px 24px; width: calc(100% - 24px); table-layout: auto; }
table.aw-table th, table.aw-table td { white-space: normal; max-width: none; overflow: visible; word-break: break-word; }
table.aw-table th.num, table.aw-table td.num { white-space: nowrap; }

/* AR speedometers (bottom of AR Work Activity): per-user needles + legend */
/* Leaderboard toggle: a full-width white handle bar notched onto the ticket section's flat bottom
   edge — it continues the white card as its bottom lip, so the card's own bottom border/rounding is
   dropped for this view and the bar carries them. The WHOLE bar is the hover/click target; hovering
   grows the whole bar DOWN a few px into a reserved band (no reflow). Clicking animates the
   leaderboard open/closed via grid-rows. */
#activityView { gap: 0; }
#activitySpeed { margin-top: 0; }
#activityView #activityWrap { border-bottom: none; border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.speed-toggle-wrap { position: relative; height: 34px; margin-top: -1px; } /* reserves room so the bar + notch grow DOWN into it without pushing anything */
.speed-toggle-band {
  position: absolute; top: 0; left: 0; right: 0; height: 14px; box-sizing: border-box;
  background: var(--panel); border: 1px solid var(--border); border-top-color: transparent;
  border-radius: 0 0 8px 8px; box-shadow: 0 5px 8px -3px rgba(15, 30, 50, .12);
  cursor: pointer; color: var(--muted);
  transition: height .3s cubic-bezier(.33, 1, .68, 1), box-shadow .3s ease, color .2s ease; will-change: height;
}
.speed-toggle-band:hover { height: 20px; color: var(--accent); box-shadow: 0 9px 13px -3px rgba(15, 30, 50, .18); } /* whole full-width bar grows down a few px — the "pull me" hint */
/* Little notch centered on the band's bottom edge — the arrow lives here; top:100% keeps it stuck to the
   bar's bottom, so it rides smoothly DOWN as the bar grows on hover. */
.speed-notch {
  position: absolute; top: calc(100% - 1px); left: 50%; transform: translateX(-50%);
  width: 42px; height: 13px; box-sizing: border-box;
  background: var(--panel); border: 1px solid var(--border); border-top-color: transparent;
  border-radius: 0 0 9px 9px; box-shadow: 0 3px 5px -2px rgba(15, 30, 50, .1);
  display: flex; align-items: center; justify-content: center;
}
.speed-notch-arrow { font-size: 12px; line-height: 1; }
.speed-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin: 4px 0 10px; }
/* Smooth expand/collapse: grid-rows 1fr<->0fr animates the leaderboard's real height (no snap). */
.speed-collapsible { display: grid; grid-template-rows: 1fr; transition: grid-template-rows .34s cubic-bezier(.4, 0, .2, 1); }
#activitySpeed.lb-collapsed .speed-collapsible { grid-template-rows: 0fr; }
.speed-collapsible-inner { overflow: hidden; min-height: 0; }
.speed-meta { font-size: 12px; color: var(--muted); }
.speed-row { display: flex; gap: 18px; flex-wrap: wrap; align-items: flex-start; }
.speed-card { flex: 1 1 360px; max-width: 480px; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 12px 16px 10px; box-shadow: 0 1px 4px rgba(15,30,50,.08); }
.speed-title { font-weight: 800; font-size: 14px; margin-bottom: 4px; }
.speed-sub { font-size: 11px; color: var(--muted); margin-top: 8px; }
.speed-svg { width: 100%; height: auto; display: block; }
.speed-svg .speed-tick { font-size: 11px; fill: var(--muted); }
.speed-legend { display: flex; flex-direction: column; gap: 3px; margin-top: 6px; }
.speed-leg-row { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: default; }
.speed-swatch { width: 12px; height: 12px; border-radius: 3px; flex: 0 0 12px; }
.speed-leg-user { font-weight: 600; }
.speed-leg-val { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 700; }

/* charges watchlist (auto-flagged Allowed = Charged) — grouped by CPT */
tr.charge-row { cursor: pointer; }
tr.charge-row:hover td { background: var(--accent-soft); }
button.cw-dismiss { padding: 3px 10px; font-size: 11px; }
.cw-group { margin-bottom: 8px; }
.cw-ribbon { display: flex; flex-direction: column; gap: 4px; padding: 8px 12px; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; cursor: pointer; user-select: none; }
.cw-ribbon:hover { background: var(--accent-soft); }
.cw-ribbon-main { display: flex; align-items: center; gap: 10px; }
.cw-fees { font-size: 11px; color: var(--muted); padding-left: 24px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cw-caret { width: 14px; color: var(--muted); }
.cw-cpt { font-weight: 700; font-size: 13px; }
.cw-desc { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 420px; }
.cw-meta { margin-left: auto; font-size: 12px; color: var(--muted); white-space: nowrap; }
.cw-dismiss-all { flex: none; }
table.cw-table { margin: 4px 0 2px 24px; width: calc(100% - 24px); table-layout: auto; }
/* Wrap long text (Carrier / full Company + Facility names) so the table fits the panel — no
   horizontal scroll. Selectors are `table.cw-table` to outrank `table.grid td` (same specificity, later in file). */
table.cw-table th, table.cw-table td { white-space: normal; max-width: none; overflow: visible; word-break: break-word; }
table.cw-table th.num, table.cw-table td.num { white-space: nowrap; }
tr.claim-flagged td { background: #fdecec; }

/* the Grid: supporting-services second row — dimmed until scrolled/hovered */
.grid-support-section { margin-top: 14px; opacity: 0.45; transition: opacity 0.25s ease; }
.grid-support-section:hover, .grid-support-section:not(.dim) { opacity: 1; }
.gss-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.gss-title { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.4px; }

/* template editor: supporting-service controls */
.proc-support .ps-check { display: flex; align-items: center; gap: 7px; font-size: 13px; margin: 5px 0; cursor: pointer; font-weight: 400; }
.proc-support .ps-check input { margin: 0; cursor: pointer; }
.proc-support em, .ps-sed-head em { color: var(--muted); font-style: normal; font-size: 11px; }
.ps-sed { margin-top: 12px; }
.ps-sed-head { font-size: 13px; margin-bottom: 5px; }
.ps-sed input[type="range"] { width: 100%; max-width: 360px; display: block; cursor: pointer; }
.ps-sed-ticks { display: flex; justify-content: space-between; max-width: 360px; font-size: 10px; color: var(--muted); margin-top: 2px; }
.seg-label { margin-left: auto; font-size: 12px; color: var(--muted); }
.seg-toggle { display: inline-flex; border: 1px solid var(--border); border-radius: 7px; overflow: hidden; }
.seg-toggle button { border: none; border-radius: 0; background: var(--panel); color: var(--muted); padding: 6px 12px; font-size: 12px; cursor: pointer; border-left: 1px solid var(--border); }
.seg-toggle button:first-child { border-left: none; }
.seg-toggle button.active { background: var(--accent); color: #fff; font-weight: 600; }
.seg-toggle button:hover:not(.active) { background: var(--accent-soft); color: var(--text); }
/* A line that is listed but not yet live for texting: visible, clearly parked, not clickable. */
.seg-toggle button.seg-off { opacity: .55; cursor: not-allowed; font-style: italic; }
.seg-toggle button.seg-off:hover { background: var(--panel); color: var(--muted); }
.seg-toggle button:disabled { opacity: .4; cursor: default; }
.seg-toggle button:disabled:hover { background: var(--panel); color: var(--muted); }
/* Red overdue-count badge on a seg-toggle tab (owner watchlists) — readable on active/hover too */
.seg-toggle .seg-badge { display: inline-block; margin-left: 6px; background: #d63939; color: #fff; border-radius: 999px; padding: 0 5px; font-size: 10px; font-weight: 700; line-height: 15px; min-width: 15px; text-align: center; vertical-align: 1px; }
/* Watchlist sub-tabs: 8 tabs + badges must stay on ONE line. Buttons never wrap internally,
   the font-weight is CONSTANT (selecting a tab no longer widens it), padding is compact, and
   the summary text yields (ellipsis) instead of squeezing the tabs into two lines. */
#watchSubToggle { flex: 0 0 auto; }
#watchSubToggle button { white-space: nowrap; padding: 6px 9px; font-size: 11.5px; font-weight: 600; }
#watchSummary { flex: 1 1 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Supporting-services table (Edit Procedure Template): compact AR-Work-style selectors per sub-type. */
.support-table td.ss-control { text-align: left; }
.support-table .seg-toggle button { padding: 5px 9px; font-size: 11px; }
.modal-close { background: none; border: 1px solid var(--err); color: var(--err); border-radius: 6px; width: 26px; height: 26px; font-size: 13px; line-height: 1; cursor: pointer; padding: 0; font-weight: 700; }
.modal-close:hover { background: var(--err); color: #fff; }
.modal-window .balance-cards { padding: 12px 16px 4px; }
.modal-body { flex: 1; min-width: 0; min-height: 0; overflow: auto; padding: 4px 16px 16px; }
.modal-footer { padding: 10px 16px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
.modal-subbar { display: flex; align-items: center; padding: 0 18px 8px; }
.ticket-group-title { font-size: 13px; font-weight: 600; margin: 18px 0 6px; color: var(--text); }
.ticket-group-title .count { color: var(--muted); font-weight: 400; }

/* Accounting-formatted currency cells ($ pinned left, amount right) */
td.acct { text-align: right; }
td.acct .acct-wrap { display: flex; justify-content: space-between; gap: 12px; white-space: nowrap; }
td.acct .cur { color: var(--muted); }
td.overdue-cell .amt { color: var(--warn); font-weight: 600; }

/* Search box (worklist + watchlist toolbars) */
.search-box { min-width: 190px; max-width: 280px; }

/* Watchlist: per-row remove button */
td.wl-remove-cell { text-align: center; width: 40px; }
button.wl-remove { padding: 2px 8px; font-size: 12px; color: var(--err); border-color: var(--border); line-height: 1; }
button.wl-remove:hover:not(:disabled) { background: var(--err); border-color: var(--err); color: #fff; }

/* Add-to-watchlist search modal */
.watch-add-window { min-width: 0; width: 600px; max-width: 92vw; max-height: 80vh; }
.watch-add-body { display: flex; flex-direction: column; gap: 10px; padding: 14px 16px 16px; min-height: 0; overflow: hidden; }
.watch-add-body .search-box { max-width: none; width: 100%; }
.watch-add-results { overflow: auto; border: 1px solid var(--border); border-radius: 8px; background: var(--panel-2); min-height: 200px; }
.wa-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 7px 12px; border-bottom: 1px solid var(--border); }
.wa-row:last-child { border-bottom: none; }
.wa-info { display: flex; flex-direction: column; min-width: 0; }
.wa-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wa-meta { font-size: 11px; color: var(--muted); }
.wa-row button { padding: 4px 14px; font-size: 12px; flex: none; }
.wa-row button.wa-on { color: var(--ok); border-color: var(--ok); }

/* Analytics: clickable metric tiles toggle their chart line */
.stat-tile.toggle { cursor: pointer; user-select: none; transition: opacity .12s, border-color .12s; }
.stat-tile.toggle:hover { border-color: var(--accent-dim); }
.stat-tile.off { opacity: .55; }
.st-label { display: flex; align-items: center; }
.st-swatch { width: 11px; height: 11px; border-radius: 3px; border: 2px solid; display: inline-block; margin-right: 6px; vertical-align: middle; }

/* Attorney name cell (Attorney worklist view) — hover for contact info */
td.attorney-cell { cursor: help; text-decoration: underline dotted var(--muted); text-underline-offset: 3px; }

/* ── The Grid (procedure fee-schedule quoting) ── */
#grid { flex-direction: column; padding: 12px; gap: 10px; }
/* Grid top bar: the two type-ahead lookups are centered; edit + info link sit at the ends. */
.grid-bar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; }
.grid-bar > .grid-bar-left { justify-self: start; display: flex; align-items: center; gap: 8px; }
.grid-bar > .grid-bar-right { justify-self: end; display: flex; align-items: center; gap: 8px; }
#packetTplBtn { margin-left: auto; }   /* packets tab: tuck "Edit Templates" to the far right */
.grid-lookups { justify-self: center; display: flex; gap: 12px; }
.gcombo { position: relative; }
.gcombo input { width: 250px; padding: 7px 10px; font-size: 13px; border: 1px solid var(--border); border-radius: 6px; background: var(--panel); color: var(--text); }
.gcombo input:focus { outline: none; border-color: var(--accent); }
.gcombo-list { position: absolute; top: calc(100% + 3px); left: 0; right: 0; z-index: 30; background: var(--panel); border: 1px solid var(--border); border-radius: 6px; box-shadow: 0 6px 18px rgba(15,30,50,.18); max-height: 320px; overflow-y: auto; }
.gcombo-list.hidden { display: none !important; }
.gcombo-opt { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding: 7px 10px; cursor: pointer; font-size: 13px; }
.gcombo-opt:hover { background: var(--accent-dim); }
.gco-sub { color: var(--muted); font-size: 11px; white-space: nowrap; }
.grid-hint { font-size: 12px; color: var(--muted); padding: 2px 2px 10px; }
.grid-body { display: flex; gap: 12px; flex: 1; min-height: 0; }
.grid-info { width: 250px; min-width: 250px; overflow: auto; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; box-shadow: 0 1px 4px rgba(15,30,50,.06); display: flex; flex-direction: column; gap: 10px; }
.grid-info-title { margin: 0; font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.grid-info-field { display: flex; flex-direction: column; gap: 3px; font-size: 12px; }
.grid-info-field .gif-label { color: var(--muted); font-weight: 600; }
.grid-info-field textarea { width: 100%; resize: vertical; font-family: inherit; font-size: 12px; }
.grid-result { position: relative; flex: 1; min-width: 0; overflow: auto; border: 1px solid var(--border); border-radius: 8px; background: var(--panel); box-shadow: 0 2px 8px rgba(15,30,50,.10); padding: 10px; }
/* "Edit Conversion Factors": floats in the results' top-right corner, in line with the sub-type
   tabs, without reserving a row. The sub-type bar / legend get a right gutter so text never runs under it. */
.cf-corner-btn { position: absolute; top: 10px; right: 10px; z-index: 5; padding: 6px 14px; font-size: 13px; font-weight: 600; }
.grid-result.has-cf .grid-subtype-bar,
.grid-result.has-cf .grid-legend { padding-right: 220px; }
.saved-flash { color: var(--ok); font-size: 12px; font-weight: 600; margin-left: 4px; }

/* conversion-factor editor (per payer × 5 lanes, with a payer dropdown per carrier) */
.cf-editor { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 10px 14px; padding: 2px 2px 12px; }
.cf-editor .cf-title { width: 100%; font-weight: 700; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.cf-edit-window { width: 860px; max-width: 94vw; }
.cf-edit-body { padding: 14px 18px 18px; overflow: auto; max-height: 82vh; }
.grid-pending-btn { font-weight: 700; }   /* high contrast (primary) — the main workflow */
/* low contrast — present but not inviting; only a select few edit templates */
/* Low-contrast bordered button for rarely-used actions (Edit Procedure Templates, the allowables
   info link, the packets Edit Templates) — muted so it doesn't compete with the primary actions. */
.minor-btn { background: transparent; border-color: var(--border); color: var(--muted); font-weight: 400; font-size: 12px; }
.minor-btn:hover:not(:disabled) { background: var(--panel-2); }
.pending-window { width: 1040px; max-width: 96vw; }
.pending-body { padding: 14px 18px 18px; overflow: auto; max-height: 80vh; }
.pending-table .pending-match { font-weight: 600; }
.pending-table .pending-nomatch { color: var(--muted); font-weight: 400; font-style: italic; }
.pending-table .pending-detail { white-space: nowrap; }
.pending-head { font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.pending-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.pending-table th { text-align: left; font-size: 11px; color: var(--muted); font-weight: 600; padding: 4px 8px; border-bottom: 2px solid var(--border); }
.pending-table td { padding: 6px 8px; border-bottom: 1px solid var(--panel-2); vertical-align: top; }
.pending-table .pending-pat { font-weight: 700; white-space: nowrap; }
.pending-table .pending-when { white-space: nowrap; color: var(--muted); font-size: 12px; }
.pending-row { cursor: pointer; }
.pending-row:hover td { background: var(--accent-soft); }
.pending-loading, .pending-error { font-size: 13px; color: var(--muted); padding: 8px; }
.pending-error { color: var(--warn); }
.cf-carrier { display: flex; flex-direction: column; gap: 6px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--panel-2); }
.cf-carrier-top { display: flex; align-items: center; gap: 8px; }
.cf-carrier .cf-name { font-weight: 600; max-width: 230px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cf-label-sel { font-size: 12px; padding: 3px 6px; }
.cf-lanes { display: flex; flex-wrap: wrap; gap: 8px; }
.cf-input { display: inline-flex; flex-direction: column; font-size: 10px; color: var(--muted); gap: 2px; }
.cf-input input { width: 72px; padding: 3px 6px; font-size: 12px; }
.cf-input input:disabled { opacity: .45; }
.cf-note { color: var(--warn); font-size: 12px; }

/* CPT cards (one vertical card per CPT; row labels repeat on each) */
.grid-cards { --gc-w: 344px; display: flex; flex-wrap: nowrap; gap: 14px; align-items: flex-start; overflow-x: auto; padding-bottom: 8px; }
.grid-card { flex: 0 0 var(--gc-w); width: var(--gc-w); border: 1px solid var(--border); border-radius: 10px; background: var(--panel); box-shadow: 0 1px 4px rgba(15,30,50,.08); overflow: hidden; }
.gc-head { padding: 8px 12px; background: var(--accent-soft); border-bottom: 2px solid var(--accent); display: flex; flex-direction: column; gap: 1px; }
.gc-head-top { display: flex; align-items: center; gap: 8px; }
.gc-head .gc-cpt { font-weight: 800; font-size: 15px; color: var(--text); }
/* Description wraps within the fixed card width; every card reserves 2 lines so all cards align. */
.gc-head .gc-label { font-size: 11px; color: var(--muted); line-height: 1.3; min-height: 2.6em; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
/* charge-entry alert: charged > 4× allowed — slow red pulse on BOTH figures, forever.
   The pulse animates OPACITY on an overlay (compositor-driven) rather than the cell's
   background-color (main-thread): browsers throttle non-composited animations on
   elements scrolled out of view, which froze the flash on right-side cards. */
@keyframes chargeAlertPulse { 0%, 100% { opacity: 0; } 50% { opacity: 1; } }
.gc-table td.charge-alert { position: relative; }
.gc-table td.charge-alert::after { content: ''; position: absolute; inset: 0; background: rgba(214, 57, 57, 0.38); animation: chargeAlertPulse 2.6s ease-in-out infinite; pointer-events: none; }

/* supporting-service badges (procedure level, above the CPT cards) */
.grid-badges { display: flex; gap: 8px; margin: 2px 0 10px; flex-wrap: wrap; }
.grid-badge { font-size: 11px; font-weight: 600; color: #7a5d00; background: #fdf3d7; border: 1px solid #e7d49a; border-radius: 999px; padding: 3px 11px; white-space: nowrap; }
/* inline supporting-service status badge on a CPT card header */
.gc-support-badge { margin-left: auto; font-size: 10px; font-weight: 700; border-radius: 999px; padding: 2px 8px; white-space: nowrap; text-transform: uppercase; letter-spacing: .3px; }
.gc-support-badge.sb-bundled { color: #5b5b66; background: #ececf1; border: 1px solid #d4d4dd; }
.gc-support-badge.sb-na { color: #7a3b3b; background: #f6e4e4; border: 1px solid #e3c4c4; }
.gc-support-badge.sb-cash { color: #7a3b00; background: #ffe9d6; border: 1px solid #f0c9a6; }
/* Bundled / not-payable supporting services: grayed-out card, no table, one big centered badge. */
.grid-cards.gss-cards { align-items: stretch; }                 /* support cards all match the tallest → bundled boxes keep full size */
.grid-card.gc-off { display: flex; flex-direction: column; opacity: 0.5; filter: grayscale(0.6); } /* persistently grayed (stays dim even after the section brightens) */
.gc-bundled-body { flex: 1 1 auto; display: flex; align-items: center; justify-content: center; padding: 28px 12px; min-height: 110px; }
.gc-bundled-badge { font-size: 16px; font-weight: 800; text-transform: uppercase; letter-spacing: .6px; border-radius: 999px; padding: 9px 20px; white-space: nowrap; }
.gc-bundled-badge.sb-bundled { color: #5b5b66; background: #ececf1; border: 1px solid #d4d4dd; }
.gc-bundled-badge.sb-na { color: #7a3b3b; background: #f6e4e4; border: 1px solid #e3c4c4; }

/* per-card frequency / eligibility banner (patient-specific) — always one line; ellipsis + tooltip if long */
.gc-freq { padding: 5px 12px; font-size: 11px; font-weight: 700; cursor: help; border-bottom: 1px solid var(--border); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gc-freq.freq-ok { background: rgba(40,160,90,.12); color: #1f7a45; }
.gc-freq.freq-too_soon { background: rgba(210,160,40,.16); color: #8a5a00; }
.gc-freq.freq-reached { background: rgba(200,70,70,.15); color: #b02a2a; }
table.gc-table { width: 100%; }
.gc-table th.gc-corner { background: var(--panel); border-top: none; border-left: none; }
.gc-table th.gm-sub { background: var(--panel-2); color: var(--muted); font-weight: 600; font-size: 11px; text-align: right; }
.gc-table td.gm-rowlabel { text-align: left; font-weight: 600; background: var(--panel-2); white-space: nowrap; }
.gc-table td.gm-val { text-align: right; font-variant-numeric: tabular-nums; }
.gc-table tr.gm-section td.gm-section-label { background: var(--accent); color: #fff; font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: .4px; }
/* Insurance name: never widen the card — truncate with an ellipsis (full name in the title tooltip). */
.gc-table td.gm-section-label .gm-section-text { display: block; max-width: calc(var(--gc-w) - 24px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gc-table tr.gm-section.charged td.gm-section-label { background: var(--panel-2); color: var(--muted); } /* understated */
.gc-table tr.gm-section.allowable td.gm-section-label { background: var(--accent-dim); } /* emphasized — the key number */
.gc-table tr.gm-gap td { border: none; background: transparent; height: 10px; padding: 0; } /* gap between charge & allowable */
.gc-table td.from-history { font-weight: 700; cursor: help; text-decoration: underline solid var(--accent); text-underline-offset: 2px; } /* median of actual claims */
.gc-table td.from-csv { cursor: help; text-decoration: underline dotted var(--muted); text-underline-offset: 2px; } /* old-grid (CSV) table */
.gc-table td.from-formula { cursor: help; color: var(--muted); } /* RVU × CF estimate */
.gc-table td.from-pct { cursor: help; text-decoration: underline dashed var(--muted); text-underline-offset: 2px; } /* % of Medicare */
.cf-pct { margin-top: 4px; align-items: flex-end; }
.cf-pct-title { font-size: 10px; color: var(--muted); align-self: flex-end; padding-bottom: 5px; cursor: help; }
.gc-table td.cf-missing { cursor: help; color: #8a5a00; font-style: italic; font-size: .9em; } /* priced, but no conversion factor set for this payer */
.gc-table td.gm-click { cursor: pointer; }
.gc-table td.gm-click:hover { background: var(--accent-dim); } /* click → claims drill-down */
tr.claim-denied td { color: var(--muted); background: rgba(200, 80, 80, .07); } /* $0 / denied claim line */
tr.claim-processing td { color: var(--muted); background: rgba(210, 160, 40, .10); font-style: italic; } /* still processing — excluded from the median */
.grid-legend { font-size: 11px; color: var(--muted); padding: 0 2px 8px; }
/* per-card list of the patient's prior dates of service for that CPT */
.gc-dos { border-top: 1px solid var(--border); padding: 8px 12px; }
.gc-dos-title { font-size: 10px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); font-weight: 700; margin-bottom: 4px; }
.gc-dos-list { max-height: 160px; overflow-y: auto; display: flex; flex-direction: column; gap: 1px; }
.gc-dos-item { font-size: 12px; font-variant-numeric: tabular-nums; color: var(--text); }
.gc-dos-empty { font-size: 12px; color: var(--muted); font-style: italic; }

/* Procedure-template editor */
.proc-edit-window { width: 880px; max-width: 94vw; }
.proc-edit-body { display: flex; min-height: 360px; max-height: 70vh; }
.proc-edit-list { width: 240px; flex: 0 0 auto; border-right: 1px solid var(--border); padding: 12px; overflow-y: auto; }
.proc-edit-list #procNewBtn { width: 100%; margin-bottom: 10px; }
.proc-edit-list ul { list-style: none; margin: 0; padding: 0; }
.pe-item { display: block; width: 100%; text-align: left; background: none; border: none; padding: 7px 8px; border-radius: 6px; cursor: pointer; color: var(--text); font-size: 13px; }
.pe-item:hover { background: var(--panel-2); }
.pe-item.active { background: var(--accent-dim); font-weight: 600; }
.pe-loading, .pe-empty { color: var(--muted); font-size: 12px; padding: 6px 8px; }
.proc-edit-form { flex: 1; padding: 16px 18px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.proc-edit-form .field { display: flex; flex-direction: column; gap: 5px; }
.proc-edit-form .field > span { font-size: 12px; color: var(--muted); font-weight: 600; }
.proc-edit-form input[type=text] { padding: 7px 9px; font-size: 13px; }
.cpt-add-row { display: flex; gap: 6px; }
.cpt-add-row input { flex: 1; }
.cpt-chip-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 5px; }
.cpt-chip { display: flex; align-items: center; gap: 8px; padding: 6px 8px; background: var(--panel-2); border-radius: 6px; font-size: 13px; }
.cpt-chip .cc-code { font-weight: 700; font-variant-numeric: tabular-nums; }
.cpt-chip .cc-desc { flex: 1; color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cpt-chip.unpriced .cc-desc { color: var(--warn); }
.cpt-chip .cc-x { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 13px; padding: 2px 5px; }
.cpt-chip .cc-x:hover { color: #c0392b; }
/* The Grid procedure editor — sub-type tabs + per-code table */
.proc-subtabs-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.proc-subtabs { display: flex; gap: 4px; flex-wrap: wrap; }
.proc-subtab { padding: 5px 11px; font-size: 12px; border: 1px solid var(--border); background: var(--panel-2); border-radius: 6px; cursor: pointer; color: var(--text); }
.proc-subtab.active { background: var(--accent-dim); border-color: var(--accent); color: #fff; font-weight: 600; }
.proc-subtab.dragging { opacity: .45; }
.proc-subtab.drag-over { outline: 2px dashed var(--accent-dim); outline-offset: 1px; }
.proc-sub-add { padding: 5px 10px; font-size: 12px; border: 1px dashed var(--border); background: none; border-radius: 6px; cursor: pointer; color: var(--muted); }
.proc-sub-add:hover { color: var(--text); border-color: var(--muted); }
.proc-subname-row { display: flex; gap: 6px; align-items: center; }
.proc-subname-row input { flex: 1; }
.proc-sub-del { padding: 6px 10px; font-size: 12px; white-space: nowrap; }
.proc-sub-del:disabled { opacity: .4; cursor: default; }
.cpt-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.cpt-table th { text-align: left; font-size: 11px; color: var(--muted); font-weight: 600; padding: 4px 8px; border-bottom: 1px solid var(--border); }
.cpt-table th.ct-c, .cpt-table td.ct-c { text-align: center; }
.cpt-table td { padding: 5px 8px; border-bottom: 1px solid var(--panel-2); vertical-align: middle; }
.cpt-table .ct-code { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cpt-table .ct-desc { color: var(--muted); font-size: 12px; max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cpt-table tr.unpriced .ct-desc { color: var(--warn); }
.cpt-table .ct-units { width: 56px; padding: 4px 6px; font-size: 13px; text-align: center; }
.cpt-table .ct-billto { font-size: 12px; padding: 3px 4px; }
.cpt-table .ct-x { width: 1%; }
.cpt-table .ct-x .cc-x { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 13px; padding: 2px 5px; }
.cpt-table .ct-x .cc-x:hover { color: #c0392b; }
.cpt-table .pe-empty { color: var(--muted); font-size: 12px; padding: 10px 8px; text-align: center; }
.proc-edit-actions { display: flex; align-items: center; gap: 10px; margin-top: auto; padding-top: 6px; }
#procDeleteBtn { color: #c0392b; }
.proc-edit-msg { font-size: 12px; color: var(--muted); }

/* low-contrast "how are allowables calculated?" link + its explainer modal */
.info-link { margin-left: auto; background: none; border: none; color: var(--muted); font-size: 12px; text-decoration: underline; text-underline-offset: 2px; cursor: pointer; padding: 6px 4px; }
.info-link:hover { color: var(--accent-dim); border-color: transparent; }
.info-window { min-width: 0; width: 600px; max-width: 92vw; max-height: 82vh; }
.info-body { overflow: auto; padding: 6px 20px 18px; line-height: 1.5; font-size: 13px; color: var(--text); }
.info-body h4 { margin: 14px 0 4px; font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.info-body p { margin: 6px 0; }
.info-body p.info-note { margin-top: 10px; padding: 8px 10px; background: var(--panel-2); border-radius: 6px; font-size: 12px; color: var(--muted); }
.info-body ul, .info-body ol { margin: 6px 0; padding-left: 20px; }
.info-body li { margin: 4px 0; }

/* The Grid: sub-type selector bar */
.grid-subtype-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.gsb-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.gsb-tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.gsb-tab { padding: 5px 12px; font-size: 12.5px; border: 1px solid var(--border); background: var(--panel-2); border-radius: 6px; cursor: pointer; color: var(--text); }
.gsb-tab:hover { border-color: var(--accent-dim); }
.gsb-tab.active { background: var(--accent-dim); border-color: var(--accent); color: #fff; font-weight: 600; }

/* The Grid: Generate Quote button (floats bottom-right of the grid panel) */
#grid { position: relative; }
.grid-genquote { position: absolute; right: 22px; bottom: 18px; padding: 10px 18px; font-size: 14px; font-weight: 600; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,.18); z-index: 5; }

/* The Grid: Generate Quote modal */
.gq-window { width: 1100px; max-width: 96vw; }
.gq-body { padding: 12px 18px 14px; overflow: auto; max-height: 88vh; display: flex; flex-direction: column; gap: 10px; }
.gq-benefits { display: flex; gap: 16px; flex-wrap: wrap; }
.gq-ins { flex: 1; min-width: 280px; border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; }
.gq-ins.disabled { opacity: .55; }
.gq-ins-title { font-size: 12px; font-weight: 700; color: var(--text); margin-bottom: 5px; display: flex; align-items: center; gap: 10px; }
.gq-ins-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px 10px; }
.gq-field { display: flex; flex-direction: column; gap: 3px; font-size: 11px; color: var(--muted); min-width: 0; }
.gq-num { width: 100%; box-sizing: border-box; padding: 4px 7px; font-size: 13px; }
.gq-controls { display: flex; gap: 16px; flex-wrap: wrap; align-items: flex-end; }
.gq-ctrl { display: flex; flex-direction: column; gap: 3px; font-size: 11px; color: var(--muted); }
.gq-payer { min-width: 200px; padding: 6px 8px; font-size: 13px; }
.gq-levels { width: 90px; padding: 6px 8px; font-size: 13px; }
.gq-sides { padding: 6px 8px; font-size: 13px; min-width: 130px; }
/* Generate Quote — settings (inviting input panel) vs the estimate (separate result box) */
.gq-panel-head { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; }
.gq-panel-head em { font-style: normal; text-transform: none; letter-spacing: 0; font-weight: 400; color: var(--muted); font-size: 11px; }
.gq-settings { background: var(--accent-soft); border: 1px solid #cfe6fb; border-radius: 10px; padding: 10px 14px; display: flex; flex-direction: column; gap: 9px; }
.gq-settings .gq-panel-head { color: var(--accent-dim); }
.gq-settings .gq-ins { background: #fff; border-color: #cfe6fb; }
.gq-settings input, .gq-settings select { background: #fff; border: 1px solid #b9d9f4; }
.gq-settings input:focus, .gq-settings select:focus { border-color: var(--accent-dim); outline: 1px solid var(--accent-dim); }
.gq-quote { border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; background: var(--panel); box-shadow: 0 1px 6px rgba(15,30,50,.08); display: flex; flex-direction: column; gap: 10px; }
.gq-quote-head { color: var(--text); }
.gq-copy-btn { padding: 6px 16px; font-size: 13px; }
.gq-grand .gq-copy-btn:first-of-type { margin-left: auto; }   /* push the two export buttons to the right edge of the banner */
.gq-grand .gq-copy-btn + .gq-copy-btn { margin-left: -6px; }  /* keep the WordPad + Excel buttons snug (counteracts the flex gap) */
.gq-privatepay { margin-left: auto; margin-right: 12px; display: flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; color: var(--text); cursor: pointer; white-space: nowrap; }
.gq-pp-note { font-size: 12px; color: var(--accent-dim); background: var(--accent-soft); border: 1px solid #cfe6fb; border-radius: 8px; padding: 10px 12px; }
.gq-sec-toggle { margin-left: auto; font-size: 11px; font-weight: 400; color: var(--muted); display: flex; align-items: center; gap: 5px; cursor: pointer; }
.gq-asc { margin-top: 10px; padding-top: 9px; border-top: 1px solid #cfe6fb; display: flex; flex-direction: column; gap: 7px; }
.gq-asc-toggle { display: flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 600; color: var(--text); cursor: default; }
.gq-asc-toggle input { cursor: pointer; }
.gq-dedfirst { display: flex; align-items: center; gap: 6px; margin-top: 8px; font-size: 11px; font-weight: 600; color: var(--text); cursor: pointer; }
.gq-asc .gq-field { max-width: 170px; }
.gq-tables { display: flex; flex-direction: column; gap: 10px; }
.gq-bill-title { font-size: 12px; font-weight: 700; color: var(--accent-dim); margin-bottom: 2px; }
.gq-table { width: 100%; border-collapse: collapse; font-size: 13px; table-layout: fixed; }
/* Fixed column widths so the CPSI and BSC tables always line up, no matter the description length. */
.gq-table th:nth-child(1), .gq-table td:nth-child(1) { width: 86px; }  /* CPT (+ ✕) */
.gq-table th:nth-child(2), .gq-table td:nth-child(2) { width: 56px; }  /* Side */
.gq-table th:nth-child(4), .gq-table td:nth-child(4) { width: 90px; }  /* Fee */
.gq-table th:nth-child(5), .gq-table td:nth-child(5) { width: 108px; } /* Allowable (input) */
.gq-table th:nth-child(6), .gq-table td:nth-child(6) { width: 100px; } /* GFE — col 3 (Description) takes the rest */
.gq-table th { text-align: left; font-size: 11px; color: var(--muted); font-weight: 600; padding: 3px 8px; border-bottom: 2px solid var(--border); }
.gq-table th:nth-child(n+4) { text-align: right; }
.gq-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.gq-table td { padding: 2px 8px; border-bottom: 1px solid var(--panel-2); vertical-align: middle; }
.gq-table .gq-cpt { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.gq-rm { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 11px; padding: 0 7px 0 0; line-height: 1; }
.gq-rm:hover { color: #c0392b; }
.gq-table .gq-desc { color: var(--muted); font-size: 12px; white-space: normal; overflow-wrap: anywhere; }
.gq-side { padding: 3px 6px; font-size: 12px; border-radius: 6px; border: 1px solid var(--border); background: var(--panel-2); color: var(--text); }
.gq-alw { width: 92px; padding: 4px 6px; font-size: 13px; text-align: right; }
.gq-gfe { font-weight: 700; color: var(--text); }
.gq-table td.gq-mva-alw { font-weight: 800; color: var(--text); cursor: help; } /* MVA: allowed = full charge; standard reimbursement shown in the tooltip */
.gq-mva-banner { margin: 0 0 8px; padding: 6px 10px; border-radius: 6px; background: #fff3e0; border: 1px solid #f0c98a; color: #7a4b00; font-size: 12px; font-weight: 600; }
.gq-mva-banner.gq-mva-warn { background: #fdecea; border-color: #e6a6a0; color: #8a2020; } /* Private Pay overriding MVA */
.gq-support-row td { background: rgba(47, 155, 240, .05); }
.gq-support-row .gq-desc { font-style: italic; color: var(--muted); }
.gq-table tfoot .gq-total td { border-top: 2px solid var(--border); border-bottom: none; font-weight: 700; padding-top: 4px; font-size: 13px; }
.gq-table tfoot .gq-total td:nth-child(3) { font-weight: 400; font-size: 11px; color: var(--muted); text-align: right; }
/* MVA "nothing due today" line - sits INSIDE the combined-estimate block, on its own full-width
   row above it, in the same black/weight as the grand-total value so it reads as a peer of
   Charge / Full charge / Patient GFE rather than a side banner. */
.gq-due { flex: 0 0 100%; font-size: 15px; font-weight: 700; color: var(--text);
  font-variant-numeric: tabular-nums; }
.gq-grand { display: flex; flex-wrap: wrap; align-items: center; gap: 14px 14px; padding: 8px 12px; background: var(--accent-soft); border: 1px solid #cfe6fb; border-radius: 8px; }
.gq-grand-lab { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--accent-dim); }
.gq-grand-val { font-size: 15px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.gq-note { font-size: 11.5px; color: var(--muted); line-height: 1.5; padding-top: 4px; border-top: 1px solid var(--panel-2); }

#msgtemplates.panel.active, #msgautomations.panel.active {
  display: flex; flex-direction: column; min-height: 0; overflow-y: auto;
}
#msgtemplates .console-bar, #msgautomations .console-bar { flex: 0 0 auto; }
.tmpl-wrap, .auto-wrap { flex: 1 1 auto; }
/* Grid children default to min-width:auto and blow out the track — the 8-column preview table did. */
.tmpl-list, .tmpl-edit, .tmpl-side, .auto-list, .auto-edit { min-width: 0; }
.table-scroll { overflow-x: auto; max-width: 100%; }

/* ── text templates + reminder automations ────────────────────────────────── */
/* Templates: list | editor | live preview. The preview earns the third column — seeing the
   rendered message next to the field you are editing is the whole point of the screen. */
.tmpl-wrap { display: grid; grid-template-columns: 260px minmax(0, 1fr) 330px; gap: 16px; padding: 12px 16px; align-items: start; }
@media (max-width: 1200px) {
  .tmpl-wrap { grid-template-columns: 240px minmax(0, 1fr); }
  .tmpl-side { grid-column: 1 / -1; }
}
/* Automations: the rule list stays narrow; the editor spreads its fields across the width instead
   of stacking 340px inputs down the left edge. */
.auto-wrap { display: block; padding: 12px 16px; }
.auto-list { margin-bottom: 16px; }
/* Full panel width — the old 1100px cap left dead space on wide monitors while the
   preview table scrolled horizontally inside it. */
.auto-edit { max-width: none; }
.tmpl-list, .auto-list { display: flex; flex-direction: column; gap: 6px; }
.tmpl-row { text-align: left; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 9px 11px; cursor: pointer; font: inherit; color: inherit; }
.tmpl-row:hover { border-color: var(--accent); }
.tmpl-row.active { border-color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
.tmpl-row-name { font-weight: 650; }
.tmpl-row-body { font-size: 12px; color: var(--muted); margin-top: 3px; }
.tmpl-builtin { font-size: 10px; color: var(--muted); border: 1px solid var(--border); border-radius: 10px; padding: 0 6px; }
.tmpl-edit, .auto-edit { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; }
.tmpl-edit .field, .auto-edit .field { display: block; margin-bottom: 12px; }
.tmpl-edit .field-label, .auto-edit .field-label, .field-label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.tmpl-name, .auto-num, .auto-hour { width: 100%; padding: 7px 9px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: inherit; font: inherit; }
.auto-num { max-width: 90px; }
.auto-hour { max-width: 140px; }
.tmpl-body { width: 100%; max-width: 62ch; padding: 9px 11px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: inherit; font: inherit; line-height: 1.45; resize: vertical; }
.tmpl-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; }
.tmpl-chip { font-size: 12px; padding: 3px 9px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg); color: inherit; cursor: pointer; font-family: inherit; }
.tmpl-chip:hover { border-color: var(--accent); color: var(--accent); }
.tmpl-preview { border: 1px solid var(--border); border-radius: 10px; padding: 12px; background: var(--panel); }
.tmpl-side { position: sticky; top: 12px; }
@media (max-width: 1200px) { .tmpl-side { position: static; } }
/* Render the preview as a message bubble — staff judge tone by how it will actually look. */
.tmpl-preview-body { white-space: pre-wrap; line-height: 1.5; background: rgba(60, 120, 200, .12); border: 1px solid rgba(60, 120, 200, .3); border-radius: 14px 14px 14px 4px; padding: 9px 12px; }
.tmpl-seg { font-size: 11px; color: var(--muted); margin-top: 6px; }
.tmpl-warn { margin-top: 8px; font-size: 12px; color: #8a5b00; }
.tmpl-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.auto-timing { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; align-items: end; }
.auto-timing .field { margin-bottom: 0; }
.auto-filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; margin-top: 12px; }


.auto-flags { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 6px 18px; margin-bottom: 12px; }
.auto-multi { width: 100%; padding: 4px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: inherit; font: inherit; }
.auto-pill { font-size: 11px; border-radius: 10px; padding: 1px 8px; }
.auto-pill.on { background: rgba(20, 101, 44, .12); color: #14652c; }
.auto-pill.off { background: rgba(120, 120, 120, .15); color: var(--muted); }
.auto-preview { margin-top: 14px; }
.auto-preview-head { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; }
.auto-why { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.auto-table td { white-space: nowrap; }
.auto-skip { opacity: .55; }

/* ── conversations (two-way) ──────────────────────────────────────────────── */
/* One row, always: label left, Incomplete toggle beside it, poll time flushed right. Nothing wraps. */
.msg-inbox-head { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; padding: 10px 8px 6px; border-top: 1px solid var(--border); margin-top: 12px; white-space: nowrap; }
.msg-inbox-head .muted { margin-left: auto; font-size: 11px; }
.thr-list { display: flex; flex-direction: column; gap: 5px; flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 0 6px 8px; }
.thr-row { text-align: left; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; cursor: pointer; font: inherit; color: inherit; }
.thr-row:hover { border-color: var(--accent); }
.thr-row.active { border-color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
.thr-head { display: flex; align-items: center; gap: 6px; }
.thr-who { font-weight: 650; }
.thr-line { font-size: 10px; color: var(--muted); border: 1px solid var(--border); border-radius: 9px; padding: 0 6px; }
.thr-unread { margin-left: auto; background: var(--accent); color: #fff; font-size: 10px; border-radius: 9px; padding: 0 6px; }
.thr-sub, .thr-when { font-size: 12px; color: var(--muted); margin-top: 2px; }
.thrv { margin-top: 14px; flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.thrv-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
/* "Mark complete" / "Mark action needed" on the SELECTED conversation card — spans (the card is a
   <button>). They sit on their own full-width row (.thr-actions) and never wrap (user, 2026-09-29). */
.thr-markcomplete, .thr-markaction { margin-left: auto; padding: 1px 9px; font-size: 10.5px; font-weight: 600;
  border: 1px solid var(--border); border-radius: 5px; background: var(--panel); cursor: pointer;
  white-space: nowrap; flex: 0 0 auto; }
.thr-markcomplete:hover { border-color: var(--accent); color: var(--accent); }
.thr-markaction:hover { border-color: #8c1d18; color: #8c1d18; }
.thr-actionflag { font-size: 10.5px; font-weight: 700; color: #8c1d18; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; min-width: 0; flex: 1 1 auto; align-self: center; }
.thrv-head, .thrv-tabwrap, .thrv-others { flex: 0 0 auto; }
.thrv-meta { font-size: 12px; color: var(--muted); }
.thrv-presence { margin-left: auto; font-size: 11.5px; color: var(--muted); font-weight: 600; }
.thrv-presence.typing { color: var(--accent); }
/* ERA enrollment admin tab */
.era-h { margin: 18px 0 4px; font-size: 15px; }
.era-instr { font-size: 11.5px; color: var(--muted); }
.era-possible { font-size: 11px; color: #7a5c07; font-weight: 600; margin-top: 2px; }
.era-fam { border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; margin: 10px 0; background: var(--panel-2); }
.era-fam-h { display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap; margin-bottom: 6px; }
.era-fam-status { font-size: 12px; font-weight: 700; }
.era-st-receiving { color: #1d7a35; }
.era-st-partial, .era-st-enroll { color: #8c1d18; }
.era-st-no-era, .era-st-unknown { color: var(--muted); }
.era-v-receiving { color: #1d7a35; font-weight: 600; white-space: nowrap; }
.era-v-enroll { color: #8c1d18; font-weight: 700; white-space: nowrap; }
.era-v-no-era, .era-v-unknown-id { color: var(--muted); }
.era-arrival td { color: var(--muted); font-size: 12px; }
/* ERA Enrollment Completion — the one-number card above the chips. */
.era-score { display: flex; align-items: center; gap: 14px; padding: 12px 16px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--panel); width: 100%; }
.era-score-pct { font-size: 34px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1; }
.era-score-lbl { font-weight: 600; }
.era-score-low .era-score-pct { color: #c0392b; }
.era-score-mid .era-score-pct { color: var(--warn); }
.era-score-high .era-score-pct { color: var(--ok); }
/* Identical column geometry across every family block — the blocks read as ONE aligned report,
   not a stack of independently-sized tables. */
.era-fam table.grid { table-layout: fixed; width: 100%; }
.era-fam th:nth-child(1), .era-fam td:nth-child(1) { width: 26%; }
.era-fam th:nth-child(2), .era-fam td:nth-child(2) { width: 13%; }
.era-fam th:nth-child(3), .era-fam td:nth-child(3) { width: 6%; text-align: right; font-variant-numeric: tabular-nums; }
.era-fam th:nth-child(4), .era-fam td:nth-child(4) { width: 14%; }
.era-fam th:nth-child(5), .era-fam td:nth-child(5) { width: 41%; }
.era-fam td { overflow-wrap: break-word; vertical-align: top; }

/* MMS attachments render inline in the bubble; click opens full size. */
.thrv-mms { display: block; max-width: 260px; max-height: 320px; border-radius: 8px; margin-top: 4px; cursor: zoom-in; }
.thrv-mms-link { display: inline-block; margin-top: 4px; font-size: 12.5px; }
.thrv-others { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
/* THE one scrolling element on this screen. overscroll-contain stops a wheel at either end from
   scrolling anything behind it. */
.thrv-log { display: flex; flex-direction: column; gap: 8px; padding-right: 4px;
  flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
/* A short conversation hugs the composer (bubbles rise from the bottom), exactly like a phone's
   thread view — the auto margin absorbs the free space above the first bubble. */
.thrv-log > :first-child { margin-top: auto; }
.thrv-msg { max-width: 46ch; padding: 8px 11px; border-radius: 12px; }
.thrv-msg.in { align-self: flex-start; background: var(--panel); border: 1px solid var(--border); }
.thrv-msg.out { align-self: flex-end; background: rgba(60, 120, 200, .12); border: 1px solid rgba(60, 120, 200, .3); }
.thrv-body { white-space: pre-wrap; line-height: 1.45; }
.thrv-when { font-size: 11px; color: var(--muted); margin-top: 4px; }
/* "Marked complete by … · time" / "Action needed — marked by … · time" — an event between
   messages, not a bubble from either side. Spans the whole log and stays on ONE line: it never
   wraps, and a very long name trims with an ellipsis (the full text is in the tooltip). */
.thrv-log .thrv-msg.note { align-self: stretch; max-width: none; width: 100%; box-sizing: border-box; padding: 2px 10px; font-size: 11px; line-height: 1.4; color: var(--muted);
  background: none; border: 0; box-shadow: none; text-align: center; font-style: italic; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thrv-log .thrv-msg.note.action { color: #8c1d18; font-style: normal; font-weight: 600; }
.auto-check { display: flex; align-items: flex-start; gap: 7px; font-size: 13px; }

/* Rule table — the seeded set is 11 rules deep, so every attribute gets its own column. */
.auto-table-rules { width: 100%; }
/* Drag-to-reorder affordances on automation rows. */
.auto-table-rules tr.dragging { opacity: .45; }
.auto-table-rules tr.drop-above td { box-shadow: inset 0 2px 0 var(--accent); }
.auto-table-rules tr.drop-below td { box-shadow: inset 0 -2px 0 var(--accent); }
.auto-table-rules tr.clickable.active td { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.auto-muted { color: var(--muted); }
.tmpl-preview-label { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 6px; }

/* ── conversation compose + patient context panel ─────────────────────────── */
.msg-compose { flex: 0 0 auto; border-top: 1px solid var(--border); padding: 10px 0 4px; margin-top: 10px; }
.msg-chips { margin: 8px 0 6px; }
.msg-prev { font-size: 12px; color: var(--muted); margin: 6px 0; font-style: italic; }
.msg-sec { border-top: 1px solid var(--border); padding-top: 10px; margin-top: 12px; }
.msg-sec-h { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 6px; }
.msg-ph { display: flex; align-items: baseline; gap: 7px; margin-bottom: 4px; flex-wrap: wrap; }
.msg-ph-num { font-weight: 600; }
.msg-ph-tag { font-size: 10px; border: 1px solid var(--border); border-radius: 9px; padding: 0 6px; color: var(--muted); }
.msg-ph-tag.ok { color: #14652c; border-color: #bfe3ca; }
.msg-consent-state { display: inline-block; font-weight: 700; font-size: 12px; border-radius: 999px; padding: 2px 10px; border: 1px solid currentColor; }
.msg-appt { border-left: 2px solid var(--accent); padding: 2px 0 2px 8px; margin-bottom: 8px; }
.msg-appt-when { display: flex; gap: 8px; align-items: baseline; }
.msg-appt-date { font-weight: 650; }
.msg-appt-type { font-size: 12.5px; }
.msg-appt-conf { font-size: 11.5px; font-weight: 700; margin-top: 3px; }
.msg-appt-conf.ok { color: #1d7a35; }
.msg-appt-conf.no { color: #8c1d18; }
.msg-appt-btns { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.msg-appt-confbtn, .msg-appt-remindbtn { padding: 2px 12px; font-size: 11.5px; font-weight: 600; white-space: nowrap;
  border: 1px solid var(--border); border-radius: 5px; background: var(--panel); cursor: pointer; }
.msg-appt-confbtn:hover { border-color: #1d7a35; color: #1d7a35; }
.msg-appt-remindbtn:hover { border-color: var(--accent); color: var(--accent); }
.msg-appt-confbtn:disabled, .msg-appt-remindbtn:disabled { opacity: .6; cursor: default; }
.msg-appt-sent { font-size: 11.5px; font-weight: 600; color: #1d7a35; white-space: nowrap; }

/* Compose sits on its own surface so the conversation above it reads as a distinct area. */
.msg-compose { background: var(--panel-2); margin: 10px -16px 0; padding: 12px 16px 8px; }
/* Per-patient line tabs — clinic vs surgery centre, never interleaved. */
/* Incomplete conversations must be findable without hunting: a badge on the nav and a filter on the list. */
.snav-unread { margin-left: 6px; background: var(--err, #b3261e); color: #fff; font-size: 10px; font-weight: 700;
  border-radius: 9px; padding: 1px 6px; }
.msg-incomplete-toggle { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 4px; }
.thr-row.unread { background: var(--accent-soft); }
.thr-row.unread .thr-who { font-weight: 750; }

/* Line tabs: centred over the conversation, and unmistakably a control rather than a caption.
   The active line also decides which number a reply leaves from, so it must never be ambiguous. */
/* Announcements — a top-to-bottom builder (from → to → message), then the review + send. */
.ann-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 330px; width: 100%; min-height: 0; }
@media (max-width: 1100px) { .ann-wrap { grid-template-columns: minmax(0, 1fr); } .ann-side { display: none; } }
.ann-main { min-width: 0; overflow-y: auto; padding: 0 16px 24px; }
.ann-side { min-width: 0; overflow-y: auto; padding: 12px 14px; border-left: 1px solid var(--border); background: var(--panel); }
.ann-step { margin: 14px 0 0; padding: 12px 14px; border: 1px solid var(--border); border-radius: 8px; background: var(--panel); }
.ann-step-h { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; margin-bottom: 8px; }
.ann-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.ann-row select, .ann-row input[type="date"] { font: inherit; font-size: 13px; padding: 5px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--panel); color: var(--text); }
.ann-hint { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.ann-warn { color: #b3261e; font-weight: 600; }
.ann-body { margin-top: 8px; }
.ann-sample { font-size: 12.5px; color: var(--muted); margin-top: 6px; padding: 7px 10px; background: var(--panel-2); border-radius: 6px; white-space: pre-wrap; }
.ann-actions { display: flex; align-items: center; gap: 12px; margin: 14px 0 0; }
.ann-progress { font-size: 13px; font-weight: 600; color: var(--muted); }
.ann-review { margin-top: 18px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 8px; background: var(--panel); }
.ann-stale { padding: 8px 11px; border-radius: 6px; background: #fdf3c4; color: #7a5c07; border: 1px solid #eedb8a; font-size: 12.5px; font-weight: 600; margin-bottom: 10px; }
.ann-summary { font-size: 13px; margin-bottom: 8px; }
.ann-counts { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.ann-warn-box { padding: 8px 11px; border-radius: 6px; background: #fdecea; color: #8c1d18; border: 1px solid #f5c6c2; font-size: 12.5px; margin-bottom: 10px; }
.ann-table { font-size: 12.5px; }
.ann-table .ann-skip { opacity: .55; }
.ann-table .ann-yes { color: var(--ok); font-weight: 700; }
.ann-table .ann-no { color: #8c1d18; font-size: 11.5px; }
.ann-table .ann-msg { max-width: 34ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* CPSI Scheduling worklist actions — two solid, unmistakable buttons: green moves the
   appointment, red takes the row off the list. Same filled treatment as button.primary.
   The cell is width-capped so a result message can NEVER widen the table — anything longer than
   the buttons' own footprint truncates to an ellipsis, full text on hover. */
.adm-md-actions { white-space: nowrap; max-width: 190px; }
.adm-md-actions button { margin-right: 4px; }
.adm-md-actions span { display: inline-block; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }

/* Hovering anywhere on a worklist row — the name at the far left or the buttons at the far
   right — lights the WHOLE row, so the eye keeps its place across the width. Outranks the zebra
   stripe; the yellow matching-opening rows darken instead of losing their color. */
#admMdRows table.grid tbody tr:hover td { background: rgba(60, 120, 200, .12); }
#admMdRows table.grid tbody tr.adm-slot-open:hover td { background: #f6e18e; }
button.btn-go { background: #1d7a3f; border-color: #14652c; color: #fff; font-weight: 600; font-size: 12px; padding: 6px 12px; }
button.btn-go:hover:not(:disabled) { background: #17994a; border-color: #14652c; }
button.btn-stop { background: #b3261e; border-color: #8c1d18; color: #fff; font-weight: 600; font-size: 12px; padding: 6px 12px; }
button.btn-stop:hover:not(:disabled) { background: #d33a31; border-color: #8c1d18; }
button.btn-go:disabled, button.btn-stop:disabled { opacity: .35; }
.adm-md-ok { color: var(--ok); font-weight: 600; font-size: 12px; }
.adm-md-warn { color: #7a5c07; font-weight: 600; font-size: 12px; }
.adm-md-decided { opacity: .6; }

/* The facility multi-select: a plain button that opens a checkbox panel. */
.ann-multi { position: relative; display: inline-block; }
.ann-multi-btn { font: inherit; font-size: 13px; padding: 5px 10px; border: 1px solid var(--border); border-radius: 6px; background: var(--panel); color: var(--text); cursor: pointer; }
.ann-multi-btn:hover { background: var(--panel-2); }
.ann-multi-pop { position: absolute; top: calc(100% + 4px); left: 0; z-index: 40; min-width: 320px; max-height: 300px; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 6px 20px rgba(15, 30, 50, .16); padding: 6px; }
.ann-multi-opt { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 5px; font-size: 13px; cursor: pointer; }
.ann-multi-opt:hover { background: var(--panel-2); }
.ann-multi-opt .muted { margin-left: auto; font-size: 11px; }
.ann-multi-any { border-bottom: 1px solid var(--border); border-radius: 5px 5px 0 0; margin-bottom: 4px; }
.ann-hist { border: 1px solid var(--border); border-radius: 7px; padding: 8px 10px; margin-bottom: 8px; background: var(--panel-2); }
.ann-hist-h { font-size: 12px; font-weight: 700; }
.ann-hist-meta { font-size: 11px; color: var(--muted); margin-top: 2px; }
.ann-hist-body { font-size: 12px; margin: 5px 0; white-space: pre-wrap; }
.ann-hist-fail { font-size: 11px; color: #8c1d18; margin-top: 2px; }
/* Send accepted: the order is taken; progress lives on the run's history card, not the button. */
.ann-accepted { padding: 10px 12px; border-radius: 7px; background: #e8f5ec; color: #135723; border: 1px solid #bfe3c8; font-size: 13px; font-weight: 600; margin-top: 14px; }
.ann-accepted small { display: block; font-weight: 400; color: #2c6b3c; margin-top: 3px; }
.ann-bar { height: 8px; border-radius: 4px; background: var(--border); overflow: hidden; margin-top: 6px; }
.ann-bar-fill { height: 100%; width: 0; background: #2f855a; transition: width .6s ease; }
.ann-live-text { font-size: 11.5px; font-weight: 600; color: var(--muted); margin-top: 3px; }
.thrv-tabwrap { display: flex; justify-content: center; padding: 4px 0 12px; border-bottom: 1px solid var(--border); margin-bottom: 12px; }
.thrv-tabs { box-shadow: 0 1px 2px rgba(15, 30, 50, .06); }
.thrv-tabs button { padding: 8px 20px; font-size: 13px; font-weight: 600; }
/* Lives on the send row beside the character count — no margin of its own. */
.msg-fromline { font-size: 11.5px; color: var(--muted); margin: 0; }
.msg-chip-hint { font-size: 11.5px; color: var(--muted); align-self: center; margin-right: 2px; }
.msg-prev-label { font-style: normal; font-weight: 600; color: var(--muted); }
.msg-prev-body { font-style: normal; color: var(--text); }
.msg-prev-appt { font-size: 11.5px; color: var(--muted); margin-top: 4px; font-style: normal; }
.msg-prev-warn { font-size: 11.5px; color: #8a5b00; margin-top: 4px; font-style: normal; }

/* ── Indexing tab table: must NEVER scroll horizontally (user's rule) ─────────
   Fixed layout + percentage columns = the table mathematically cannot exceed its container;
   cells wrap instead of pushing width. */
#admIdxRows table.grid { table-layout: fixed; }
#admIdxRows table.grid th, #admIdxRows table.grid td {
  white-space: normal; overflow-wrap: anywhere; word-break: break-word;
  max-width: none; vertical-align: top;
}
#admIdxRows th:nth-child(1) { width: 13%; }   /* File */
#admIdxRows th:nth-child(2) { width: 17%; }   /* Patient / account */
#admIdxRows th:nth-child(3) { width: 11%; }   /* Doc type */
#admIdxRows th:nth-child(4) { width: 12%; }   /* Provider */
#admIdxRows th:nth-child(5) { width: 9%; }    /* Clinical date */
#admIdxRows th:nth-child(6) { width: 23%; }   /* Summary line */
#admIdxRows th:nth-child(7) { width: 15%; }   /* Action */
#admIdxRows .adm-md-actions { max-width: none; }
#admIdxRows .adm-md-actions button { margin: 2px 4px 2px 0; }
#admIdxRows .fax-summary { max-width: none; }

/* Optimistic indexing actions: the row confirms with a glow, then collapses so the rows below
   slide up into its place. Filing continues in the background — the click never waits. */
#admIdxRows tr.adm-idx-done td { background: #d7f3e1 !important; transition: background .18s ease; }
#admIdxRows tr.adm-idx-going td { background: #fadcd9 !important; transition: background .18s ease; }
#admIdxRows tr.adm-idx-leaving td {
  padding-top: 0 !important; padding-bottom: 0 !important;
  line-height: 0; font-size: 0; opacity: 0; overflow: hidden;
  border-top-color: transparent; border-bottom-color: transparent;
  transition: padding .40s ease, line-height .40s ease, font-size .40s ease, opacity .30s ease, border-color .30s ease;
}
#admIdxRows tr.adm-idx-leaving td > * { opacity: 0; transition: opacity .16s ease; }
/* A row that came back because filing failed. */
#admIdxRows tr.adm-idx-failed td, #admIdxRows tr.adm-idx-failed:nth-child(even) td { background: #fdecec; }
@media (prefers-reduced-motion: reduce) {
  #admIdxRows tr.adm-idx-done td, #admIdxRows tr.adm-idx-going td, #admIdxRows tr.adm-idx-leaving td,
  #admIdxRows tr.adm-idx-leaving td > * { transition: none; }
}

/* ── Toast stack: fixed bottom-right, newest at the bottom, one 15s life each ──
   Messages never overwrite each other and never shift the page. A leaving toast collapses its own
   box (height + padding + margin together), so the ones above glide down instead of snapping. */
#uiToasts {
  position: fixed; right: 18px; bottom: 18px; z-index: 60;
  display: flex; flex-direction: column; align-items: flex-end;
  max-width: min(460px, 92vw); pointer-events: none;
}
.ui-toast {
  pointer-events: auto; cursor: pointer;
  margin-top: 8px; max-height: 260px; overflow: hidden;
  background: var(--panel, #fff); color: var(--text, #16324f);
  border: 1px solid var(--border, #d9e2ec); border-left: 4px solid var(--accent, #2f6fb0);
  border-radius: 8px; padding: 9px 13px;
  font-size: 12.5px; line-height: 1.45; white-space: pre-line;
  box-shadow: 0 8px 24px rgba(15, 30, 50, .17);
  opacity: 0; transform: translateY(10px) scale(.97);
  transition: opacity .26s ease, transform .3s cubic-bezier(.2, .8, .3, 1);
}
.ui-toast.in { opacity: 1; transform: none; }
.ui-toast.out {
  opacity: 0; transform: translateX(16px);
  max-height: 0 !important; margin-top: 0;
  padding-top: 0; padding-bottom: 0;
  border-top-width: 0; border-bottom-width: 0;
  transition: opacity .22s ease, transform .3s ease, max-height .36s cubic-bezier(.4, 0, .2, 1),
              margin .36s cubic-bezier(.4, 0, .2, 1), padding .36s cubic-bezier(.4, 0, .2, 1),
              border-width .36s ease;
}
.ui-toast-ok   { border-left-color: #1d7a3f; }
.ui-toast-warn { border-left-color: #b8860b; }
.ui-toast-err  { border-left-color: #b3261e; }
@media (prefers-reduced-motion: reduce) {
  .ui-toast, .ui-toast.in, .ui-toast.out { transition: none; }
}

/* Manual hand-off: neither approve (green) nor delete (red) — an amber "someone else takes it". */
.btn-manual { border-color: #d8b45a; color: #8a6300; background: #fdf6e4; }
.btn-manual:hover:not(:disabled) { background: #fbeeca; }
#admIdxRows tr.adm-idx-manual td { background: #fdf1d6 !important; transition: background .18s ease; }

/* ── shared-number household (2026-08-26) ── */
.msg-head-also { margin-top: 4px; }
.msg-head-also .linklike {
  background: none; border: none; padding: 0; cursor: pointer;
  color: var(--link, #2563eb); font: inherit; font-weight: 600; text-decoration: underline;
}
.msg-head-also .linklike:hover { opacity: .8; }
.msg-appt-owner { font-weight: 700; margin: 8px 0 2px; font-size: 0.92em; }
.msg-ph .msg-consent-state { margin-left: 6px; font-size: 0.78em; }
.msg-num-consent { margin-left: 4px; padding: 1px 7px; font-size: 0.78em; }
.msg-ask-edit { width: 100%; box-sizing: border-box; margin-top: 6px; font: inherit; padding: 6px 8px; }
.msg-shared { margin: 2px 0 6px; }

/* Load-older control in a conversation (2026-08-27) */
.thrv-older { text-align: center; padding: 6px 0 10px; }
.thrv-older .minor-btn { font-size: 0.82em; }

.msg-reminder-label { display: flex; flex-direction: column; gap: 6px; margin-top: 14px; font-size: 12px; font-weight: 600; }
.msg-reminder-number { width: 100%; min-width: 0; padding: 7px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--text); }
.msg-reminder-status { margin-top: 6px; line-height: 1.5; }

/* Conversation identity and routing each get their own predictable space. */
.thr-row { min-width: 0; flex-shrink: 0; }
.thr-head { align-items: flex-start; }
.thr-who { min-width: 0; flex: 1; overflow-wrap: anywhere; line-height: 1.4; }
.thr-unread { flex-shrink: 0; white-space: nowrap; }
.thr-routing { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-top: 5px; font-size: 11px; color: var(--muted); }
.thr-phone { white-space: nowrap; font-variant-numeric: tabular-nums; }
.thr-date { white-space: nowrap; font-size: 10px; }
.thr-company { margin-top: 3px; font-size: 11px; line-height: 1.4; color: var(--muted); overflow-wrap: anywhere; }
.thr-row .thr-sub { margin-top: 7px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
/* One full-width row for the card's control (and the open action-needed flag): nothing wraps. */
.thr-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 8px; width: 100%; min-width: 0; flex-wrap: nowrap; white-space: nowrap; }

.thr-search-phone { display: flex; flex-wrap: wrap; gap: 4px 8px; margin-top: 5px; font-size: 12px; }
.thr-phone-type { color: var(--muted); font-size: 11px; }
.thr-match-reason { margin-top: 4px; color: var(--accent); font-size: 11px; line-height: 1.4; }
.thr-phone-pick { cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

/* Failure notices stay visible without crowding out the conversation and composer. */
.msg-delivery-issues[hidden] { display:none; }
.thrv-when .msg-delivery-status, .thrv-when .msg-delivery-retry { border:0; padding:0; background:none; font:inherit; color:inherit; cursor:pointer; text-decoration:underline; text-underline-offset:2px; }
.msg-delivery-time { margin-left:7px; }
.thrv-when .msg-delivery-retry { margin-left:10px; font-weight:600; color:var(--primary,#176e83); }
.thrv-msg[data-delivery-state="not-sent"] .msg-delivery-status, .thrv-msg[data-delivery-state="not-delivered"] .msg-delivery-status { color:#a82828; font-weight:600; }
.msg-delivery-dialog { border:1px solid #ccd8df; border-radius:10px; padding:22px; max-width:420px; width:calc(100% - 48px); line-height:1.5; }
.msg-delivery-dialog::backdrop { background:#15232d66; }
.msg-delivery-dialog h2 { margin-top:0; font-size:18px; }
.msg-delivery-dialog button { margin-top:10px; }

.thr-failure{color:#ae2727;font-weight:600;font-size:12px;margin:5px 0;}

/* Quote fields and responsive totals. */
.gq-save-status { font-size:12px; color:var(--muted); margin-top:8px; line-height:1.4; }
.gq-ctrl input[type=date] { padding:7px; border:1px solid var(--border); border-radius:5px; background:var(--panel); color:var(--text); }
.gq-table td.gq-gfe { white-space:normal; overflow-wrap:anywhere; }
.gq-table th:last-child,.gq-table td:last-child { width:125px; }
.gq-bill { overflow-x:auto; }
@media(max-width:760px) { .gq-table { min-width:690px; } }
/* ---------- Admin → SOPs: procedures rebuilt from the S: drive, for staff review ---------- */
.sop-search { min-width: 200px; padding: 5px 9px; border: 1px solid var(--border); border-radius: 6px; font: inherit; background: var(--panel); }
.sop-layout { display: grid; grid-template-columns: 290px minmax(0, 1fr); gap: 14px; margin-top: 10px; }
.sop-list { border: 1px solid var(--border); border-radius: 10px; background: var(--panel); padding: 8px; max-height: calc(100vh - 330px); min-height: 240px; overflow: auto; }
.sop-cat { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin: 12px 6px 4px; }
.sop-cat:first-child { margin-top: 2px; }
.sop-item { display: block; width: 100%; text-align: left; border: 1px solid transparent; background: none; border-radius: 8px; padding: 6px 8px; cursor: pointer; font: inherit; color: var(--text); }
.sop-item:hover { background: var(--panel-2); }
.sop-item.active { background: var(--accent-soft); border-color: #cfe6fb; }
.sop-item:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.sop-item-t { display: block; font-weight: 600; font-size: 13px; line-height: 1.3; }
.sop-item-m { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.sop-chip { display: inline-block; font-size: 10.5px; font-weight: 600; padding: 1px 7px; border-radius: 999px; background: var(--panel-2); color: var(--muted); border: 1px solid var(--border); white-space: nowrap; }
.sop-rev-approved, .sop-al-matches { background: #e6f5ec; color: #1d7a35; border-color: #bfe3cc; }
.sop-rev-in-review { background: var(--accent-soft); color: var(--accent-dim); border-color: #cfe6fb; }
.sop-rev-needs-changes, .sop-al-differs { background: #fdecea; color: #8c1d18; border-color: #f3c7c2; }
.sop-al-app-only, .sop-al-doc-only, .sop-al-told-only, .sop-q { background: #fff6e0; color: #8a5a00; border-color: #f1dca8; }
.sop-conf-high { color: #1d7a35; }
.sop-conf-low { color: #8c1d18; }
.sop-detail { border: 1px solid var(--border); border-radius: 10px; background: var(--panel); padding: 16px 20px; max-height: calc(100vh - 330px); min-height: 240px; overflow: auto; min-width: 0; }
.sop-head { border-bottom: 1px solid var(--border); padding-bottom: 8px; margin-bottom: 10px; }
.sop-crumb { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.sop-title { margin: 2px 0 6px; font-size: 19px; text-wrap: balance; }
.sop-head-m { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.sop-review { background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; margin-bottom: 14px; }
.sop-review-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 6px; }
.sop-note { width: 100%; font: inherit; border: 1px solid var(--border); border-radius: 6px; padding: 6px 8px; resize: vertical; background: var(--panel); }
.sop-hist { margin-top: 6px; font-size: 12px; color: var(--muted); }
.sop-sec { margin: 0 0 16px; }
.sop-sec h3 { font-size: 14px; margin: 0 0 6px; padding-bottom: 3px; border-bottom: 1px solid var(--border); }
.sop-p { margin: 0 0 6px; max-width: 82ch; }
.sop-sec ol, .sop-sec ul { margin: 0; padding-left: 22px; }
.sop-sec li { margin: 4px 0; max-width: 92ch; }
.sop-basis { display: inline-block; font-size: 10px; font-weight: 600; padding: 0 6px; border-radius: 999px; margin-left: 4px; vertical-align: 1px; border: 1px solid var(--border); color: var(--muted); background: var(--panel); white-space: nowrap; }
.sop-basis-told { color: #6d28d9; border-color: #ddd0fb; background: #f5f0ff; }
.sop-basis-app { color: var(--accent-dim); border-color: #cfe6fb; background: var(--accent-soft); }
.sop-basis-inferred { color: #8a5a00; border-color: #f1dca8; background: #fff6e0; }
.sop-refs { white-space: nowrap; }
.sop-ref { font-size: 10px; vertical-align: super; margin-left: 2px; color: var(--accent-dim); text-decoration: none; }
.sop-refs .sop-ref + .sop-ref::before { content: ","; color: var(--muted); }
.sop-item-note { color: var(--muted); font-size: 12px; margin-top: 2px; }
.sop-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.sop-table td { vertical-align: top; }
.sop-align td { font-size: 12px; min-width: 110px; }
.sop-src-t { display: block; }
.sop-src-m { display: block; font-size: 11.5px; color: var(--muted); word-break: break-word; }
.sop-flash { background: #fff6c7; transition: background .4s; }
.sop-meta { width: 100%; }
@media (max-width: 900px) { .sop-layout { grid-template-columns: 1fr; } .sop-list, .sop-detail { max-height: none; } }

/* Real-time benefits: the quote strip and Admin → Eligibility */
.gq-elig { border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; margin-bottom: 10px; display: flex; flex-direction: column; gap: 6px; }
.gq-elig-head { display: flex; align-items: center; gap: 8px; }
.gq-elig-sources { display: flex; flex-direction: column; gap: 6px; }
.gq-elig-card { border: 1px dashed var(--border); border-radius: 6px; padding: 6px 8px; display: flex; flex-direction: column; gap: 5px; align-items: flex-start; }
.gq-elig-card-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.gq-elig-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.elig-chip { display: inline-flex; gap: 5px; align-items: baseline; border: 1px solid var(--border); border-radius: 999px; padding: 1px 8px; font-size: 12px; }
.elig-chip-l { color: var(--muted); }
.elig-chip-v { font-weight: 600; font-variant-numeric: tabular-nums; }
.gq-elig-note { font-size: 12.5px; color: var(--muted); }
.gq-elig-warn { color: #a33; font-weight: 600; }
.gq-elig-run { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.elig-table td { vertical-align: top; }
.elig-actions { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.elig-cands { display: flex; flex-wrap: wrap; gap: 4px; width: 100%; }
.adm-ok { color: #2b7a2b; }
.adm-bad { color: #a33; font-weight: 600; }
.adm-note, .adm-muted { color: var(--muted); }
.pending-ver { white-space: nowrap; }
.pending-ver.stale { color: #a33; }
