:root {
  --cor-fundo: #f7f8fa;
  --cor-texto: #111827;
  --cor-texto-suave: #6b7280;
  --cor-borda: #e5e7eb;
  --cor-primaria: #111827;
  --cor-primaria-hover: #1f2937;
  --cor-marca: #bb1015;
  --cor-marca-hover: #950d10;
  --cor-erro: #b91c1c;
  --cor-erro-fundo: #fee2e2;
  --cor-sucesso: #15803d;
  --cor-sucesso-fundo: #dcfce7;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 250px 1fr;
  grid-template-rows: 1fr auto;
  font-family: "Inter", system-ui, sans-serif;
  background: var(--cor-fundo);
  color: var(--cor-texto);
}

header {
  grid-column: 1;
  grid-row: 1 / span 2;
  background: #fff;
  border-right: 1px solid var(--cor-borda);
  padding: 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

section {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  min-width: 0;
  overflow-x: auto;
  background: #fff;
  border: 1px solid var(--cor-borda);
  border-radius: 10px;
  padding: 1.5rem;
}

.marca {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  color: inherit;
  padding: 0 0.25rem;
}

.marca-icone {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  object-fit: contain;
}

.marca-texto strong {
  display: block;
  font-size: 0.95rem;
  line-height: 1.2;
}

.marca-texto span {
  display: block;
  font-size: 0.75rem;
  color: var(--cor-texto-suave);
}

header nav {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

header nav a {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  color: var(--cor-texto);
  text-decoration: none;
  font-size: 0.9rem;
}

header nav a svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

header nav a:hover {
  background: var(--cor-fundo);
}

header nav a.ativo {
  background: var(--cor-marca);
  color: #fff;
  font-weight: 600;
}

footer {
  grid-column: 2;
  grid-row: 2;
  padding: 1rem 2.5rem;
  border-top: 1px solid var(--cor-borda);
  color: var(--cor-texto-suave);
  font-size: 0.8rem;
  text-align: center;
}

footer p {
  margin: 0;
}

main {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  width: 100%;
  padding: 2rem 2.5rem;
}

h2 {
  margin: 0;
  font-size: 1.3rem;
}

label {
  display: block;
  margin-bottom: 0.75rem;
  font-weight: 600;
  font-size: 0.9rem;
}

input,
select {
  display: block;
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.5rem;
  border: 1px solid var(--cor-borda);
  border-radius: 6px;
  font-size: 1rem;
  font-weight: normal;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--cor-primaria);
  box-shadow: 0 0 0 3px rgba(17, 24, 39, 0.1);
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  opacity: 1;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  border: 1px solid var(--cor-borda);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 1rem;
}

th,
td {
  text-align: left;
  padding: 0.65rem 0.5rem;
  border-bottom: 1px solid var(--cor-borda);
}

thead th {
  background: var(--cor-fundo);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--cor-texto-suave);
}

tbody tr:hover {
  background: var(--cor-fundo);
}

.linha-clicavel {
  cursor: pointer;
}

button {
  cursor: pointer;
  padding: 0.55rem 1.1rem;
  border: none;
  border-radius: 6px;
  background: var(--cor-primaria);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 500;
  transition: background-color 0.15s;
}

button:hover {
  background: var(--cor-primaria-hover);
}

button:disabled {
  background: var(--cor-borda);
  cursor: not-allowed;
}

button.secundario {
  background: transparent;
  color: var(--cor-primaria);
  border: 1px solid var(--cor-borda);
}

button.secundario:hover {
  background: var(--cor-fundo);
}

.btn-remover-linha {
  background: transparent;
  color: var(--cor-erro);
  border: 1px solid var(--cor-erro);
}

.btn-remover-linha:hover {
  background: var(--cor-erro-fundo);
}

.acoes-form {
  display: flex;
  gap: 0.75rem;
  margin-top: 1rem;
}

.mensagem {
  padding: 0.75rem 1rem;
  border-radius: 6px;
  margin-bottom: 1rem;
}

.mensagem.erro {
  background: var(--cor-erro-fundo);
  color: var(--cor-erro);
}

.mensagem.sucesso {
  background: var(--cor-sucesso-fundo);
  color: var(--cor-sucesso);
}

.mensagem ul {
  margin: 0;
  padding-left: 1.25rem;
}

