/* Maix Controladoria — tema claro (inspirado no dashboard de referência) */

:root {
  --azul: #354DF0;
  --azul-escuro: #0021FE;
  --azul-forte: #0021FE;
  --azul-claro: #ECEFFF;
  --grad: linear-gradient(93.65deg, #455DFF 0%, #0021FE 103%);

  --bg: #F4F6FB;
  --card: #FFFFFF;
  --card-soft: #FFFFFF;

  --texto: #1A1C2B;
  --texto2: #565973;
  --muted: #9296B0;
  --borda: #ECEEF6;

  --verde: #1AB900;
  --vermelho: #E53636;

  --sombra: 0 10px 30px rgba(2,46,86,.08);
  --radius: 16px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--texto);
}

.oculto { display: none !important; }

/* ───────── LOGIN ───────── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #455DFF 0%, #0021FE 100%);
  padding: 20px;
}
.login-card {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  width: 100%;
  max-width: 380px;
  padding: 40px 32px;
}
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo .marca {
  display: inline-flex; align-items: center; justify-content: center;
  width: 64px; height: 64px;
  background: var(--grad); color: #fff;
  font-weight: 800; font-size: 26px;
  border-radius: 50%;
  margin-bottom: 12px;
}
.login-logo h1 { font-size: 20px; font-weight: 800; }
.login-logo p { color: var(--muted); font-size: 13px; margin-top: 4px; }

.campo { margin-bottom: 16px; }
.campo label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--texto2); }
.campo input, .campo select {
  width: 100%; padding: 11px 13px;
  border: 1px solid #DDD; border-radius: 8px; font-size: 14px;
  font-family: inherit; background: #fff;
}
.campo input:focus, .campo select:focus {
  outline: none; border-color: var(--azul);
  box-shadow: 0 0 0 3px rgba(66,153,255,.15);
}

.btn {
  width: 100%; padding: 12px;
  background: var(--grad); color: #fff; border: none;
  border-radius: 10px; font-size: 15px; font-weight: 600; cursor: pointer;
  transition: filter .2s, transform .1s;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: scale(.99); }
.btn:disabled { opacity: .6; cursor: not-allowed; }

.erro-box {
  background: #fef2f2; color: var(--vermelho); border: 1px solid #fecaca;
  padding: 10px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 16px;
}
.dica { margin-top: 18px; font-size: 12px; color: var(--muted); text-align: center; line-height: 1.5; }

/* ───────── SHELL ───────── */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 248px;
  background: var(--card-soft);
  border-right: 1px solid var(--borda);
  display: flex; flex-direction: column; flex-shrink: 0;
}
.sidebar .brand {
  display: flex; align-items: center; gap: 12px;
  padding: 22px 20px;
}
.sidebar .brand .marca {
  width: 42px; height: 42px;
  background: var(--grad); color: #fff;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 18px;
}
.sidebar .brand strong { color: var(--azul); font-size: 16px; font-weight: 800; letter-spacing: .02em; text-transform: uppercase; }
.sidebar .brand small { display: block; color: var(--muted); font-size: 11px; font-weight: 600; }

