main.chat-main {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.75rem;
  width: 100%;
  min-height: min(70vh, 560px);
}

.chat-panel {
  width: 100%;
  max-width: 460px;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.chat-log {
  min-height: 260px;
  max-height: min(50vh, 400px);
  overflow-y: auto;
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  background: var(--surface);
  -webkit-overflow-scrolling: touch;
}

.chat-msg {
  max-width: 88%;
  padding: 0.55rem 0.8rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  line-height: 1.48;
  animation: chat-in 0.25s ease;
}

@keyframes chat-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.chat-msg--bot {
  align-self: flex-start;
  background: var(--surface-muted);
  color: var(--text);
  border-bottom-left-radius: 4px;
}

.chat-msg--user {
  align-self: flex-end;
  background: var(--color-primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chat-msg--user a {
  color: #fff;
}

.chat-msg a {
  font-weight: 600;
}

.chat-msg p {
  margin: 0 0 0.5rem;
}

.chat-msg p:last-child {
  margin-bottom: 0;
}

.chat-msg ul {
  margin: 0.35rem 0 0.5rem 1.1rem;
  padding: 0;
}

.chat-msg li {
  margin-bottom: 0.25rem;
}

.chat-msg strong {
  color: var(--color-heading);
}

.chat-msg--user strong {
  color: inherit;
}

.chat-typing {
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.75rem;
  background: var(--surface-muted);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  color: var(--text-muted);
  border-bottom-left-radius: 4px;
}

.chat-typing-dots {
  display: inline-flex;
  gap: 3px;
  align-items: center;
}

.chat-typing-dots span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: typing-dot 1.2s ease-in-out infinite;
}

.chat-typing-dots span:nth-child(2) {
  animation-delay: 0.15s;
}

.chat-typing-dots span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes typing-dot {
  0%,
  60%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }
  30% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

.chat-panel.is-busy .chat-form input,
.chat-panel.is-busy .chat-form button {
  opacity: 0.65;
  pointer-events: none;
}

.chat-panel.is-busy .chat-quick button {
  pointer-events: none;
  opacity: 0.6;
}

.chat-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  padding: 0.65rem 0.75rem 0.75rem;
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.chat-quick--stack {
  flex-direction: column;
  flex-wrap: nowrap;
}

.chat-quick-btn {
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--color-heading);
  cursor: pointer;
  font-family: inherit;
  font-weight: 500;
  text-align: center;
  line-height: 1.25;
}

.chat-quick-btn--primary {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
  font-weight: 600;
}

.chat-quick-btn--primary:active,
.chat-quick-btn:active {
  transform: scale(0.98);
}

.chat-quick--stack .chat-quick-btn {
  width: 100%;
  min-height: 46px;
  padding: 0.65rem 0.85rem;
}

.chat-form {
  display: none;
  gap: 0.45rem;
  padding: 0.55rem 0.75rem;
  padding-bottom: max(0.55rem, env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: var(--surface-muted);
}

.chat-form.is-visible {
  display: flex;
}

.chat-form input {
  flex: 1;
  min-width: 0;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  font-size: 16px;
  font-family: inherit;
}

.chat-form input:focus {
  outline: 2px solid var(--accent-soft);
  border-color: var(--color-primary);
}

.chat-form button[type="submit"] {
  flex-shrink: 0;
  padding: 0.65rem 1rem;
  border: none;
  border-radius: var(--radius-pill);
  background: var(--color-primary);
  color: #fff;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  font-family: inherit;
  min-height: 44px;
}

.chat-form button[type="submit"]:hover {
  background: var(--color-heading);
}

@media (max-width: 768px) {
  .wrapper:has(.chat-main) {
    flex: 1;
    min-height: 0;
  }

  main.chat-main {
    flex: 1;
    justify-content: stretch;
    min-height: 0;
    padding: 0.5rem;
    width: 100%;
  }

  .chat-panel {
    flex: 1;
    max-width: none;
    max-height: calc(100dvh - var(--header-h) - 52px);
    border-radius: var(--radius-sm);
  }

  .chat-log {
    flex: 1;
    min-height: 200px;
    max-height: none;
  }

  .chat-quick-btn {
    min-height: 44px;
  }
}

@media (min-width: 769px) {
  main.chat-main {
    padding-top: 1.25rem;
  }
}

/* PIX no chat — espelha checkout FUNIL 2 (pages/site.css .pix-pay-*) */
.chat-msg--bot:has(.chat-pix-pay) {
  max-width: 98%;
  width: 100%;
  padding: 0.35rem;
  background: transparent;
}

.hidden {
  display: none !important;
}

.chat-pix-pay {
  margin-top: 0.25rem;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid #d8e0ea;
  box-shadow: 0 8px 28px rgba(12, 26, 46, 0.08);
  background: #fff;
  font-size: 0.82rem;
  line-height: 1.45;
}

.chat-pix-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 14px 12px;
  background: linear-gradient(135deg, #07111f 0%, #1550b0 100%);
  color: #fff;
}

.chat-pix-head-logo {
  display: block;
  max-height: 36px;
  max-width: 120px;
  object-fit: contain;
  margin-bottom: 8px;
  background: rgba(255, 255, 255, 0.92);
  border-radius: 6px;
  padding: 4px 8px;
}

.chat-pix-kicker {
  display: block;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.82;
  margin-bottom: 4px;
}

.chat-pix-title {
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.25;
  margin: 0 0 4px;
}

.chat-pix-sub,
.chat-pix-code-ref {
  margin: 0;
  font-size: 0.72rem;
  opacity: 0.88;
}

.chat-pix-code-ref {
  margin-top: 4px;
  font-weight: 600;
}

.chat-pix-timer-block {
  flex-shrink: 0;
  text-align: right;
  background: rgba(0, 0, 0, 0.22);
  padding: 6px 10px;
  border-radius: 8px;
}

.chat-pix-timer-label {
  display: block;
  font-size: 0.58rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.78;
}

.chat-pix-timer-value {
  display: block;
  font-size: 1.05rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.chat-pix-timer-value--urgente {
  color: #fca5a5;
}

.chat-pix-timer-value--expired {
  color: #fecaca;
  font-size: 0.78rem;
}

.chat-pix-body {
  padding: 14px;
}

.chat-pix-val {
  font-size: 1.45rem;
  font-weight: 800;
  color: #1351b4;
  margin: 0 0 8px;
}

.chat-pix-instructions {
  text-align: center;
  color: #243044;
  font-size: 0.8rem;
  margin: 0 0 12px;
}

.chat-pix-qr-frame {
  position: relative;
  text-align: center;
  padding: 16px 12px;
  margin-bottom: 12px;
  border: 2px solid #1351b4;
  border-radius: 12px;
  background: #fafbfc;
}

.chat-pix-qr-label {
  position: absolute;
  top: -9px;
  left: 50%;
  transform: translateX(-50%);
  background: #1351b4;
  color: #fff;
  font-size: 0.58rem;
  font-weight: 800;
  padding: 3px 10px;
  border-radius: 20px;
  letter-spacing: 0.1em;
}

.chat-pix-qr {
  display: block;
  margin: 0 auto;
  border-radius: 8px;
  max-width: 100%;
  height: auto;
}

.chat-pix-qr-loader {
  padding: 28px 8px;
  color: #5a6a7e;
  font-size: 0.78rem;
}

.chat-pix-qr-loader-bar {
  height: 4px;
  background: #e5e7eb;
  border-radius: 4px;
  overflow: hidden;
  max-width: 180px;
  margin: 0 auto 10px;
}

.chat-pix-qr-loader-fill {
  height: 100%;
  width: 40%;
  background: #1351b4;
  border-radius: 4px;
  animation: chat-pix-load 1.2s ease infinite;
}

@keyframes chat-pix-load {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(350%);
  }
}

.chat-pix-copy-block {
  background: #eef2f7;
  border: 1px solid #d8e0ea;
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 10px;
}

.chat-pix-copy-label {
  font-size: 0.65rem;
  font-weight: 700;
  color: #5a6a7e;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

.chat-pix-copy-code {
  font-family: ui-monospace, monospace;
  font-size: 9px;
  word-break: break-all;
  max-height: 72px;
  overflow-y: auto;
  line-height: 1.5;
  color: #243044;
  background: #fff;
  border: 1px solid #d8e0ea;
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 10px;
}

.chat-pix-copy {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 999px;
  background: #1351b4;
  color: #fff;
  font-weight: 800;
  font-size: 0.88rem;
  cursor: pointer;
  font-family: inherit;
}

.chat-pix-copy--ok,
.chat-pix-copy.chat-pix-copy--ok {
  background: #168821;
}

.chat-pix-wait {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 10px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #1351b4;
  margin-bottom: 8px;
}

.chat-pix-wait-dot {
  width: 8px;
  height: 8px;
  background: #1351b4;
  border-radius: 50%;
  animation: chat-pix-pulse 1.5s ease infinite;
}

.chat-pix-wait-dot--ok {
  background: #168821;
  animation: none;
}

@keyframes chat-pix-pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.35;
  }
}

.chat-pix-warn {
  font-size: 0.72rem;
  color: #5a6a7e;
  margin: 0;
  line-height: 1.45;
}

.chat-pix-error {
  margin: 8px 0 0;
  padding: 8px 10px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 8px;
  color: #9a3412;
  font-size: 0.75rem;
}

.chat-pix-regen {
  width: 100%;
  margin-top: 8px;
  padding: 11px;
  border: 1.5px solid #1351b4;
  border-radius: 999px;
  background: #fff;
  color: #1351b4;
  font-weight: 800;
  cursor: pointer;
  font-family: inherit;
}

.chat-pix--expired .chat-pix-head {
  background: linear-gradient(135deg, #451a03 0%, #9a3412 100%);
}

.chat-pix--paid {
  border-color: #a7f3d0;
}

.chat-pix--medico .chat-pix-val {
  color: #b45309;
}

.chat-pix--psico .chat-pix-val {
  color: #7c3aed;
}

.chat-pix--emissao .chat-pix-val {
  color: #0369a1;
}

.chat-pix--tox .chat-pix-val {
  color: #be123c;
}

/* Agendamento — Detran / mês / provas (FUNIL 2) */
.chat-msg--bot:has(.chat-schedule-panel) {
  max-width: 98%;
  width: 100%;
  padding: 0.35rem;
  background: transparent;
}

.chat-schedule-panel {
  border: 1px solid #d8e0ea;
  border-radius: 12px;
  background: #fff;
  padding: 12px;
  box-shadow: 0 4px 18px rgba(12, 26, 46, 0.06);
}

.chat-schedule-title {
  font-size: 0.82rem;
  font-weight: 800;
  color: #1351b4;
  text-align: center;
  margin: 0 0 10px;
  padding-bottom: 8px;
  border-bottom: 2px solid #1351b4;
}

.chat-detran-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 240px;
  overflow-y: auto;
}

.chat-detran-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d8e0ea;
  border-radius: 8px;
  background: linear-gradient(180deg, #f7f9fc 0%, #fff 100%);
  cursor: pointer;
  font-family: inherit;
  text-align: left;
}

.chat-detran-row:hover {
  border-color: #1351b4;
  box-shadow: 0 2px 10px rgba(19, 81, 180, 0.12);
}

.chat-detran-row-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 0.82rem;
  color: #243044;
}

