@font-face {
  font-family: "Code";
  src: url("fonts/Code-Light.otf") format("opentype");
  font-weight: 300;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Code";
  src: url("fonts/Code-Bold.otf") format("opentype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --bg: #0a0f1e;
  --bg-soft: #0d1428;
  --card: #101a30;
  --card-hover: #142238;
  --ink: #eef2f8;
  --muted: #8a94ab;
  --muted-2: #5f6a82;
  --line: #1e2a44;
  --accent: #fa7d0c;
  --accent-ink: #0a0f1e;
  --blue: #2f86ff;
  --success: #22c55e;
  --success-ink: #7ee9a4;
  --danger: #f87171;
  --danger-ink: #f87171;
  --warn: #f5b942;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background:
    radial-gradient(900px 420px at 15% -10%, rgba(47, 134, 255, 0.16), transparent 60%),
    radial-gradient(700px 380px at 85% -15%, rgba(250, 125, 12, 0.12), transparent 55%),
    var(--bg);
  color: var(--ink);
  font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

/* ===== Cabeçalho / marca ===== */
header.topo {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 32px;
  border-bottom: 1px solid var(--line);
}
.marca { display: flex; align-items: center; gap: 12px; }
.marca img.logo-icone { width: 34px; height: 34px; display: block; }
.marca .logotipo {
  font-family: "Code", monospace;
  font-size: 22px;
  letter-spacing: 0.5px;
  line-height: 1;
}
.marca .logotipo .peso-bold { font-weight: 700; color: var(--ink); }
.marca .logotipo .peso-light { font-weight: 300; color: var(--muted); }
.marca .selo {
  margin-left: 10px;
  font-family: "Code", monospace;
  font-weight: 300;
  font-size: 10px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--muted-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 9px;
}
.by-infomode {
  font-family: "Code", monospace;
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted-2);
}
.by-infomode b { color: var(--muted); font-weight: 700; }

.sessao { display: flex; align-items: center; gap: 14px; }
.usuario-logado {
  font-family: "Code", monospace;
  font-size: 11px;
  letter-spacing: 0.5px;
  color: var(--muted);
}
.btn-sair {
  font-family: "Code", monospace;
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted-2);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 14px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.btn-sair:hover { color: var(--accent); border-color: var(--accent); }

.eyebrow {
  font-family: "Code", monospace;
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 1.8px;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 6px;
}
.sub { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.5; }

main { padding: 24px 32px 56px; }
main > .intro,
.bloco-cnpj,
#form-busca,
.separador {
  max-width: 1180px;
}
main > .intro { margin-bottom: 22px; }
main > .intro h1 { margin: 0 0 6px; font-size: 21px; font-weight: 600; }

/* ===== Formulários / cartões ===== */
#form-busca {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: end;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
}
.campo { display: flex; flex-direction: column; gap: 6px; flex: 1 1 220px; }
.campo-pequeno { flex: 0 0 110px; }
label {
  font-family: Verdana, Geneva, sans-serif;
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--blue);
}
input[type="text"], input[type="number"], select {
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 14px;
  background: var(--bg-soft);
  color: var(--ink);
}
input::placeholder { color: var(--muted-2); }
input:focus, select:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(47, 134, 255, 0.18);
}
select { color-scheme: dark; }

button {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .15s ease, transform .05s ease;
}
button:hover { opacity: 0.88; }
button:active { transform: translateY(1px); }
button:disabled { opacity: 0.45; cursor: default; }

.status { margin: 16px 0; color: var(--muted); font-size: 14px; }

.barra-resultados {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 22px 0 10px;
}
#contagem {
  color: var(--muted);
  font-size: 12px;
  font-family: "Code", monospace;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
#btn-csv { background: transparent; color: var(--ink); border: 1px solid var(--line); }
#btn-csv:hover { background: var(--card-hover); opacity: 1; }

