/* Sistema de design compartilhado entre as telas — Modulo 1 (SAC) */
/* Fonte principal: Geist (Vercel) — minimalista premium, casa com o Geist Mono
   que ja usamos nos numeros. Carregada aqui (centralizado) pra valer em todas as
   telas sem mexer no <head> de cada HTML. */
@import url('https://fonts.googleapis.com/css2?family=Geist:wght@300;400;500;600;700;800&family=Geist+Mono:wght@400;500;600&display=swap');
/* Fraunces (serifada editorial, gratis/Google) — so' nos TITULOS, pro feel premium
   estilo Claude. Corpo/numeros seguem em Geist (sem serifa). */
@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,500;9..144,600;9..144,700&display=swap');

:root {
  /* ======================================================================
   * Design System — Âmbar Shop & Casa Rosé
   * Fase 1 (24/05/2026): paleta orange Tailwind + neutros Tailwind dark.
   * Identidade visual SaaS moderno (Linear/Stripe/Notion) com base warm
   * preservada (BG não-frio) pra casar com nome "Âmbar" (luz quente, terra).
   *
   * White mode: ADIADO. Variáveis nomeadas pra facilitar dual-theme futuro.
   * ======================================================================
   *
   * PRIMARIA — amber refinado (#F5820C) — Fase 0 (31/05/2026): acento unificado.
   * Anterior: Tailwind orange-500 #F97316. Mantemos --ambar como ALIAS
   * pra retro-compat (toda chamada var(--ambar) continua funcionando).
   */
  --primary: #EFAD55;            /* PANTONE 14-1045 TCX Amber — a cor do nome "Âmbar" */
  --primary-hover: #E5A23F;      /* amber hover/active (um tom mais fechado) */
  --primary-light: #FFF4EC;      /* orange-50 — chips/badges em fundo claro (futuro white mode) */
  --primary-soft: rgba(239, 173, 85, 0.14);  /* substitui ambar-soft */
  /* anel de foco/hover ambar — usado em botoes pill, busca e selects (estilo Tiny) */
  --primary-ring: rgba(239, 173, 85, 0.30);

  /* Aliases pra compat com código antigo que usa --ambar */
  --ambar: var(--primary);
  --ambar-soft: var(--primary-soft);

  /* SECUNDÁRIA — Casa Rosé (rosa quente, distinção visual entre empresas) */
  --teal: #D67B92;
  --teal-soft: rgba(214, 123, 146, 0.14);

  /*
   * NEUTROS — base warm (não trocamos pra Tailwind slate frio).
   * BGs continuam quentes pra reforçar a marca "Âmbar".
   */
  /* Paleta "Grafite warm" (Thiago, 11/06/2026): marrom puxado pra baixo —
   * mais limpo/crisp que o cafe anterior, mantendo um sopro de calor. */
  --bg: #0C0B0A;                 /* page background — grafite warm */
  --bg-2: #1A1918;               /* surface — cards, panels */
  --bg-3: #262321;               /* surface-soft — hover, nested */
  --border: #322E2B;             /* borders — grafite warm */
  --bg-1: var(--bg-3);           /* compat: telas que referenciam --bg-1 (superficie elevada/hover) */

  /*
   * TEXTO — Tailwind gray (#F9FAFB / #D1D5DB / #9CA3AF).
   * Mais clean que cream #E8DFD3 anterior, melhor leitura em fundo warm.
   */
  --text: #F9FAFB;               /* gray-50 — texto principal */
  --text-2: #D1D5DB;             /* gray-300 — texto secundário */
  --text-3: #9CA3AF;             /* gray-400 — texto muted, captions */
  /* texto SOBRE fundo claro/amarelo (ex: chip amarelo de quantidade) — contraste escuro */
  --text-dark: #1A1614;
  /* texto SOBRE o laranja primário — BRANCO (padrão do sistema, Thiago 03/06/2026) */
  --text-on-primary: #2A1E0C;   /* texto/icone ESCURO no botao amber (claro) — legivel, estilo Claude */

  /* Compat: alguns lugares usam --text-secondary / --text-muted */
  --text-primary: var(--text);
  --text-secondary: var(--text-2);
  --text-muted: var(--text-3);
  --text-1: var(--text);         /* compat: telas que referenciam --text-1 (= texto principal) */

  /*
   * ESTADOS — semânticos. Padrão Tailwind:
   * danger #EF4444 (red-500) · warning #F59E0B (amber-500)
   * success #22C55E (green-500) · purple #8B5CF6 (violet-500)
   *
   * Nota: --info AZUL foi removido como cor principal (decisão Thiago 24/05/2026).
   * Mantido como alias do primary pra não quebrar telas legadas, mas evitar
   * uso novo. Substitua var(--info) por var(--primary) quando vir.
   */
  --danger: #EF4444;
  --danger-soft: rgba(239, 68, 68, 0.12);
  --warning: #F59E0B;
  --warning-soft: rgba(245, 158, 11, 0.12);
  --success: #22C55E;
  --success-soft: rgba(34, 197, 94, 0.12);
  --purple: #8B5CF6;
  --purple-soft: rgba(139, 92, 246, 0.15);
  /* DEPRECATED — usar --primary. Mantido como alias pra retro-compat. */
  --info: var(--primary);
  --info-soft: var(--primary-soft);

  /*
   * RADIUS — bumpado pra 14px (Fase 1) pra alinhar com SaaS moderno.
   * --radius-sm 8px, --radius 14px, --radius-lg 18px.
   */
  --radius: 16px;
  --radius-sm: 8px;
  --radius-lg: 20px;

  /* Fonte de TITULOS — serifada editorial (Fraunces), feel premium estilo Claude.
     So' em titulos; corpo/numeros seguem em Geist (--font-display vs sans). */
  --font-display: 'Fraunces', Georgia, 'Times New Roman', serif;

  /* === Sistema de sombras multi-layer (upgrade 24/05/2026) ===
     Inspirado em Linear/Vercel: highlight interno + sombra suave + ring sutil.
     Da profundidade sem peso. Acumula bem com z-index. */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-sm:
    0 1px 0 rgba(255, 255, 255, 0.04) inset,
    0 1px 2px rgba(0, 0, 0, 0.22),
    0 0 0 1px rgba(255, 255, 255, 0.025);
  --shadow-md:
    0 1px 0 rgba(255, 255, 255, 0.05) inset,
    0 2px 4px rgba(0, 0, 0, 0.2),
    0 6px 12px -2px rgba(0, 0, 0, 0.22),
    0 0 0 1px rgba(255, 255, 255, 0.03);
  --shadow-lg:
    0 1px 0 rgba(255, 255, 255, 0.06) inset,
    0 4px 8px rgba(0, 0, 0, 0.22),
    0 12px 28px -6px rgba(0, 0, 0, 0.36),
    0 0 0 1px rgba(255, 255, 255, 0.04);
  --shadow-xl:
    0 1px 0 rgba(255, 255, 255, 0.07) inset,
    0 8px 16px rgba(0, 0, 0, 0.24),
    0 24px 48px -8px rgba(0, 0, 0, 0.48),
    0 0 0 1px rgba(255, 255, 255, 0.05);
  /* Compat com codigo antigo que usa --shadow */
  --shadow: var(--shadow-md);

  /* Sombra de card em repouso (feel "suave" estilo Claude — 14/06/2026):
     realce sutil no topo + contato leve + ambiente difusa larga. SEM o anel
     duro de 1px (a borda ja define o contorno). Cards calmos, sem peso. */
  --shadow-card:
    0 1px 0 rgba(255, 255, 255, 0.035) inset,
    0 1px 3px rgba(0, 0, 0, 0.14),
    0 8px 20px -8px rgba(0, 0, 0, 0.22);

  /* Glow ambient (futurista) — pra primary buttons + focus + accents.
     Atualizado pra orange-500 #F97316 (Fase 1 — 24/05/2026). */
  --glow-ambar-sm: 0 0 0 1px rgba(239, 173, 85, 0.25), 0 0 14px -2px rgba(239, 173, 85, 0.3);
  --glow-ambar-md: 0 0 0 1px rgba(239, 173, 85, 0.4), 0 0 28px -4px rgba(239, 173, 85, 0.4);
  --glow-ambar-lg: 0 0 0 1px rgba(239, 173, 85, 0.55), 0 0 36px -2px rgba(239, 173, 85, 0.55);

  /* Easing tokens — natural spring (Apple HIG / Linear) */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);

  /* Bottom nav (mobile/PWA) — paleta Ambar Refinado */
  --bn-bg: #141312;          /* superficie da barra/gaveta (grafite warm) */
  --bn-accent: #EFAD55;      /* amber forte */
  --bn-text: #EDE6DB;
  --bn-dim: #7d7163;
  --bn-border: rgba(255,255,255,0.06);

  /* Tokens Fase 1 — refinamento visual desktop (31/05/2026) */
  --sidebar-bg: #141312;                     /* sidebar grafite warm — igual --bn-bg do mobile */
  --sidebar-text: #E8E4DF;                   /* branco quente dos itens de nav sidebar */
  --border-hairline: rgba(255,255,255,0.06); /* borda fina — sidebar + mobile */
}

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

html {
  scroll-behavior: smooth;
}
/* PWA standalone — bloqueia double-tap zoom e (por default) pull-to-refresh.
   Sem afetar browser comum. Função bloquearZoomEmPWA() em shared.js
   ajusta o viewport meta tag dinamicamente. iOS ignora user-scalable=no
   desde iOS 10 mesmo em PWA, mas respeita touch-action: manipulation
   pra eliminar double-tap zoom. Combinação dos dois cobre todos browsers.

   Pull-to-refresh: bloqueado por default pra evitar recarregar acidentalmente
   no meio de uma conferencia/expedicao. Telas seguras (dashboard, pedidos,
   rastreamento, reclamacoes) ganham class `permite-refresh` no body via
   _aplicarPermiteRefresh() em shared.js — funciona em iOS e Android. */
@media (display-mode: standalone), (display-mode: fullscreen), (display-mode: minimal-ui) {
  html, body {
    touch-action: manipulation;
    overscroll-behavior-y: contain;  /* default: sem pull-to-refresh acidental */
  }
  /* Quando o body tem permite-refresh, libera o gesto nativo no
     elemento que rola (html no Android Chrome, body no iOS Safari).
     :has() suportado em iOS 17+ e Android Chrome 105+ — basta pros
     dispositivos atuais da equipe. */
  body.permite-refresh,
  html:has(body.permite-refresh) {
    overscroll-behavior-y: auto;
  }
}

html, body {
  /* gradiente warm muito sutil no topo — da profundidade sem perder o dark */
  background: radial-gradient(125% 85% at 50% -8%, #14120F 0%, var(--bg) 58%);
  color: var(--text);
  /*
   * Fonte principal: Plus Jakarta Sans (Fase 1 — 24/05/2026).
   * Geometric humanist, moderna, alta legibilidade pra UI densa.
   * Geist fica como fallback (já carregada em algumas paginas) +
   * system-ui pra render imediato enquanto fontes web carregam.
   *
   * Escala de pesos formalizada:
   *   400 — texto comum (parágrafos, descrições, valores secundários)
   *   500 — menus, navegação, labels
   *   600 — botões, títulos de seção, headers de card
   *   700-800 — KPIs principais, valores em destaque, números grandes
   */
  font-family: 'Geist', 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  font-size: 15px;
  font-weight: 400;
  line-height: 1.55;
  letter-spacing: -0.005em;
  /* dvh = altura "viva" do viewport (descontando teclado/barras moveis). */
  min-height: 100vh;
  min-height: 100dvh;
  /* tnum cria numeros de largura fixa — KPIs/colunas financeiras alinham bonito.
     (ss01 era stylistic set da Plus Jakarta; removido ao migrar pra Geist.) */
  font-feature-settings: 'tnum';
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* Focus-visible: glow ambient laranja (futurista, sem outline grosso).
   Acessível (WCAG 2.4.7) sem poluir mouse — só aparece em keyboard nav. */
:focus-visible {
  outline: none;
  box-shadow:
    0 0 0 2px var(--bg),
    0 0 0 4px var(--ambar),
    0 0 16px -2px rgba(239, 173, 85, 0.55),
    0 0 28px -4px rgba(239, 173, 85, 0.35);
  border-radius: 6px;
  transition: box-shadow 0.18s var(--ease-out);
}
:focus:not(:focus-visible) {
  outline: none;
}

/* Sidebar: glow MENOR e mais discreto pra nao "vazar" sobre items vizinhos
   nem deixar halo grande quando elemento ganha focus durante PJAX/navegacao.
   Antes (24/05/2026): focus-visible global aplicava glow grande tambem no
   menu colapsado — visual bagunçado. Aqui restringimos: so ring 2px laranja
   sem blur ambient. */
.sidebar-nav :focus-visible,
.sidebar-rodape :focus-visible,
.app-shell .sidebar :focus-visible {
  box-shadow:
    0 0 0 2px var(--bg),
    0 0 0 3px var(--ambar);
  border-radius: 6px;
}

/* Screen-reader only — esconde visualmente mas mantém acessível pra a11y.
   Use em labels de inputs que tem placeholder mas precisam de label real. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.container { max-width: 1400px; margin: 0 auto; padding: 28px; }

/* Hierarquia tipográfica */
h1, h2, h3, h4 { font-weight: 600; letter-spacing: -0.01em; }

/* ===== HEADER ===== */
header.topo {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  padding: 18px 22px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 14px;
}
header.topo h1 {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.015em;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
header.topo h1 .ic { color: var(--ambar); display: inline-flex; }

header.topo h1 .accent { color: var(--ambar); }
header.topo h1 .accent2 { color: var(--teal); }

.user-nome {
  font-size: 12px; color: var(--text-2);
  font-family: 'Geist Mono', monospace;
  max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.user-role-pill {
  font-size: 9px; padding: 2px 6px; border-radius: 99px;
  background: var(--bg-3); border: 1px solid var(--border);
  color: var(--ambar); text-transform: uppercase; letter-spacing: 0.05em;
  font-weight: 600;
}
.btn-sair {
  background: var(--bg-3);
  color: var(--text-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 9px;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  transition: all 0.18s ease;
  display: inline-flex;
  align-items: center;
}
.btn-sair:hover { color: var(--danger); border-color: var(--danger); }

/* ===== NAV BADGE (sidebar + flyout) ===== */
nav.sidebar-nav a .nav-badge,
.nav-grupo-flyout a .nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  font-size: 11px;
  font-weight: 700;
  /* DEFAULT = info/neutro (contagem informativa). Antes era vermelho pra tudo
     -> fadiga de alerta. Agora o vermelho fica só pro que é erro/atraso. */
  background: var(--bg-3);
  color: var(--text-2);
  border-radius: 99px;
  flex-shrink: 0;
}
/* Severidade (anti-fadiga de alerta, regra Thiago/CLAUDE.md):
   danger = erro/atraso/avaria · warning = pendência normal · info = contagem. */
nav.sidebar-nav a .nav-badge.danger,
.nav-grupo-flyout a .nav-badge.danger { background: var(--danger); color: #fff; }
nav.sidebar-nav a .nav-badge.warning,
.nav-grupo-flyout a .nav-badge.warning { background: var(--warning); color: #1A1614; }
nav.sidebar-nav a .nav-badge.info,
.nav-grupo-flyout a .nav-badge.info { background: var(--bg-3); color: var(--text-2); }
/* Variante urgente — vermelha pulsante (reclamacoes fora SLA, etc).
   Animacao USA SO transform — sem box-shadow expanding. */
nav.sidebar-nav a .nav-badge.urgente,
.nav-grupo-flyout a .nav-badge.urgente,
.nav-grupo-badge-urgente {
  background: var(--danger);
  color: #fff;
  animation: nav-badge-pulse 1.8s ease-in-out infinite;
}
@keyframes nav-badge-pulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.15); }
}
/* Acessibilidade: respeita preferencia do usuario por menos animacao */
@media (prefers-reduced-motion: reduce) {
  nav.sidebar-nav a .nav-badge.urgente,
  .nav-grupo-flyout a .nav-badge.urgente { animation: none; }
}

/* ===== CENTRO DE ALERTAS — sino no header com dropdown =====
   Acessivel a todos. Filtra por permissao (operacional sem alerta financeiro).
   Reusa contadores do menu (1 chamada compartilhada). */
.topbar-direita {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  position: relative;
}
.centro-alertas-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 50%;
  cursor: pointer;
  font-size: 16px;
  color: var(--text-2);
  transition: background 0.15s, border-color 0.15s;
}
.centro-alertas-btn:hover {
  background: var(--bg-3);
  border-color: var(--ambar);
}
/* SVG do sino herda cor do botao (text-2) — fica branco-acinzentado, fica
   laranja no hover. Mais sutil que emoji amarelo da chrome (regra Thiago
   24/05/2026 — chrome sem emoji colorido). */
.centro-alertas-btn .centro-alertas-ico { display: inline-flex; line-height: 0; }
.centro-alertas-btn .centro-alertas-ico svg { width: 18px; height: 18px; }
/* Badge: era vermelho saturado puro (--danger #EF4444) que parecia
   alarme. Agora laranja primary (cor da marca) — mantém atenção mas sem
   agredir. Regra Thiago 27/05/2026: bolinha mais discreta. */
.centro-alertas-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  background: var(--primary);
  color: var(--text-on-primary);
  font-size: 10px;
  font-weight: 700;
  font-family: 'Geist Mono', monospace;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--bg-2);
  animation: badge-aparecer 0.3s ease-out;
}
@keyframes badge-aparecer {
  from { transform: scale(0); }
  to { transform: scale(1); }
}
.centro-alertas-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  min-width: 320px;
  max-width: 380px;
  max-height: 70vh;
  overflow-y: auto;
  z-index: 200;
  padding: 6px;
}
.centro-alertas-titulo {
  padding: 8px 12px 10px;
  font-size: 11px;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 700;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}
