/* Design system do painel — tema escuro padrão, toggle claro (aula 13). */
:root,
[data-theme="dark"] {
  --bg: 222 30% 6%;
  --bg-2: 222 26% 9%;
  --cartao: 222 24% 11%;
  --borda: 222 18% 20%;
  --texto: 210 20% 94%;
  --texto-2: 215 14% 62%;
  --primaria: 142 76% 58%;
  --primaria-texto: 222 30% 6%;
  --ciano: 189 85% 55%;
  --ambar: 38 92% 58%;
  --perigo: 0 80% 62%;
  --raio: 0.625rem;
  --sombra: 0 10px 30px -12px hsl(0 0% 0% / 0.6);
  color-scheme: dark;
}
[data-theme="light"] {
  --bg: 210 25% 97%;
  --bg-2: 210 22% 93%;
  --cartao: 0 0% 100%;
  --borda: 214 18% 86%;
  --texto: 222 30% 12%;
  --texto-2: 218 12% 40%;
  --primaria: 142 70% 26%;
  --primaria-texto: 0 0% 100%;
  --ciano: 192 80% 32%;
  --ambar: 32 90% 38%;
  --perigo: 0 70% 45%;
  --sombra: 0 10px 30px -14px hsl(220 30% 30% / 0.25);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Manrope", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: hsl(var(--texto));
  background:
    radial-gradient(1200px 600px at 10% -10%, hsl(var(--primaria) / 0.10), transparent 60%),
    radial-gradient(900px 500px at 110% 10%, hsl(var(--ciano) / 0.08), transparent 60%),
    hsl(var(--bg));
  background-attachment: fixed;
  min-height: 100vh;
}
.mono, code, pre { font-family: "JetBrains Mono", ui-monospace, monospace; font-variant-numeric: tabular-nums; }
.pequeno { font-size: 12px; color: hsl(var(--texto-2)); }
a { color: hsl(var(--primaria)); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.35rem; font-weight: 800; }
h2 { font-size: 1.05rem; font-weight: 700; }
p { margin: 0 0 .75rem; }

/* ── Estrutura ─────────────────────────────────────────────── */
.app { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar {
  background: hsl(var(--bg-2) / 0.85);
  backdrop-filter: blur(10px);
  border-right: 1px solid hsl(var(--borda));
  padding: 1.25rem 1rem;
  display: flex; flex-direction: column; gap: 1.5rem;
  position: sticky; top: 0; height: 100vh;
}
.marca { display: flex; align-items: center; gap: .5rem; font-weight: 800; font-size: 1.1rem; }
.ponto { width: 10px; height: 10px; border-radius: 50%; background: hsl(var(--primaria)); box-shadow: 0 0 12px hsl(var(--primaria)); }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sidebar nav a, .sidebar nav .em-breve {
  padding: .6rem .75rem; border-radius: var(--raio); text-decoration: none;
  color: hsl(var(--texto-2)); font-weight: 600; min-height: 40px; display: flex; align-items: center;
}
.sidebar nav a:hover { background: hsl(var(--cartao)); color: hsl(var(--texto)); }
.sidebar nav a.ativo { background: hsl(var(--primaria) / 0.12); color: hsl(var(--primaria)); }
.sidebar nav .em-breve { opacity: .4; cursor: default; }
.sidebar-rodape { display: flex; flex-direction: column; gap: .25rem; word-break: break-all; }
.conteudo { padding: 1.5rem 2rem 3rem; min-width: 0; }
.topo { display: flex; align-items: center; gap: .75rem; margin-bottom: 1.5rem; }
.topo h1 { flex: 1; margin: 0; }
.btn-menu { display: none; }
.menu-toggle { display: none; }
.btn-tema, .btn-menu {
  background: hsl(var(--cartao)); border: 1px solid hsl(var(--borda)); color: hsl(var(--texto));
  border-radius: var(--raio); width: 40px; height: 40px; cursor: pointer; font-size: 1.1rem;
  align-items: center; justify-content: center;
}
.btn-tema { display: inline-flex; }

/* ── Componentes ───────────────────────────────────────────── */
.cartao {
  background: hsl(var(--cartao) / 0.75);
  backdrop-filter: blur(8px);
  border: 1px solid hsl(var(--borda));
  border-radius: calc(var(--raio) * 1.4);
  padding: 1.25rem;
  box-shadow: var(--sombra);
}
.grade { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); margin-bottom: 1rem; }
.kpi .rotulo { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: hsl(var(--texto-2)); font-weight: 700; }
.kpi .valor { font-family: "JetBrains Mono", monospace; font-variant-numeric: tabular-nums; font-size: 1.6rem; font-weight: 600; margin-top: .25rem; }
.selo { white-space: nowrap; display: inline-flex; align-items: center; gap: .35rem; padding: .15rem .55rem; border-radius: 999px; font-size: 12px; font-weight: 700; }
.selo.ok { background: hsl(var(--primaria) / 0.14); color: hsl(var(--primaria)); }
.selo.aviso { background: hsl(var(--ambar) / 0.14); color: hsl(var(--ambar)); }
.selo.erro { background: hsl(var(--perigo) / 0.14); color: hsl(var(--perigo)); }
.lista-status { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .6rem; }
.lista-status li { display: flex; justify-content: space-between; gap: 1rem; align-items: center; flex-wrap: wrap; }

