* { box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  margin: 0;
  background: #f5f6f8;
  color: #1a1a1a;
  font-size: 14px;
}

.hidden { display: none !important; }
.erro { color: #b00020; margin: 0; }
.msg { color: #0a7d2c; margin-left: 0.5rem; }
.hint { color: #555; font-size: 0.9rem; margin: 0.3rem 0 0.6rem; }

/* ===== Topbar ===== */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.9rem 1.5rem; background: #fff; border-bottom: 1px solid #e3e3e3;
}
.topbar h1 { font-size: 1.05rem; margin: 0; color: #1f2937; }
.topbar #user-info { margin-right: 0.75rem; color: #555; }

/* ===== Tabs ===== */
.tabs {
  display: flex; gap: 0.25rem; padding: 0 1.5rem; background: #fff;
  border-bottom: 1px solid #e3e3e3; overflow-x: auto;
}
.tab-btn {
  background: transparent; border: none; padding: 0.75rem 1rem; cursor: pointer;
  border-bottom: 3px solid transparent; font-size: 0.95rem; color: #555;
}
.tab-btn:hover { color: #1f2937; }
.tab-btn.active { border-bottom-color: #2563eb; color: #2563eb; font-weight: 600; }

/* ===== Container & Panes ===== */
.container { padding: 1.5rem; max-width: 1100px; margin: 0 auto; }
.tab-pane { display: none; background: #fff; padding: 1.5rem; border-radius: 8px; border: 1px solid #e3e3e3; }
.tab-pane.active { display: block; }
.tab-pane h2 { margin-top: 0; font-size: 1.15rem; }

/* ===== Forms ===== */
label { display: block; margin: 0.5rem 0 0.25rem; font-weight: 500; }
input[type=text], input[type=password], textarea, select {
  width: 100%; padding: 0.55rem 0.65rem; font-size: 0.95rem;
  border: 1px solid #cdd1d8; border-radius: 6px; font-family: inherit;
  background: #fff;
}
input:focus, textarea:focus, select:focus {
  outline: none; border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,0.15);
}
textarea {
  resize: vertical; min-height: 80px;
  font-family: ui-monospace, "Cascadia Code", Menlo, Consolas, monospace;
}

button {
  background: #2563eb; color: #fff; border: none; padding: 0.55rem 1rem;
  border-radius: 6px; font-size: 0.95rem; cursor: pointer; font-weight: 500;
}
button:hover { background: #1d4ed8; }
button.ghost { background: transparent; color: #2563eb; border: 1px solid #2563eb; }
button.ghost:hover { background: #eff6ff; }
button.danger { background: #dc2626; }
button.danger:hover { background: #b91c1c; }

.row { margin-bottom: 1rem; }
.switch { display: inline-flex; align-items: center; gap: 0.5rem; font-weight: 500; cursor: pointer; }

.form-inline {
  display: flex; flex-direction: column; gap: 0.6rem; margin-bottom: 1.5rem;
  padding: 1rem; background: #fafbfc; border-radius: 8px; border: 1px solid #e3e3e3;
}
.form-actions { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }

/* ===== Grid ===== */
.grid { width: 100%; border-collapse: collapse; }
.grid th, .grid td { padding: 0.65rem 0.6rem; text-align: left; border-bottom: 1px solid #ececec; vertical-align: top; }
.grid th { background: #f7f8fa; font-weight: 600; font-size: 0.9rem; color: #444; }
.grid td button { margin-right: 0.25rem; padding: 0.35rem 0.7rem; font-size: 0.85rem; }
.grid tr:last-child td { border-bottom: none; }
.grid tr:hover td { background: #fafbfc; }

/* ===== Login ===== */
.login-page {
  display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 1rem;
}
.login-card {
  width: 100%; max-width: 360px; padding: 2rem; background: #fff;
  border-radius: 8px; border: 1px solid #e3e3e3;
}
.login-card h1 { margin: 0 0 1.25rem; font-size: 1.1rem; text-align: center; color: #1f2937; }
.login-card form { display: flex; flex-direction: column; gap: 0.75rem; }
.login-card button { margin-top: 0.5rem; }

/* ===== Status badges (Base de Conhecimento) ===== */
.status-badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border: 1px solid transparent;
}
.status-badge.ativo { background: #ecfdf5; color: #047857; border-color: #6ee7b7; }
.status-badge.inativo { background: #f3f4f6; color: #4b5563; border-color: #d1d5db; }
.status-badge.arquivado { background: #fef9c3; color: #854d0e; border-color: #fde68a; }
.status-badge.pendente { background: #fef3c7; color: #92400e; border-color: #fcd34d; }
.status-badge.bloqueado { background: #fee2e2; color: #991b1b; border-color: #fca5a5; }

/* Origens de pausa (Clientes Pausados) */
.status-badge.comportamento { background: #fee2e2; color: #991b1b; border-color: #fca5a5; }
.status-badge.manual { background: #f3f4f6; color: #4b5563; border-color: #d1d5db; }
.status-badge.transferencia { background: #fef3c7; color: #92400e; border-color: #fcd34d; }
.status-badge.outro { background: #e0e7ff; color: #3730a3; border-color: #c7d2fe; }
.status-badge.chatguru { background: #dcfce7; color: #166534; border-color: #86efac; }

.auth-links { text-align: center; margin-top: 1rem; font-size: 0.9rem; }
.auth-links a { color: #2563eb; text-decoration: none; }
.auth-links a:hover { text-decoration: underline; }
.auth-links .sep { margin: 0 0.4rem; color: #9ca3af; }

.user-secundario { font-size: 0.85rem; color: #6b7280; }

/* ===== Modo de Teste ===== */
.topbar-left { display: flex; align-items: center; gap: 0.75rem; }

/* Link da topbar com cara de botão "ghost" (usado pelo atalho da Rádio Recanto) */
.topbar-link {
  display: inline-block; color: #2563eb; text-decoration: none; border: 1px solid #2563eb;
  border-radius: 6px; padding: 0.4rem 0.8rem; font-size: 0.9rem; font-weight: 500; margin-right: 0.75rem;
}
.topbar-link:hover { background: #eff6ff; }

.badge-teste {
  display: inline-block;
  padding: 0.25rem 0.7rem;
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fcd34d;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.divider { border: 0; border-top: 1px solid #e5e7eb; margin: 1.5rem 0; }

.numeros-teste-form { display: flex; gap: 0.5rem; }
.numeros-teste-form input {
  flex: 1;
  font-family: ui-monospace, "Cascadia Code", Menlo, Consolas, monospace;
}
.numeros-teste-form button { white-space: nowrap; }

.numeros-list {
  list-style: none;
  padding: 0;
  margin: 0.6rem 0 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.numeros-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.45rem 0.7rem;
  background: #fafbfc;
  border: 1px solid #e3e3e3;
  border-radius: 6px;
}
.numeros-list li span {
  font-family: ui-monospace, "Cascadia Code", Menlo, Consolas, monospace;
  font-size: 0.95rem;
}
.numeros-list li.empty {
  justify-content: center;
  color: #6b7280;
  font-style: italic;
}
.numeros-list li button { padding: 0.25rem 0.7rem; font-size: 0.8rem; }
#history-sales-settings { padding: 1rem; background: #f9fafb; border: 1px solid #e5e7eb; border-radius: 8px; margin-bottom: 1.5rem; }
#history-sales-settings h3 { margin-bottom: 1rem; }
#history-sales-settings .switch { display: inline-flex; align-items: center; gap: 0.5rem; }
#history-sales-settings .switch.active-sales-mode { color: #047857; }
#sales-mode-row.active-sales-mode input + span { color: #047857; }
/* ===== Emoji picker ===== */
.textarea-with-emoji { position: relative; }

/* Campaign cards */
.campaign-card {
  padding: 0.75rem; margin-bottom: 0.8rem; border-radius: 6px; background: #fafbfc; border-left: 4px solid #e5e7eb;
}
.campaign-card.active-campaign { border-left-color: #10b981; }
.campaign-card .muted { color: #6b7280; }
.textarea-with-emoji .emoji-btn {
  position: absolute;
  right: 0.5rem;
  bottom: 0.5rem;
  background: transparent;
  border: 1px solid #e3e3e3;
  border-radius: 6px;
  padding: 0.2rem 0.45rem;
  font-size: 1.1rem;
  cursor: pointer;
  line-height: 1;
}
.textarea-with-emoji .emoji-btn:hover { background: #f3f4f6; }

.emoji-popup {
  position: absolute;
  z-index: 1000;
  background: #fff;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 0.5rem;
  display: grid;
  grid-template-columns: repeat(10, auto);
  gap: 0.2rem;
  box-shadow: 0 6px 24px rgba(0,0,0,0.12);
  max-width: 320px;
}
.emoji-popup button.emoji {
  background: transparent;
  border: none;
  font-size: 1.2rem;
  padding: 0.25rem 0.35rem;
  cursor: pointer;
  border-radius: 4px;
  line-height: 1;
}
.emoji-popup button.emoji:hover { background: #f3f4f6; }

.kb-conteudo {
  white-space: pre-wrap;
  font-family: ui-monospace, "Cascadia Code", Menlo, Consolas, monospace;
  font-size: 0.85rem;
  color: #444;
  max-height: 4.2em;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

.tokens-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.tokens-toolbar .button-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.small-btn {
  background: #f3f4f6;
  color: #1f2937;
  border: 1px solid #d1d5db;
  padding: 0.55rem 0.9rem;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.9rem;
}
.small-btn:hover { background: #e5e7eb; }
.small-btn.active {
  background: #2563eb;
  color: #fff;
  border-color: #2563eb;
}
.date-range-row {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}
.date-range-row label {
  display: flex;
  flex-direction: column;
  font-size: 0.9rem;
  color: #4b5563;
}
.tokens-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.token-card {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  padding: 1rem 1.15rem;
  min-height: 100px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.token-card-label {
  color: #6b7280;
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}
.token-card-value {
  font-size: 1.45rem;
  font-weight: 700;
  color: #111827;
}
.tokens-chart-panel {
  margin-bottom: 1.5rem;
}
.tokens-chart-container {
  position: relative;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 1rem;
  min-height: 320px;
}
.tokens-chart-container svg {
  width: 100%;
  height: 320px;
}
.chart-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #6b7280;
  font-size: 0.95rem;
  padding: 1rem;
  text-align: center;
}
.tokens-recent-panel .grid th,
.tokens-recent-panel .grid td {
  font-size: 0.92rem;
}
.tokens-recent-panel .grid td code {
  font-family: ui-monospace, "Cascadia Code", Menlo, Consolas, monospace;
}

/* Truncatable text helper (JS-driven) */
.truncatable { word-break: break-word; }
.truncatable.inline { display: inline; }
.truncatable .toggle-more { color: #2563eb; text-decoration: none; cursor: pointer; margin-left: 6px; font-weight: 600; }
.trunc-text { display: inline; }

/* ===== Status da Infra ===== */
.status-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 1rem; flex-wrap: wrap; margin-bottom: 0.5rem;
}
.status-header h2 { margin: 0; }
.status-header .hint { margin: 0.2rem 0 0; }

.status-zona { margin-top: 1.5rem; }
.status-zona-head {
  display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap;
  margin-bottom: 0.75rem;
}
.zona-badge {
  display: inline-block; padding: 0.2rem 0.6rem; border-radius: 999px;
  font-size: 0.78rem; font-weight: 700;
}
.zona-vivo { background: #dcfce7; color: #166534; border: 1px solid #86efac; }
.zona-declarado { background: #e0e7ff; color: #3730a3; border: 1px solid #a5b4fc; }
.zona-links { background: #f3f4f6; color: #374151; border: 1px solid #d1d5db; }
.zona-sub { color: #6b7280; font-size: 0.85rem; }
.zona-acao { margin-left: auto; }

.status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.9rem;
}
.status-card {
  background: #f9fafb; border: 1px solid #e5e7eb; border-left: 4px solid #9ca3af;
  border-radius: 12px; padding: 0.9rem 1rem; min-height: 92px;
  display: flex; flex-direction: column; gap: 0.25rem;
}
.status-card-label { color: #6b7280; font-size: 0.85rem; }
.status-card-value { font-size: 1.35rem; font-weight: 700; color: #111827; line-height: 1.2; }
.status-card-sub { color: #6b7280; font-size: 0.8rem; }

/* Indicadores de cor (borda esquerda + leve tom de fundo) */
.status-card.status-verde    { border-left-color: #16a34a; background: #f0fdf4; }
.status-card.status-amarelo  { border-left-color: #d97706; background: #fffbeb; }
.status-card.status-vermelho { border-left-color: #dc2626; background: #fef2f2; }
.status-card.status-laranja  { border-left-color: #ea580c; background: #fff7ed; }
.status-card.status-neutro   { border-left-color: #9ca3af; }

.status-config-form { margin-top: 1rem; border-top: 1px solid #e5e7eb; padding-top: 1rem; }
.status-config-actions { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; margin-top: 0.5rem; }

.status-links { display: flex; gap: 0.6rem; flex-wrap: wrap; }
.status-link-btn {
  display: inline-block; padding: 0.55rem 1rem; border-radius: 8px;
  background: #2563eb; color: #fff; text-decoration: none; font-weight: 600;
  font-size: 0.9rem;
}
.status-link-btn:hover { background: #1d4ed8; }

/* Ações em massa da aba Transferências (2026-09-14) */
.transf-massa {
  display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center;
  padding: 0.55rem 0.75rem; margin-bottom: 0.5rem;
  border: 1px solid #e5e7eb; border-radius: 8px; background: #f9fafb;
}
.transf-contador { font-weight: 600; color: #374151; margin-right: 0.25rem; }
.transf-contador.tem-selecao { color: #1d4ed8; }
.transf-massa button[disabled] { opacity: 0.5; cursor: not-allowed; }
#transf-massa-msg { margin: 0; }

/* Relógio de Salvador na topbar: a hora oficial do parque, vinda do servidor.
   Discreto ao lado do título; some em telas estreitas para não empurrar os botões. */
.relogio-topbar {
  margin-left: 0.85rem;
  font-size: 0.82rem;
  color: #6b7280;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
@media (max-width: 720px) {
  .relogio-topbar { display: none; }
}

/* Tabelas largas do painel (pausados, IA definitiva): rolam dentro da própria caixa no celular. */
.tabela-rolavel { overflow-x: auto; max-width: 100%; }