.centro-alertas-vazio {
  padding: 24px 16px;
  text-align: center;
  color: var(--text-3);
  font-size: 13px;
}
.centro-alertas-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 6px;
  text-decoration: none;
  color: var(--text);
  font-size: 13px;
  transition: background 0.12s;
}
.centro-alertas-item:hover {
  background: var(--bg-3);
}
.centro-alertas-item-ico {
  font-size: 18px;
  flex-shrink: 0;
}
.centro-alertas-item-label {
  flex: 1;
}
.centro-alertas-item-count {
  background: var(--danger);
  color: #fff;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 700;
  font-family: 'Geist Mono', monospace;
  min-width: 24px;
  text-align: center;
}
@media (max-width: 700px) {
  .centro-alertas-dropdown {
    right: -8px;
    left: -8px;
    min-width: auto;
    max-width: none;
  }
}

/* ===== PLACEHOLDERS "EM BREVE" no menu =====
   Mostra itens da spec que ainda nao tem tela — cinza, sem acão.
   Preserva a visao do desenho final do menu sem links quebrados. */
.nav-placeholder,
.nav-grupo-flyout .nav-placeholder {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  /* Contraste WCAG: text-2 (mais claro) + opacidade leve. A hierarquia de
     "desabilitado" fica no itálico + badge "EM BREVE" + cursor not-allowed,
     sem esmagar a legibilidade (antes era text-3 + opacity 0.55 = ilegível). */
  color: var(--text-2);
  opacity: 0.72;
  cursor: not-allowed;
  font-size: 13px;
  user-select: none;
  border-radius: 6px;
}
.nav-placeholder:hover {
  background: transparent;     /* sem feedback hover — nao eh clicavel */
}
.nav-placeholder .nav-placeholder-label {
  flex: 1;
  font-style: italic;
}
.nav-badge.nav-em-breve {
  background: var(--bg-3);
  color: var(--text-2);
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
}
/* Toggle "Em breve (N)" — agrupa os placeholders de um grupo, recolhido por padrao */
.nav-embreve-toggle {
  display: flex; align-items: center; gap: 7px; width: 100%;
  background: none; border: 0; cursor: pointer; font-family: inherit;
  color: var(--text-3); font-size: 11.5px; font-weight: 500;
  padding: 7px 12px; border-radius: var(--radius-sm); text-align: left; margin-top: 2px;
}
.nav-embreve-toggle:hover { color: var(--text-2); background: var(--bg-3); }
.nav-embreve-toggle svg { width: 13px; height: 13px; transition: transform 0.15s ease; opacity: 0.8; }
.nav-embreve-toggle.aberto svg { transform: rotate(180deg); }
.nav-embreve-itens[hidden] { display: none; }

/* ===== CARDS, KPIs =====
 * Refator 24/05/2026: estilo Tiny — flat, sombra minima, sem lift no hover.
 * Fase 1 refino (31/05/2026): padding bumped pra 20px 22px (mais respiracao).
 * Antes: padding 18px + shadow xs + so border-color muda no hover. */
.card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;  /* evita conteudo (img, table interna) "estourar" os cantos do card */
  padding: 26px 28px;
  box-shadow: var(--shadow-card);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.card:hover { border-color: #3E3935; }

/* Sparkline de tendencia nos cards de Ads (Modulo 13). Cor semantica so' no
   chip de tendencia (variacao) — segue a regra de KPI neutro. */
.ad-spark { display: flex; align-items: center; gap: 8px; margin-top: 10px; min-height: 22px; flex-wrap: wrap; }
.ad-spark .spark { flex: 0 0 auto; display: block; }
.ad-spark .spark-label { font-size: 10px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.04em; }
.ad-spark .spark-tend { font-size: 11px; font-weight: 600; font-family: 'Geist Mono', monospace; white-space: nowrap; }
.ad-spark .spark-up { color: var(--success); }
.ad-spark .spark-down { color: var(--danger); }
.ad-spark .spark-cair { color: var(--warning); }
.ad-spark .spark-flat { color: var(--text-3); }
.ad-spark .spark-vazio { font-size: 11px; color: var(--text-3); font-style: italic; }

.kpi .rotulo {
  font-size: 12px; color: var(--text-2);
  font-weight: 500; text-transform: uppercase;
  letter-spacing: 0.05em; margin-bottom: 12px;
}
.kpi .valor {
  font-family: 'Plus Jakarta Sans', 'Inter', sans-serif;
  font-size: 30px; font-weight: 700;
  letter-spacing: -0.025em; line-height: 1.1;
  font-feature-settings: 'tnum';
}
/* KPI principal (Faturamento Bruto, valores em destaque) — peso máximo */
.kpi .valor.grande { font-size: 36px; font-weight: 800; letter-spacing: -0.03em; }
.kpi .valor.ambar { color: var(--ambar); }
.kpi .valor.teal { color: var(--teal); }
.kpi .valor.danger { color: var(--danger); }
.kpi .valor.warning { color: var(--warning); }
.kpi .valor.success { color: var(--success); }
.kpi .valor.muted { color: var(--text-3); font-weight: 500; }
.kpi .complemento {
  font-size: 12px; color: var(--text-2); margin-top: 6px;
  font-family: 'Geist Mono', monospace;
}

/* ===== GRID ===== */
.grid { display: grid; gap: 20px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .grid-4, .grid-3 { grid-template-columns: 1fr; }

  /* iOS Safari faz zoom-in quando font-size < 16px num input em foco.
   * Garante 16px global em todos os campos no mobile pra evitar isso
   * (mantém visual igual no desktop). `input` generico cobre tambem os
   * <input> SEM type (telas admin/diag) que os seletores [type] nao pegavam. */
  input,
  input[type="text"],
  input[type="search"],
  input[type="email"],
  input[type="password"],
  input[type="number"],
  input[type="tel"],
  input[type="url"],
  input[type="date"],
  input[type="time"],
  input[type="datetime-local"],
  select,
  textarea {
    font-size: 16px !important;
  }
}

/* Tap targets ≥44px em dispositivos touch (regra Apple HIG / Material).
 * Cobre botões pequenos espalhados pelo sistema sem precisar tocar
 * cada CSS local. Aplica só em pointer:coarse (touch real, não
 * desktop com mouse). */
@media (pointer: coarse) {
  .btn,
  button.btn-sm,
  .btn.btn-sm {
    min-height: 40px;
  }
  /* Botões só com ícone (sem texto) — quadrados ≥40px */
  .btn-icon,
  .btn-fechar {
    min-width: 40px;
    min-height: 40px;
  }
}

/* ===== TABELAS ===== */
.table-wrap {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
table.tabela {
  width: 100%; border-collapse: collapse;
  font-size: 14px;
  font-variant-numeric: tabular-nums; /* digitos de largura fixa: numeros alinhados na vertical (DRE/Margem/financeiro) */
}
table.tabela th {
  text-align: left; font-weight: 600;
  color: var(--text-2); font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.06em;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-3);
}
table.tabela td {
  padding: 14px;
  border-bottom: 1px solid var(--bg-3);
  vertical-align: middle;
}
table.tabela tr:last-child td { border-bottom: none; }
table.tabela tr.clicavel { cursor: pointer; transition: background 0.15s ease; }
table.tabela tr.clicavel:hover { background: var(--bg-3); }
/* SLA estourado / proximo do limite — usa 6% pra ficar sutil na linha,
 * 12% no hover (= var --danger-soft / --warning-soft). */
table.tabela tr.fora-sla { background: rgba(239, 68, 68, 0.06); }
table.tabela tr.fora-sla:hover { background: var(--danger-soft); }
table.tabela tr.vencida { background: rgba(245, 158, 11, 0.06); }
table.tabela tr.vencida:hover { background: var(--warning-soft); }

/* Afford. de clicabilidade global (auditoria 1.4 — antes nao havia regra
   global, entao elementos ad-hoc com onclick ficavam com cursor de texto).
   Estados :disabled tem specificity maior e seguem com cursor:not-allowed. */
[onclick],
[role="button"] {
  cursor: pointer;
}

/* ===== BOTOES ===== */
/* ============================================================================
 * BOTOES — design minimalista futurista (upgrade 24/05/2026)
 * Multi-layer shadows + inset highlight + ring sutil + spring easing.
 * Inspirado em Linear/Vercel: profundidade sem peso, foco com glow ambient.
 * ========================================================================= */
/* Refator 24/05/2026: simplificacao estilo Tiny — flat, compacto, sem
 * gradient nem glow forte. Glow continua so no :focus-visible (a11y). */
/* Refator 29/05/2026 (Thiago): "novo design de botões em todas as telas".
 * Pills estilo Tiny — cantos 999px, fundo translúcido com borda, e o anel
 * âmbar (--primary-ring) no hover/focus como assinatura visual. O primário
 * é o pill laranja preenchido. Mesma linguagem do toolbar de filtros (.flt-pill). */
.btn {
  background: transparent;
  color: var(--text);
  border: 1.5px solid var(--border);
  border-radius: 999px;
  padding: 8px 16px;
  cursor: pointer;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: -0.005em;
  transition:
    background 0.15s var(--ease-out),
    border-color 0.15s var(--ease-out),
    box-shadow 0.15s var(--ease-out),
    color 0.15s var(--ease-out);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  text-decoration: none;
  position: relative;
  white-space: nowrap;
}
.btn:hover {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-ring);
}
.btn:focus-visible {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-ring);
}
.btn:active {
  background: var(--bg-3);
}
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  background: transparent;
  box-shadow: none;
}

/* Primary — pill laranja preenchido. Texto escuro (contraste melhor que branco
 * sobre orange-500 — passa WCAG AA). Icones herdam a cor via currentColor. */
.btn-primary {
  background: var(--primary);
  color: var(--text-on-primary);
  border-color: var(--primary);
  font-weight: 700;
  letter-spacing: -0.008em;
}
.btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  box-shadow: 0 0 0 3px var(--primary-ring);
}
.btn-primary:active {
  background: var(--primary-hover);
  box-shadow: none;
}
/* Disabled: mantem o preenchimento laranja (so esmaecido pela opacity .45 do
 * .btn:disabled). Sem isso, o background:transparent do .btn:disabled deixava o
 * texto escuro invisivel no fundo escuro — virava uma pill vazia (ex: botao
 * "Sincronizando..." no Rastreamento). */
.btn-primary:disabled {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--text-on-primary);
}

/* Success — pill verde preenchido (mantém identidade semântica) */
.btn-success {
  background: var(--success);
  color: white;
  border-color: var(--success);
  font-weight: 700;
  letter-spacing: -0.008em;
}
.btn-success:hover {
  background: #1FAE52;  /* success um pouco mais escuro */
  border-color: #1FAE52;
  box-shadow: 0 0 0 3px var(--success-soft);
}
.btn-success:active { box-shadow: none; }

/* Danger — outline pill, fill no hover (anel vermelho, não âmbar) */
.btn-danger {
  background: transparent;
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.45);
}
.btn-danger:hover {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
  box-shadow: 0 0 0 3px var(--danger-soft);
}
.btn-danger:active { box-shadow: none; }

.btn-sm { padding: 5px 12px; font-size: 12px; border-radius: 999px; }

/* Botao so com icone (sem texto). Util pra fechar modal, acoes inline em
 * cards, headers compactos. Tap target >= 32px em desktop, 40px em mobile. */
.btn-icon {
  background: transparent;
  border: none;
  color: var(--text-3);
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
  font-family: inherit;
  font-size: 14px;
  line-height: 1;
  padding: 0;
  flex-shrink: 0;
}
.btn-icon:hover { background: var(--bg-3); color: var(--text); }
.btn-icon:disabled { opacity: 0.4; cursor: not-allowed; }

/* ===== TOPBAR DE AÇÕES (estilo Olist Tiny) =====
 * Toolbar fixa na parte superior da tela com:
 * - Filtros/selects à esquerda (label inline compacto)
 * - Botão de ação primário (laranja) destacado
 * - Botões secundários como outline
 * - "⋯ Mais ações" dropdown agrupando acoes secundarias raras
 *
 * Uso:
 *   <div class="topbar-acoes">
 *     <div class="topbar-grupo">
 *       <label class="topbar-label">Empresa</label>
 *       <select>...</select>
 *     </div>
 *     <!-- Botoes secundarios agora vao em renderHeader.acoesHtml
 *          (padrao Tiny). Linha .topbar-acoes fica so com filtros. -->
 *   </div>
 */