/* ── Formulários ───────────────────────────────────────────── */
label { display: block; font-weight: 600; font-size: 13px; margin: .9rem 0 .35rem; }
.dica { font-weight: 400; color: hsl(var(--texto-2)); font-size: 12px; display: block; margin-top: .2rem; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=url], input[type=date], select, textarea {
  width: 100%; min-height: 44px; padding: .6rem .8rem; font: inherit;
  background: hsl(var(--bg-2)); color: hsl(var(--texto));
  border: 1px solid hsl(var(--borda)); border-radius: var(--raio);
}
input:focus, select:focus, textarea:focus { outline: 2px solid hsl(var(--primaria) / 0.5); border-color: hsl(var(--primaria)); }
.checkbox { display: flex; gap: .5rem; align-items: flex-start; font-weight: 500; }
.checkbox input { margin-top: .25rem; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: 44px; padding: .6rem 1.2rem; border-radius: var(--raio); border: 0; cursor: pointer;
  background: hsl(var(--primaria)); color: hsl(var(--primaria-texto)); font: inherit; font-weight: 700;
  text-decoration: none;
}
.btn:hover { filter: brightness(1.08); }
.btn.secundario { background: transparent; color: hsl(var(--texto)); border: 1px solid hsl(var(--borda)); }
.btn.largo { width: 100%; margin-top: 1.25rem; }
.alerta { overflow-wrap: anywhere; padding: .75rem 1rem; border-radius: var(--raio); margin: 1rem 0; font-size: 14px; }
.alerta.erro { background: hsl(var(--perigo) / 0.12); border: 1px solid hsl(var(--perigo) / 0.4); }
.alerta.ok { background: hsl(var(--primaria) / 0.10); border: 1px solid hsl(var(--primaria) / 0.4); }
.alerta.aviso { background: hsl(var(--ambar) / 0.10); border: 1px solid hsl(var(--ambar) / 0.4); }
fieldset { border: 1px solid hsl(var(--borda)); border-radius: var(--raio); padding: .5rem 1rem 1rem; margin: 1rem 0 0; }
legend { font-weight: 800; padding: 0 .4rem; }

/* ── Telas simples (login/instalador) ──────────────────────── */
.tela-simples { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 2rem 1rem; }
.cartao-simples { width: 100%; max-width: 520px; }
.cartao-simples .marca { margin-bottom: 1rem; }

/* ── Celular ───────────────────────────────────────────────── */
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 20;
    transform: translateX(-100%); transition: transform .2s ease;
  }
  .menu-toggle:checked ~ .sidebar { transform: none; box-shadow: var(--sombra); }
  .btn-menu { display: inline-flex; }
  .conteudo { padding: 1rem 1rem 3rem; }
}

