:root {
  --verde: #1f9d6b;
  --verde-escuro: #0d4f3c;
  --verde-claro: #e8f6ef;
  --tinta: #1a2b25;
  --cinza: #5b6b64;
  --borda: #dfe6e2;
  --fundo: #f5f8f7;
  --branco: #fff;
  --alerta: #fff4e0;
  --alerta-borda: #f0c674;
  --sombra: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--tinta);
  background: var(--fundo);
  line-height: 1.5;
}
a { color: var(--verde); }

/* ── Topo ── */
.topo {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 1rem;
  padding: .9rem 1.5rem;
  background: var(--branco);
  border-bottom: 1px solid var(--borda);
  box-shadow: var(--sombra);
}
.marca { display: flex; align-items: center; gap: .8rem; }
.marca h1 { font-size: 1.35rem; margin: 0; letter-spacing: .5px; }
.marca .tag {
  font-size: .65rem; font-weight: 700; color: var(--verde);
  border: 1px solid var(--verde); border-radius: 4px;
  padding: 1px 5px; vertical-align: middle; letter-spacing: 1px;
}
.marca .sub { margin: 0; font-size: .8rem; color: var(--cinza); }
.menu { display: flex; gap: .25rem; }
.nav-item {
  border: none; background: transparent; cursor: pointer;
  padding: .5rem .9rem; border-radius: 7px; font-size: .92rem; color: var(--cinza);
}
.nav-item:hover { background: var(--verde-claro); }
.nav-item.ativo { background: var(--verde); color: #fff; font-weight: 600; }

/* ── Páginas ── */
main { max-width: 1180px; margin: 1.5rem auto; padding: 0 1.5rem; }
.page { display: none; }
.page.ativa { display: block; }
h2 { font-size: 1.3rem; margin: 0 0 .6rem; }
h3 { font-size: 1.05rem; margin: 1.4rem 0 .4rem; color: var(--verde-escuro); }
.texto { max-width: 760px; }
.texto-aux { color: var(--cinza); font-size: .88rem; max-width: 760px; }
blockquote {
  border-left: 3px solid var(--verde); margin: .6rem 0; padding: .3rem 1rem;
  background: var(--verde-claro); color: var(--tinta); max-width: 760px; border-radius: 0 6px 6px 0;
}

/* ── Avisos ── */
.aviso {
  background: var(--alerta); border: 1px solid var(--alerta-borda);
  padding: .7rem 1rem; border-radius: 8px; margin-bottom: 1rem; font-size: .9rem;
}
.oculto { display: none !important; }

/* ── Modos e busca ── */
.modos { display: flex; gap: .4rem; margin-bottom: .8rem; }
.modo {
  border: 1px solid var(--borda); background: var(--branco); cursor: pointer;
  padding: .45rem 1rem; border-radius: 20px; font-size: .9rem; color: var(--cinza);
}
.modo.ativo { background: var(--verde-escuro); color: #fff; border-color: var(--verde-escuro); }

.busca { margin-bottom: 1rem; }
.campo-busca { display: flex; gap: .5rem; }
.campo-busca input {
  flex: 1; padding: .7rem .9rem; font-size: 1rem;
  border: 1px solid var(--borda); border-radius: 9px; background: var(--branco);
}
.campo-busca select, .campos-compra input {
  padding: .7rem .6rem; border: 1px solid var(--borda); border-radius: 9px; background: var(--branco);
}
.campos-compra { display: flex; gap: .5rem; flex-wrap: wrap; }
.campos-compra input { flex: 1; min-width: 120px; }

.btn-primario {
  background: var(--verde); color: #fff; border: none; cursor: pointer;
  padding: .7rem 1.4rem; border-radius: 9px; font-size: .95rem; font-weight: 600;
}
.btn-primario:hover { background: var(--verde-escuro); }
.btn-secundario {
  background: var(--branco); color: var(--verde-escuro); border: 1px solid var(--verde);
  cursor: pointer; padding: .5rem 1rem; border-radius: 8px; font-size: .88rem;
}
.btn-secundario:hover { background: var(--verde-claro); }

/* ── Filtros ── */
.filtros { background: var(--branco); border: 1px solid var(--borda); border-radius: 10px; padding: .3rem 1rem; margin-bottom: 1rem; }
.filtros summary { cursor: pointer; font-weight: 600; padding: .5rem 0; color: var(--verde-escuro); }
.filtros-grid { display: flex; flex-wrap: wrap; gap: 1rem 1.4rem; padding: .6rem 0 1rem; align-items: center; }
.filtros-grid label { font-size: .88rem; display: flex; align-items: center; gap: .4rem; }
.filtros-grid input[type=number] { width: 80px; padding: .35rem; border: 1px solid var(--borda); border-radius: 6px; }
.filtros-grid select { padding: .35rem; border: 1px solid var(--borda); border-radius: 6px; }

/* ── Status e chips ── */
.status-busca { margin: .5rem 0; color: var(--cinza); font-size: .92rem; min-height: 1.2rem; }
.status-busca.erro { color: #c0392b; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .8rem; }
.chip {
  border: 1px solid var(--borda); background: var(--branco); cursor: pointer;
  padding: .3rem .7rem; border-radius: 16px; font-size: .82rem; color: var(--cinza);
}
.chip:hover { border-color: var(--verde); }
.chip.ativo { background: var(--verde); color: #fff; border-color: var(--verde); }
.chip .n { opacity: .7; margin-left: .3rem; }

/* ── Resultados ── */
.resultados-topo { display: flex; justify-content: space-between; align-items: center; margin-bottom: .5rem; }
#contador { font-weight: 600; }
.tabela-wrap { overflow-x: auto; background: var(--branco); border: 1px solid var(--borda); border-radius: 10px; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th, td { padding: .55rem .7rem; text-align: left; border-bottom: 1px solid var(--borda); }
th { background: var(--verde-claro); color: var(--verde-escuro); font-weight: 600; white-space: nowrap; position: sticky; top: 0; }
td.num, th.num { text-align: right; white-space: nowrap; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--verde-claro); }
.desc-cell { max-width: 360px; }
.vence-perto { color: #c0392b; font-weight: 600; }

/* ── Catálogo ── */
.card-status { display: flex; gap: 2rem; background: var(--branco); border: 1px solid var(--borda); border-radius: 10px; padding: 1rem 1.3rem; margin: 1rem 0; }
.card-status .rotulo { display: block; font-size: .8rem; color: var(--cinza); }
.card-status .metrica { font-size: 1.4rem; font-weight: 700; color: var(--verde-escuro); }
.progresso { margin-top: 1rem; max-width: 600px; }
.barra { height: 10px; background: var(--borda); border-radius: 6px; overflow: hidden; }
.barra-fill { height: 100%; width: 0; background: var(--verde); transition: width .3s; }
.texto-mono { font-family: ui-monospace, monospace; font-size: .82rem; color: var(--cinza); }
code { background: #eef2f0; padding: 1px 5px; border-radius: 4px; font-size: .85em; }

/* ── Drawer ── */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 10; }
.drawer {
  position: fixed; top: 0; right: 0; height: 100%; width: min(520px, 92vw);
  background: var(--branco); box-shadow: -4px 0 16px rgba(0,0,0,.15); z-index: 11;
  overflow-y: auto; padding: 1.4rem 1.5rem; transform: translateX(0);
}
.drawer.oculto { display: none; }
.drawer-fechar { position: absolute; top: .6rem; right: .9rem; border: none; background: none; font-size: 1.8rem; cursor: pointer; color: var(--cinza); line-height: 1; }
.drawer h3 { margin-top: 0; }
.detalhe-marca {
  background: var(--verde-claro); border: 1px solid var(--verde); border-radius: 10px;
  padding: .8rem 1rem; margin: .8rem 0;
}
.detalhe-marca .marca-valor { font-size: 1.5rem; font-weight: 700; color: var(--verde-escuro); }
.detalhe-marca .marca-rotulo { font-size: .78rem; color: var(--cinza); text-transform: uppercase; letter-spacing: .5px; }
.detalhe-linhas { font-size: .9rem; }
.detalhe-linhas div { padding: .25rem 0; border-bottom: 1px solid var(--borda); }
.detalhe-linhas .rot { color: var(--cinza); font-size: .8rem; }
.drawer-links { display: flex; flex-direction: column; gap: .5rem; margin-top: 1rem; }
.drawer-links a { display: block; text-align: center; padding: .55rem; border: 1px solid var(--verde); border-radius: 8px; text-decoration: none; }
.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid var(--borda); border-top-color: var(--verde); border-radius: 50%; animation: girar .7s linear infinite; vertical-align: middle; }
@keyframes girar { to { transform: rotate(360deg); } }

@media (max-width: 640px) {
  .topo { flex-direction: column; align-items: flex-start; }
  .desc-cell { max-width: 200px; }
}
