/* ==========================================================================
   Argos Zap · Telas operacionais: Conversas, Objeções, Leads, Configuração, WhatsApp.
   Somente tokens de theme.css.
   ========================================================================== */
.cv-view, .ob-view, .ld-view, .cf-view { min-width: 0; max-width: 100%; }

/* ---------- Conversas ---------- */
.cv-layout { display: grid; grid-template-columns: minmax(270px, .8fr) minmax(0, 1.7fr); gap: var(--space-md); min-width: 0; align-items: start; }
.cv-sidebar, .cv-thread { min-width: 0; padding: 0; overflow: hidden; }
.cv-list-header { display: grid; gap: var(--space-xs); padding: var(--space-md) var(--space-lg); border-bottom: 1px solid var(--color-border); }
.cv-list-header h2, .cv-thread-title { margin: 0; font-size: 1.2rem; }
.cv-poll-note, .cv-list-time, .cv-bubble-meta, .cv-queue-help, .cv-queue-item time { font-size: var(--text-caption); }
.cv-filter { display: flex; gap: var(--space-xs); align-items: center; min-height: 40px; font-size: var(--text-sm); font-weight: var(--weight-semibold); color: var(--color-text-2); cursor: pointer; }
.cv-filter input { accent-color: var(--color-brand); width: 18px; height: 18px; }
.cv-list { max-height: 72vh; overflow-y: auto; overscroll-behavior: contain; }
.cv-conversation { display: grid; width: 100%; grid-template-columns: 40px minmax(0, 1fr); gap: var(--space-sm); padding: var(--space-md) var(--space-lg); background: transparent; color: var(--color-ink); border: 0; border-bottom: 1px solid var(--color-border); text-align: left; transition: background var(--duration-fast) var(--ease); }
.cv-conversation:hover { background: var(--color-surface-muted); }
.cv-conversation.is-active { background: var(--color-brand-softer); box-shadow: inset 3px 0 var(--color-brand); }
.cv-avatar { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: var(--color-brand-soft); color: var(--color-brand-text); font-weight: var(--weight-extrabold); }
.cv-conversation.is-active .cv-avatar { background: var(--color-brand); color: var(--white); }
.cv-conversation-info { display: grid; min-width: 0; gap: 4px; }
.cv-conversation-name { font-weight: var(--weight-bold); }
.cv-preview { display: block; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--color-text-3); font-size: var(--text-sm); }
.cv-conversation-badges { display: flex; flex-wrap: wrap; gap: 4px; }
.cv-list-time { grid-column: 2; color: var(--color-text-3); }
.cv-list-status:empty, .cv-thread-status:empty, .cv-send-status:empty, .cv-contact-warning:empty { display: none; }
.cv-list-status:not(:empty), .cv-thread-status:not(:empty) { padding: var(--space-sm); }
.cv-thread { display: flex; flex-direction: column; }
.cv-thread-header { display: flex; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; gap: var(--space-sm); padding: var(--space-md) var(--space-lg); border-bottom: 1px solid var(--color-border); }
.cv-thread-header:empty { display: none; }
.cv-thread-identity { display: grid; gap: var(--space-xs); min-width: 0; flex: 1 1 220px; }
.cv-thread-actions { display: flex; gap: var(--space-xs); flex-wrap: wrap; }
.cv-back { display: none; }
.cv-messages { display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-xs); height: clamp(300px, 46vh, 560px); min-height: 240px; overflow-y: auto; overscroll-behavior: contain; padding: var(--space-lg); background: var(--color-surface-sunken); }
.cv-messages > .empty { width: 100%; margin: auto; }
/* Bolhas no padrão WhatsApp: contato em branco, agente em verde-menta, dono em lavanda. */
.cv-bubble { max-width: min(78%, 560px); padding: 8px 12px 10px; border-radius: var(--radius-md); border: 1px solid var(--color-border); background: var(--color-surface); box-shadow: var(--shadow-xs); border-top-left-radius: 4px; }
.cv-bubble p { margin: 4px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: var(--text-sm); color: var(--color-ink); }
.cv-bubble-meta { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: var(--space-xs); color: var(--color-text-3); }
.cv-bubble-meta strong { color: var(--color-ink-2); }
.cv-bubble-agente { align-self: flex-end; background: var(--color-success-soft); border-color: var(--color-success-border); border-top-left-radius: var(--radius-md); border-top-right-radius: 4px; }
.cv-bubble-agente .cv-bubble-meta strong { color: var(--color-success-text); }
.cv-bubble-dono { align-self: flex-end; background: var(--color-brand-soft); border-color: var(--color-brand-border); border-top-left-radius: var(--radius-md); border-top-right-radius: 4px; }
.cv-bubble-dono .cv-bubble-meta strong { color: var(--color-brand-text); }
.cv-bubble-sistema { align-self: center; max-width: 92%; border-style: dashed; border-radius: var(--radius-pill); padding: 4px 14px; color: var(--color-text-3); background: var(--color-surface-muted); box-shadow: none; text-align: center; }
.cv-composer { display: grid; gap: var(--space-xs); padding: var(--space-md) var(--space-lg); border-top: 1px solid var(--color-border); background: var(--color-surface); }
.cv-message-input { min-height: 90px; }
.cv-send-row { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: var(--space-xs); }
.cv-queue-help { margin: var(--space-xs) 0 0; color: var(--color-text-3); }
.cv-outbox { padding: var(--space-md) var(--space-lg); border-top: 1px solid var(--color-border); background: var(--color-surface-muted); }
.cv-outbox h3 { margin-bottom: var(--space-sm); }
.cv-queue { list-style: none; display: grid; gap: var(--space-xs); padding: 0; margin: 0; max-height: 240px; overflow-y: auto; overscroll-behavior: contain; }
.cv-queue-item { padding: var(--space-sm); background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md); }
.cv-queue-item p { font-size: var(--text-sm); margin: var(--space-xs) 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---------- Objeções ---------- */
.ob-toolbar { justify-content: space-between; align-items: flex-start; }
.ob-toolbar h2, .ob-toolbar h3, .ob-toolbar p { margin-bottom: var(--space-2xs); }
.ob-toolbar > .field { min-width: 180px; }
.ob-columns { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
.ob-ranking, .ob-excerpts { display: grid; gap: var(--space-xs); }
.ob-rank-item { display: grid; gap: var(--space-xs); width: 100%; min-width: 0; padding: var(--space-sm) var(--space-md); border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-surface-muted); color: var(--color-ink); text-align: left; transition: border-color var(--duration-fast) var(--ease), background var(--duration-fast) var(--ease); }
.ob-category:hover, .ob-category[aria-pressed="true"] { border-color: var(--color-brand); background: var(--color-brand-softer); }
.ob-bar-label { justify-content: space-between; font-weight: var(--weight-semibold); }
.ob-bar { display: block; appearance: none; width: 100%; height: 8px; border: 0; overflow: hidden; border-radius: var(--radius-pill); background: var(--color-surface-sunken); color: var(--color-brand); }
.ob-bar::-webkit-progress-bar { background: var(--color-surface-sunken); }
.ob-bar::-webkit-progress-value { background: var(--color-brand); border-radius: var(--radius-pill); transition: width .2s; }
.ob-bar::-moz-progress-bar { background: var(--color-brand); border-radius: var(--radius-pill); }
.ob-caption { font-size: var(--text-caption); margin: 0; color: var(--color-text-3); }
.ob-excerpt { padding: var(--space-md); border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-surface-muted); }
.ob-excerpt blockquote { margin: var(--space-sm) 0; padding: var(--space-xs) var(--space-md); border-left: 3px solid var(--color-brand); background: var(--color-surface); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; font-family: var(--font-display); font-style: italic; font-size: 1.02rem; color: var(--color-ink); white-space: pre-wrap; overflow-wrap: anywhere; }
.ob-excerpt time { font-size: var(--text-caption); color: var(--color-text-3); }
.ob-switch { display: inline-flex; align-items: center; gap: var(--space-xs); min-height: 44px; cursor: pointer; font-weight: var(--weight-semibold); }
.ob-switch input { width: 18px; height: 18px; accent-color: var(--color-brand); }
.ob-lead { max-width: 100%; white-space: normal; text-align: left; }

