/*
 * EXP Design System — Variáveis Canônicas de Identidade Visual
 * Versão: 1.0 — Maio 2026
 *
 * Como usar:
 *   Importar no <head> de cada módulo, antes dos estilos locais:
 *   <link rel="stylesheet" href="exp-design-system.css">
 *
 * Esta folha não altera nenhum estilo existente.
 * Ela apenas define variáveis CSS disponíveis para uso gradual.
 */

:root {

  /* ─────────────────────────────────────────
     NEUTROS
     Cores de estrutura: texto, fundo, borda
  ───────────────────────────────────────── */

  --grafite:    #141414;   /* texto principal, fundos escuros */
  --cinza:      #D0CFC9;   /* bordas, divisores principais */
  --cinza2:     #ECEAE4;   /* divisores internos, fundos alternados, linhas de tabela */
  --branco:     #FFFFFF;   /* fundo de superfície pura */
  --off:        #F7F6F3;   /* fundo de página, hover neutro */


  /* ─────────────────────────────────────────
     ACENTOS — IDENTIDADE EXP
     Quatro cores da paleta oficial da marca
  ───────────────────────────────────────── */

  --verde:       #3E7858;   /* natural, ativo, institucional */
  --verde-hover: #2D9E6B;   /* hover/active sobre --verde */
  --azul:        #4A72B5;   /* informação, navegação, neutro-frio */
  --ouro:        #C49A27;   /* valor, destaque, atenção quente */
  --terracota:   #B85638;   /* crítico, alerta forte, remoção */
  --roxo:        #6B4FA0;   /* identidade: contatos, financeiro */


  /* ─────────────────────────────────────────
     SEMÂNTICA DE ESTADO
     Apelidos com significado funcional.
     Usar --sucesso em vez de --verde quando
     o contexto for de estado, não de marca.
  ───────────────────────────────────────── */

  --sucesso:    var(--verde);      /* concluído, aprovado, ativo */
  --info:       var(--azul);       /* em andamento, informativo, link */
  --atencao:    var(--ouro);       /* pendente, aguardando, alerta leve */
  --critico:    var(--terracota);  /* erro, bloqueado, removido, urgente */


  /* ─────────────────────────────────────────
     SUPERFÍCIES SUAVES
     Mesma cor com baixa opacidade.
     Usar em: hover de linha, fundo de badge,
     fundo de card com acento sutil.
  ───────────────────────────────────────── */

  --verde-soft:      rgba(62,  120, 88,  0.08);
  --azul-soft:       rgba(74,  114, 181, 0.08);
  --ouro-soft:       rgba(196, 154, 39,  0.08);
  --terracota-soft:  rgba(184, 86,  56,  0.08);
  --roxo-soft:       rgba(107, 79,  160, 0.10);

  /* Fundos sólidos suaves — para badges, pills, fundo de linha colorida */
  --verde-bg:        #EAF5EE;
  --azul-bg:         #EAF0FB;
  --ouro-bg:         #FBF3E8;
  --terracota-bg:    #FBF0EE;
  --roxo-bg:         #F3EFFE;

  /* Aliases curtos — compatibilidade com módulos */
  --az-bg:  var(--azul-bg);
  --am-bg:  var(--ouro-bg);
  --tc-bg:  var(--terracota-bg);
  --verde-l: var(--verde-hover);


  /* ─────────────────────────────────────────
     TIPOGRAFIA
  ───────────────────────────────────────── */

  --font-ui:    'Raleway', sans-serif;
  --font-mono:  'DM Mono', monospace;

  /* Escala de tamanhos */
  --text-label:   8px;    /* labels de campo, badges, cabeçalhos de tabela */
  --text-body:    12px;   /* corpo de texto padrão */
  --text-sub:     10px;   /* texto secundário, datas, metadados */
  --text-title:   13px;   /* títulos de seção */

  /* Pesos */
  --weight-label:    700;
  --weight-semibold: 600;
  --weight-body:     400;
  --weight-light:    300;

  /* Espaçamento de label */
  --label-spacing: 0.06em;


  /* ─────────────────────────────────────────
     FORMA — BORDAS E RAIOS
     Resolve inconsistência entre módulos
     (modal 8px vs 10px, etc.)
  ───────────────────────────────────────── */

  --radius-shell:  14px;   /* cards de módulo e nav lateral */
  --radius-card:   8px;    /* cards internos, modais, painéis flutuantes */
  --radius-modal:  8px;
  --radius-input:  6px;
  --radius-btn:    6px;
  --radius-badge:  4px;
  --radius-tag:    3px;


  /* ─────────────────────────────────────────
     OVERLAY — FUNDO DE MODAL
     Padrão único para todos os módulos
  ───────────────────────────────────────── */

  --overlay-bg: rgba(0, 0, 0, 0.40);


  /* ─────────────────────────────────────────
     SOMBRAS
  ───────────────────────────────────────── */

  --shadow-card:   0 1px 4px rgba(0, 0, 0, 0.08);
  --shadow-modal:  0 4px 24px rgba(0, 0, 0, 0.14);
  --shadow-hover:  0 2px 8px  rgba(0, 0, 0, 0.10);


  /* ─────────────────────────────────────────
     ESPAÇAMENTO BASE
  ───────────────────────────────────────── */

  --gap-xs:  4px;
  --gap-sm:  8px;
  --gap-md:  16px;
  --gap-lg:  24px;
  --gap-xl:  32px;

  --nav-height: 46px;


  /* ─────────────────────────────────────────
     TRANSIÇÕES
     Usar em hover, foco e mudanças de estado
  ───────────────────────────────────────── */

  --transition-fast:   0.15s ease;
  --transition-normal: 0.22s ease;
  --transition-slow:   0.35s ease;


  /* ─────────────────────────────────────────
     GRADE DE FUNDO
     Opacidade da grade de linhas no body::before.
     Usar: opacity: var(--bg-grid-opacity)
  ───────────────────────────────────────── */

  --bg-grid-opacity: 0.45;
  --nav-active: var(--grafite);

  /* Foco de input — cada módulo sobrescreve com sua cor de acento */
  --mod-focus:      var(--azul);
  --mod-focus-soft: var(--azul-soft);

}


/* ═══════════════════════════════════════════
   DARK MODE
   Ativado via atributo no elemento raiz:
     document.documentElement.setAttribute('data-theme','dark')
   Sobrescreve apenas os tokens que mudam.
   Tipografia, forma, espaçamento — inalterados.
═══════════════════════════════════════════ */

