:root {
  --bg: #f4f6f8;
  --bg-elevado: #ffffff;
  --texto: #1b1f24;
  --texto-suave: #5c6672;
  --borda: #dde2e8;
  --primaria: #2f6fed;
  --primaria-hover: #2559c4;
  --perigo: #d9463f;
  --perigo-hover: #b8362f;
  --sucesso: #1f8a4c;
  --sombra: 0 1px 3px rgba(0, 0, 0, 0.08);
}

[data-theme="dark"] {
  --bg: #14171c;
  --bg-elevado: #1e2229;
  --texto: #e8eaed;
  --texto-suave: #9aa4b2;
  --borda: #2c313a;
  --primaria: #4c8dff;
  --primaria-hover: #6ea1ff;
  --perigo: #e5665f;
  --perigo-hover: #ef8880;
  --sucesso: #34b568;
  --sombra: 0 1px 3px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--texto);
}

a { color: var(--primaria); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-elevado);
  border-bottom: 1px solid var(--borda);
  padding: 0.75rem 1.5rem;
}

.topbar .marca { font-weight: 700; font-size: 1.1rem; }

.topbar nav { display: flex; gap: 0.25rem; align-items: center; flex-wrap: wrap; }

.topbar nav a {
  color: var(--texto-suave);
  font-weight: 500;
  padding: 0.4rem 0.75rem;
  border-radius: 8px;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.topbar nav a:hover {
  color: var(--primaria);
  background: rgba(47, 111, 237, 0.10);
  text-decoration: none;
}

.empresa-atual {
  background: rgba(47, 111, 237, 0.12);
  color: var(--primaria);
  font-weight: 600;
  font-size: 0.85rem;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  white-space: nowrap;
}

.btn-tema {
  border: 1px solid var(--borda);
  background: var(--bg);
  color: var(--texto);
  border-radius: 999px;
  padding: 0.35rem 0.7rem;
  cursor: pointer;
  font-size: 0.95rem;
}

.container {
  max-width: 1100px;
  margin: 1.5rem auto;
  padding: 0 1.5rem;
}

.card {
  background: var(--bg-elevado);
  border: 1px solid var(--borda);
  border-radius: 10px;
  padding: 1.25rem 1.5rem;
  box-shadow: var(--sombra);
  margin-bottom: 1.25rem;
}

h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h2 { font-size: 1.15rem; margin: 0 0 0.75rem; }

.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }

.card-modulo {
  display: block;
  background: var(--bg-elevado);
  border: 1px solid var(--borda);
  border-radius: 10px;
  padding: 1.25rem 1rem;
  text-align: center;
  color: var(--texto);
  text-decoration: none;
}
.card-modulo:hover { border-color: var(--primaria); text-decoration: none; }
.card-modulo-icone { font-size: 1.8rem; margin-bottom: 0.5rem; }
.card-modulo-titulo { font-weight: 700; margin-bottom: 0.2rem; }

.opcao-empresa {
  display: block;
  border: 1px solid var(--borda);
  border-radius: 10px;
  padding: 0.85rem 1rem;
  cursor: pointer;
  font-size: 0.95rem;
  color: var(--texto);
  margin-bottom: 0;
}
.opcao-empresa:hover { border-color: var(--primaria); }
.opcao-empresa.selecionada { border-color: var(--primaria); background: rgba(47, 111, 237, 0.06); }

label { display: block; font-size: 0.85rem; color: var(--texto-suave); margin-bottom: 0.3rem; }

input, select, textarea {
  width: 100%;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--borda);
  border-radius: 6px;
  background: var(--bg);
  color: var(--texto);
  font-size: 0.95rem;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primaria);
}

.campo { margin-bottom: 1rem; }

.campo-senha { position: relative; }
.campo-senha input { padding-right: 2.4rem; }
.btn-ver-senha {
  position: absolute;
  right: 0.4rem;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: none;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0.25rem;
}

.btn {
  display: inline-block;
  border: none;
  border-radius: 6px;
  padding: 0.55rem 1.1rem;
  font-size: 0.95rem;
  cursor: pointer;
  background: var(--primaria);
  color: #fff;
  text-decoration: none;
}
.btn:hover, .btn:focus { background: var(--primaria-hover); text-decoration: none; }
.btn-perigo { background: var(--perigo); }
.btn-perigo:hover { background: var(--perigo-hover); }
.btn-secundario { background: transparent; border: 1px solid var(--borda); color: var(--texto); }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.6rem 0.5rem; border-bottom: 1px solid var(--borda); font-size: 0.92rem; vertical-align: middle; }
th { color: var(--texto-suave); font-weight: 600; }
tr:hover td { background: rgba(47, 111, 237, 0.05); }

.acoes { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; }
.acoes a, .acoes button { font-size: 0.85rem; white-space: nowrap; }

.badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  background: rgba(47, 111, 237, 0.12);
  color: var(--primaria);
}

.alerta {
  padding: 0.7rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}
.alerta-erro { background: rgba(217, 70, 63, 0.12); color: var(--perigo); }
.alerta-sucesso { background: rgba(31, 138, 76, 0.12); color: var(--sucesso); }

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-card { width: 100%; max-width: 360px; }

.texto-suave { color: var(--texto-suave); }
.resumo-valor { font-size: 1.6rem; font-weight: 700; }

.tab-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  border-bottom: 1px solid var(--borda);
  margin-bottom: 1.1rem;
}
.tab-link {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.6rem 0.9rem;
  margin-bottom: -1px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--texto-suave);
  border-bottom: 2px solid transparent;
}
.tab-link:hover { color: var(--texto); }
.tab-link.ativo { color: var(--primaria); border-bottom-color: var(--primaria); }
.tab-painel { display: none; }
.tab-painel.ativo { display: block; }

details.card > summary {
  cursor: pointer;
  list-style: none;
}
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary h2 { display: inline-block; }
details.card > summary::after {
  content: '▾';
  float: right;
  color: var(--texto-suave);
}
details.card[open] > summary::after { content: '▴'; }

@media print {
  .no-print { display: none !important; }
}
