/* Marketing keeps the shared list controls, with a quieter and more compact lead hierarchy. */
.marketing-leads { --lead-accent: #087d70; }
.lead-import-tools { margin: 1.5rem 0 1rem; padding: 0.75rem 1rem; border: 1px solid #e4e7ec; border-radius: 0.75rem; background: #fff; }
.lead-import-tools > summary { color: #475467; }
.lead-queues { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.75rem; }
.lead-queue { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 0.375rem; padding: 1rem 1.25rem; border: 1px solid #e4e7ec; border-radius: 0.75rem; background: #fff; transition: border-color 120ms, background-color 120ms; }
.lead-queue:hover { border-color: #64b7aa; background: #f6fbfa; }
.lead-queue-active { border-color: var(--lead-accent); background: #f0faf7; box-shadow: inset 0 3px var(--lead-accent); }
.lead-queue-label { color: #344054; font-size: 0.875rem; font-weight: 600; }
.lead-queue-count { grid-column: 2; grid-row: 1 / 3; color: #101828; font-size: 1.5rem; font-weight: 650; line-height: 1.2; font-variant-numeric: tabular-nums; }
.lead-queue-active .lead-queue-count { color: var(--lead-accent); }
.lead-queue-description { grid-column: 1; }
.lead-queue-description, .lead-queue-note { color: #667085; font-size: 0.75rem; line-height: 1.5; }
.lead-queue-note { margin: 0.5rem 0 1.25rem; }
.lead-filter-bar { align-items: end; }
.lead-filter-bar .lead-quick-filter { flex: 0 1 12rem; }
.lead-applied-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin-top: 0.875rem; }
.lead-results-toolbar { padding: 0.75rem 1.25rem; border-bottom: 1px solid #eaecf0; background: #fcfcfd; }
.lead-table { table-layout: fixed; }
.lead-table th:nth-child(1) { width: 25%; }
.lead-table th:nth-child(2) { width: 37%; }
.lead-table th:nth-child(3) { width: 23%; }
.lead-table th:nth-child(4) { width: 15%; }
.lead-table > tbody > tr > td { padding-block: 0.875rem; overflow-wrap: anywhere; }
.lead-table .cell-title { line-height: 1.4; }
.lead-table .cell-detail { margin-top: 0.2rem; font-size: 0.75rem; }
.lead-table .lead-source { color: #667085; font-size: 0.6875rem; margin-top: 0.5rem; }
.lead-message { display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2; color: #344054; }
.lead-statuses { display: flex; flex-wrap: wrap; gap: 0.375rem; }
.lead-table .lead-statuses { flex-wrap: wrap; }
.lead-missing-contact { display: block; margin-top: 0.25rem; color: #b54708; font-size: 0.75rem; }
.lead-reply-needed { display: block; margin-bottom: 0.375rem; color: #93370d; font-size: 0.75rem; font-weight: 600; }
.lead-table .lead-do-not-contact { color: #b42318; font-weight: 500; }
.lead-not-interested { color: #667085; font-weight: 500; }
.lead-tracking-details { margin-top: 0.375rem; font-size: 0.75rem; }
.lead-tracking-details summary { cursor: pointer; color: #475467; }
.lead-tracking-details[open] summary { margin-bottom: 0.5rem; }
.lead-action { justify-content: center; min-height: 2.75rem; border: 1px solid #d0d5dd; border-radius: 0.625rem; padding: 0.5rem 0.75rem; color: #344054; background: #fff; font-size: 0.8125rem; font-weight: 600; text-align: center; text-wrap: balance; }
.lead-action:hover { background: #f2f4f7; }
.lead-action-primary { background: var(--lead-accent); border-color: var(--lead-accent); color: #fff; }
.lead-action-primary:hover { background: #056358; }
.lead-queue:focus-visible, .lead-action:focus-visible { outline: 3px solid #80c9bf; outline-offset: 3px; }
.lead-table > tbody > tr.lead-awaiting > td:first-child { border-left: 3px solid #f79009; padding-left: calc(1.25rem - 3px); }
.dark .lead-import-tools, .dark .lead-queue { background: #101828; border-color: #344054; }
.dark .lead-queue-active, .dark .lead-queue:hover { background: #102c29; border-color: #4fb3a1; }
.dark .lead-queue-label, .dark .lead-queue-count, .dark .lead-message { color: #eaecf0; }
.dark .lead-queue-note, .dark .lead-queue-description, .dark .lead-tracking-details summary { color: #98a2b3; }
.dark .lead-results-toolbar { background: #101828; border-color: #344054; }
.dark .lead-action { background: #1d2939; color: #eaecf0; border-color: #475467; }
.dark .lead-action-primary { background: #087d70; border-color: #087d70; }
.dark .lead-table .lead-do-not-contact { color: #fda29b; }
@media (max-width: 900px) {
  .lead-queue { padding: 0.875rem; }
  .lead-queue-description { display: none; }
}
@media (max-width: 639px) {
  .lead-queues { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.5rem; }
  .lead-queue { padding: 0.75rem; }
  .lead-queue-label { font-size: 0.75rem; line-height: 1.3; }
  .lead-queue-count { font-size: 1.375rem; }
  .lead-filter-bar .lead-quick-filter { flex: 1 1 8rem; }
  .lead-results-toolbar { padding: 0.75rem 1rem; }
  .lead-table .cell-actions .lead-action { display: flex; width: 100%; margin-top: 0.5rem; }
  .lead-table .lead-message { text-align: left; }
  .lead-table .lead-statuses { justify-content: end; }
  .lead-table > tbody > tr.lead-awaiting > td:first-child { border: 0; padding-left: 0; }
  .lead-table > tbody > tr.lead-awaiting { border-left: 3px solid #f79009; }
}
/* Four columns become cards before the actions would need horizontal scrolling. */
@media (max-width: 899px) {
  .marketing-leads .data-table-scroll { overflow: visible; }
  .marketing-leads .data-table-scroll::before { display: none; }
  .marketing-leads .lead-table { min-width: 0; }
  .lead-table > thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .lead-table > tbody > tr { display: block; padding: 1rem; border-bottom: 1px solid #eaecf0; }
  .lead-table > tbody > tr:last-child { border-bottom: 0; }
  .marketing-leads .lead-table > tbody > tr > td { display: grid; grid-template-columns: 7rem minmax(0, 1fr); gap: 0.375rem 1rem; border: 0; padding: 0.375rem 0; text-align: left; }
  .lead-table > tbody > tr > td[data-label]::before { content: attr(data-label); grid-column: 1; color: #667085; font-size: 0.75rem; }
  .lead-table > tbody > tr > td[data-label] > * { grid-column: 2; }
  .marketing-leads .lead-table > tbody > tr > td.cell-primary { display: block; padding-bottom: 0.75rem; }
  .marketing-leads .lead-table > tbody > tr > td.cell-actions { display: block; }
  .lead-table .cell-actions .lead-action { display: flex; width: 100%; margin-top: 0.375rem; }
  .marketing-leads .lead-table .lead-statuses { justify-content: start; }
  .marketing-leads .lead-table > tbody > tr.lead-awaiting > td:first-child { border: 0; padding-left: 0; }
  .lead-table > tbody > tr.lead-awaiting { border-left: 3px solid #f79009; }
  .dark .lead-table > tbody > tr { border-color: #344054; }
}

.lead-section-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin: 1.25rem 0 1rem; }
.lead-section-heading h2 { color: #1d2939; font-size: 1.125rem; font-weight: 600; }
.lead-section-heading p { margin-top: 0.25rem; color: #667085; font-size: 0.8125rem; line-height: 1.5; }
.lead-conversation-filters { display: flex; flex-wrap: wrap; gap: 0.375rem; }
.lead-conversation-filter { display: inline-flex; align-items: center; min-height: 2.75rem; padding: 0.5rem 0.875rem; border: 1px solid #d0d5dd; border-radius: 0.625rem; background: #fff; color: #475467; font-size: 0.8125rem; font-weight: 600; }
.lead-conversation-filter:hover { border-color: var(--lead-accent); }
.lead-conversation-filter.is-active { border-color: var(--lead-accent); color: #066455; background: #e8f8f4; }
.lead-contact-details { margin-top: 0.5rem; font-size: 0.6875rem; color: #667085; }
.lead-contact-details summary { cursor: pointer; }
.lead-action { display: inline-flex; align-items: center; }
.dark .lead-section-heading h2 { color: #eaecf0; }
.dark .lead-section-heading p, .dark .lead-contact-details { color: #98a2b3; }
.dark .lead-conversation-filter { background: #101828; color: #eaecf0; border-color: #475467; }
.dark .lead-conversation-filter.is-active { background: #102c29; color: #a4e4d5; border-color: #4fb3a1; }
@media (max-width: 639px) {
  .lead-conversation-filters { width: 100%; }
  .lead-conversation-filter { flex: 1; justify-content: center; }
}

/* Conversation workspace: metrics stay above, list and history scroll independently. */
.lead-inbox { display: grid; grid-template-columns: minmax(300px, 38%) minmax(0, 1fr); height: min(850px, 80dvh); min-height: 550px; border: 1px solid #dce4e3; border-radius: 18px; overflow: hidden; background: #fff; box-shadow: 0 8px 28px #153c3410; }
.lead-inbox .lead-inbox-list { display: flex; flex-direction: column; min-height: 0; margin: 0; border: 0; border-right: 1px solid #dce4e3; border-radius: 0; overflow-y: auto; }
.lead-inbox .list-card-toolbar { padding: 16px; background: #fff; }
.lead-inbox .lead-filter-bar { display: flex; flex-wrap: wrap; gap: 10px; }
.lead-inbox .lead-filter-bar > * { max-width: 100%; }
.lead-inbox .lead-filter-bar input[type="search"] { min-width: 0; width: 100%; background: #f0f4f3; }
.lead-inbox .lead-filter-bar .list-field { min-width: 0; }
.lead-inbox .lead-results-toolbar, .lead-inbox .list-pagination-footer { padding: 10px 16px; }
.lead-inbox-contacts { flex: 1; }
.lead-inbox-contact { display: flex; gap: 12px; padding: 16px; color: #152c2b; text-decoration: none; border-bottom: 1px solid #edf1f0; transition: background .15s; }
.lead-inbox-contact:hover { background: #f5f8f7; }
.lead-inbox-contact[aria-current="true"] { background: #e7f4ef; box-shadow: inset 3px 0 #087d70; }
.lead-inbox-contact:focus-visible, .lead-chat-tool:focus-visible, .lead-chat-back:focus-visible { outline: 3px solid #087d70; outline-offset: -3px; }
.lead-avatar { display: grid; place-items: center; flex: 0 0 42px; width: 42px; height: 42px; border-radius: 50%; background: #e2eeea; color: #167567; font-size: 18px; font-weight: 700; }
.lead-inbox-contact-content { display: block; min-width: 0; flex: 1; }
.lead-inbox-contact-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.lead-inbox-contact-top strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.lead-inbox-contact-top time { white-space: nowrap; font-size: 10px; color: #667a76; }
.lead-inbox-preview { display: block; margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #62706e; font-size: 13px; }
.lead-inbox-labels { display: flex; flex-wrap: wrap; gap: 4px 8px; margin-top: 6px; font-size: 11px; color: #62706e; }
.lead-inbox-labels .lead-reply-needed { font-size: 10px; margin: 0; }
.lead-inbox-registered { color: #087d70; }
.lead-inbox-panel { min-width: 0; min-height: 0; background: #efeae2; }
.lead-conversation-frame { display: flex; flex-direction: column; min-width: 0; min-height: 0; height: 100%; }
.lead-conversation-frame[busy] { opacity: .65; pointer-events: none; }
.lead-inbox-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; height: 100%; padding: 30px; text-align: center; color: #526861; }
.lead-inbox-empty > span { font-size: 50px; color: #087d70; }
.lead-inbox-empty h2 { font-size: 22px; font-weight: 600; }
.lead-inbox-empty p { max-width: 320px; font-size: 14px; line-height: 1.7; }
.lead-chat { display: flex; flex-direction: column; min-height: 0; height: min(850px, 80dvh); background: #efeae2; border: 1px solid #dce4e3; border-radius: 16px; overflow: hidden; }
.lead-inbox .lead-chat { flex: 1; height: 100%; border: 0; border-radius: 0; }
.lead-chat-header { display: flex; flex-shrink: 0; align-items: center; gap: 10px; padding: 14px 18px; background: #f6f8f7; border-bottom: 1px solid #dce4e3; }
.lead-chat-person { flex: 1; min-width: 0; }
.lead-chat-person h2 { font-size: 15px; font-weight: 700; overflow-wrap: anywhere; }
.lead-chat-person p { font-size: 12px; color: #62706e; }
.lead-chat-header nav { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.lead-chat-tool { font-size: 12px; color: #087d70; font-weight: 600; padding: 6px; border-radius: 6px; }
.lead-chat-tool-form { display: inline; margin: 0; }
button.lead-chat-tool { background: transparent; border: 0; cursor: pointer; font: inherit; }
.lead-chat-back { display: none; font-size: 24px; min-width: 40px; min-height: 44px; }
.lead-chat-window { flex-shrink: 0; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px; padding: 8px 18px; background: #fffaf0; color: #786033; font-size: 11px; }
.lead-chat-window details { max-width: 100%; }
.lead-chat-window summary { cursor: pointer; text-decoration: underline; }
.lead-chat-window details[open] { flex-basis: 100%; }
.lead-chat-window details p { margin-top: 6px; max-width: 500px; }
.lead-chat-messages { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 20px 24px; background-color: #efeae2; background-image: radial-gradient(#b7c5ba35 .8px, transparent .8px); background-size: 18px 18px; }
.lead-chat-day { text-align: center; margin: 12px 0 18px; }
.lead-chat-day time { display: inline-block; border-radius: 8px; padding: 5px 12px; color: #62706e; font-size: 11px; background: #fffdf9; box-shadow: 0 1px 2px #00000010; }
.lead-chat-row { display: flex; margin-bottom: 8px; }
.lead-chat-row.is-outbound { justify-content: flex-end; }
.lead-chat-bubble { min-width: 90px; max-width: 85%; padding: 9px 12px; border-radius: 0 12px 12px; background: #fff; color: #1f302c; box-shadow: 0 1px 2px #00000013; font-size: 14px; overflow-wrap: anywhere; }
.is-outbound .lead-chat-bubble { background: #d9fdd3; border-radius: 12px 0 12px 12px; }
.lead-chat-composer { flex-shrink: 0; max-height: 45%; overflow-y: auto; padding: 12px 16px max(12px, env(safe-area-inset-bottom)); border-top: 1px solid #dce4e3; background: #f6f8f7; }
.lead-chat-compose-form { display: flex; align-items: flex-end; gap: 10px; }
.lead-chat-compose-form > div { min-width: 0; }
.lead-chat-compose-form textarea { display: block; resize: none; max-height: 144px; min-height: 44px; border-radius: 22px; background: #fff; font-size: 16px; }
.lead-chat-compose-form input[type="submit"] { min-height: 44px; border-radius: 22px; }
.lead-chat-attachment { font-size: 12px; margin-top: 6px; }
.lead-chat-attachment summary { cursor: pointer; color: #087d70; }
.lead-chat-notice, .lead-chat-error { margin: 0; padding: 10px 16px; font-size: 13px; }
.lead-chat-notice { background: #e7f4ef; color: #087d70; }
.lead-chat-error { background: #fef2f2; color: #b91c1c; }
@media (max-width: 767px) {
  .lead-inbox { display: block; height: max(560px, 75dvh); min-height: 0; }
  .lead-inbox .lead-inbox-list { height: 100%; border-right: 0; }
  .lead-inbox-panel { display: none; }
  .lead-inbox.has-conversation .lead-inbox-list { display: none; }
  .lead-inbox.has-conversation .lead-inbox-panel { display: block; position: fixed; inset: 0; height: 100dvh; z-index: 60; }
  .lead-chat-back { display: inline-block; }
  .lead-chat-header { padding: 10px; gap: 6px; }
  .lead-chat-header .lead-avatar { flex-basis: 34px; width: 34px; height: 34px; font-size: 15px; }
  .lead-chat-tool { font-size: 11px; }
  .lead-chat-messages { padding: 12px; }
  .lead-chat-bubble { max-width: 92%; }
  .lead-chat-composer { padding-left: 10px; padding-right: 10px; }
  .lead-chat-compose-form input[type="submit"] { padding: 10px 14px; font-size: 12px; }
}
@media (max-width: 767px) {
  body:has(.lead-inbox) { overflow-x: clip; }
  body:has(.lead-inbox.has-conversation) { overflow: hidden; }
}

/* Keep attention on the inbox; advanced filters live outside the contact rail. */
.lead-inbox-page .list-page-header { margin-bottom: 12px; }
.lead-inbox-page .lead-queue { padding: 10px 14px; }
.lead-inbox-page .lead-queue-count { font-size: 21px; }
.lead-inbox-context { margin: 8px 0; color: #667085; font-size: 11px; }
.lead-inbox-context summary { cursor: pointer; width: fit-content; }
.lead-inbox-context p { margin-top: 6px; max-width: 800px; line-height: 1.6; }
.lead-inbox-page .lead-section-heading { margin: 10px 0; }
.lead-inbox-page .lead-inbox { grid-template-columns: minmax(300px, 33%) minmax(0, 1fr); height: max(480px, calc(100dvh - 340px)); }
.lead-inbox .lead-inbox-list { overflow: hidden; }
.lead-inbox .lead-inbox-toolbar { padding: 12px; flex-shrink: 0; }
.lead-inbox-search { display: grid; gap: 8px; }
.lead-inbox-search-row { display: flex; gap: 6px; }
.lead-inbox-search-row input[type="search"] { flex: 1; min-width: 0; border-radius: 10px; background: #f0f4f3; font-size: 13px; }
.lead-inbox-search-row .list-filter-submit { padding-inline: 12px; font-size: 12px; }
.lead-inbox-controls { display: flex; gap: 8px; align-items: center; }
.lead-inbox-sort { flex: 1; min-width: 0; }
.lead-inbox-sort select { width: 100%; min-height: 40px; border: 0; background-color: transparent; color: #526861; padding: 6px 30px 6px 4px; font-size: 12px; }
.lead-inbox-controls .list-filter-toggle { min-height: 40px; font-size: 12px; padding-inline: 12px; }
.lead-inbox-filter-summary { display: flex; justify-content: space-between; gap: 8px; margin-top: 8px; color: #667085; font-size: 11px; }
.lead-inbox-filter-summary span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lead-inbox-filter-summary a { flex-shrink: 0; color: #087d70; text-decoration: underline; }
.lead-inbox .lead-results-toolbar, .lead-inbox .list-pagination-footer { flex-shrink: 0; padding: 8px 12px; }
.lead-inbox .lead-inbox-contacts { overflow-y: auto; overscroll-behavior: contain; min-height: 0; }
.lead-inbox-contact { padding: 13px 14px; }
.lead-filter-drawer { position: fixed; inset: 0 0 0 auto; margin: 0; width: min(440px, 100%); max-width: 100%; height: 100dvh; max-height: 100dvh; padding: 0; border: 0; background: #fff; color: #1f302c; box-shadow: -12px 0 40px #132f3026; }
.lead-filter-drawer::backdrop { background: #122e3b66; }
.lead-filter-drawer[open] { display: flex; flex-direction: column; }
.lead-filter-drawer > header { display: flex; align-items: start; justify-content: space-between; gap: 12px; padding: 22px; border-bottom: 1px solid #e4e7ec; flex-shrink: 0; }
.lead-filter-drawer h2 { font-weight: 700; font-size: 19px; }
.lead-filter-drawer header p { margin-top: 4px; font-size: 12px; color: #667085; }
.lead-filter-drawer header button { min-width: 44px; min-height: 44px; border-radius: 50%; font-size: 25px; background: #f3f6f5; }
.lead-filter-drawer > form { display: flex; flex: 1; flex-direction: column; min-height: 0; }
.lead-filter-drawer-fields { flex: 1; min-height: 0; overflow-y: auto; display: grid; align-content: start; gap: 18px; padding: 22px; }
.lead-filter-drawer .list-field { font-size: 12px; }
.lead-filter-drawer select { min-height: 44px; border: 1px solid #d0d5dd; border-radius: 9px; padding: 9px 32px 9px 12px; color: #344054; background-color: #fff; font-size: 14px; }
.lead-filter-drawer footer { flex-shrink: 0; display: flex; justify-content: flex-end; gap: 10px; border-top: 1px solid #e4e7ec; padding: 16px 22px max(16px, env(safe-area-inset-bottom)); }
@media (max-width: 767px) {
  .lead-inbox-page .lead-inbox { height: max(540px, 75dvh); }
  .lead-inbox-page .lead-section-heading h2 { display: none; }
  .lead-inbox-context { font-size: 10px; }
}