[data-theme="dark"] {

  /* Neutros invertidos */
  --grafite:    #F0EFEC;   /* texto principal — quase branco quente */
  --cinza:      #3E3E3C;   /* bordas e divisores */
  --cinza2:     #2A2A28;   /* divisores internos, fundos alternados */
  --branco:     #1C1C1A;   /* superfície de card, modal, input */
  --off:        #141412;   /* fundo de página */

  /* Acentos — mesma identidade, levemente mais luminosos para contraste */
  --verde:       #52A676;
  --verde-hover: #3DBF80;
  --azul:        #6089CC;
  --ouro:        #D4AA37;
  --terracota:   #CC6848;
  --roxo:        #8B6CC0;

  /* Semântica — herda dos acentos ajustados acima */
  --sucesso:    var(--verde);
  --info:       var(--azul);
  --atencao:    var(--ouro);
  --critico:    var(--terracota);

  /* Superfícies suaves — opacidade levemente maior no escuro */
  --verde-soft:      rgba(82,  166, 118, 0.13);
  --azul-soft:       rgba(96,  137, 204, 0.13);
  --ouro-soft:       rgba(212, 170, 55,  0.13);
  --terracota-soft:  rgba(204, 104, 72,  0.13);
  --roxo-soft:       rgba(139, 108, 192, 0.13);

  /* Fundos sólidos suaves — versão dark */
  --verde-bg:        #1A2E22;
  --azul-bg:         #1A2236;
  --ouro-bg:         #2E2710;
  --terracota-bg:    #2E1A14;
  --roxo-bg:         #251A38;

  /* Grade de fundo — muito suave no escuro */
  --bg-grid-opacity: 0.08;

  /* Overlay mais denso — fundo já é escuro */
  --overlay-bg: rgba(0, 0, 0, 0.65);

  /* Sombras mais pronunciadas */
  --shadow-card:   0 1px 4px  rgba(0, 0, 0, 0.35);
  --shadow-modal:  0 4px 24px rgba(0, 0, 0, 0.55);
  --shadow-hover:  0 2px 8px  rgba(0, 0, 0, 0.40);

}


/* ═══════════════════════════════════════════
   FUNDO — Malha de linhas verticais convergentes
   Identidade EXP: espaçamento logarítmico (g₀ = 400 px, r = 0.72)
   20 linhas que vão de 400 px de gap até 1 px — efeito de perspectiva
   A animação usa apenas opacity: roda no compositor (GPU), custo zero.
═══════════════════════════════════════════ */

body::before {
  content: '';
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='1440' height='2' preserveAspectRatio='none'><g stroke='%23D0CFC9' stroke-width='1'><line x1='580' y1='0' x2='580' y2='2'/><line x1='821' y1='0' x2='821' y2='2'/><line x1='995' y1='0' x2='995' y2='2'/><line x1='1120' y1='0' x2='1120' y2='2'/><line x1='1210' y1='0' x2='1210' y2='2'/><line x1='1275' y1='0' x2='1275' y2='2'/><line x1='1322' y1='0' x2='1322' y2='2'/><line x1='1356' y1='0' x2='1356' y2='2'/><line x1='1380' y1='0' x2='1380' y2='2'/><line x1='1397' y1='0' x2='1397' y2='2'/><line x1='1410' y1='0' x2='1410' y2='2'/><line x1='1419' y1='0' x2='1419' y2='2'/><line x1='1425' y1='0' x2='1425' y2='2'/><line x1='1430' y1='0' x2='1430' y2='2'/><line x1='1433' y1='0' x2='1433' y2='2'/><line x1='1435' y1='0' x2='1435' y2='2'/><line x1='1437' y1='0' x2='1437' y2='2'/><line x1='1438' y1='0' x2='1438' y2='2'/><line x1='1439' y1='0' x2='1439' y2='2'/><line x1='1440' y1='0' x2='1440' y2='2'/></g></svg>");
  background-size: 100% 100%;
  background-repeat: no-repeat;
  animation: expBgBreathe 10s ease-in-out infinite;
}

@keyframes expBgBreathe {
  0%, 100% { opacity: 0.38; }
  50%       { opacity: 0.56; }
}

@keyframes expBgBreatheDark {
  0%, 100% { opacity: 0.06; }
  50%       { opacity: 0.11; }
}

[data-theme="dark"] body::before {
  animation-name: expBgBreatheDark;
}

@media (prefers-reduced-motion: reduce) {
  body::before                      { animation: none; opacity: 0.42; transform: none; }
  [data-theme="dark"] body::before  { animation: none; opacity: 0.08; transform: none; }
}


/* ═══════════════════════════════════════════
   COMPONENTE — THEME TOGGLE
   Estilo canônico do botão de tema claro/escuro.
   Usado em todos os módulos da plataforma.

   HTML esperado:
     <button class="theme-toggle" onclick="toggleTheme()">
       <span class="ttg-icon">☀</span>
       <span class="ttg-track"><span class="ttg-knob"></span></span>
       <span class="ttg-icon">🌙</span>
     </button>
═══════════════════════════════════════════ */

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 3px;
  border-radius: 20px;
  flex-shrink: 0;
}

.ttg-icon {
  font-size: 9px;
  opacity: 0;
  transition: opacity var(--transition-fast);
  user-select: none;
  line-height: 1;
}

/* Em modo claro: mostra a lua levemente (indica que vai para escuro) */
.theme-toggle .ttg-icon:last-child  { opacity: .35; }

/* Em modo escuro: mostra o sol levemente (indica que vai para claro) */
[data-theme="dark"] .theme-toggle .ttg-icon:first-child { opacity: .65; filter: invert(1); }
[data-theme="dark"] .theme-toggle .ttg-icon:last-child  { opacity: 0;   }

/* Hover — ambos visíveis */
.theme-toggle:hover .ttg-icon { opacity: .75; }
[data-theme="dark"] .theme-toggle:hover .ttg-icon:first-child { filter: invert(1); }

.ttg-track {
  width: 30px;
  height: 16px;
  border-radius: 8px;
  background: var(--cinza);
  position: relative;
  transition: background var(--transition-normal);
  flex-shrink: 0;
}

.ttg-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
  transition: transform var(--transition-normal);
}

