/* ── CRM Ribbon ── */

.crm-ribbon {
  background: var(--bg-warm);
  border-bottom: 1px solid var(--border);
  padding: 6px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  /* A single clean row at every width. Instead of wrapping to a ragged second
     row, commands that don't fit peel off into the "⋯ More" flyout (see
     layoutRibbon in crm-table.js). The command bar (.ribbon-cmd-bar) shrinks
     and clips; nothing forces the page shell wider, so the only horizontal
     scroll left is the columns scroll inside .crm-table-wrap. */
  flex-wrap: nowrap;
  flex-shrink: 0;   /* never collapse vertically in the flex-column CRM layout */
  position: sticky;
  top: 0;
  z-index: 40;
  /* overflow must be visible so dropdowns can escape */
  overflow: visible;
  min-width: 0;
}

/* The measured, clipping command region. Groups that overflow are moved out of
   it by JS, so clipping never hides a half-command mid-render. */
.ribbon-cmd-bar {
  display: flex;
  align-items: center;
  /* Grow to fill so the overflow "⋯" and the search pin to the right; shrink +
     clip when content can't fit (that's what layoutRibbon measures). Grow works
     only because the search-wrap has no auto margin — an auto margin would
     swallow the free space and starve the grow. */
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
}

.ribbon-group {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

/* An author `display` beats the UA [hidden] rule, so hiding an emptied group
   (all its commands overflowed) needs an explicit rule. */
.ribbon-group[hidden] { display: none; }

/* Thin vertical divider between adjacent command groups (Fluent grouping).
   The bar only ever holds a left-contiguous prefix of groups, so a "+"
   divider never strands at the start. */
.ribbon-cmd-bar .ribbon-group + .ribbon-group {
  margin-left: 4px;
  padding-left: 6px;
  border-left: 1px solid var(--border);
}

/* Overflow flyout: the re-parented commands stack vertically as a menu, in
   priority order, reusing the .ribbon-dropdown panel chrome. Individual
   commands overflow (not whole groups), so this is a flat list. */
.ribbon-overflow-menu { padding: 4px; }

.ribbon-overflow-menu .ribbon-btn-wrap { display: block; }

.ribbon-overflow-menu > * + * { margin-top: 1px; }

.ribbon-overflow-menu .btn-ribbon {
  width: 100%;
  justify-content: flex-start;
  border-radius: 4px;
}

/* In the vertical flyout the trailing caret pushes to the far right. */
.ribbon-overflow-menu .ribbon-cmd-caret { margin-left: auto; }

.crm-search-wrap {
  /* No auto margin — the command bar grows to push this to the right instead
     (see .ribbon-cmd-bar). */
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0 10px;
}

.crm-search-wrap:focus-within {
  outline: 2px solid var(--gold);
  outline-offset: 1px;
}

.crm-search-icon {
  color: var(--text-dim);
  pointer-events: none;
  flex-shrink: 0;
  line-height: 0;
  display: inline-flex;
}

.crm-search-icon .ribbon-cmd-ico {
  width: 14px;
  height: 14px;
}

.crm-search {
  /* Shrink (don't disappear) as the ribbon tightens. */
  width: clamp(90px, 22vw, 160px);
  min-width: 0;
  padding: 5px 0;
  font-size: 12px;
  /* The wrapper (.crm-search-wrap) is the visible search control; the input
     itself must never draw its own box, or it reads as a bar-inside-a-bar. */
  border: none;
  background: transparent;
  box-shadow: none;
  -webkit-appearance: none;
  appearance: none;
  outline: none;
  color: inherit;
}

/* ── Ribbon dropdown panels — use position:fixed, JS positions them ── */

.ribbon-btn-wrap {
  position: relative;
  flex-shrink: 0;
}

.ribbon-overflow-wrap[hidden] { display: none; }

.ribbon-dropdown {
  position: fixed;           /* escape any overflow context */
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(var(--shadow-rgb),0.12);
  padding: 6px 0;
  min-width: 190px;
  z-index: 9999;
  display: none;
  max-height: 320px;
  overflow-y: auto;
}

.ribbon-dropdown.open { display: block; }

.ribbon-dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  transition: background var(--speed);
  white-space: nowrap;
}

