* { box-sizing: border-box; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  margin: 0;
  background: #f4f5f7;
  color: #1f2430;
}
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #1f2430;
  color: #fff;
  padding: 0.75rem 1.5rem;
}
.topbar a { color: #fff; text-decoration: none; }
.brand { font-weight: 600; }
.topbar nav { display: flex; align-items: center; gap: 0.25rem; }
.topbar nav a, .topbar nav span { margin-right: 1rem; }
.topbar nav .nav-btn {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.4);
  color: #fff;
  padding: 0.3rem 0.7rem;
  margin-right: 1rem;
  font-size: 0.85rem;
}
.container { max-width: 1000px; margin: 1.5rem auto; padding: 0 1rem; }
table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { padding: 0.5rem 0.75rem; border-bottom: 1px solid #e2e4e9; text-align: left; font-size: 0.9rem; }
.summary-cell { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status { padding: 0.15rem 0.5rem; border-radius: 999px; font-size: 0.75rem; background: #e2e4e9; }
.status-open { background: #d7f0e0; }
.status-handoff_pending { background: #ffe6b3; }
.status-resolved { background: #d9d9d9; }
.login-form { display: flex; flex-direction: column; max-width: 320px; gap: 0.75rem; }
.login-form label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.9rem; }
.captcha-box { display: flex; flex-direction: column; gap: 0.4rem; }
.captcha-label { font-size: 0.85rem; color: #6b7280; }
.captcha-challenge { display: flex; align-items: center; gap: 0.5rem; }
.captcha-img { height: 44px; border-radius: 8px; }
.captcha-op { font-size: 1.1rem; font-weight: 600; color: #1f2430; }
.captcha-input { width: 70px; padding: 0.4rem 0.5rem; border: 1px solid #d0d3d9; border-radius: 6px; font-size: 1rem; }
button {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 6px;
  background: #2d6cdf;
  color: #fff;
  cursor: pointer;
}
.actions { display: flex; gap: 0.75rem; margin: 1rem 0; }
.actions form { display: inline; }
.conversation-meta p { margin: 0.25rem 0; }
.transcript { list-style: none; padding: 0; }
.msg { padding: 0.5rem 0.75rem; margin-bottom: 0.5rem; border-radius: 8px; background: #fff; }
.msg-user { border-left: 4px solid #2d6cdf; }
.msg-assistant { border-left: 4px solid #2e9e5b; }
.msg-blocked { border-left-color: #d64545; background: #fdeeee; }
.msg-role { display: inline-block; font-weight: 600; text-transform: uppercase; font-size: 0.7rem; margin-right: 0.5rem; }
.msg-time { display: block; font-size: 0.7rem; color: #6b7280; margin-top: 0.25rem; }
.msg-block-reason { display: block; font-size: 0.75rem; color: #d64545; }
.flashes { list-style: none; padding: 0.5rem 0.75rem; background: #fff3cd; border-radius: 6px; }
.hint { color: #6b7280; font-size: 0.85rem; }
.settings-form { display: flex; flex-direction: column; max-width: 420px; gap: 0.75rem; margin-bottom: 1.5rem; }
.settings-form label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.9rem; }
.source-tag { font-size: 0.72rem; font-weight: 600; text-transform: uppercase; color: #8a93a6; }
.settings-form input { padding: 0.4rem 0.5rem; border: 1px solid #d0d3d9; border-radius: 6px; }
.btn-secondary { background: #6b7280; }
.wa-card {
  background: #fff;
  border-radius: 10px;
  padding: 1rem 1.25rem;
  max-width: 420px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}
.wa-estado {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  background: #f4f5f7;
  margin-bottom: 0.75rem;
}
.wa-dot { width: 10px; height: 10px; border-radius: 50%; background: #8a93a6; flex: none; }
.wa-dot.on { background: #2e9e5b; }
.wa-dot.wait { background: #e0a400; }
.wa-dot.off { background: #d64545; }
.wa-qr { text-align: center; margin: 0.5rem 0; min-height: 120px; display: flex; align-items: center; justify-content: center; }
.wa-qr img { width: 220px; height: 220px; border: 1px solid #e2e4e9; border-radius: 8px; padding: 6px; background: #fff; }
.wa-code { text-align: center; font-family: ui-monospace, monospace; letter-spacing: 2px; color: #6b7280; margin-top: 0.25rem; }
.wa-msg { font-size: 0.85rem; color: #6b7280; margin-top: 0.5rem; min-height: 1rem; }
.wa-erro { margin-top: 0.75rem; background: #fdeeee; border: 1px solid #f3c8c8; border-radius: 8px; padding: 0.75rem; }
.wa-erro pre { white-space: pre-wrap; word-break: break-word; font-size: 0.78rem; margin: 0.5rem 0 0; }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 18, 26, 0.55);
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}
.modal-box {
  background: #fff;
  border-radius: 12px;
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  padding: 1.25rem;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
}
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.25rem; }
.modal-header h2 { margin: 0; font-size: 1.05rem; }
.modal-close {
  background: transparent;
  color: #6b7280;
  font-size: 1.4rem;
  line-height: 1;
  padding: 0.1rem 0.4rem;
}
.chat-mensagens {
  flex: 1;
  overflow-y: auto;
  min-height: 220px;
  max-height: 45vh;
  background: #f4f5f7;
  border-radius: 8px;
  padding: 0.75rem;
  margin: 0.75rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.chat-msg { padding: 0.45rem 0.65rem; border-radius: 8px; font-size: 0.88rem; max-width: 85%; white-space: pre-wrap; word-break: break-word; }
.chat-msg-user { align-self: flex-end; background: #2d6cdf; color: #fff; }
.chat-msg-assistant { align-self: flex-start; background: #fff; border: 1px solid #e2e4e9; }
.chat-form { display: flex; gap: 0.5rem; }
.chat-form input { flex: 1; padding: 0.5rem 0.6rem; border: 1px solid #d0d3d9; border-radius: 6px; }
.chat-typing { display: flex; align-items: center; gap: 0.25rem; padding: 0.6rem 0.75rem; }
.typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #9aa1ac;
  animation: typing-bounce 1.2s infinite ease-in-out;
}
.typing-dot:nth-child(2) { animation-delay: 0.15s; }
.typing-dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-4px); opacity: 1; }
}