[data-theme="dark"] .ttg-track { background: var(--verde); }
[data-theme="dark"] .ttg-knob  { transform: translateX(14px); background: #f0efec; }


/* ═══════════════════════════════════════════
   COMPONENTE — CHECKBOX
   Dois padrões canônicos. Tokens de cor adaptam
   automaticamente ao dark mode — sem override extra.

   ── NATIVO (input) ──
   Estiliza <input type="checkbox"> diretamente.
   Usar dentro de um <label> para área de clique correta.

     <label class="exp-cb-row">
       <input type="checkbox" class="exp-cb">
       <span class="exp-cb-label">Texto</span>
     </label>

   Variante compacta: adicionar classe exp-cb-sm ao input
   e exp-cb-row-sm ao label.

   ── CUSTOM (div, toggled via JS) ──
   Para checkboxes controladas por JS que alternam .done.

     <div class="exp-tick" onclick="..."></div>
     <span class="exp-tick-label">Texto</span>

   Variante compacta: adicionar classe exp-tick-sm ao div.
═══════════════════════════════════════════ */

/* ── Container de linha ── */
.exp-cb-row {
  display: inline-flex;
  align-items: flex-start;
  gap: var(--gap-xs);
  cursor: pointer;
  font-family: var(--font-ui);
  font-size: var(--text-body);
  color: var(--grafite);
  user-select: none;
}
.exp-cb-row-sm {
  font-size: var(--text-sub);
}

/* ── Checkbox nativo ── */
input[type="checkbox"].exp-cb {
  appearance: none;
  -webkit-appearance: none;
  width: 15px;
  height: 15px;
  border: 1.5px solid var(--cinza);
  border-radius: 4px;
  background: var(--branco);
  flex-shrink: 0;
  cursor: pointer;
  margin-top: 1px;
  position: relative;
  transition: border-color var(--transition-fast), background var(--transition-fast);
}

input[type="checkbox"].exp-cb::after {
  content: '';
  position: absolute;
  display: none;
  left: 4px;
  top: 1px;
  width: 5px;
  height: 9px;
  border: 2px solid #fff;
  border-top: none;
  border-left: none;
  transform: rotate(45deg);
}

input[type="checkbox"].exp-cb:checked {
  background: var(--verde);
  border-color: var(--verde);
}
input[type="checkbox"].exp-cb:checked::after { display: block; }

input[type="checkbox"].exp-cb:disabled {
  opacity: 0.45;
  cursor: default;
}
input[type="checkbox"].exp-cb:focus-visible {
  outline: 2px solid var(--azul-soft);
  outline-offset: 2px;
}

/* Hover — unchecked: intenção de marcar → check cinza + borda cinza */
.exp-cb-row:hover input[type="checkbox"].exp-cb:not(:checked):not(:disabled) {
  border-color: #aaa;
}
.exp-cb-row:hover input[type="checkbox"].exp-cb:not(:checked):not(:disabled)::after {
  display: block;
  border-color: rgba(0, 0, 0, 0.22);
}

/* Hover — checked: intenção de desmarcar → fundo cinza médio */
.exp-cb-row:hover input[type="checkbox"].exp-cb:checked:not(:disabled) {
  background: #9E9E9E;
  border-color: #9E9E9E;
}

/* Dark mode — fundo do checkbox ligeiramente mais claro que a superfície */
[data-theme="dark"] input[type="checkbox"].exp-cb {
  background: #242422;
}
[data-theme="dark"] .exp-cb-row:hover input[type="checkbox"].exp-cb:not(:checked):not(:disabled) {
  border-color: #666;
}
[data-theme="dark"] .exp-cb-row:hover input[type="checkbox"].exp-cb:not(:checked):not(:disabled)::after {
  border-color: rgba(255, 255, 255, 0.22);
}
[data-theme="dark"] .exp-cb-row:hover input[type="checkbox"].exp-cb:checked:not(:disabled) {
  background: #6E6E6C;
  border-color: #6E6E6C;
}

/* Texto riscado quando marcado */
.exp-cb-label.done,
input[type="checkbox"].exp-cb:checked ~ .exp-cb-label {
  text-decoration: line-through;
  color: var(--cinza);
}

/* Variante compacta */
input[type="checkbox"].exp-cb-sm {
  width: 12px;
  height: 12px;
  border-radius: 3px;
}
input[type="checkbox"].exp-cb-sm::after {
  left: 3px;
  top: 0;
  width: 4px;
  height: 7px;
}


/* ── Custom tick (div, JS-toggled) ── */
.exp-tick {
  width: 15px;
  height: 15px;
  border: 1.5px solid var(--cinza);
  border-radius: 4px;
  background: var(--branco);
  flex-shrink: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 700;
  color: transparent;
  margin-top: 1px;
  user-select: none;
  transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
}
.exp-tick::after { content: '✓'; }

/* Hover — unchecked: intenção de marcar → check cinza + borda cinza */
.exp-tick:hover:not(.done) {
  border-color: #aaa;
  color: rgba(0, 0, 0, 0.22);
}

/* Hover — done: intenção de desmarcar → fundo cinza médio */
.exp-tick.done:hover {
  background: #9E9E9E;
  border-color: #9E9E9E;
}

.exp-tick.done {
  background: var(--verde);
  border-color: var(--verde);
  color: #fff;
}

/* Dark mode */
[data-theme="dark"] .exp-tick {
  background: #242422;
}
[data-theme="dark"] .exp-tick:hover:not(.done) {
  border-color: #666;
  color: rgba(255, 255, 255, 0.22);
}
[data-theme="dark"] .exp-tick.done:hover {
  background: #6E6E6C;
  border-color: #6E6E6C;
}

/* Variante compacta */
.exp-tick-sm {
  width: 12px;
  height: 12px;
  font-size: 8px;
}

/* Texto companion */
.exp-tick-label.done {
  text-decoration: line-through;
  color: var(--cinza);
}

/* ── Variante cancel — exp-tick-x (custom) ──
   Usar quando marcar significa cancelar, encerrar ou remover.
   Hover: × cinza sutil. Done: × cinza sobre fundo neutro.
   HTML: <div class="exp-tick exp-tick-x [done]" onclick="..."></div>
─────────────────────────────────────────────────── */
.exp-tick-x::after { content: '×'; font-size: 11px; font-weight: 400; }

.exp-tick-x:hover:not(.done) {
  border-color: var(--cinza);
  color: rgba(0, 0, 0, 0.2);
}

.exp-tick-x.done {
  background: var(--cinza2);
  border-color: var(--cinza);
  color: #888;
}

[data-theme="dark"] .exp-tick-x:hover:not(.done) {
  color: rgba(255, 255, 255, 0.2);
}

[data-theme="dark"] .exp-tick-x.done {
  background: var(--cinza2);
  border-color: var(--cinza);
  color: #888;
}

/* ── Variante cancel — exp-cb-x (nativo) ──
   HTML: <input type="checkbox" class="exp-cb exp-cb-x">
   Hover: × cinza sutil. Checked: × cinza, fundo neutro.
─────────────────────────────────────────────────── */
input[type="checkbox"].exp-cb.exp-cb-x::after {
  content: '×';
  border: none;
  transform: translate(-50%, -50%);
  left: 50%;
  top: 50%;
  width: auto;
  height: auto;
  font-family: var(--font-ui);
  font-size: 10px;
  font-weight: 400;
  color: transparent;
  display: block;
}

.exp-cb-row:hover input[type="checkbox"].exp-cb.exp-cb-x:not(:checked):not(:disabled) {
  border-color: var(--cinza);
}
.exp-cb-row:hover input[type="checkbox"].exp-cb.exp-cb-x:not(:checked):not(:disabled)::after {
  color: rgba(0, 0, 0, 0.2);
}

input[type="checkbox"].exp-cb.exp-cb-x:checked {
  background: var(--cinza2);
  border-color: var(--cinza);
}
input[type="checkbox"].exp-cb.exp-cb-x:checked::after {
  color: #888;
}

[data-theme="dark"] .exp-cb-row:hover input[type="checkbox"].exp-cb.exp-cb-x:not(:checked):not(:disabled)::after {
  color: rgba(255, 255, 255, 0.2);
}


/* ═══════════════════════════════════════════
   COMPONENTE — CAMPOS DE FORMULÁRIO
   Padrão único para input, textarea e select.
   Tokens adaptam automaticamente ao dark mode.

   HTML esperado:
     <div class="exp-field">
       <label class="exp-label">Nome do campo</label>
       <input class="exp-input" type="text" placeholder="...">
       <span class="exp-field-hint">Texto auxiliar opcional</span>
     </div>

   Estado de erro: adicionar .exp-error ao campo.
   Classes: exp-input · exp-textarea · exp-select
═══════════════════════════════════════════ */

/* ── Wrapper de campo ── */
.exp-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* ── Label ── */
.exp-label {
  display: block;
  font-family: var(--font-ui);
  font-size: var(--text-label);
  font-weight: var(--weight-label);
  letter-spacing: var(--label-spacing);
  text-transform: uppercase;
  color: var(--grafite);
  opacity: 0.5;
}

/* ── Base: input, textarea, select ── */
.exp-input,
.exp-textarea,
.exp-select {
  width: 100%;
  box-sizing: border-box;
  font-family: var(--font-ui);
  font-size: var(--text-body);
  font-weight: var(--weight-light);
  color: var(--grafite);
  background: var(--branco);
  border: 1px solid var(--cinza);
  border-radius: var(--radius-input);
  padding: 6px 10px;
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.exp-input::placeholder,
.exp-textarea::placeholder {
  color: var(--cinza);
  font-weight: var(--weight-body);
}

/* Focus — cor vem do módulo via --mod-focus (fallback: --azul) */
.exp-input:focus,
.exp-textarea:focus,
.exp-select:focus {
  border-color: var(--mod-focus, var(--azul));
  box-shadow: 0 0 0 3px var(--mod-focus-soft, var(--azul-soft));
}

/* Disabled */
.exp-input:disabled,
.exp-textarea:disabled,
.exp-select:disabled {
  opacity: 0.45;
  cursor: default;
  background: var(--off);
}

/* Erro */
.exp-input.exp-error,
.exp-textarea.exp-error,
.exp-select.exp-error {
  border-color: var(--terracota);
  box-shadow: 0 0 0 3px var(--terracota-soft);
}

/* Textarea */
.exp-textarea {
  resize: vertical;
  min-height: 64px;
  line-height: 1.5;
}

/* Select — seta customizada */
.exp-select {
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23D0CFC9' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}

/* Hint / mensagem de apoio */
.exp-field-hint {
  font-family: var(--font-ui);
  font-size: var(--text-sub);
  color: var(--grafite);
  opacity: 0.45;
}

/* Dark — seta do select com cor adaptada */
[data-theme="dark"] .exp-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%233E3E3C' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}


/* ═══════════════════════════════════════════
   COMPONENTE — NAV
   Barra de navegação principal, sticky, 46px.
   Elementos opcionais marcados abaixo.

   HTML canônico:
   ┌──────────────────────────────────────────┐
   │<nav class="nav">                         │
   │  <a href="app.html" class="nav-brand">   │
   │    <img src="exp.png" style="height:20px;width:auto;display:block"> │
   │  </a>                                    │
   │  <div class="nav-sep"></div>             │
   │                                          │
   │  <!-- Seletor de módulo -->              │
   │  <div class="nav-mod-wrap" id="nav-mod-wrap"> │
   │    <button class="nav-lbl-btn" onclick="toggleNavDropdown()"> │
   │      EXP.modulo <span>▾</span>          │
   │    </button>                             │
   │    <div class="nav-dropdown" id="nav-dropdown"> │
   │      <a href="gestao.html">EXP.projetos</a> │
   │      <a href="apoio.html">EXP.apoio</a> │
   │      <a href="contatos.html">EXP.contatos</a> │
   │      <div class="nd-sep nd-soc" style="display:none"></div> │
   │      <a href="calc.html"       class="nd-soc" style="display:none">EXP.calc</a> │
   │      <a href="crm.html"        class="nd-soc" style="display:none">EXP.comercial</a> │
   │      <a href="financeiro.html" class="nd-soc nd-active" style="display:none">EXP.financeiro</a> │
   │    </div>                                │
   │  </div>                                  │
   │                                          │
   │  <!-- Tabs (omitir se módulo usa sidebar) --> │
   │  <div class="nav-tabs">                  │
   │    <button class="ntab active" data-tab="x">Tab</button> │
   │  </div>                                  │
   │                                          │
   │  <div class="nav-right">                 │
   │    <div class="conn-dot" id="conn-dot"></div> │
   │                                          │
   │    <!-- EXP Room (opcional) -->          │
   │    <a href="https://..." target="_blank" class="exp-room-btn" title="EXP Room">📹</a> │
   │                                          │
   │    <!-- Notificações (opcional) -->      │
   │    <div class="notif-wrap" id="notif-wrap"> │
   │      <button class="notif-bell" id="notif-bell-btn" onclick="toggleNotifPanel()"> │
   │        🔔<span class="notif-badge" id="notif-badge" style="display:none">0</span> │
   │      </button>                           │
   │      <!-- Lembrete — socio-only (opcional) --> │
   │      <button class="notif-plus nd-soc" onclick="abrirLembretePopup()" style="display:none">＋</button> │
   │      <div class="notif-panel" id="notif-panel" style="display:none"> │
   │        <div class="notif-panel-hd">     │
   │          <span class="notif-panel-hd-t">Notificações</span> │
   │          <button class="notif-panel-clr" onclick="...">Encerrar todas ✓</button> │
   │        </div>                            │
   │        <div id="notif-lista">…</div>    │
   │      </div>                              │
   │    </div>                                │
   │                                          │
   │    <button class="theme-toggle" onclick="toggleTheme()"> │
   │      <span class="ttg-icon">☀</span>   │
   │      <span class="ttg-track"><span class="ttg-knob"></span></span> │
   │      <span class="ttg-icon">🌙</span>  │
   │    </button>                             │
   │                                          │
   │    <!-- Chip de usuário -->              │
   │    <div class="user-pill-wrap" id="user-pill-wrap"> │
   │      <div class="user-chip" onclick="toggleUserMenu()"> │
   │        <div class="uav" id="nav-av"></div> │
   │        <div class="u-text">             │
   │          <span class="u-nome" id="nav-nome">—</span> │
   │          <span class="u-role" id="nav-role"></span> │
   │        </div>                            │
   │        <span class="u-caret">▾</span>  │
   │      </div>                              │
   │      <div class="user-dropdown" id="user-dropdown"> │
   │        <div class="ud-coming">Meus dados</div> │
   │        <div class="ud-sep nd-soc" style="display:none"></div> │
   │        <div class="ud-coming nd-soc" style="display:none">Gestão da plataforma</div> │
   │        <div class="ud-sep"></div>        │
   │        <button onclick="sair()">Sair do sistema</button> │
   │      </div>                              │
   │    </div>                                │
   │  </div>                                  │
   │</nav>                                    │
   └──────────────────────────────────────────┘
═══════════════════════════════════════════ */

/* ── Estrutura principal ── */
.nav {
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--cinza);
  padding: 0 16px;
  height: var(--nav-height);
  position: sticky;
  top: 0;
  z-index: 100;
  gap: 0;
}

[data-theme="dark"] .nav {
  background: rgba(28, 28, 26, 0.95);
}

/* ── Marca / logo ── */
.nav-brand {
  display: flex;
  align-items: center;
  margin-right: 16px;
  text-decoration: none;
  color: inherit;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 5px;
  flex-shrink: 0;
}
.nav-brand:hover { opacity: 0.7; }

.nav-brand-logo {
  height: 20px;
  width: auto;
  display: block;
}

/* ── Separador vertical ── */
.nav-sep {
  width: 1px;
  height: 14px;
  background: var(--cinza);
  margin-right: 16px;
  flex-shrink: 0;
}

.nav-mod {
  font-family: var(--font-ui);
  font-size: var(--text-label);
  font-weight: var(--weight-semibold);
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: #999;
}

/* ── Seletor de módulo ── */
.nav-mod-wrap {
  position: relative;
  margin-right: 20px;
  flex-shrink: 0;
}

.nav-lbl-btn {
  background: none;
  border: none;
  font-family: var(--font-ui);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: #999;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  gap: 4px;
}
.nav-lbl-btn:hover { color: var(--grafite); }

.nav-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  left: -12px;
  background: var(--branco);
  border: 1px solid var(--cinza);
  min-width: 200px;
  z-index: 200;
  box-shadow: var(--shadow-modal);
  border-radius: var(--radius-card);
  overflow: hidden;
}
.nav-dropdown.open { display: block; }

.nav-dropdown a {
  display: block;
  padding: 7px 16px 7px 12px;
  font-family: var(--font-ui);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--grafite);
  text-decoration: none;
  white-space: nowrap;
}
.nav-dropdown a:hover { background: var(--off); }
.nav-dropdown a.nd-active {
  font-weight: 700;
  pointer-events: none;
  color: var(--nav-active, var(--azul));
}