.ribbon-dropdown-item:hover { background: var(--gold-soft); color: var(--text); }

.ribbon-dropdown-item input[type="checkbox"] {
  width: 14px;
  height: 14px;
  accent-color: var(--gold);
  flex-shrink: 0;
  cursor: pointer;
}

/* Product-line dropdown — single-select checkmark column. Fixed width so
   the labels stay aligned across checked / unchecked rows. */
.product-line-check {
  display: inline-block;
  width: 14px;
  font-weight: 600;
  color: var(--gold);
  flex-shrink: 0;
  text-align: center;
}

/* Lead Order + Filter Date dropdowns reuse the same single-select checkmark
   column so their labels line up with the Product Line list. */
.lead-order-check,
.date-preset-check {
  display: inline-block;
  width: 14px;
  font-weight: 600;
  color: var(--gold);
  flex-shrink: 0;
  text-align: center;
}

/* Custom From/To range at the foot of the Filter Date dropdown. Revealed only
   when the "Custom Range…" preset is picked — see renderDateFilterOptions in
   src/js/components/crm-table.js. */
.ribbon-date-custom {
  border-top: 1px solid var(--border);
  margin-top: 6px;
  padding: 10px 14px 6px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ribbon-date-custom.hidden { display: none; }

.ribbon-date-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  color: var(--text-muted);
}

.ribbon-date-row input[type="date"] {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 12px;
  font-family: var(--font-body);
  color: var(--text);
}

.ribbon-date-row input[type="date"]:focus {
  outline: none;
  border-color: var(--gold);
}

.ribbon-date-clear {
  align-self: flex-start;
  background: none;
  border: none;
  padding: 2px 0;
  font-family: var(--font-body);
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.ribbon-date-clear:hover { color: var(--gold); }

/* ── Status / selection bar ──
   Always in the layout, below the table and outside .crm-table-wrap, so it
   doesn't scroll away from the selection it describes and — critically — so no
   click ever resizes the table under the pointer (see the markup comment in
   crm-table.js). Idle it reads "N records"; with rows selected it lights up and
   reads the selection. syncSelectionBar swaps .has-selection.

   14px, above the ribbon's 11-13px: this is a status message someone reads
   mid-task, and the small-type dominance elsewhere is a known legibility
   problem rather than a house style to extend. --gold is the app-wide PRIMARY
   ACTION color, remapped per theme (indigo on Arsenal, navy on Win2000), not
   literally gold — so this needs no per-theme override. */
.crm-selection-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  padding: 8px 14px;
  font-size: 14px;
  color: var(--text-muted);
  background: var(--bg-warm);
  border-top: 1px solid var(--border);
  transition: background var(--speed), color var(--speed);
}

.crm-selection-bar.has-selection {
  color: var(--text);
  background: var(--gold-soft);
}

/* Idle the count is just ambient context; selected, it's the message. */
.crm-selection-count { font-weight: 500; }
.crm-selection-bar.has-selection .crm-selection-count { font-weight: 600; }

/* Not a new button class — a plain text action, styled like .ribbon-date-clear
   above so the two read as the same kind of affordance. */
.crm-selection-clear {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.crm-selection-clear:hover { color: var(--gold); }
.crm-selection-clear:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
  border-radius: var(--radius-control);
}

/* ── Table ── */

.crm-table-wrap {
  flex: 1;        /* fills remaining height below ribbon */
  overflow: auto; /* both axes — table-wrap is now the scroll container */
  min-height: 0;  /* prevents flex blowout */
}

.crm-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  table-layout: fixed;
}

.crm-table thead {
  position: sticky;
  top: 0;   /* sticks at top of .crm-table-wrap, which is now the scroll container */
  z-index: 30;
}

.crm-table th {
  background: var(--bg-warm);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-light);
  white-space: nowrap;
  text-align: left;
  user-select: none;
  position: relative;
}

.crm-table th.sortable { cursor: pointer; }
.crm-table th.sortable:hover { color: var(--gold); }

.sort-indicator {
  margin-left: 4px;
  font-size: 10px;
  color: var(--gold);
}

/* Resize handle */
.col-resize-handle {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 5px;
  cursor: col-resize;
  z-index: 1;
}