.linha-consulta {
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
}

.linha-consulta > div {
  flex: 1;
}

.linha-consulta label {
  margin-bottom: 0;
}

.info-item {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem 1.5rem;
  margin: 1rem 0 1.25rem;
}

.info-item div {
  font-size: 0.9rem;
}

.info-item strong {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--cor-texto-suave);
}

.abas {
  display: flex;
  gap: 0.5rem;
  border-bottom: 1px solid var(--cor-borda);
  margin-bottom: 1rem;
}

.aba-botao {
  background: transparent;
  color: var(--cor-texto);
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  padding: 0.5rem 0.25rem;
}

.aba-botao:hover {
  background: transparent;
}

.aba-botao.ativa {
  color: var(--cor-primaria);
  border-bottom-color: var(--cor-primaria);
  font-weight: 600;
}

.filtros-relatorio {
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.filtros-relatorio label {
  flex: 1;
  min-width: 160px;
  margin-bottom: 0;
}

.filtros-relatorio-exportar {
  display: flex;
  gap: 0.75rem;
  margin-left: auto;
}

.celula-titulo {
  font-weight: 600;
  font-size: 0.9rem;
}

.badge {
  display: inline-block;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-neutro {
  background: var(--cor-fundo);
  color: var(--cor-texto-suave);
  font-weight: 500;
  border: 1px solid var(--cor-borda);
}

.badge-categoria {
  background: #e5e7eb;
  color: #374151;
}

.estado-vazio {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--cor-texto-suave);
  font-size: 0.9rem;
}

.hero-inicio {
  text-align: center;
  padding: 3rem 1.5rem;
}

.logo-inicio {
  max-width: 220px;
  margin-bottom: 1.5rem;
}

.hero-inicio h2 {
  margin-bottom: 0.5rem;
}

.hero-inicio p {
  margin: 0;
  color: var(--cor-texto-suave);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
}

.stat-card {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 1.25rem;
  border: 1px solid var(--cor-borda);
  border-radius: 10px;
  background: var(--cor-fundo);
}

.stat-valor {
  font-size: 1.75rem;
  font-weight: 700;
}

.stat-rotulo {
  font-size: 0.85rem;
  color: var(--cor-texto-suave);
}

.cabecalho-secao {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

a.botao,
a.botao-secundario {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.55rem 1.1rem;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}

a.botao {
  background: var(--cor-primaria);
  color: #fff;
}

a.botao:hover {
  background: var(--cor-primaria-hover);
}

a.botao-secundario {
  background: transparent;
  color: var(--cor-primaria);
  border: 1px solid var(--cor-borda);
}

a.botao-secundario:hover {
  background: var(--cor-fundo);
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--cor-texto-suave);
  margin: -1rem 0 0.25rem;
}

.breadcrumb a {
  color: var(--cor-texto-suave);
  text-decoration: none;
}

.breadcrumb a:hover {
  text-decoration: underline;
}

.breadcrumb-atual {
  color: var(--cor-texto);
  font-weight: 600;
}

.celula-acoes {
  text-align: right;
}

.link-detalhes {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.35rem;
  color: var(--cor-texto);
  border-radius: 6px;
}

.link-detalhes:hover {
  background: var(--cor-fundo);
}

@media print {
  header,
  footer,
  .filtros-relatorio,
  .mensagem,
  .acoes-form,
  #toast-container {
    display: none !important;
  }

  body {
    display: block;
  }

  section {
    border: none;
    padding: 0;
  }
}

#toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 320px;
}

.toast {
  position: relative;
  padding: 0.75rem 2rem 0.75rem 1rem;
  border-radius: 8px;
  font-size: 0.9rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  animation: toast-entrar 0.2s ease-out;
}

.toast-sucesso {
  background: var(--cor-sucesso-fundo);
  color: var(--cor-sucesso);
}

.toast-erro {
  background: var(--cor-erro-fundo);
  color: var(--cor-erro);
}

.toast ul {
  margin: 0;
  padding-left: 1.1rem;
}

.toast-fechar {
  position: absolute;
  top: 0.35rem;
  right: 0.5rem;
  background: transparent;
  border: none;
  color: inherit;
  font-size: 1.1rem;
  line-height: 1;
  padding: 0;
}

@keyframes toast-entrar {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}
