:root {
  /* Paleta de marca R3 (vermelho/preto/branco) — mesma do nps-app, ver
     src/styles.css do protótipo Lovable "R3 Feedback Loop". Neutros passam
     de cinza-azulado (hue 220) pra cinza puro (hue 0), acompanhando o
     vermelho da marca. */
  --background: hsl(0 0% 98%);
  --foreground: hsl(0 0% 12%);
  --card: hsl(0 0% 100%);
  --card-foreground: hsl(0 0% 12%);
  --sidebar: hsl(0 0% 96%);
  --sidebar-foreground: hsl(0 0% 22%);
  --sidebar-accent: hsl(0 0% 90%);
  --muted: hsl(0 0% 93%);
  --muted-foreground: hsl(0 0% 45%);
  --primary: hsl(356 95% 46%);
  --primary-foreground: hsl(0 0% 100%);
  --secondary: hsl(0 0% 92%);
  --accent: hsl(0 0% 92%);
  --destructive: hsl(0 80% 45%);
  --success: hsl(142 65% 40%);
  --warning: hsl(32 95% 48%);
  --border: hsl(0 0% 87%);
  --border-strong: hsl(0 0% 75%);
  --input: hsl(0 0% 87%);
  --ring: hsl(356 95% 46%);
  --shadow-color: 0 0% 20%;
  --shadow-strength: .08;
  --radius: .75rem;
  --radius-sm: .5rem;
  --radius-lg: .75rem;
}
.dark {
  --background: hsl(0 0% 6%);
  --foreground: hsl(0 0% 92%);
  --card: hsl(0 0% 9%);
  --card-foreground: hsl(0 0% 92%);
  --sidebar: hsl(0 0% 7%);
  --sidebar-foreground: hsl(0 0% 85%);
  --sidebar-accent: hsl(0 0% 13%);
  --muted: hsl(0 0% 13%);
  --muted-foreground: hsl(0 0% 58%);
  --primary: hsl(356 95% 52%);
  --primary-foreground: hsl(0 0% 100%);
  --secondary: hsl(0 0% 14%);
  --accent: hsl(0 0% 14%);
  --destructive: hsl(0 80% 50%);
  --success: hsl(142 65% 48%);
  --warning: hsl(32 95% 55%);
  --border: hsl(0 0% 17%);
  --border-strong: hsl(0 0% 26%);
  --input: hsl(0 0% 17%);
  --ring: hsl(356 95% 52%);
  --shadow-color: 0 0% 0%;
  --shadow-strength: .3;
}
/* Base menor: todo o resto (texto e ícones, ambos em rem no Tailwind)
   encolhe junto proporcionalmente — não precisa mexer em cada classe. */
html { font-size: 14px; }
html, body { font-family: 'Inter', ui-sans-serif, system-ui, sans-serif; }
body {
  color: var(--foreground);
  background: var(--background);
  min-height: 100dvh;
  transition: background .15s ease, color .15s ease;
}
/* Sidebar item ativo — fundo sólido do primário, texto branco */
.nav-active { background: var(--primary); color: var(--primary-foreground); }
/* Botão primário padrão */
.btn-primary {
  background: var(--primary);
  color: var(--primary-foreground);
  border-radius: var(--radius-sm);
  font-weight: 500;
  transition: opacity .15s ease;
}
.btn-primary:hover { opacity: .9; }
.btn-primary:active { opacity: .8; }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }
/* Botão secundário */
.btn-secondary {
  background: var(--secondary);
  color: var(--foreground);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-weight: 500;
  transition: background .15s ease, border-color .15s ease;
}
.btn-secondary:hover { background: var(--accent); border-color: var(--border-strong); }
/* Inputs */
.field {
  width: 100%;
  background: var(--input);
  color: var(--foreground);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .55rem .75rem;
  font-size: 14px;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.field::placeholder { color: var(--muted-foreground); opacity: .7; }
.field:focus { border-color: var(--ring); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 20%, transparent); }
.field:disabled { opacity: .5; cursor: not-allowed; }
textarea.field { resize: vertical; min-height: 3rem; }
/* Input de arquivo: o botão nativo do navegador ignora --input/--foreground
   por padrão (fica branco, fora do tema escuro) -- restyla o botão interno
   pra bater com .btn-secondary, sem mexer no restante do .field. */
