:root {
  --bg: #0f1117;
  --surface: #171b24;
  --surface-2: #1f2533;
  --border: #2a3142;
  --text: #e8ecf4;
  --muted: #9aa4b8;
  --primary: #4f8cff;
  --primary-hover: #3d78ea;
  --success: #3ecf8e;
  --danger: #ff6b6b;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Inter,Segoe UI,Roboto,sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.hidden { display: none !important; }

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: rgba(15,17,23,.9);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand { display: flex; gap: .75rem; align-items: center; }
.icon {
  width: 1.15em;
  height: 1.15em;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.brand-icon {
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 10px;
  font-size: 1.35rem;
  color: var(--primary);
  background: rgba(79, 140, 255, .14);
  border: 1px solid rgba(79, 140, 255, .3);
}
.brand h1 { margin: 0; font-size: 1.1rem; }
.brand p { margin: 0; color: var(--muted); font-size: .85rem; }

.header-actions { display: flex; gap: .75rem; align-items: center; }
.user-email { color: var(--muted); font-size: .9rem; }

main { max-width: 1200px; margin: 0 auto; padding: 1.5rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.card-header { margin-bottom: 1rem; }
.card-header h2 { margin: 0 0 .25rem; font-size: 1.1rem; }
.card-header p { margin: 0; color: var(--muted); font-size: .9rem; }

.login-card { max-width: 420px; margin: 4rem auto; text-align: center; }
.login-card h2 { margin-top: 0; }

.grid {
  display: grid;
  grid-template-columns: 1.4fr .8fr;
  gap: 1rem;
}

label {
  display: block;
  margin-bottom: 1rem;
  font-size: .9rem;
  color: var(--muted);
}

input, textarea, select {
  width: 100%;
  margin-top: .35rem;
  padding: .7rem .85rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
}

textarea { resize: vertical; min-height: 80px; }

.row { display: flex; gap: 1rem; }
.half { flex: 1; }

.checkbox {
  display: flex;
  align-items: center;
  gap: .5rem;
  color: var(--text);
}

.checkbox input { width: auto; margin: 0; }

.form-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: .5rem;
}

.btn {
  border: none;
  border-radius: 8px;
  padding: .65rem 1rem;
  font: inherit;
  cursor: pointer;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover { background: var(--primary-hover); }

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}

.btn-danger {
  background: rgba(255, 107, 107, .16);
  color: #ffb4b4;
  border: 1px solid rgba(255, 107, 107, .45);
}

.btn-danger:hover:not(:disabled) {
  background: rgba(255, 107, 107, .28);
}

.btn-danger-outline {
  background: transparent;
  color: #ffb4b4;
  border: 1px solid rgba(255, 107, 107, .45);
}

.btn-danger-outline:hover:not(:disabled) {
  background: rgba(255, 107, 107, .12);
}

.btn:disabled {
  opacity: .5;
  cursor: not-allowed;
}

.save-status { color: var(--muted); font-size: .9rem; }
.save-status.ok { color: var(--success); }
.save-status.err { color: var(--danger); }

.error { color: var(--danger); margin-top: 1rem; }
.hint { color: var(--muted); font-size: .85rem; margin-top: -.5rem; }

.integration-card {
  background: var(--surface-2);
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 1rem;
}

.integration-card.disabled { opacity: .85; }

.integration-head {
  display: flex;
  gap: .75rem;
  align-items: center;
  margin-bottom: .75rem;
}

.integration-icon { font-size: 1.5rem; }
.integration-head h3 { margin: 0; font-size: 1rem; }
.integration-text { color: var(--muted); font-size: .9rem; }

.badge {
  display: inline-block;
  font-size: .75rem;
  padding: .15rem .5rem;
  border-radius: 999px;
}

.badge-muted {
  background: #2a3142;
  color: var(--muted);
}

.badge-connected {
  background: rgba(62, 207, 142, .14);
  color: var(--success);
}

.tips h3 { margin-top: 0; font-size: 1rem; }
.tips ul { margin: 0; padding-left: 1.1rem; color: var(--muted); font-size: .9rem; }
.tips li + li { margin-top: .35rem; }

.side-col { display: flex; flex-direction: column; gap: 1rem; }

.wa-instance-form label {
  margin-bottom: .75rem;
}

.wa-instance-actions {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
  margin-bottom: .5rem;
}

.wa-instance-status {
  margin: 0;
}

.wa-qr-wrap {
  margin-top: .75rem;
  padding: .75rem;
  border: 1px dashed var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  display: flex;
  justify-content: center;
}

#wa-qr-image {
  width: min(220px, 100%);
  height: auto;
  border-radius: 8px;
  background: #fff;
  padding: .4rem;
}

.wa-instance-list {
  margin-top: .75rem;
  display: flex;
  flex-direction: column;
  gap: .45rem;
}

.wa-instance-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .45rem .6rem;
  background: var(--surface-2);
  font-size: .82rem;
}