.nd-sep {
  height: 1px;
  background: var(--cinza);
  margin: 4px 0;
}

/* ── Tabs ── */
.nav-tabs {
  display: flex;
  height: 100%;
  gap: 0;
}

.ntab {
  display: flex;
  align-items: center;
  padding: 0 11px;
  font-family: var(--font-ui);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: #999;
  border-bottom: 2px solid transparent;
  border-top: none;
  border-left: none;
  border-right: none;
  background: none;
  cursor: pointer;
  white-space: nowrap;
  transition: color var(--transition-fast);
}
.ntab:hover { color: var(--grafite); }
.ntab.active {
  color: var(--nav-active, var(--grafite));
  border-bottom-color: var(--nav-active, var(--grafite));
}

/* ── Área direita ── */
.nav-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

/* ── Indicador de conexão ── */
.conn-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #ccc;
  flex-shrink: 0;
  cursor: default;
  pointer-events: none;
  transition: background var(--transition-normal);
}
.conn-dot.online  { background: #22c55e; }
.conn-dot.offline { background: var(--terracota); }

/* ── EXP Room (opcional) ── */
.exp-room-btn {
  width: 28px;
  height: 28px;
  border: 1px solid var(--verde);
  background: var(--verde-bg);
  color: var(--verde);
  border-radius: var(--radius-btn);
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  font-size: 13px;
  flex-shrink: 0;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.exp-room-btn:hover { background: var(--verde); color: #fff; }
.exp-room-btn.active {
  background: var(--verde);
  color: #fff;
  animation: exp-room-pulse 1.5s ease-in-out infinite;
}

@keyframes exp-room-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(62, 120, 88, 0.4); }
  50%       { box-shadow: 0 0 0 6px rgba(62, 120, 88, 0); }
}
[data-theme="dark"] .exp-room-btn.active {
  animation-name: exp-room-pulse-dark;
}
@keyframes exp-room-pulse-dark {
  0%, 100% { box-shadow: 0 0 0 0 rgba(82, 166, 118, 0.4); }
  50%       { box-shadow: 0 0 0 6px rgba(82, 166, 118, 0); }
}

/* ── Notificações (opcional) ── */
.notif-wrap {
  position: relative;
  display: flex;
  align-items: center;
  gap: 4px;
}

.notif-bell {
  width: 28px;
  height: 28px;
  border: 1px solid var(--cinza);
  background: var(--branco);
  border-radius: var(--radius-btn);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  position: relative;
  flex-shrink: 0;
  transition: border-color var(--transition-fast);
}
.notif-bell:hover { border-color: var(--grafite); }

.notif-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 16px;
  height: 16px;
  background: var(--terracota);
  color: #fff;
  font-size: 8px;
  font-weight: 700;
  font-family: var(--font-mono);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  border: 2px solid var(--off);
  pointer-events: none;
}

