:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --surface-2: #f1f0eb;
  --text: #1a1a18;
  --text-2: #5f5e5a;
  --text-muted: #8a8983;
  --border: #e2e0d8;
  --border-strong: #c9c7bc;
  --accent: #185fa5;
  --accent-bg: #e6f1fb;
  --success: #0f6e56;
  --success-bg: #e1f5ee;
  --warning: #854f0b;
  --warning-bg: #faeeda;
  --danger: #a32d2d;
  --danger-bg: #fcebeb;
  --radius: 8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.container { max-width: 1080px; margin: 0 auto; padding: 24px 20px 64px; }

header.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; background: var(--surface); border-bottom: 1px solid var(--border);
}
header.topbar .brand { font-weight: 600; font-size: 15px; text-decoration: none; color: var(--text); }
header.topbar nav a {
  margin-left: 18px; font-size: 14px; color: var(--text-2); text-decoration: none;
}
header.topbar nav a.active, header.topbar nav a:hover { color: var(--text); font-weight: 500; }

h1 { font-size: 22px; font-weight: 600; margin: 0 0 4px; }
h2 { font-size: 17px; font-weight: 600; margin: 0 0 10px; }
h3 { font-size: 14px; font-weight: 600; margin: 0 0 8px; }
p.subtitle { color: var(--text-2); font-size: 14px; margin: 0 0 20px; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 16px 20px; margin-bottom: 12px;
}

.metric-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 20px; }
.metric-card { background: var(--surface-2); border-radius: var(--radius); padding: 14px 16px; }
.metric-card .label { font-size: 12px; color: var(--text-2); margin: 0 0 4px; }
.metric-card .value { font-size: 22px; font-weight: 600; margin: 0; }

select, input[type=text], input[type=number], input[type=date], input[type=password], textarea {
  font-family: inherit; font-size: 14px; padding: 8px 10px; border: 1px solid var(--border-strong);
  border-radius: var(--radius); background: var(--surface); color: var(--text); width: 100%;
}
textarea { min-height: 70px; resize: vertical; }
label.field-label { display: block; font-size: 12px; color: var(--text-2); margin: 0 0 4px; }
.field { margin-bottom: 12px; }

button, a.button {
  font-family: inherit; font-size: 14px; padding: 8px 16px; border-radius: var(--radius);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  cursor: pointer; text-decoration: none; display: inline-block;
}
button:hover, a.button:hover { background: var(--surface-2); }
button.primary { background: var(--text); color: var(--surface); border-color: var(--text); }
button.primary:hover { opacity: 0.9; }
button.danger { color: var(--danger); border-color: var(--danger-bg); }
button.small { padding: 4px 10px; font-size: 12px; }

.chip {
  display: inline-flex; align-items: center; gap: 4px; font-size: 12px; padding: 3px 10px;
  border-radius: var(--radius); background: var(--surface-2); color: var(--text-2);
}
.chip.ok { background: var(--success-bg); color: var(--success); }
.chip.warn { background: var(--warning-bg); color: var(--warning); }
.chip.bad { background: var(--danger-bg); color: var(--danger); }

.rank-row {
  display: flex; align-items: center; gap: 14px; padding: 12px 20px;
}
.rank-row .pos { width: 24px; font-weight: 600; color: var(--text-muted); }
.rank-row .info { flex: 1; }
.rank-row .info .name { font-weight: 500; font-size: 14px; margin: 0; }
.rank-row .info .sub { font-size: 12px; color: var(--text-2); margin: 0; }
.rank-row .stat { min-width: 140px; text-align: right; font-weight: 600; }
.rank-row a { text-decoration: none; color: inherit; }

table.datatable { width: 100%; border-collapse: collapse; font-size: 13px; }
table.datatable th { text-align: left; color: var(--text-muted); font-weight: 500; padding: 6px 8px; border-bottom: 1px solid var(--border); }
table.datatable td { padding: 6px 8px; border-bottom: 1px solid var(--border); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
@media (max-width: 640px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

.section-title {
  font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.02em;
  color: var(--text-2); margin: 24px 0 10px; padding-top: 12px; border-top: 1px solid var(--border);
}
.section-title:first-child { margin-top: 0; border-top: none; padding-top: 0; }

.error-box { background: var(--danger-bg); color: var(--danger); padding: 10px 14px; border-radius: var(--radius); font-size: 13px; margin-bottom: 14px; }
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-2); }

.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.photo-grid img { width: 100%; height: 100px; object-fit: cover; border-radius: var(--radius); border: 1px solid var(--border); }