.tabela-wrap {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: visible;
}
table { border-collapse: collapse; width: 100%; table-layout: fixed; font-size: 13px; }
th, td {
  text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line);
  white-space: normal; overflow-wrap: anywhere;
}
th {
  position: sticky; top: 0; background: var(--card);
  font-family: Verdana, Geneva, sans-serif;
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--blue);
}
tbody tr:hover td { background: var(--card-hover); }
td.col-pesquisar a { color: var(--blue); text-decoration: none; }
td.col-pesquisar a:hover { text-decoration: underline; }

th:nth-child(1), td:nth-child(1)  { width: 13%; }
th:nth-child(2), td:nth-child(2)  { width: 8%; }
th:nth-child(3), td:nth-child(3)  { width: 15%; }
th:nth-child(4), td:nth-child(4)  { width: 15%; }
th:nth-child(5), td:nth-child(5)  { width: 7%; }
th:nth-child(6), td:nth-child(6)  { width: 7%; }
th:nth-child(7), td:nth-child(7)  { width: 7%; }
th:nth-child(8), td:nth-child(8)  { width: 9%; }
th:nth-child(9), td:nth-child(9)  { width: 3%; }
th:nth-child(10), td:nth-child(10) { width: 5%; }
th:nth-child(11), td:nth-child(11) { width: 6%; }
th:nth-child(12), td:nth-child(12) { width: 5%; }

/* ===== Bloco de consulta por CNPJ ===== */
.bloco-cnpj { margin-bottom: 8px; }
.bloco-cnpj h2 {
  font-family: "Code", monospace;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--ink);
  margin: 0 0 4px;
}
.bloco-cnpj #form-cnpj { display: flex; gap: 12px; align-items: end; margin-top: 12px; }
.separador { border: none; border-top: 1px solid var(--line); margin: 28px 0; }

.cartao-cnpj {
  margin-top: 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
}
.cnpj-cabecalho { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; font-size: 15px; font-weight: 600; }
.tag {
  font-family: "Code", monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.8px;
  padding: 3px 10px;
  border-radius: 999px;
}
.situacao-ativa { background: rgba(34, 197, 94, 0.14); color: var(--success-ink); }
.situacao-baixada { background: rgba(248, 113, 113, 0.14); color: var(--danger-ink); }
.situacao-outra { background: rgba(245, 185, 66, 0.14); color: var(--warn); }
.cnpj-grade { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px 22px; font-size: 13px; }
.cnpj-grade > div { display: flex; flex-direction: column; gap: 3px; }
.cnpj-grade span {
  font-family: Verdana, Geneva, sans-serif;
  font-weight: 700;
  color: var(--blue);
  font-size: 10px;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}
.cnpj-json-hint { margin: 16px 0 0; font-size: 12px; color: var(--muted); }
.cnpj-json-hint code {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  padding: 1px 6px;
  border-radius: 4px;
  color: var(--blue);
}

/* ===== Responsivo ===== */
@media (max-width: 640px) {
  header.topo { padding: 16px 18px; flex-wrap: wrap; row-gap: 10px; }
  .sessao { width: 100%; justify-content: space-between; }
  main { padding: 18px 18px 40px; }
  #form-busca, .bloco-cnpj #form-cnpj { flex-direction: column; align-items: stretch; }
  .campo-pequeno { flex-basis: auto; }

  /* Tabela vira uma lista de cartões empilhados (um por empresa) */
  .tabela-wrap { border: none; background: transparent; }
  table, thead, tbody, th, td, tr { display: block; width: auto !important; }
  thead { display: none; }
  #tabela { width: 100%; }
  tbody tr {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    margin-bottom: 12px;
    padding: 6px 0;
  }
  tbody tr:hover td { background: transparent; }
  td {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    justify-content: space-between;
    border-bottom: 1px solid var(--line);
    padding: 8px 14px;
  }
  tbody tr td:last-child { border-bottom: none; }
  td::before {
    content: attr(data-label);
    flex: 0 0 38%;
    font-family: Verdana, Geneva, sans-serif;
    font-weight: 700;
    font-size: 10px;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    color: var(--blue);
  }
  td.nome::before, td.endereco::before { padding-top: 1px; }
  td.col-pesquisar { flex-direction: column; align-items: flex-start; gap: 4px; }
  td.col-pesquisar::before { flex: none; }
}
