:root {
  --bg: #f3f3f3;
  --card: #ffffff;
  --texto: #252423;
  --texto-suave: #605e5c;
  --borda: #e1e1e1;
  --borda-forte: #d0d0d0;
  --verde: #2f7d4f;
  --verde-escuro: #245f3c;
  --taupe: #9c8567;
  --alerta: #c0392b;
  --atencao: #b8860b;
  --cinza-forte: #82868b;
  --header-bg: #ffffff;
  --sombra: 0 1px 2px rgba(0, 0, 0, 0.05);
  --tooltip-bg: #ffffff;
  --tooltip-txt: #373d3f;
  --tooltip-border: #e3e3e3;
  --ai-bg: #ffffff;
  --radius: 3px;
}

html[data-theme="dark"] {
  --bg: #1b1a19;
  --card: #252423;
  --texto: #f3f2f1;
  --texto-suave: #a19f9d;
  --borda: #3b3a39;
  --borda-forte: #484644;
  --verde: #4a9d6e;
  --verde-escuro: #3a8058;
  --taupe: #b09877;
  --alerta: #d65a4a;
  --atencao: #d4a72c;
  --cinza-forte: #8b8f93;
  --header-bg: #252423;
  --sombra: none;
  --tooltip-bg: #1e1e1e;
  --tooltip-txt: #ffffff;
  --tooltip-border: #333333;
  --ai-bg: #252423;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "Segoe UI", system-ui, Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--texto);
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: var(--header-bg);
  color: var(--texto);
  border-bottom: 1px solid var(--borda);
}
.brand { display: flex; align-items: center; gap: 11px; }
.logo { display: flex; align-items: center; }
/* a marca é um emblema circular claro: funciona nos dois temas sem inversão */
.logo img { display: block; width: 40px; height: 40px; }
.brand-text h1 { font-size: 17px; font-weight: 700; letter-spacing: 0; }
.brand-text .subtitle { font-size: 12px; color: var(--texto-suave); font-weight: 400; }
.meta { display: flex; align-items: center; gap: 14px; }
.meta .updated { font-size: 12px; color: var(--texto-suave); font-weight: 400; }
.theme-toggle {
  border: 1px solid var(--borda-forte);
  background: transparent;
  color: var(--texto-suave);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.theme-toggle:hover { background: var(--bg); color: var(--texto); }

/* ---------- Tabs ---------- */
.tabs {
  display: flex;
  align-items: stretch;
  gap: 2px;
  padding: 0 24px;
  background: var(--card);
  border-bottom: 1px solid var(--borda);
}
.tab {
  border: none;
  background: transparent;
  color: var(--texto-suave);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 11px 16px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.12s, border-color 0.12s;
}
.tab:hover { color: var(--texto); }
.tab.active { color: var(--verde); border-bottom-color: var(--verde); }
.btn-importar {
  margin-left: auto;
  align-self: center;
  border: 1px solid var(--borda-forte);
  background: transparent;
  color: var(--texto);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.12s;
}
.btn-importar:hover { background: var(--bg); }

/* ---------- Layout ---------- */
main { padding: 18px 24px 8px; max-width: 1320px; margin: 0 auto; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.section-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--texto-suave);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin: 20px 0 10px;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--borda);
}

