/* CRM tab: view switch in the bar, group tiles, and one table per group.
   On a phone each row becomes a small stacked block. */
.tabs { display: flex; gap: 4px; padding: 3px; background: var(--sunk); border-radius: 10px; width: max-content; max-width: 100%; }
.tab { height: 34px; padding: 0 18px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-size: 14px; font-weight: 700; cursor: pointer; }
.tab[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(15, 31, 61, 0.14); }

body[data-tab="crm"] .wrap { max-width: 1180px; }
body[data-tab="crm"] .progress,
body[data-tab="crm"] .stats,
body[data-tab="crm"] .chips,
body[data-tab="crm"] #script,
body[data-tab="crm"] #list,
body[data-tab="crm"] #empty,
body[data-tab="crm"] #add { display: none !important; }

.crm-view { display: grid; gap: 14px; min-width: 0; }
.crm-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: 8px; }
.crm-tile { display: grid; gap: 2px; text-align: left; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); cursor: pointer; }
.crm-tile[aria-pressed="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.crm-tile-n { font-family: var(--font-display); font-size: 24px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.crm-tile-l { font-size: 12px; font-weight: 600; color: var(--muted); }
.crm-tile[data-stage="active"] .crm-tile-n { color: var(--ok); }
.crm-tile[data-stage="passed"] .crm-tile-n { color: var(--bad); }
.crm-tile[data-stage="brokers"] .crm-tile-n { color: var(--gold); }
.crm-note { margin: 0; font-size: 13px; color: var(--muted); }
.crm-note:empty { display: none; }
.crm-body { display: grid; gap: 12px; min-width: 0; }

details.crm-group { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); min-width: 0; }
details.crm-group > summary { cursor: pointer; padding: 12px 14px; display: flex; align-items: baseline; gap: 10px; list-style: none; }
details.crm-group > summary::-webkit-details-marker { display: none; }
details.crm-group > summary::before { content: "\25B8"; color: var(--muted); font-size: 12px; }
details.crm-group[open] > summary::before { content: "\25BE"; }
details.crm-group > summary h2 { font-family: var(--font-display); font-size: 17px; margin: 0; }
.crm-scroll { overflow-x: auto; border-top: 1px solid var(--line); }

.crm-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.crm-table th { text-align: left; padding: 0; background: var(--bg); border-bottom: 1px solid var(--line); white-space: nowrap; }
.crm-sort { width: 100%; text-align: left; padding: 8px 12px; border: 0; background: transparent; font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); cursor: pointer; }
.crm-sort[data-dir="up"]::after { content: " \25B2"; }
.crm-sort[data-dir="down"]::after { content: " \25BC"; }
.crm-table td { padding: 10px 12px; vertical-align: top; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.crm-table tbody tr:last-child td { border-bottom: 0; }
.crm-table tbody tr { cursor: pointer; }
.crm-table tbody tr:hover { background: var(--bg); }
.crm-table .c-co { width: 24%; min-width: 180px; }
.crm-table .c-st { width: 15%; white-space: nowrap; }
.crm-table .c-sent { width: 9%; white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--muted); }
.crm-table .c-reply { width: 24%; }
.crm-table .c-reply b { font-weight: 600; font-variant-numeric: tabular-nums; color: var(--ok); }
.crm-table .c-next { width: 28%; }
.crm-sub { display: block; font-size: 12.5px; color: var(--muted); }
.badge[data-tone="none"] { background: var(--sunk); color: var(--muted); }

.card.crm-flash { outline: 3px solid var(--gold-fill); outline-offset: 2px; }

@media (max-width: 720px) {
  .tabs { width: 100%; }
  .tab { flex: 1; }
  .crm-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .crm-table, .crm-table tbody { display: block; }
  .crm-table tbody tr { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
  .crm-table tbody tr:last-child { border-bottom: 0; }
  .crm-table td { display: block; padding: 0; border: 0; width: auto !important; min-width: 0 !important; white-space: normal; }
  .crm-table .c-co { grid-column: 1; }
  .crm-table .c-st { grid-column: 2; justify-self: end; }
  .crm-table .c-sent, .crm-table .c-reply, .crm-table .c-next { grid-column: 1 / -1; font-size: 13px; }
  .crm-table td[data-label]::before { content: attr(data-label) ": "; font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
  .crm-table .c-reply .crm-sub { display: inline; }
  .crm-table .c-reply b::after { content: " "; }
}
