/* ── Reset & Base ────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --border: #e0e0e0;
  --text: #1d1d1f;
  --text-light: #6e6e73;
  --accent: #0066cc;
  --accent-hover: #004499;
  --green: #30b94e;
  --green-bg: #e8f5e9;
  --yellow: #f5a623;
  --yellow-bg: #fff8e1;
  --red: #e53935;
  --red-bg: #ffebee;
  --gray: #9e9e9e;
  --gray-bg: #f0f0f0;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --transition: 0.2s ease;
}

html { font-size: 16px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 16px;
  width: 100%;
}

/* ── Header ──────────────────────────────────────────────────── */
.topo {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 24px 0 20px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.titulo-grupo {
  display: flex;
  align-items: center;
  gap: 10px;
}
.topo h1 { font-size: 1.4rem; font-weight: 700; letter-spacing: -0.02em; }
.subtitulo { font-size: 0.85rem; color: var(--text-light); margin-top: 4px; }

/* ── Methodology panel ───────────────────────────────────────── */
.btn-metodologia {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text-light);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all var(--transition);
}
.btn-metodologia:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: #f0f6ff;
}

.painel-metodologia {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0,0,0,0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}
.painel-metodologia.oculto { display: none !important; }

.painel-content {
  background: var(--surface);
  border-radius: 14px;
  max-width: 620px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  padding: 28px 30px;
  position: relative;
  box-shadow: 0 8px 30px rgba(0,0,0,0.15);
}
.fechar-metodologia {
  position: absolute;
  top: 12px; right: 16px;
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-light);
  cursor: pointer;
  line-height: 1;
}
.fechar-metodologia:hover { color: var(--text); }

.painel-content h3 {
  font-size: 1.1rem;
  margin-bottom: 12px;
  padding-right: 24px;
}
.painel-content h4 {
  font-size: 0.85rem;
  margin-top: 20px;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-light);
}
.painel-content p {
  font-size: 0.88rem;
  line-height: 1.6;
  color: var(--text);
  margin-bottom: 12px;
}

.tabela-metodologia {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  margin-bottom: 12px;
}
.tabela-metodologia td {
  padding: 7px 10px;
  border-bottom: 1px solid #f0f0f0;
  vertical-align: top;
  line-height: 1.5;
}
.tabela-metodologia td:first-child { white-space: nowrap; font-weight: 600; }
.tabela-metodologia td:nth-child(2) { white-space: nowrap; font-weight: 700; text-align: center; width: 60px; }
.met-verde { color: #1b5e20; }
.met-azul { color: #0d47a1; }
.met-amarelo { color: #e65100; }
.met-vermelho { color: #b71c1c; }
.met-cinza { color: var(--text-light); }

.met-aviso {
  font-size: 0.8rem !important;
  color: var(--text-light) !important;
  background: #fafafa;
  padding: 10px 14px;
  border-radius: 8px;
  margin-top: 8px;
  margin-bottom: 0 !important;
}

@media (max-width: 640px) {
  .painel-content { padding: 20px 18px; }
}

/* ── Controls ────────────────────────────────────────────────── */
.controles {
  margin: 16px 0;
}
.busca-grupo {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}
.busca-input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.95rem;
  background: var(--surface);
  outline: none;
  transition: border var(--transition), box-shadow var(--transition);
}
.busca-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0,102,204,0.12);
}
.contador {
  white-space: nowrap;
  font-size: 0.85rem;
  color: var(--text-light);
  font-variant-numeric: tabular-nums;
}

.filtros {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.filtro-grupo {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  min-width: 130px;
}
.filtro-grupo label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-light);
}
.filtro-grupo select {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.88rem;
  background: var(--surface);
  cursor: pointer;
  outline: none;
  transition: border var(--transition);
}
.filtro-grupo select:focus {
  border-color: var(--accent);
}