.checklist-item { display: flex; align-items: center; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.checklist-item:last-child { border-bottom: none; }

/* ---- fotos e placeholders ---- */
.photo-placeholder { width: 100%; height: 100%; color: var(--text-muted); display: flex; align-items: center; justify-content: center; }
.battery-photo-cover { width: 100%; aspect-ratio: 4 / 3; border-radius: 12px 12px 0 0; overflow: hidden; background: var(--surface-2); display: flex; align-items: center; justify-content: center; }
.battery-photo-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.battery-photo-square { width: 100%; aspect-ratio: 1 / 1; border-radius: var(--radius); overflow: hidden; background: var(--surface-2); display: flex; align-items: center; justify-content: center; }
.battery-photo-square img { width: 100%; height: 100%; object-fit: cover; display: block; }
.battery-photo-hero { width: 88px; height: 88px; border-radius: 12px; overflow: hidden; background: var(--surface-2); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.battery-photo-hero img { width: 100%; height: 100%; object-fit: cover; display: block; }
.battery-photo-thumb { width: 44px; height: 44px; border-radius: var(--radius); overflow: hidden; background: var(--surface-2); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.battery-photo-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ---- grid de cards (ranking / comparador) ---- */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.battery-card {
  display: flex; flex-direction: column; background: var(--surface);
  border: 1px solid var(--border); border-radius: 12px; overflow: hidden; position: relative;
  transition: box-shadow 0.15s ease, transform 0.15s ease, border-color 0.15s ease;
}
.battery-card:hover { box-shadow: 0 6px 20px rgba(20, 20, 18, 0.09); transform: translateY(-2px); border-color: var(--border-strong); }
/* o link que cobre foto+corpo do card fica separado do botao "Comprar"
   (que e um <a> irmao, nao aninhado) para o HTML continuar valido - um
   <a> nao pode conter outro <a> clicavel dentro. */
.battery-card-link { display: flex; flex-direction: column; flex: 1; text-decoration: none; color: inherit; }
.battery-card .body { padding: 14px 16px 16px; display: flex; flex-direction: column; flex: 1; }
.battery-card .name { margin: 0; font-size: 15px; font-weight: 600; }
.battery-card .sub { margin: 2px 0 10px; font-size: 12px; color: var(--text-2); }
/* ancora o bloco final (preco/Ah/Wh) no rodape do card, para alinhar
   entre baterias mesmo quando a quantidade de badges/linhas acima varia */
.battery-card .card-footer { margin-top: auto; }
.rank-badge {
  position: absolute; top: 10px; left: 10px; background: rgba(26, 26, 24, 0.82); color: #fff;
  font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px; letter-spacing: 0.01em;
}
.battery-card .chips-row { display: flex; flex-wrap: wrap; gap: 6px; position: absolute; top: 10px; right: 10px; }
.battery-card .stat-highlight { font-size: 20px; font-weight: 600; margin: 2px 0 8px; }
.battery-card .stat-highlight .unit { font-size: 13px; font-weight: 400; color: var(--text-2); margin-left: 3px; }
.battery-card .mini-stats { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--text-2); padding-top: 10px; border-top: 1px solid var(--border); }
.battery-card .mini-stats b { color: var(--text); font-weight: 600; }

/* ---- barras de comparacao ---- */
.metric-row { margin-bottom: 12px; }
.metric-row .top-line { display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; margin-bottom: 4px; }
.metric-row .top-line .lbl { color: var(--text-2); }
.metric-row .top-line .val { font-weight: 600; }
.metric-bar-track { width: 100%; height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.metric-bar-fill { height: 100%; border-radius: 3px; background: var(--accent); transition: width 0.2s ease; }
.metric-bar-fill.best { background: var(--success); }

.search-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.search-row input[type=text] { max-width: 260px; }

/* ---- nota Guanabara e badges de categoria ---- */
.stars { color: #ad7f0a; font-weight: 600; letter-spacing: 1px; font-size: 14px; }
.stars .num { color: var(--text); font-weight: 600; margin-left: 4px; letter-spacing: normal; font-size: 13px; }
.nota-row { display: flex; align-items: center; gap: 4px; margin: 4px 0 8px; min-height: 20px; }
.nota-row .sem-nota { font-size: 12px; color: var(--text-muted); }
.badges-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; min-height: 22px; }
.chip.badge { background: var(--accent-bg); color: var(--accent); }

.winner-icon { display: inline-block; vertical-align: -2px; margin-left: 4px; }

.nota-metodologia { margin-top: 10px; font-size: 12px; color: var(--text-2); }
.nota-metodologia summary { cursor: pointer; font-size: 13px; color: var(--accent); font-weight: 500; }
.nota-metodologia summary:hover { text-decoration: underline; }
.nota-metodologia p { margin: 8px 0; }
.nota-metodologia ul { margin: 6px 0; padding-left: 18px; }
.nota-metodologia li { margin-bottom: 6px; }

.aviso-amostra { font-size: 12px; color: var(--text-2); background: var(--surface-2); padding: 8px 12px; border-radius: var(--radius); margin: 4px 0 14px; }

.video-link { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; padding: 6px 12px; border-radius: var(--radius); background: var(--danger); color: #fff; text-decoration: none; border: none; }
.video-link:hover { opacity: 0.9; }

/* botao "Onde comprar" na ficha (ao lado do "Assistir ao teste") */
.buy-link-inline { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; padding: 6px 12px; border-radius: var(--radius); background: var(--accent); color: #fff; text-decoration: none; border: none; }
.buy-link-inline:hover { opacity: 0.9; }

/* barra "Comprar" no rodape dos cards do ranking/comparador */
.battery-card .buy-link {
  display: block; text-align: center; font-size: 13px; font-weight: 600; padding: 10px 12px;
  background: var(--accent); color: #fff; text-decoration: none; border-top: 1px solid var(--border);
}
.battery-card .buy-link:hover { opacity: 0.9; }