.chat-detran-row-main small {
  font-size: 0.72rem;
  font-weight: 700;
  color: #1351b4;
  background: rgba(19, 81, 180, 0.08);
  padding: 2px 8px;
  border-radius: 4px;
  width: fit-content;
}

.chat-detran-row-cta {
  flex-shrink: 0;
  font-size: 0.75rem;
  font-weight: 700;
  color: #fff;
  background: #1351b4;
  padding: 6px 12px;
  border-radius: 6px;
}

.chat-month-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.chat-month-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 72px;
  padding: 10px 8px;
  border: 1px solid #d8e0ea;
  border-radius: 8px;
  background: linear-gradient(180deg, #f7f9fc 0%, #fff 100%);
  cursor: pointer;
  font-family: inherit;
}

.chat-month-btn:hover {
  border-color: #1351b4;
}

.chat-month-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: #243044;
}

.chat-month-meta {
  font-size: 0.68rem;
  font-weight: 600;
  color: #1351b4;
  margin-top: 4px;
}

/* Comprovante RENACH + PIX enriquecido (FUNIL 2) */
.chat-msg--bot:has(.chat-renach-doc) {
  max-width: 98%;
  width: 100%;
  padding: 0.35rem;
  background: transparent;
}

.chat-renach-doc {
  border: 1px solid #d8e0ea;
  border-radius: 12px;
  background: #fff;
  padding: 14px;
  box-shadow: 0 6px 22px rgba(12, 26, 46, 0.07);
  font-size: 0.78rem;
}