.nav { padding: 10px 14px; flex: 1; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 13px;
  padding: 12px 14px; margin-bottom: 4px;
  border-radius: var(--radius);
  cursor: pointer; font-size: 14px; font-weight: 600;
  color: var(--texto); border: none; background: none;
  width: 100%; text-align: left; transition: all .15s;
}
.nav-item:hover { background: var(--azul-claro); color: var(--azul-escuro); }
.nav-item.ativo { background: var(--grad); color: #fff; box-shadow: 0 8px 20px rgba(53,77,240,.35); }
.nav-item .ico { font-size: 17px; }

.usuario-box { padding: 16px 18px; border-top: 1px solid var(--borda); font-size: 13px; }
.usuario-box .nome { color: var(--texto); font-weight: 700; }
.usuario-box .papel { color: var(--muted); font-size: 11px; margin-top: 2px; }
.btn-sair {
  margin-top: 12px; width: 100%; padding: 9px;
  background: #fff; color: var(--vermelho);
  border: 1px solid var(--borda); border-radius: 8px; cursor: pointer; font-size: 13px; font-weight: 600;
}
.btn-sair:hover { background: #fef2f2; border-color: #fecaca; }

.conteudo { flex: 1; overflow-y: auto; }
.topo {
  background: var(--card-soft);
  border-bottom: 1px solid var(--borda);
  padding: 20px 32px;
  display: flex; align-items: center; justify-content: space-between;
}
.topo h2 { font-size: 22px; font-weight: 800; color: #3D3D3D; }
.topo p { color: var(--muted); font-size: 13px; margin-top: 2px; }

.pagina { padding: 28px 32px; }

.ambiente-badge {
  font-size: 12px; font-weight: 700; padding: 7px 14px; border-radius: 20px;
  white-space: nowrap; letter-spacing: .02em;
}
.ambiente-badge.homolog { background: #FEF3C7; color: #92400E; border: 1px solid #FCD34D; }
.ambiente-badge.prod { background: #FEE2E2; color: #B91C1C; border: 1px solid #FCA5A5; }

/* Modais (cancelar / emitir avulsa) */
.modal-ov {
  position: fixed; inset: 0; background: rgba(15,18,40,.45);
  display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 20px;
}
.modal-bx {
  background: #fff; border-radius: var(--radius); padding: 24px;
  width: 100%; max-width: 460px; box-shadow: 0 20px 60px rgba(2,46,86,.3);
}
.modal-bx h3 { margin-bottom: 4px; }
/* Modal grande (visualizador de DANFSe) */
.modal-bx.grande {
  max-width: 900px; width: 92vw; height: 92vh;
  display: flex; flex-direction: column; padding: 18px;
}

/* Autocomplete de tabelas (código de serviço / NBS) */
.ac-box {
  position: absolute; top: 100%; left: 0; right: 0; margin-top: 2px;
  background: #fff; border: 1px solid var(--borda); border-radius: 8px;
  box-shadow: var(--sombra); max-height: 260px; overflow-y: auto; z-index: 50; display: none;
}
.ac-item { padding: 8px 12px; font-size: 13px; cursor: pointer; border-bottom: 1px solid var(--borda); }
.ac-item:last-child { border-bottom: none; }
.ac-item:hover { background: var(--azul-claro); }

/* Botões de download XML / PDF */
.btn-file {
  border: none; border-radius: 6px; font-size: 11px; font-weight: 700;
  padding: 4px 9px; cursor: pointer; margin-right: 4px; color: #fff;
}
.btn-file.xml { background: #0F6E56; }
.btn-file.pdf { background: #B91C1C; }
.btn-file.ver { background: #475569; }
.btn-file:hover { filter: brightness(1.12); }

/* Tag de retenção (na coluna Documentos) */
.tag-ret {
  background: #FEF3C7; color: #92400E; border: 1px solid #FCD34D;
  margin-left: 4px; vertical-align: middle; cursor: help;
}

/* Tooltip de retenções (hover na tag) */
.ret-tooltip {
  position: fixed; z-index: 2000; display: none;
  background: #fff; border: 1px solid var(--borda); border-radius: 10px;
  box-shadow: var(--sombra); padding: 10px 12px; min-width: 250px; max-width: 340px;
  font-size: 12px; color: var(--texto);
}
.ret-titulo { font-weight: 700; margin-bottom: 6px; color: var(--texto2); }
.ret-tab { width: 100%; border-collapse: collapse; }
.ret-tab th {
  text-align: left; font-size: 10px; text-transform: uppercase; letter-spacing: normal;
  color: var(--muted); padding: 3px 5px; background: none; font-weight: 700;
}
.ret-tab td { padding: 3px 5px; border-bottom: 1px solid var(--borda); color: var(--texto2); }
.ret-tab tfoot td {
  font-weight: 700; color: var(--texto);
  border-top: 2px solid var(--borda); border-bottom: none; padding-top: 5px;
}
.ret-vazio { color: var(--muted); font-size: 12px; }

/* ───────── CARDS / TABELAS ───────── */
.card {
  background: var(--card);
  border: 1px solid var(--borda);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 20px;
  box-shadow: var(--sombra);
}
.card h3 { font-size: 15px; font-weight: 700; margin-bottom: 16px; color: var(--texto2); }

.linha-form { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.btn-inline { width: auto; padding: 10px 22px; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  text-align: left; padding: 12px; background: var(--bg);
  color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; font-weight: 700;
}
td { padding: 12px; border-bottom: 1px solid var(--borda); color: var(--texto2); }
tr:hover td { background: #FAFBFC; }

.tag { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 700; }
.tag-verde { background: #E3F9E0; color: var(--verde); }
.tag-roxo { background: var(--azul-claro); color: var(--azul-escuro); }

.vazio { text-align: center; padding: 40px; color: var(--muted); font-size: 14px; }

.em-breve { text-align: center; padding: 70px 20px; color: var(--muted); }
.em-breve .ico-grande { font-size: 48px; margin-bottom: 14px; }
.em-breve h3 { color: var(--texto); margin-bottom: 8px; font-size: 18px; }

.btn-icone { background: none; border: none; cursor: pointer; font-size: 15px; padding: 4px 7px; border-radius: 5px; }
.btn-icone:hover { background: var(--bg); }

/* Sub-abas segmentadas (Documento Fiscal / Contrato / Cadastro · Emitidos / Recebidos · Clientes / Produtos / Certificado) */
.subtabs {
  display: inline-flex; gap: 6px; flex-wrap: wrap;
  background: var(--card); border: 1px solid var(--borda);
  padding: 6px; border-radius: 14px; margin-bottom: 20px;
  box-shadow: var(--sombra);
}
.subtab {
  display: inline-flex; align-items: center; gap: 8px;
  border: none; background: none; cursor: pointer;
  padding: 9px 18px; border-radius: 10px;
  font-family: inherit; font-size: 13.5px; font-weight: 600;
  color: var(--texto2); transition: all .15s; white-space: nowrap;
}
.subtab:hover:not(.ativo) { color: var(--azul-escuro); background: var(--azul-claro); }
.subtab.ativo { background: var(--grad); color: #fff; box-shadow: 0 6px 16px rgba(53,77,240,.30); }

/* Abas de análise de documento (Dados Gerais / Suframa / ST) */
.aba-doc, .aba-nfse {
  background: none; border: none; border-bottom: 3px solid transparent;
  padding: 10px 16px; font-size: 14px; font-weight: 700; color: var(--muted); cursor: pointer;
}
.aba-doc:hover, .aba-nfse:hover { color: var(--azul); }
.aba-doc.ativo, .aba-nfse.ativo { color: var(--azul); border-bottom-color: var(--azul); }

/* Expandir/recolher documento na lista */
.btn-toggle {
  background: none; border: 1px solid var(--borda); border-radius: 6px;
  width: 26px; height: 26px; cursor: pointer; font-size: 12px; color: var(--azul);
  line-height: 1;
}
.btn-toggle:hover { background: var(--azul); color: #fff; }
.det-row > td { background: #f8f9fb; padding: 0; }
.det-painel { padding: 16px 18px; }

/* ───────── STAT CARDS (Painel) ───────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 18px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--borda);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--sombra);
}
.stat-top { display: flex; align-items: center; justify-content: space-between; }
.stat-label { font-size: 13px; font-weight: 700; color: var(--texto2); }
.stat-pill {
  width: 34px; height: 34px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center; font-size: 16px;
  background: var(--azul-claro);
}
.stat-value { font-size: 30px; font-weight: 800; color: #3F3F3F; margin-top: 12px; }
.stat-sub { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* Barras decorativas (mini-gráfico do painel) */
.mini-bars { display: flex; align-items: flex-end; gap: 10px; height: 150px; padding-top: 10px; }
.mini-bars .barra { flex: 1; background: #C2C9FF; border-radius: 6px 6px 0 0; }
.mini-bars .barra.forte { background: var(--grad); }

@media (max-width: 920px) {
  .sidebar { width: 70px; }
  .sidebar .brand strong, .sidebar .brand small, .nav-item span:not(.ico), .usuario-box .nome, .usuario-box .papel { display: none; }
  .nav-item { justify-content: center; }
  .linha-form { grid-template-columns: 1fr; }
}