.col-resize-handle:hover,
.col-resize-handle.resizing {
  background: var(--gold);
  opacity: 0.4;
}

/* Drag-reorder ghost */
.crm-table th.col-dragging { opacity: 0.4; }
.crm-table th.col-drag-over { border-left: 2px solid var(--gold); }

/* Checkbox column */
.crm-table th.col-check,
.crm-table td.col-check {
  width: 36px;
  min-width: 36px;
  max-width: 36px;
  padding: 0 8px;
  text-align: center;
}

.crm-table th.col-check input,
.crm-table td.col-check input {
  width: 14px;
  height: 14px;
  accent-color: var(--gold);
  cursor: pointer;
}

.crm-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-light);
  white-space: nowrap;
  color: var(--text);
  background: var(--surface);   /* all rows white */
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Row hover and selected. The empty-state row is not a record — it is a message
   with buttons in it — so it must not light up like something you can select.
   The "Show more" row is the same kind of thing: a control, not a record. */
.crm-table tbody tr:not(.crm-empty-row):not(.crm-more-row):hover td { background: var(--gold-soft); }

/* Paging control at the foot of the rows. The table renders at most
   ROW_RENDER_CAP records at a time (crm-table.js) — this row is how the rest
   are reached, and how the count stays honest about what is being shown. */
.crm-more-row td {
  padding: 12px;
  text-align: center;
  background: var(--surface);
}
.crm-more-count {
  margin-left: 10px;
  color: var(--text-muted);
  font-size: 12px;
}

.crm-table tbody tr.selected td {
  background: var(--gold-soft);
}

.crm-table tbody tr.selected td.col-check {
  border-left: 3px solid var(--gold);
  padding-left: 5px;
}

/* Kanban-click highlight */
.crm-table tbody tr.highlighted td {
  background: rgba(181,137,58,0.18);
}

/* Inline editing */
.crm-table td.cell-editing {
  padding: 4px 6px;
}

.crm-table td.cell-editing input,
.crm-table td.cell-editing select {
  padding: 4px 6px;
  font-size: 13px;
  width: 100%;
  min-width: 70px;
}

/* Multi-select income cell */
.income-display {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.income-multiselect-dd {
  position: fixed;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(var(--shadow-rgb),0.10);
  padding: 6px 0;
  min-width: 180px;
  z-index: 9999;
  display: none;
}

.income-multiselect-dd.open { display: block; }

.income-opt {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-muted);
  transition: background var(--speed);
}

.income-opt:hover { background: var(--gold-soft); }

.income-opt input[type="checkbox"] {
  width: 14px;
  height: 14px;
  accent-color: var(--gold);
}

/* ── Client Detail Panel ── */
/*
 * #lead-panel rides on every rule here on purpose. A lead panel and a client
 * panel are the same object at two points in one lifecycle, and an agent should
 * not have to learn a second panel because the row happens to live in a
 * different table. Sharing the selectors also means the win2000 overrides and
 * the split-pane anchoring keep working with no second copy to maintain.
 *
 * They are separate ELEMENTS rather than one shared node, because #client-panel
 * is a singleton guarded by activePanelCleanup; a second consumer of that node
 * would have to participate in its teardown or leak listeners on every open.
 */

#client-panel,
#lead-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 440px;
  max-width: 100vw;
  height: 100vh;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: -8px 0 32px rgba(var(--shadow-rgb),0.14);
  transform: translateX(100%);
  /* Hidden when closed. Needed because the panel can be anchored to a split
     divider (not the viewport edge), so sliding it off by its own width no
     longer guarantees it lands off-screen — visibility hides it after the
     slide-out completes, and reveals it instantly on open. */
  visibility: hidden;
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1), visibility 0s linear 0.3s;
  z-index: 850;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#client-panel.open,
#lead-panel.open {
  transform: translateX(0);
  visibility: visible;
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1), visibility 0s linear 0s;
}

#cp-backdrop,
#lp-backdrop {
  position: fixed;
  inset: 0;
  z-index: 849;
  display: none;
  background: transparent;
  /* Non-modal panel: the backdrop must not intercept wheel/click events, so
     the rest of the page stays scrollable and interactive while the panel is
     open. Outside-click-to-close is handled by a document listener in JS. */
  pointer-events: none;
}