.topbar-acoes {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.topbar-grupo {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.topbar-label {
  font-size: 11px;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}
.topbar-acoes select,
.topbar-acoes input {
  background: var(--bg);
  border: 1.5px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  min-height: 38px;
  transition: border-color 0.15s var(--ease-out), box-shadow 0.15s var(--ease-out);
}
/* Anel âmbar no foco — assinatura do novo design (igual .flt-ctrl) */
.topbar-acoes select:focus,
.topbar-acoes select:focus-visible,
.topbar-acoes input:focus,
.topbar-acoes input:focus-visible {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-ring);
}
/* Chevron custom no select (remove a setinha nativa feia) */
.topbar-acoes select {
  appearance: none; -webkit-appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='20' height='20' fill='none' stroke='%239CA3AF' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat; background-position: right 10px center; padding-right: 34px;
}
.topbar-acoes .btn {
  min-height: 38px;
  padding: 8px 16px;
  font-size: 13px;
}
/* =====================================================================
 * TOOLBAR DE FILTROS ESTILO TINY (.flt-*) — componente reutilizável.
 * Movido do pedidos.html pro global em 29/05/2026 ("novo design de botões
 * em todas as telas"). Busca grande + pills arredondadas + painel de filtros
 * que, no mobile, mantém os filtros escondidos atrás da pill "Filtros"
 * (sobra mais tela útil). Use junto com iniciarFiltrosColapsaveis() do shared.js.
 *
 * Estrutura:
 *   <div class="flt-toolbar">
 *     <div class="flt-busca"><span class="flt-busca-ico">{icon}</span><input ...></div>
 *     <div id="periodo"></div>                        <!-- opcional -->
 *     <button class="flt-pill" id="btnFiltros">{icon} Filtros <span class="flt-pill-badge" hidden>0</span></button>
 *     <button class="flt-pill flt-pill-texto" id="btnLimpar">Limpar</button>
 *     <div class="flt-painel" id="painel" hidden> ...campos... </div>
 *     <button class="flt-pill flt-pill-primary">{icon} Ação</button>
 *   </div>
 * ===================================================================== */
.flt-toolbar {
  position: relative;
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.flt-busca {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1 1 320px;
  min-width: 220px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 11px 16px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.flt-busca:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); }
.flt-busca input {
  flex: 1; min-width: 0;
  background: transparent; border: 0; outline: none;
  color: var(--text); font-family: inherit; font-size: 15px;
}
.flt-busca input::placeholder { color: var(--text-3); }
.flt-busca .flt-busca-ico { color: var(--text-3); display: inline-flex; flex-shrink: 0; }
.flt-busca .flt-busca-ico svg { width: 18px; height: 18px; }

/* Pills arredondadas (botões + filtros) */
.flt-pill {
  display: inline-flex; align-items: center; gap: 8px;
  border-radius: 999px;
  padding: 9px 18px;
  font-size: 14px; font-weight: 600; font-family: inherit;
  cursor: pointer;
  background: transparent; border: 1.5px solid var(--border); color: var(--text);
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease, color .15s ease;
  white-space: nowrap;
}
.flt-pill svg { width: 16px; height: 16px; }
.flt-pill .ic { display: inline-flex; }
.flt-pill .ic svg { width: 16px; height: 16px; }
.flt-pill:hover { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); }
.flt-pill:focus-visible { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); }
.flt-pill-primary { background: var(--primary); color: var(--text-on-primary); border-color: var(--primary); }
.flt-pill-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); box-shadow: 0 0 0 3px var(--primary-ring); }
.flt-pill-primary .ic, .flt-pill-primary svg { color: var(--text-on-primary); }
.flt-pill.flt-pill-ativo,
.flt-pill.aberto { color: var(--primary); border-color: var(--primary); }
.flt-pill-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 19px; height: 19px; padding: 0 6px;
  border-radius: 999px;
  background: var(--primary); color: var(--text-on-primary);
  font-size: 11px; font-weight: 800; line-height: 1;
}
.flt-pill-texto {
  display: inline-flex; align-items: center; gap: 7px;
  border: 0; border-radius: 999px;
  padding: 9px 12px;
  font-size: 14px; font-weight: 600; font-family: inherit;
  cursor: pointer;
  background: transparent; color: var(--text-3);
  transition: color .15s ease, background .15s ease;
  white-space: nowrap;
}
.flt-pill-texto svg { width: 16px; height: 16px; }
.flt-pill-texto:hover { color: var(--text); background: var(--bg-3); }
.flt-pill .flt-dots {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 999px;
  background: var(--primary); color: var(--text-on-primary);
  margin-left: 2px;
}
.flt-pill .flt-dots svg { width: 13px; height: 13px; }

/* Painel de filtros (dropdown ancorado sob a pill "filtros").
 * PADRAO REFINADO (01/06/2026) — cabecalho + corpo + rodape. Cada tela monta:
 *   <div class="flt-painel flt-painel-dir" id="painel" hidden>
 *     <div class="flt-painel-cab">
 *       <span class="flt-painel-titulo">Filtros</span>
 *       <button class="flt-limpar" id="btnLimpar">Limpar</button>
 *     </div>
 *     <div class="flt-painel-corpo"> ...flt-campo... </div>
 *     <div class="flt-painel-rodape">
 *       <button class="flt-pill flt-pill-primary">aplicar filtros</button>
 *     </div>
 *   </div>
 * Use .flt-painel-dir quando a pill fica na DIREITA da toolbar (ancora a direita).
 */
.flt-painel {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 120;
  width: 320px; max-width: calc(100vw - 32px);
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 30px -8px rgba(0,0,0,0.45);
  padding: 0; overflow: hidden;
}
.flt-painel[hidden] { display: none; }
.flt-painel-dir { left: auto; right: 0; }
.flt-painel-cab {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 16px; border-bottom: 1px solid var(--border);
}
.flt-painel-titulo { font-size: 13px; font-weight: 700; color: var(--text); }
.flt-limpar {
  background: transparent; border: 0; cursor: pointer; font-family: inherit;
  font-size: 12px; font-weight: 600; color: var(--text-3);
  padding: 3px 5px; border-radius: 6px; transition: color .15s ease;
}
.flt-limpar:hover { color: var(--text); }
.flt-painel-corpo { padding: 15px 16px; }
.flt-painel-rodape { padding: 13px 16px; border-top: 1px solid var(--border); }
.flt-painel-rodape .flt-pill-primary { width: 100%; justify-content: center; border-radius: var(--radius-sm); }
.flt-campo { margin-bottom: 13px; }
.flt-campo:last-child { margin-bottom: 0; }
.flt-campo > label {
  display: block; font-size: 12px; color: var(--text-3); margin-bottom: 6px;
}
.flt-ctrl {
  width: 100%;
  background: var(--bg-3); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px 13px;
  color: var(--text); font-size: 14px; font-weight: 500; font-family: inherit;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.flt-ctrl:focus, .flt-ctrl:focus-visible {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring);
}
select.flt-ctrl {
  appearance: none; -webkit-appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='20' height='20' fill='none' stroke='%239CA3AF' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 40px;
}
/* Controle segmentado (chips) — alternativa ao <select> pra poucas opcoes.
   Os chips quebram linha automaticamente. Marca a opcao ativa com .on.
   Padrao: usar como "pele" visual sobre um <select hidden> pra nao reescrever
   o JS que le o .value. */
.flt-seg { display: flex; flex-wrap: wrap; gap: 6px; }
.flt-seg-op {
  flex: 1 1 auto; text-align: center; padding: 8px 12px; border-radius: 7px;
  font-size: 12.5px; font-weight: 600; font-family: inherit; cursor: pointer;
  background: var(--bg-3); border: 1px solid var(--border); color: var(--text-3);
  transition: border-color .15s ease, color .15s ease, background .15s ease;
  white-space: nowrap;
}
.flt-seg-op:hover { color: var(--text); }
.flt-seg-op.on { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }
/* Compat: barra de acoes antiga (sem rodape). Telas novas usam .flt-painel-rodape. */
.flt-painel-acoes {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 16px; border-top: 1px solid var(--border);
}
/* Pills de ação no header (Atualizar / Mais ações) — compactas pro ritmo do header */
header.topbar .topbar-acoes-header .flt-pill { padding: 8px 16px; font-size: 13px; }
header.topbar .topbar-acoes-header .flt-pill .flt-dots { width: 20px; height: 20px; }

/* Toggle "Filtros" injetado por colapsarFiltrosMobile() — só aparece no mobile
   (regra mobile fica no @media max-width:700px). No desktop fica escondido. */
.filtros-toggle-mobile { display: none; }
/* Badge com a contagem de filtros ativos dentro da pill "Filtros" (opcional) */
.filtros-toggle-mobile .flt-pill-count {
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 700;
  line-height: 1.6;
}
.filtros-toggle-mobile .flt-pill-count[hidden] { display: none; }

/* .topbar-acoes-direita removida em 25/05/2026 — auditoria revelou zero uso.
   Botoes secundarios agora ficam em renderHeader.acoesHtml (padrao Tiny). */
.topbar-info {
  font-size: 11px;
  color: var(--text-3);
  margin-left: 4px;
}

/* Dropdown "⋯ Mais ações" — reutilizável em qualquer toolbar */
.mais-acoes {
  position: relative;
  display: inline-block;
}
.mais-acoes-trigger {
  background: var(--bg-3);
  border: 1px solid var(--border);
  color: var(--text-2);
  padding: 7px 12px;
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  transition: all 0.15s;
}
.mais-acoes-trigger:hover {
  background: var(--bg-2);
  border-color: var(--ambar);
  color: var(--ambar);
}
.mais-acoes-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  min-width: 240px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  padding: 6px;
  z-index: 100;
  /* abre/fecha com fade + slide suave — a classe .aberto e togglada via JS.
     visibility na transition mantem visivel durante o fade-out. */
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  pointer-events: none;
  transition: opacity 0.15s var(--ease-out), transform 0.15s var(--ease-out), visibility 0.15s;
}
.mais-acoes-menu.aberto {
  opacity: 1;
  visibility: visible;
  transform: none;
  pointer-events: auto;
}
.mais-acoes-menu a,
.mais-acoes-menu button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
  text-align: left;
  white-space: nowrap;
}
.mais-acoes-menu a:hover,
.mais-acoes-menu button:hover {
  background: rgba(239, 173, 85, 0.10);
  color: var(--ambar);
}
.mais-acoes-menu .divisor { height: 1px; background: var(--border); margin: 4px 0; }
.mais-acoes-menu .grupo-titulo {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-3);
  padding: 6px 12px 2px;
  font-weight: 700;
}

@media (max-width: 700px) {
  .topbar-acoes { padding: 10px; gap: 8px; }
  .topbar-acoes select, .topbar-acoes input { font-size: 16px; min-height: 44px; }
  .topbar-acoes .btn, .mais-acoes-trigger { min-height: 44px; font-size: 14px; }
  .mais-acoes-menu { right: auto; left: 0; min-width: 220px; }

  /* Toolbar de filtros estilo Tiny no mobile: busca ocupa a linha inteira,
     pills com tap target ≥44px, painel vira full-width. Os filtros ficam
     escondidos atrás da pill "Filtros" (sobra mais tela útil). */
  .flt-toolbar { gap: 10px; }
  .flt-busca { flex: 1 1 100%; }
  .flt-busca input { font-size: 16px; } /* ≥16px evita zoom no iOS */
  .flt-pill, .flt-pill-texto { min-height: 44px; }
  .flt-ctrl { min-height: 44px; font-size: 16px; }
  .flt-painel { width: 100%; left: 0; right: 0; max-width: 100%; }

  /* Esconde no mobile o que for marcado como "só desktop" (ações de admin/diag) */
  [data-mobile-hide] { display: none !important; }

  /* colapsarFiltrosMobile(): no mobile a barra de filtros some por padrão
     (sobra mais tela útil) e a pill "Filtros" mostra/esconde. O :not(.aberto)
     preserva o display natural da barra (flex/grid/block) quando abre — sem
     precisar saber o tipo de display de cada tela. */
  .filtros-toggle-mobile { display: inline-flex; margin-bottom: 12px; }
  .filtros-colapsavel:not(.filtros-aberto) { display: none !important; }
}

/* ===== FORMS ===== */
.campo {
  display: flex; flex-direction: column; gap: 6px;
  margin-bottom: 14px;
}
.campo label {
  font-size: 11px; color: var(--text-2);
  font-weight: 500; text-transform: uppercase;
  letter-spacing: 0.04em;
}
.campo label .obrigatorio { color: var(--danger); }
.campo input, .campo select, .campo textarea {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  transition: border-color 0.15s;
  width: 100%;
}
.campo input:focus, .campo select:focus, .campo textarea:focus {
  outline: none;
  border-color: var(--ambar);
  box-shadow: 0 0 0 3px var(--primary-ring);
}
.campo textarea { resize: vertical; min-height: 80px; }
.campo input[type="file"] {
  padding: 8px;
  cursor: pointer;
}

.linha-campos {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

/* ===== BADGES ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  font-size: 10.5px;
  font-weight: 600;
  border-radius: 99px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.badge.aberta { background: var(--warning-soft); color: var(--warning); }
.badge.em_andamento { background: var(--purple-soft); color: #C4B5FD; }
.badge.fechada, .badge.concluida { background: var(--success-soft); color: var(--success); }
.badge.fora-sla { background: var(--danger-soft); color: var(--danger); margin-left: 6px; }
.badge.vencida { background: var(--warning-soft); color: var(--warning); margin-left: 6px; }
.badge.canal-mercado_livre { background: rgba(255, 230, 0, 0.12); color: #FDE047; }
.badge.canal-shopee { background: rgba(238, 77, 45, 0.18); color: #FB923C; }
/* .badge.canal-whatsapp removida: zero uso (canal WhatsApp usa .badge generico) */

/* ===== PAINEL DE ALERTA ===== */
.painel-alerta {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 20px;
  background: var(--danger-soft);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius);
  margin-bottom: 16px;
}
.painel-alerta.ok {
  background: var(--success-soft);
  border-color: rgba(34, 197, 94, 0.3);
}
.painel-alerta .icone { font-size: 24px; line-height: 1; }
.painel-alerta .texto-principal {
  font-size: 17px; font-weight: 600;
}
.painel-alerta.ok .texto-principal { color: var(--success); }
.painel-alerta:not(.ok) .texto-principal { color: var(--danger); }
.painel-alerta .descricao {
  font-size: 13px; color: var(--text-2); margin-top: 2px;
}

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(10, 8, 6, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: none;
  align-items: flex-start;
  justify-content: center;
  z-index: 200;  /* acima da sidebar (100 desktop, 110 mobile drawer) */
  padding: 32px 24px;
  overflow-y: auto;
}
.modal-overlay.aberto {
  display: flex;
  animation: overlayFadeIn 0.18s ease-out;
}
.modal {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  max-width: 720px;
  width: 100%;
  margin: auto;
  box-shadow: 0 24px 80px rgba(0,0,0,0.6), 0 0 0 1px rgba(255,255,255,0.02);
  animation: modalSlideUp 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes overlayFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes modalSlideUp {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.modal.large { max-width: 900px; }
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
}
.modal-header h2 {
  font-size: 17px; font-weight: 600;
}
.modal-header .btn-fechar,
.modal-header .btn-icon {
  background: transparent;
  border: none;
  color: var(--text-3);
  font-size: 24px;
  cursor: pointer;
  line-height: 1;
  width: 32px; height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
}
.modal-header .btn-fechar:hover,
.modal-header .btn-icon:hover { color: var(--text); background: var(--bg-3); }
.modal-body { padding: 20px 24px; }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
}

