/* Visual inspirado no shadcn/ui (tons neutros, bordas finas, tipografia forte).
   Todas as cores vêm dos tokens abaixo; o tema escuro redefine só os tokens. */

:root {
  color-scheme: light;
  --fundo: #ffffff;
  --fundo-app: #f7f7f8;
  --texto: #09090b;
  --texto-suave: #71717a;
  --cartao: #ffffff;
  --borda: #e4e4e7;
  --campo: #e4e4e7;
  --realce: #f4f4f5;          /* hover e fundos discretos */
  --primario: #18181b;
  --primario-texto: #fafafa;
  --anel: #a1a1aa;            /* contorno de foco */
  --menu: #fafafa;
  --menu-ativo: #f4f4f5;
  --sucesso: #15803d;
  --sucesso-fundo: #dcfce7;
  --perigo: #dc2626;
  --perigo-fundo: #fee2e2;
  --aviso-texto: #92400e;
  --aviso-fundo: #fef3c7;
  --aviso-borda: #fde68a;
  --sombra: 0 1px 2px rgb(0 0 0 / 0.05);
  --raio: 10px;
}

/* Tema escuro: segue o sistema, a menos que o usuário tenha escolhido o claro. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --fundo: #09090b;
    --fundo-app: #09090b;
    --texto: #fafafa;
    --texto-suave: #a1a1aa;
    --cartao: #111113;
    --borda: #27272a;
    --campo: #3f3f46;
    --realce: #1c1c1f;
    --primario: #fafafa;
    --primario-texto: #18181b;
    --anel: #71717a;
    --menu: #0c0c0e;
    --menu-ativo: #1c1c1f;
    --sucesso: #4ade80;
    --sucesso-fundo: #052e16;
    --perigo: #f87171;
    --perigo-fundo: #450a0a;
    --aviso-texto: #fcd34d;
    --aviso-fundo: #2b1d06;
    --aviso-borda: #713f12;
    --sombra: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --fundo: #09090b;
  --fundo-app: #09090b;
  --texto: #fafafa;
  --texto-suave: #a1a1aa;
  --cartao: #111113;
  --borda: #27272a;
  --campo: #3f3f46;
  --realce: #1c1c1f;
  --primario: #fafafa;
  --primario-texto: #18181b;
  --anel: #71717a;
  --menu: #0c0c0e;
  --menu-ativo: #1c1c1f;
  --sucesso: #4ade80;
  --sucesso-fundo: #052e16;
  --perigo: #f87171;
  --perigo-fundo: #450a0a;
  --aviso-texto: #fcd34d;
  --aviso-fundo: #2b1d06;
  --aviso-borda: #713f12;
  --sombra: none;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  background: var(--fundo-app);
  color: var(--texto);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--texto); text-underline-offset: 3px; }

/* ---------- Estrutura: menu lateral + conteúdo ---------- */

body.app { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }

.menu-lateral {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px 12px;
  background: var(--menu);
  border-right: 1px solid var(--borda);
}

.marca-sistema { display: flex; align-items: center; gap: 10px; padding: 6px 10px 18px; font-weight: 600; font-size: 15px; }
.marca-sistema .logo-sistema {
  width: 30px; height: 30px; border-radius: 8px;
  display: grid; place-items: center;
  background: var(--primario); color: var(--primario-texto);
}
.marca-sistema .logo-sistema svg { width: 17px; height: 17px; }

.menu-lateral nav { display: flex; flex-direction: column; gap: 2px; }
.item-menu {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 8px;
  color: var(--texto-suave); text-decoration: none; font-weight: 500;
}
.item-menu:hover { background: var(--menu-ativo); color: var(--texto); }
.item-menu.ativo { background: var(--menu-ativo); color: var(--texto); }
.item-menu svg, .botao-icone svg { width: 18px; height: 18px; flex-shrink: 0; }