.field[type="file"] { padding: .3rem .75rem .3rem .3rem; }
.field[type="file"]::file-selector-button,
.field[type="file"]::-webkit-file-upload-button {
  background: var(--secondary);
  color: var(--foreground);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius-sm) - 2px);
  padding: .35rem .65rem;
  margin-right: .65rem;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}
.field[type="file"]:hover::file-selector-button,
.field[type="file"]:hover::-webkit-file-upload-button {
  background: var(--accent);
  border-color: var(--border-strong);
}
/* Barra de filtros (Leads, Registros de Conexão): input de data, select e
   botões na MESMA altura e MESMA fonte. Sem isso cada um vinha do seu
   jeito — o <input type=date> do navegador é mais alto que o select, e os
   botões (py-2 + text-sm) mais baixos e com fonte menor que os campos. */
.filtros .field,
.filtros .btn-secondary,
.filtros .btn-primary {
  height: 2.5rem;
  box-sizing: border-box;
  font-size: 14px;
  line-height: 1.2;
  padding-top: 0;
  padding-bottom: 0;
}
.filtros .btn-secondary,
.filtros .btn-primary {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}
.filtros .field { display: block; }
.filtros label { line-height: 1.2; }
/* Card */
.card {
  background: var(--card);
  color: var(--card-foreground);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 1px 2px hsl(var(--shadow-color) / var(--shadow-strength));
}
/* Aba (tab) — trilho com fundo muted, aba ativa "recorta" pro fundo da página */
.tab {
  padding: .375rem .75rem;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted-foreground);
  background: transparent;
  border-radius: calc(var(--radius-sm) - 2px);
  cursor: pointer;
  transition: color .15s ease, background .15s ease;
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  white-space: nowrap;
}
.tab:hover { color: var(--foreground); }
.tab-active {
  background: var(--background);
  color: var(--foreground);
  box-shadow: 0 1px 2px hsl(var(--shadow-color) / var(--shadow-strength));
}
.tab-active:hover { background: var(--background); }
.tab:disabled { opacity: .5; cursor: not-allowed; pointer-events: none; }
/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  padding: .15rem .55rem;
  font-size: 12px;
  font-weight: 500;
  border-radius: 999px;
}
.badge-primary { background: color-mix(in srgb, var(--primary) 18%, transparent); color: var(--primary); }
.badge-success { background: color-mix(in srgb, var(--success) 18%, transparent); color: var(--success); }
.badge-warning { background: color-mix(in srgb, var(--warning) 18%, transparent); color: var(--warning); }
.badge-danger  { background: color-mix(in srgb, var(--destructive) 18%, transparent); color: var(--destructive); }
.badge-muted   { background: var(--muted); color: var(--muted-foreground); }
/* Scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: color-mix(in srgb, var(--foreground) 22%, transparent); }
/* Logo */
.logo-badge {
  width: 40px; height: 40px;
  border-radius: var(--radius-sm);
  background: var(--primary);
  display: flex; align-items: center; justify-content: center;
}
/* Divisor sutil */
.divider { border-top: 1px solid var(--border); }