/* ---------- Leads ---------- */
.ld-filters { display: grid; grid-template-columns: minmax(0, 2fr) minmax(180px, 1fr); gap: var(--space-md); }
.ld-toolbar, .ld-heading { justify-content: space-between; }
.ld-toolbar p, .ld-heading h3, .ld-heading p { margin: 0; }
.ld-name { display: block; max-width: 100%; padding: 2px 0; border: 0; background: transparent; color: var(--color-ink); font-weight: var(--weight-extrabold); text-align: left; overflow-wrap: anywhere; }
.ld-name:hover { color: var(--color-brand-text); text-decoration: underline; text-underline-offset: 3px; }
.ld-phone { display: block; white-space: nowrap; font-size: var(--text-caption); color: var(--color-text-3); font-variant-numeric: tabular-nums; }
.ld-profile { max-width: 260px; min-width: 140px; color: var(--color-text-2); }
.ld-closer { display: inline-flex; align-items: center; gap: var(--space-xs); font-weight: var(--weight-semibold); }
.ld-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; background: var(--closer-1); }
.ld-dot-indigo { background: var(--closer-2); }
.ld-dot-muted { background: var(--closer-3); }
.ld-details { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-md); margin: 0; }
.ld-details > div { padding: var(--space-sm) var(--space-md); border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-surface-muted); }
.ld-details dt { font-size: var(--text-caption); font-weight: var(--weight-bold); color: var(--color-text-3); margin-bottom: 4px; }
.ld-details dd { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--color-ink); font-weight: var(--weight-semibold); }
.ld-heading { align-items: flex-start; }
.ld-switch { display: flex; gap: var(--space-sm); align-items: flex-start; min-height: 44px; cursor: pointer; }
.ld-switch input { accent-color: var(--color-brand); width: 18px; height: 18px; flex-shrink: 0; margin-top: 4px; }
.ld-control-note { margin: 0; font-size: var(--text-sm); color: var(--color-text-3); }
.ld-records { display: grid; gap: var(--space-sm); }
.ld-record { border-top: 1px solid var(--color-border); padding-top: var(--space-md); }
.ld-record p { margin: var(--space-xs) 0; }
.ld-record time { font-size: var(--text-caption); color: var(--color-text-3); }
.ld-prewrap, .ld-quote { white-space: pre-wrap; overflow-wrap: anywhere; }
.ld-quote { margin: var(--space-sm) 0; padding: 0 0 0 var(--space-sm); border-left: 3px solid var(--color-brand); color: var(--color-ink); }