/* ===== FILTROS ===== */
.filtros-linha {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: flex-end;
  margin-bottom: 16px;
  padding: 14px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.filtros-linha .filtro {
  display: flex; flex-direction: column; gap: 4px;
  /* min-width no container (nao so no input) impede label cortado quando
     muitos filtros estao na linha. flex-shrink: 0 garante que o item nao
     encolhe abaixo do minimo — em vez disso, quebra pra proxima linha. */
  min-width: 130px;
  flex: 0 1 auto;
}
/* Filtro Buscar pedido: cresce e ocupa espaco sobrante. flex-grow 2 faz
   ele crescer 2x mais que os outros quando ha espaco extra na linha. */
.filtros-linha .filtro-busca {
  flex: 2 1 180px;
  min-width: 180px;
}
.filtros-linha .filtro label {
  font-size: 10px; color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.05em;
  white-space: nowrap;
}
.filtros-linha .filtro select,
.filtros-linha .filtro input[type="text"] {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  width: 100%;          /* preenche o container do .filtro */
  min-width: 0;         /* permite input encolher se necessario */
  transition: border-color 0.18s ease;
}
.filtros-linha .filtro select:focus,
.filtros-linha .filtro input:focus {
  outline: none;
  border-color: var(--ambar);
  box-shadow: 0 0 0 3px var(--primary-ring);
}

/* ===== DETALHE GRUPOS ===== */
.detalhe-grupo {
  margin-bottom: 18px;
}
.detalhe-grupo h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
  margin-bottom: 8px;
  font-weight: 600;
}
.detalhe-info {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px 24px;
}
.detalhe-info .item label {
  display: block;
  font-size: 11px;
  color: var(--text-3);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.detalhe-info .item .valor {
  font-size: 14px;
  color: var(--text);
}
.detalhe-info .item.full {
  grid-column: 1 / -1;
}

/* ===== LISTA OCORRENCIAS NO DETALHE ===== */
.lista-ocorrencias .item {
  padding: 12px 14px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 8px;
  font-size: 13px;
}
.lista-ocorrencias .item .titulo {
  font-weight: 600;
  margin-bottom: 4px;
}
.lista-ocorrencias .item .meta {
  font-size: 11px;
  color: var(--text-3);
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 4px;
}

/* ===== ANEXOS ===== */
.lista-anexos {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.lista-anexos .anexo {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.1s;
  text-decoration: none;
  color: var(--text);
}
.lista-anexos .anexo:hover {
  border-color: var(--ambar);
  color: var(--ambar);
}

/* ===== CHARTS ===== */
.chart-wrap { position: relative; height: 280px; }
.chart-wrap.mini { height: 220px; }

/* ===== MENSAGENS ===== */
.placeholder-text {
  color: var(--text-3);
  font-style: italic;
  font-size: 13px;
  text-align: center;
  padding: 32px;
}
.erro-banner {
  padding: 12px 16px;
  background: var(--danger-soft);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #FCA5A5;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 16px;
}
.aviso-banner {
  padding: 12px 16px;
  background: var(--ambar-soft);
  border: 1px solid rgba(245, 166, 35, 0.3);
  color: var(--ambar);
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 16px;
}

/* ===== ICONES (lucide inline SVG) ===== */
.ic {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.ic svg {
  width: 1em;
  height: 1em;
  stroke-width: 2;  /* base — sobrescrito por tamanho abaixo */
}
.ic-sm svg { width: 14px; height: 14px; }  /* stroke-width 2 (legibilidade em 14px) */
/* Fase 1 (31/05/2026): icones medios/grandes com 1.6 — visual refinado
   sem sacrificar legibilidade. Icones pequenos (.ic-sm, .btn) ficam em 2/1.9
   porque em 14px a linha fina fica sutil demais. */
.ic-md svg { width: 16px; height: 16px; stroke-width: 1.6; }
.ic-lg svg { width: 20px; height: 20px; stroke-width: 1.6; }
.ic-xl svg { width: 26px; height: 26px; stroke-width: 1.6; }

/* Padrao 24/05/2026 (Thiago): chrome (botoes topbar/header) usa SVG
 * branco/laranja em vez de emoji. SVG herda cor via currentColor:
 *   - .btn default → texto branco → icone branco
 *   - .btn-primary → texto white → icone white
 *   - .btn link com cor laranja → icone laranja
 * Tamanho padrao dentro de .btn é 14px (proporcional ao font 13.5px).
 * Margem direita pequena pra separar do texto. */
.btn .ic svg,
.btn-sair .ic svg,
.mais-acoes-trigger .ic svg {
  width: 14px;
  height: 14px;
  stroke-width: 1.9;  /* Fase 1: levemente mais fino que 2, legivel em 14px */
}
.btn-sm .ic svg { width: 12px; height: 12px; }

/* ===== TOAST ===== */
#toast-stack {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 360px;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 16px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--ambar);
  border-radius: 10px;
  font-size: 14px;
  color: var(--text);
  box-shadow: 0 12px 32px rgba(0,0,0,0.4);
  animation: toastIn 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.toast.saindo { animation: toastOut 0.2s ease-in forwards; }
.toast.success { border-left-color: var(--success); }
.toast.success .ic { color: var(--success); }
.toast.danger { border-left-color: var(--danger); }
.toast.danger .ic { color: var(--danger); }
.toast.info .ic { color: var(--ambar); }
.toast.warning { border-left-color: var(--warning); }
.toast.warning .ic { color: var(--warning); }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes toastOut {
  to { opacity: 0; transform: translateX(20px); }
}

/* ===== TRANSICAO PADRAO DE MOSTRAR/ESCONDER (toggleSuave) =====
 * Padrao UNICO do sistema pra reveal/popover/accordion/aba. O elemento
 * comeca com `hidden` (fica fora do layout) + classe `fx-suave`. O helper
 * toggleSuave(el, mostrar) em shared.js tira o hidden, forca reflow e poe
 * `fx-aberto` (fade+slide de entrada); ao esconder, tira `fx-aberto` e, no
 * fim da transicao, recoloca `hidden`. Mesma suavidade em TODA tela. */
.fx-suave {
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.16s var(--ease-out), transform 0.16s var(--ease-out);
}
.fx-suave.fx-aberto { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  .fx-suave { transition: none; }
}

/* ===== HELPERS ===== */
.text-mono { font-family: 'Geist Mono', monospace; font-feature-settings: 'tnum'; }
.text-muted { color: var(--text-2); }
.text-dim { color: var(--text-3); }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-end { display: flex; justify-content: flex-end; gap: 8px; }
.flex-center { display: flex; align-items: center; gap: 8px; }
.gap-8 { gap: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.ml-auto { margin-left: auto; }

/* Mostra so no mobile (texto extra que substitui icones quando vira card) */
.mobile-only { display: none; }
@media (max-width: 768px) {
  .mobile-only { display: inline; }
}

/* ===== SKELETON ===== */
.skeleton {
  display: inline-block;
  background: linear-gradient(90deg, var(--bg-3) 0%, var(--border) 50%, var(--bg-3) 100%);
  background-size: 200% 100%;
  border-radius: 4px;
  animation: shimmer 1.4s ease-in-out infinite;
  color: transparent;
  user-select: none;
  pointer-events: none;
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ===== ESTADO VAZIO ===== */
.estado-vazio {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 48px 24px;
  color: var(--text-3);
  text-align: center;
}
.estado-vazio .ic { color: var(--text-3); opacity: 0.5; margin-bottom: 4px; }
.estado-vazio strong { font-size: 15px; color: var(--text-2); font-weight: 500; }
.estado-vazio span { font-size: 13px; }

/* ===== ANIMACAO DE ENTRADA ===== */
/* Rows de tabela surgem suavemente ao ser inseridas no DOM */
@keyframes rowEntrar {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
table.tabela tbody tr { animation: rowEntrar 0.18s ease-out both; }
@media (prefers-reduced-motion: reduce) {
  table.tabela tbody tr { animation: none; }
}

/* ============================================================================
 * APP SHELL — sidebar lateral fixa (desktop) + drawer slide-in (mobile)
 * Layout estilo Linear/Notion/Tiny: sidebar a esquerda, topbar compacto, main.
 * ============================================================================ */

.app-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
  min-height: 100dvh;  /* desconta teclado/barras moveis em tablet/mobile */
  /* Recolher/expandir suave: anima a largura da coluna do menu. Navegadores
     atuais interpolam grid-template-columns liso. O conteudo (1fr) desliza
     junto. Desabilitado se o usuario pediu menos movimento (media abaixo). */
  transition: grid-template-columns 0.26s var(--ease-out);
}
@media (prefers-reduced-motion: reduce) {
  .app-shell { transition: none; }
}
/* Sidebar colapsada (so icones) — toggle via botao na topbar */
.app-shell.sidebar-colapsada { grid-template-columns: 64px 1fr; }

/* SIDEBAR — coluna esquerda fixa.
   Background warm gray escuro mas nao preto (estilo Olist Tiny — clean).
   IMPORTANTE: NAO usar contain/transform aqui — eles criam containing block
   pra position: fixed dos descendentes (flyout). O flyout precisa se
   posicionar relativo a viewport, nao a sidebar. */
aside.sidebar {
  background: var(--sidebar-bg);  /* warm gray escuro, nao preto puro */
  border-right: 1px solid var(--border-hairline);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;                  /* desconta teclado/barras moveis */
  overflow-y: auto;
  overflow-x: visible;             /* permite flyout vazar pra direita */
  z-index: 100;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px;
  min-height: 76px;   /* casa com header.topbar pra a linha do topo alinhar */
  /* mesma cor da borda do header pra a linha do topo ser continua */
  border-bottom: 1px solid var(--border);
  color: inherit;
}
/* Logo e marca estatica (nao e link) — sem hover, sem clique. O destino
 * "Inicio" era inutil (cada um vai pra sua home pelo menu mesmo). */
/* Simbolo (sacola laranja) — laranja puro, funciona em qualquer fundo */
.sidebar-brand-simbolo {
  width: 40px;
  height: 40px;
  object-fit: contain;
  flex-shrink: 0;
}
/* Texto montado via CSS pra controlar as cores no fundo escuro */
.sidebar-brand-texto {
  display: inline-flex;
  align-items: baseline;
  font-family: 'Plus Jakarta Sans', 'Inter', sans-serif;
  font-weight: 800;
  font-size: 22px;
  letter-spacing: -0.02em;
  line-height: 1;
  white-space: nowrap;
}
.sidebar-brand-texto .sb-ambar { color: var(--ambar); }
.sidebar-brand-texto .sb-shop { color: var(--text); margin-left: 1px; }

/* Sidebar colapsada: esconde o texto, simbolo continua sozinho centralizado */
.app-shell.sidebar-colapsada .sidebar-brand { padding: 14px 8px; gap: 0; }
.app-shell.sidebar-colapsada .sidebar-brand-texto { display: none; }
.app-shell.sidebar-colapsada .sidebar-brand-simbolo { width: 36px; height: 36px; }

.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}
/* Divisor entre a navegacao de negocio e os grupos de rodape (Ajuda/Configuracoes) */
.sidebar-nav-sep {
  height: 1px;
  background: var(--border);
  margin: 8px 6px;
  flex-shrink: 0;
}

/* === GRUPOS COLAPSAVEIS DO MENU === */
.nav-grupo {
  display: flex;
  flex-direction: column;
}
.nav-grupo-solto {
  /* Dashboard sozinho — sem header, sem indentacao extra */
  margin-bottom: 6px;
}
.nav-grupo:not(.nav-grupo-solto) {
  margin-top: 10px;
}
.nav-grupo:not(.nav-grupo-solto):first-child {
  margin-top: 0;
}
/* Header de grupo — estilo Tiny: texto branco normal, lowercase, sem caps.
   Quando hovered ou flyout aberto, vira card elevated escuro. */
.nav-grupo-header {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  background: transparent;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;          /* sem CAPS — visual mais leve, igual Tiny */
  color: var(--sidebar-text);    /* branco quente */
  border-radius: 10px;
  transition: color 0.15s, background 0.15s;
}
.nav-grupo-header:hover {
  background: rgba(255, 255, 255, 0.04);
  color: #fff;
}
/* Estado "ativo" — header elevated quando flyout aberto OU eh o grupo da tela atual */
.nav-grupo.flyout-aberto .nav-grupo-header,
.nav-grupo.tem-ativo .nav-grupo-header {
  background: var(--bg);         /* card elevated visivel — usa --bg pra tokenizar */
  color: var(--ambar);
  position: relative;
  z-index: 1501;
}
.nav-grupo.flyout-aberto .nav-grupo-header {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}
/* Bolinha indicadora (estilo Tiny) — pequeno ponto laranja no header
   do grupo que contem a tela ativa. Visivel em ambos modos (expandido/colapsado) */
.nav-grupo.tem-ativo .nav-grupo-header::after {
  content: '';
  position: absolute;
  width: 6px; height: 6px;
  border-radius: 99px;
  background: var(--ambar);
  box-shadow: 0 0 0 2px rgba(239, 173, 85, 0.25);
  top: 50%; right: 12px;
  transform: translateY(-50%);
}
/* Quando flyout esta aberto, esconde a bolinha (ja tem o destaque do card) */
.nav-grupo.flyout-aberto .nav-grupo-header::after {
  display: none;
}
/* Tambem esconde quando ha badge urgente (vermelho) — evita sobreposicao
 * com a bolinha laranja indicadora. O destaque visual do item ativo dentro
 * do flyout ja informa qual eh a tela atual. */
.nav-grupo.tem-ativo:has(.nav-grupo-badge-urgente) .nav-grupo-header::after {
  display: none;
}
/* No modo colapsado, bolinha vai pro canto superior esquerdo do icone */
.app-shell.sidebar-colapsada .nav-grupo.tem-ativo .nav-grupo-header::after {
  top: 4px; right: auto; left: 4px;
  transform: none;
}
/* Mesma bolinha pro Dashboard (item solto) quando eh a tela ativa */
.nav-grupo-solto a.ativo::after {
  content: '';
  position: absolute;
  width: 6px; height: 6px;
  border-radius: 99px;
  background: var(--ambar);
  box-shadow: 0 0 0 2px rgba(239, 173, 85, 0.25);
  top: 50%; right: 12px;
  transform: translateY(-50%);
}
.app-shell.sidebar-colapsada .nav-grupo-solto a.ativo::after {
  top: 4px; right: auto; left: 4px;
  transform: none;
}
.nav-grupo-header .ic { color: inherit; flex-shrink: 0; }
.nav-grupo-label { flex: 1; text-align: left; }
/* Chevron removido — visual mais limpo. Hover ja indica clickable. */
/* Badge urgente no header quando grupo esta colapsado — avisa que tem alerta.
 * Circular (pill) com tamanho minimo pra centralizar o numero. Sem margin
 * negativa (evita sobrepor o icone do grupo). */
.nav-grupo-badge-urgente {
  display: none;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  border-radius: 100px;
  letter-spacing: 0;
  text-transform: none;
  line-height: 1;
  flex-shrink: 0;
  animation: nav-badge-pulse 1.6s ease-in-out infinite;
}
.nav-grupo.colapsado .nav-grupo-badge-urgente {
  display: inline-flex;
}
/* Estrategia Tiny: flyout ja renderizado dentro de cada .nav-grupo,
   escondido por default via visibility/opacity (NAO display: none —
   permite transition suave). Hover/click adiciona .flyout-aberto no
   .nav-grupo pai pra mostrar. Zero criacao/destruicao de DOM. */
/* Sidebar colapsada (so icones) — TODOS botoes 44x44 centralizados.
   Dashboard + headers de grupo + items soltos = mesmo tamanho. */
.app-shell.sidebar-colapsada .sidebar-nav {
  padding: 12px 0;
  align-items: center;
}
.app-shell.sidebar-colapsada .nav-grupo {
  width: 100%;
  display: flex;
  justify-content: center;
  margin: 0;
}
.app-shell.sidebar-colapsada .nav-grupo-solto {
  margin: 0 0 4px;
}
/* Botoes identicos: 44x44, padding 0, centralizados via margin auto.
   contain: layout style paint isola repaint de cada botao individualmente. */
/* So botoes DIRETOS da sidebar (header de grupo + Dashboard solto) ficam 44x44.
   Items DENTRO do flyout mantem seu tamanho normal (com label e tudo). */
.app-shell.sidebar-colapsada .nav-grupo-header,
.app-shell.sidebar-colapsada .nav-grupo-solto > a {
  width: 44px;
  height: 44px;
  padding: 0;
  margin: 3px auto;
  gap: 0;
  justify-content: center;
  align-items: center;
  display: flex;
  position: relative;
  flex-shrink: 0;
  border-radius: 8px;
  box-sizing: border-box;
  will-change: background-color;
}
/* Icone do botao colapsado: centralizado, sem margin */
.app-shell.sidebar-colapsada .nav-grupo-header > .ic,
.app-shell.sidebar-colapsada .nav-grupo-solto > a > .ic {
  margin: 0 !important;
  flex: 0 0 auto;
}
/* Icone 20px no modo colapsado — stroke 1.6 (Fase 1: refinado igual .ic-lg) */
.app-shell.sidebar-colapsada .nav-grupo-header .ic svg,
.app-shell.sidebar-colapsada .nav-grupo-solto a .ic svg,
.app-shell.sidebar-colapsada .sidebar-nav a .ic svg {
  width: 20px; height: 20px; stroke-width: 1.6;
}
.app-shell.sidebar-colapsada .nav-grupo-label {
  display: none;
}
/* Item ativo: SEM barra lateral (a bolinha ja indica). Mantem fundo destacado */
.app-shell.sidebar-colapsada .sidebar-nav a.ativo::before {
  display: none;
}
/* Badge urgente pequeno no canto superior direito do icone */
.app-shell.sidebar-colapsada .nav-grupo-badge-urgente {
  position: absolute;
  top: -2px; right: -2px;
  min-width: 18px; height: 18px;
  font-size: 10px;
  font-weight: 700;
  padding: 0 5px;
  margin: 0;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 99px;
  border: 2px solid var(--sidebar-bg);  /* borda casa com o fundo da sidebar */
}
/* Lista interna do flyout — apenas o container dos links */
.nav-grupo-flyout-itens {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* === FLYOUT LATERAL (estilo Tiny — ja renderizado, toggle via class) ===
   Position fixed pra ficar a direita da sidebar.
   Default: invisivel (visibility hidden + opacity 0).
   Aberto: visible + opacity 1. Transition suave. Zero DOM thrashing. */
.nav-grupo {
  position: relative;
}
.nav-grupo-flyout {
  position: fixed;
  left: 240px;                       /* desktop expandido (240px sidebar) */
  top: 0;
  bottom: 0;
  width: 280px;
  background: var(--bg);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 8px 0 32px rgba(0, 0, 0, 0.5);
  padding: 24px 12px 16px;
  overflow-y: auto;
  z-index: 1500;
  display: none;     /* estilo Tiny: display none/block, sem opacity transition */
}
.nav-grupo.flyout-aberto .nav-grupo-flyout {
  display: block;
}
/* Quando sidebar colapsada (64px), flyout aparece mais a esquerda */
.app-shell.sidebar-colapsada .nav-grupo-flyout {
  left: 64px;
}
.nav-grupo-flyout-titulo {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: none;          /* sem CAPS no titulo do flyout */
  color: #8e8a85;
  padding: 4px 14px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  margin-bottom: 8px;
}
.nav-grupo-flyout a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: 8px;
  color: var(--sidebar-text);    /* branco quente igual headers */
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.12s, color 0.12s;
}
.nav-grupo-flyout a:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
}
.nav-grupo-flyout a.ativo {
  background: rgba(239, 173, 85, 0.14);
  color: var(--ambar);
  font-weight: 600;
}
.nav-grupo-flyout a .ic { flex-shrink: 0; color: inherit; }
.nav-grupo-flyout a .nav-badge { margin-left: auto; flex-shrink: 0; }
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 8px;
  color: var(--sidebar-text);      /* branco quente igual headers */
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
  position: relative;
}
.sidebar-nav a:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
}
.sidebar-nav a.ativo {
  background: rgba(239, 173, 85, 0.14);
  color: var(--ambar);
  font-weight: 600;
}
.sidebar-nav a.ativo::before {
  content: '';
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 2px;
  background: var(--ambar);
}
.sidebar-nav a .ic { color: inherit; flex-shrink: 0; }
.sidebar-nav a span:not(.nav-badge):not(.ic) { flex: 1; min-width: 0; }
.sidebar-nav a .nav-badge {
  margin-left: auto;
  flex-shrink: 0;
}

/* Toggle de recolher/expandir menu — area dedicada no rodape (igual Tiny) */
.sidebar-toggle-area {
  padding: 8px 10px;
  border-top: 1px solid var(--border-hairline);
}
.sidebar-toggle-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 14px;
  background: transparent;
  border: none;
  cursor: pointer;
  color: #8e8a85;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  border-radius: 8px;
  transition: background 0.15s, color 0.15s;
}
.sidebar-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--sidebar-text);
}
.sidebar-toggle-btn .ic { flex-shrink: 0; }
.sidebar-toggle-btn .ic-expandir,
.sidebar-toggle-btn .sidebar-toggle-label-expandir { display: none; }
.sidebar-colapsada .sidebar-toggle-btn .ic-recolher,
.sidebar-colapsada .sidebar-toggle-btn .sidebar-toggle-label-recolher { display: none; }
.sidebar-colapsada .sidebar-toggle-btn .ic-expandir,
.sidebar-colapsada .sidebar-toggle-btn .sidebar-toggle-label-expandir { display: inline-flex; }
/* Quando sidebar colapsada, esconde labels */
.sidebar-colapsada .sidebar-toggle-btn .sidebar-toggle-label-recolher,
.sidebar-colapsada .sidebar-toggle-btn .sidebar-toggle-label-expandir {
  display: none;
}
.sidebar-colapsada .sidebar-toggle-btn { justify-content: center; padding: 10px 0; }