/* Botão + lembrete — socio-only (opcional) */
.notif-plus {
  width: 22px;
  height: 22px;
  border: none;
  background: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 15px;
  font-weight: 300;
  color: #bbb;
  font-family: inherit;
  transition: color var(--transition-fast);
  padding: 0;
}
.notif-plus:hover { color: var(--grafite); }

/* Painel de notificações */
.notif-panel {
  display: none;
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  background: var(--branco);
  border: 1px solid var(--cinza);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-modal);
  min-width: 340px;
  max-height: 520px;
  overflow-y: auto;
  z-index: 200;
}
.notif-panel.open { display: block; }

.notif-panel-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 16px 11px;
  border-bottom: 1px solid var(--cinza2);
  position: sticky;
  top: 0;
  background: var(--branco);
  z-index: 1;
}

.notif-panel-hd-t {
  font-family: var(--font-ui);
  font-size: var(--text-label);
  font-weight: var(--weight-label);
  letter-spacing: var(--label-spacing);
  text-transform: uppercase;
  color: var(--grafite);
}

.notif-panel-clr {
  background: none;
  border: none;
  font-family: var(--font-ui);
  font-size: 10px;
  color: var(--cinza);
  cursor: pointer;
  padding: 0;
  transition: color var(--transition-fast);
}
.notif-panel-clr:hover { color: var(--grafite); }

