/* Broker → Leads. Table styles come from the shared .table (tenant admin shell.css); this file adds the
   toolbar extras, filter panel, kanban board and lead cards. Status = quiet dots, no tinted fills or stripes. */

/* ─── Header: title left, view switch right ─── */
.view-head .view-switch[hidden] { display: none; }

/* ─── Toolbar: search · Filters · New lead (right) ─── */
.leads-bar .search { flex: 1 1 320px; max-width: 420px; }
.leads-bar .new-lead-btn { margin-left: auto; }
.filter-btn { gap: 7px; }
.filter-count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--r-full); background: var(--fg); color: var(--surface); font-size: 11.5px; font-weight: 600; }
.filter-count[hidden] { display: none; }
.active-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: -4px; }
.active-filters[hidden] { display: none; }
.filter-chip { height: 28px; padding: 0 4px 0 10px; font-size: 12.5px; }
.filter-chip button { display: grid; place-items: center; width: 22px; height: 22px; padding: 0; border: 0; border-radius: 6px; background: none; color: var(--muted); cursor: pointer; }
.filter-chip button:hover { background: var(--surface-soft); color: var(--fg); }
.filter-chip svg.lucide { width: 13px; height: 13px; }
.active-filters .link-inline { margin-left: 4px; font-size: 13px; }

.filter-panel { width: min(440px, calc(100vw - 16px)); padding: 14px 16px 16px; }
.filter-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; font-size: 14px; }
.filter-head .link-inline { font-size: 13px; }
.filter-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.filter-grid .field { gap: 6px; }
.filter-grid .label { font-size: 12.5px; font-weight: 500; color: var(--fg-2); }
.filter-grid .input { height: 38px; font-size: 13.5px; }
.filter-grid .input.is-set { border-color: var(--fg-2); }

/* ─── Table extras ─── */
.leads-table { min-width: 1640px; }
.clients-table { min-width: 1560px; } /* Broker → Clients reuses this stylesheet */
.clients-table th:nth-last-child(-n+2) .th-info::after { left: auto; right: -8px; }
.clients-table .member-text .ndot { font-size: 12.5px; }
.leads-table th:nth-last-child(-n+3) .th-info::after { left: auto; right: -8px; } /* open leftward: a hidden tip past the last column widened the scroll area */
.av-sm { width: 24px; height: 24px; font-size: 10px; }
.av-xs { width: 18px; height: 18px; font-size: 8.5px; }
.score { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; }
.score-track { width: 36px; height: 4px; border-radius: 2px; background: var(--surface-soft); overflow: hidden; }
.score-track > span { display: block; height: 100%; background: var(--fg-2); }
.tag-list { display: flex; align-items: center; gap: 4px; }
.stage-btn { display: inline-flex; align-items: center; gap: 4px; padding: 2px 4px 2px 2px; border: 0; border-radius: var(--r-full); background: none; color: var(--muted); cursor: pointer; }
.stage-btn:hover { background: var(--surface-soft); color: var(--fg); }
.stage-btn .tag { cursor: inherit; }
.shell-page .stage-btn > svg.lucide { width: 14px; height: 14px; }
.menu-label { padding: 6px 10px 4px; color: var(--muted); font-size: 12px; font-weight: 500; }
.stage-opt .ndot { color: var(--fg); font-size: 14px; }
.stage-opt[aria-current] { background: var(--surface-sunken); }
.shell-page .stage-opt .stage-check { width: 15px; height: 15px; margin-left: auto; color: var(--fg); }
.tag-more { color: var(--muted); font-size: 12px; font-weight: 500; }
.ndot[data-tone="info"]::before { background: var(--info); }
.leads-state .state-msg { padding: 56px 16px; text-align: center; }
.leads-state .state-msg > span { max-width: 420px; }