/* ── Sidebar expansível/recolhível, fixa (não rola com a página) ─────────── */
#sidebar {
  width: 4rem;
  transition: width .15s ease;
}
html.sidebar-expanded #sidebar { width: 16rem; }
@media (min-width: 768px) {
  #sidebar { position: fixed; top: 0; left: 0; bottom: 0; z-index: 30; }
  #main-wrapper { margin-left: 4rem; transition: margin-left .15s ease; }
  html.sidebar-expanded #main-wrapper { margin-left: 16rem; }
}
.rail-item { position: relative; }
.rail-btn {
  height: 42px;
  display: flex; align-items: center; gap: .75rem;
  justify-content: center;
  padding: 0;
  border-radius: var(--radius-sm);
  color: var(--sidebar-foreground);
  transition: background .15s ease, color .15s ease;
  width: 42px;
}
.rail-btn:hover { background: var(--sidebar-accent); color: var(--foreground); }
.rail-btn.nav-active:hover { background: var(--primary); }
.sidebar-label { display: none; white-space: nowrap; font-size: 14px; font-weight: 500; }
html.sidebar-expanded .rail-btn { width: 100%; justify-content: flex-start; padding: 0 .75rem; }
html.sidebar-expanded .sidebar-label { display: inline; }
.rail-tooltip {
  position: absolute; left: calc(100% + .6rem); top: 50%; transform: translateY(-50%);
  background: var(--card); color: var(--foreground);
  border: 1px solid var(--border-strong);
  font-size: 12px; font-weight: 500;
  padding: .35rem .65rem;
  border-radius: calc(var(--radius-sm) - 2px);
  white-space: nowrap;
  opacity: 0; pointer-events: none;
  transition: opacity .12s ease;
  box-shadow: 0 8px 20px -4px hsl(var(--shadow-color) / .5);
  z-index: 60;
}
.rail-item:hover .rail-tooltip { opacity: 1; }
html.sidebar-expanded .rail-tooltip { display: none; }
/* Skeleton (não usado agora, deixado pronto) */
.skeleton { background: linear-gradient(90deg, var(--muted) 0%, var(--secondary) 50%, var(--muted) 100%); background-size: 200% 100%; animation: shimmer 1.5s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ── Editor HTML rico (static/js/editor-html.js) — corpo do e-mail marketing ──
   Barra escura no tema do painel; a ÁREA de texto é branca de propósito: é
   assim que o e-mail chega no cliente, e editar em fundo escuro dava cor
   errada (texto branco invisível no Gmail). */
.editor-html { border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--input); overflow: hidden; }
.eh-barra { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 0; padding: 6px 8px; background: var(--secondary); border-bottom: 1px solid var(--border); }
.eh-quebra { flex-basis: 100%; height: 0; }
.eh-grupo { display: inline-flex; align-items: center; gap: 2px; padding: 2px 6px; border-right: 1px solid var(--border); }
.eh-grupo:last-child { border-right: none; }
.eh-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 30px; min-width: 30px; padding: 0 6px; border-radius: 6px; color: var(--foreground); background: transparent; border: 1px solid transparent; cursor: pointer; font-size: 12.5px; }
.eh-btn svg { width: 16px; height: 16px; }
.eh-btn:hover { background: var(--accent); }
.eh-btn.ativo { background: color-mix(in srgb, var(--primary) 18%, transparent); border-color: color-mix(in srgb, var(--primary) 45%, transparent); color: var(--primary); }
.eh-btn:disabled, .eh-sel:disabled { opacity: .4; cursor: not-allowed; }
.eh-btn-texto span { white-space: nowrap; }
.eh-btn-cor { position: relative; }
.eh-btn-cor::after { content: ""; position: absolute; left: 7px; right: 7px; bottom: 4px; height: 3px; border-radius: 2px; background: var(--eh-cor, #111); }
.eh-cor { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.eh-sel { height: 30px; padding: 0 22px 0 8px; border-radius: 6px; border: 1px solid var(--border); background: var(--input); color: var(--foreground); font-size: 12.5px; cursor: pointer; }
.eh-sel-var { width: 132px; border-color: color-mix(in srgb, var(--primary) 45%, transparent); font-weight: 600; }
.eh-area { min-height: 380px; max-height: 70vh; overflow: auto; padding: 24px 28px; background: #ffffff; color: #1c1c22; font-family: Arial, Helvetica, sans-serif; font-size: 15px; line-height: 1.55; outline: none; }
.eh-area:focus { box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--primary) 35%, transparent); }
.eh-area p { margin: 0 0 .8em; }
.eh-area h1, .eh-area h2, .eh-area h3, .eh-area h4 { margin: .6em 0 .4em; line-height: 1.25; }
.eh-area h1 { font-size: 2em; } .eh-area h2 { font-size: 1.5em; } .eh-area h3 { font-size: 1.25em; } .eh-area h4 { font-size: 1.05em; }
.eh-area a { color: #1a5fd0; text-decoration: underline; }
.eh-area img { max-width: 100%; height: auto; }
.eh-area blockquote { margin: .8em 0; padding: .4em 1em; border-left: 4px solid #d8d8de; color: #555; }
.eh-area pre { background: #f4f4f7; padding: .8em 1em; border-radius: 6px; font-family: ui-monospace, monospace; font-size: 13px; white-space: pre-wrap; }
/* Tailwind preflight zera list-style — no e-mail o marcador aparece, então
   aqui também. */
.eh-area ul { list-style: disc; padding-left: 1.6em; margin: 0 0 .8em; }
.eh-area ol { list-style: decimal; padding-left: 1.6em; margin: 0 0 .8em; }
.eh-area table { border-collapse: collapse; }
.eh-area td, .eh-area th { border: 1px solid #d0d0d6; padding: 6px 8px; min-width: 40px; }
.eh-fonte { width: 100%; min-height: 380px; padding: 16px 20px; background: #0f0f13; color: #d6dbe6; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; line-height: 1.5; border: none; outline: none; resize: vertical; }
.eh-rodape { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 8px 10px; background: var(--secondary); border-top: 1px solid var(--border); font-size: 12px; color: var(--muted-foreground); }
.eh-rodape-btn { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px; border-radius: 6px; border: 1px solid var(--border); background: var(--input); color: var(--foreground); font-size: 12.5px; cursor: pointer; }
.eh-rodape-btn svg { width: 15px; height: 15px; }
.eh-rodape-btn:hover { background: var(--accent); }
.eh-rodape-btn:disabled { opacity: .5; cursor: wait; }
.eh-rodape-msg.ok { color: #35c26b; } .eh-rodape-msg.erro { color: var(--destructive); }
.eh-rodape-conta { margin-left: auto; }
/* Popovers (imagem, tabela, caracteres) */
.eh-pop { position: absolute; top: 34px; z-index: 40; min-width: 260px; max-width: 360px; background: var(--card); border: 1px solid var(--border-strong, var(--border)); border-radius: 8px; box-shadow: 0 12px 30px rgba(0,0,0,.35); padding: 10px; }
.eh-pop-rotulo { display: block; font-size: 11px; color: var(--muted-foreground); margin-bottom: 6px; }
.eh-pop-linha { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--foreground); }
.eh-pop-input { flex: 1; height: 30px; padding: 0 8px; border-radius: 6px; border: 1px solid var(--border); background: var(--input); color: var(--foreground); font-size: 12.5px; }
.eh-pop-num { flex: 0 0 56px; }
.eh-pop-ok { height: 30px; padding: 0 10px; border-radius: 6px; background: var(--primary); color: #fff; font-size: 12.5px; font-weight: 600; cursor: pointer; border: none; }
.eh-pop-ou { text-align: center; font-size: 11px; color: var(--muted-foreground); margin: 8px 0; }
.eh-pop-upload { display: block; text-align: center; padding: 8px; border: 1px dashed var(--border-strong, var(--border)); border-radius: 6px; font-size: 12px; color: var(--foreground); cursor: pointer; }
.eh-pop-upload:hover { background: var(--accent); }
.eh-pop-dica { font-size: 10.5px; color: var(--muted-foreground); margin-top: 8px; }
.eh-pop-especiais { display: grid; grid-template-columns: repeat(10, 1fr); gap: 2px; min-width: 300px; }
.eh-esp { height: 28px; border-radius: 4px; border: 1px solid transparent; background: transparent; color: var(--foreground); font-size: 15px; cursor: pointer; }
.eh-esp:hover { background: var(--accent); border-color: var(--border); }
/* Tela cheia */
.editor-html.eh-tela-cheia { position: fixed; inset: 0; z-index: 60; border-radius: 0; display: flex; flex-direction: column; }
.editor-html.eh-tela-cheia .eh-area, .editor-html.eh-tela-cheia .eh-fonte { flex: 1; max-height: none; }
.eh-body-travado { overflow: hidden; }
/* Modal de pré-visualização */
.eh-modal { position: fixed; inset: 0; z-index: 70; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; padding: 24px; }
.eh-modal-caixa { width: min(880px, 100%); height: min(88vh, 900px); background: var(--card); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; display: flex; flex-direction: column; }
.eh-modal-topo { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--border); font-size: 12.5px; color: var(--muted-foreground); }
.eh-modal-topo strong { color: var(--foreground); }
.eh-modal-fechar { margin-left: auto; width: 28px; height: 28px; border-radius: 6px; background: transparent; border: 1px solid var(--border); color: var(--foreground); cursor: pointer; }
.eh-modal-quadro { flex: 1; width: 100%; border: none; background: #eef0f4; }