.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.grid.grid-2 { grid-template-columns: repeat(2, 1fr); }
.pair-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
  align-items: stretch;
}
.pair-2 > * { margin-bottom: 0; }
.pair-2 #alertas { display: flex; flex-direction: column; }
.pair-2 .alertas { flex: 1; margin-bottom: 0; }
.pair-2 .ai-summary { margin-bottom: 0; }
@media (max-width: 900px) { .pair-2, .grid.grid-2 { grid-template-columns: 1fr; } }
.card {
  background: var(--card);
  border: 1px solid var(--borda);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--sombra);
}
.card.span-2 { grid-column: span 2; }
.card.span-3 { grid-column: span 3; }
.card h3 {
  font-size: 13px;
  font-weight: 700;
  color: var(--texto);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.card h3 .hint {
  font-size: 11.5px;
  font-weight: 400;
  color: var(--texto-suave);
  text-transform: none;
  letter-spacing: 0;
}

/* ---------- Info tooltip ---------- */
.info {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid var(--borda-forte);
  background: transparent;
  color: var(--texto-suave);
  font-size: 9px;
  font-weight: 700;
  font-style: normal;
  cursor: help;
  position: relative;
  flex: 0 0 auto;
}
.info::after {
  content: attr(data-tip);
  position: absolute;
  top: 150%;
  left: 0;
  width: 240px;
  background: var(--tooltip-bg);
  color: var(--tooltip-txt);
  border: 1px solid var(--tooltip-border);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.4;
  text-transform: none;
  letter-spacing: 0;
  padding: 9px 11px;
  border-radius: var(--radius);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s;
  z-index: 50;
}
.info:hover::after { opacity: 1; }
.info.left::after { left: auto; right: 0; }

/* ---------- Import button (nav) já acima ---------- */

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}
.modal-overlay[hidden] { display: none; }
.modal {
  background: var(--card);
  border: 1px solid var(--borda-forte);
  border-radius: var(--radius);
  width: 100%;
  max-width: 440px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--borda);
}
.modal-head h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--texto);
  display: flex;
  align-items: center;
  gap: 8px;
}
.modal-close {
  border: none;
  background: transparent;
  color: var(--texto-suave);
  font-size: 15px;
  cursor: pointer;
  line-height: 1;
  padding: 4px;
}
.modal-close:hover { color: var(--texto); }
.modal-body { padding: 16px; }
.modal-desc { font-size: 13px; color: var(--texto-suave); margin-bottom: 14px; line-height: 1.45; }
.field { display: block; margin-bottom: 14px; }
.field-label { display: block; font-size: 11px; font-weight: 700; color: var(--texto-suave); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 5px; }
.field select {
  width: 100%;
  font-family: inherit;
  font-size: 13px;
  color: var(--texto);
  background: var(--card);
  border: 1px solid var(--borda-forte);
  border-radius: var(--radius);
  padding: 8px 10px;
  cursor: pointer;
}
.dropzone {
  border: 1px dashed var(--borda-forte);
  border-radius: var(--radius);
  padding: 22px 16px;
  text-align: center;
  transition: border-color 0.12s, background 0.12s;
}
.dropzone.drag { border-color: var(--verde); background: var(--bg); }
.dz-icon { color: var(--texto-suave); margin-bottom: 8px; display: flex; justify-content: center; }
.dz-main { font-size: 13px; font-weight: 600; color: var(--texto); }
.dz-hint { font-size: 12px; color: var(--texto-suave); margin-top: 6px; }
.link-btn {
  border: none;
  background: none;
  color: var(--verde);
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
}
.link-btn:hover { text-decoration: underline; }
.modal-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 16px;
  border-top: 1px solid var(--borda);
}
.import-last { font-size: 12px; color: var(--texto-suave); }
.import-last b { color: var(--texto); font-weight: 600; }
.btn-import {
  background: var(--verde);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 9px 18px;
  font-family: inherit;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: filter 0.12s;
}
.btn-import:hover:not(:disabled) { filter: brightness(1.08); }
.btn-import:disabled { opacity: 0.45; cursor: not-allowed; }

/* ---------- Análise (AI summary) ---------- */
.ai-summary {
  background: var(--ai-bg);
  border: 1px solid var(--borda);
  border-left: 3px solid var(--verde);
  border-radius: var(--radius);
  padding: 12px 16px;
  box-shadow: var(--sombra);
  margin-bottom: 12px;
}
.ai-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--verde);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 4px;
}
.ai-tag {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--texto-suave);
  border: 1px solid var(--borda-forte);
  border-radius: 2px;
  padding: 1px 6px;
}
.ai-text { font-size: 14px; font-weight: 400; color: var(--texto); line-height: 1.5; }

/* ---------- KPI strip ---------- */
.kpi-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}
.kpi {
  background: var(--card);
  border: 1px solid var(--borda);
  border-radius: var(--radius);
  padding: 13px 15px;
  box-shadow: var(--sombra);
}
.kpi .kpi-label { font-size: 11px; font-weight: 600; color: var(--texto-suave); text-transform: uppercase; letter-spacing: 0.4px; display: flex; align-items: center; gap: 5px; }
.kpi .kpi-value { font-size: 23px; font-weight: 700; color: var(--texto); margin-top: 5px; }
.kpi .kpi-value.up { color: var(--verde); }
.kpi .kpi-value.down { color: var(--alerta); }
.kpi .kpi-value.warn { color: var(--atencao); }
.kpi .kpi-value.bad { color: var(--alerta); }
.kpi .kpi-sub { font-size: 11.5px; color: var(--texto-suave); margin-top: 3px; }