/* ── Itens dentro do painel de notificações ── */
.notif-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--cinza2);
  cursor: pointer;
  transition: background var(--transition-fast);
}
.notif-item:last-child { border-bottom: none; }
.notif-item.nova { background: #EEF3FB; }
.notif-item:hover { background: var(--off); }
.notif-item.nova:hover { background: #E1ECFF; }
[data-theme="dark"] .notif-item.nova { background: rgba(74,114,181,.13); }
[data-theme="dark"] .notif-item:hover { background: var(--off); }
[data-theme="dark"] .notif-item.nova:hover { background: rgba(74,114,181,.20); }

.notif-item-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.notif-icon {
  font-size: 13px;
  flex-shrink: 0;
  margin-top: 1px;
}
.notif-titulo {
  font-size: 11px;
  font-weight: 600;
  flex: 1;
  line-height: 1.4;
  color: var(--grafite);
}
.notif-corpo {
  font-size: 10px;
  color: #666;
  line-height: 1.4;
  padding-left: 21px;
  white-space: pre-wrap;
  word-break: break-word;
}
.notif-ts {
  font-size: 9px;
  color: #bbb;
  padding-left: 21px;
}
.notif-check-btn {
  width: 20px;
  height: 20px;
  border: 1px solid var(--cinza);
  border-radius: 50%;
  background: var(--branco);
  font-size: 9px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #888;
  font-family: inherit;
  padding: 0;
  line-height: 1;
  transition: border-color var(--transition-fast), color var(--transition-fast);
}
.notif-check-btn:hover { border-color: var(--verde); color: var(--verde); }
[data-theme="dark"] .notif-titulo { color: var(--grafite); }
[data-theme="dark"] .notif-corpo  { color: #999; }

/* ── Separador de seção dentro do painel de notificações ── */
.notif-sec-hd {
  font-family: var(--font-ui);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
  color: var(--cinza);
  padding: 7px 14px 4px;
  border-top: 1px solid var(--cinza2);
  background: var(--off);
  position: sticky;
  top: 0;
  z-index: 1;
}
.notif-sec-hd:first-child { border-top: none; }

/* ── Chip de usuário ── */
.user-pill-wrap {
  position: relative;
  display: inline-flex;
  min-width: 120px;
  max-width: 200px;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 3px 9px 3px 3px;
  border: 1px solid var(--cinza);
  background: var(--branco);
  cursor: pointer;
  border-radius: 20px;
  width: 100%;
  box-sizing: border-box;
  transition: border-color var(--transition-fast);
}
.user-chip:hover { border-color: var(--grafite); }

.uav,
.user-av {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-ui);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.3px;
  color: #fff;
  flex-shrink: 0;
}

.uav.has-avatar,
.user-av.has-avatar {
  overflow: hidden;
  padding: 0;
}

.uav img,
.user-av img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.u-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  flex: 1;
  min-width: 0;
}

.u-nome {
  font-family: var(--font-ui);
  font-size: 10px;
  font-weight: 500;
  color: var(--grafite);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

.u-role {
  font-family: var(--font-ui);
  font-size: 8px;
  font-weight: 400;
  color: #888;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

.u-caret,
.user-chip-arrow {
  font-size: 8px;
  color: #bbb;
  flex-shrink: 0;
}

/* ── Dropdown de usuário ── */
.user-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  width: 100%;
  background: var(--branco);
  border: 1px solid var(--cinza);
  z-index: 200;
  box-shadow: var(--shadow-modal);
  border-radius: var(--radius-card);
  overflow: hidden;
}
.user-dropdown.open { display: block; }

.user-dropdown button {
  display: block;
  width: 100%;
  padding: 9px 14px;
  background: none;
  border: none;
  font-family: var(--font-ui);
  font-size: var(--text-sub);
  font-weight: 500;
  color: var(--terracota);
  text-align: left;
  cursor: pointer;
  box-sizing: border-box;
}
.user-dropdown button:hover { background: var(--off); }

/* Painel de resumo de identidade no topo do dropdown */
.user-dropdown-summary {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 12px 14px 10px;
}
.ud-summary-name {
  font-size: 11px;
  font-weight: 700;
  color: var(--grafite);
  line-height: 1.35;
  word-break: break-word;
}
.ud-summary-role {
  font-size: 10px;
  color: #777;
  line-height: 1.35;
}
.ud-summary-email {
  font-size: 10px;
  color: #999;
  line-height: 1.4;
  word-break: break-word;
}
[data-theme="dark"] .ud-summary-name  { color: var(--grafite); }
[data-theme="dark"] .ud-summary-role  { color: #A7A095; }
[data-theme="dark"] .ud-summary-email { color: #8F897F; }

/* Separador interno do dropdown */
.ud-sep,
.user-dropdown-sep {
  height: 1px;
  background: var(--cinza2);
  margin: 3px 0;
}

/* Item "em breve" — placeholder visual */
.ud-coming {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 9px 14px;
  box-sizing: border-box;
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 500;
  color: var(--cinza);
  cursor: default;
}
.ud-coming::after {
  content: 'em breve';
  font-size: 7px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--ouro);
  opacity: 0.8;
  flex-shrink: 0;
  margin-left: 8px;
}

.user-dropdown-note,
.user-term-state {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  font-family: var(--font-ui);
  font-size: var(--text-label);
  line-height: 1.4;
}

.user-dropdown-note {
  color: #888;
  border-top: 1px solid rgba(0, 0, 0, 0.04);
}
.user-dropdown-note:empty { display: none; }

.user-term-state {
  cursor: pointer;
  transition: background var(--transition-fast);
}

.user-term-state.pending {
  color: var(--azul);
  background: var(--azul-bg);
  border-top: 1px solid rgba(74, 114, 181, 0.2);
  border-bottom: 1px solid rgba(74, 114, 181, 0.2);
}

.user-term-state.pending:hover {
  background: #d8e4f7;
}

.user-term-state.ok {
  color: #bbb;
  background: none;
}

.user-term-state.ok:hover {
  background: var(--off);
}

.term-state-hover {
  display: none;
  color: #777;
  font-style: italic;
}

.user-term-state.ok:hover .term-state-normal {
  display: none;
}

.user-term-state.ok:hover .term-state-hover {
  display: flex;
  align-items: center;
  gap: 5px;
}

.user-term-state-icon,
.term-chip-icon {
  font-size: 11px;
  flex-shrink: 0;
}

.term-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  font-family: var(--font-ui);
  font-size: var(--text-label);
  cursor: pointer;
}

.term-chip.pending {
  padding: 4px 10px;
  border: 1px solid rgba(74, 114, 181, 0.35);
  border-radius: 999px;
  color: var(--azul);
  background: var(--azul-bg);
}

.term-chip.ok {
  color: #bbb;
  padding: 0;
  border: none;
  background: none;
}

/* ── Dark mode — nav ── */
[data-theme="dark"] .nav-mod {
  color: #666;
}

[data-theme="dark"] .nav-dropdown,
[data-theme="dark"] .user-dropdown,
[data-theme="dark"] .notif-panel { box-shadow: var(--shadow-modal); }

[data-theme="dark"] .notif-badge { border-color: var(--off); }

[data-theme="dark"] .exp-room-btn {
  background: var(--branco);
}

[data-theme="dark"] .user-dropdown-note {
  color: #999;
}

[data-theme="dark"] .user-term-state.ok {
  color: #999;
  background: none;
}

[data-theme="dark"] .user-term-state.pending {
  color: #a9c3f6;
  background: rgba(74, 114, 181, 0.16);
  border-top-color: rgba(74, 114, 181, 0.25);
  border-bottom-color: rgba(74, 114, 181, 0.25);
}

[data-theme="dark"] .user-term-state.pending:hover {
  background: #1f2d47;
}


/* ═══════════════════════════════════════════
   COMPONENTE — FEEDBACK POPOVER (botão "!")
   Botão de reportar problema/sugestão presente em todos os módulos.
   HTML esperado no nav-right:
     <div class="nav-feedback-wrap" id="nav-feedback-wrap">
       <button class="nav-feedback-btn" id="nav-feedback-btn"
               onclick="toggleToolFeedbackPopover(event)"
               title="Problemas e sugestões">!</button>
       <div class="nav-feedback-pop" id="nav-feedback-pop">
         <div class="nav-feedback-title">Problema ou sugestão</div>
         <div class="nav-feedback-sub">...</div>
         ...
         <div class="nav-feedback-status" id="tool-feedback-status"></div>
         <div class="nav-feedback-actions">...</div>
       </div>
     </div>
═══════════════════════════════════════════ */

.nav-feedback-wrap { position: relative; }

.nav-feedback-btn {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 1px solid var(--cinza);
  background: var(--branco);
  color: var(--grafite);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-ui);
  font-size: 12px; font-weight: 700;
  cursor: pointer;
  transition: border-color var(--transition-fast), background var(--transition-fast), transform var(--transition-fast);
}
.nav-feedback-btn:hover {
  border-color: var(--grafite);
  background: var(--off);
  transform: translateY(-1px);
}

.nav-feedback-pop {
  position: absolute; top: calc(100% + 10px); right: 0;
  z-index: 9100;
  width: min(360px, calc(100vw - 24px));
  padding: 12px;
  display: none; flex-direction: column; gap: 10px;
  background: var(--branco);
  border: 1px solid var(--cinza);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,.12);
}
.nav-feedback-pop.open { display: flex; }
.nav-feedback-pop::before {
  content: ''; position: absolute; top: -6px; right: 12px;
  width: 12px; height: 12px; transform: rotate(45deg);
  background: var(--branco);
  border-top: 1px solid var(--cinza);
  border-left: 1px solid var(--cinza);
}