/* ── Table ───────────────────────────────────────────────────── */
.tabela-wrapper {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.tabela {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
.tabela thead {
  background: #fafafa;
  border-bottom: 1px solid var(--border);
}
.tabela th {
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-light);
  white-space: nowrap;
}
.tabela td { padding: 10px 12px; border-bottom: 1px solid #f0f0f0; }

/* Score badge */
.score-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  padding: 3px 10px;
  border-radius: 20px;
  font-weight: 700;
  font-size: 0.85rem;
  line-height: 1.4;
}
.score-verde { background: var(--green-bg); color: #1b5e20; }
.score-amarelo { background: var(--yellow-bg); color: #e65100; }
.score-vermelho { background: var(--red-bg); color: #b71c1c; }
.score-cinza { background: var(--gray-bg); color: var(--text-light); }

.risk-label { font-size: 0.82rem; }

/* Site badge */
.site-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}
.site-hellojapao { background: #e3f2fd; color: #0d47a1; }
.site-elausa { background: #fce4ec; color: #880e4f; }

/* Type badge */
.type-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 500;
  background: #f3f3f3;
  color: var(--text-light);
}

/* ── Expandable rows ─────────────────────────────────────────── */
.linha-produto {
  cursor: pointer;
  transition: background var(--transition);
}
.linha-produto:hover { background: #f8f8fa; }
.linha-produto.ativo { background: #f0f4ff; }

.linha-detalhe {
  display: none;
}
.linha-detalhe.visivel { display: table-row; }

.detalhe-content {
  padding: 16px 20px;
  background: #fafbfc;
  border-bottom: 1px solid var(--border);
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.detalhe-content h4 {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-light);
  margin-bottom: 4px;
  margin-top: 12px;
}
.detalhe-content h4:first-child { margin-top: 0; }

/* ── Ingredient breakdown table ──────────────────────────────── */
.det-scroll { overflow-x: auto; }
.det-tabela {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}
.det-tabela th {
  text-align: left;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-light);
  padding: 4px 8px 6px 8px;
  border-bottom: 1px solid var(--border);
}
.det-tabela td {
  padding: 5px 8px;
  border-bottom: 1px solid #f0f0f0;
  vertical-align: middle;
}
.det-num {
  width: 24px;
  text-align: center;
  color: var(--text-light);
  font-size: 0.72rem;
}
.det-cat { font-size: 0.78rem; }
.det-peso {
  text-align: center;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  width: 60px;
}
.det-top5 { color: #e65100; }

.det-ing-tag {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 0.78rem;
}

.det-formula {
  margin-top: 10px;
  padding: 8px 12px;
  background: #f8f9fa;
  border-radius: 8px;
  font-size: 0.82rem;
  line-height: 1.6;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.det-nota {
  font-size: 0.72rem;
  color: var(--text-light);
}

.ing-red { background: #ffebee; }
.ing-yellow { background: #fff8e1; }
.ing-green { background: #e8f5e9; }
.ing-blue { background: #e3f2fd; }
.ing-gray { background: #f0f0f0; }

.detalhe-claims {
  font-size: 0.82rem;
  color: var(--text-light);
  line-height: 1.6;
  white-space: pre-wrap;
}

.detalhe-link {
  display: inline-block;
  margin-top: 8px;
  color: var(--accent);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 500;
}
.detalhe-link:hover { text-decoration: underline; }

/* Expand indicator */
.expand-icon {
  display: inline-block;
  width: 20px;
  text-align: center;
  color: var(--text-light);
  transition: transform var(--transition);
  font-size: 0.7rem;
}
.linha-produto.ativo .expand-icon { transform: rotate(90deg); }

/* ── States ──────────────────────────────────────────────────── */
.carregando {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-light);
}
.erro {
  background: var(--red-bg);
  color: #b71c1c;
  padding: 14px 18px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 0.88rem;
}
.vazio {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-light);
  font-size: 0.95rem;
}
.oculto { display: none !important; }

/* ── Footer ──────────────────────────────────────────────────── */
.rodape {
  margin-top: auto;
  padding: 20px 0;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-light);
}
.rodape-fonte { margin-top: 4px; font-size: 0.72rem; }

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 640px) {
  .topo { padding: 16px 0 14px; }
  .topo h1 { font-size: 1.15rem; }
  .filtros { flex-direction: column; gap: 8px; }
  .filtro-grupo { min-width: 100%; }
  .busca-grupo { flex-direction: column; gap: 6px; }
  .contador { align-self: flex-end; }
  .tabela { font-size: 0.8rem; }
  .tabela th, .tabela td { padding: 8px 8px; }
  .col-marca, .col-tipo { display: none; }
}
