/* Sales view. Owned by the CRM agent.
 *
 * Composes kit.css; adds only what the kit has no shape for: the two-pane queue,
 * the ranked row, the quote and the dossier. Every colour is a token; every
 * spacing is on the --s scale. Prefix is crm- throughout so nothing here can
 * collide with the analytics view.
 *
 * The drawer, the dialog, kbd, the checkbox label and the sortable header all
 * started here and were promoted to the kit once the other view wanted them
 * too - so they are deliberately absent below.
 */

.crm { display: flex; flex-direction: column; gap: var(--s4); }

/* ------------------------------------------------------------ header/bar */

.crm-head { display: flex; align-items: center; gap: var(--s4); flex-wrap: wrap; }
.crm-hint { display: inline-flex; align-items: center; gap: var(--s1); white-space: pre; }

.crm-bar {
  display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap;
  padding: var(--s3) var(--s4); border: 1px solid var(--line); border-radius: var(--r-lg);
  background: var(--surface-1);
}
.crm-bar .crm-search { flex: 1 1 260px; min-width: 200px; }
.crm-bar .field { flex: 0 0 auto; }
.crm-bar .field > select { flex: 0 0 auto; max-width: 220px; }
.crm-shown { white-space: nowrap; }

/* --------------------------------------------------------------- two-pane */

.crm-two { display: grid; grid-template-columns: minmax(320px, 420px) minmax(0, 1fr); gap: var(--s4); align-items: start; }
.crm-list {
  /* Below the sticky chrome, not below a guess at it. */
  position: sticky; top: calc(var(--chrome-h) + var(--s4));
  max-height: calc(100vh - var(--chrome-h) - var(--s6)); overflow: auto;
}
.crm-back { display: none; align-self: flex-start; }
.crm-detail { min-width: 0; display: flex; flex-direction: column; gap: var(--s4); }
.crm-fold {
  padding: var(--s2) var(--s3); font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .07em; color: var(--ink-3); background: var(--surface-1);
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
}