/* ---------- Alertas ---------- */
.alertas {
  background: var(--card);
  border: 1px solid var(--borda);
  border-left: 3px solid var(--atencao);
  border-radius: var(--radius);
  padding: 12px 16px;
  box-shadow: var(--sombra);
  margin-bottom: 4px;
}
.alertas h3 {
  font-size: 11px;
  font-weight: 700;
  color: var(--atencao);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.alertas ul { list-style: none; display: flex; flex-wrap: wrap; gap: 6px 24px; }
.alertas li { font-size: 13px; color: var(--texto); }
.alertas li b { font-weight: 600; }
.alertas .qtd { color: var(--verde); font-weight: 700; }
.alertas .tudo-ok { font-size: 13px; color: var(--texto-suave); }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--borda); color: var(--texto); }
th { font-weight: 700; color: var(--texto-suave); text-transform: uppercase; font-size: 10.5px; letter-spacing: 0.4px; }
td.num, th.num { text-align: right; }
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 2px;
  font-size: 11px;
  font-weight: 600;
}
.badge.ok { background: transparent; color: var(--verde); border: 1px solid var(--verde); }
.badge.low { background: transparent; color: var(--atencao); border: 1px solid var(--atencao); }
.badge.crit { background: transparent; color: var(--alerta); border: 1px solid var(--alerta); }

/* ---------- Marketing ---------- */
.section-title .st-hint {
  font-size: 11px;
  font-weight: 400;
  color: var(--texto-suave);
  text-transform: none;
  letter-spacing: 0;
  margin-left: 8px;
}

/* nota explicativa (ressalva honesta sobre atribuição) */
.note {
  background: var(--card);
  border: 1px solid var(--borda);
  border-left: 3px solid var(--cinza-forte, #82868b);
  border-radius: var(--radius);
  padding: 11px 15px;
  margin-bottom: 12px;
  box-shadow: var(--sombra);
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--texto-suave);
}
.note b { color: var(--texto); font-weight: 600; }
.note i { font-style: normal; font-weight: 600; color: var(--texto); }

/* funil (indicador sem gráfico) */
.funil { display: flex; flex-direction: column; }
.funil-step + .funil-step { margin-top: 2px; }
.funil-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  font-size: 12px;
  color: var(--texto-suave);
  margin-bottom: 4px;
}
.funil-top b { font-size: 15px; font-weight: 700; color: var(--texto); }
.funil-bar { height: 24px; background: var(--verde); border-radius: 1px; }
.funil-conv {
  font-size: 11px;
  color: var(--texto-suave);
  padding: 8px 0 10px 10px;
  border-left: 1px dotted var(--borda-forte);
  margin-left: 8px;
}
.funil-foot {
  margin-top: 16px;
  padding-top: 11px;
  border-top: 1px solid var(--borda);
  font-size: 12px;
  color: var(--texto-suave);
  line-height: 1.5;
}
.funil-foot b { color: var(--texto); font-weight: 700; }

/* barra fina dentro de tabelas */
.mini-bar {
  display: inline-block;
  vertical-align: middle;
  width: 64px;
  height: 6px;
  background: var(--borda);
  border-radius: 1px;
  overflow: hidden;
  margin-right: 7px;
}
.mini-bar > i { display: block; height: 100%; background: var(--verde); }
.mini-bar.alt > i { background: var(--taupe); }

.badge.neutro { background: transparent; color: var(--texto-suave); border: 1px solid var(--borda-forte); }
td .plat { font-weight: 600; }
td .plat small { display: block; font-weight: 400; font-size: 11px; color: var(--texto-suave); }
td.destaque-bom { color: var(--verde); font-weight: 700; }
td.destaque-ruim { color: var(--alerta); font-weight: 700; }

/* lista de destaques */
.destaques-lista { list-style: none; display: flex; flex-direction: column; gap: 9px; }
.destaques-lista li { font-size: 12.5px; color: var(--texto-suave); line-height: 1.45; }
.destaques-lista li b { color: var(--texto); font-weight: 600; }
.destaques-lista .dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-right: 7px;
  vertical-align: middle;
  background: var(--cinza-forte, #82868b);
}
.destaques-lista .dot.bom { background: var(--verde); }
.destaques-lista .dot.ruim { background: var(--alerta); }
.destaques-lista .dot.aten { background: var(--atencao); }

/* comparativo pago × orgânico */
.comparativo { display: flex; flex-direction: column; gap: 16px; }
.comp-top { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 5px; }
.comp-top span { font-size: 12px; font-weight: 600; color: var(--texto-suave); text-transform: uppercase; letter-spacing: 0.4px; }
.comp-top b { font-size: 19px; font-weight: 700; color: var(--texto); }
.comp-bar { height: 12px; background: var(--borda); border-radius: 1px; overflow: hidden; }
.comp-bar > i { display: block; height: 100%; background: var(--verde); }
.comp-bar.alt > i { background: var(--taupe); }
.comp-sub { font-size: 11.5px; color: var(--texto-suave); margin-top: 5px; }

/* ---------- Footer ---------- */
.foot {
  text-align: center;
  color: var(--texto-suave);
  font-size: 11.5px;
  padding: 18px;
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .grid { grid-template-columns: 1fr; }
  .card.span-2, .card.span-3 { grid-column: span 1; }
}