.rodape-menu { margin-top: auto; border-top: 1px solid var(--borda); padding-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.conta-atual { padding: 0 10px; }
.conta-atual strong { display: block; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conta-atual span { display: block; font-size: 12px; color: var(--texto-suave); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acoes-menu { display: flex; gap: 4px; }

.botao-icone {
  display: inline-flex; align-items: center; gap: 8px;
  height: auto; background: transparent; color: var(--texto-suave);
  border: 0; border-radius: 8px; padding: 8px 10px;
  font: inherit; font-weight: 500; cursor: pointer;
}
.botao-icone:hover { background: var(--menu-ativo); color: var(--texto); opacity: 1; }

.conteudo { min-width: 0; }

main { max-width: 760px; margin: 0 auto; padding: 32px 24px 48px; }
main.largo { max-width: 1040px; }

.cabecalho-pagina { margin-bottom: 24px; }
.cabecalho-pagina h1 { font-size: 24px; font-weight: 600; letter-spacing: -0.02em; margin: 0 0 4px; }
.cabecalho-pagina p { margin: 0; color: var(--texto-suave); }

/* Barra superior só no celular (abre o menu). */
.topo-movel { display: none; }

@media (max-width: 860px) {
  body.app { display: block; }
  .topo-movel {
    display: flex; align-items: center; justify-content: space-between;
    position: sticky; top: 0; z-index: 20;
    padding: 10px 16px; background: var(--fundo); border-bottom: 1px solid var(--borda);
  }
  .topo-movel .marca-sistema { padding: 0; }
  .menu-lateral {
    position: fixed; z-index: 30; left: 0; top: 0; width: 264px;
    transform: translateX(-100%); transition: transform 0.2s ease;
    box-shadow: 0 10px 30px rgb(0 0 0 / 0.2);
  }
  body.menu-aberto .menu-lateral { transform: none; }
  body.menu-aberto::after { content: ""; position: fixed; inset: 0; z-index: 25; background: rgb(0 0 0 / 0.4); }
  main { padding: 20px 16px 40px; }
}

/* ---------- Cartões e tipografia ---------- */

.card {
  background: var(--cartao);
  border: 1px solid var(--borda);
  border-radius: var(--raio);
  padding: 24px;
  box-shadow: var(--sombra);
  margin-bottom: 20px;
}

h1 { font-size: 20px; font-weight: 600; letter-spacing: -0.01em; margin: 0 0 20px; }
h2 { font-size: 16px; font-weight: 600; margin: 0 0 16px; }
.card > h1, .card > h2 { margin-bottom: 4px; }
.card > h1 + .dica, .card > h2 + .dica, .card > h2 + p { margin: 0 0 20px; }

label { display: block; font-weight: 500; font-size: 13px; margin-bottom: 6px; }

/* ---------- Campos ---------- */

input, select, textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--campo);
  border-radius: 8px;
  font: inherit;
  font-size: 14px;
  color: var(--texto);
  background: var(--fundo);
  margin-bottom: 16px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input::placeholder, textarea::placeholder { color: var(--texto-suave); }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible {
  outline: none;
  border-color: var(--anel);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--anel) 35%, transparent);
}
input:disabled { opacity: 0.5; cursor: not-allowed; }
textarea { resize: vertical; line-height: 1.5; }
input[type=file] { padding: 7px; font-size: 13px; }

.dica { font-size: 12.5px; color: var(--texto-suave); margin: -10px 0 16px; }
/* A margem negativa só serve para "grudar" a dica no campo acima. Depois de botão ou
   mensagem, a dica ganha espaço normal (senão sobe e invade o botão). */
button + .dica, .mensagem + .dica { margin: 16px 0 0; }

.caixa { display: flex; align-items: center; gap: 8px; font-weight: 400; font-size: 14px; margin-bottom: 6px; cursor: pointer; }
.caixa input { width: 16px; height: 16px; margin: 0; accent-color: var(--primario); }
.caixa + .dica, .linha-botoes + .dica { margin-top: 4px; }

/* ---------- Botões ---------- */

button, a.botao {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 16px;
  background: var(--primario); color: var(--primario-texto);
  border: 1px solid var(--primario); border-radius: 8px;
  font: inherit; font-weight: 500; font-size: 14px;
  text-decoration: none; cursor: pointer;
  transition: opacity 0.15s, background 0.15s;
}
button:hover, a.botao:hover { opacity: 0.9; }
button:disabled { opacity: 0.5; cursor: wait; }

button.secundario, a.botao.secundario {
  background: var(--fundo); color: var(--texto); border-color: var(--campo);
}
button.secundario:hover, a.botao.secundario:hover { background: var(--realce); opacity: 1; }
button.perigo { background: var(--fundo); color: var(--perigo); border-color: var(--campo); }
button.perigo:hover { background: var(--perigo-fundo); opacity: 1; }
button.pequeno { height: 32px; padding: 0 12px; font-size: 13px; }

button.link {
  height: auto; padding: 0; background: none; border: 0;
  color: var(--texto-suave); font-size: 13px; font-weight: 500;
}
button.link:hover { color: var(--texto); text-decoration: underline; opacity: 1; }