/* ── Fase 5A: tabelas, filtros, formulários, detalhes ─────────── */
.secao { margin-bottom: 1rem; }
.secao > h2 { margin-bottom: .75rem; }
.vazio { color: hsl(var(--texto-2)); padding: 1rem 0; margin: 0; }
.barra-acoes { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; align-items: center; }
.barra-acoes form { margin: 0; }
.tabela-rolagem { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -.25rem; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: hsl(var(--texto-2)); font-weight: 700; padding: .5rem .5rem; border-bottom: 1px solid hsl(var(--borda)); white-space: nowrap; }
td { padding: .55rem .5rem; border-bottom: 1px solid hsl(var(--borda) / .6); vertical-align: middle; }
tr:hover td { background: hsl(var(--primaria) / .03); }
tr.apagada td { opacity: .5; }
td input[type=text], td input[type=number] { min-height: 36px; padding: .35rem .5rem; }
input.curto { width: 5rem; }
.acoes-linha { display: flex; flex-wrap: wrap; gap: .35rem; justify-content: flex-end; }
.acoes-linha form { margin: 0; }
.btn.pequeno { min-height: 34px; padding: .3rem .7rem; font-size: 13px; }
.btn.perigo { background: transparent; color: hsl(var(--perigo)); border: 1px solid hsl(var(--perigo) / .5); }
.btn.perigo:hover { background: hsl(var(--perigo) / .1); }
.acoes-form { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-top: 1rem; }
.grade-form { display: grid; gap: 0 1rem; grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); }
.grade-2 { grid-template-columns: repeat(auto-fit, minmax(min(380px, 100%), 1fr)); }
.filtros { display: grid; gap: 0 .75rem; grid-template-columns: repeat(auto-fit, minmax(min(150px, 100%), 1fr)); align-items: end; margin-bottom: 1rem; padding: .25rem 1rem 1rem; }
.filtros label { margin-top: .6rem; }
.filtros .acoes-form { margin-top: 0; }
.paginacao { display: flex; gap: .75rem; align-items: center; justify-content: center; margin-top: 1rem; }
details.adicionar { margin-top: 1rem; }
details.adicionar > summary { list-style: none; display: inline-flex; }
details.adicionar > summary::-webkit-details-marker { display: none; }
details.adicionar[open] > summary { margin-bottom: .5rem; }
.form-conta { max-width: 560px; }
.copiar { display: flex; gap: .4rem; align-items: center; margin: 0; }
.copiar input { min-width: 0; flex: 1; font-size: 12px; }
pre.json, .bloco-codigo pre { background: hsl(var(--bg-2)); border: 1px solid hsl(var(--borda)); border-radius: var(--raio); padding: .75rem; font-size: 12px; line-height: 1.5; overflow: auto; max-height: 420px; margin: 0; white-space: pre-wrap; word-break: break-word; }
.bloco-codigo { position: relative; margin: .5rem 0 1rem; }
.bloco-codigo .btn { position: absolute; top: .4rem; right: .4rem; }
.bloco-codigo pre { padding-right: 6rem; }
.quebra { word-break: break-all; }
.opcoes-tipo { display: grid; gap: .5rem; grid-template-columns: repeat(auto-fit, minmax(min(190px, 100%), 1fr)); }
.opcao { margin: 0; font-weight: 500; cursor: pointer; }
.opcao input { position: absolute; opacity: 0; }
.opcao span { display: flex; flex-direction: column; gap: .15rem; height: 100%; padding: .7rem .8rem; border: 1px solid hsl(var(--borda)); border-radius: var(--raio); background: hsl(var(--bg-2)); }
.opcao small { color: hsl(var(--texto-2)); font-size: 12px; }
.opcao input:checked + span { border-color: hsl(var(--primaria)); background: hsl(var(--primaria) / .08); box-shadow: 0 0 0 1px hsl(var(--primaria)); }
.opcao input:focus-visible + span { outline: 2px solid hsl(var(--primaria) / .5); }
.opcoes-linha { display: flex; flex-wrap: wrap; gap: .25rem 1.25rem; }
[hidden] { display: none !important; }
.linha-tempo { list-style: none; padding: 0; margin: 0; border-left: 2px solid hsl(var(--borda)); }
.linha-tempo li { position: relative; padding: .35rem 0 .75rem 1rem; display: flex; flex-direction: column; gap: .1rem; }
.linha-tempo li::before { content: ""; position: absolute; left: -6px; top: .65rem; width: 10px; height: 10px; border-radius: 50%; background: hsl(var(--texto-2)); }
.linha-tempo .lt-etapa::before { background: hsl(var(--ciano)); }
.linha-tempo .lt-video::before { background: hsl(var(--ambar)); }
.linha-tempo .lt-compra::before { background: hsl(var(--primaria)); box-shadow: 0 0 8px hsl(var(--primaria)); }
td.mono { white-space: nowrap; }