.sidebar-rodape {
  padding: 12px 14px;
  border-top: 1px solid var(--border-hairline);
  display: flex;
  align-items: center;
  gap: 10px;
  background: transparent;       /* mesma cor da sidebar (continuum visual Tiny) */
  flex-shrink: 0;                /* nunca comprime — quem rola eh o .sidebar-nav */
  position: relative;            /* ancora o dropdown de pendencias */
}
/* Avatar com iniciais coloridas (estilo Tiny "ÂM" em circulo azul) */
.sidebar-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  color: #fff;
  flex-shrink: 0;
  letter-spacing: 0.02em;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}
.app-shell.sidebar-colapsada .sidebar-avatar {
  margin: 0 auto;
}
.app-shell.sidebar-colapsada .sidebar-rodape .user-info {
  display: none;
}
.sidebar-rodape .user-info {
  flex: 1;
  min-width: 0;
}
.sidebar-rodape .user-nome {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-rodape .user-role-pill {
  font-size: 9px;
  padding: 2px 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-2);
  margin-top: 2px;
  display: inline-block;
}
.sidebar-rodape .btn-sair {
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-2);
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
}
.sidebar-rodape .btn-sair:hover {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
  border-color: var(--danger);
}

/* Sino de pendencias no rodape (estilo Tiny — Thiago 28/05/2026) */
.sidebar-alertas-btn {
  position: relative;
  width: 40px; height: 40px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 6px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-2);
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
}
.sidebar-alertas-btn:hover {
  background: rgba(239, 173, 85, 0.1);
  color: var(--primary);
  border-color: var(--primary);
}
.sidebar-alertas-badge {
  position: absolute;
  top: -4px; right: -4px;
  min-width: 17px; height: 17px;
  padding: 0 4px;
  border-radius: 99px;
  background: #EF4444;
  color: #fff;
  font-size: 10px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  line-height: 1;
  box-shadow: 0 0 0 2px var(--sidebar-bg);  /* ring casa com fundo da sidebar */
}
/* Dropdown abre pra CIMA (rodape esta na base da tela) */
.sidebar-alertas-dropdown {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 12px; right: 12px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 -8px 28px rgba(0,0,0,0.4);
  padding: 6px;
  z-index: 200;
  max-height: 60vh;
  overflow-y: auto;
}
/* Quando colapsado, o dropdown vaza pra direita (rodape estreito 64px) */
.app-shell.sidebar-colapsada .sidebar-alertas-dropdown {
  left: calc(100% + 8px);
  right: auto;
  bottom: 8px;
  width: 280px;
}

/* ===== SIDEBAR COLAPSADA — variante so com icones =====
 * Estrategia: largura da sidebar anima via grid-template-columns no .app-shell.
 * Os LABELS (texto dos menus, marca, nome do user) tem opacity transition pra
 * fade-out/in sincronizado — em vez de display:none que daria flash.
 * Containers (brand, nav a, rodape) tambem animam padding pra acompanhar.
 */

/* Labels que aparecem/somem com a sidebar */
.sidebar-nav a span:not(.ic):not(.nav-badge),
.sidebar-rodape .user-info {
  white-space: nowrap;
  transition: opacity 0.15s ease-out;
}

/* Containers que mudam padding/justify quando colapsa */
.sidebar-brand,
.sidebar-rodape {
  transition: padding 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}
/* Regras de colapsado pro brand ficam consolidadas no bloco principal
 * (.sidebar-brand acima) — sem duplicacao. */
/* Esconde labels dos links DIRETOS da sidebar (Dashboard solto + items dentro
   do .nav-grupo-itens se houver), MAS NAO dos itens dentro do flyout — esses
   precisam mostrar o label completo no popover lateral. */
.app-shell.sidebar-colapsada .sidebar-nav > .nav-grupo > a span:not(.ic):not(.nav-badge),
.app-shell.sidebar-colapsada .nav-grupo-solto > a span:not(.ic):not(.nav-badge) {
  display: none;
}
/* Restaura labels dentro do flyout — eles devem aparecer mesmo com sidebar colapsada */
.app-shell.sidebar-colapsada .nav-grupo-flyout a span:not(.ic):not(.nav-badge) {
  display: inline !important;
}
/* Badge no canto do icone — APLICADO so nos links diretos da sidebar (Dashboard solto),
   NAO nos itens do flyout (la o badge fica inline normal) */
.app-shell.sidebar-colapsada .sidebar-nav > .nav-grupo > a .nav-badge,
.app-shell.sidebar-colapsada .nav-grupo-solto > a .nav-badge {
  position: absolute;
  top: 4px;
  right: 8px;
  min-width: 16px;
  height: 16px;
  font-size: 9px;
  padding: 0 4px;
  margin: 0;
}
/* Badge dentro do flyout volta ao tamanho normal */
.app-shell.sidebar-colapsada .nav-grupo-flyout a .nav-badge {
  position: static;
  margin-left: auto;
  min-width: 20px;
  height: 20px;
  font-size: 11px;
  padding: 0 6px;
}
/* Rodape colapsado: EMPILHA vertical (avatar + sino + sair). Antes ficavam
   lado a lado e nao cabiam nos 64px de largura (36+44 = 80px > 64) — por
   isso o avatar TS aparecia cortado na base. Empilhar resolve e "sobe o TS".
   Thiago 28/05/2026. */
.app-shell.sidebar-colapsada .sidebar-rodape {
  flex-direction: column;
  gap: 8px;
  padding: 10px 8px 14px;
  justify-content: center;
  align-items: center;
}
.app-shell.sidebar-colapsada .sidebar-rodape .user-info {
  display: none;          /* nome/role somem no colapsado */
}
.app-shell.sidebar-colapsada .sidebar-rodape .sidebar-avatar {
  order: -1;              /* avatar sempre no topo do empilhamento */
}
.app-shell.sidebar-colapsada .sidebar-rodape .btn-sair,
.app-shell.sidebar-colapsada .sidebar-rodape .sidebar-alertas-btn {
  width: 40px;
  height: 40px;
}

/* Botao de colapsar/expandir — so visivel no desktop (mobile usa drawer) */
header.topbar .collapse-toggle {
  display: none;
  width: 32px;
  height: 32px;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-2);
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
}
header.topbar .collapse-toggle:hover {
  color: var(--ambar);
  border-color: var(--ambar);
}
/* Alterna entre 2 icones: recolher (sidebar expandida) vs expandir (sidebar colapsada) */
header.topbar .collapse-toggle .ic-recolher,
header.topbar .collapse-toggle .ic-expandir { display: inline-flex; }
.app-shell.sidebar-colapsada .collapse-toggle .ic-recolher { display: none; }
.app-shell:not(.sidebar-colapsada) .collapse-toggle .ic-expandir { display: none; }
/* Botao collapse-toggle so faz sentido em desktop real (mouse + sidebar fixo).
   Em touch device o sidebar virou drawer (regra acima), entao o botao some. */
@media (min-width: 1025px) and (pointer: fine) {
  header.topbar .collapse-toggle { display: inline-flex; }
}

/* MAIN — coluna direita com topbar + conteudo */
.app-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100vh;
  min-height: 100dvh;  /* descontar teclado virtual em tablet/mobile */
}

header.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 28px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
  /* mesma altura do topo do sidebar pra a borda de baixo formar UMA linha
   * continua com a do logo — sem "dente" no canto. Casa com .sidebar-brand. */
  min-height: 76px;
}
header.topbar .menu-toggle {
  display: none;  /* visivel so em mobile */
  width: 38px;
  height: 38px;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
}
/* Container titulo + breadcrumb empilhados verticalmente */
header.topbar .topbar-titulo-wrap {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
/* Breadcrumb fino acima do titulo (estilo Tiny) */
.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-3);
  font-weight: 500;
  letter-spacing: 0.01em;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.breadcrumbs .bc-link {
  color: var(--text-3);
  text-decoration: none;
  transition: color 0.15s;
}
.breadcrumbs .bc-link:hover { color: var(--ambar); }
.breadcrumbs .bc-grupo { color: var(--text-3); }
.breadcrumbs .bc-atual { color: var(--text-2); font-weight: 600; }
.breadcrumbs .bc-sep {
  color: var(--text-3);
  opacity: 0.5;
  font-size: 10px;
}
/* Em telas muito estreitas, esconde breadcrumb pra dar espaco ao titulo */
@media (max-width: 640px) {
  .breadcrumbs { display: none; }
}