.nav-feedback-title {
  font-size: 9px; font-weight: 700;
  letter-spacing: .07em; text-transform: uppercase; color: #666;
}
.nav-feedback-sub,
.nav-feedback-status { font-size: 10px; color: #888; line-height: 1.45; }
.nav-feedback-actions { display: flex; justify-content: flex-end; gap: 6px; flex-wrap: wrap; }

/* Dark mode */
[data-theme="dark"] .nav-feedback-pop { background: var(--branco); border-color: var(--cinza); }
[data-theme="dark"] .nav-feedback-pop::before { background: var(--branco); border-color: var(--cinza); }
[data-theme="dark"] .nav-feedback-pop select,
[data-theme="dark"] .nav-feedback-pop textarea { background: var(--branco); border-color: var(--cinza); color: var(--grafite); }


/* ═══════════════════════════════════════════════════════════════
   IDENTIDADE POR MÓDULO
   Cada módulo sobrescreve apenas --nav-active no <style> local.
   O resto herda automaticamente desta folha.

   EXP.gestão      → --nav-active: var(--ouro)
   EXP.comercial   → --nav-active: var(--azul)
   EXP.financeiro  → --nav-active: var(--fin)   (definido localmente)
   EXP.calc        → --nav-active: var(--verde)
   EXP.apoio       → --nav-active: var(--terracota)
   EXP.contatos    → --nav-active: var(--roxo)
═══════════════════════════════════════════════════════════════ */


/* ═══════════════════════════════════════════════════════════════
   BASE — BODY E CONTAINER PRINCIPAL
   Regras estruturais compartilhadas por todos os módulos.
   Cada módulo importa este arquivo e herda automaticamente.
   Dark mode: zero overrides necessários — tokens mudam sozinhos.
═══════════════════════════════════════════════════════════════ */

/* ── Scrollbar slim global ── */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(0,0,0,.15) transparent;
}
[data-theme="dark"] * {
  scrollbar-color: rgba(255,255,255,.12) transparent;
}
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,.15); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,.28); }
[data-theme="dark"] ::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); }
[data-theme="dark"] ::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.22); }

body {
  font-family: var(--font-ui);
  font-size: var(--text-body);
  font-weight: var(--weight-light);
  line-height: 1.5;
  color: var(--grafite);
  background: var(--off);
  min-height: 100vh;
}

.main {
  padding: var(--gap-md);
  max-width: 1400px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}


/* ═══════════════════════════════════════════════════════════════
   COMPONENTE — CARD
   Superfície branca sobre fundo off-white. Borda discreta.
   Variantes de acento: classe de cor no elemento (.verde, .azul…)

   HTML canônico:
     <div class="card verde">
       <div class="card-hd">
         <span class="card-title">Título</span>
         <button class="btn sm">Ação</button>
       </div>
       <div class="card-body"> … </div>
     </div>
═══════════════════════════════════════════════════════════════ */

.card {
  background: var(--branco);
  border: 1px solid var(--cinza);
  border-radius: var(--radius-card);
  overflow: hidden;
  position: relative;
}

/* Barra lateral de 3px — ativa com classe de cor */
.card::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 3px;
  height: 100%;
  background: transparent;
}
.card.verde::before     { background: var(--verde); }
.card.azul::before      { background: var(--azul); }
.card.ouro::before      { background: var(--ouro); }
.card.terracota::before { background: var(--terracota); }
.card.cinza::before     { background: var(--cinza); }

.card-hd,
.card-hdr {
  padding: 9px 14px 9px 17px;
  border-bottom: 1px solid var(--cinza);
  display: flex;
  align-items: center;
  gap: var(--gap-sm);
  flex-wrap: wrap;
}

.card-title {
  font-size: var(--text-label);
  font-weight: var(--weight-label);
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--grafite);
  flex: 1;
}

.card-body {
  padding: 12px 14px 12px 17px;
}


/* ═══════════════════════════════════════════════════════════════
   COMPONENTE — STAT (KPI)
   Card de indicador com valor numérico em destaque.

   HTML canônico:
     <div class="stat azul">
       <div class="stat-lbl">Pipeline ativo</div>
       <div class="stat-val">R$ 17.665.154</div>
       <div class="stat-sub">83 oportunidades</div>
     </div>
═══════════════════════════════════════════════════════════════ */

.stat {
  background: var(--branco);
  border: 1px solid var(--cinza);
  border-radius: var(--radius-card);
  padding: 14px 16px 14px 19px;
  overflow: hidden;
  position: relative;
}

.stat::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 3px;
  height: 100%;
  background: var(--cinza);
}
.stat.verde::before     { background: var(--verde); }
.stat.azul::before      { background: var(--azul); }
.stat.ouro::before      { background: var(--ouro); }
.stat.terracota::before { background: var(--terracota); }

.stat-lbl {
  font-size: var(--text-label);
  font-weight: var(--weight-label);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--grafite);
  opacity: 0.5;
  margin-bottom: var(--gap-xs);
}

.stat-val {
  font-size: 24px;
  font-weight: 700;
  font-family: var(--font-mono);
  letter-spacing: -1px;
  line-height: 1;
  color: var(--grafite);
}

.stat-sub {
  font-size: var(--text-sub);
  color: var(--grafite);
  opacity: 0.5;
  margin-top: var(--gap-xs);
}