.wa-instance-item strong {
  font-size: .86rem;
}

.tabs {
  display: flex;
  gap: .5rem;
  margin-bottom: 1rem;
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 8px;
  padding: .55rem 1rem;
  font: inherit;
  cursor: pointer;
}

.tab:hover { color: var(--text); }
.tab.active .icon { color: var(--primary); }

.tab.active {
  color: var(--text);
  border-color: var(--primary);
  background: var(--surface-2);
}

.conversations-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 1rem;
  min-height: 520px;
}

.conversations-list-wrap .card-header,
.conversation-detail-wrap .card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.conversations-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 440px;
  overflow-y: auto;
}

.conversations-list li {
  border-top: 1px solid var(--border);
  padding: .75rem;
  cursor: pointer;
}

.conversations-list li:hover,
.conversations-list li.active {
  background: var(--surface-2);
}

.conv-name { font-weight: 600; font-size: .95rem; }
.conv-meta { color: var(--muted); font-size: .8rem; margin-top: .2rem; }
.conv-preview { color: var(--muted); font-size: .85rem; margin-top: .35rem; }
.conv-handoff-tag {
  display: inline-block;
  margin-top: .35rem;
  font-size: .75rem;
  color: #ffb347;
  background: rgba(255, 179, 71, .12);
  padding: .15rem .45rem;
  border-radius: 999px;
}

.conversation-detail-header {
  flex-wrap: wrap;
  gap: .75rem;
}

.conversation-actions {
  display: flex;
  gap: .5rem;
  align-items: center;
  flex-wrap: wrap;
}

.badge-handoff {
  background: rgba(255, 179, 71, .15);
  color: #ffb347;
  border: 1px solid rgba(255, 179, 71, .35);
}

.conversation-empty {
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 400px;
  text-align: center;
  padding: 1rem;
}

.conversation-messages {
  display: flex;
  flex-direction: column;
  gap: .65rem;
  max-height: 440px;
  overflow-y: auto;
  padding-right: .25rem;
}

.msg-bubble {
  max-width: 85%;
  padding: .6rem .85rem;
  border-radius: 10px;
  font-size: .9rem;
  white-space: pre-wrap;
}

.msg-bubble.user {
  align-self: flex-end;
  background: #1e3a5f;
}

.msg-bubble.assistant {
  align-self: flex-start;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.msg-bubble.human {
  align-self: flex-start;
  background: #2a3d2e;
  border: 1px solid #3d5c44;
}

.msg-time {
  font-size: .75rem;
  color: var(--muted);
  margin-top: .2rem;
}

.msg-role {
  font-size: .72rem;
  color: var(--muted);
  margin-bottom: .15rem;
  text-transform: uppercase;
  letter-spacing: .03em;
}

.tracking-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.tracking-header h2 { margin: 0 0 .25rem; }
.tracking-header p { margin: 0; color: var(--muted); }

.tracking-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: .5rem;
  flex-wrap: wrap;
}

.field-label {
  display: block;
  margin: 0 0 .65rem;
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
}

.whatsapp-mode-block {
  margin-bottom: 0;
}

.mode-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: .75rem;
}

label.mode-card {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: .85rem;
  margin: 0;
  margin-bottom: 0;
  padding: 1rem 1.05rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}