/* A ranked row: the score on the left, everything else stacked on the right. */
.crm-row {
  display: grid; grid-template-columns: 56px minmax(0, 1fr); gap: var(--s3);
  padding: var(--s3) var(--s4); border-bottom: 1px solid var(--line); cursor: pointer;
  transition: background .12s;
}
.crm-row:last-child { border-bottom: none; }
.crm-row:hover { background: var(--surface-1); }
.crm-row[aria-selected="true"] { background: var(--accent-weak); box-shadow: inset 3px 0 0 var(--accent); }
.crm-row-main { display: flex; flex-direction: column; gap: var(--s1); min-width: 0; }
.crm-row-title { font-weight: 600; font-size: 14px; }
.crm-row-who { font-size: 12.5px; color: var(--ink-2); }
.crm-row-who .truncate { min-width: 0; }
.crm-row-trigger {
  font-size: 12.5px; color: var(--ink-2); line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.crm-clamp {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  max-width: 48ch;
}
.crm-flags { display: flex; align-items: center; gap: var(--s1); flex-wrap: wrap; }

.crm-score { text-align: right; font-weight: 600; font-size: 20px; line-height: 1.1;
             font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.crm-score .note { font-weight: 400; margin-top: 2px; }
.crm-score.hot { color: var(--accent); }
.crm-score.warm { color: var(--ink-1); }
.crm-score.cool, .crm-score.none { color: var(--ink-3); }
.crm-score.big { font-size: 34px; }
.crm-score-sm { font-size: 12px; color: var(--ink-3); font-weight: 600; flex: 0 0 34px; }

/* ---------------------------------------------------------------- dossier */

.crm-dossier { display: flex; flex-direction: column; gap: var(--s4); min-width: 0; }
.crm-dossier-head { display: flex; align-items: flex-start; gap: var(--s4); flex-wrap: wrap; }
.crm-dossier-title { display: flex; flex-direction: column; gap: var(--s2); flex: 1 1 320px; min-width: 0; }
.crm-score-box { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; text-align: right; flex: 0 0 auto; }
.crm-score-box .note.warn { max-width: 28ch; }

.crm-section { display: flex; flex-direction: column; gap: var(--s3); }
.crm-prose { margin: 0; font-size: 13.5px; line-height: 1.6; color: var(--ink-1); white-space: pre-line; }
.crm-prose.small { font-size: 13px; color: var(--ink-2); }
.crm-trigger { display: flex; flex-direction: column; gap: var(--s1); padding-top: var(--s3); border-top: 1px solid var(--line); }
.crm-insight { border-left: 3px solid var(--accent); padding-left: var(--s3); margin: 0; color: var(--ink-2); }
.crm-people-head { margin-top: var(--s2); }

/* The person card. */
.crm-person { display: flex; flex-direction: column; gap: var(--s3); }
.crm-person.is-lead { border-color: var(--accent); }
.crm-person.is-dnc { border-color: var(--critical); }
.crm-person-head { display: flex; align-items: flex-start; gap: var(--s3); }
.crm-person-head > div:first-child { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.crm-contact { display: flex; align-items: baseline; gap: var(--s3); flex-wrap: wrap; font-size: 13px; color: var(--ink-2); }
.crm-contact a { color: var(--accent); }
.crm-dnc {
  padding: var(--s2) var(--s3); border-radius: var(--r-md); font-weight: 600; font-size: 13px;
  color: var(--critical); background: color-mix(in srgb, var(--critical) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--critical) 40%, transparent);
}

/* Their own words. This is the field that makes the cold email warm, so it gets the room. */
.crm-words { display: flex; flex-direction: column; gap: var(--s2); }
.crm-quote {
  margin: 0; padding: var(--s3) var(--s4); font-size: 14px; line-height: 1.6; color: var(--ink-1);
  background: var(--surface-1); border-left: 3px solid var(--accent); border-radius: 0 var(--r-md) var(--r-md) 0;
}
.crm-answer { margin: 0; font-size: 13px; color: var(--ink-2); padding-left: var(--s4); }

.crm-opener { min-height: 84px; line-height: 1.55; font-size: 13.5px; }
.crm-actions { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.crm-actions.end { justify-content: flex-end; margin-top: var(--s2); }
.crm-touchline { padding-top: var(--s2); border-top: 1px solid var(--line); }
.crm-more > summary { cursor: pointer; list-style: none; }
.crm-more > summary::before { content: '+ '; color: var(--ink-3); }
.crm-more[open] > summary::before { content: '- '; }
.crm-more > summary::-webkit-details-marker { display: none; }
.crm-more > .crm-form { margin-top: var(--s3); }

/* Editors and forms. */
.crm-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--s3); }
.crm-form .wide { grid-column: 1 / -1; }
.crm-edit > .row > label { font-size: 12px; color: var(--ink-3); }
.crm-edit > .row { width: 100%; }
.crm-edit textarea, .crm-edit input, .crm-edit select { width: 100%; }
.crm-kv { display: grid; grid-template-columns: max-content 1fr; gap: var(--s2) var(--s4); align-items: baseline; font-size: 13.5px; }

/* Thread rows inside a dossier. */
.crm-threadlist { display: flex; flex-direction: column; }
.crm-threadrow {
  display: flex; align-items: center; gap: var(--s3); width: 100%; text-align: left;
  border: none; border-radius: var(--r-md); padding: var(--s2) var(--s2); background: transparent;
}
.crm-threadrow-main { display: flex; flex-direction: column; min-width: 0; gap: 1px; }
.crm-threadrow:hover { background: var(--surface-1); }

/* ----------------------------------------------------------------- tables */

/* Twelve columns of facts. The kit's --s3 gutter spends 288px on padding
 * alone here, which pushed two whole columns off the right edge of the card
 * with nothing to say they were there. Tighter gutters, and the columns that
 * hold prose are capped rather than left to size themselves from content. */
.crm-table thead th, .crm-table tbody td { padding-inline: var(--s2); }
.crm-table tbody td { font-size: 13.5px; }
.crm-table tbody td.num { white-space: nowrap; }
.crm-table tbody td.crm-col-wide { min-width: 240px; max-width: 270px; }
.crm-table tbody td.crm-col-lead { max-width: 230px; }
.crm-table tbody td.crm-col-domain { max-width: 250px; }
.crm-table tbody td .row { gap: var(--s2); min-width: 0; }
/* A flex child only truncates once it is allowed to be narrower than its text. */
.crm-table tbody td .row > .truncate { min-width: 0; }
.crm-foot { margin: 0; }

/* ----------------------------------------------------------------- narrow */

@media (max-width: 900px) {
  .crm-two { grid-template-columns: 1fr; }
  .crm-list { position: static; max-height: none; }
  .crm-two.open .crm-list { display: none; }
  .crm-two.open .crm-back { display: inline-block; }
  .crm-bar .crm-search { flex-basis: 100%; }
}