.chat-renach-head {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 2px solid #1351b4;
}

.chat-renach-logo {
  max-width: 88px;
  max-height: 44px;
  object-fit: contain;
  flex-shrink: 0;
}

.chat-renach-kicker {
  margin: 0;
  font-size: 0.62rem;
  font-weight: 700;
  color: #5a6a7e;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.chat-renach-title {
  margin: 2px 0 0;
  font-size: 0.72rem;
  font-weight: 800;
  color: #1351b4;
}

.chat-renach-grid {
  display: grid;
  gap: 8px;
  margin-bottom: 8px;
}

.chat-renach-grid--2 {
  grid-template-columns: 1fr 1fr;
}

.chat-renach-lbl {
  margin: 0;
  font-size: 0.58rem;
  color: #9ca3af;
  letter-spacing: 0.04em;
}

.chat-renach-val {
  margin: 2px 0 0;
  font-weight: 700;
  color: #1f2937;
  font-size: 0.75rem;
  line-height: 1.3;
  word-break: break-word;
}

.chat-renach-val--blue {
  color: #1351b4;
  font-size: 0.85rem;
}

.chat-renach-val--warn {
  color: #ea580c;
}

.chat-renach-highlight {
  background: #eff6ff;
  border-radius: 8px;
  padding: 8px;
  margin-bottom: 8px;
}