header.topbar h1 {
  font-family: var(--font-display);   /* serifada editorial (feel Claude) */
  font-size: 17px;
  font-weight: 500;
  letter-spacing: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  min-width: 0;        /* permite shrink */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
header.topbar h1 .ic { color: var(--ambar); flex-shrink: 0; }
header.topbar h1 span:not(.ic) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Titulos editoriais em serifada (feel premium estilo Claude). So' os titulos
   de conteudo; labels de UI (filtros, menus, badges) seguem em sans (Geist). */
.secao-titulo,
.ie-titulo,
.lista-titulo,
.bloco > h2,
.bloco > h3 {
  font-family: var(--font-display);
}
header.topbar .topbar-acoes {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Container de botões de ação no header (à direita do título).
 * Usado quando renderHeader recebe opts.acoesHtml — coloca Sincronizar +
 * Mais ações na mesma linha do título, sem precisar de toolbar separada
 * embaixo. Estilo Olist Tiny (compacto).
 *
 * Fica como irmão DEPOIS de .topbar-direita (que segura so o sino). Quem
 * empurra o conjunto sino+acoes pra direita no desktop eh o margin-left:auto
 * do .topbar-direita — por isso aqui o margin-left fica 0 (dois auto-margins
 * abririam um vao entre sino e botoes). No mobile (@768) vira linha cheia.
 */
header.topbar .topbar-acoes-header {
  margin-left: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
header.topbar .topbar-acoes-header .btn {
  min-height: 34px;
  padding: 6px 12px;
  font-size: 13px;
}
header.topbar .topbar-acoes-header select {
  background: var(--bg-3);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 10px;
  border-radius: 7px;
  font-family: inherit;
  font-size: 13px;
  min-height: 34px;
}
header.topbar .topbar-acoes-header .mais-acoes-trigger {
  min-height: 34px;
  padding: 6px 12px;
}

/* Botão "?" tooltip ao lado do título — abre popover com descrição da tela.
 * Substitui o parágrafo grande que ficava embaixo (estilo Tiny: clean). */
.topbar-help {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--bg-3);
  border: 1px solid var(--border);
  color: var(--text-3);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  margin-left: 6px;
  flex-shrink: 0;
  padding: 0;
  transition: all 0.15s;
}
.topbar-help:hover {
  background: rgba(239, 173, 85, 0.15);
  border-color: var(--ambar);
  color: var(--ambar);
}
.topbar-help-popover {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 10px 32px rgba(0,0,0,0.5);
  padding: 14px 16px;
  max-width: 360px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-2);
}
.topbar-help-corpo { color: var(--text-2); }

@media (max-width: 768px) {
  header.topbar .topbar-acoes-header {
    width: 100%;
    margin-top: 6px;
    margin-left: 0;
  }
  header.topbar { flex-wrap: wrap; }
}

/* CONTAINER — interno, antigo */
.app-main .container {
  padding: 28px;
  max-width: none;
  width: 100%;
}

/* OVERLAY (mobile drawer) */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 99;
  opacity: 0;
  transition: opacity 0.2s;
}
.sidebar-overlay.aberto {
  display: block;
  opacity: 1;
}

/* ===== Tablet & Mobile: sidebar vira drawer =====
   Trigger: viewport <= 1024px OU device touch (pointer: coarse).
   Pointer coarse cobre tablets em landscape que tem viewport >1024
   (ex: iPad Pro 11" landscape 1194, Galaxy Tab S landscape 1280) —
   nesses casos o sidebar fixo de 240px deixava o conteudo apertado.
   Desktop com mouse (pointer: fine) mantem sidebar fixo. */
@media (max-width: 1024px), (pointer: coarse) {
  /* Anula estado "sidebar-colapsada" em touch — em drawer mode nao faz
     sentido ter sidebar de 64px so com icones. Sem esse override, a
     classe colapsada (vinda de outro device via localStorage) deixava
     uma segunda sidebar sobreposta ao drawer. */
  .app-shell,
  .app-shell.sidebar-colapsada { grid-template-columns: 1fr !important; }
  aside.sidebar,
  .app-shell.sidebar-colapsada aside.sidebar {
    position: fixed !important;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px !important;
    max-width: 86vw;
    transform: translateX(-100%);
    transition: transform 0.25s ease-out;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
    z-index: 110;
  }
  aside.sidebar.aberta,
  .app-shell.sidebar-colapsada aside.sidebar.aberta { transform: translateX(0) !important; }
  /* Em touch SEMPRE mostra labels e texto da brand (nao usa modo icon-only).
     Bug fix: `display: revert` em <a> revertia pra `display: inline`,
     quebrando flex (icone + label ficavam empilhados verticalmente).
     Solucao: forca display: flex explicitamente + row direction. */
  .app-shell.sidebar-colapsada .sidebar-brand-texto,
  .app-shell.sidebar-colapsada .nav-grupo-label { display: inline !important; }
  .app-shell.sidebar-colapsada .nav-grupo-header,
  .app-shell.sidebar-colapsada .nav-grupo-solto > a {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: flex-start !important;
    width: 100% !important;
    height: auto !important;
    padding: 12px 14px !important;
    gap: 12px !important;
    margin: 0 !important;
    text-align: left !important;
  }
  /* Restaura tamanho de fonte do label nos itens (foi minified no colapsado) */
  .app-shell.sidebar-colapsada .nav-grupo-header .ic svg,
  .app-shell.sidebar-colapsada .nav-grupo-solto a .ic svg {
    width: 20px !important;
    height: 20px !important;
  }
  /* FLYOUT (submenu lateral) eh feature SO de desktop hover. Em touch
     fica escondido por padrao — vira accordion inline quando o grupo
     recebe `.expandido-inline` (via click). */
  .nav-grupo-flyout,
  .nav-grupo.flyout-aberto .nav-grupo-flyout,
  .app-shell.sidebar-colapsada .nav-grupo-flyout { display: none !important; }

  /* TOUCH ACCORDION: quando o user clica num grupo, expande inline aqui
     dentro do drawer (em vez de abrir flyout lateral). Reseta as
     propriedades position: fixed e mostra como bloco normal. */
  .nav-grupo.expandido-inline .nav-grupo-flyout {
    display: block !important;
    position: static !important;
    left: auto !important;
    top: auto !important;
    bottom: auto !important;
    width: 100% !important;
    background: rgba(255,255,255,0.02) !important;
    border-right: none !important;
    box-shadow: none !important;
    padding: 8px 12px 12px 28px !important;
    z-index: auto !important;
    border-radius: 8px;
    margin: 4px 8px 8px;
  }
  /* Esconde o titulo redundante (label do grupo ja esta visivel no header) */
  .nav-grupo.expandido-inline .nav-grupo-flyout-titulo { display: none !important; }
  /* Indicador visual no header quando expandido (chevron / cor) */
  .nav-grupo.expandido-inline .nav-grupo-header {
    background: rgba(239, 173, 85, 0.08);
    color: var(--ambar);
  }
  header.topbar .menu-toggle { display: inline-flex; }
  header.topbar { padding: 12px 16px; }
  .app-main .container { padding: 12px; }
}

/* Previne scroll horizontal causado por overflow inesperado em tablet/mobile.
   IMPORTANTE: usar `clip` em vez de `hidden` — clip nao cria scroll container,
   entao position: sticky de descendentes (sidebar, conf-busca) continua
   funcionando. `hidden` quebrava o sticky em browsers modernos.
   Fallback: browsers velhos sem `clip` caem pro hidden mesmo. */
html, body {
  overflow-x: hidden;  /* fallback */
  overflow-x: clip;    /* moderno: nao quebra sticky */
}

/* ============================================================================
 * RESPONSIVO — laptops, tablets, mobile
 * Estrategia mobile-first em algumas areas; outras usamos overrides em max-width.
 * Touch targets >= 44px em mobile (WCAG/Apple HIG).
 * ============================================================================ */

/* ===== TELAS GRANDES (>= 1600px) — aproveita espaco horizontal ===== */
@media (min-width: 1600px) {
  .container { max-width: 1600px; }
}

/* ===== TABLET / LAPTOP PEQUENO (<= 1024px) ===== */
@media (max-width: 1024px) {
  .container { padding: 20px; }
  header.topo { padding: 14px 16px; gap: 12px; }
  header.topo h1 { font-size: 16px; }

  .modal { max-width: 92vw; }
  .modal.large { max-width: 92vw; }

  /* Detalhe info passa pra 1 coluna */
  .detalhe-info { grid-template-columns: 1fr; gap: 12px; }
}

/* ===== MOBILE (<= 768px) ===== */
@media (max-width: 768px) {
  html, body { font-size: 15px; }
  .container { padding: 12px; }

  /* HEADER compacto: nome do usuario some, fica so a sigla na pill */
  header.topo {
    padding: 12px 14px;
    gap: 10px;
    margin-bottom: 10px;
  }
  header.topo h1 { font-size: 15px; gap: 6px; }
  header.topo h1 span:not(.ic):not(.accent):not(.accent2) { font-size: 14px; }
  /* .brand-row e .brand-mark removidas: zero uso em HTML */
  .user-nome { display: none; }
  .user-role-pill { font-size: 8px; padding: 2px 5px; }
  .btn-sair { padding: 8px 10px; }

  /* FILTROS empilhados, cada um cheio */
  .filtros-linha {
    padding: 10px;
    gap: 8px;
    flex-direction: column;
    align-items: stretch;
  }
  .filtros-linha .filtro {
    width: 100%;
  }
  .filtros-linha .filtro select,
  .filtros-linha .filtro input[type="text"] {
    width: 100%;
    min-width: 0;
    padding: 12px 14px;  /* maior pra caber dedo */
    font-size: 16px;     /* 16px+ evita zoom automatico no iOS Safari */
    min-height: 44px;    /* tap target minimo */
  }
  .filtros-linha .ml-auto { margin-left: 0; }
  .filtros-linha button {
    width: 100%;
    justify-content: center;
    padding: 12px 14px;
    font-size: 15px;
    min-height: 44px;    /* tap target minimo */
  }

  /* TABELAS viram cards empilhados — cada td vira linha "Label: valor" */
  .table-wrap { background: transparent; border: none; }
  table.tabela { font-size: 13px; }
  table.tabela thead {
    /* Esconde cabecalho — labels vem do data-th de cada td */
    position: absolute;
    width: 1px; height: 1px; padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap; border: 0;
  }
  table.tabela tbody tr {
    display: block;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 14px;
    margin-bottom: 10px;
    box-shadow: var(--shadow);
  }
  table.tabela tbody tr.fora-sla {
    border-color: rgba(239, 68, 68, 0.4);
    background: rgba(239, 68, 68, 0.06);
  }
  table.tabela tbody tr.vencida {
    border-color: rgba(245, 158, 11, 0.4);
    background: rgba(245, 158, 11, 0.06);
  }
  table.tabela td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
    border: none;
    text-align: right;
    min-height: 28px;
  }
  table.tabela td::before {
    content: attr(data-th);
    flex-shrink: 0;
    font-size: 10.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-3);
    text-align: left;
  }
  /* Quando td nao tem data-th, ocupa linha inteira (titulo, descricao) */
  table.tabela td:not([data-th]) {
    display: block;
    text-align: left;
    border-bottom: 1px solid var(--border);
    padding-bottom: 8px;
    margin-bottom: 8px;
  }
  table.tabela td:not([data-th]):last-child {
    border-bottom: none;
    margin-bottom: 0;
  }
  /* Acoes ficam empilhadas horizontalmente, ocupam espaco */
  table.tabela td .btn,
  table.tabela td .btn-sm {
    padding: 8px 12px;
    font-size: 13px;
  }
  /* Coluna Ação/Ações em mobile: empilha botões pra não quebrar */
  table.tabela td[data-th="Ação"],
  table.tabela td[data-th="Ações"] {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }
  table.tabela td[data-th="Ação"] > div,
  table.tabela td[data-th="Ações"] > div {
    width: 100%;
    flex-wrap: nowrap;
  }
  table.tabela td[data-th="Ação"] > div > .btn,
  table.tabela td[data-th="Ação"] > div > .btn-sm,
  table.tabela td[data-th="Ações"] > div > .btn,
  table.tabela td[data-th="Ações"] > div > .btn-sm {
    flex: 1;
    justify-content: center;
  }
  /* Badge dentro de td: garante que nao quebre em duas linhas */
  table.tabela td .badge { white-space: nowrap; }

  /* MODAL fullscreen no mobile, com header sticky. Mantem padding lateral
   * minimo (8px) pra conteudo respirar das bordas; resto fica fullscreen. */
  .modal-overlay {
    padding: 0;
    align-items: stretch;
  }
  .modal,
  .modal.large {
    max-width: 100%;
    width: 100%;
    margin: 0;
    border-radius: 0;
    border: none;
    height: 100dvh;        /* dvh respeita a barra do navegador mobile + contem o scroll no .modal-body */
    max-height: 100dvh;
    display: flex;
    flex-direction: column;
  }
  /* Padding lateral nos containers internos do modal (header/body/footer)
   * pra conteudo nao colar nas bordas em telas pequenas. */
  .modal-header,
  .modal-body,
  .modal-footer {
    padding-left: 16px;
    padding-right: 16px;
  }
  .modal-header {
    position: sticky;
    top: 0;
    background: var(--bg-2);
    z-index: 5;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
  }
  .modal-header h2 { font-size: 16px; }
  .modal-header .btn-fechar {
    width: 38px; height: 38px;
    font-size: 28px;
    background: var(--bg-3);
    border-radius: 50%;
    color: var(--text);
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .modal-body {
    padding: 16px;
    flex: 1;
    overflow-y: auto;
  }
  .modal-footer {
    position: sticky;
    bottom: 0;
    background: var(--bg-2);
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    flex-direction: column-reverse;
    gap: 8px;
  }
  .modal-footer .btn,
  .modal-footer .btn-primary {
    width: 100%;
    justify-content: center;
    padding: 14px;
    font-size: 15px;
  }

  /* INPUTS maiores pro toque */
  .campo input, .campo select, .campo textarea {
    padding: 12px 14px;
    font-size: 16px;  /* >=16px previne zoom no iOS */
  }
  .campo label { font-size: 12px; }
  .linha-campos {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  /* BOTOES com tap target >= 44px */
  .btn { padding: 11px 16px; font-size: 14px; }
  .btn-sm { padding: 9px 12px; font-size: 13px; min-height: 36px; }
  .btn-icon { width: 40px; height: 40px; font-size: 16px; }

  /* CARDS / KPIs com padding menor */
  .card { padding: 16px; }
  .kpi .valor { font-size: 24px; }
  .kpi .valor.grande { font-size: 28px; }

  /* PAINEL ALERTA mais compacto */
  .painel-alerta {
    padding: 12px 14px;
    gap: 10px;
    flex-wrap: wrap;
  }
  .painel-alerta .texto-principal { font-size: 15px; }
  .painel-alerta .descricao { font-size: 12px; }

  /* TOAST canto inferior cheio */
  #toast-stack {
    bottom: 12px;
    right: 12px;
    left: 12px;
    max-width: none;
  }

  /* CHARTS com altura menor */
  .chart-wrap { height: 220px; }
  .chart-wrap.mini { height: 180px; }
}