#cp-backdrop.open,
#lp-backdrop.open { display: block; }

.cp-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 20px 20px 14px;
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
  gap: 12px;
}

.cp-client-name {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
}

.cp-status-wrap { margin-top: 6px; }

.cp-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.cp-delete-btn:hover {
  color: var(--red);
  border-color: var(--red);
}

.cp-close-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: none;
  border: none;
  font-size: 20px;
  color: var(--text-dim);
  cursor: pointer;
  line-height: 1;
  transition: color var(--speed), background var(--speed);
}

.cp-close-btn:hover {
  color: var(--red);
  background: var(--bg);
}

.cp-body {
  flex: 1;
  /* min-height:0 lets this flex child shrink below its content height so
     overflow-y actually engages. Without it, a flex item defaults to
     min-height:auto and refuses to shrink — the content overflows the fixed
     100vh panel (clipped by overflow:hidden) and can't scroll. Most visible
     on short viewports / split screen, where the content exceeds the space. */
  min-height: 0;
  overflow-y: auto;
  padding: 16px 20px 24px;
}

.cp-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px 20px;
  border-top: 1px solid var(--border-light);
  background: var(--surface);
  flex-shrink: 0;
}

/* The do-not-call refusal/warning (see crm-table.js's save handler). Ordered
   first and forced to its own full-width line so it reads above Cancel/Save
   rather than squeezed between them -- reuses .lp-edit-message's red/amber
   tones from the dial tracker so a refusal and a warning read the same
   regardless of which panel triggers them. */
.cp-footer .lp-edit-message {
  order: -1;
  flex: 1 1 100%;
}

.cp-section {
  margin-bottom: 16px;
  border: 1px solid var(--border-light);
  border-radius: 6px;
  padding: 12px 14px;
}

.cp-section-title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 2px;
  cursor: pointer;
  user-select: none;
}

/* Collapse chevron — sits just left of each category title. Points down when
   the section is open, right when collapsed. */
.cp-section-title::before {
  content: '';
  display: inline-block;
  width: 0;
  height: 0;
  margin-right: 8px;
  vertical-align: middle;
  border-left: 5px solid currentColor;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  transform: rotate(90deg);
  transition: transform 0.18s ease;
  opacity: 0.5;
}

.cp-section.collapsed .cp-section-title::before {
  transform: rotate(0deg);
}

/* Collapsed: hide everything in the section except its (clickable) title, and
   tighten the title so it reads as a single bar. */
.cp-section.collapsed > :not(.cp-section-title) {
  display: none;
}

.cp-section.collapsed .cp-section-title {
  padding-bottom: 0;
  border-bottom: none;
  margin-bottom: 0;
}

.cp-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 0;
  border-bottom: 1px solid var(--border-light);
  gap: 16px;
}

.cp-field:last-child { border-bottom: none; }

.cp-field-block {
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

.cp-field-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-family: var(--font-body);
  flex-shrink: 0;
  min-width: 120px;
}

.cp-field-value {
  font-size: 13px;
  color: var(--text);
  font-family: var(--font-body);
  text-align: right;
  word-break: break-word;
}

/* Category sub-heading inside the custom-fields "Additional Information" section. */
.cp-subsection-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-dim);
  font-family: var(--font-body);
  padding: 12px 0 4px;
}
.cp-subsection-label:first-child { padding-top: 4px; }

/* Orphaned cross-line fields — preserved values from another product line. */
.cp-orphan-section { border-style: dashed; }
.cp-orphan-star { color: var(--gold, #a87033); font-weight: 700; }
.cp-orphan-legend {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-body);
  padding-top: 10px;
  margin-top: 4px;
  border-top: 1px solid var(--border-light);
  line-height: 1.5;
}

/* Label pill next to the primary phone number in the panel. */
.cp-phone-pill {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.03em;
  padding: 1px 7px;
  margin-left: 6px;
  border-radius: 999px;
  background: var(--gold-soft, rgba(181,137,58,0.16));
  color: var(--gold, #a87033);
  vertical-align: middle;
}

/* Block fields (notes, address) read left-to-right, not right-aligned. */
.cp-field-block .cp-field-value { text-align: left; }

/* Other numbers listed directly under the Personal Notes field. */
.cp-assoc-lines {
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: left;
  width: 100%;
  margin: 4px 0 2px;
}
.cp-assoc-line {
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--font-body);
}

.cp-field input,
.cp-field select {
  font-size: 13px;
  padding: 5px 8px;
  text-align: right;
  flex: 1;
  min-width: 0;
  max-width: 220px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-body);
  outline: none;
}