/* ─── Kanban board (columns on a soft surface, white cards) ─── */
.board { display: flex; gap: 12px; align-items: flex-start; overflow-x: auto; padding-bottom: 8px; scroll-snap-type: x proximity; }
.board[hidden] { display: none; }
.lane {
  flex: 0 0 288px; display: flex; flex-direction: column; gap: 8px; padding: 10px 8px 8px; scroll-snap-align: start;
  border-radius: var(--r-card); background: var(--surface-soft); transition: box-shadow 0.15s;
}
.lane[data-over] { box-shadow: inset 0 0 0 2px var(--border-strong); background: var(--surface-sunken); }
.lane-head { display: flex; align-items: center; gap: 8px; min-height: 30px; padding: 0 4px 0 6px; }
.lane-head .ndot { color: var(--fg); font-size: 13.5px; font-weight: 600; }
.lane-head .count-pill { background: var(--surface); }
.lane-plus { width: 28px; height: 28px; margin-left: auto; }
.shell-page .lane-plus svg.lucide { width: 16px; height: 16px; }
.lane-body { display: grid; gap: 8px; min-height: 64px; }
.lane-empty { display: grid; place-items: center; min-height: 64px; padding: 12px; border: 1px dashed var(--border-strong); border-radius: 10px; color: var(--muted); font-size: 12.5px; text-align: center; }
.lane-add { display: flex; align-items: center; gap: 6px; height: 34px; padding: 0 8px; border: 0; border-radius: 8px; background: none; color: var(--muted); font: inherit; font-size: 13px; font-weight: 500; cursor: pointer; }
.lane-add:hover { background: var(--surface); color: var(--fg); }
.shell-page .lane-add svg.lucide { width: 15px; height: 15px; }