/* ===== MOBILE BEM PEQUENO (<= 380px) ===== */
@media (max-width: 380px) {
  .container { padding: 8px; }
  header.topo h1 .accent,
  header.topo h1 .accent2 { display: none; }
}

/* ===== RANKING / TOP MAIS VENDIDOS — usado no Dashboard e modal do Estoque ===== */
.ranking-card {
  padding: 16px 18px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 12px;
}
.ranking-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 10px;
}
.ranking-header h3 {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.ranking-controles {
  display: flex;
  gap: 6px;
  align-items: center;
}
.ranking-controles select {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  color: var(--text);
  font-size: 12px;
  font-family: inherit;
}
.ranking-lista {
  display: grid;
  gap: 4px;
}
.ranking-item {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  border-radius: 6px;
  transition: background 0.15s;
}
.ranking-item.clicavel { cursor: pointer; }
.ranking-item.clicavel:hover { background: var(--bg-3); }
.ranking-item .pos {
  font-family: 'Geist Mono', monospace;
  font-weight: 700;
  color: var(--ambar);
  text-align: center;
  font-size: 13px;
}
.ranking-item .pos-medalha-1 { color: gold; }
.ranking-item .pos-medalha-2 { color: silver; }
.ranking-item .pos-medalha-3 { color: #cd7f32; }
.ranking-item .info-prod { min-width: 0; }
.ranking-item .nome {
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}
.ranking-item .sku {
  font-family: 'Geist Mono', monospace;
  font-size: 11px;
  color: var(--text-3);
}
.ranking-item .qtd {
  font-family: 'Geist Mono', monospace;
  font-weight: 600;
  color: var(--text);
  font-size: 13px;
}
.ranking-empty {
  padding: 24px;
  text-align: center;
  color: var(--text-3);
  font-size: 13px;
  font-style: italic;
}

/* ===== INPUT FILE — visual melhor (botao pra tirar foto) ===== */
.input-file-pretty {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.input-file-pretty label {
  flex: 1;
  min-width: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px;
  background: var(--bg-3);
  border: 1.5px dashed var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-2);
  transition: all 0.15s ease;
  text-align: center;
}
.input-file-pretty label:hover {
  border-color: var(--ambar);
  color: var(--text);
  background: rgba(239, 173, 85, 0.06);
}
.input-file-pretty label:active { transform: scale(0.98); }
.input-file-pretty input { display: none; }
.input-file-pretty label .ic { color: var(--ambar); }

/* ===== Tooltips de ajuda (Fase 2 do manual) =====
 * Uso: <label>Campo <span class="help" data-help="Texto">?</span></label>
 * Handler em shared.js (iniciarTooltipsAjuda) — hover desktop, click mobile.
 */
.help {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(239, 173, 85, 0.12);
  color: var(--ambar);
  font-size: 11px;
  font-weight: 700;
  font-family: inherit;
  cursor: help;
  margin-left: 4px;
  vertical-align: middle;
  user-select: none;
  transition: background 0.12s, transform 0.12s;
  border: 1px solid transparent;
}
.help:hover {
  background: var(--ambar);
  color: #1a1a1a;
  transform: scale(1.1);
}

/* Tooltip flutuante (criado dinamicamente, posicionado via JS) */
.tooltip-bubble {
  position: absolute;
  z-index: 9999;
  max-width: 280px;
  padding: 10px 14px;
  background: var(--bg-3);
  color: var(--text);
  border: 1px solid var(--ambar);
  border-radius: 8px;
  font-size: 12.5px;
  line-height: 1.45;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  pointer-events: none;
  animation: tooltip-fade-in 0.15s ease-out;
}
@keyframes tooltip-fade-in {
  from { opacity: 0; transform: translateY(2px); }
  to   { opacity: 1; transform: translateY(0); }
}

@media (max-width: 768px) {
  /* Em mobile, tap target ≥44px conforme CLAUDE.md (acessibilidade) */
  .help {
    width: 22px;
    height: 22px;
    font-size: 13px;
  }
  .tooltip-bubble { max-width: calc(100vw - 32px); }
}

/* ===== Loading com logo da Âmbar pulsante =====
 * Usado quando uma tela ou seção está carregando dados.
 * Muito mais óbvio que "Carregando..." em texto pequeno — reduz a chance
 * de o colaborador achar que tela travou.
 *
 * Uso JS: htmlLoadingAmbar('Buscando pedidos…')
 * Uso direto: <div class="loading-ambar"><img src="/logo.png" alt="Carregando"><span>...</span></div>
 */
.loading-ambar {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 56px 20px;
  color: var(--text-3);
}
.loading-ambar img {
  width: 56px;
  height: 56px;
  animation: pulse-ambar 1.4s ease-in-out infinite;
  filter: drop-shadow(0 0 12px rgba(239, 173, 85, 0.3));
}
.loading-ambar .label {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 500;
  color: var(--text-2);
}
@keyframes pulse-ambar {
  0%, 100% {
    transform: scale(1);
    opacity: 1;
    filter: drop-shadow(0 0 12px rgba(239, 173, 85, 0.3));
  }
  50% {
    transform: scale(1.12);
    opacity: 0.75;
    filter: drop-shadow(0 0 22px rgba(239, 173, 85, 0.55));
  }
}

/* Variante inline (menor, pra modais ou seções compactas) */
.loading-ambar.inline {
  flex-direction: row;
  gap: 10px;
  padding: 18px;
}
.loading-ambar.inline img { width: 28px; height: 28px; }
.loading-ambar.inline .label { font-size: 12px; }

/* ===== MODO DEMO =====
 * User com role=demo veem banner fixo + botoes de acao desabilitados.
 * Marcador no body via shared.js (document.body.classList.add('modo-demo')).
 *
 * IMPORTANTE: o banner-demo ocupa espaco fixo no topo. Sidebar e topbar
 * (que sao position:sticky com top:0) precisam compensar essa altura,
 * senao ficam atras do banner e a parte de baixo do sidebar fica cortada
 * quando o user rola a pagina. Solucao: variavel CSS --banner-demo-h. */
body.modo-demo {
  --banner-demo-h: 40px;
  /* Em PWA standalone, banner-demo precisa empurrar tambem a Dynamic Island/notch */
  padding-top: calc(var(--banner-demo-h) + env(safe-area-inset-top, 0px));
}
#banner-demo {
  position: fixed;          /* fixed em vez de sticky pra nao depender do parent scroll */
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  /* Altura total = banner + safe area (Dynamic Island/notch) */
  height: calc(var(--banner-demo-h) + env(safe-area-inset-top, 0px));
  padding-top: env(safe-area-inset-top, 0px);  /* conteudo abaixo da ilha */
  background: linear-gradient(90deg, #F3C079, #EFAD55);
  color: var(--bg);
  padding-left: 16px;
  padding-right: 16px;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: nowrap;
  overflow: hidden;          /* evita quebrar em 2 linhas em tela estreita */
  line-height: 1.2;
}
#banner-demo .banner-demo-icone { font-size: 16px; flex-shrink: 0; }
#banner-demo .banner-demo-sep { opacity: 0.5; flex-shrink: 0; }
#banner-demo .banner-demo-msg { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#banner-demo:hover { cursor: help; }   /* dica que o title= tem mais info */
@media (max-width: 600px) {
  #banner-demo {
    font-size: 11px;
    gap: 6px;
  }
  #banner-demo .banner-demo-icone { font-size: 14px; }
  /* Em mobile, mostra so 'Modo Demonstração' (o resto fica no title) */
  #banner-demo .banner-demo-sep,
  #banner-demo .banner-demo-msg { display: none; }
}

/* Sidebar e topbar sao sticky e iniciam logo abaixo do banner.
 * Sem o offset, ao rolar a pagina, sidebar/topbar grudam no topo do
 * viewport COBERTAS pelo banner fixed (ficam 40px atras dele). */
body.modo-demo aside.sidebar {
  top: var(--banner-demo-h);
  height: calc(100vh - var(--banner-demo-h));
}
body.modo-demo header.topbar {
  top: var(--banner-demo-h);
}

/* Desabilita visualmente botoes de acao quando user e demo.
 * Backend ja bloqueia com 403 — isto eh UX pra deixar claro que nao pode.
 * Exceto botoes de filtro/busca/navegacao (data-permitido-demo).
 *
 * Em 25/05/2026 removidos `[data-acao-write]` e `.acao-write` desta lista
 * — auditoria revelou zero uso no projeto. Hoje so .btn-primary/success/danger
 * sao o gatilho.
 */
body.modo-demo .btn-primary,
body.modo-demo .btn-success,
body.modo-demo .btn-danger {
  opacity: 0.45;
  cursor: not-allowed !important;
  pointer-events: none;
  position: relative;
}
body.modo-demo .btn-primary[data-permitido-demo],
body.modo-demo .btn-success[data-permitido-demo],
body.modo-demo .btn-danger[data-permitido-demo],
body.modo-demo button[data-permitido-demo] {
  opacity: 1;
  cursor: pointer !important;
  pointer-events: auto;
}

/* ============================================================================
 * BADGE DE CANAL (Mercado Livre, Shopee, Site Próprio) — reusável global.
 *
 * Use via helper iconeCanal() em shared.js OU manualmente:
 *   <span class="canal-badge canal-mercado_livre"><img src="/img/marketplaces/mercado-livre.png" alt="Mercado Livre"></span>
 *   <span class="canal-badge canal-shopee"><img src="/img/marketplaces/shopee.png" alt="Shopee"></span>
 *   <span class="canal-badge canal-site_proprio"><img src="/logo.png" alt="Âmbar Shop">Âmbar Shop</span>
 *
 * Tamanho: pequeno (24px altura). Pra versão grande use modificador .canal-badge-grande.
 * ============================================================================ */
.canal-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 16px;
  flex-shrink: 0; white-space: nowrap;
  font-size: 12px; font-weight: 600;
  vertical-align: middle;
}
.canal-badge img {
  display: block; flex-shrink: 0;
  height: 16px; width: auto; max-width: 80px;
  object-fit: contain;
}
.canal-badge.canal-mercado_livre {
  background: #FFE600; color: #2D3277;
  padding: 4px 12px;
}
.canal-badge.canal-mercado_livre img { height: 16px; }
.canal-badge.canal-shopee {
  background: #EE4D2D; color: #fff;
}
.canal-badge.canal-shopee img { height: 16px; }
.canal-badge.canal-site_proprio {
  background: #fff; color: var(--ambar);
  border: 1px solid rgba(239, 173, 85, 0.2);
}
.canal-badge.canal-site_proprio img {
  height: 16px; width: auto; max-width: 80px;
  /* sem filter — logo Ambar Shop ja eh laranja, contrasta no branco */
}
/* Quando img cair pro fallback (/logo.png so sacolinha), mostra texto.
   Quando carrega ambar-shop.png (PNG completo com texto), esconde o span. */
.canal-badge.canal-site_proprio .logo-texto-fallback {
  display: none;
}
.canal-badge.canal-site_proprio img.logo-fallback + .logo-texto-fallback {
  display: inline; font-weight: 700; margin-left: 4px;
}
.canal-badge.canal-site_proprio img.logo-fallback {
  height: 16px; width: 16px; max-width: 16px;
  /* So sacolinha — fica pequena, igual o tamanho que era */
}
.canal-badge.canal-generico {
  background: var(--bg-3); border: 1px solid var(--border);
  color: var(--text);
}

/* Variante GRANDE (pra cards de destaque) */
.canal-badge.grande {
  padding: 8px 18px; border-radius: 22px;
  font-size: 14px; font-weight: 800;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}
.canal-badge.grande img { height: 26px; max-width: 140px; }
.canal-badge.grande.canal-site_proprio img { width: 22px; height: 22px; }

/* Variante MINI (so logo, sem texto) — pra tabelas densas */
.canal-badge.mini {
  padding: 3px 8px; border-radius: 12px;
}
.canal-badge.mini img { height: 14px; max-width: 60px; }

/* ============================================================================
 * HOVER/FOCUS GLOBAL — feedback visual consistente em elementos interativos
 * ============================================================================ */
.canal-badge {
  transition: opacity 0.12s ease;
}
.canal-badge:hover {
  opacity: 0.85;
}

/* Cards/linhas clicáveis ganham feedback */
tr.clicavel {
  cursor: pointer;
  transition: background 0.12s ease;
}
tr.clicavel:hover td {
  background: rgba(239, 173, 85, 0.04);
}

/* ============================================================================
 * FILTRO DE PERÍODO PADRÃO (referência: dashboard.html)
 * ----------------------------------------------------------------------------
 * Tem que ser idêntico ao do dashboard pra todas as telas terem o mesmo
 * comportamento. Usado via iniciarFiltroPeriodo() em shared.js.
 *
 * Estrutura HTML gerada:
 *   <div class="filtros-periodo">
 *     <div class="filtro-grupo" data-tipo="periodo">
 *       <button data-valor="hoje">Hoje</button>
 *       ...
 *       <button class="btn-periodo-personalizado">Personalizado ▾</button>
 *     </div>
 *   </div>
 *   <div class="popover-periodo">...</div>  <!-- portado pro body -->
 * ============================================================================ */
.filtros-periodo {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  padding: 10px 12px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 14px;
}
/* Permite incorporar dentro de uma topbar existente sem chrome extra. */
.filtros-periodo.embed {
  background: transparent;
  border: none;
  padding: 0;
  margin: 0;
}
/* Filtro-grupo segue o padrão "tabs com underline" (regra UI minimalista
   25/05/2026). Compartilhado com dashboard.html. */
.filtros-periodo .filtro-grupo {
  display: flex;
  gap: 2px;
  padding: 2px 0;
  background: transparent;
  border: none;
  border-radius: 0;
}
.filtros-periodo .filtro-grupo button {
  background: transparent;
  color: var(--text-3);
  border: none;
  padding: 7px 10px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border-radius: 0;
  border-bottom: 2px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.filtros-periodo .filtro-grupo button:hover { color: var(--text); }
.filtros-periodo .filtro-grupo button.ativo {
  background: transparent;
  color: var(--text);
  border-bottom-color: var(--primary);
  font-weight: 600;
}
/* Pill compacta de periodo — escondida no desktop, aparece so no mobile
   (Pedidos #5, 04/06/2026): no celular os 8 botoes quebravam em 2-3 linhas e
   comiam espaco da lista. No mobile vira "🗓 30 dias ▾" que abre os botoes. */
.filtros-periodo .fp-mobile-trigger { display: none; }

/* Popover do "Personalizado ▾" (3 tabs: mês, atalhos, intervalo livre) */
.popover-periodo {
  position: fixed;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  padding: 14px;
  min-width: 280px;
  z-index: 9999;
}
.popover-periodo-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}
.popover-periodo-tabs button {
  background: transparent;
  border: none;
  color: var(--text-2);
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 500;
}
.popover-periodo-tabs button:hover { background: var(--bg-3); color: var(--text); }
.popover-periodo-tabs button.ativo {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 700;
}
.popover-periodo-corpo {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.popover-periodo-corpo .pop-dica {
  flex: 1 1 100%;
  font-size: 11px;
  color: var(--text-3);
  margin-bottom: 4px;
  padding: 6px 8px;
  background: var(--bg-3);
  border-radius: 4px;
  border-left: 2px solid var(--primary);
}
.popover-periodo-corpo label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  color: var(--text-2);
  flex: 1;
  min-width: 100px;
}
.popover-periodo-corpo[data-corpo="atalhos"] label {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text);
  min-width: 100%;
  padding: 6px 4px;
  cursor: pointer;
}
.popover-periodo-corpo[data-corpo="atalhos"] label:hover {
  background: var(--bg-3);
  border-radius: 4px;
}
.popover-periodo-corpo select,
.popover-periodo-corpo input[type="date"] {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 10px;
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
}
.popover-periodo-rodape {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
}
.popover-periodo-rodape button {
  padding: 7px 14px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border);
}
.popover-periodo-rodape .btn-secondary {
  background: transparent;
  color: var(--text-2);
}
.popover-periodo-rodape .btn-secondary:hover { background: var(--bg-3); }
.popover-periodo-rodape .btn-primary {
  background: var(--primary);
  color: #1A1614;
  border-color: var(--primary);
}
.popover-periodo-rodape .btn-primary:hover { filter: brightness(1.08); }