/* ---------- Configuração ---------- */
.cf-tabs { border-radius: var(--radius-pill); }
.cf-content { display: grid; min-width: 0; gap: var(--space-md); }
.cf-content > * { min-width: 0; }
.cf-content h2 { font-size: 1.3rem; }
.cf-form-grid { align-items: start; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-md); }
.cf-section { display: grid; gap: var(--space-md); }
.cf-section h3, .cf-section p { margin-bottom: 0; }
.cf-hint { color: var(--color-text-3); font-size: var(--text-label); margin: 0; }
.cf-toggle { display: grid; gap: var(--space-xs); min-height: 44px; }
.cf-toggle > label { cursor: pointer; font-weight: var(--weight-semibold); }
.cf-switch-input { width: 18px; height: 18px; accent-color: var(--color-brand); margin-top: 4px; flex-shrink: 0; }
.cf-editor-list { display: grid; gap: var(--space-sm); }
.cf-editor-item { display: grid; gap: var(--space-md); padding: var(--space-md); border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-surface-muted); }
.cf-item-heading { display: flex; align-items: center; justify-content: space-between; gap: var(--space-xs); flex-wrap: wrap; }
.cf-editor-actions { display: flex; gap: var(--space-xs); flex-wrap: wrap; }
.cf-closers { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-md); }
.cf-phone-list { display: grid; gap: var(--space-xs); }
.cf-phone-row, .cf-phone-add { display: flex; align-items: center; gap: var(--space-sm); flex-wrap: wrap; }
.cf-phone-row { padding: 6px 6px 6px var(--space-md); border: 1px solid var(--color-border); border-radius: var(--radius-pill); background: var(--color-surface-muted); }
.cf-phone-add > .field { flex: 1 1 220px; }
.cf-phone-row > span { flex: 1; font-variant-numeric: tabular-nums; font-weight: var(--weight-semibold); }
.cf-command { display: block; max-width: 100%; overflow-x: auto; padding: var(--space-md); margin: 0; border: 0; border-radius: var(--radius-md); color: #e6e9f0; background: var(--color-ink); font-family: var(--font-mono); font-size: var(--text-code); white-space: pre; }
.cf-savebar { position: sticky; bottom: var(--space-md); z-index: 2; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: var(--space-sm); padding: var(--space-sm) var(--space-sm) var(--space-sm) var(--space-lg); border: 1px solid var(--color-border); border-radius: var(--radius-pill); background: var(--color-surface); box-shadow: var(--shadow-md); }
.cf-dirty { font-size: var(--text-sm); font-weight: var(--weight-semibold); color: var(--color-text-2); }
.cf-savebar .btn-primary { margin-left: auto; }
.cf-feedback:empty { display: none; }
.cf-view input[type="color"] { min-height: 44px; padding: 4px; cursor: pointer; }

@media (max-width: 900px) {
  .cf-savebar { bottom: calc(88px + env(safe-area-inset-bottom)); }
}
@media (max-width: 760px) {
  .ob-columns { grid-template-columns: minmax(0, 1fr); }
  .cv-layout { grid-template-columns: minmax(0, 1fr); }
  .cv-layout:not(.cv-has-selection) .cv-thread { display: none; }
  .cv-layout.cv-has-selection .cv-sidebar { display: none; }
  .cv-back { display: inline-flex; flex-basis: auto; }
  .cv-thread-header { flex-direction: column; padding: var(--space-md); }
  .cv-thread-identity { flex: auto; width: 100%; }
  .cv-messages { height: 52vh; padding: var(--space-md); }
  .cv-bubble { max-width: 88%; }
  .cv-conversation, .cv-list-header, .cv-composer, .cv-outbox { padding-left: var(--space-md); padding-right: var(--space-md); }
  .ld-filters, .ld-details, .cf-form-grid, .cf-closers { grid-template-columns: minmax(0, 1fr); }
  /* Tabela de leads vira lista de cartões no celular. */
  .ld-table-wrap { border: 0; overflow: visible; background: transparent; }
  .ld-table, .ld-table tbody { display: block; }
  .ld-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .ld-table tbody { display: grid; gap: var(--space-sm); }
  .ld-table tr { display: grid; gap: 2px; padding: var(--space-md); border: 1px solid var(--color-border); border-radius: var(--radius-lg); background: var(--color-surface); box-shadow: var(--shadow-xs); }
  .ld-table tbody tr:hover { background: var(--color-surface); }
  .ld-table td { display: grid; grid-template-columns: minmax(96px, .7fr) minmax(0, 1.3fr); gap: var(--space-sm); padding: 6px 0; border: 0; max-width: 100%; }
  .ld-table td::before { content: attr(data-label); color: var(--color-text-3); font-family: var(--font-sans); font-size: var(--text-caption); font-weight: var(--weight-bold); }
  .ld-table td:first-child { display: block; padding-bottom: var(--space-xs); margin-bottom: 4px; border-bottom: 1px solid var(--color-border); }
  .ld-table td:first-child::before { display: none; }
  .ld-phone { white-space: normal; }
  .ld-profile { min-width: 0; }
  .cf-savebar { border-radius: var(--radius-lg); padding: var(--space-sm); }
  .cf-savebar .btn-primary { width: 100%; }
}
@media (max-width: 420px) {
  .ob-toolbar > .field { width: 100%; }
  .ob-excerpt { padding: var(--space-sm); }
}
@media (prefers-reduced-motion: reduce) {
  .ob-bar::-webkit-progress-value { transition: none; }
}

/* ---------- WhatsApp: conexão e QR Code ---------- */
.wa-view { min-width: 0; max-width: 780px; }
.wa-toolbar h2, .wa-status h3, .wa-command h3, .wa-actions h3 { margin: 0; }
.wa-toolbar h2 { font-size: 1.35rem; }
.wa-status h3, .wa-command h3, .wa-actions h3 { font-size: var(--text-h3); }
.wa-status .row { justify-content: space-between; }
.wa-status .row h3 { margin-right: auto; }
.wa-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--color-text-3); flex: none; box-shadow: 0 0 0 4px var(--color-surface-sunken); }
.wa-dot-green { background: var(--color-success); box-shadow: 0 0 0 4px var(--color-success-soft); }
.wa-dot-red { background: var(--color-danger); box-shadow: 0 0 0 4px var(--color-danger-soft); }
.wa-dot-amber { background: var(--color-warning); box-shadow: 0 0 0 4px var(--color-warning-soft); }
.wa-qr-wrap { display: flex; justify-content: center; padding: var(--space-lg); border-radius: var(--radius-lg); background: var(--color-surface-muted); border: 1px dashed var(--color-border-strong); }
.wa-qr { display: block; max-width: 100%; height: auto; padding: var(--space-sm); background: var(--white); border-radius: var(--radius-md); box-shadow: var(--shadow-sm); image-rendering: pixelated; }
.wa-steps { margin: 0; padding-left: var(--space-lg); color: var(--color-text-2); display: grid; gap: 4px; }
.wa-steps li::marker { color: var(--color-brand); font-weight: var(--weight-extrabold); }
.wa-code { letter-spacing: .14em; color: var(--color-brand-text); font-weight: var(--weight-extrabold); font-size: 1.4rem; }
.wa-actions .row > .btn { flex: 1 1 200px; }
@media (max-width: 600px) { .wa-qr { width: 100%; } .wa-qr-wrap { padding: var(--space-sm); } }