.linha-botoes { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
/* Só campos de texto esticam (não o seletor de cor nem caixas de marcar). */
.linha-botoes input[type=text] { flex: 1; min-width: 200px; margin: 0; }
.linha-botoes .caixa { margin: 0; }

/* ---------- Mensagens, alertas e selos ---------- */

.mensagem { margin: 14px 0 0; font-size: 13px; color: var(--texto-suave); }
.mensagem:empty { display: none; }
.mensagem.erro { color: var(--perigo); }
.mensagem.sucesso { color: var(--sucesso); }

.aviso {
  display: flex; gap: 6px; align-items: center; flex-wrap: wrap;
  background: var(--aviso-fundo); color: var(--aviso-texto);
  border: 1px solid var(--aviso-borda); border-radius: var(--raio);
  padding: 12px 16px; margin: 0 0 20px; font-size: 13.5px;
}
.aviso a { color: inherit; font-weight: 600; }

.selo {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 500; white-space: nowrap;
  border: 1px solid var(--borda); color: var(--texto-suave); background: var(--realce);
}
.selo::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.selo.ativo { color: var(--sucesso); background: var(--sucesso-fundo); border-color: transparent; }

/* ---------- Tabelas ---------- */

.tabela-envoltorio { overflow-x: auto; margin: 0 -24px -24px; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th {
  text-align: left; font-weight: 500; color: var(--texto-suave);
  padding: 10px 12px; border-bottom: 1px solid var(--borda); white-space: nowrap;
}
td { text-align: left; padding: 12px; border-bottom: 1px solid var(--borda); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--realce); }
th:first-child, td:first-child { padding-left: 24px; }
th:last-child, td:last-child { padding-right: 24px; }
td.acoes { text-align: right; white-space: nowrap; }
td.acoes button + button { margin-left: 6px; }
tr.inativo td:not(.acoes) { color: var(--texto-suave); }
.numero { font-variant-numeric: tabular-nums; color: var(--texto-suave); }

/* ---------- Gerar relatório: período e campanhas ---------- */

.linha-datas { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
#tipo-periodo { margin-bottom: 8px; }
#bloco-mes input, .linha-datas input { margin-bottom: 8px; }
#dica-periodo { margin: 0 0 16px; }

.campanhas-topo { display: flex; justify-content: space-between; align-items: baseline; }
.campanhas-topo span { font-size: 13px; color: var(--texto-suave); }

.campanhas {
  border: 1px solid var(--campo);
  border-radius: 8px;
  max-height: 264px;
  overflow-y: auto;
  margin-bottom: 16px;
}
.campanhas .vazio { margin: 0; padding: 14px; font-size: 13px; color: var(--texto-suave); }
.campanha {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; margin: 0;
  font-weight: 400; font-size: 13.5px;
  border-bottom: 1px solid var(--borda); cursor: pointer;
}
.campanha:last-child { border-bottom: 0; }
.campanha:hover { background: var(--realce); }
.campanha input { width: 16px; height: 16px; margin: 0; flex-shrink: 0; accent-color: var(--primario); }
.campanha span { flex: 1; overflow-wrap: anywhere; }
.campanha small { color: var(--texto-suave); white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ---------- Clientes: metas ---------- */

.linha-metas { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 8px; }
.linha-metas input { margin-bottom: 8px; }
.rotulo-fino { font-weight: 400; font-size: 12.5px; color: var(--texto-suave); }
.dica-inline { font-weight: 400; color: var(--texto-suave); }
#edicao-evento-manual { margin-top: -8px; }
@media (max-width: 640px) { .linha-metas { grid-template-columns: 1fr; } }

/* ---------- Minha conta ---------- */

.logo-area { display: flex; gap: 16px; align-items: flex-start; margin-bottom: 16px; flex-wrap: wrap; }
.logo-area input[type=file] { margin-bottom: 12px; }
.logo-previa {
  width: 180px; height: 90px; flex-shrink: 0;
  border: 1px dashed var(--campo); border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  background: var(--realce); color: var(--texto-suave); font-size: 13px; overflow: hidden;
}
.logo-previa img { max-width: 100%; max-height: 100%; object-fit: contain; }
.seletor-cor { width: 52px; height: 38px; padding: 3px; margin: 0; cursor: pointer; }

/* ---------- Administração ---------- */

.link-gerado { margin-top: 16px; font-size: 13px; }
.link-gerado p { margin: 0 0 8px; color: var(--texto-suave); }
.conta-admin { border: 1px solid var(--borda); border-radius: var(--raio); margin-bottom: 14px; overflow: hidden; }
.conta-admin .tabela-envoltorio { margin: 0; }
.conta-topo {
  display: flex; flex-wrap: wrap; gap: 10px; justify-content: space-between; align-items: center;
  padding: 14px 24px; border-bottom: 1px solid var(--borda); background: var(--realce);
}
.conta-topo strong { font-size: 14px; }
.conta-topo small { color: var(--texto-suave); display: block; margin-top: 2px; }
.conta-admin.inativo .conta-topo strong { color: var(--texto-suave); }

/* ---------- Telas de login e convite ---------- */

body.centralizado { display: grid; place-items: center; min-height: 100vh; padding: 24px 16px; }
body.centralizado main { width: 100%; max-width: 400px; margin: 0; padding: 0; }
body.centralizado .marca-sistema { justify-content: center; padding: 0 0 20px; font-size: 16px; }
body.centralizado .card { padding: 28px; }
body.centralizado .card h1 { text-align: center; margin-bottom: 4px; }
body.centralizado .card h1 + .dica, body.centralizado .card h1 + p { text-align: center; margin: 0 0 22px; }
body.centralizado button[type=submit] { width: 100%; margin-top: 4px; }
body.centralizado .card > .dica:last-child { text-align: center; }
.links-legais { text-align: center; font-size: 12.5px; color: var(--texto-suave); margin: 16px 0 0; }
.links-legais a { color: var(--texto-suave); }
