/* Inter — vendorizado LOCAL (sem CDN). Origem: @fontsource/inter@5.1.0, subset latin,
   licença OFL-1.1. Servido first-party -> a CSP `default-src 'self'` já cobre font-src,
   sem abrir fonts.googleapis.com/gstatic. Sem local(): usa sempre o arquivo auditado
   (sha256 em assets/vendor/inter/NOTICE), não a fonte instalada na máquina. */
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 300; font-display: swap;
  src: url('../vendor/inter/inter-latin-300-normal.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('../vendor/inter/inter-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 500; font-display: swap;
  src: url('../vendor/inter/inter-latin-500-normal.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 600; font-display: swap;
  src: url('../vendor/inter/inter-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 700; font-display: swap;
  src: url('../vendor/inter/inter-latin-700-normal.woff2') format('woff2'); }

/* Portal Interno NN — tema (DNA visual: verde-petróleo profundo + terracota).
   Identidade profissional e quente para produto financeiro/contábil executivo.
   Sem CDN, sem build: tokens em CSS variables + componentes do dashboard.
   Denso, executivo, legivel, mobile e TV-friendly.
   Fonte canônica da paleta: blocos :root abaixo (ver Design System NN/Hub). */

:root {
  /* === Marca === */
  --verde:        #002a2b;  /* âncora: header, texto principal, theme-color */
  --verde-medio:  #2e7474;  /* destaque / links / ícones (teal) */
  --terra:        #b2512b;  /* acento secundário (ações, item ativo) */
  --terra-claro:  #d86d42;  /* variação do acento / âmbar (gráficos) */
  --areia:        #f3daba;  /* acento quente suave */

  /* === Neutros === */
  --branco:       #ffffff;
  --superficie-2: #f6f4f0;
  --bg:           #f0efec;
  --borda:        #e8e5e5;
  --texto:        #002a2b;
  --texto-2:      #5b595b;
  --texto-fraco:  #8a8789;

  /* === Semânticos (financeiro) === */
  --positivo:     #15803d;
  --negativo:     #b91c1c;
  --positivo-bg:  rgba(21, 128, 61, .10);
  --negativo-bg:  rgba(185, 28, 28, .10);
  --verde-bg:     rgba(46, 116, 116, .12);
  --terra-bg:     rgba(178, 81, 43, .12);

  /* === Tipografia === */
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono: 'Courier New', monospace;

  /* === Layout === */
  --raio-card: 6px;
  --raio:      4px;
  --sombra:    0 1px 4px rgba(0, 0, 0, .04);
  --gap:       14px;

  /* === Aliases legados (compat com os componentes existentes) === */
  --bg-app:         var(--bg);            /* fundo da página */
  --bg-panel:       var(--branco);        /* cards / painéis */
  --bg-panel-soft:  var(--superficie-2);
  --bg-pill:        var(--superficie-2);  /* inputs / seletores */
  --bg-pill-active: var(--terra);         /* item ativo / ação */
  --accent:         var(--terra);
  --brand:          var(--terra);
  --danger:         var(--negativo);
  --text:           var(--texto);
  --text-muted:     var(--texto-2);
  --border:         var(--borda);
  --grid:           rgba(0, 0, 0, .08);
  --radius:         var(--raio);

  font-synthesis: none;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden; /* dashboard de tela cheia: sem barra de rolagem */
  background: var(--bg-app);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
body { display: flex; flex-direction: column; }

button { font-family: inherit; cursor: pointer; }

/* ---------- Topbar (marca + abas de departamento) ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 10px 18px;
  background: var(--verde);
  border-bottom: 1px solid rgba(255, 255, 255, .08);
  flex: 0 0 auto;
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
.brand-logo { height: 40px; width: auto; display: block; }
.login-logo { height: 66px; width: auto; }
.brand .brand-txt { line-height: 1.05; }
.brand .brand-txt strong { display: block; font-size: 14px; letter-spacing: .2px; color: #fff; }
.brand .brand-txt span { display: block; font-size: 12px; color: rgba(255, 255, 255, .5); }

.dept-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  flex: 1 1 auto;
  scrollbar-width: thin;
}
.dept-tabs button {
  white-space: nowrap;
  background: transparent;
  color: rgba(255, 255, 255, .55);
  border: 1px solid transparent;
  padding: 7px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  transition: background .15s, color .15s;
}
.dept-tabs button:hover { color: #fff; background: rgba(255, 255, 255, .06); }
.dept-tabs button.active {
  color: #fff;
  background: var(--bg-pill-active);
  font-weight: 600;
}

/* ---------- Subbar (titulo + periodo + abas de ferramenta) ---------- */
.subbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 18px;
  flex-wrap: wrap;
  flex: 0 0 auto;
}
.page-title {
  margin: 0;
  font-size: 26px;
  font-weight: 300;
  letter-spacing: .3px;
}
.period { display: flex; align-items: center; gap: 10px; }
.period-label {
  color: var(--text-muted); font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em;
}
/* Controle agrupado: ano + meses num unico bloco segmentado */
.period-group {
  display: flex; align-items: stretch;
  background: var(--bg-pill);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.period-group .seg {
  background: transparent; border: none; color: var(--text-muted);
  padding: 7px 11px; font-size: 13px; line-height: 1.2;
  transition: background .12s, color .12s;
}
.period-group .seg:hover { color: var(--text); background: rgba(0, 0, 0, .04); }
.period-group .seg.year {
  color: var(--text); font-weight: 600; display: flex; align-items: center; gap: 7px;
}
.period-group .seg.year i { font-size: 10px; color: var(--text-muted); }
.period-group .divider { width: 1px; background: var(--border); margin: 5px 3px; }
.period-group .seg.month.active { color: #fff; background: var(--bg-pill-active); font-weight: 600; }

.tool-tabs { display: flex; gap: 6px; margin-left: auto; flex-wrap: wrap; }
.tool-tabs button {
  background: var(--bg-pill);
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 13px;
}
.tool-tabs button.active { color: #fff; background: var(--bg-pill-active); border-color: transparent; font-weight: 600; }
.tool-tabs button .ic { margin-right: 6px; opacity: .85; }

/* ---------- View (preenche a tela, sem rolagem) ---------- */
.view {
  padding: 8px 18px 14px;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* KPIs */
.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--gap);
  margin-bottom: var(--gap);
  flex: 0 0 auto;
}
.kpi {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--raio-card);
  box-shadow: var(--sombra);
  padding: 12px 16px;
  text-align: center;
}
.kpi .kpi-label { color: var(--text-muted); font-size: 12px; margin-bottom: 6px; min-height: 28px; display: flex; align-items: center; justify-content: center; }
.kpi .kpi-value { font-size: clamp(22px, 3vh, 32px); font-weight: 700; line-height: 1; }
.kpi .kpi-value.danger { color: var(--danger); }
.kpi .kpi-value.accent { color: var(--accent); }

/* Grade de paineis (12 colunas) — preenche a altura restante */
.grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  grid-auto-rows: 1fr;
  gap: var(--gap);
  flex: 1 1 auto;
  min-height: 0;
}
.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--raio-card);
  box-shadow: var(--sombra);
  padding: 12px 16px;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.panel.span-3 { grid-column: span 3; }
.panel.span-4 { grid-column: span 4; }
.panel.span-6 { grid-column: span 6; }
.panel.span-8 { grid-column: span 8; }
.panel.span-12 { grid-column: span 12; }

.panel-head { display: flex; align-items: center; justify-content: center; gap: 8px; margin-bottom: 8px; flex: 0 0 auto; }
.panel-head .ic { color: var(--verde-medio); display: inline-flex; }
.panel-head .ic i { font-size: 16px; }
.panel-head h3 { margin: 0; font-size: 15px; font-weight: 600; text-align: center; }
.panel-body { position: relative; flex: 1 1 auto; min-height: 0; }
.panel-body canvas { max-height: 100%; }

/* Callout (numero consolidado + comparativos) */
.callout .big { font-size: 44px; font-weight: 700; color: var(--accent); margin: 6px 0 14px; }
.callout .sub { color: var(--text-muted); font-size: 14px; }
.callout .cmp { margin-top: 10px; }
.callout .cmp .cmp-label { font-weight: 600; }
.callout .cmp .cmp-pct { color: var(--positivo); font-weight: 700; }
.callout .cmp .cmp-detail { color: var(--positivo); font-size: 18px; }
.callout .cmp.neg .cmp-pct, .callout .cmp.neg .cmp-detail { color: var(--danger); }

/* Sidebar de filtros (visao Empresas) */
.filters .fld { margin-bottom: 14px; }
.filters label { display: block; color: var(--text-muted); font-size: 12px; margin-bottom: 5px; }
.filters select, .filters .fake-select {
  width: 100%; background: var(--bg-pill); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 9px 12px; font-size: 13px;
}
.filters .btn-clear {
  width: 100%; margin-top: 6px; background: var(--bg-pill); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; font-size: 13px;
}

/* Checklist (tool, nao-dashboard) */
.checklist { max-width: 720px; }
.checklist .progress { color: var(--text-muted); margin-bottom: 14px; }
.checklist .bar { height: 8px; background: var(--bg-pill); border-radius: var(--radius); overflow: hidden; margin: 8px 0 18px; }
.checklist .bar > i { display: block; height: 100%; background: var(--accent); transition: width .25s; }
.checklist ul { list-style: none; margin: 0; padding: 0; }
.checklist li {
  display: flex; align-items: center; gap: 12px;
  background: var(--bg-panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 14px; margin-bottom: 8px;
}
.checklist li input { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; }
.checklist li.done span { color: var(--text-muted); text-decoration: line-through; }

.placeholder { color: var(--text-muted); text-align: center; padding: 60px 20px; font-size: 15px; }

/* Ferramenta Societário: gerador de documentos .docx — preenche a view inteira */
.soc-tool { width: 100%; height: 100%; display: flex; flex-direction: column; min-height: 0; }
.soc-head { flex: 0 0 auto; }
.soc-head h3 { margin: 0 0 4px; font-size: 17px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.soc-head h3 .ic { color: var(--verde-medio); }
.soc-sub { margin: 0 0 14px; color: var(--texto-2); font-size: 13px; }
.soc-grid { flex: 0 0 auto; display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 12px; }
.soc-grid .fld { flex: 0 1 460px; margin-bottom: 0; }
.soc-tool .fld { margin-bottom: 12px; }
.soc-tool label { display: block; color: var(--texto-2); font-size: 12px; font-weight: 500; margin-bottom: 6px; }
.soc-tool select, .soc-tool textarea {
  width: 100%; background: var(--branco); color: var(--texto);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; font-size: 14px;
  font-family: inherit; transition: border-color .15s, box-shadow .15s;
}
/* O campo de texto cresce para ocupar a altura disponível */
.soc-texto-fld { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.soc-texto-fld textarea { flex: 1 1 auto; min-height: 200px; resize: none; line-height: 1.5; }
.soc-tool select:focus, .soc-tool textarea:focus {
  outline: none; border-color: var(--verde-medio); box-shadow: 0 0 0 3px rgba(46, 116, 116, .16);
}
.soc-foot { flex: 0 0 auto; display: flex; align-items: center; gap: 14px; margin-top: 10px; flex-wrap: wrap; }
.soc-status { font-size: 13px; color: var(--texto-2); }
.soc-status.ok { color: var(--positivo); }
.soc-status.err { color: var(--negativo); }
.badge-sens { font-size: 10px; background: var(--brand); color: #fff; padding: 1px 8px; border-radius: 999px; margin-left: 6px; vertical-align: middle; }

/* Login — tela de acesso: fundo de marca (verde profundo) + card claro flutuante */
.login-wrap {
  flex: 1 1 auto; min-height: 0; overflow: auto;
  display: flex; align-items: center; justify-content: center; padding: 24px;
  background: radial-gradient(1100px 540px at 50% -8%, rgba(46, 116, 116, .35), transparent 60%), var(--verde);
}
.login-card {
  position: relative; width: 100%; max-width: 400px; overflow: hidden;
  background: var(--bg-panel); border: 1px solid var(--border);
  border-radius: var(--raio-card); box-shadow: 0 16px 44px rgba(0, 0, 0, .28);
  padding: 34px 32px 30px;
}
.login-card::before { /* fio terracota no topo (acento de marca) */
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: var(--terra);
}
.login-card .lc-brand {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  margin-bottom: 22px; padding-bottom: 20px; border-bottom: 1px solid var(--borda);
}
.login-card h1 { font-size: 19px; font-weight: 700; margin: 0; text-align: center; letter-spacing: .2px; }
.login-card .lc-sub { margin: 0; font-size: 12px; color: var(--texto-fraco); text-align: center; }
.login-card label { display: block; color: var(--text-muted); font-size: 13px; font-weight: 500; margin: 14px 0 6px; }
.login-card input {
  width: 100%; background: var(--bg-pill); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 11px 13px; font-size: 14px;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.login-card input:focus {
  outline: none; background: var(--branco);
  border-color: var(--verde-medio); box-shadow: 0 0 0 3px rgba(46, 116, 116, .16);
}
/* Campo de senha com botao "mostrar senha" (olho) */
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 42px; }
.pw-toggle {
  position: absolute; top: 0; right: 0; height: 100%; width: 40px;
  display: flex; align-items: center; justify-content: center;
  background: transparent; border: none; color: var(--texto-fraco);
  cursor: pointer; border-radius: var(--radius); font-size: 14px;
}
.pw-toggle:hover { color: var(--verde-medio); }
.pw-toggle:focus-visible { outline: 2px solid var(--verde-medio); outline-offset: 2px; }
.login-card .btn {
  width: 100%; margin-top: 22px; background: var(--accent); color: #fff;
  border: none; border-radius: var(--radius); padding: 12px; font-size: 15px; font-weight: 600;
  transition: background .15s, transform .05s;
}
.login-card .btn:hover { background: var(--terra-claro); }
.login-card .btn:active { transform: translateY(1px); }
.login-card .btn:focus-visible { outline: 2px solid var(--verde-medio); outline-offset: 2px; }
.login-card .hint { color: var(--texto-fraco); font-size: 12px; text-align: center; margin-top: 16px; }

/* ---------- Ações do header (usuário / admin / sair) ---------- */
.top-actions { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; margin-left: 12px; }
.top-actions .user { color: rgba(255, 255, 255, .6); font-size: 13px; white-space: nowrap; }
.ta-btn {
  background: rgba(255, 255, 255, .08); color: #fff; border: 1px solid rgba(255, 255, 255, .16);
  border-radius: var(--radius); padding: 7px 12px; font-size: 13px; text-decoration: none;
  display: inline-flex; align-items: center; gap: 6px;
}
.ta-btn:hover { background: var(--bg-pill-active); border-color: transparent; }

/* ---------- Fluxo de autenticação ---------- */
.auth-step label:first-child { margin-top: 0; }
.auth-msg { background: var(--negativo-bg); border: 1px solid var(--negativo); color: var(--negativo);
  border-radius: var(--radius); padding: 9px 12px; font-size: 13px; margin-bottom: 12px; }
.auth-info {
  color: var(--text); font-size: 13px; line-height: 1.45; margin: 0 0 12px;
  background: var(--verde-bg); border-radius: var(--radius); padding: 10px 12px;
}
.auth-info i { color: var(--accent); margin-right: 4px; }
.auth-hint { color: var(--texto-fraco); font-size: 12px; margin: 8px 0 0; }
.auth-hint code {
  font-family: var(--mono); color: var(--texto); font-size: 12px; word-break: break-all;
  background: var(--superficie-2); border: 1px solid var(--borda); border-radius: 4px; padding: 1px 6px;
}
/* QR do cadastro 2FA (imgSrc da CSP já permite data: para o data-URL do QR) */
.qr-box { display: flex; justify-content: center; margin: 6px 0 12px; }
.qr-box img {
  width: 184px; height: 184px; background: #fff;
  border: 1px solid var(--borda); border-radius: var(--radius); padding: 8px;
}

/* ---------- Tela de administração ---------- */
.admin-wrap { flex: 1 1 auto; min-height: 0; overflow: auto; padding: 18px; }
.admin-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 12px; }
.admin-head h2 { margin: 0; font-size: 20px; font-weight: 600; }
.admin-head h2 i { color: var(--accent); margin-right: 6px; }
.btn-primary {
  background: var(--accent); color: #fff; border: none; border-radius: var(--radius);
  padding: 9px 16px; font-size: 14px; font-weight: 600; display: inline-flex; align-items: center; gap: 7px;
}
.btn-ghost {
  background: transparent; color: var(--text-muted); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 9px 16px; font-size: 14px;
}

.form-panel { background: var(--bg-panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.form-msg { background: var(--negativo-bg); border: 1px solid var(--negativo); color: var(--negativo); border-radius: var(--radius); padding: 8px 12px; font-size: 13px; margin-bottom: 12px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin-bottom: 8px; }
.form-cols { display: grid; grid-template-columns: 1fr 2fr; gap: 20px; margin-top: 10px; }
.form-cols h4 { margin: 8px 0; font-size: 13px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.fld label { display: block; color: var(--text-muted); font-size: 12px; margin-bottom: 5px; }
.fld input, .form-panel input {
  width: 100%; background: var(--bg-pill); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 9px 12px; font-size: 14px;
}
.chk-list { display: flex; flex-direction: column; gap: 8px; }
.chk { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 14px; }
.chk input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); }
.chk.dep { justify-content: space-between; background: var(--bg-pill); border: 1px solid var(--border); border-radius: var(--radius); padding: 7px 10px; }
.chk.dep .dep-papel { background: var(--bg-app); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius); padding: 4px 8px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }

.table-wrap { background: var(--bg-panel); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th, .tbl td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl th { color: var(--text-muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; background: var(--superficie-2); }
.tbl tr:last-child td { border-bottom: none; }
.tbl .acts { display: flex; gap: 6px; flex-wrap: wrap; }
.pill-ok { background: var(--positivo); color: #fff; padding: 2px 9px; border-radius: 999px; font-size: 12px; }
.pill-off { background: var(--texto-2); color: #fff; padding: 2px 9px; border-radius: 999px; font-size: 12px; }
.pill-warn { background: var(--accent); color: #fff; padding: 2px 9px; border-radius: 999px; font-size: 11px; }
.pill-info { background: var(--verde-medio); color: #fff; padding: 2px 9px; border-radius: 999px; font-size: 11px; }

/* Responsivo: em telas estreitas, empilha e volta a permitir rolagem
   (tela cheia sem scroll vale para monitor/TV; no celular seria espremido). */
@media (max-width: 900px) {
  html, body { height: auto; overflow: auto; }
  .view { overflow: visible; }
  .grid { grid-auto-rows: auto; }
  .panel { overflow: visible; }
  .panel-body { min-height: 220px; }
  .panel.span-3, .panel.span-4, .panel.span-6, .panel.span-8 { grid-column: span 12; }
  .filters { grid-row: auto !important; }
  .subbar { gap: 10px; }
  .tool-tabs { margin-left: 0; }
  .page-title { font-size: 22px; }
}

/* Altura curta (notebooks/TV deitada): encolhe um pouco os KPIs */
@media (max-height: 760px) {
  .kpi { padding: 9px 14px; }
  .kpi .kpi-label { min-height: 24px; margin-bottom: 4px; font-size: 11px; }
}
