/* Clinic portal layout. */
body.portal { background: var(--bg); font-size: 14px; }

.container { max-width: 1440px; margin: 0 auto; padding: 0 24px; }

/* Header */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar__inner { padding-top: 14px; padding-bottom: 14px; display: flex; flex-wrap: wrap; align-items: center; gap: 16px 28px; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand__mark { width: 32px; height: 32px; border-radius: 8px; background: var(--accent); display: flex; align-items: center; justify-content: center; }
.brand__name { display: block; font-weight: 700; font-size: 16px; letter-spacing: -0.01em; }
.brand__sub { display: block; font-size: 12px; color: var(--muted); }
.tabs { display: flex; gap: 4px; flex-grow: 1; }
.tab {
  height: 44px; padding: 0 16px; border: none; border-radius: 8px; cursor: pointer;
  font-size: 14px; font-weight: 600; display: flex; align-items: center;
  background: transparent; color: var(--ink-3);
}
.tab[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
.tab__count { margin-left: 8px; background: var(--warn-bg); color: var(--warn-fg); border-radius: 999px; padding: 1px 8px; font-size: 12px; font-weight: 600; }
.topbar__tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.avatar { width: 32px; height: 32px; border-radius: 999px; background: #E6EBF1; color: var(--ink-2); font-weight: 600; font-size: 12px; display: flex; align-items: center; justify-content: center; }

.main { padding-top: 20px; padding-bottom: 48px; display: flex; flex-direction: column; gap: 16px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.card__head { display: flex; flex-direction: column; gap: 2px; }
.card__title { font-size: 16px; }

/* Date range bar */
.rangebar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 10px 12px; }
.rangebar .btn--icon { height: 40px; }
.rangebar__label { display: flex; flex-direction: column; min-width: 200px; }
.rangebar__label strong { font-weight: 600; }
.rangebar__nav { display: flex; align-items: center; gap: 8px; }
.rangebar__custom { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; }
.rangebar label { font-size: 12px; color: var(--muted); }
.rangebar input[type="date"] { height: 38px; padding: 0 8px; }

/* Dashboard */
.dash-row { display: flex; flex-wrap: wrap; gap: 16px; }
.chart { flex: 1 1 480px; min-width: 0; padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.chart__row { display: grid; grid-template-columns: 140px minmax(0, 1fr) 96px; align-items: center; gap: 12px; }
.chart__headline { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 12px; }
.chart__headline strong { font-size: 32px; font-weight: 700; letter-spacing: -0.02em; }
.chart__headline span { font-size: 13px; color: var(--muted); }
.chart__row span:first-child { font-weight: 500; }
.chart__row span:last-child { font-weight: 600; text-align: right; }
.chart__track { height: 26px; background: var(--bg-3); border-radius: 6px; overflow: hidden; }
.chart__bar { height: 100%; border-radius: 6px; background: var(--accent); }
.chart__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.chart__body { display: flex; flex-direction: column; gap: 14px; }
.chart__foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.chart__copy { height: 36px; padding: 0 12px; font-size: 13px; color: var(--ink-2); flex-shrink: 0; }

/* ⋮ menu (reuses the filter dropdown styles) */
.chart__menu-wrap { position: relative; margin: -6px -8px 0 0; }
.chart__kebab {
  width: 40px; height: 40px; border-radius: 999px; border: none; background: transparent;
  color: var(--ink-2); cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.chart__kebab:hover, .chart__kebab[aria-expanded="true"] { background: var(--bg-3); }
.chart__menu { min-width: 200px; }
.chart__menu-title { padding: 6px 10px 4px; font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }

/* Column chart */
.cols { display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); gap: 12px; height: 220px; }
.cols__item { display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; }
.cols__value { font-weight: 600; }
.cols__track { flex: 1 1 auto; width: min(56px, 70%); background: var(--bg-3); border-radius: 6px; display: flex; align-items: flex-end; overflow: hidden; }
.cols__bar { width: 100%; background: var(--accent); border-radius: 6px; }
.cols__label { font-size: 12px; font-weight: 500; text-align: center; color: var(--ink-3); }

/* Donut chart */
.donut { display: flex; flex-wrap: wrap; align-items: center; gap: 28px; }
.donut__ring { position: relative; width: 180px; height: 180px; border-radius: 50%; flex-shrink: 0; }
.donut__ring::after { content: ''; position: absolute; inset: 28px; background: var(--surface); border-radius: 50%; }
.donut__center { position: absolute; inset: 0; z-index: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.donut__center strong { font-size: 26px; font-weight: 700; }
.donut__center strong.is-long { font-size: 18px; }
.donut__center span { font-size: 12px; color: var(--muted); }
.donut__legend { list-style: none; margin: 0; padding: 0; flex: 1 1 200px; display: flex; flex-direction: column; gap: 10px; }
.donut__legend li { display: grid; grid-template-columns: 12px minmax(0, 1fr) auto 44px; align-items: center; gap: 10px; }
.donut__legend .muted { text-align: right; }
.donut__swatch { width: 12px; height: 12px; border-radius: 3px; }

/* Table view */
.chart-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.chart-table thead th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; padding: 8px 12px; background: var(--bg-2); border-bottom: 1px solid var(--line-2); }
.chart-table tbody th { text-align: left; font-weight: 500; }
.chart-table .donut__swatch { display: inline-block; margin-right: 10px; vertical-align: -1px; }
.chart-table tbody th, .chart-table td { padding: 10px 12px; border-bottom: 1px solid var(--line-3); }
.chart-table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* Quick-actions ribbon (top of the referral split view) */
.ribbon {
  padding: 6px 4px; display: flex; flex-wrap: wrap; align-items: stretch; gap: 6px 4px;
  border: 1px solid var(--line-2); border-radius: 10px; background: var(--surface);
}
.ribbon__group { display: flex; flex-direction: column; gap: 4px; padding: 0 8px; border-right: 1px solid var(--line-2); }
.ribbon__group:last-child { border-right: none; }
.ribbon__buttons { display: flex; gap: 4px; }
.ribbon__caption { font-size: 11px; color: var(--muted); text-align: center; }
.ribbon__btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  min-width: 78px; min-height: 58px; padding: 6px 8px; border: 1px solid transparent; border-radius: 8px;
  background: var(--surface); cursor: pointer; font-size: 12px; font-weight: 500; color: var(--ink);
}
.ribbon__btn:hover:not(:disabled) { background: var(--bg-2); border-color: var(--line-2); }

/* Referrals table */
.table-card { display: flex; flex-direction: column; }
.table-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line-2); }
.table-toolbar h2 { font-size: 16px; margin-right: 8px; flex-grow: 1; }
.table-toolbar h2 span { font-weight: 500; color: var(--muted); }
.table-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.table-toolbar .input { width: 260px; max-width: 100%; }

/* Status filter dropdown */
.filter { position: relative; }
.filter__button { color: var(--ink-2); }
.filter__button.is-active { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.filter__current { font-weight: 600; }
.filter__current::before { content: '·'; margin-right: 6px; }
.filter__menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; min-width: 240px; padding: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 10px 30px rgba(10, 20, 30, 0.16); display: flex; flex-direction: column; gap: 2px;
}
.filter__item {
  display: flex; align-items: center; gap: 8px; width: 100%; min-height: 40px; padding: 0 10px;
  border: none; border-radius: 6px; background: transparent; cursor: pointer;
  font-size: 14px; color: var(--ink); text-align: left;
}
.filter__item:hover, .filter__item:focus-visible { background: var(--bg-2); }
.filter__item[aria-checked="true"] { color: var(--accent); font-weight: 600; }
.filter__check { width: 16px; display: inline-flex; flex-shrink: 0; }
.filter__label { flex-grow: 1; }
.filter__count { font-size: 12px; font-weight: 600; color: var(--muted); background: var(--bg-3); border-radius: 999px; padding: 1px 8px; }

.table-scroll { overflow-x: auto; }
/* Column tracks and min width come from the chosen columns (set inline on .table). */
.table__cols { display: grid; grid-template-columns: var(--cols); gap: 12px; align-items: center; }
.cell { min-width: 0; }
.cell-wrap { overflow-wrap: anywhere; }
.table__head { padding: 10px 16px; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; border-bottom: 1px solid var(--line-2); background: var(--bg-2); }
.table__row {
  width: 100%; text-align: left; font-size: 14px; color: var(--ink); padding: 12px 16px;
  border: none; border-bottom: 1px solid var(--line-3); cursor: pointer; background: var(--surface);
}
.table__row:hover { background: var(--bg-2); }
.table__row.is-selected { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.table__empty { padding: 24px 16px; color: var(--muted); }
.cell-stack { display: flex; flex-direction: column; gap: 2px; min-width: 0; align-items: flex-start; }
.cell-stack--gap { gap: 4px; }
.cell-strong { font-weight: 600; }
.cell-name { font-weight: 600; color: var(--accent); }
.cell-13 { font-size: 13px; }
.cell-last { font-size: 13px; color: var(--ink-3); }

/* Page frame. With a referral open (#app.is-split) the window splits in half:
   the list keeps working on the left and the referral sits beside it, each scrolling on its own. */
#app { display: flex; flex-direction: column; min-height: 100vh; }
.workspace { flex: 1 1 auto; display: flex; min-height: 0; }
.workspace > .main { flex: 1 1 0; min-width: 0; }
#app.is-split { height: 100vh; }
#app.is-split .main { max-width: none; margin: 0; overflow-y: auto; }

.split-panel {
  flex: 0 0 50%; min-width: 0; display: flex; flex-direction: column;
  background: var(--surface); border-left: 1px solid var(--line);
  box-shadow: -6px 0 18px rgba(10, 20, 30, 0.06);
}
.split-panel.is-entering { animation: panel-in 180ms ease-out; }
@keyframes panel-in { from { opacity: 0; transform: translateX(24px); } }
@media (prefers-reduced-motion: reduce) { .split-panel.is-entering { animation: none; } }

/* Too narrow to split: the referral covers the list instead. */
@media (max-width: 900px) {
  .split-panel { position: fixed; inset: 0; z-index: 30; border-left: none; }
}
.drawer__head { padding: 16px 20px; border-bottom: 1px solid var(--line-2); display: flex; flex-direction: column; gap: 10px; }
.drawer__titlerow { display: flex; align-items: flex-start; gap: 12px; }
.drawer__title { display: flex; flex-direction: column; gap: 4px; flex-grow: 1; }
.drawer__title > div { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.drawer__title h2 { font-size: 20px; letter-spacing: -0.01em; }
.drawer__title .badge--urgent { padding: 3px 9px; }
.drawer__meta { font-size: 13px; color: var(--muted); }
.drawer__body { flex-grow: 1; min-height: 0; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 20px; background: var(--bg-2); }

.panel { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.panel h3 { font-size: 15px; }
.panel__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.confidence { font-size: 12px; color: var(--ok-fg); background: var(--ok-bg); border-radius: 999px; padding: 2px 9px; font-weight: 600; }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.field { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border: 1px solid var(--line-2); border-radius: 8px; background: #FBFCFD; min-width: 0; }
.field--wide { grid-column: 1 / -1; }
.field__k { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; }

/* Fax viewer */
.fax { background: #E9ECF0; border: 1px solid var(--line); border-radius: 10px; display: flex; flex-direction: column; }
.fax__bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 10px 12px; background: var(--surface); border-bottom: 1px solid var(--line); border-radius: 10px 10px 0 0; }
.fax__name { font-weight: 600; font-size: 13px; flex-grow: 1; }
.fax__bar .btn { height: 36px; font-size: 12px; padding: 0 10px; }
.fax__bar .btn--icon { width: 40px; padding: 0; }
.fax__pageno { font-size: 13px; min-width: 78px; text-align: center; }
.fax__stage { padding: 20px; }
.fax__page {
  background: #FFFFFF; box-shadow: 0 1px 4px rgba(20, 30, 45, 0.2); padding: 28px 30px; min-height: 620px;
  font-family: var(--font-mono); font-size: 12px; line-height: 1.75; color: #2A2F36; white-space: pre-wrap;
}
.fax__header { display: flex; justify-content: space-between; border-bottom: 1px dashed #9AA3AE; padding-bottom: 6px; margin-bottom: 14px; font-size: 11px; color: #4A5260; }
.fax__title { font-size: 15px; font-weight: 500; letter-spacing: 0.06em; margin-bottom: 12px; }
.fax__gap { margin-top: 12px; }
.fax__gap-s { margin-top: 8px; }
.fax__foot { margin-top: 22px; color: #6A7280; }
.fax--hl mark { background: #FFF3B0; color: inherit; }
.fax mark { background: transparent; color: inherit; }

/* Split view tabs */
.drawer__tabs { display: flex; gap: 4px; margin-bottom: -17px; }
.drawer__tab {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px;
  border: none; border-bottom: 3px solid transparent; background: transparent; cursor: pointer;
  font-size: 14px; font-weight: 600; color: var(--ink-3);
}
.drawer__tab[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.drawer__tab-count { font-size: 12px; font-weight: 600; color: var(--muted); background: var(--bg-3); border-radius: 999px; padding: 1px 8px; }
.drawer__tab-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warn-fg); }

/* Communications tab */
.comms__contact { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.comms__contact-icon { width: 36px; height: 36px; border-radius: 50%; background: var(--info-bg); color: var(--info-fg); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.comms__contact-text { display: flex; flex-direction: column; gap: 2px; flex-grow: 1; min-width: 0; }
.comms__filters { align-self: flex-start; }

.thread { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.msg { display: flex; flex-direction: column; gap: 4px; max-width: 80%; }
.msg--out { align-self: flex-end; align-items: flex-end; }
.msg--in { align-self: flex-start; align-items: flex-start; }
.msg__bubble { padding: 10px 14px; line-height: 1.45; border-radius: 16px; overflow-wrap: anywhere; }
.msg--out .msg__bubble { background: var(--accent); color: #FFFFFF; border-bottom-right-radius: 4px; }
.msg--in .msg__bubble { background: var(--surface); border: 1px solid var(--line); color: var(--ink); border-bottom-left-radius: 4px; }
.msg__bubble--quick { font-weight: 600; }
.msg__meta { font-size: 12px; color: var(--muted); display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }

.note { align-self: center; max-width: 90%; display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center; font-size: 12px; color: var(--ink-3); }
.note__t { font-size: 11px; color: var(--muted); white-space: nowrap; }

.call { align-self: stretch; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.call__head { display: flex; align-items: center; gap: 10px; }
.call__icon { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.call__icon--ok { background: var(--ok-bg); color: var(--ok-fg); }
.call__icon--miss { background: var(--neutral-bg); color: var(--neutral-fg); }
.call__text { display: flex; flex-direction: column; gap: 2px; flex-grow: 1; min-width: 0; }
.call__toggle { align-self: flex-start; min-height: 32px; padding: 0 10px; border: 1px solid var(--control); border-radius: 8px; background: var(--surface); cursor: pointer; font-size: 12px; font-weight: 500; color: var(--ink-2); }
.call__voicemail { font-size: 13px; color: var(--ink-3); background: var(--bg-2); border-radius: 8px; padding: 10px 12px; }
.transcript { list-style: none; margin: 0; padding: 10px 12px; background: var(--bg-2); border-radius: 8px; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.transcript li { display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: 8px; }
.transcript__who { font-weight: 600; color: var(--muted); }

/* Message box under the conversation */
.composer { flex-shrink: 0; border-top: 1px solid var(--line-2); background: var(--surface); padding: 12px 20px 16px; display: flex; flex-direction: column; gap: 8px; }
.composer__input { width: 100%; resize: vertical; min-height: 64px; border: 1px solid var(--control); border-radius: 10px; padding: 10px 12px; font-size: 14px; line-height: 1.45; color: var(--ink); }
.composer__row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.composer__template { height: 36px; font-size: 13px; }
.composer__hint { flex-grow: 1; }
.composer__count { font-variant-numeric: tabular-nums; }
.composer--off { color: var(--ink-3); }

/* Modals */
.modal { position: fixed; inset: 0; background: rgba(16, 22, 30, 0.45); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 40; }
.modal__box { background: var(--surface); border-radius: 12px; width: 520px; max-width: 100%; padding: 22px; display: flex; flex-direction: column; gap: 14px; box-shadow: 0 12px 40px rgba(10, 20, 30, 0.25); }
.modal__box--wide { width: 600px; }
.modal__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.modal__head h2 { font-size: 18px; }
.modal__head > div { display: flex; flex-direction: column; gap: 2px; }
.modal__sub { font-size: 13px; color: var(--muted); }
.modal__msg { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 14px; line-height: 1.55; }
.modal__actions { display: flex; justify-content: flex-end; gap: 8px; }
.script { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; }
.script li { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border-radius: 8px; line-height: 1.5; background: var(--bg-2); border: 1px solid var(--line-2); color: var(--ink-3); }
.script li.is-done { background: var(--info-bg); border-color: #BCD3EE; color: var(--ink); }
.script__step { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
/* Customize columns */
.modal__box--cols { width: 720px; max-height: calc(100vh - 32px); overflow-y: auto; }
.modal__actions--split { justify-content: space-between; flex-wrap: wrap; }
.modal__actions--split > div { display: flex; gap: 8px; }
/* Each panel's header (and the move arrows) stays put; only the lists scroll. */
.colpick { flex: 1 1 auto; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: minmax(0, 1fr); gap: 16px; min-height: 320px; }
.colpick__panel { border: 1px solid var(--line); border-radius: 10px; background: var(--bg-2); display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.colpick__panel .colpick__list { overflow-y: auto; min-height: 0; }
.colpick__panel h3 {
  font-size: 13px; font-weight: 600; padding: 12px 14px; border-bottom: 1px solid var(--line-2);
  display: flex; align-items: center; justify-content: space-between;
}
.colpick__panel h3 span { font-size: 12px; font-weight: 600; color: var(--muted); background: var(--surface); border: 1px solid var(--line-2); border-radius: 999px; padding: 0 8px; }
.colpick__list { list-style: none; margin: 0; padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.colpick__head { display: flex; align-items: center; gap: 8px; padding-right: 8px; border-bottom: 1px solid var(--line-2); }
.colpick__head h3 { flex-grow: 1; border-bottom: none; }
.colpick__move { display: flex; gap: 2px; }
.colpick__move .colpick__icon { border-color: var(--control); background: var(--surface); }
.colpick__hint { padding: 8px 14px 0; font-size: 12px; color: var(--muted); }
.colpick__item {
  display: flex; align-items: center; gap: 6px; min-height: 44px; padding: 4px 4px 4px 12px;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: 8px;
}
.colpick__item.is-selected { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.colpick__select {
  flex-grow: 1; min-width: 0; min-height: 36px; display: flex; align-items: center; gap: 6px;
  border: none; background: transparent; padding: 0; text-align: left; cursor: pointer; font-size: 14px; color: var(--ink);
}
.colpick__item.is-selected .colpick__label { color: var(--accent); font-weight: 600; }
.colpick__pos { width: 20px; flex-shrink: 0; font-size: 12px; font-weight: 600; color: var(--muted); }
.colpick__label { flex-grow: 1; min-width: 0; font-weight: 500; }
.colpick__lock { display: block; font-size: 11px; font-weight: 500; color: var(--muted); }
.colpick__add {
  height: 36px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--control); background: var(--surface);
  color: var(--accent); font-size: 13px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 4px;
}
.colpick__add:hover { background: var(--accent-soft); border-color: var(--accent); }
.colpick__icon {
  width: 36px; height: 36px; border-radius: 8px; border: 1px solid transparent; background: transparent;
  color: var(--ink-2); cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
}
.colpick__icon:hover:not(:disabled) { background: var(--bg-2); border-color: var(--line-2); }
.colpick__icon[data-action="col-remove"] { color: var(--bad-fg); }
.colpick__icon:disabled { opacity: 0.3; cursor: not-allowed; }
.colpick__empty { padding: 16px 14px; font-size: 13px; color: var(--muted); }

.voicemail { background: #FFF8E6; border: 1px solid #F0DDA8; border-radius: 8px; padding: 10px 12px; font-size: 13px; color: #4A3A10; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #FFFFFF;
  padding: 12px 18px; border-radius: 10px; font-size: 14px; box-shadow: 0 8px 24px rgba(10, 20, 30, 0.3); z-index: 50; max-width: calc(100% - 32px);
}

@media (max-width: 640px) {
  .container { padding: 0 16px; }
  .fields { grid-template-columns: minmax(0, 1fr); }
  .colpick { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(180px, 1fr) minmax(260px, 1.4fr); min-height: 456px; }
  .msg { max-width: 92%; }
  .chart__row { grid-template-columns: 110px minmax(0, 1fr) 80px; }
}

/* Reports */
.report-criteria { padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.crit-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px 16px; }
.crit { position: relative; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.crit__label { font-size: 12px; font-weight: 600; color: var(--muted); }
.crit__button { justify-content: space-between; width: 100%; color: var(--ink-2); font-weight: 500; }
.crit__button.is-active { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.crit__value { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crit__menu { left: 0; right: auto; min-width: max(100%, 300px); max-width: min(420px, calc(100vw - 32px)); max-height: 340px; overflow-y: auto; }
.crit__item[aria-checked="true"] { color: var(--ink); font-weight: 500; }
.crit__box {
  width: 18px; height: 18px; flex-shrink: 0; border: 1.5px solid var(--control); border-radius: 4px;
  display: inline-flex; align-items: center; justify-content: center; background: var(--surface);
}
.crit__item[aria-checked="true"] .crit__box { background: var(--accent); border-color: var(--accent); }
.report-adv { display: flex; flex-direction: column; gap: 12px; padding-top: 14px; border-top: 1px solid var(--line-3); }
.report-adv__toggle {
  align-self: flex-start; display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 8px; margin-left: -8px;
  border: none; border-radius: 6px; background: transparent; cursor: pointer; font-size: 14px; font-weight: 600; color: var(--accent);
}
.report-adv__toggle:hover { background: var(--accent-soft); }
.report-criteria__actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 10px; }
.report-stale { color: var(--warn-fg); margin-right: auto; }
.report-empty { padding: 48px 24px; display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; }
.report-empty h2 { font-size: 16px; margin-top: 6px; }
.report-empty p { max-width: 460px; }
.report-results { padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.report-results__head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 12px; }
.report-results__head h2 { scroll-margin-top: 16px; }
.report-results__head h2:focus { outline: none; }
.report-results__head h2 .muted { font-weight: 500; }
.report-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.report-chip { font-size: 13px; padding: 4px 10px; border-radius: 999px; background: var(--bg-3); }
.report-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.report-stat { display: flex; flex-direction: column; gap: 4px; padding: 12px 14px; border: 1px solid var(--line-2); border-left: 4px solid var(--stat); border-radius: 8px; }
.report-stat strong { font-size: 24px; font-weight: 700; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.report-block { display: flex; flex-direction: column; gap: 10px; }
.report-block__head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.report-block__head h3 { font-size: 15px; margin-right: auto; }
.report-select { height: 36px; padding: 0 8px; }
.report-table { min-width: 720px; }
.report-table td, .report-table tbody th { vertical-align: top; }
.report-table tr.is-total th, .report-table tr.is-total td { font-weight: 700; background: var(--bg-2); }

/* Upload referrals */
.dropzone-card { padding: 16px; }
.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 28px 16px; text-align: center;
  border: 2px dashed var(--control); border-radius: 10px; background: var(--bg-2); transition: background 120ms, border-color 120ms;
}
.dropzone.is-over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone h2 { font-size: 16px; margin-top: 4px; }
.upload-check { color: var(--warn-fg); font-weight: 600; }
.upload-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.upload-step { display: flex; align-items: center; gap: 10px; color: var(--muted); }
.upload-step.is-done { color: var(--ink); }
.upload-step.is-current { color: var(--accent); font-weight: 600; }
.upload-step__mark {
  width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--control); flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
}
.upload-step.is-done .upload-step__mark { background: var(--ok-fg); border-color: var(--ok-fg); }
.upload-step.is-current .upload-step__mark { border-color: var(--accent); border-top-color: transparent; animation: spin 900ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .upload-step.is-current .upload-step__mark { animation: none; border-top-color: var(--accent); } }
.upload-note { display: flex; align-items: flex-start; gap: 8px; padding: 10px 12px; border-radius: 8px; font-size: 13px; background: var(--neutral-bg); color: var(--neutral-fg); }
.upload-note .icon { margin-top: 1px; }
.upload-note--ok { background: var(--ok-bg); color: var(--ok-fg); }
.upload-note--warn { background: var(--warn-bg); color: var(--warn-fg); }
.confidence--low { color: var(--warn-fg); background: var(--warn-bg); }
.upload-preview { width: 100%; height: 640px; border: none; border-radius: 0 0 10px 10px; background: var(--surface); }
.upload-image { display: block; max-width: 100%; margin: 0 auto; border-radius: 4px; box-shadow: 0 2px 10px rgba(10, 20, 30, 0.15); }

/* ---- Live mode ---- */
.badge--processing { background: var(--info-bg); color: var(--info-fg); }
.badge--error { background: var(--bad-bg); color: var(--bad-fg); }
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; background: var(--bg); }
.login__card { width: 100%; max-width: 400px; padding: 28px; display: flex; flex-direction: column; gap: 10px; }
.login__card .brand { margin-bottom: 12px; }
.login__card h1 { font-size: 22px; margin-bottom: 6px; }
.login__card label { font-size: 13px; font-weight: 600; color: var(--ink-2); margin-top: 6px; }
.login__card .input { width: 100%; height: 44px; }
.login__card .btn--primary { margin-top: 14px; width: 100%; }
.login__card p { color: var(--ink-3); line-height: 1.5; }
.login__error { color: var(--bad-fg) !important; font-size: 14px; }
.fax__bar a.btn { text-decoration: none; height: 36px; font-size: 12px; padding: 0 10px; }

/* ---- Live mode: editing, history, duplicates, audit report, record viewer ---- */
.badge--merged { background: var(--neutral-bg); color: var(--neutral-fg); }
.linkbtn { background: none; border: none; padding: 0; color: var(--accent); font: inherit; font-size: inherit; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.linkbtn:hover { color: var(--accent-hover); }
.nowrap { white-space: nowrap; }

.ext-head-tools { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; }
.ext-head-tools .btn { height: 36px; font-size: 13px; }
.ext-edited { margin-left: 8px; padding: 0 6px; border-radius: 999px; background: var(--info-bg); color: var(--info-fg); font-size: 10px; letter-spacing: 0.04em; cursor: help; }
.ext-input { width: 100%; height: 38px; margin-top: 4px; font-size: 14px; }
textarea.ext-input { height: auto; padding: 8px 12px; resize: vertical; line-height: 1.4; }
.field label.field__k { display: block; }

.ext-docpick button { height: 32px; font-size: 12px; }
.ext-docwait { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; min-height: 220px; color: var(--muted); padding: 24px; text-align: center; }

.ext-history .table-scroll { max-height: 420px; overflow: auto; border: 1px solid var(--line-2); border-radius: 8px; }
.ext-audit-table { font-size: 13px; }
.ext-audit-table td { vertical-align: top; }
.ext-audit-table tr.is-view td { color: var(--ink-3); }
.ext-history .linkbtn { align-self: flex-start; font-size: 13px; }

.ext-card { padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.ext-pairs { display: flex; flex-direction: column; gap: 8px; }
.ext-pair { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 12px 14px; border: 1px solid var(--line-2); border-radius: 10px; background: var(--surface); cursor: pointer; font-size: 14px; color: var(--ink); }
.ext-pair:hover { background: var(--bg-2); }
.ext-pair.is-selected { border-color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); background: var(--accent-soft); }
.ext-pair__vs { font-size: 18px; color: var(--muted); }
.ext-compare tr.is-diff td, .ext-compare tr.is-diff th { background: #FFF8E6; }
.ext-compare thead th { vertical-align: top; }
.ext-keep { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink); text-transform: none; letter-spacing: 0; cursor: pointer; }
.ext-keep input, .ext-take input { width: 16px; height: 16px; accent-color: var(--accent); }
.ext-take { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; }
.ext-docrow { display: flex; flex-wrap: wrap; gap: 8px; }
.ext-dupdoc { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #E9ECF0; }
.ext-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.ext-actions__spacer { flex-grow: 1; }
.ext-confirm { background: #8E2424; border-color: #8E2424; }

.ext-report-switch { align-self: flex-start; }
.ext-rv-scroll { max-height: 70vh; overflow: auto; }
.ext-rv-table { font-size: 12px; }
.ext-rv-table thead th { position: sticky; top: 0; z-index: 1; text-transform: none; letter-spacing: 0; }
.ext-rv-table td { white-space: nowrap; vertical-align: top; }
.ext-json { color: var(--ink-3); }

@media (max-width: 640px) {
  .ext-pair { grid-template-columns: minmax(0, 1fr); }
  .ext-pair__vs { display: none; }
}

/* Two-step sign-in */
.mfa-qr { display: block; margin: 8px auto; width: 200px; height: 200px; background: #FFFFFF; border: 1px solid var(--line); border-radius: 8px; }
.mfa-secret { font-size: 13px; color: var(--muted); }
.mfa-secret code { display: block; margin-top: 6px; word-break: break-all; font-family: var(--font-mono); color: var(--ink); }
.login__card .linkbtn { background: none; border: none; color: var(--accent); font-weight: 600; cursor: pointer; padding: 8px 0; }