.chat-renach-proto {
  margin: 8px 0 4px;
  font-size: 0.72rem;
  color: #374151;
}

.chat-renach-foot {
  margin: 0;
  padding-top: 8px;
  border-top: 1px solid #e5e7eb;
  font-size: 0.62rem;
  color: #9ca3af;
}

.chat-pix-detran {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
}

.chat-pix-detran-logo {
  max-height: 40px;
  max-width: 100px;
  object-fit: contain;
}

.chat-pix-detran-fallback {
  font-weight: 800;
  font-size: 0.75rem;
  color: #1351b4;
}

.chat-pix-detran-text strong {
  display: block;
  font-size: 0.82rem;
  color: #0f172a;
}

.chat-pix-detran-text small {
  display: block;
  font-size: 0.65rem;
  color: #64748b;
  margin-top: 2px;
}

.chat-pix-meta-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.chat-pix-meta-grid span {
  display: block;
  background: #f1f5f9;
  border-radius: 8px;
  padding: 8px;
  border: 1px solid #e2e8f0;
}

.chat-pix-meta-grid em {
  display: block;
  font-style: normal;
  font-size: 0.58rem;
  text-transform: uppercase;
  color: #64748b;
  letter-spacing: 0.04em;
}

.chat-pix-meta-grid strong {
  display: block;
  font-size: 0.72rem;
  color: #0f172a;
  margin-top: 2px;
  word-break: break-all;
}

.chat-pix-tax-block {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 12px;
}

.chat-pix-tax-title {
  margin: 0 0 4px;
  font-size: 0.72rem;
  font-weight: 800;
  color: #92400e;
}

.chat-pix-tax-lead {
  margin: 0 0 8px;
  font-size: 0.68rem;
  color: #78350f;
  line-height: 1.45;
}

.chat-pix-tax-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.chat-pix-tax-row {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  gap: 6px;
  align-items: start;
  padding: 6px 0;
  border-top: 1px solid #fde68a;
  font-size: 0.68rem;
}

.chat-pix-tax-cod {
  font-weight: 800;
  color: #b45309;
}

.chat-pix-tax-desc {
  color: #44403c;
  line-height: 1.35;
}

.chat-pix-tax-amt {
  font-weight: 700;
  color: #0f172a;
  white-space: nowrap;
}

.chat-pix-tax-total {
  margin: 8px 0 0;
  text-align: right;
  font-size: 0.75rem;
  color: #0f172a;
}

.chat-pix-howpay {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 12px;
  text-align: left;
}

.chat-pix-howpay-title {
  margin: 0 0 6px;
  font-size: 0.72rem;
  font-weight: 800;
  color: #0f172a;
  text-align: center;
}

.chat-pix-howpay-list {
  margin: 0;
  padding-left: 1.1rem;
  font-size: 0.68rem;
  color: #475569;
  line-height: 1.45;
}