/* Selects with options should be left-aligned */
.cp-field select,
.cp-field select option,
.cp-select-left { text-align: left; }

.cp-field input:focus,
.cp-field select:focus { outline: 2px solid var(--gold); outline-offset: 1px; }

.cp-field textarea {
  font-size: 13px;
  padding: 6px 8px;
  width: 100%;
  resize: vertical;
  min-height: 56px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-body);
  outline: none;
}

.cp-field textarea:focus { outline: 2px solid var(--gold); outline-offset: 1px; }

/* Income checkboxes in panel */
.cp-income-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 6px 0;
}

.cp-check-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  font-family: var(--font-body);
}

.cp-check-item input[type="checkbox"] {
  width: 14px;
  height: 14px;
  accent-color: var(--gold);
  cursor: pointer;
  flex-shrink: 0;
}

/* File section */
.cp-file-item {
  font-size: 13px;
  color: var(--text-muted);
  padding: 4px 0;
  font-family: var(--font-body);
}

.cp-file-add {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 8px;
  padding: 6px 12px;
  border: 1px dashed var(--border);
  border-radius: 6px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  font-family: var(--font-body);
  transition: border-color var(--speed), color var(--speed);
}

.cp-file-add:hover { border-color: var(--gold); color: var(--gold); }

/* Real attachment chip: filename opens a presigned URL; × deletes (edit mode). */
.cp-att {
  display: flex;
  align-items: center;
  gap: 8px;
}
.cp-att-name {
  color: var(--text-muted);
  text-decoration: none;
  cursor: pointer;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cp-att-name:hover { color: var(--gold); text-decoration: underline; }
.cp-att-del {
  border: none;
  background: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 0 4px;
}
.cp-att-del:hover { color: #e5484d; }

/* Uploading + legacy states. */
.cp-att-uploading { color: var(--text-dim); font-style: italic; }
.cp-att-hint { font-size: 12px; color: var(--text-dim); }
.cp-att-legacy { color: var(--text-dim); opacity: 0.6; cursor: default; }

/* Derived per-condition timing + meds, at the top of the Medical Details block.
   Generated rather than typed, so it reads as structured data and is set off
   from the free text (and the edit-mode textarea) beneath it. */
.cp-hx-summary {
  display: block;
  width: 100%;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text);
  padding-bottom: 6px;
  margin-bottom: 6px;
  border-bottom: 1px dashed var(--border);
}
.cp-hx-summary:last-child {
  padding-bottom: 0;
  margin-bottom: 0;
  border-bottom: none;
}

/* Pre-checklist free-text conditions, folded into the Medical Details value.
   Set apart from the agent's current notes without reading as a separate
   field — it's the same medical narrative, just captured by the older form. */
.cp-hx-legacy {
  display: block;
  margin-top: 6px;
  padding-left: 8px;
  border-left: 2px solid var(--border);
}
.cp-hx-legacy-tag {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  margin-bottom: 2px;
}

/* ── Quotes-from-call section ────────────────────────────── */


.cp-quotes-empty {
  padding: 14px 0 4px;
  font-size: 13px;
  color: var(--text-dim);
  font-style: italic;
}

.cp-quotes-selected {
  margin-top: 12px;
  padding: 12px 14px;
  border: 1px solid var(--gold);
  background: var(--gold-soft, rgba(181, 137, 58, 0.06));
  border-radius: 6px;
}

.cp-quotes-selected-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.cp-quotes-selected-tag {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 2px 7px;
  border-radius: 3px;
  background: var(--gold);
  color: white;
}

.cp-quotes-carrier {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
}

.cp-quotes-approval {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 8px;
  border-radius: 3px;
  background: var(--surface);
  color: var(--text-muted);
  border: 1px solid var(--border-light);
}

.cp-quotes-selected-body {
  display: flex;
  gap: 22px;
  flex-wrap: wrap;
}

.cp-quotes-selected-body > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cp-quotes-k {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.cp-quotes-v {
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.cp-quotes-toggler {
  margin-top: 12px;
  background: transparent;
  border: none;
  padding: 6px 0;
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.cp-quotes-toggler:hover { color: var(--gold); }

.cp-quotes-others {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cp-quotes-other {
  padding: 10px 12px;
  border: 1px solid var(--border-light);
  border-radius: 5px;
  background: var(--surface);
}

.cp-quotes-other-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.cp-quotes-other-head .cp-quotes-carrier {
  font-size: 14px;
}

.cp-quotes-other-row {
  display: flex;
  gap: 18px;
  font-size: 13px;
  padding: 3px 0;
  color: var(--text);
}

.cp-quotes-other-empty {
  font-size: 12px;
  color: var(--text-dim);
  font-style: italic;
}

/* An IUL lead that closed as a whole life policy. The record keeps
   productLine 'IUL' so lead spend stays attributed to the IUL order — this
   badge is what explains the WL carrier/product sitting on an IUL row.
   See pivotBadge() in src/js/components/crm-table.js. */
.cp-pivot-badge {
  margin-left: 8px;
  display: inline-block;
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 8px;
  border-radius: 3px;
  background: var(--surface);
  color: var(--text-muted);
  border: 1px solid var(--border-light);
  vertical-align: middle;
}

/* Product name on an IUL illustration card, next to the carrier. */
.cp-quotes-product {
  font-family: var(--font-body);
  font-size: 12px;
  color: var(--text-muted);
}

/* The illustration cards reuse .cp-quotes-selected-head for both the selected
   and the non-selected variants, so give the non-selected one the same spacing
   the quotes matrix gets from .cp-quotes-other-head. */
.cp-quotes-other > .cp-quotes-selected-head { margin-bottom: 6px; }

/* ══ CRM on small screens ═════════════════════════════════════════════════════
   A 19-column table cannot be made to fit a phone by shrinking it — at that
   width every column is a few characters wide and the row is unreadable. So
   below 720px the table stops being a table and becomes a list of cards: the
   header row is dropped, each row is a card, and each cell names its own column
   from the data-label the renderer stamps on it (crm-table.js#renderRows).

   Only the columns that identify a client and its money are shown. The rest are
   still in the DOM, still exported, and still there the moment the viewport is
   wide enough — this hides them, it does not drop them. Tapping a card opens
   the detail panel, which is where the full record has always lived. */

@media (max-width: 720px) {
  /* Cards size themselves, so the fixed column widths and the sideways scroll
     they forced both go. */
  .crm-table {
    display: block;
    table-layout: auto;
    min-width: 0;
  }

  .crm-table thead { display: none; }

  .crm-table tbody { display: block; }

  .crm-table tbody tr {
    position: relative;
    display: block;
    margin: 0 0 8px;
    padding: 10px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-control);
  }

  /* The row background is on the <tr> now, not the cells, so the desktop
     hover/selected rules (which paint td) need a card-level equivalent. */
  .crm-table tbody tr:not(.crm-empty-row):not(.crm-more-row):hover td,
  .crm-table tbody tr.selected td { background: transparent; }
  .crm-table tbody tr.selected {
    border-color: var(--gold);
    background: var(--gold-soft);
  }

  .crm-table tbody td {
    display: none;          /* opt in per column, below */
    width: auto !important; /* beats the inline widths the resizer writes */
    border: 0;
    padding: 2px 0;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
  }

  /* The columns worth carrying on a phone: who it is, where it stands, with
     whom, and for how much. */
  .crm-table tbody td[data-key="name"],
  .crm-table tbody td[data-key="status"],
  .crm-table tbody td[data-key="carrier"],
  .crm-table tbody td[data-key="monthlyPremium"] {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
  }

  .crm-table tbody td::before {
    content: attr(data-label);
    flex: none;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
  }

  /* The name leads the card as a heading, so it drops its label and outweighs
     the rows under it. */
  .crm-table tbody td[data-key="name"] {
    margin-bottom: 4px;
    font-size: 15px;
    font-weight: 600;
  }
  .crm-table tbody td[data-key="name"]::before { content: none; }

  /* Selection checkbox sits in the card's top-right rather than owning a
     column of its own. */
  .crm-table tbody td.col-check {
    display: block;
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 0;
  }
  .crm-table tbody td.col-check::before { content: none; }

  /* Column resizing is a pointer-precision gesture with no meaning here. */
  .col-resize-handle { display: none; }

  /* The empty state is a message, not a card. */
  .crm-table tbody tr.crm-empty-row {
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
  }
  .crm-table tbody tr.crm-empty-row td { display: block; }
  .crm-table tbody tr.crm-empty-row td::before { content: none; }

  /* Same reasoning for the paging control: a card layout would give it a
     data-label pseudo-element and a record's border. */
  .crm-table tbody tr.crm-more-row {
    margin: 0;
    border: 0;
    background: none;
  }
  .crm-table tbody tr.crm-more-row td { display: block; }
  .crm-table tbody tr.crm-more-row td::before { content: none; }

  .crm-table-wrap {
    overflow-x: hidden;   /* nothing left that needs to scroll sideways */
    padding: 8px;
  }

  /* Full-bleed detail panel — 440px on a 390px screen was already clamped by
     max-width, but the rounded shadow edge wasted space that the record needs. */
  #client-panel,
  #lead-panel {
    width: 100%;
    border-left: 0;
  }
}

/* ── Consolidated Filter dropdown ──────────────────────────────────────────
   One button, two levels: a list of filtering methods, then the options for
   whichever method was picked. Both levels live inside the same .ribbon-dropdown
   panel and swap via [hidden], so the panel keeps its position, its scroll
   container and its max-height across the transition. See wireFilterMenu() in
   src/js/components/crm-table.js. */
.ribbon-filter-dd { min-width: 230px; }

.ribbon-filter-panel[hidden],
.ribbon-filter-root[hidden] { display: none; }

/* A method row: label on the left, its current value on the right, caret last.
   The current value is what makes one button as readable as the five it
   replaced — every active filter is visible without opening anything. */
.ribbon-filter-method .ribbon-filter-method-label { flex: 1; }

.ribbon-filter-method-current {
  font-size: 12px;
  color: var(--text-muted);
  opacity: 0.8;
  max-width: 96px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ribbon-filter-method:hover .ribbon-filter-method-current { opacity: 1; }

/* Chevron points right (into the panel) on a method row, left (back out) on the
   panel header — one glyph, rotated, so both directions stay visually identical. */
.ribbon-filter-method-caret {
  transform: rotate(-90deg);
  flex-shrink: 0;
  opacity: 0.55;
}

.ribbon-filter-back-caret {
  transform: rotate(90deg);
  flex-shrink: 0;
}

.ribbon-filter-back {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text);
  cursor: pointer;
  user-select: none;
}

.ribbon-filter-back:hover { background: var(--gold-soft); }

/* ── Card fields in the client panel ─────────────────────────────────────────
   The card number and CVV are collected but never stored (see
   src/js/utils/card-fields.js). The ⓘ carries that explanation, because a
   field that silently discards what you typed is otherwise indistinguishable
   from a bug. Styled quiet rather than as a warning: nothing has gone wrong,
   the agent just needs the option of finding out why the box is empty. */
.cp-card-info {
  flex: 0 0 auto;
  width: 16px; height: 16px;
  margin-left: 6px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: none;
  color: var(--text-dim);
  font-family: var(--font-body);
  font-size: 10px; font-weight: 700; font-style: italic;
  line-height: 1;
  cursor: help;
  transition: color var(--speed), border-color var(--speed);
}
.cp-card-info:hover,
.cp-card-info[aria-expanded="true"] {
  color: var(--text);
  border-color: var(--text-dim);
}
.cp-card-info:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 1px;
}

.cp-card-note {
  padding: 8px 10px;
  margin: 0 0 6px;
  border-left: 2px solid var(--border);
  background: var(--bg-warm);
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.5;
}

/* "Visa - 1111" and "Not stored" are values, not placeholders — but neither is
   data the agent entered, so they read one step back from a typed field. */
.cp-card-value { color: var(--text-dim); }
.cp-card-never { font-style: italic; }