.mode-card:hover {
  border-color: #3d4a63;
  background: #232a38;
}

.mode-card:has(.mode-card-input:checked),
.mode-card.is-selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px rgba(79, 140, 255, .35);
  background: rgba(79, 140, 255, .08);
}

.mode-card-input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  clip: rect(0, 0, 0, 0);
  overflow: hidden;
}

.mode-card-check {
  width: 16px;
  height: 16px;
  margin-top: .1rem;
  border-radius: 999px;
  border: 2px solid #54617b;
  background: transparent;
  flex-shrink: 0;
  transition: border-color .15s ease, box-shadow .15s ease;
}

.mode-card.is-selected .mode-card-check {
  border-color: var(--primary);
  box-shadow: inset 0 0 0 3px rgba(79, 140, 255, .25);
}

.mode-card-icon {
  flex-shrink: 0;
  width: 2.4rem;
  height: 2.4rem;
  display: grid;
  place-items: center;
  border-radius: 8px;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .04em;
  background: var(--surface);
  border: 1px solid var(--border);
}

.mode-card-icon { font-size: 1.15rem; }
.mode-card-icon-attend { background: rgba(79, 140, 255, .12); color: #8db3ff; }
.mode-card-icon-observe { background: rgba(62, 207, 142, .12); color: var(--success); }
.mode-card-icon-manual { background: rgba(255, 193, 77, .14); color: #ffc14d; }

.mode-card-copy {
  display: flex;
  flex-direction: column;
  gap: .25rem;
  min-width: 0;
}

.mode-card-copy strong {
  font-size: .95rem;
  color: var(--text);
  font-weight: 600;
}

.mode-card-copy span {
  font-size: .82rem;
  line-height: 1.45;
  color: var(--muted);
}

.mode-status-banner {
  margin: .85rem 0 0;
  padding: .65rem .85rem;
  border-radius: 8px;
  font-size: .85rem;
  line-height: 1.45;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--muted);
}

.mode-status-banner.is-attend {
  border-color: rgba(79, 140, 255, .35);
  color: #c5d9ff;
  background: rgba(79, 140, 255, .08);
}

.mode-status-banner.is-observe {
  border-color: rgba(62, 207, 142, .35);
  color: #b8f0d4;
  background: rgba(62, 207, 142, .08);
}

.mode-status-banner.is-manual {
  border-color: rgba(255, 193, 77, .35);
  color: #ffe2a8;
  background: rgba(255, 193, 77, .08);
}

.observer-settings-panel {
  padding: 1rem 1.05rem;
  margin-bottom: 1.25rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
}

label.observer-toggle {
  margin: 0;
  margin-bottom: 0;
  align-items: flex-start;
  gap: .65rem;
  color: var(--text);
}

.observer-toggle input {
  width: auto;
  margin: .15rem 0 0;
  flex-shrink: 0;
}

.observer-toggle span {
  display: flex;
  flex-direction: column;
  gap: .15rem;
}

.observer-toggle strong {
  font-size: .92rem;
  color: var(--text);
  font-weight: 600;
}

.observer-toggle small {
  font-size: .8rem;
  color: var(--muted);
  line-height: 1.4;
}

.observer-note {
  margin: .75rem 0 0;
  padding-top: .75rem;
  border-top: 1px solid var(--border);
  font-size: .8rem;
  color: var(--muted);
  line-height: 1.45;
}

.observer-layout {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1rem;
  align-items: stretch;
  margin-bottom: 1.25rem;
}

.observer-controls {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.observer-help {
  margin: 0;
  padding: 1rem 1.05rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
}

.observer-help h3 {
  margin: 0 0 .7rem;
  font-size: .9rem;
}

.observer-help ol {
  margin: 0;
  padding-left: 1rem;
  color: var(--muted);
  font-size: .84rem;
}

.observer-help li + li {
  margin-top: .45rem;
}

.analysis-section-head {
  margin-bottom: .75rem;
}

.analysis-section-head h3 {
  margin: 0;
  font-size: .95rem;
  font-weight: 600;
  color: var(--text);
}

.checkbox.compact {
  margin: 0 .5rem 0 0;
  white-space: nowrap;
}

.tracking-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1rem;
}

.metric-card {
  display: flex;
  flex-direction: column;
  gap: .35rem;
}

.metric-label {
  color: var(--muted);
  font-size: .8rem;
}

.metric-card strong {
  font-size: 1.7rem;
  line-height: 1.2;
}

.tracking-funnel {
  display: flex;
  flex-direction: column;
  gap: .9rem;
}

.funnel-heading {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: .3rem;
  font-size: .9rem;
}

.funnel-heading span { color: var(--muted); }

.funnel-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-2);
}

