/* TailAdmin-inspired CRM shell — keep thread/legacy helpers */
:root {
  --blue: #465fff;
  --ink: #101828;
  --muted: #667085;
  --line: #e4e7ec;
  --bg: #f9fafb;
  --card: #fff;
  --green: #12b76a;
  --red: #f04438;
  --radius: 16px;
  --header-h: 64px;
  --bottom-nav-h: 64px;
  --sidebar-w: 290px;
}
* { box-sizing: border-box; }
[x-cloak] { display: none !important; }

body {
  margin: 0;
  font-family: Outfit, system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.45;
  padding-bottom: env(safe-area-inset-bottom);
}

/* Forms / legacy helpers still used by lead detail & thread */
.panel, .card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: 0px 1px 3px 0px rgba(16, 24, 40, 0.1), 0px 1px 2px 0px rgba(16, 24, 40, 0.06);
}
.detail-grid { display: grid; gap: 10px; margin: 12px 0; }
.detail-grid dt { font-size: 12px; color: var(--muted); }
.detail-grid dd { margin: 0; word-break: break-all; }
.stack-form label { display: block; margin-bottom: 12px; }
.check-row { display: flex; gap: 8px; align-items: flex-start; }
.stack-form .wide { width: 100%; max-width: 100%; padding: 8px; }
.muted { color: var(--muted); font-size: 14px; }
.step-list { padding-left: 20px; }
.page-title { font-size: 1.5rem; margin: 0 0 16px; }
.lead-card-head h1 { margin: 0 0 8px; font-size: 1.35rem; }
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: #f2f4f7;
}
.badge-lead { background: #ecfdf3; color: #027a48; }
.badge-qualifying { background: #f4ebff; color: #6941c6; }
.badge-qualified { background: #ecf3ff; color: #3641f5; }
.badge-unclassified { background: #fffaeb; color: #b54708; }
.badge-irrelevant { background: #fef3f2; color: #b42318; }
.badge-customer { background: #ecf3ff; color: #3641f5; }
.badge-partner { background: #f4ebff; color: #6941c6; }
.badge-stage { background: #f4ebff; color: #6941c6; }
.badge-stage-won { background: #ecfdf3; color: #027a48; }
.badge-stage-lost { background: #fef3f2; color: #b42318; }
.meta { margin: 4px 0; color: var(--muted); font-size: 14px; }
.facts { display: grid; gap: 8px; margin: 16px 0; }
.facts dt { font-size: 12px; color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; }
.action-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.btn {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 10px 14px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
  color: var(--ink);
  display: inline-block;
  text-align: center;
}
.btn-primary { background: var(--blue); color: #fff; border-color: var(--blue); }
.btn-secondary { background: #f2f4f7; }
.btn-good { background: #ecfdf3; border-color: #abefc6; color: #027a48; }
.btn-bad { background: #fef3f2; border-color: #fecdca; color: var(--red); }
.btn-block { width: 100%; }
.classify-row { display: flex; flex-wrap: wrap; gap: 8px; }
.field { display: block; margin-bottom: 12px; }
.field span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font: inherit;
}
input[type="checkbox"],
input[type="radio"] {
  width: auto;
  flex: 0 0 auto;
  padding: 0;
  accent-color: var(--blue);
}
.queue-section h2 { font-size: 1rem; margin: 0 0 8px; }
.count { color: var(--muted); font-weight: 400; }
.lead-list { list-style: none; padding: 0; margin: 0 0 20px; }
.lead-list li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.lead-list a { color: var(--blue); text-decoration: none; font-weight: 600; }
.back-link { display: inline-block; margin-bottom: 8px; color: var(--blue); text-decoration: none; }
.chip-list { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: #f2f4f7; padding: 4px 10px; border-radius: 999px; font-size: 13px; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.tl-type { font-weight: 700; margin-right: 6px; }
.thread { display: flex; flex-direction: column; gap: 10px; min-height: 200px; margin-bottom: 12px; }
.bubble-body-html {
  margin: 4px 0 0;
  font-size: 13px;
  line-height: 1.45;
  overflow-x: auto;
  max-width: 100%;
}
.bubble-body-html table {
  border-collapse: collapse;
  width: 100%;
  min-width: 280px;
  margin: 8px 0;
  font-size: 12px;
}
.bubble-body-html th,
.bubble-body-html td {
  border: 1px solid #d0d5dd;
  padding: 6px 8px;
  vertical-align: top;
  text-align: left;
}
.bubble-body-html th {
  background: #f2f4f7;
  font-weight: 600;
  text-align: center;
}
.bubble-body-html ul,
.bubble-body-html ol {
  margin: 6px 0 6px 1.2em;
  padding: 0;
}
.bubble-body-html p { margin: 0 0 8px; }
.bubble-body-html p:last-child { margin-bottom: 0; }
.bubble-body-html img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 8px 0;
  border-radius: 4px;
}
.bubble-body-html .email-truncated {
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
}
.bubble {
  max-width: 85%;
  padding: 8px 10px 6px;
  border-radius: 8px;
  font-size: 15px;
  line-height: 1.35;
  color: #111b21;
  box-shadow: 0 1px 0.5px rgba(11, 20, 26, 0.13);
}
.bubble-inbound {
  align-self: flex-start;
  background: #ffffff;
  border: 1px solid rgba(11, 20, 26, 0.08);
}
.bubble-delivery {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  font-weight: 600;
  opacity: 0.85;
}
.bubble-delivery-pending .bubble-delivery,
.bubble-delivery.bubble-delivery-pending {
  color: #64748b;
}
.bubble-delivery-failed .bubble-delivery,
.bubble-delivery.bubble-delivery-failed {
  color: #b91c1c;
}
.bubble-outbound {
  align-self: flex-end;
  background: #d9fdd3;
  border: 1px solid rgba(11, 20, 26, 0.04);
}
.bubble-audio-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 6px;
  width: 100%;
  max-width: 100%;
  margin-bottom: 4px;
}
.bubble-audio-message {
  width: min(520px, 100%);
  max-width: min(520px, 100%);
}
.bubble-audio {
  display: block;
  width: 100%;
  min-width: 240px;
  max-width: none;
  margin-bottom: 0;
}
.bubble-audio-speed {
  justify-self: start;
  min-width: 2.75rem;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  color: #0f766e;
  background: #fff;
  border: 1px solid rgba(15, 118, 110, 0.35);
  border-radius: 6px;
  cursor: pointer;
}
.bubble-audio-speed:hover {
  background: #f0fdfa;
}
.bubble-audio-speed:focus-visible {
  outline: 2px solid #0f766e;
  outline-offset: 2px;
}
@media (max-width: 360px) {
  .bubble-audio-message {
    width: 100%;
    max-width: 100%;
  }
  .bubble-audio {
    min-width: 0;
  }
}
.bubble-voice-caption {
  font-size: 13px;
  color: #64748b;
  margin: 0 0 4px;
}
.bubble-transcript-status {
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
  margin: 4px 0 0;
}
.bubble-transcript-error {
  font-size: 12px;
  color: #b91c1c;
  margin: 4px 0 0;
}
.bubble-transcribe-btn {
  display: inline-block;
  margin-top: 6px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  color: #0f766e;
  background: #fff;
  border: 1px solid rgba(15, 118, 110, 0.35);
  border-radius: 6px;
  cursor: pointer;
}
.bubble-transcribe-btn:disabled {
  opacity: 0.6;
  cursor: wait;
}
.bubble-source-whatsapp { --bubble-accent: #12b76a; }
.bubble-source-whatsapp-group { --bubble-accent: #7c3aed; }
.bubble-source-messenger { --bubble-accent: #1877f2; }
.bubble-source-instagram { --bubble-accent: #c13584; }
.bubble-source-meta_leadgen { --bubble-accent: #f79009; }
.bubble-source-call_recording { --bubble-accent: #4f46e5; }
.bubble-source-call_recording.bubble-outbound {
  border-left: 3px solid var(--bubble-accent);
}
.bubble-source-call_recording p { white-space: pre-line; }

.bubble-source-gmail { --bubble-accent: #ea4335; }
.bubble-source-gmail.bubble-inbound {
  background: #fef3f2;
  border-color: rgba(234, 67, 53, 0.30);
}
.bubble-source-gmail.bubble-outbound {
  background: #fee4e2;
  border-color: rgba(234, 67, 53, 0.40);
}
.bubble-source-gmail .bubble-sender { color: #b42318; }
.bubble-source-gmail p { white-space: pre-line; }
.bubble-source-messenger.bubble-inbound {
  background: #e7f3ff;
  border-color: rgba(24, 119, 242, 0.35);
}
.bubble-source-messenger.bubble-outbound {
  background: #d4e8ff;
  border-color: rgba(24, 119, 242, 0.45);
}
.bubble-source-instagram.bubble-inbound {
  background: #fceef8;
  border-color: rgba(193, 53, 132, 0.35);
}
.bubble-source-instagram.bubble-outbound {
  background: #f8d9ef;
  border-color: rgba(193, 53, 132, 0.45);
}
.bubble-source-meta_leadgen.bubble-inbound,
.bubble-source-meta_leadgen.bubble-outbound {
  background: #fff8e6;
  border-color: rgba(247, 144, 9, 0.45);
}
.bubble-source-whatsapp.bubble-inbound {
  background: #ffffff;
  border-color: rgba(11, 20, 26, 0.08);
}
.bubble-source-whatsapp.bubble-outbound {
  background: #d9fdd3;
  border-color: rgba(11, 20, 26, 0.04);
}
.thread-pane-group {
  background: linear-gradient(180deg, #f5f3ff 0%, #ede9fe 100%);
  padding: 10px;
  border-radius: 10px;
  border: 1px solid rgba(124, 58, 237, 0.12);
}
.bubble-sender {
  display: block;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.25;
  margin-bottom: 4px;
  color: #5b21b6;
}
.bubble-sender-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 4px;
}
.bubble-sender-row .bubble-sender {
  margin-bottom: 0;
}
.bubble-sender-add {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--bubble-accent, #465fff);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
}
.bubble-sender-add:hover {
  color: #2a31d8;
}
.bubble-subject {
  margin: 0 0 4px;
  font-size: 13px;
  font-weight: 700;
  color: #b42318;
}
.bubble-gmail-link {
  display: inline-block;
  margin-top: 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--bubble-accent, #b42318);
}
.bubble-attachments {
  margin: 4px 0;
  padding: 0;
  list-style: none;
  font-size: 12px;
}
.bubble-attachments a {
  color: var(--bubble-accent, #b42318);
  font-weight: 600;
  text-decoration: underline;
}
.bubble-document {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin: 4px 0;
  font-size: 13px;
}
.bubble-document-link {
  color: var(--bubble-accent, #b42318);
  font-weight: 600;
  text-decoration: underline;
  word-break: break-word;
}
.bubble-document-download {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-muted, #667085);
  text-decoration: underline;
}
.bubble-file-preview {
  margin: 6px 0;
  max-width: 100%;
}
.bubble-file-preview__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  margin-bottom: 6px;
  font-size: 12px;
}
.bubble-file-preview__name {
  font-weight: 600;
  word-break: break-word;
  color: inherit;
}
.bubble-file-preview__download,
.bubble-file-preview__open {
  font-weight: 600;
  color: var(--bubble-accent, #b42318);
  text-decoration: underline;
  white-space: nowrap;
}
.bubble-file-preview__image {
  display: block;
  max-width: 100%;
  max-height: 280px;
  width: auto;
  height: auto;
  border-radius: 8px;
  border: 1px solid var(--color-line, #e4e7ec);
}
.bubble-file-preview__pdf {
  display: block;
  width: 100%;
  min-height: 320px;
  max-height: 480px;
  border: 1px solid var(--color-line, #e4e7ec);
  border-radius: 8px;
  background: #fff;
}
.bubble-file-preview__text {
  margin: 0;
  padding: 10px 12px;
  max-height: 240px;
  overflow: auto;
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  border-radius: 8px;
  border: 1px solid var(--color-line, #e4e7ec);
  background: rgba(255, 255, 255, 0.65);
}
.bubble-file-preview__video {
  display: block;
  max-width: 100%;
  max-height: 320px;
  border-radius: 8px;
}
.bubble-file-preview__audio {
  display: block;
  width: 100%;
  max-width: 100%;
}
.lead-attachment-preview {
  display: block;
  width: 72px;
  height: 72px;
  overflow: hidden;
  border-radius: 10px;
  border: 1px solid var(--color-line, #e4e7ec);
  background: #fff;
}
.lead-attachment-preview__media {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.lead-attachment-preview__placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #667085;
  background: #f2f4f7;
}
.lead-attachment-preview--compact {
  width: 40px;
  height: 40px;
  border-radius: 6px;
}
.lead-attachment-preview--compact .lead-attachment-preview__placeholder {
  font-size: 9px;
}
.lead-media-panels {
  min-height: 280px;
}
.lead-media-panels > .min-w-0 {
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.lead-attachments-panel-scroll {
  max-height: min(420px, 55vh);
}
.lead-call-recordings-list {
  max-height: min(420px, 55vh);
}
.thread-gmail-link {
  margin: -4px 0 8px;
  font-size: 13px;
  font-weight: 600;
}
.thread-gmail-link a {
  color: #b42318;
}
.bubble-source-whatsapp-group.bubble-outbound {
  background: #e9d5ff;
  border-color: rgba(124, 58, 237, 0.35);
}
.bubble-source-whatsapp-group.bubble-outbound .bubble-sender {
  color: #6d28d9;
}
.bubble-speaker-0.bubble-inbound { background: #fff7ed; border-color: #fdba74; --bubble-accent: #ea580c; }
.bubble-speaker-0.bubble-inbound .bubble-sender { color: #c2410c; }
.bubble-speaker-1.bubble-inbound { background: #ecfeff; border-color: #67e8f9; --bubble-accent: #0891b2; }
.bubble-speaker-1.bubble-inbound .bubble-sender { color: #0e7490; }
.bubble-speaker-2.bubble-inbound { background: #f0fdf4; border-color: #86efac; --bubble-accent: #16a34a; }
.bubble-speaker-2.bubble-inbound .bubble-sender { color: #15803d; }
.bubble-speaker-3.bubble-inbound { background: #fef2f2; border-color: #fca5a5; --bubble-accent: #dc2626; }
.bubble-speaker-3.bubble-inbound .bubble-sender { color: #b91c1c; }
.bubble-speaker-4.bubble-inbound { background: #fdf4ff; border-color: #e9d5ff; --bubble-accent: #9333ea; }
.bubble-speaker-4.bubble-inbound .bubble-sender { color: #7e22ce; }
.bubble-speaker-5.bubble-inbound { background: #fffbeb; border-color: #fcd34d; --bubble-accent: #d97706; }
.bubble-speaker-5.bubble-inbound .bubble-sender { color: #b45309; }
.bubble-speaker-6.bubble-inbound { background: #f0f9ff; border-color: #93c5fd; --bubble-accent: #2563eb; }
.bubble-speaker-6.bubble-inbound .bubble-sender { color: #1d4ed8; }
.bubble-speaker-7.bubble-inbound { background: #f8fafc; border-color: #cbd5e1; --bubble-accent: #475569; }
.bubble-speaker-7.bubble-inbound .bubble-sender { color: #334155; }
.thread-message.bubble-inbound,
.thread-message.bubble-outbound {
  max-width: 85%;
}
.thread-message.bubble-outbound {
  margin-left: auto;
}
.bubble img, .bubble video { max-width: 100%; border-radius: 8px; }
.bubble-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-top: 4px;
}
.bubble-meta time,
.bubble time { display: block; font-size: 11px; color: var(--muted); margin-top: 0; }
.bubble > time { margin-top: 4px; }
.bubble-crm-sender {
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}
.bubble-latest,
.thread-message-latest {
  position: relative;
  z-index: 1;
}
.bubble-latest-inbound,
.thread-message-latest-inbound {
  border: 2px solid var(--bubble-accent, #12b76a);
  animation: latest-inbound-pulse 1.8s ease-in-out infinite;
}
.bubble-latest-outbound,
.thread-message-latest-outbound {
  border: 2px solid var(--bubble-accent, #465fff);
  animation: latest-outbound-pulse 1.8s ease-in-out infinite;
}
@keyframes latest-inbound-pulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(18, 183, 106, 0.18), 0 1px 3px rgba(16, 24, 40, 0.08);
  }
  50% {
    box-shadow: 0 0 0 5px rgba(18, 183, 106, 0.28), 0 0 20px rgba(18, 183, 106, 0.46);
  }
}
@keyframes latest-outbound-pulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(70, 95, 255, 0.18), 0 1px 3px rgba(16, 24, 40, 0.08);
  }
  50% {
    box-shadow: 0 0 0 5px rgba(70, 95, 255, 0.28), 0 0 20px rgba(70, 95, 255, 0.46);
  }
}
@media (prefers-reduced-motion: reduce) {
  .bubble-latest-inbound,
  .thread-message-latest-inbound {
    animation: none;
    box-shadow: 0 0 0 3px rgba(18, 183, 106, 0.28);
  }
  .bubble-latest-outbound,
  .thread-message-latest-outbound {
    animation: none;
    box-shadow: 0 0 0 3px rgba(70, 95, 255, 0.28);
  }
}
.reply-bar textarea { resize: vertical; }
.reply-composer-hint {
  margin: 0 0 8px;
  font-size: 12px;
  color: var(--muted);
}
.js-thread-reply-dropzone.reply-drop-active {
  outline: 2px dashed var(--blue);
  outline-offset: 2px;
  background: rgba(70, 95, 255, 0.06);
}
.reply-attachment-preview {
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
}
.reply-attachment-preview.is-error {
  color: #b42318;
}
.sheet {
  position: fixed;
  inset: 0;
  background: rgba(16, 24, 40, 0.4);
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.sheet[hidden] { display: none !important; }
#meeting-create-session-modal[hidden] { display: none !important; }
.sheet-panel {
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow: auto;
  position: relative;
}
.sheet-panel-wide { max-width: 520px; }
.inbox-start-wa-details {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  background: var(--surface);
}
.inbox-start-wa-details summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}
.inbox-start-wa-details-body { margin-top: 12px; }
.inbox-start-wa-hint { margin: 0; font-size: 12px; line-height: 1.4; }
.inbox-start-wa-form textarea { width: 100%; min-height: 88px; resize: vertical; }
.sheet-close {
  position: absolute;
  right: 12px;
  top: 8px;
  border: 0;
  background: transparent;
  font-size: 28px;
  cursor: pointer;
}
.flash { padding: 10px 12px; border-radius: 10px; margin-bottom: 12px; }
.flash-error { background: #fef3f2; }
.flash-success { background: #ecfdf3; }
.mt-sm { margin-top: 8px; }
.mt-md { margin-top: 16px; }
.login-card { max-width: 400px; margin: 40px auto; }
.btn-sm { padding: 6px 10px; font-size: 12px; }
.pager { display: flex; justify-content: space-between; align-items: center; margin-top: 16px; }
.pager a { color: var(--blue); text-decoration: none; font-weight: 600; }
.channel-tabs { display: flex; gap: 8px; margin-bottom: 12px; }
.channel-tab {
  padding: 8px 12px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--line);
  text-decoration: none;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
}
.channel-tab.active { background: var(--blue); color: #fff; border-color: var(--blue); }
.channel-list { list-style: none; padding: 0; font-size: 14px; }
.channel-list li { padding: 6px 0; border-bottom: 1px solid var(--line); }
.task-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.task-done-form { margin: 0; }
.admin-links { list-style: none; padding: 0; margin: 0; }
.admin-links a { color: var(--blue); font-weight: 600; text-decoration: none; display: block; padding: 10px 0; border-bottom: 1px solid var(--line); }
.user-admin-list { list-style: none; padding: 0; }
.user-admin-list li { margin-bottom: 12px; }
.section-label { font-size: 13px; font-weight: 700; margin: 12px 0 6px; }
.facts-compact { margin: 8px 0; }
.lead-rail-title { font-size: 1.1rem; margin: 0 0 8px; }
.lead-rail { padding: 14px; }
.reply-bar-compact { padding: 12px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.reply-channel-label { display: block; margin-bottom: 4px; font-size: 12px; font-weight: 700; color: var(--muted); }
.reply-channel-select { width: 100%; margin: 0 0 10px; padding: 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); font-size: 14px; }
.channel-tabs-compact { margin-bottom: 8px; }
.thread-pane { max-height: 50vh; overflow-y: auto; }
.identity-suggestions { margin-bottom: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
.identity-suggestion-list { list-style: none; margin: 8px 0 0; padding: 0; }
.identity-suggestion-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 0; border-top: 1px solid var(--line); }
.identity-suggestion-row:first-child { border-top: none; }
.identity-suggestion-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.identity-suggestion-actions .inline-form { display: inline; margin: 0; }

.inbox-actions { margin-bottom: 10px; padding: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
.inbox-actions-toggle { cursor: pointer; font-weight: 700; padding: 10px 12px; list-style: none; }
.inbox-actions-toggle::-webkit-details-marker { display: none; }
.inbox-actions-body { padding: 0 12px 12px; border-top: 1px solid var(--line); }
.inbox-actions-body .field-input { width: 100%; margin-top: 4px; padding: 8px; border-radius: 8px; border: 1px solid var(--line); font-size: 14px; }
.inbox-actions-body .mode-row { display: flex; flex-wrap: wrap; gap: 6px; }
.inbox-actions-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 12px;
  align-items: start;
}
.inbox-actions-span-2 { grid-column: 1 / -1; }
.inbox-actions-col .section-label { margin-top: 0; }
.inbox-actions-col .section-label + .classify-row,
.inbox-actions-col .section-label + .mode-row { margin-top: 0; }
.inbox-actions-classify {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.inbox-actions-classify .btn { width: 100%; justify-content: center; }
.inbox-actions-mode {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.inbox-actions-mode .btn { width: 100%; justify-content: center; padding-left: 4px; padding-right: 4px; }
.inbox-actions-btn-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.inbox-actions-btn-grid .btn { width: 100%; justify-content: center; }
.inbox-actions-script-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 6px;
  align-items: end;
}
.inbox-actions-script-channel .field-input { margin-top: 0; }
.inbox-actions-script-send { align-self: end; min-width: 4.5rem; }
.inbox-actions-footer {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.inbox-actions-footer > a { grid-column: 1 / -1; }
.inbox-actions-body .mt-xs { margin-top: 6px; }
@media (max-width: 360px) {
  .inbox-actions-script-row { grid-template-columns: 1fr; }
  .inbox-actions-script-send { width: 100%; }
}
.stack-sm > * + * { margin-top: 10px; }
.radio-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-bottom: 12px;
  font-size: 14px;
}
.radio-row input { width: auto; margin-top: 4px; }

/* Shared WhatsApp inbox: compact filter drawer + two-pane chat workspace. */
.inbox-views-layout { width: 100%; }
.inbox-views-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.inbox-views-toolbar .inbox-view-tabs {
  flex: 1 1 auto;
  margin-bottom: 0;
  min-width: 0;
}
.inbox-toolbar-actions {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.inbox-sync-meta-form {
  margin: 0;
}
.inbox-start-convo-btn,
.inbox-sync-meta-btn {
  flex: 0 0 auto;
  white-space: nowrap;
}
.inbox-meta-sync-panel {
  max-width: min(640px, 96vw);
}
.inbox-meta-sync-log {
  margin-top: 10px;
  max-height: min(50vh, 360px);
  overflow: auto;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #0f172a;
  color: #e2e8f0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}
.inbox-meta-sync-status {
  font-weight: 600;
}
.view-nav-inline {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  overflow-x: auto;
  padding: 2px;
}
.source-nav {
  align-items: center;
  margin-top: -4px;
}
.view-nav-label {
  flex: 0 0 auto;
  margin-right: 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.view-tab {
  flex: 0 0 auto;
  padding: 8px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}
.view-tab:hover { color: var(--blue); border-color: #b8c4ff; }
.view-tab.active {
  color: #fff;
  background: var(--blue);
  border-color: var(--blue);
  box-shadow: 0 2px 6px rgba(70, 95, 255, 0.2);
}
.inbox-filters {
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 1px 3px rgba(16, 24, 40, 0.08);
}
.inbox-filters-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  cursor: pointer;
  padding: 10px 13px;
  list-style: none;
  border-radius: 14px;
  user-select: none;
}
.inbox-filters-summary:focus { outline: none; }
.inbox-filters-summary:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}
.inbox-filters-summary::-webkit-details-marker { display: none; }
.inbox-filters-summary::after {
  content: "⌄";
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
}
.inbox-filters[open] .inbox-filters-summary::after { content: "⌃"; }
.inbox-filters-title { color: var(--ink); font-size: 14px; font-weight: 700; }
.inbox-filters-state {
  margin-left: auto;
  padding: 4px 9px;
  border-radius: 999px;
  background: #ecf3ff;
  color: #3641f5;
  font-size: 11px;
  font-weight: 700;
}
.inbox-filters .filter-bar {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 10px;
  margin: 0;
  padding: 10px 12px 12px;
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0 0 14px 14px;
  box-shadow: none;
  overflow: visible;
}
.inbox-filters .filter-bar.card {
  margin-bottom: 0;
  padding: 10px 12px 12px;
}
.inbox-filters .field {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  margin: 0;
  min-width: 0;
}
.inbox-filters .field span {
  display: block;
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  line-height: 1.2;
}
.inbox-filters input,
.inbox-filters select {
  width: 100%;
  min-width: 0;
  min-height: 36px;
  padding: 7px 28px 7px 10px;
  border-radius: 999px;
  font-size: 12px;
  line-height: 1.25;
  text-overflow: ellipsis;
}
.inbox-filter-search { grid-column: 1 / -1; }
.inbox-filter-search input { border-radius: 10px; }
.inbox-filter-chip-classification select,
.inbox-filter-chip-stage select,
.inbox-filter-chip-owner select {
  border-width: 1px;
  border-style: solid;
  font-weight: 700;
  cursor: pointer;
}
.inbox-filter-chip-classification select {
  background: #ecfdf3;
  border-color: #abefc6;
  color: #027a48;
}
.inbox-filter-chip-stage select {
  background: #f4ebff;
  border-color: #d6bbfb;
  color: #6941c6;
}
.inbox-filter-chip-owner select {
  background: #ecf3ff;
  border-color: #b8c4ff;
  color: #3641f5;
}
.inbox-filter-checklist {
  position: relative;
}
.inbox-filter-checklist > summary {
  position: relative;
  min-height: 36px;
  padding: 7px 28px 7px 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font-size: 12px;
  line-height: 1.25;
  cursor: pointer;
  list-style: none;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.inbox-filter-checklist > summary::-webkit-details-marker { display: none; }
.inbox-filter-checklist > summary::after {
  content: "⌄";
  position: absolute;
  top: 7px;
  right: 10px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
}
.inbox-filter-checklist[open] > summary::after { content: "⌃"; }
.inbox-filter-chip-classification .inbox-filter-checklist > summary {
  border-color: #abefc6;
  background: #ecfdf3;
  color: #027a48;
  font-weight: 700;
}
.inbox-filter-chip-stage .inbox-filter-checklist > summary {
  border-color: #d6bbfb;
  background: #f4ebff;
  color: #6941c6;
  font-weight: 700;
}
.inbox-filter-chip-owner .inbox-filter-checklist > summary {
  border-color: #b8c4ff;
  background: #ecf3ff;
  color: #3641f5;
  font-weight: 700;
}
.inbox-filter-checklist-panel {
  position: absolute;
  z-index: 30;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 230px;
  overflow-y: auto;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 8px 20px rgba(16, 24, 40, 0.14);
}
.inbox-filter-checklist-panel label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 30px;
  padding: 5px 6px;
  border-radius: 7px;
  color: var(--ink);
  font-size: 12px;
  cursor: pointer;
}
.inbox-filter-checklist-panel label span {
  display: inline;
  margin: 0;
  color: inherit;
  font-size: inherit;
  font-weight: inherit;
  line-height: inherit;
}
.inbox-filter-checklist-panel label:hover { background: var(--bg); }
.inbox-filter-checklist-panel input[type="checkbox"] {
  width: 15px;
  min-width: 15px;
  min-height: 15px;
  margin: 0;
  padding: 0;
  accent-color: var(--blue);
}
.inbox-filter-sort-row {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr) auto auto;
  gap: 8px 10px;
  align-items: end;
}
.inbox-filter-options-row {
  display: flex;
  grid-template-columns: auto 1fr;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.inbox-filter-sort-row .field span,
.inbox-filter-sort-row .inbox-filter-unread span {
  white-space: nowrap;
}
.inbox-filter-sort select,
.inbox-filter-order select {
  border-radius: 10px;
  font-weight: 600;
}
.inbox-filter-unread {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  margin: 0;
  padding: 0 4px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.inbox-filter-unread input[type="checkbox"] {
  width: 15px;
  height: 15px;
  max-width: 15px;
  min-width: 15px;
  min-height: 15px;
  flex: 0 0 15px;
  padding: 0;
}
.inbox-filter-options-row .inbox-filter-unread {
  flex: 1 1 auto;
  min-width: 0;
}
.inbox-filter-options-row .inbox-filter-actions {
  flex: 0 0 auto;
}
.inbox-filter-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 36px;
}
.inbox-filter-actions .btn { padding: 7px 11px; font-size: 12px; }
.inbox-sort-card {
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 1px 3px rgba(16, 24, 40, 0.08);
}
.inbox-sort-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  cursor: pointer;
  padding: 10px 13px;
  list-style: none;
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
}
.inbox-sort-summary::-webkit-details-marker { display: none; }
.inbox-sort-summary::after { content: "⌄"; color: var(--muted); font-size: 16px; }
.inbox-sort-card[open] .inbox-sort-summary::after { content: "⌃"; }
.inbox-sort-state {
  margin-left: auto;
  padding: 4px 9px;
  border-radius: 999px;
  background: #ecf3ff;
  color: #3641f5;
  font-size: 11px;
}
.inbox-sort-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 0 12px 12px;
  border-top: 1px solid var(--line);
}
.inbox-sort-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 10px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}
.inbox-sort-chip:hover,
.inbox-sort-chip.active {
  border-color: #b8c4ff;
  background: #eef2ff;
  color: var(--blue);
}
.inbox-sort-chip-arrow { font-size: 14px; line-height: 1; }
.workspace-inbox {
  display: grid;
  grid-template-columns: minmax(300px, 38%) minmax(0, 1fr);
  gap: 12px;
  min-height: calc(100vh - 164px);
  align-items: stretch;
}
.workspace-inbox .workspace-list {
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
}
.workspace-inbox .lead-list-rich {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  margin: 0;
  padding: 2px 3px 10px 1px;
}
.workspace-inbox .lead-list-rich > li {
  flex: 0 0 auto;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
  overflow: hidden;
}
.workspace-inbox .lead-list-rich > li.lead-row-unread {
  border-color: #c11574;
  background: #fdf2f8;
  box-shadow: 0 0 0 1px rgba(193, 21, 116, 0.35), 0 0 16px rgba(236, 72, 153, 0.35);
  animation: inbox-unread-glow 2.2s ease-in-out infinite;
}
.workspace-inbox .lead-list-rich > li.lead-row-unread:hover,
.workspace-inbox .lead-list-rich > li.lead-row-unread.lead-row-open {
  border-color: #9d174d;
  box-shadow: 0 0 0 2px rgba(157, 23, 77, 0.45), 0 0 22px rgba(236, 72, 153, 0.5);
}
@keyframes inbox-unread-glow {
  0%, 100% { box-shadow: 0 0 0 1px rgba(193, 21, 116, 0.35), 0 0 12px rgba(236, 72, 153, 0.28); }
  50% { box-shadow: 0 0 0 2px rgba(157, 23, 77, 0.5), 0 0 20px rgba(236, 72, 153, 0.45); }
}
@media (prefers-reduced-motion: reduce) {
  .workspace-inbox .lead-list-rich > li.lead-row-unread {
    animation: none;
  }
}
.workspace-inbox .lead-list-rich > li.lead-row-followup {
  border-color: #c2410c;
  background: #fff7ed;
  box-shadow: 0 0 0 1px rgba(234, 88, 12, 0.4), 0 0 16px rgba(249, 115, 22, 0.4);
  animation: inbox-followup-glow 2.2s ease-in-out infinite;
}
.workspace-inbox .lead-list-rich > li.lead-row-followup:hover,
.workspace-inbox .lead-list-rich > li.lead-row-followup.lead-row-open {
  border-color: #9a3412;
  box-shadow: 0 0 0 2px rgba(154, 52, 18, 0.5), 0 0 22px rgba(249, 115, 22, 0.55);
}
.workspace-inbox .lead-list-rich > li.lead-row-followup.lead-row-unread {
  border-color: #c2410c;
  background: #fff7ed;
  animation: inbox-followup-glow 2.2s ease-in-out infinite;
}
@keyframes inbox-followup-glow {
  0%, 100% { box-shadow: 0 0 0 1px rgba(234, 88, 12, 0.35), 0 0 12px rgba(249, 115, 22, 0.3); }
  50% { box-shadow: 0 0 0 2px rgba(194, 65, 12, 0.55), 0 0 20px rgba(249, 115, 22, 0.5); }
}
@media (prefers-reduced-motion: reduce) {
  .workspace-inbox .lead-list-rich > li.lead-row-followup {
    animation: none;
  }
}
.reason-chip-followup {
  background: #ffedd5;
  color: #9a3412;
  border: 1px solid #fdba74;
}
.lead-followup-mark-btn {
  background: #fff7ed;
  border: 1px solid #fdba74;
  color: #9a3412;
}
.lead-followup-mark-btn:hover {
  background: #ffedd5;
  border-color: #f97316;
}
.workspace-inbox .lead-list-rich > li:hover:not(.lead-row-unread):not(.lead-row-followup),
.workspace-inbox .lead-list-rich > li.lead-row-open:not(.lead-row-unread):not(.lead-row-followup) {
  border-color: #b8c4ff;
  box-shadow: 0 2px 8px rgba(70, 95, 255, 0.12);
}
.lead-row-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
}
.lead-row-activity {
  margin-left: auto;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.unread-count-badge {
  display: inline-flex;
  min-width: 1.35rem;
  align-items: center;
  justify-content: center;
  padding: 2px 7px;
  border-radius: 999px;
  background: #be185d;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
  box-shadow: 0 0 0 2px rgba(253, 242, 248, 0.9);
}
.reason-chip-muted {
  opacity: 0.85;
  font-size: 10px;
}
.badge-source {
  background: #f4f3ff;
  color: #5925dc;
  border: 1px solid #d9d6fe;
  font-weight: 600;
}
.badge-source-whatsapp {
  background: #ecfdf3;
  color: #027a48;
  border-color: #a6f4c5;
}
.badge-source-whatsapp-group {
  background: #f4f3ff;
  color: #7c3aed;
  border-color: #d9d6fe;
}
.badge-source-messenger {
  background: #eff4ff;
  color: #175cd3;
  border-color: #b2ccff;
}
.badge-source-instagram {
  background: #fdf2fa;
  color: #c11574;
  border-color: #fcceee;
}
.badge-source-meta_ads,
.badge-source-meta_leadgen {
  background: #fff6ed;
  color: #b54708;
  border-color: #f9dbaf;
}
.badge-source-gmail {
  background: #fef3f2;
  color: #b42318;
  border-color: #fecdca;
}
.badge-source-manual {
  background: #f2f4f7;
  color: #344054;
  border-color: #e4e7ec;
}
.badge-source-website,
.badge-source-web {
  background: #f0f9ff;
  color: #026aa2;
  border-color: #b9e6fe;
}
.badge-source-unknown {
  background: #f2f4f7;
  color: #667085;
  border-color: #e4e7ec;
}
.badge-source-waha {
  background: #ecfdf3;
  color: #027a48;
  border-color: #a6f4c5;
}
/* Stable fallback palette for sources without a hand-picked colour. */
.badge-source-c0 {
  background: #ecfdf3;
  color: #027a48;
  border-color: #a6f4c5;
}
.badge-source-c1 {
  background: #eff4ff;
  color: #175cd3;
  border-color: #b2ccff;
}
.badge-source-c2 {
  background: #fdf2fa;
  color: #c11574;
  border-color: #fcceee;
}
.badge-source-c3 {
  background: #fff6ed;
  color: #b54708;
  border-color: #f9dbaf;
}
.badge-source-c4 {
  background: #fef3f2;
  color: #b42318;
  border-color: #fecdca;
}
.badge-source-c5 {
  background: #f4f3ff;
  color: #5925dc;
  border-color: #d9d6fe;
}
.badge-source-c6 {
  background: #f0f9ff;
  color: #026aa2;
  border-color: #b9e6fe;
}
.badge-source-c7 {
  background: #f0fdf9;
  color: #107569;
  border-color: #99f6e0;
}
.workspace-inbox .lead-list-rich > li > .lead-row-link {
  display: block;
  padding: 12px 13px;
}
.workspace-inbox .lead-list-rich > li > .classify-row {
  padding: 0 13px 11px;
}
.lead-row-identity {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 0;
}
.lead-row-avatar {
  display: inline-flex;
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 1px solid #d0d5dd;
  border-radius: 50%;
  background: #eef2ff;
  color: #3641f5;
  font-size: 15px;
  font-weight: 800;
  text-transform: uppercase;
}
.lead-row-avatar img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.lead-row-details {
  display: block;
  min-width: 0;
  flex: 1 1 auto;
}
.lead-row-phone {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}
.workspace-inbox .lead-row-meta {
  margin-top: 8px;
  gap: 5px;
}
.workspace-inbox .lead-row-meta .badge,
.workspace-inbox .reason-chip {
  border: 1px solid transparent;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}
.workspace-inbox .lead-row-meta .badge-stage {
  background: #f4ebff;
  border-color: #d6bbfb;
  color: #6941c6;
}
.workspace-inbox .lead-row-meta .badge-stage-won {
  background: #ecfdf3;
  border-color: #abefc6;
  color: #027a48;
}
.workspace-inbox .lead-row-meta .badge-stage-lost {
  background: #fef3f2;
  border-color: #fecdca;
  color: #b42318;
}
.workspace-inbox .reason-chip {
  background: #fff7e6;
  border-color: #fedf89;
  color: #b54708;
}
.workspace-inbox .meta-inline {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}
.workspace-inbox .workspace-detail {
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  margin: 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 1px 3px rgba(16, 24, 40, 0.1);
  overflow: hidden;
}
.workspace-inbox .workspace-detail-inner,
.workspace-inbox .workspace-thread {
  display: flex;
  min-width: 0;
  min-height: 0;
  flex: 1;
  flex-direction: column;
}
.workspace-inbox .workspace-rail { display: none; }
.workspace-inbox .workspace-thread > .thread-inbox-history,
.workspace-inbox .workspace-thread > .thread-inbox-history-form {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 0 12px 12px;
}
.workspace-inbox .workspace-thread > .thread-inbox-history-form > .thread-inbox-history {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.thread-inbox-history-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 8px 0 6px;
}
.thread-inbox-history-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.thread-message-select-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
}
.thread-message-select-row .bubble {
  flex: 1;
  min-width: 0;
}
.thread-message-select {
  margin-top: 14px;
  flex-shrink: 0;
}
.workspace-inbox .workspace-thread > .thread-inbox-history .thread-inbox-history-label,
.workspace-inbox .workspace-thread > .thread-inbox-history-form .thread-inbox-history-label {
  flex: 0 0 auto;
  margin: 0;
}
.workspace-inbox .workspace-thread > .thread-inbox-history .thread-inbox-history-head,
.workspace-inbox .workspace-thread > .thread-inbox-history-form .thread-inbox-history-head {
  flex: 0 0 auto;
  margin: 8px 0 6px;
  padding: 0;
}
.workspace-inbox .workspace-thread > .thread-inbox-history .thread-pane,
.workspace-inbox .workspace-thread > .thread-inbox-history-form .thread-pane {
  flex: 1;
  min-height: 0;
  max-height: none;
  margin: 0;
  padding: 14px;
  overflow-y: auto;
  background: #f8fafc;
}
.workspace-inbox .workspace-thread > .reply-bar {
  flex: 0 0 auto;
  margin: 0 12px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.workspace-inbox .workspace-thread > .inbox-actions {
  flex: 0 0 auto;
  margin: 0 12px 8px;
}
.workspace-inbox .workspace-thread > .inbox-actions [data-merge-picker] {
  margin-top: 10px;
}
.workspace-inbox .workspace-thread > .channel-tabs { flex: 0 0 auto; margin: 12px 12px 8px; }
.workspace-inbox .workspace-thread > .thread-gmail-link { flex: 0 0 auto; margin: 0 12px 8px; font-size: 13px; }
.workspace-inbox .workspace-detail-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.workspace-inbox .workspace-empty {
  max-width: 280px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 900px) {
  .workspace-inbox { grid-template-columns: minmax(270px, 42%) minmax(0, 1fr); }
  .inbox-filter-sort-row {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
  .inbox-filter-unread { grid-column: 1 / -1; }
  .inbox-filter-actions { grid-column: 1 / -1; }
}

@media (max-width: 520px) {
  .inbox-filters .filter-bar { grid-template-columns: 1fr; }
  .inbox-filter-sort-row { grid-template-columns: 1fr; }
}

@media (max-width: 700px) {
  .workspace-inbox {
    display: block;
    min-height: 0;
  }
  .workspace-inbox .workspace-list { min-height: 0; }
  .workspace-inbox .lead-list-rich { overflow: visible; }
  .workspace-inbox .workspace-detail-empty { display: none; }
  .workspace-inbox.workspace-mobile-detail .workspace-list-hidden-mobile { display: none; }
  .workspace-inbox.workspace-mobile-detail .workspace-detail-mobile {
    display: flex;
    min-height: calc(100vh - 190px);
  }
  .workspace-inbox:not(.workspace-mobile-detail) .workspace-detail {
    display: none;
  }
}

/* Pipeline board: keep every stage compact and scroll cards independently. */
.pipeline-board {
  align-items: flex-start;
  max-height: calc(100vh - 190px);
  overscroll-behavior: contain;
}
.pipeline-column {
  display: flex;
  min-height: 0;
  max-height: calc(100vh - 190px);
  flex-direction: column;
}
.pipeline-dropzone {
  min-height: 140px;
  scrollbar-gutter: stable;
  overscroll-behavior: contain;
}

@media (max-width: 1023px) {
  .pipeline-board,
  .pipeline-column {
    max-height: calc(100vh - 220px);
  }
}

/* Leads table: slide-over detail panel */
body.lead-drawer-open { overflow: hidden; }
.lead-drawer {
  position: fixed;
  inset: 0;
  z-index: 70;
  pointer-events: none;
  visibility: hidden;
}
.lead-drawer.open {
  pointer-events: auto;
  visibility: visible;
}
.lead-drawer-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  padding: 0;
  background: rgba(16, 24, 40, 0.38);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.22s ease;
}
.lead-drawer.open .lead-drawer-backdrop { opacity: 1; }
.lead-drawer-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  display: flex;
  width: min(760px, 100%);
  max-width: 100%;
  flex-direction: column;
  background: #fff;
  box-shadow: -8px 0 32px rgba(16, 24, 40, 0.14);
  transform: translateX(104%);
  transition: transform 0.24s ease;
}
.lead-drawer.open .lead-drawer-panel { transform: translateX(0); }
.lead-drawer-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.lead-drawer-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: #fff;
  position: sticky;
  top: 0;
  z-index: 2;
}
.lead-drawer-eyebrow {
  margin: 0 0 2px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.lead-drawer-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
}
.lead-drawer-sub {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--muted);
}
.lead-drawer-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.lead-drawer-link {
  font-size: 12px;
  font-weight: 700;
  color: var(--blue);
  text-decoration: none;
  white-space: nowrap;
}
.lead-drawer-close {
  border: 0;
  background: #f2f4f7;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
}
.lead-drawer-loading {
  position: absolute;
  top: 72px;
  left: 16px;
  right: 16px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #ecf3ff;
  color: #3641f5;
  font-size: 12px;
  font-weight: 700;
  opacity: 0;
  transition: opacity 0.15s ease;
  pointer-events: none;
  z-index: 3;
}
.lead-drawer-loading.htmx-request { opacity: 1; }
.lead-table-row-open { background: #ecf3ff !important; }
.lead-detail-body--compact { padding: 0 14px 18px; }
.lead-detail-body--compact .lead-detail-grid {
  display: flex;
  flex-direction: column;
  margin-bottom: 14px;
}
.lead-detail-body--compact .lead-detail-grid > article,
.lead-detail-body--compact .lead-detail-grid > aside {
  width: 100%;
  max-width: none;
}
.lead-detail-body--compact .lead-detail-grid > article { order: 1; }
.lead-detail-body--compact .lead-detail-grid > aside { order: 2; }
.lead-detail-drawer-aside {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  align-content: start;
}
.lead-detail-drawer-aside > section {
  margin: 0;
  min-width: 0;
}
.lead-detail-drawer-aside > section.lead-detail-drawer-aside-span {
  grid-column: 1 / -1;
}
.lead-detail-body--compact .lead-media-panels {
  grid-template-columns: 1fr 1fr;
}
@media (max-width: 700px) {
  .lead-drawer-panel { width: 100%; }
}

/* Floating integration debug — FAB collapsed, panel on expand */
.integration-debug-console {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 80;
  pointer-events: none;
}
.integration-debug-console > * {
  pointer-events: auto;
}
.integration-debug-fab {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  padding: 0;
  border: 1px solid #344054;
  border-radius: 50%;
  background: linear-gradient(180deg, #1d2939 0%, #101828 100%);
  color: #e4e7ec;
  box-shadow: 0 6px 20px rgba(16, 24, 40, 0.35);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.integration-debug-fab:hover {
  transform: scale(1.05);
  box-shadow: 0 8px 24px rgba(16, 24, 40, 0.45);
}
.integration-debug-fab:focus-visible {
  outline: 2px solid #7cd4fd;
  outline-offset: 2px;
}
.integration-debug-fab-icon {
  display: block;
}
.integration-debug-console.open .integration-debug-fab {
  display: none;
}
.integration-debug-panel {
  display: none;
  position: absolute;
  right: 0;
  bottom: 0;
  width: min(420px, calc(100vw - 24px));
  border: 1px solid #1d2939;
  border-radius: 14px;
  background: #0b1220;
  color: #e4e7ec;
  box-shadow: 0 12px 40px rgba(16, 24, 40, 0.35);
  overflow: hidden;
}
.integration-debug-console.open .integration-debug-panel {
  display: block;
}
.integration-debug-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid #344054;
  background: #101828;
}
.integration-debug-title {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
}
.integration-debug-sub {
  margin: 2px 0 0;
  font-size: 11px;
  color: #98a2b3;
}
.integration-debug-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.integration-debug-btn {
  border: 1px solid #475467;
  background: #1d2939;
  color: #f9fafb;
  border-radius: 8px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}
.integration-debug-log {
  display: block;
  width: 100%;
  min-height: 160px;
  max-height: 36vh;
  margin: 0;
  padding: 10px 12px;
  border: 0;
  resize: vertical;
  background: #0b1220;
  color: #d0d5dd;
  font: 12px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  outline: none;
}
@media (max-width: 700px) {
  .integration-debug-console {
    right: 10px;
    bottom: calc(72px + env(safe-area-inset-bottom));
  }
  .integration-debug-panel {
    width: min(420px, calc(100vw - 20px));
  }
}

.markdown-summary h1,
.markdown-summary h2,
.markdown-summary h3,
.markdown-summary h4 {
  margin: 1em 0 0.5em;
  font-weight: 600;
  line-height: 1.35;
  color: var(--ink);
}
.markdown-summary h1 { font-size: 1.125rem; }
.markdown-summary h2,
.markdown-summary h3,
.markdown-summary h4 { font-size: 1rem; }
.markdown-summary h1:first-child,
.markdown-summary h2:first-child,
.markdown-summary h3:first-child { margin-top: 0; }
.markdown-summary p { margin: 0.5em 0; }
.markdown-summary ul,
.markdown-summary ol {
  margin: 0.5em 0 0.75em;
  padding-left: 1.35rem;
}
.markdown-summary ul { list-style: disc; }
.markdown-summary ol { list-style: decimal; }
.markdown-summary li { margin: 0.25em 0; }
.markdown-summary strong { font-weight: 600; }
.markdown-summary a { color: var(--blue); text-decoration: underline; }
.markdown-summary code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92em;
  background: #f2f4f7;
  padding: 0.1em 0.35em;
  border-radius: 4px;
}
.markdown-summary pre {
  overflow-x: auto;
  margin: 0.75em 0;
  padding: 0.75em;
  border-radius: 8px;
  background: #f2f4f7;
  font-size: 0.85em;
}