/* Mobile: periodo vira pill compacta que abre os botoes (economiza espaco) */
@media (max-width: 768px) {
  .filtros-periodo { padding: 8px 10px; gap: 8px; flex-direction: column; align-items: flex-start; }
  .filtros-periodo.embed { padding: 0; }
  /* Pill compacta (trigger) */
  .filtros-periodo .fp-mobile-trigger {
    display: inline-flex; align-items: center; gap: 6px;
    background: transparent; border: 1px solid var(--border);
    color: var(--text-2); border-radius: 99px; padding: 8px 14px;
    font-family: inherit; font-size: 13px; font-weight: 500;
    cursor: pointer; min-height: 40px;
  }
  .filtros-periodo .fp-mobile-trigger .fp-mobile-lbl { color: var(--primary); font-weight: 600; }
  .filtros-periodo.aberto .fp-mobile-trigger { border-color: var(--primary); color: var(--text); }
  /* Botoes escondidos ate abrir a pill */
  .filtros-periodo .filtro-grupo { display: none; }
  .filtros-periodo.aberto .filtro-grupo {
    display: flex; flex: 1 1 100%; flex-wrap: wrap; width: 100%; margin-top: 8px;
  }
  .filtros-periodo .filtro-grupo button {
    padding: 8px 12px;
    min-height: 44px;  /* tap target */
  }
}

/* ============================================================================
 * PWA SAFE-AREA — Dynamic Island, notch, home indicator
 * ============================================================================
 * iPhone 14 Pro+ tem Dynamic Island no topo (~37.5pt). iPhones com notch
 * (X até 13) tem o entalhe. Em ambos, status-bar-style:black-translucent +
 * viewport-fit=cover puxam o conteúdo até as bordas — sem padding, o
 * conteúdo fica ATRÁS do Dynamic Island/notch.
 *
 * Fix: usar env(safe-area-inset-*) pra empurrar o conteúdo da safe-area
 * só quando em modo standalone (PWA instalado). No browser comum (Safari
 * mostra barra de URL) não precisa.
 *
 * Aplicado em:
 *   - .app-shell (telas modernas com sidebar)
 *   - header.topo (telas legadas)
 *   - aside.sidebar (drawer mobile abre por cima do conteúdo, precisa
 *     respeitar safe-area no topo + bottom pro home indicator)
 *   - .modal-overlay (modais fullscreen no mobile)
 *
 * Bottom (home indicator iPhone X+): empurra rodapé pra cima da barra.
 * Left/right: protege landscape em iPhones (notch lateral).
 * ============================================================================ */

@supports (padding: env(safe-area-inset-top)) {
  /* Standalone = PWA instalado (homescreen). No browser regular do iOS,
     o display-mode é 'browser' e a barra do Safari já compensa. */
  @media (display-mode: standalone) {
    /* Header da tela ganha espaço pro Dynamic Island/notch */
    header.topo {
      padding-top: calc(18px + env(safe-area-inset-top));
    }

    /* App shell — sidebar e conteúdo principal respeitam safe-area */
    .app-shell {
      padding-left: env(safe-area-inset-left);
      padding-right: env(safe-area-inset-right);
    }

    /* Sidebar topo respeita Dynamic Island, bottom respeita home indicator */
    aside.sidebar {
      padding-top: env(safe-area-inset-top);
      padding-bottom: env(safe-area-inset-bottom);
    }

    /* Brand da sidebar — re-aplica padding interno por cima do safe-area
       (senão a logo fica colada ao Dynamic Island) */
    aside.sidebar .sidebar-brand {
      padding-top: max(16px, env(safe-area-inset-top));
    }

    /* Main content (mobile/touch) — sem sidebar visível, conteúdo direto.
       Aplica padding-top no header global das telas com topbar fixo. */
    @media (max-width: 1024px), (pointer: coarse) {
      header.topbar {
        padding-top: calc(12px + env(safe-area-inset-top));
      }
      /* Container principal das telas legadas — empurra todo conteúdo */
      body > .container {
        padding-top: calc(12px + env(safe-area-inset-top));
        padding-bottom: max(12px, env(safe-area-inset-bottom));
      }
    }

    /* Modais fullscreen (mobile <= 768px) — fundo cobre tela inteira,
       conteúdo do modal respeita safe-area */
    @media (max-width: 768px) {
      .modal-overlay,
      .modal {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
      }
    }

    /* Bottom-fixed elements (FAB, modais) sobem acima da home bar */
    .conc-modal,
    [data-fab] {
      bottom: max(20px, env(safe-area-inset-bottom));
    }
  }
}

/* ============================================================================
   BOTTOM NAV (mobile/PWA <=768px) — paleta "Ambar Refinado"
   Desktop/tablet: a barra fica escondida; a sidebar atual segue valendo.
   ============================================================================ */

#bottom-nav { display: none; }  /* default: escondido (desktop) */
/* Gaveta "Mais" tambem escondida por padrao (desktop). No mobile, a regra
   .bottom-sheet.aberto (dentro do @media 768) tem especificidade maior e
   reabre. Usa classe (nao #id) pra nao vencer o .aberto por especificidade. */
.bottom-sheet { display: none; }

@media (max-width: 768px) {
  #bottom-nav {
    display: flex;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 1200;
    align-items: stretch;
    justify-content: space-around;
    background: var(--bn-bg);
    border-top: 1px solid var(--bn-border);
    padding-bottom: max(8px, env(safe-area-inset-bottom));
  }
  .bn-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-height: 52px;          /* tap target >=44px */
    padding: 8px 2px 6px;
    background: none;
    border: 0;
    text-decoration: none;
    color: var(--bn-dim);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  .bn-item svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.6; }
  .bn-item .bn-lb { font-size: 9px; font-weight: 600; letter-spacing: 0.01em; line-height: 1; }
  .bn-item.ativo { color: var(--bn-accent); }
  .bn-item.ativo .bn-lb { font-weight: 700; }
  .bn-item:active { background: rgba(255,255,255,0.04); }

  /* badge de urgencia: ponto vermelho no canto do icone */
  .bn-ic { position: relative; display: inline-flex; }
  .bn-ic.bn-urgente::after {
    content: ''; position: absolute; top: -2px; right: -4px;
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--danger); border: 1.5px solid var(--bn-bg);
  }

  .bottom-sheet { position: fixed; inset: 0; z-index: 1300; display: none; }
  .bottom-sheet.aberto { display: block; }
  .bottom-sheet-overlay { position: absolute; inset: 0; background: rgba(15,13,11,0.6); }
  .bottom-sheet-painel {
    position: absolute; left: 0; right: 0; bottom: 0;
    max-height: 75vh; overflow-y: auto;
    background: var(--bn-bg);
    border-top-left-radius: 18px; border-top-right-radius: 18px;
    border-top: 1px solid var(--bn-border);
    padding: 8px 14px max(18px, env(safe-area-inset-bottom));
    animation: bsheet-up 0.18s ease-out;
  }
  .bottom-sheet-grip { width: 36px; height: 4px; border-radius: 4px; background: var(--bn-dim); opacity: 0.5; margin: 6px auto 12px; }
  .bsheet-grupo { margin-bottom: 14px; }
  .bsheet-grupo-titulo { font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--bn-dim); margin: 6px 4px 8px; font-weight: 700; }
  .bsheet-grupo-itens { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .bsheet-item {
    display: flex; align-items: center; gap: 10px;
    min-height: 48px; padding: 10px 12px;
    border-radius: 12px; text-decoration: none;
    color: var(--bn-text); background: rgba(255,255,255,0.03);
  }
  .bsheet-item svg { width: 20px; height: 20px; fill: none; stroke: var(--bn-dim); stroke-width: 1.6; }
  .bsheet-item.ativo { background: rgba(239, 173, 85,0.14); color: var(--bn-accent); }
  .bsheet-item.ativo svg { stroke: var(--bn-accent); }
  .bsheet-lb { font-size: 13px; font-weight: 600; }
  body.bottom-sheet-lock { overflow: hidden; }

  /* Banners PWA (instalar / iOS / atualizar) usam bottom:20px inline (z 9999)
     e cobririam a barra inferior — eleva acima dela no mobile. */
  #pwa-banner-instalar,
  #pwa-banner-instalar-ios,
  #pwa-banner-atualizar {
    bottom: calc(72px + env(safe-area-inset-bottom)) !important;
  }

  /* Bottom nav substitui o drawer no mobile (<=768px): esconde sidebar,
     hamburguer e overlay. Tablet (769-1024px) mantem o drawer antigo. */
  aside.sidebar { display: none !important; }
  .sidebar-overlay { display: none !important; }
  .menu-toggle { display: none !important; }

  /* Reserva espaco pra barra fixada no rodape nao cobrir conteudo.
     .app-main eh o flex-container que envolve todo o conteudo da pagina;
     adicionar padding-bottom aqui empurra o final da area rolavel pra
     acima da bottom bar (altura minima 52px + padding 8px + safe-area). */
  .app-main { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
}
@keyframes bsheet-up { from { transform: translateY(100%); } to { transform: translateY(0); } }
@media (prefers-reduced-motion: reduce) {
  .bottom-sheet-painel { animation: none; }
}

/* ============================================================================
   KIT DE ANÁLISE — visual "artefato" estilo Claude (15/06/2026)
   Prosa serifada editorial (tom "pensando junto") + tabela waterfall (estrutura
   da receita, estilo DRE comparativo) + callouts tintados (verde=bom, azul=info,
   âmbar=atenção, vermelho=ruim). Reutilizavel em QUALQUER tela de analise
   (Margem, DRE, Inteligencia de Estoque, Ads...). REGRA: so' a PROSA usa a
   serifada (--font-display); numeros/tabelas seguem em Geist / Geist Mono pra
   nao perder legibilidade. Cor com parcimonia — ganho verde, custo vermelho.
   ============================================================================ */
.an-painel { margin: 2px 0 22px; }

/* Prosa editorial — serifada, frase de analise em linguagem humana */
.an-prosa {
  font-family: var(--font-display);
  font-size: 16px;
  line-height: 1.55;
  letter-spacing: 0.01em;
  color: var(--text);
  font-weight: 400;
  margin: 0 0 16px;
}
.an-prosa strong { font-weight: 600; }
.an-prosa .an-muted { color: var(--text-3); }

/* Rotulo de secao — maiuscula miuda, igual aos prints */
.an-rotulo {
  font-size: 11px; font-weight: 600; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--text-3); margin: 0 0 10px;
}

/* Tabela waterfall (receita -> margem), estilo DRE comparativo dos prints */
.an-wf {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-2);
}
.an-wf-linha {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; padding: 11px 16px; border-bottom: 1px solid var(--border);
}
.an-wf-linha:last-child { border-bottom: 0; }
.an-wf-rot { color: var(--text-2); font-size: 13.5px; }
.an-wf-rot .an-wf-pct { color: var(--text-3); font-size: 12px; margin-left: 6px; }
.an-wf-val {
  font-family: 'Geist Mono', monospace; font-size: 14px; font-weight: 500;
  white-space: nowrap; color: var(--text-2);
}
.an-wf-val.custo  { color: var(--danger); }
.an-wf-val.ganho  { color: var(--success); }
/* Linha de total (a margem) — destacada */
.an-wf-linha.total { background: var(--bg-3); }
.an-wf-linha.total .an-wf-rot { color: var(--text); font-weight: 600; font-size: 14px; }
.an-wf-linha.total .an-wf-val { font-size: 17px; font-weight: 700; color: var(--text); }
.an-wf-linha.total.neg .an-wf-val { color: var(--danger); }

/* Callout tintado — verde/azul/ambar/vermelho */
.an-callout {
  border: 1px solid var(--border);
  border-left-width: 3px;
  border-radius: var(--radius);
  padding: 14px 16px;
  margin: 16px 0 0;
  background: var(--bg-2);
}
.an-callout-tit {
  display: flex; align-items: center; gap: 8px;
  font-weight: 600; font-size: 14px; color: var(--text); margin: 0 0 4px;
}
.an-callout-txt { font-size: 13px; line-height: 1.5; color: var(--text-2); margin: 0; }
.an-callout.bom     { border-left-color: var(--success); background: rgba(34, 197, 94, 0.06); }
.an-callout.bom     .an-callout-tit { color: var(--success); }
.an-callout.info    { border-left-color: var(--primary); background: var(--primary-soft); }
.an-callout.info    .an-callout-tit { color: var(--primary); }
.an-callout.atencao { border-left-color: var(--warning); background: rgba(245, 158, 11, 0.08); }
.an-callout.atencao .an-callout-tit { color: var(--warning); }
.an-callout.ruim    { border-left-color: var(--danger); background: rgba(239, 68, 68, 0.06); }
.an-callout.ruim    .an-callout-tit { color: var(--danger); }

@media (max-width: 700px) {
  .an-prosa { font-size: 15px; }
  .an-wf-linha { padding: 10px 13px; }
}

/* ============================================================================
   Campo de busca sobre <select> — tornarSelectBuscavel() em shared.js.
   Digita pra filtrar (acha no meio da frase, ignora acento). O <select> fica
   escondido (value/form intactos). Reusavel em qualquer tela.
   ============================================================================ */
.combo-busca { position: relative; }
/* Em contexto .campo (modais), o .campo input ja' estiliza (ganha por
   especificidade) — fica igual aos outros campos. Fora dele, este baseline vale. */
.combo-busca-input {
  width: 100%; background: var(--bg-3); border: 1px solid var(--border);
  border-radius: 8px; padding: 9px 11px; color: var(--text);
  font-family: inherit; font-size: 14px;
}
.combo-busca-input:focus { outline: none; border-color: var(--primary); }
.combo-busca-painel {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 60;
  background: var(--bg-2); border: 1px solid var(--border); border-radius: 10px;
  max-height: 240px; overflow: auto; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}
.combo-busca-op { padding: 9px 12px; cursor: pointer; font-size: 14px; color: var(--text-2); }
.combo-busca-op.ativo, .combo-busca-op:hover { background: var(--bg-3); color: var(--text); }
.combo-busca-vazio { padding: 10px 12px; color: var(--text-3); font-size: 13px; }