.funnel-bar {
  height: 100%;
  min-width: 0;
  border-radius: inherit;
  background: var(--primary);
  transition: width .2s ease;
}

.tracking-empty {
  color: var(--muted);
  text-align: center;
  margin: 1.5rem 0 .25rem;
}

.tracking-source-card { margin-bottom: 1rem; }

.tracking-source-form {
  display: grid;
  grid-template-columns: 1fr 1.4fr auto;
  align-items: end;
  gap: .75rem;
}

.tracking-source-form label { margin: 0; }
.tracking-source-form .btn { margin-bottom: 0; }

.tracking-sources-list {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  margin-top: 1rem;
}

.tracking-source-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
}

.tracking-source-item div {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.tracking-source-item span {
  color: var(--muted);
  font-size: .8rem;
}

.tracking-source-item code {
  color: var(--muted);
  font-size: .78rem;
  word-break: break-all;
}

.observer-card { margin-bottom: 1rem; }

.observer-card > .card-header { margin-bottom: 1.25rem; }

.analysis-list {
  display: flex;
  flex-direction: column;
  gap: .75rem;
  margin-top: 1rem;
}

.analysis-item {
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
}

.analysis-item-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.analysis-item-header > div {
  display: flex;
  flex-direction: column;
}

.analysis-item-header span {
  color: var(--muted);
  font-size: .8rem;
}

.analysis-summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: .75rem;
  margin-top: .9rem;
}

.analysis-summary div {
  display: flex;
  flex-direction: column;
}

.analysis-summary span {
  color: var(--muted);
  font-size: .75rem;
}

.analysis-summary strong { font-size: .9rem; }

.analysis-reason {
  color: var(--muted);
  font-size: .88rem;
  margin: .9rem 0;
}

.analysis-actions {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
}

.analysis-actions select {
  width: auto;
  min-width: 165px;
  margin: 0;
  padding: .6rem .75rem;
}

.leads-card { margin-bottom: 1rem; }

.leads-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.leads-header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  justify-content: flex-end;
}

.leads-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .65rem 0 .35rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: .25rem;
}

.lead-select-all-label {
  margin: 0;
  color: var(--text);
}

.lead-selection-count {
  color: var(--muted);
  font-size: .82rem;
}

.leads-list {
  display: flex;
  flex-direction: column;
}