/* ═══════════════════════════════════════════════════════════════
   COMPONENTE — BOTÃO
   Três variantes: padrão (outline), sm (compacto), filled (sólido).
   Dark mode: automático via tokens.

   HTML canônico:
     <button class="btn">Ação</button>
     <button class="btn sm">Compacto</button>
     <button class="btn filled">Primário</button>
     <button class="btn sm filled">Primário compacto</button>
═══════════════════════════════════════════════════════════════ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--gap-xs);
  padding: 6px 14px;
  font-family: var(--font-ui);
  font-size: var(--text-body);
  font-weight: var(--weight-semibold);
  line-height: 1;
  white-space: nowrap;
  color: #888;
  background: var(--branco);
  border: 1px solid var(--cinza);
  border-radius: var(--radius-btn);
  cursor: pointer;
  text-decoration: none;
  transition:
    border-color var(--transition-fast),
    color        var(--transition-fast),
    background   var(--transition-fast),
    opacity      var(--transition-fast);
}
.btn:hover {
  border-color: var(--grafite);
  color: var(--grafite);
}
.btn:disabled {
  opacity: 0.45;
  cursor: default;
  pointer-events: none;
}

/* Compacto */
.btn.sm {
  font-size: var(--text-label);
  padding: 4px 10px;
}

/* Sólido — ação primária */
.btn.filled {
  background: var(--grafite);
  border-color: var(--grafite);
  color: var(--branco);
}
.btn.filled:hover { opacity: 0.82; }

/* Perigo — ação destrutiva */
.btn.danger {
  border-color: var(--terracota);
  color: var(--terracota);
}
.btn.danger:hover {
  background: var(--terracota);
  color: #fff;
}


/* ═══════════════════════════════════════════════════════════════
   COMPONENTE — FILTER SELECT
   Select/input inline de filtro, menor que o exp-input padrão.

   HTML canônico:
     <select class="filter-select" onchange="…">…</select>
     <input type="date" class="filter-select">
═══════════════════════════════════════════════════════════════ */

.filter-select {
  font-family: var(--font-ui);
  font-size: var(--text-sub);
  font-weight: var(--weight-body);
  color: var(--grafite);
  background: var(--branco);
  border: 1px solid var(--cinza);
  border-radius: var(--radius-input);
  padding: 4px 8px;
  outline: none;
  transition: border-color var(--transition-fast);
  color-scheme: light dark;
}
.filter-select:focus { border-color: var(--mod-focus, var(--azul)); box-shadow: 0 0 0 3px var(--mod-focus-soft, var(--azul-soft)); }


/* ═══════════════════════════════════════════════════════════════
   COMPONENTE — MODAL
   Overlay + painel. Dark mode: automático via tokens.

   HTML canônico:
     <div class="modal-bg" id="modal-x" style="display:none">
       <div class="modal">
         <div class="modal-hd">
           <span class="modal-title">Título</span>
           <button class="modal-close" onclick="fechar()">×</button>
         </div>
         <div class="modal-body"> … </div>
         <div class="modal-ft">
           <button class="btn">Cancelar</button>
           <button class="btn filled">Salvar</button>
         </div>
       </div>
     </div>
═══════════════════════════════════════════════════════════════ */

.modal-bg {
  position: fixed;
  inset: 0;
  background: var(--overlay-bg);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 16px;
  overflow-y: auto;
}

.modal {
  background: var(--branco);
  border: 1px solid var(--cinza);
  border-radius: var(--radius-modal);
  width: 540px;
  max-width: 96vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-modal);
}

.modal-hd {
  padding: 14px 16px;
  border-bottom: 1px solid var(--cinza);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap-sm);
  flex-shrink: 0;
}

.modal-title {
  font-size: var(--text-title);
  font-weight: var(--weight-semibold);
  color: var(--grafite);
}

.modal-close {
  background: none;
  border: none;
  font-size: 18px;
  line-height: 1;
  color: #bbb;
  cursor: pointer;
  padding: 0;
  transition: color var(--transition-fast);
  font-family: inherit;
}
.modal-close:hover { color: var(--grafite); }

.modal-body {
  padding: 16px;
  overflow-y: auto;
  flex: 1;
}

.modal-ft {
  padding: 10px 16px;
  border-top: 1px solid var(--cinza);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--gap-sm);
  flex-shrink: 0;
}


/* ═══════════════════════════════════════════════════════════════
   COMPONENTE — TABELA (.tbl)
   Tabela padrão da plataforma. Dark mode: automático via tokens.

   HTML canônico:
     <table class="tbl">
       <thead><tr><th>Col A</th><th>Col B</th></tr></thead>
       <tbody>
         <tr><td>…</td><td>…</td></tr>
       </tbody>
     </table>
═══════════════════════════════════════════════════════════════ */

.tbl {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-ui);
  font-size: var(--text-body);
}

.tbl th {
  background: var(--off);
  color: var(--grafite);
  text-align: left;
  font-size: var(--text-label);
  font-weight: var(--weight-label);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 7px 10px;
  border-bottom: 1px solid var(--cinza);
  opacity: 0.7;
}

.tbl td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--cinza2);
  color: var(--grafite);
  vertical-align: top;
}

.tbl tr:last-child td { border-bottom: none; }
.tbl tr:hover td      { background: var(--off); }
.tbl .n               { text-align: right; font-family: var(--font-mono); white-space: nowrap; }


/* ═══════════════════════════════════════════════════════════════
   COMPONENTE — TOAST
   Notificação flutuante temporária.
   Dark mode: automático (usa var(--grafite) e var(--branco)).

   JS canônico: função toast(msg, tipo='') — tipo: 'ok' | 'erro' | ''
═══════════════════════════════════════════════════════════════ */

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(0);
  background: var(--grafite);
  color: var(--branco);
  font-family: var(--font-ui);
  font-size: var(--text-sub);
  font-weight: var(--weight-semibold);
  padding: 9px 18px;
  border-radius: var(--radius-btn);
  box-shadow: var(--shadow-modal);
  z-index: 9999;
  white-space: nowrap;
  pointer-events: none;
  animation: toastIn var(--transition-normal) ease;
}

.toast.ok   { background: var(--verde); }
.toast.erro { background: var(--terracota); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(8px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0);   }
}


/* ═══════════════════════════════════════════════════════════════
   UTILITÁRIOS — ESTADOS VAZIOS / CARREGAMENTO
═══════════════════════════════════════════════════════════════ */

.loading-state {
  text-align: center;
  color: var(--cinza);
  font-size: var(--text-sub);
  padding: 24px 16px;
  font-family: var(--font-ui);
}

.empty-note {
  text-align: center;
  color: var(--cinza);
  font-size: var(--text-sub);
  padding: 16px;
  font-family: var(--font-ui);
}


/* ═══════════════════════════════════════════════════════════════
   NOTA SOBRE DARK MODE NOS MÓDULOS
   ───────────────────────────────────────────────────────────────
   Todos os componentes acima usam APENAS variáveis CSS.
   O bloco [data-theme="dark"] no início deste arquivo já redefine
   todos os tokens (--branco, --off, --cinza, --grafite, etc.).

   Portanto, os módulos NÃO precisam de:
     [data-theme="dark"] .card  { background: var(--branco) }
     [data-theme="dark"] .btn   { background: var(--branco) }
     [data-theme="dark"] .modal { background: var(--branco) }
     … e afins

   Esses blocos são redundantes e podem ser removidos dos módulos.

   O único dark mode legítimo nos módulos são:
     - Componentes exclusivos do módulo com cores locais hardcoded
     - Superfícies que usam rgba() fixo (precisam de ajuste manual)
     - Inputs com background:#252523 (substituir por var(--branco))
═══════════════════════════════════════════════════════════════ */