.lead-card {
  display: grid; gap: 10px; padding: 12px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); box-shadow: 0 1px 2px rgb(16 24 20 / 0.04); cursor: grab;
}
.lead-card:hover { border-color: var(--border-strong); }
.lead-card.is-dragging { opacity: 0.4; }
.lead-card.is-flash { animation: card-flash 1.6s var(--ease); }
@keyframes card-flash { from { box-shadow: 0 0 0 3px var(--focus); } }
.lc-head { display: flex; align-items: flex-start; gap: 10px; }
.lc-title { display: grid; gap: 2px; min-width: 0; flex: 1; }
.lc-name { justify-self: start; border-radius: 4px; max-width: 100%; padding: 0; border: 0; background: none; color: var(--fg); font: inherit; font-size: 14px; font-weight: 500; text-align: left; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lc-name:hover { text-decoration: underline; text-decoration-color: var(--border-strong); text-underline-offset: 3px; }
.lc-sub { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lc-score { flex: none; min-width: 30px; height: 24px; padding: 0 7px; border: 1px solid var(--border); border-radius: 7px; color: var(--fg); font-size: 12.5px; font-weight: 600; line-height: 22px; text-align: center; }
.lc-chips { display: flex; flex-wrap: wrap; gap: 5px; padding-top: 10px; border-top: 1px solid var(--border); }
.lc-chip { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 8px; border: 1px solid var(--border); border-radius: var(--r-full); background: var(--surface); color: var(--fg-2); font-size: 12px; font-weight: 500; white-space: nowrap; }
.lc-chip.ndot { gap: 6px; }
.lc-chip .av-xs { margin-left: -4px; }
.shell-page .lc-chip svg.lucide { width: 13px; height: 13px; color: var(--muted); }
.lc-lost { color: var(--muted); font-size: 12.5px; }
.lc-foot { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.lc-when { display: inline-flex; align-items: center; gap: 5px; }
.shell-page .lc-foot svg.lucide { width: 13px; height: 13px; }
.lc-menu { width: 26px; height: 26px; margin-left: auto; opacity: 0; }
.lead-card:hover .lc-menu, .lead-card:focus-within .lc-menu { opacity: 1; }
@media (hover: none) { .lc-menu { opacity: 1; } }

/* ─── Tasks (../tasks/) ─── */
.tasks-table { min-width: 1480px; }
.tasks-table .col-check { width: 44px; padding-right: 0; }
.task-check { width: 18px; height: 18px; margin: 0; accent-color: var(--fg); cursor: pointer; }
.tasks-table tr.is-done .task-title .link-inline { color: var(--muted); text-decoration-line: line-through; }
.task-title { max-width: 340px; white-space: normal; }
.task-title .member-email { display: flex; align-items: center; gap: 6px; }
.ai-chip { display: inline-flex; align-items: center; gap: 3px; color: var(--info); font-weight: 500; }
.shell-page .ai-chip svg.lucide { width: 12px; height: 12px; }
.task-type { display: inline-flex; align-items: center; gap: 7px; color: var(--fg-2); }
.shell-page .task-type svg.lucide { width: 15px; height: 15px; color: var(--muted); }
.cell-pick { padding: 4px 6px; margin: -4px -6px; border: 0; border-radius: 8px; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.cell-pick:hover { background: var(--surface-soft); }
.task-card .lc-head { align-items: flex-start; }
.task-card .task-check { margin-top: 2px; flex: none; }
.task-card .lc-name { white-space: normal; }
.task-card.is-done .lc-name { color: var(--muted); text-decoration: line-through; }
.task-card .lc-when { display: inline-flex; align-items: center; gap: 5px; margin: -4px; padding: 4px; font-size: 12px; color: var(--muted); }
.task-card .lc-when.is-expired { color: var(--danger); }
.menu-date { display: grid; gap: 6px; margin-top: 4px; padding: 8px 10px 6px; border-top: 1px solid var(--border); color: var(--muted); font-size: 12px; }
.menu-date .input { height: 34px; }

/* ─── Lead detail (lead/): ratio strip carries the lead score as a 5th cell ─── */
.lead-ratios { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.lead-ratios .of { color: var(--muted); font-size: 13px; font-weight: 500; letter-spacing: 0; }
.rec-top .view-title .ndot { font-size: 13.5px; }

/* ─── Email composer (../shared/email.js): modal + "Write with AI" chat docked right, inside the dialog ─── */
.leads-table .col-actions { width: 96px; }
.leads-table .row-actions { flex-wrap: nowrap; } /* mail + ⋯ side by side */
.lc-mail { margin-left: auto; }
.lc-mail + .lc-menu { margin-left: 0; }
.compact dialog.modal.email-modal { width: min(600px, calc(100% - 32px)); transition: margin 0.2s var(--ease); }
/* fade only: a transform animation would make the dialog the containing block and trap the fixed chat panel inside it */
dialog.modal.email-modal[open] { animation: email-in 0.2s var(--ease) both; }
@keyframes email-in { from { opacity: 0; } }
.email-modal[data-ai] { margin-right: calc(var(--ai-w) + 24px); } /* slide left so the form sits beside the chat */
.label-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 24px; }
.label-row .link-inline { font-size: 13px; }
.ai-draft-btn.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; }
/* Body scrolls, Send stays in view however many errors or chips there are */
.email-modal[open] { display: flex; flex-direction: column; max-height: calc(100dvh - 32px); }
dialog.email-modal > form { display: flex; flex-direction: column; min-height: 0; }
.email-modal .modal-body { min-height: 0; overflow-y: auto; }
.email-modal .modal-foot { flex: none; }
.email-copies { display: grid; gap: 14px; }
.email-copies[hidden] { display: none; }
.email-modal textarea.input { min-height: 180px; resize: vertical; }
.email-modal .modal-body p.hint { font-size: 12.5px; }
.email-modal .modal-body p.field-error { font-size: 12.5px; } /* beats .compact .modal-body p */
.email-modal .field-error svg.lucide { width: 14px; height: 14px; margin-top: 1px; }
.email-modal .chip-input input { min-width: 140px; }
.email-ai { z-index: 1; box-shadow: var(--shadow-pop); }
.email-ai .ai-draft { display: grid; gap: 6px; padding: 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-sunken); }
.email-ai .ai-draft strong { font-size: 13.5px; font-weight: 600; }
.email-ai .ai-draft p { color: var(--fg-2); font-size: 13px; white-space: pre-wrap; }
.ai-insert { display: grid; gap: 6px; flex: none; padding: 12px 14px; border-top: 1px solid var(--border); background: var(--surface); }
.ai-insert[hidden] { display: none; }
.ai-insert .btn { width: 100%; height: 40px; }
.ai-insert span { color: var(--muted); font-size: 12px; text-align: center; }
@media (max-width: 1100px) { .email-modal[data-ai] { margin-right: auto; } }

/* ─── Dialog extras ─── */
.lead-more { display: grid; gap: 14px; }
.lead-more[hidden] { display: none; }
.tag-pick { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-opt { position: relative; cursor: pointer; }
.tag-opt input { position: absolute; opacity: 0; pointer-events: none; }
.tag-opt span { display: inline-flex; align-items: center; height: 30px; padding: 0 11px; border: 1px solid var(--border-strong); border-radius: var(--r-full); background: var(--surface); color: var(--fg-2); font-size: 12.5px; font-weight: 500; }
.tag-opt:hover span { border-color: var(--fg-2); }
.tag-opt input:checked + span { border-color: var(--fg); background: var(--fg); color: var(--surface); }
.tag-opt input:focus-visible + span { box-shadow: 0 0 0 3px var(--focus); }

@media (max-width: 1100px) { .lead-ratios { grid-template-columns: repeat(3, minmax(0, 1fr)); } .lead-ratios .stat:nth-child(4) { border-left: 0; } }
@media (max-width: 720px) {
  .lead-ratios { grid-template-columns: 1fr 1fr; }
  .filter-grid { grid-template-columns: 1fr; }
  .lane { flex-basis: 84vw; }
}
@media (prefers-reduced-motion: reduce) { .lead-card.is-flash { animation: none; } .lane { transition: none; } }