.lead-identity,
.lead-field {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.lead-identity span,
.lead-field span,
.lead-field small {
  color: var(--muted);
  font-size: .78rem;
  overflow-wrap: anywhere;
}

.lead-field strong { font-size: .9rem; }

.lead-filters {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin: .25rem 0 .5rem;
}

.lead-filter {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  padding: .45rem .85rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: .85rem;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease, color .15s ease;
}

.lead-filter:hover { border-color: #3d4a63; color: var(--text); }

.lead-filter.active {
  border-color: var(--primary);
  background: rgba(79, 140, 255, .1);
  color: var(--text);
}

.lead-filter-count {
  min-width: 1.35rem;
  padding: .05rem .4rem;
  border-radius: 999px;
  background: var(--surface-2);
  font-size: .75rem;
  text-align: center;
}

.leads-toolbar .btn { padding: .35rem .7rem; font-size: .8rem; }

.lead-status-badge {
  align-self: flex-start;
  padding: .15rem .55rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
  background: #2a3142;
  color: var(--muted);
}

.lead-status-badge.is-qualified { background: rgba(79, 140, 255, .16); color: #b9d0ff; }
.lead-status-badge.is-won { background: rgba(62, 207, 142, .16); color: var(--success); }
.lead-status-badge.is-unqualified { background: rgba(154, 164, 184, .14); color: var(--muted); }
.lead-status-badge.is-lost { background: rgba(255, 107, 107, .14); color: #ffb4b4; }


.sale-dialog {
  width: min(520px, calc(100vw - 2rem));
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.sale-dialog::backdrop {
  background: rgba(0, 0, 0, .7);
}

.conversions-card { margin-bottom: 1rem; }

.subtabs {
  display: flex;
  gap: .25rem;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
}

.subtab,
.settings-tab {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  padding: .6rem .9rem;
  margin-bottom: -1px;
  font: inherit;
  cursor: pointer;
}

.subtab:hover,
.settings-tab:hover { color: var(--text); }

.subtab.active,
.settings-tab.active {
  color: var(--text);
  border-bottom-color: var(--primary);
}

#tracking-status { margin: 0 0 1rem; }
#tracking-status:empty { display: none; }

.tracking-section {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.tracking-section .card { margin-bottom: 0; }
.tracking-section .tracking-stats { margin-bottom: 0; }

.integration-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.integration-panel {
  display: flex;
  flex-direction: column;
  gap: .85rem;
}

.integration-panel .integration-head { margin-bottom: 0; }
.integration-panel .integration-text { margin: 0; }
.integration-panel .hint { margin: 0; }
.integration-panel code {
  font-size: .8rem;
  color: var(--text);
  background: var(--surface-2);
  padding: .05rem .3rem;
  border-radius: 4px;
}

.integration-planned { border-style: dashed; }
.integration-planned .integration-text { opacity: .9; }

.integration-actions {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
  margin-top: auto;
}

.integration-icon-meta,
.integration-icon-google {
  display: inline-flex;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  font-size: 1.1rem;
  font-weight: 700;
}

.integration-icon-meta {
  background: rgba(24, 119, 242, .18);
  color: #6ea8ff;
}

.integration-icon-google {
  background: rgba(234, 67, 53, .16);
  color: #ff8a80;
}

.badge-warning {
  background: rgba(255, 179, 71, .15);
  color: #ffb347;
}

.queue-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: .5rem;
}

.queue-stat {
  display: flex;
  flex-direction: column;
  padding: .5rem .65rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
}

.queue-stat span {
  color: var(--muted);
  font-size: .72rem;
}

.queue-stat strong { font-size: 1.05rem; }
.queue-stat.is-sent strong { color: var(--success); }
.queue-stat.is-failed strong { color: var(--danger); }

.test-actions {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
  margin-bottom: .75rem;
}

.test-steps {
  margin: 0 0 1rem;
  padding-left: 1.2rem;
  color: var(--muted);
  font-size: .9rem;
}

.test-steps li + li { margin-top: .35rem; }
.test-steps strong { color: var(--text); }

.conversions-list {
  display: flex;
  flex-direction: column;
}

.conversion-item {
  display: grid;
  grid-template-columns: minmax(170px, 1.2fr) 1fr .6fr 1.4fr auto;
  align-items: center;
  gap: 1rem;
  padding: .85rem 0;
  border-top: 1px solid var(--border);
}

.conversion-destinations {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .5rem;
}

.conversion-destination {
  display: flex;
  flex-direction: column;
}

.conversion-destination span,
.conversion-date {
  color: var(--muted);
  font-size: .75rem;
}

.conversion-destination strong { font-size: .8rem; }

/* ===== Acessibilidade: foco visível ===== */
button:focus-visible,
summary:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ===== Avisos (toasts) ===== */
.toast-root {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  max-width: min(380px, calc(100vw - 2rem));
}

.toast {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: .7rem .9rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  font-size: .88rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .35);
  cursor: pointer;
  animation: toast-in .18s ease-out;
}

.toast.is-ok { border-color: rgba(62, 207, 142, .45); }
.toast.is-err { border-color: rgba(255, 107, 107, .55); }

.toast-action {
  flex-shrink: 0;
  padding: .2rem .5rem;
  border: 0;
  border-radius: 6px;
  background: rgba(79, 140, 255, .16);
  color: #b9d0ff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .toast { animation: none; }
}

/* ===== Janela de confirmação ===== */
.confirm-dialog {
  width: min(440px, calc(100vw - 2rem));
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.confirm-dialog::backdrop { background: rgba(0, 0, 0, .7); }
.confirm-dialog h2 { margin: 0 0 .5rem; font-size: 1.05rem; }
.confirm-dialog p { margin: 0 0 1rem; color: var(--muted); font-size: .9rem; }
.confirm-actions { justify-content: flex-end; }

/* ===== Card de lead ===== */
.lead-bulk-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .5rem;
}

.lead-card {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr) auto;
  align-items: center;
  gap: .9rem;
  padding: .9rem .75rem;
  border-top: 1px solid var(--border);
  transition: background .15s ease;
}

.lead-card:hover { background: rgba(255, 255, 255, .02); }

.lead-card-check input { width: auto; margin: 0; }

.lead-avatar {
  width: 2.4rem;
  height: 2.4rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #2a3142;
  color: var(--text);
  font-size: .8rem;
  font-weight: 700;
}

.lead-avatar.is-google { background: rgba(234, 67, 53, .18); color: #ff9d94; }
.lead-avatar.is-meta { background: rgba(24, 119, 242, .2); color: #8db9ff; }
.lead-avatar.is-whatsapp { background: rgba(62, 207, 142, .16); color: var(--success); }

.lead-main {
  display: flex;
  flex-direction: column;
  gap: .25rem;
  min-width: 0;
}

.lead-main-top {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .5rem;
}

.lead-name { font-size: .95rem; }
.lead-time { color: var(--muted); font-size: .78rem; }
.lead-contact { color: var(--muted); font-size: .82rem; overflow-wrap: anywhere; }

.lead-chips {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  margin-top: .1rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  padding: .12rem .55rem;
  border-radius: 999px;
  background: #2a3142;
  color: var(--muted);
  font-size: .75rem;
  white-space: nowrap;
}

.chip.is-ok { background: rgba(62, 207, 142, .14); color: var(--success); }
.chip.is-err { background: rgba(255, 107, 107, .14); color: #ffb4b4; }
.chip.is-warn { background: rgba(255, 179, 71, .15); color: #ffb347; }
.chip.is-google { background: rgba(234, 67, 53, .16); color: #ff9d94; }
.chip.is-meta { background: rgba(24, 119, 242, .18); color: #8db9ff; }
.chip.is-whatsapp { background: rgba(62, 207, 142, .14); color: var(--success); }

.lead-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: .5rem;
}

.lead-side .lead-status-badge { align-self: flex-end; }

.lead-buttons {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: .4rem;
}

.lead-buttons .btn { padding: .4rem .75rem; font-size: .82rem; }

.lead-card.is-discarded { opacity: .65; box-shadow: inset 3px 0 0 rgba(255, 107, 107, .5); }
.lead-card.is-unqualified { box-shadow: inset 3px 0 0 rgba(154, 164, 184, .5); }
.lead-card.is-archived { opacity: .55; }

/* ===== Menu "⋯" ===== */
.row-menu { position: relative; }

.row-menu > summary {
  list-style: none;
  padding: .4rem .7rem;
  font-size: 1rem;
  line-height: 1.2;
  cursor: pointer;
}

.row-menu > summary::-webkit-details-marker { display: none; }

.row-menu-list {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  z-index: 20;
  min-width: 240px;
  display: flex;
  flex-direction: column;
  padding: .35rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  box-shadow: 0 10px 28px rgba(0, 0, 0, .4);
}

.row-menu-list button {
  padding: .55rem .7rem;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--text);
  font: inherit;
  font-size: .85rem;
  text-align: left;
  cursor: pointer;
}

.row-menu-list button:hover { background: rgba(255, 255, 255, .06); }
.row-menu-list button.is-danger { color: #ffb4b4; }

@media (max-width: 900px) {
  .grid { grid-template-columns: 1fr; }
  .row { flex-direction: column; }
  .conversations-layout { grid-template-columns: 1fr; }
  .tracking-header { flex-direction: column; }
  .tracking-actions { justify-content: flex-start; }
  .tracking-stats { grid-template-columns: repeat(2, 1fr); }
  .tracking-source-form { grid-template-columns: 1fr; align-items: stretch; }
  .analysis-summary { grid-template-columns: repeat(2, 1fr); }
  .lead-card { grid-template-columns: auto auto minmax(0, 1fr); }
  .lead-side { grid-column: 1 / -1; flex-direction: row; align-items: center; justify-content: space-between; }
  .lead-side .lead-status-badge { align-self: center; }
  .conversion-item { grid-template-columns: 1fr 1fr; }
  .integration-grid { grid-template-columns: 1fr; }
  .observer-layout { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .tracking-stats { grid-template-columns: 1fr; }
  .tracking-source-item { align-items: flex-start; flex-direction: column; }
  .mode-cards { grid-template-columns: 1fr; }
  .analysis-summary { grid-template-columns: 1fr; }
  .leads-header { flex-direction: column; }
  .lead-buttons .btn, .row-menu > summary { min-height: 40px; }
  .lead-side { flex-direction: column; align-items: stretch; }
  .lead-side .lead-status-badge { align-self: flex-start; }
  .lead-buttons { justify-content: flex-start; }
  .row-menu-list { right: auto; left: 0; }
  .toast-root { left: 1rem; max-width: none; }
  .conversion-item { grid-template-columns: 1fr; }
  .queue-stats { grid-template-columns: repeat(2, 1fr); }
}

/* ---- Rodada 2/3: navegação, desempenho por origem, avisos de envio ---- */

.tabs { overflow-x: auto; }
.tab span { white-space: nowrap; }

.overview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.overview-toolbar .field-label { margin: 0; }

.period-switch {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}

.period-btn {
  border: none;
  border-radius: 7px;
  padding: .4rem .85rem;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: .88rem;
  cursor: pointer;
}

.period-btn:hover { color: var(--text); }
.period-btn.active {
  background: var(--surface-2);
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--border);
}

.origin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: .85rem;
}

.origin-card {
  display: flex;
  flex-direction: column;
  gap: .75rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
}

.origin-head {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .92rem;
}

.origin-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--muted);
}

.origin-dot.is-google { background: #ea4335; }
.origin-dot.is-meta { background: #1877f2; }
.origin-dot.is-whatsapp { background: var(--success); }

.origin-leads {
  display: flex;
  align-items: baseline;
  gap: .4rem;
}

.origin-leads strong { font-size: 2rem; line-height: 1; }
.origin-leads span { color: var(--muted); font-size: .85rem; }

.origin-rows {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: .3rem .75rem;
  margin: 0;
  font-size: .85rem;
}

.origin-rows dt { color: var(--muted); }
.origin-rows dd { margin: 0; font-weight: 600; text-align: right; }

.problems-card {
  border-color: rgba(255, 179, 71, .4);
  background: rgba(255, 179, 71, .05);
}

.problems-list { display: flex; flex-direction: column; gap: .6rem; }

.problem-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .7rem .85rem;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
}

.problem-copy { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.problem-copy small { color: var(--muted); font-size: .8rem; }
.problem-count { color: var(--muted); font-size: .85rem; white-space: nowrap; }

.delivery-alert {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  margin-bottom: 1rem;
  padding: .7rem .9rem;
  border-radius: 8px;
  border: 1px solid rgba(255, 179, 71, .4);
  background: rgba(255, 179, 71, .08);
  color: #ffd08a;
  font-size: .9rem;
}

.conversion-error {
  display: block;
  margin-top: .15rem;
  color: #ffb4b4;
  font-size: .72rem;
  cursor: help;
}

@media (max-width: 560px) {
  .tabs { gap: .35rem; }
  .tab {
    flex: 1;
    flex-direction: column;
    justify-content: center;
    gap: .2rem;
    padding: .5rem .25rem;
    font-size: .72rem;
  }
  .tab .icon { font-size: 1.25rem; }
  .overview-toolbar { flex-direction: column; align-items: flex-start; }
  .delivery-alert { flex-direction: column; align-items: flex-start; }
  .problem-item { flex-wrap: wrap; }
  .user-email { display: none; }
}

/* ---- Tela do assistente (triagem) ---- */

.agent-view { max-width: 820px; margin: 0 auto; display: flex; flex-direction: column; gap: 1rem; }
.agent-form { display: flex; flex-direction: column; gap: 1rem; }

.agent-section label:last-child { margin-bottom: 0; }

.agent-section-head {
  display: flex;
  align-items: flex-start;
  gap: .85rem;
  margin-bottom: 1.1rem;
}

.agent-section-head h2 { margin: 0 0 .15rem; font-size: 1.05rem; }
.agent-section-head p { margin: 0; color: var(--muted); font-size: .88rem; }

.agent-step {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 999px;
  background: rgba(79, 140, 255, .16);
  color: var(--primary);
  font-size: .85rem;
  font-weight: 700;
}

.field-help {
  display: block;
  margin-top: .3rem;
  color: var(--muted);
  font-size: .78rem;
  font-weight: 400;
}

.triage-toggle {
  align-items: flex-start;
  padding: .85rem 1rem;
  margin-bottom: 1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
}

.triage-toggle input { margin-top: .25rem; }
.triage-toggle small { display: block; color: var(--muted); font-weight: 400; }

#triage-options.is-off { opacity: .45; pointer-events: none; }

.triage-fields {
  display: flex;
  flex-direction: column;
  margin-bottom: 1.1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.triage-field-row {
  display: grid;
  grid-template-columns: 1fr 5.5rem 5.5rem;
  align-items: center;
  gap: .5rem;
  padding: .55rem .9rem;
  font-size: .9rem;
}

.triage-field-row + .triage-field-row { border-top: 1px solid var(--border); }
.triage-field-row small { color: var(--muted); }
.triage-field-row input[type="checkbox"] { width: 1.05rem; height: 1.05rem; margin: 0 auto; }
.triage-field-head { background: var(--surface-2); color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; }
.triage-field-head span:not(:first-child), .triage-na { text-align: center; color: var(--muted); }

.triage-preview {
  margin: -.5rem 0 1rem;
  padding: .55rem .8rem;
  border-radius: 8px;
  background: rgba(62, 207, 142, .08);
  border: 1px dashed rgba(62, 207, 142, .35);
  color: var(--text);
  font-size: .85rem;
}

.triage-preview span { color: #bff0d9; white-space: pre-line; }

.agent-advanced summary {
  display: flex;
  align-items: center;
  gap: .85rem;
  cursor: pointer;
  list-style: none;
}

.agent-advanced summary::-webkit-details-marker { display: none; }
.agent-advanced summary small { display: block; color: var(--muted); }
.agent-advanced[open] summary { margin-bottom: 1.1rem; }

.agent-savebar {
  position: sticky;
  bottom: 0;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .8rem 1rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(23, 27, 36, .96);
  backdrop-filter: blur(8px);
  z-index: 5;
}

.preview-list {
  display: flex;
  flex-direction: column;
  margin-bottom: .6rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.preview-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .6rem 1rem;
  padding: .7rem .9rem;
}

.preview-row + .preview-row { border-top: 1px solid var(--border); }
.preview-info { min-width: 0; flex: 1 1 14rem; }
.preview-info strong { display: block; font-size: .92rem; }
.preview-info small { display: block; color: var(--muted); font-size: .8rem; }
.preview-file { color: #bff0d9; word-break: break-all; }
.preview-file.is-empty { color: var(--muted); }
.preview-actions { display: flex; flex-wrap: wrap; gap: .4rem; }
.preview-actions .btn { padding: .35rem .7rem; font-size: .82rem; }
.preview-player { flex-basis: 100%; }
.preview-player video { width: 100%; max-width: 22rem; max-height: 22rem; border-radius: 8px; background: #000; }
.preview-row.is-busy { opacity: .6; pointer-events: none; }

.lead-triage {
  margin-top: .15rem;
  color: #bff0d9;
  font-size: .82rem;
}

@media (max-width: 560px) {
  .triage-field-row { grid-template-columns: 1fr 4.2rem 4.2rem; padding: .55rem .6rem; }
}