/* ── Fase 5B: gráficos (uma série = uma cor; valor sempre escrito) ─ */
h3 { font-size: .95rem; font-weight: 700; margin: .25rem 0 .6rem; }
.grade-3 { grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr)); }
.chips { display: flex; gap: .35rem; align-items: end; padding-bottom: .2rem; flex-wrap: wrap; }
.chip { white-space: nowrap; display: inline-flex; align-items: center; min-height: 34px; padding: .25rem .7rem; border-radius: 999px; border: 1px solid hsl(var(--borda)); color: hsl(var(--texto-2)); text-decoration: none; font-size: 13px; font-weight: 600; }
.chip.ativo, .chip:hover { border-color: hsl(var(--primaria)); color: hsl(var(--primaria)); }
.barra-trilho { display: block; height: 10px; border-radius: 4px; background: hsl(var(--borda) / .45); overflow: hidden; }
.barra { display: block; height: 100%; border-radius: 4px; background: hsl(var(--primaria)); min-width: 2px; }
.funil { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.funil-etapa { display: flex; flex-direction: column; gap: .35rem; }
.funil-rotulo { display: flex; justify-content: space-between; gap: 1rem; font-weight: 600; flex-wrap: wrap; }
.funil-etapa .barra-trilho { height: 14px; }
.funil-passo { display: flex; gap: 1rem; flex-wrap: wrap; font-size: 12px; color: hsl(var(--texto-2)); padding: .45rem 0 .45rem .25rem; }
.funil-passo .saiu { color: hsl(var(--perigo) / .85); }
.barras { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .5rem; }
.barras li { display: grid; grid-template-columns: minmax(70px, 34%) 1fr auto; gap: .6rem; align-items: center; font-size: 13px; }
.barras-rotulo { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.barras-valor { color: hsl(var(--texto-2)); font-size: 12px; white-space: nowrap; }
.grafico { position: relative; }
svg.retencao { width: 100%; height: auto; display: block; overflow: visible; }
.retencao .grade-linha { stroke: hsl(var(--borda) / .7); stroke-width: 1; }
.retencao .eixo { fill: hsl(var(--texto-2)); font-size: 11px; font-family: "JetBrains Mono", monospace; }
.retencao .area { fill: hsl(var(--primaria) / .12); }
.retencao .linha { fill: none; stroke: hsl(var(--primaria)); stroke-width: 2; stroke-linejoin: round; }
.retencao .pitch { stroke: hsl(var(--ambar)); stroke-width: 1.5; stroke-dasharray: 4 4; }
.retencao .pitch-rotulo { fill: hsl(var(--texto)); font-size: 12px; font-weight: 700; }
.retencao .guia { stroke: hsl(var(--texto-2) / .6); stroke-width: 1; }
.retencao .ponto { fill: hsl(var(--primaria)); stroke: hsl(var(--cartao)); stroke-width: 2; }
.dica-grafico { position: absolute; pointer-events: none; background: hsl(var(--cartao)); border: 1px solid hsl(var(--borda)); border-radius: var(--raio); padding: .35rem .6rem; font-size: 12px; box-shadow: var(--sombra); white-space: nowrap; transform: translate(-50%, -110%); }
.ver-tabela { margin-top: .75rem; }
.ver-tabela summary { cursor: pointer; font-size: 13px; color: hsl(var(--texto-2)); }
.arvore .nivel-1 td { font-weight: 700; }
.arvore .nivel-2 td:first-child { padding-left: 1.6rem; }
.arvore .nivel-3 td:first-child { padding-left: 3.4rem; }
.arvore .nivel-3 td { font-size: 13px; }
.abrir { background: none; border: 0; color: hsl(var(--texto-2)); cursor: pointer; font-size: 14px; width: 28px; height: 28px; border-radius: 6px; }
.abrir:hover { background: hsl(var(--borda) / .5); }
.arvore td:first-child { white-space: nowrap; min-width: 220px; }
.link-sair { background: none; border: 0; padding: 0; color: hsl(var(--primaria)); text-decoration: underline; cursor: pointer; font: inherit; }
.destaques .valor { font-size: 1.4rem; }
.destaque-nome { display: block; margin-top: .3rem; font-size: 12px; color: hsl(var(--texto-2)); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tabela-anuncios th a { color: inherit; text-decoration: none; }
.tabela-anuncios th a:hover, .tabela-anuncios th a.ordem-ativa { color: hsl(var(--primaria)); }
.tabela-anuncios td:first-child { white-space: nowrap; }
.abas { display: flex; gap: .25rem; flex-wrap: wrap; margin-bottom: 1rem; border-bottom: 1px solid hsl(var(--borda)); }
.abas a { padding: .6rem 1rem; text-decoration: none; color: hsl(var(--texto-2)); font-weight: 700; border-bottom: 2px solid transparent; margin-bottom: -1px; min-height: 44px; display: inline-flex; align-items: center; }
.abas a:hover { color: hsl(var(--texto)); }
.abas a.ativa { color: hsl(var(--primaria)); border-bottom-color: hsl(var(--primaria)); }
td.negativo, .kpi .valor.negativo { color: hsl(var(--perigo)); }
.titulo-grade { margin: 20px 0 10px; }
.mix .mix-aprov { display: block; margin-top: .35rem; }
.mix-linha { font-size: 1.15rem !important; }
