/* ============================================================================
   design-system.css - tokens visuais + componentes base do CF Finance
   ----------------------------------------------------------------------------
   Linguagem Dimension (referencia: docs/design/dimension/DESIGN.md): canvas
   fosco azul-aço (escuro #090b0f, claro #f6f9fc; ver tokens), cards de 24px com borda fina, botoes em
   pilula (primario branco no escuro, preto no claro), DM Sans no corpo e
   Geist nos titulos. Violeta so em link, foco e serie principal; verde,
   vermelho e ambar ficam como status de recebimento, pagamento e atraso.
   Padrao de aparencia: Solido; Equilibrado e Vidro continuam como opcao.
   ============================================================================ */

/* Self-hosted (D11 do SDD — sem CDN). Origem/versao/licenca/checksum em
   lib/fonts/SOURCE.md. font-display:swap; unicode-range restringe ao subset
   latin ja baixado, nao muda comportamento pra fora dele. */
@font-face {
  font-family: 'Inter';
  src: url('lib/fonts/Inter-v20-latin.woff2') format('woff2');
  font-weight: 400 800;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Space Grotesk';
  src: url('lib/fonts/SpaceGrotesk-v22-latin.woff2') format('woff2');
  font-weight: 500 700;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* DM Sans (corpo/UI) e Geist (titulos/numeros): variaveis, subset latin, via npm
   @fontsource-variable 5.3.0 (lib/fonts/SOURCE.md). Faixa de peso = eixo real do arquivo. */
@font-face {
  font-family: 'DM Sans';
  src: url('lib/fonts/DMSans-var-latin.woff2') format('woff2');
  font-weight: 100 1000;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Geist';
  src: url('lib/fonts/Geist-var-latin.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  /* === Contrato visual (docs/reference/DESIGN.md, plano V3 §2.2) ===
     Fonte única de cor, raio, fonte, espaço, sombra e movimento. Os tokens
     legados abaixo são aliases destes; código novo usa só estes nomes. */
  /* Linguagem Dimension (decisão do dono, 30/10/2026; docs/design/dimension/DESIGN.md):
     canvas fosco, grafite azulado nos cards, texto frio, bordas finas (valores em 06/11/2026, abaixo).
     Violeta só em link, foco e série principal; o CTA primário é a pílula branca.
     Contrastes medidos: texto ≥ 4,68:1 em todas as superfícies (pior caso: muted sobre interaction). */
  /* Neutros azul-aço (06/11/2026, "um pouco mais gélida"): mesmo degrau de luminância dos cinzas de antes, matiz ~215° e
     croma baixo. Antes: #0A0A0A, #161616, #1C1C1C, #262626, texto #EDEDED/#C2C2C2/#8F8F8F. */
  --bg-app: #090B0F;
  --bg-structural: #090B0F;
  --surface: #12161C;
  --surface-raised: #181D25;
  --surface-interaction: #232A34;
  --backdrop: rgba(3, 5, 9, 0.72);
  --topbar-glass: rgba(9, 11, 15, 0.85);

  --text-primary: #E9EEF5;
  --text-secondary: #BFC8D4;
  --text-muted: #8C99AB; /* 5,0:1 sobre --surface-interaction; o #686868 do Dimension reprova e fica só p/ decorativo */

  /* Azul céu (06/11/2026, a cor do sol e dos LEDs): --action para texto/link/foco/série principal
     (7,7:1 sobre o fundo, 7,0:1 sobre surface). CTA primário = pílula azul: --action-fill #38A9F5 com --on-action #161616 (7,0:1). */
  --action: #38A9F5;
  --action-soft: rgba(56, 169, 245, 0.14);
  --link: var(--text-primary); /* links em texto neutro (S3); ver .link-go */
  --action-fill: #38A9F5;
  --on-action: #161616;
  /* Status: mesma matiz de antes, um pouco dessaturados (≥ 6,4:1 sobre surface e sobre o próprio tint de 10%). */
  --success: #62C28D;
  --danger: #F08A82;
  --warning: #F5B93C; /* âmbar: com o acento azul, o aviso volta a ser o amarelo convencional (10,2:1 sobre surface) */

  --border: rgba(190, 210, 240, 0.11);
  --border-strong: rgba(190, 210, 240, 0.20);
  /* Contorno de campo de formulário: 3:1 sobre as superfícies (WCAG 1.4.11, A11Y-01). */
  --border-input: rgba(190, 210, 240, 0.43);
  /* Acabamentos que dependem do tema (o claro sobrescreve em :root[data-theme="light"]). */
  --fill-wash: rgba(190, 210, 240, 0.03);
  --progress-ref: rgba(190, 210, 240, 0.38);

  /* Materiais (F3, plano 30/09/2026). No nível Sólido (padrão) valem o que o app já usa e
     nenhum blur existe; :root[data-glass="glass"] (mais abaixo) troca por fill
     translúcido + blur e só então os consumidores aplicam backdrop-filter. */
  --material-chrome: var(--topbar-glass);
  --material-sidebar: var(--bg-structural);
  --material-overlay: var(--bg-structural);
  --material-sticky: var(--bg-structural);
  --material-blur-chrome: 0px;
  --material-blur-sidebar: 0px;
  --material-blur-overlay: 0px;
  --material-saturate: 100%;
  --material-filter-chrome: none;
  --material-filter-sidebar: none;
  --material-filter-overlay: none;
  /* Borda de 1px clara no topo dos materiais e no acabamento dos cards. */
  --material-edge: rgba(190, 210, 240, 0.11);
  --material-tone: none;
  /* Vidro (nível "glass", refeito em 31/10/2026): material translúcido discreto sobre fundo neutro.
     Cards e painéis usam o próprio --surface a 78% com borda fina de 1px, sem blur, sem sombra e sem brilho
     (a base resolve por tema, pois color-mix lê o --surface do elemento). A placa de dados fica a 94%.
     Blur moderado só em topbar, sidebar e overlays (ver :root[data-glass="glass"]). O fundo com LEDs
     (lib/fundo-leds-controle.js) vale nas duas aparências; com ele ligado os tokens de texto mudo ficam mais
     fortes (bloco "Fundo com LEDs" mais adiante). */
  /* Cards (02/11/2026): opacos no escuro "Sem vidro" (visual da produção); translúcidos no claro (bloco
     "Cards translúcidos" no fim do arquivo) e no Vidro. */
  --card-fill: var(--surface);
  --glass-card-fill: color-mix(in srgb, var(--surface) 90%, transparent);

  /* Respiro interno de todo card (09/11/2026): 24px no desktop, 20px até 640px. */
  --card-pad: 24px;
  /* Gradientes frios (09/11/2026, decisão do dono; só azul, ciano e índigo, doses baixas, nunca em texto).
     Botão: o texto escuro passa de 6:1 em todos os pontos. Card: luz de 7% de azul no topo. Faixa: dois brilhos no canto.
     Ficam sólidos no alto contraste e no Vidro (bloco logo abaixo). */
  --grad-acao: linear-gradient(135deg, #5CC3FF 0%, #38A9F5 55%, #2F9DEC 100%);
  --grad-acao-hover: linear-gradient(135deg, #6FCCFF 0%, #4DB5F8 55%, #3FA6F0 100%);
  --sheen-card: linear-gradient(180deg, color-mix(in srgb, var(--action) 7%, transparent) 0%, transparent 46%);
  --grad-faixa: none; /* era um brilho azul/índigo atrás do cabeçalho; desligado em 10/11/2026 (orbe decorativa). Para reverter, ver DECISOES.md */
  --r-xs: 4px; --r-sm: 8px; --r-md: 10px; --r-lg: 24px; --r-xl: 24px; --r-pill: 999px;

  --fs-2xs: 12px; --fs-xs: 12px; /* 2xs era 11px; revisão de UI #12: nada abaixo de 12px */ --fs-sm: 13px; --fs-md: 14px; --fs-lg: 16px;
  --fs-xl: 21px; --fs-2xl: 32px; --fs-hero: 40px;

  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 20px;
  --s-6: 24px; --s-8: 32px; --s-10: 40px;

  --shadow-pop: 0 16px 48px #0005;
  --shadow-modal: 0 24px 80px #0006;
  --motion: 160ms;
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);

  --sidebar: 232px;
  --content-max: 1440px;
  --hit: 44px;

  /* === Aliases legados (não usar em código novo) === */
  /* Superfícies */
  --bg:      var(--bg-app);
  --bg-deep: var(--bg-app);
  --s0:      var(--bg-structural);
  --s1:      var(--surface);
  --s2:      var(--surface-raised);
  --s3:      var(--surface-interaction);

  /* Bordas */
  --b0: var(--border);
  --b1: var(--border);
  --b2: var(--border-strong);
  --b3: var(--border-strong);

  /* Texto */
  --t0: var(--text-primary);
  --t1: var(--text-secondary);
  --t2: var(--text-muted);
  --t3: var(--text-muted);

  /* Ação */
  --accent:   var(--action);
  --accent-2: var(--action);
  --acc-bg:   var(--action-soft);
  --acc-bdr:  color-mix(in srgb, var(--action) 28%, transparent);
  /* Texto sobre fundo --accent sólido (nenhum consumidor hoje): --bg-app dá 6,7:1 sobre o violeta
     escuro (#8F88FF) e 5,5:1 sobre o do claro (#5A51E0). */
  --on-accent: var(--bg-app);

  /* Semântica */
  --green:  var(--success); --green-bg:  color-mix(in srgb, var(--success) 10%, transparent); --green-bdr:  color-mix(in srgb, var(--success) 28%, transparent);
  --yellow: var(--warning); --yellow-bg: color-mix(in srgb, var(--warning) 10%, transparent); --yellow-bdr: color-mix(in srgb, var(--warning) 28%, transparent);
  --red:    var(--danger);  --red-bg:    color-mix(in srgb, var(--danger) 10%, transparent);  --red-bdr:    color-mix(in srgb, var(--danger) 28%, transparent);
  --violet: var(--text-secondary); --violet-bg: var(--surface-raised); --violet-bdr: var(--border-strong);
  --blue:   var(--action);

  /* Categorias (donut/legenda). --cat-other é neutro, reservado a "Outros".
     Paleta fria (09/11/2026): 8 tons entre verde-mar, ciano, azul, índigo e lilás, alternando luminosidade; nada quente.
     Gerada por tools/paleta-fria/gerar.py: distância mínima entre as 8 cores, CIELAB, ΔE 18,7 no escuro e 19,6 no claro;
     todas >= 3:1 sobre o card e sobre a trilha das barras. Vermelho só em prejuízo, atraso e erro (--chart-neg, --danger). */
  --cat-1: var(--chart-in);  --cat-2: #149274;  --cat-3: #CAA1E5;  --cat-4: #51C0C9;
  --cat-5: #867BA4;  --cat-6: #418B9C;  --cat-7: #8295DD;  --cat-8: #A6AEDA;
  --cat-other: var(--text-muted);

  /* Raio */
  --radius-control: var(--r-sm);
  --radius-panel:   var(--r-lg);
  --radius-xs:      var(--r-xs);
  --radius-pill:    var(--r-pill);
  --radius-xl:      var(--r-xl);
  --r:              var(--r-sm);

  /* Espaço */
  --sp-1: var(--s-1); --sp-2: var(--s-2); --sp-3: var(--s-3); --sp-4: var(--s-4);
  --sp-5: var(--s-5); --sp-6: var(--s-6); --sp-8: var(--s-8); --sp-10: var(--s-10);
  --sp-12: 48px; --sp-16: 64px;

  /* Movimento */
  --ease-in:  cubic-bezier(0.7, 0, 0.84, 0);
  --t-instant: 80ms var(--ease-out);
  --t-fast:  0.12s var(--ease-out);
  --t-base:  var(--motion) var(--ease-out);
  --t-slow:  0.28s var(--ease-out);

  /* Tipografia (Dimension): DM Sans no corpo/UI, Geist em títulos e números; Inter é o fallback
     self-hosted. Space Grotesk deixa de ser usada. */
  --font-body: 'DM Sans', 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-head: 'Geist', 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace;

  /* Efeitos: sombra só em overlay. */
  --inset-top:    none;
  --card-shadow:  none;
  --shadow-lg:    var(--shadow-pop);

  /* Layout */
  --sidebar-w: var(--sidebar);
  --header-h:  60px;

  /* Corrige a lista nativa do <select> em dark (unificado do :root duplicado). */
  color-scheme: dark;
}

/* Alto contraste: recurso oficial (classe em Aparência) e preferência do SO. */
.contrast { --border: rgba(190, 210, 240, 0.30); --border-strong: rgba(190, 210, 240, 0.42); --text-muted: #B3BFCF; }
@media (prefers-contrast: more) { :root { --border: rgba(190, 210, 240, 0.30); --border-strong: rgba(190, 210, 240, 0.42); --text-muted: #B3BFCF; } }
@media (max-width: 640px) { :root { --card-pad: 20px; } }
/* Sem gradiente: alto contraste (SO ou do app), contraste forçado e Vidro (o blur já faz o papel da profundidade). */
:root.contrast, :root[data-glass="glass"] { --grad-acao: linear-gradient(var(--action-fill), var(--action-fill)); --grad-acao-hover: linear-gradient(var(--action-fill), var(--action-fill)); --sheen-card: none; --grad-faixa: none; }
@media (prefers-contrast: more), (forced-colors: active) { :root { --grad-acao: linear-gradient(var(--action-fill), var(--action-fill)); --grad-acao-hover: linear-gradient(var(--action-fill), var(--action-fill)); --sheen-card: none; --grad-faixa: none; } }
@media (prefers-reduced-motion: reduce) { :root { --motion: 0ms; } }
/* Reduzir movimento escolhido em Aparência (theme-boot.js / lib/theme-prefs.js). */
:root[data-motion="reduce"] { --motion: 0ms; }

/* ==========================================================================
   Tema claro (F2, plano 30/09/2026): sobrescreve só o contrato V3; os aliases
   legados (--s0..--s3, --t0.., --accent, --green..) derivam destes tokens.
   Linguagem Dimension no claro (30/10/2026): canvas e cards azul-aço (06/11/2026; antes #fafafa e lilás #FCF9FF), pílula azul.
   Contrastes medidos (WCAG): texto neutro >= 4,5:1 em bg-app/surface/raised/interaction;
   semânticos >= 4,5:1 sobre surface e sobre o próprio tint de 10%,
   contorno de campo >= 3:1, categorias >= 3:1 sobre #FFFFFF.
   ========================================================================== */
:root {
  /* Gráficos (09/11/2026, paleta fria): azul céu = entra/série principal, índigo = sai, ciano = resultado,
     vermelho frio = prejuízo/estouro. Todos >= 3:1 sobre o card. --chart-out-texto é o índigo para texto (selos) >= 4,5:1.
     Texto de status (valores, atraso) usa --success/--danger, não estes. */
  --chart-in: #4FA0D6; --chart-out: #7C7BD0; --chart-result: #3FB6C9; --chart-neg: #C2616F; --chart-out-texto: #9C9BE3;
  --pulso-in: var(--chart-in); --pulso-out: var(--chart-out);
}
:root[data-theme="light"] {
  --chart-in: #2F86BD; --chart-out: #4F4CB0; --chart-result: #0F7C8F; --chart-neg: #B03A4E; --chart-out-texto: #4F4CB0;
  /* Neutros azul-aço no claro (06/11/2026). Antes: #FAFAFA, #F9FCFF, #F4F4F5, #EBEBEC, texto #161616/#4A4A4A/#686868. */
  --bg-app: #F6F9FC;
  --bg-structural: #F6F9FC;
  --surface: #FBFDFF;
  --surface-raised: #EEF2F7;
  --surface-interaction: #E3E9F1;
  --backdrop: rgba(0, 10, 30, 0.5);
  --topbar-glass: rgba(246, 249, 252, 0.85);

  --text-primary: #0F1620;
  --text-secondary: #475264;
  --text-muted: #566478; /* 4,93:1 sobre --surface-interaction (o #6B6B6B pedido dava 4,47) */

  /* Azul profundo p/ link/foco (5,9:1 sobre branco e 5,7:1 sobre #FAFAFA); CTA primário = pílula azul
     (06/11/2026): --action-fill #38A9F5 com --on-action #161616. */
  --action: #0369A1;
  --action-soft: rgba(56, 169, 245, 0.20);
  --action-fill: #38A9F5;
  --on-action: #161616;
  --success: #146C2B;
  --danger: #B52626; /* era #D32F2F: 4,98:1 sobre branco mas 4,28:1 sobre o próprio tint de 10% */
  --warning: #8F5B00;

  --border: rgba(15, 40, 80, 0.09);
  --border-strong: rgba(15, 40, 80, 0.17);
  --border-input: rgba(15, 40, 80, 0.52);
  --fill-wash: rgba(15, 40, 80, 0.035);
  --progress-ref: rgba(15, 40, 80, 0.38);
  --material-edge: rgba(255, 255, 255, 0.8);
  --material-tone: none;

  --shadow-pop: 0 8px 28px rgba(8, 20, 40, 0.14);
  --shadow-modal: 0 16px 56px rgba(8, 20, 40, 0.18);
  /* Dimension não usa sombra de elevação: no claro o card também se separa só pela borda fina. */
  --card-shadow: none;

  /* Preenchimento "rebaixado" (trilhas, hover de linha, selos neutros). Com o Dimension o
     --surface-raised (#EEF2F7) já é esse cinza, então o alias --s2 passa a segui-lo. */
  --s2: var(--surface-raised);

  /* Categorias no claro (paleta fria, mesmo matiz de cada posição do escuro, luminosidade invertida: >= 3:1 sobre branco). */
  --cat-2: #1A9576;  --cat-3: #623F7B;  --cat-4: #02595F;  --cat-5: #887EA7;
  --cat-6: #448E9F;  --cat-7: #4E65A8;  --cat-8: #424C72;

  color-scheme: light;
}
:root[data-theme="light"].contrast { --border: rgba(15, 40, 80, 0.38); --border-strong: rgba(15, 40, 80, 0.52); --text-muted: #465366; }
@media (prefers-contrast: more) { :root[data-theme="light"] { --border: rgba(15, 40, 80, 0.38); --border-strong: rgba(15, 40, 80, 0.52); --text-muted: #465366; } }
/* Ajustes de componente que só existem no claro (não tocam nenhuma regra do escuro). */
:root[data-theme="light"] .btn-success:hover { color: var(--on-action); }
:root[data-theme="light"] select.input { color-scheme: light; }

/* ==========================================================================
   Materiais (F3, plano 30/09/2026; Equilibrado removido em 31/10/2026): vidro só em chrome (topbar, sidebar) e overlay
   (modal, toast, popover, menu). Cards, tabelas e formulários ficam sólidos: no máximo
   recebem o "acabamento" (borda superior clara + leve tom), sem backdrop-filter.
   data-glass="solid" ("Sem vidro", padrão) não entra em nenhuma regra abaixo: visual e cascata iguais
   aos de antes. Tokens por nível; o blur só existe dentro de @supports.
   Base da cor: --bg-structural do tema ativo. Fill >= 65% (texto sempre sobre >= 55%).
   ========================================================================== */
/* Vidro: translucidez baixa. Topbar 72%, sidebar 80%, overlays 90% do --bg-structural, com blur moderado
   e sem saturação nem brilho. Sem sombra além da de overlay e sem borda luminosa (--material-edge transparente). */
:root[data-glass="glass"] {
  --material-chrome: color-mix(in srgb, var(--bg-structural) 72%, transparent);
  --material-sidebar: color-mix(in srgb, var(--bg-structural) 80%, transparent);
  --material-overlay: color-mix(in srgb, var(--bg-structural) 90%, transparent);
  --material-sticky: color-mix(in srgb, var(--bg-structural) 96%, transparent);
  --material-blur-chrome: 12px;
  --material-blur-sidebar: 14px;
  --material-blur-overlay: 16px;
  --material-saturate: 100%;
  --material-edge: transparent;
  --glass-plate: color-mix(in srgb, var(--surface) 94%, transparent);
  --material-filter-chrome: blur(var(--material-blur-chrome));
  --material-filter-sidebar: blur(var(--material-blur-sidebar));
  --material-filter-overlay: blur(var(--material-blur-overlay));
}
/* Mobile: blur menor (custo de GPU). */
@media (max-width: 700px) {
  :root[data-glass="glass"] {
    --material-blur-chrome: 8px;
    --material-blur-sidebar: 10px;
    --material-blur-overlay: 12px;
  }
}
/* Menos transparência (SO), alto contraste do SO ou do app (.contrast) e contraste forçado: o Vidro cai para os
   materiais do Sólido (opacos, sem blur) e o fundo com LEDs some (também removido do DOM por lib/fundo-leds-controle.js). Especificidade acima das regras de textura por tema. */
@media (prefers-reduced-transparency: reduce), (prefers-contrast: more), (forced-colors: active) {
  :root[data-glass="glass"][data-theme] {
    --glass-card-fill: var(--surface);
    --glass-plate: var(--surface);
    --material-chrome: var(--topbar-glass);
    --material-sidebar: var(--bg-structural);
    --material-overlay: var(--bg-structural);
    --material-sticky: var(--bg-structural);
    --material-filter-chrome: none;
    --material-filter-sidebar: none;
    --material-filter-overlay: none;
  }
}
:root.contrast[data-glass="glass"][data-theme] {
  --glass-card-fill: var(--surface);
  --glass-plate: var(--surface);
  --material-chrome: var(--topbar-glass);
  --material-sidebar: var(--bg-structural);
  --material-overlay: var(--bg-structural);
  --material-sticky: var(--bg-structural);
  --material-filter-chrome: none;
  --material-filter-sidebar: none;
  --material-filter-overlay: none;
}
@media (forced-colors: active) {
  :root[data-glass] {
    --material-chrome: color-mix(in srgb, var(--bg-structural) 95%, transparent);
    --material-sidebar: color-mix(in srgb, var(--bg-structural) 95%, transparent);
    --material-overlay: color-mix(in srgb, var(--bg-structural) 95%, transparent);
    --material-sticky: color-mix(in srgb, var(--bg-structural) 95%, transparent);
    --material-filter-chrome: none;
    --material-filter-sidebar: none;
    --material-filter-overlay: none;
  }
}

/* Acabamento de material nos cards (sem blur): borda superior clara + leve variação de tom. */
:root[data-glass="glass"] :is(.card, .panel, .kpi-strip) {
  background-image: var(--material-tone);
  box-shadow: none;
}

@supports (backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px)) {
  :root[data-glass="glass"] .topbar {
    background: var(--material-chrome);
    -webkit-backdrop-filter: var(--material-filter-chrome);
    backdrop-filter: var(--material-filter-chrome);
    box-shadow: inset 0 1px 0 var(--material-edge);
  }
  /* Ações do cabeçalho e período ficam fora de card: ganham a placa para não ler direto sobre a textura. */
  :root[data-glass="glass"] .page-header :is(.btn:not(.btn-primary), .segmented) { background: var(--glass-plate); }
  :root[data-glass="glass"] .sidebar {
    background: var(--material-sidebar);
    -webkit-backdrop-filter: var(--material-filter-sidebar);
    backdrop-filter: var(--material-filter-sidebar);
    box-shadow: inset 0 1px 0 var(--material-edge);
  }
  @media (max-width: 1050px) {
    :root[data-glass="glass"] .sidebar {
      box-shadow: inset 0 1px 0 var(--material-edge), var(--shadow-pop);
    }
  }
  :root[data-glass="glass"] :is(.modal-card, .dialog-card, .toast, .dre-calendar-popover, .row-menu-pop, .a11y-popover) {
    background: var(--material-overlay);
    -webkit-backdrop-filter: var(--material-filter-overlay);
    backdrop-filter: var(--material-filter-overlay);
  }
  :root[data-glass="glass"] :is(.modal-card, .dialog-card, .row-menu-pop) {
    box-shadow: inset 0 1px 0 var(--material-edge), var(--shadow-modal);
  }
  :root[data-glass="glass"] :is(.toast, .dre-calendar-popover, .a11y-popover) {
    box-shadow: inset 0 1px 0 var(--material-edge), var(--shadow-pop);
  }
  /* Nunca vidro dentro de vidro: flutuante dentro do modal usa surface sólida. */
  :root[data-glass="glass"] .modal-card :is(.dre-calendar-popover, .row-menu-pop, .toast, .a11y-popover) {
    background: var(--surface-raised);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
  /* Cabeçalho/rodapé fixos do modal (sheet no celular, drawer no desktop) cobrem o conteúdo que rola. */
  @media (max-width: 700px) {
    :root[data-glass="glass"] .modal-card :is(.modal-header, .modal-footer) {
      background: var(--material-sticky);
    }
  }
  @media (min-width: 701px) {
    :root[data-glass="glass"] .modal-card--drawer .modal-footer {
      background: var(--material-sticky);
    }
    /* Materializar: opacidade + escala + blur do próprio material juntos, na entrada e na saída. */
    :root[data-glass="glass"] .modal-backdrop:not(.modal-backdrop--drawer) .modal-card {
      animation: modal-materialize-glass var(--t-base);
    }
    :root[data-glass="glass"] .modal-backdrop.is-closing:not(.modal-backdrop--drawer) .modal-card {
      animation: modal-dematerialize-glass var(--motion) var(--ease-in) forwards;
    }
  }
  /* Um ancestral com opacity < 1 viraria "backdrop root" e o modal não borraria a página:
     no vidro o scrim anima só a cor de fundo, nunca a opacidade. */
  :root[data-glass="glass"] .modal-backdrop {
    animation: scrim-in var(--t-base);
  }
  :root[data-glass="glass"] .modal-backdrop.is-closing {
    animation: scrim-out var(--motion) var(--ease-in) forwards;
  }
}

/* ==========================================================================
   Vidro (nível "glass", refeito em 31/10/2026). Só sob :root[data-glass="glass"] e dentro de
   @supports. Regras:
   1) fundo = cor lisa do tema (mais o fundo com LEDs, que vale também no Sem vidro: ver adiante);
   2) cards, painéis e KPIs: --surface a 78%, borda de 1px (a do próprio componente), sem blur, sem sombra;
   3) dados (tabelas, listas, grades) numa placa de 94%; campos seguem opacos;
   4) blur só em topbar, sidebar e overlays (tokens --material-* acima); nunca material dentro de material.
   O :is([data-theme]) sobe a especificidade para vencer o acabamento dos cards.
   ========================================================================== */
/* Fundo com LEDs (lib/fundo-leds-controle.js), nas duas aparências: o canvas só existe no DOM com data-fundo="leds"
   (ligado por padrão), sem alto contraste, sem "menos transparência" e sem contraste forçado. Fica atrás de tudo:
   o body fica transparente e a cor lisa do tema passa para body::before (z-index -1, depois do canvas na ordem do DOM).
   No Sem vidro os cards são opacos e o fundo aparece só nas margens; no Vidro aparece através dos cards (78%). */
:root[data-fundo="leds"] body { background: transparent; }
:root[data-fundo="leds"] body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: var(--bg);
}
canvas.fundo-leds { display: block; position: fixed; inset: 0; z-index: -1; width: 100%; height: 100%; pointer-events: none; }
/* Texto sobre o pior ponto (LED aceso) precisa de AA: com o fundo ligado, em QUALQUER aparência, o texto
   secundário/mudo e o link ficam mais fortes (mais claros no escuro, mais escuros no claro). Medido em
   tools/medir-contraste-vidro.py e tests/e2e/visual/fundo-contraste.pw.mjs. Fundo desligado, "menos transparência",
   contraste do SO e contraste forçado (onde o fundo não existe) mantêm os tokens normais. O botão de alto
   contraste do app mantém os LEDs (paleta forte) e, portanto, este reforço. */
@media not ((prefers-reduced-transparency: reduce) or (prefers-contrast: more) or (forced-colors: active)) {
  :root[data-fundo="leds"] {
    --text-secondary: #D5DCE6; --text-muted: #C2CBD8; --action: #9AD4FF; /* azul céu claro, 11,4:1 sobre surface (06/11/2026) */
  }
  :root[data-fundo="leds"][data-theme="light"] {
    --text-secondary: #283140; --text-muted: #323C4B; --action: #044870; /* azul profundo, 9,3:1 sobre surface (06/11/2026) */
  }
}
@media (prefers-reduced-transparency: reduce), (prefers-contrast: more), (forced-colors: active) {
  canvas.fundo-leds { display: none; }
}
@supports (backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px)) {
  /* .auth-card/.login-card entram no mesmo fill dos cards do app neste nível. */
  :root[data-glass="glass"]:is([data-theme="dark"], [data-theme="light"]) :is(.card, .panel, .kpi-strip, .kpi-card, .debt-card, .forecast-card, .dre-annual-detail, .auth-card, .login-card) {
    background: var(--glass-card-fill);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    box-shadow: none;
  }
  /* Placa de dados: fill alto, sem blur próprio. */
  :root[data-glass="glass"] :is(.dt-wrap, .data-table) { background: var(--glass-plate); border-radius: var(--r-md); }
  :root[data-glass="glass"] .dash-fixo-corpo .panel > .panel-head { background: var(--glass-plate); }
  /* DRE: indicadores e gráficos são dados densos; placa quase opaca, sem blur. */
  :root[data-glass="glass"] .dre-dash :is(.panel, .kpi-strip) { background: var(--glass-plate); -webkit-backdrop-filter: none; backdrop-filter: none; }
  @supports (animation-timeline: scroll()) {
    :root[data-glass="glass"] .dash-fixo-corpo .panel > .panel-head {
      background: transparent;
      animation: panel-head-fill 1ms linear both;
      animation-timeline: scroll(nearest);
      animation-range: 0 1px;
    }
  }
  /* Sem vidro dentro de vidro: superfície dentro de outra superfície (ou de overlay) vira placa. */
  :root[data-glass="glass"]:is([data-theme="dark"], [data-theme="light"]) :is(.card, .panel, .kpi-strip, .kpi-card, .debt-card, .forecast-card, .dre-annual-detail) :is(.card, .panel, .kpi-strip, .kpi-card, .debt-card, .forecast-card, .dre-annual-detail),
  :root[data-glass="glass"]:is([data-theme="dark"], [data-theme="light"]) :is(.modal-card, .dialog-card, .a11y-popover) :is(.card, .panel, .kpi-strip, .kpi-card, .debt-card, .forecast-card, .dre-annual-detail) {
    background: var(--glass-plate);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    box-shadow: none;
  }
  /* Scrim do modal: blur leve (4px) num filho atrás do card. O scrim em si não pode ter
     backdrop-filter: viraria "backdrop root" e o card não borraria a página. */
  :root[data-glass="glass"] .modal-backdrop::before {
    content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
    -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
  }
  /* Toast no vidro: texto em primário (cor semântica só na borda). */
  :root[data-glass="glass"] .toast { color: var(--text-primary); }
  /* Login/cadastro: o ambiente precisa aparecer atrás do formulário. */
  :root[data-glass="glass"] .login-form-side { background: transparent; }
  :root[data-glass="glass"] .login-brand {
    background: var(--material-sidebar);
    -webkit-backdrop-filter: var(--material-filter-sidebar);
    backdrop-filter: var(--material-filter-sidebar);
  }
}
/* Contraste forçado: sem ambiente e sem blur do scrim (o fill de 95% já vem dos tokens acima). */
@media (forced-colors: active) {
  :root[data-fundo] body::before,
  :root[data-glass] .modal-backdrop::before { display: none; }
}
@keyframes scrim-in { from { background-color: transparent; } }
@keyframes scrim-out { to { background-color: transparent; } }
@keyframes modal-materialize { from { opacity: 0; scale: 0.97; } to { opacity: 1; scale: 1; } }
@keyframes modal-materialize-glass {
  from { opacity: 0; scale: 0.97; -webkit-backdrop-filter: blur(0) saturate(100%); backdrop-filter: blur(0) saturate(100%); }
  to { opacity: 1; scale: 1; -webkit-backdrop-filter: var(--material-filter-overlay); backdrop-filter: var(--material-filter-overlay); }
}
@keyframes modal-dematerialize-glass {
  from { opacity: 1; scale: 1; -webkit-backdrop-filter: var(--material-filter-overlay); backdrop-filter: var(--material-filter-overlay); }
  to { opacity: 0; scale: 0.97; -webkit-backdrop-filter: blur(0) saturate(100%); backdrop-filter: blur(0) saturate(100%); }
}
/* Borda da topbar aparece só quando há conteúdo rolado por baixo (CSS puro, sem JS). */
@supports (animation-timeline: scroll()) {
  :root[data-glass="glass"] .topbar {
    border-bottom-color: transparent;
    animation: topbar-edge linear both;
    animation-timeline: scroll(root);
    animation-range: 0 48px;
  }
}
@keyframes topbar-edge { to { border-bottom-color: var(--border); } }
@keyframes panel-head-fill { from { background-color: transparent; } to { background-color: var(--glass-plate); } }
:root[data-motion="reduce"] .topbar { animation: none; border-bottom-color: var(--border); }

/* ==========================================================================
   Transições (F4): sem bounce, sem loop, sem parallax. Duração = --motion (0ms em reduce).
   lib/view-transition.js marca <html data-vt="theme|route"> só durante a transição.
   ========================================================================== */
:root[data-vt] { view-transition-name: none; }
:root[data-vt="theme"] :is(.app-content, .login-wrap) { view-transition-name: theme-content; }
:root[data-vt="theme"] .sidebar { view-transition-name: theme-sidebar; }
:root[data-vt="theme"] .lp-hero { view-transition-name: theme-hero; }
::view-transition-old(theme-content),
::view-transition-new(theme-content),
::view-transition-old(theme-sidebar),
::view-transition-new(theme-sidebar),
::view-transition-old(theme-hero),
::view-transition-new(theme-hero) {
  animation-duration: calc(var(--motion) * 1.5);
  animation-timing-function: var(--ease-out);
}
/* Snapshots não interceptam os cliques que podem interromper a troca atual. */
::view-transition,
::view-transition-group(*),
::view-transition-image-pair(*),
::view-transition-old(*),
::view-transition-new(*) { pointer-events: none; }
/* Rota: só a área de conteúdo faz cross-fade; topbar e sidebar continuam interativas. */
:root[data-vt="route"] .app-content { view-transition-name: app-content; }
:root[data-vt="route"]::view-transition-old(app-content) { animation: fade-out calc(var(--motion) * 0.8) ease-out forwards; }
:root[data-vt="route"]::view-transition-group(app-content) { animation: none; }
:root[data-vt="route"]::view-transition-old(app-content),
:root[data-vt="route"]::view-transition-new(app-content) {
  animation-duration: var(--motion);
  animation-timing-function: var(--ease-out);
}
/* Entrada do modal (desktop): materializa com opacidade + escala. A saída reaproveita modal-scale-out. */
@media (min-width: 701px) {
  .modal-backdrop:not(.modal-backdrop--drawer) .modal-card { animation: modal-materialize var(--t-base); }
}
/* "Reduzir movimento" escolhido em Aparência: mesmo corte do prefers-reduced-motion do SO. */
:root[data-motion="reduce"] *,
:root[data-motion="reduce"] *::before,
:root[data-motion="reduce"] *::after {
  scroll-behavior: auto !important;
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.01ms !important;
}
@keyframes popover-in { from { opacity: 0; scale: 0.96; } to { opacity: 1; scale: 1; } }
@keyframes popover-out { from { opacity: 1; scale: 1; } to { opacity: 0; scale: 0.96; } }

/* ==========================================================================
   Popover de acessibilidade (topbar). Fica fora da topbar (#popover-root): com vidro, um
   filho da topbar não conseguiria borrar a página. JS só informa --a11y-top/right/origin.
   ========================================================================== */
.a11y-popover {
  position: fixed; top: var(--a11y-top, 64px); right: var(--a11y-right, 16px); z-index: 300;
  width: min(344px, calc(100vw - 24px)); max-height: calc(100dvh - var(--a11y-top, 64px) - 12px); overflow-y: auto;
  padding: var(--s-4); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--r-lg); box-shadow: var(--shadow-pop);
  transform-origin: var(--a11y-origin, top right);
  animation: popover-in var(--motion) var(--ease-out);
}
.a11y-popover.is-closing { animation: popover-out var(--motion) var(--ease-in) forwards; }
/* Botão de tema das páginas públicas (login, cadastro): canto superior direito. No DOM vem
   logo após o skip link, então é o segundo item da ordem de Tab, antes dos campos. Some sem JS (vazio). */
.icon-btn.theme-corner {
  position: absolute; top: var(--s-3); right: var(--s-3); z-index: 10;
  width: var(--hit); height: var(--hit);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-pill);
}
.icon-btn.theme-corner:empty { display: none; }
.a11y-popover-title { margin: 0 0 var(--s-3); font-size: var(--fs-md); font-weight: 600; color: var(--text-primary); }
.a11y-popover .settings-aparencia { margin: 0; }
@media (max-width: 700px) {
  .a11y-popover {
    top: auto; left: 0; right: 0; bottom: 0; width: auto; max-height: 85dvh;
    padding-bottom: calc(var(--s-4) + env(safe-area-inset-bottom, 0px));
    border-width: 1px 0 0; border-radius: var(--r-xl) var(--r-xl) 0 0; box-shadow: var(--shadow-modal);
    transform-origin: bottom center;
    animation: sheet-up calc(var(--motion) * 1.75) var(--ease-out);
  }
  .a11y-popover.is-closing { animation: sheet-down var(--motion) var(--ease-in) forwards; }
}

/* ==========================================================================
   Precificacao empresarial
   ========================================================================== */
.pricing-page { max-width: 1440px; margin: 0 auto; }
.pricing-toolbar { display: grid; grid-template-columns: minmax(240px, 1fr) 220px auto; gap: 12px; align-items: end; margin-bottom: 16px; }
.pricing-toolbar .field { margin: 0; }
.pricing-table-card { overflow-x: auto; }
.pricing-subline { display: block; margin-top: 3px; color: var(--t2); }
.pricing-actions { text-align: right; white-space: nowrap; }
.pricing-management { display: grid; gap: 16px; margin-bottom: 16px; }
.pricing-management-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.pricing-grid-2, .pricing-grid-3 { display: grid; gap: 14px; }
.pricing-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.pricing-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.pricing-span-2 { grid-column: span 2; }
.pricing-span-3 { grid-column: span 3; }
.pricing-section-title { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; margin-bottom: 16px; }
.pricing-section-title :is(h2, h3) { margin: 0 0 4px; font-size: 1.1429rem; color: var(--t0); }
.pricing-section-title p { margin: 0; color: var(--t2); font-size: 1.0714rem; }
.pricing-inline-create { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-bottom: 10px; }
.pricing-function-create { grid-template-columns: 1fr 120px auto; }
.pricing-config-list { max-height: 240px; overflow: auto; }
.pricing-config-list li { display: flex; justify-content: space-between; gap: 12px; }
.pricing-config-list small { color: var(--t2); }
.pricing-summary-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 16px; }
.pricing-summary-grid .card { display: flex; flex-direction: column; gap: 8px; min-height: 132px; }
.pricing-big-number { color: var(--t0); font-size: clamp(22px, 2.5vw, 32px); line-height: 1.1; }
.pricing-text-number { font-size: 1.4286rem; }
.pricing-history { margin-top: 16px; }
.pricing-history-list { display: grid; gap: 10px; margin-top: 14px; }
.pricing-history-list article { display: flex; justify-content: space-between; gap: 16px; align-items: center; padding: 12px; border: 1px solid var(--b1); border-radius: var(--r-md); background: var(--s1); }
.pricing-history-list article > div { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pricing-history-list small { display: block; flex-basis: 100%; color: var(--t2); }
.pricing-steps { display: flex; gap: 6px; padding: 6px; margin-bottom: 14px; overflow-x: auto; border: 1px solid var(--b1); border-radius: var(--r-lg); background: var(--s1); }
.pricing-steps button { border: 0; background: transparent; color: var(--t2); border-radius: var(--r-md); padding: 9px 13px; white-space: nowrap; cursor: pointer; font: inherit; font-size: .8571rem; font-weight: 600; }
.pricing-steps button.active { color: var(--t0); background: var(--acc-bg); box-shadow: inset 0 0 0 1px var(--acc-bdr); }
.pricing-editor { min-height: 360px; }
.pricing-step { min-height: 300px; }
.pricing-component-list, .pricing-range-list { display: grid; gap: 10px; }
.pricing-component, .pricing-range { position: relative; display: grid; gap: 10px; align-items: start; padding-right: 48px; }
.pricing-component { grid-template-columns: 150px minmax(180px, 1.4fr) repeat(3, minmax(120px, .8fr)); }
.pricing-range { grid-template-columns: 30px repeat(4, minmax(130px, 1fr)); align-items: center; }
.pricing-component .field, .pricing-range .field { margin: 0; }
.pricing-remove { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); }
.pricing-range-index { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; color: var(--accent); background: var(--acc-bg); font-weight: 700; }
.pricing-dre-reference { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; padding: 14px; }
.pricing-dre-reference span { color: var(--t2); font-size: 1.0714rem; }
.pricing-editor-footer { position: sticky; bottom: 12px; z-index: 12; display: flex; justify-content: space-between; gap: 14px; align-items: center; margin-top: 14px; padding: 12px 16px; border: 1px solid var(--border-strong); border-radius: var(--r-lg); background: var(--surface-raised); }
.pricing-editor-footer > div, .pricing-publish-controls { display: flex; align-items: flex-end; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.pricing-publish-controls label { display: flex; flex-direction: column; gap: 3px; color: var(--t2); font-size: .8571rem; }
.pricing-publish-controls input { min-width: 190px; }
.pricing-result-action { display: flex; justify-content: flex-end; margin-top: 14px; }
.pricing-result-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.pricing-result-grid article { display: grid; gap: 10px; padding: 15px; border: 1px solid var(--b1); border-radius: var(--r-lg); background: var(--s1); }
.pricing-result-grid article > div { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.pricing-result-grid small { color: var(--t2); }
.pricing-result-grid strong { color: var(--t0); }
.pricing-result-grid .pricing-highlight { padding-top: 10px; border-top: 1px solid var(--b1); }
.pricing-result-grid .pricing-highlight strong { color: var(--t0); font-size: 1.4286rem; }

@media (max-width: 1050px) {
  .pricing-component { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pricing-range { grid-template-columns: 30px repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 700px) {
  .pricing-toolbar, .pricing-management-grid, .pricing-grid-2, .pricing-grid-3, .pricing-summary-grid { grid-template-columns: 1fr; }
  .pricing-span-2, .pricing-span-3 { grid-column: span 1; }
  .pricing-table thead { display: none; }
  .pricing-table, .pricing-table tbody, .pricing-table tr, .pricing-table td { display: block; width: 100%; }
  .pricing-table tr { margin-bottom: 12px; padding: 12px; border: 1px solid var(--b1); border-radius: var(--r-lg); background: var(--s1); }
  .pricing-table td { display: flex; justify-content: space-between; gap: 14px; padding: 7px 0 !important; border: 0 !important; text-align: right; }
  .pricing-table td::before { content: attr(data-label); color: var(--t2); font-size: .8571rem; text-align: left; }
  .pricing-table td:first-child { display: block; text-align: left; }
  .pricing-table td:first-child::before, .pricing-table .table-empty::before { display: none; }
  /* Estado vazio no celular: bloco de largura total, sem o flex de rótulo/valor das células (revisão de UI #2). */
  .pricing-table.data-table { min-width: 0; } /* a regra global de .data-table (min-width 640px) estourava o cartão */
  .pricing-table td.table-empty { display: block; text-align: center; }
  .pricing-table td.table-empty .empty-state { width: 100%; white-space: normal; }
  .pricing-actions { justify-content: flex-end !important; }
  .pricing-function-create { grid-template-columns: 1fr 110px; }
  .pricing-function-create button { grid-column: span 2; }
  .pricing-component, .pricing-range { grid-template-columns: 1fr; padding-top: 42px; padding-right: 14px; }
  .pricing-range-index { position: absolute; top: 10px; left: 12px; }
  .pricing-remove { top: 12px; right: 12px; transform: none; }
  .pricing-dre-reference { grid-template-columns: 1fr; }
  .pricing-editor-footer { position: static; flex-direction: column; align-items: stretch; }
  .pricing-editor-footer > div, .pricing-publish-controls { justify-content: stretch; }
  .pricing-editor-footer button { flex: 1; }
  .pricing-publish-controls label { width: 100%; }
  .pricing-publish-controls input { width: 100%; }
  .pricing-history-list article { align-items: flex-start; flex-direction: column; }
}

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

html, body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--t0);
  font-family: var(--font-body);
  font-size: 100%;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background: var(--bg);
  min-height: 100vh;
}

/* === Animations === */
@keyframes fade-up   { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:none; } }
@keyframes fade-in   { from { opacity:0; } to { opacity:1; } }
@keyframes spin      { to { transform: rotate(360deg); } }
.btn:hover { background: var(--surface-interaction); border-color: var(--text-muted); }
.btn:disabled { opacity: 0.62; cursor: not-allowed; }
button:not(:disabled):active,
[role="button"]:active {
  transform: scale(.98);
  transition: transform var(--t-instant);
}
.btn-lg { height: 44px; padding: 0 20px; font-size: 1rem; }
.btn-danger { background: var(--red-bg); color: var(--red); border-color: var(--red-bdr); }
.card-title {
  font-size: .8571rem; font-weight: 600; color: var(--t1);
}
.input, .select, .textarea {
  height: 40px; padding: 0 14px; border-radius: var(--r-md);
  border: 1px solid var(--border-input); background: var(--surface-raised); color: var(--t0);
  font-family: var(--font-body); font-size: 1rem;
  transition: border-color var(--t-fast), background var(--t-fast);
}
/* Sem outline/box-shadow aqui: o anel vem da regra global :focus-visible (~:2181). */
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--accent); background: var(--s3);
}
.input[readonly] {
  background: var(--fill-wash); color: var(--t2); border-style: dashed; cursor: default;
}
.input[readonly]:focus { border-color: var(--b1); background: var(--fill-wash); }
.textarea { height: auto; min-height: 100px; padding: 12px 14px; resize: vertical; }
.field-hint { font-size: 1.0714rem; color: var(--t2); }
/* Aviso com atalho (ex.: lançamento sem conta bancária): texto e botão quebram linha juntos em 375px. */
.field-hint--acao { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: .8571rem; }
.field-error-text { color: var(--red); }
.field-error-text:empty { display: none; }
.input[aria-invalid="true"] { border-color: var(--red); }

/* Campo de senha com botão Mostrar/Ocultar (lib/pw-toggle.js). Login e cadastro repetem a regra inline. */
.pw-field { display: block; position: relative; }
.pw-toggle {
  position: absolute; right: 6px; top: 0; bottom: 0; margin: auto 0;
  width: 72px; height: var(--hit); padding: 0; border-radius: var(--r-sm);
  background: transparent; border: none; color: var(--t2);
  font-size: var(--fs-xs); font-weight: 600; cursor: pointer; transition: color var(--t-fast);
}
.pw-toggle:hover { color: var(--accent); }
.pw-toggle:not(:disabled):active { transform: none; }
.pw-field .input { padding-right: 84px; }

/* === Values === */
.valor-positivo { color: var(--green); font-variant-numeric: tabular-nums; font-weight: 500; }
.valor-negativo { color: var(--red);   font-variant-numeric: tabular-nums; font-weight: 500; }
.valor-neutro   { color: var(--t0);    font-variant-numeric: tabular-nums; font-weight: 500; }
.valor-grande   { font-family: var(--font-head); font-size: 1.5714rem; font-weight: 500; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.valor-gigante  { font-family: var(--font-head); font-size: 2.2857rem; font-weight: 500; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.badge-dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }

/* === Trends === */
.trend {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: var(--r-pill);
  font-size: .8571rem; font-weight: 600;
}
.trend-up   { background: var(--green-bg); color: var(--green); }
.trend-down { background: var(--red-bg);   color: var(--red); }
.trend-flat { background: var(--s2);        color: var(--t1); }

/* === Layout shells === */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: 1fr;
  min-height: 100vh;
}
.app-main {
  display: flex; flex-direction: column;
  min-width: 0;
  background: transparent;
}

/* === Sidebar === */
.sidebar {
  background: var(--bg-structural);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: var(--s-6) var(--s-3) var(--s-3);
  gap: var(--s-4);
  position: sticky; top: 0; height: 100vh;
  overflow-y: auto;
}
.sidebar-logo {
  display: flex; align-items: center; gap: 10px;
  padding: 0 10px;
  font-size: var(--fs-lg); font-weight: 600; letter-spacing: -0.5px;
  color: var(--text-primary);
}
/* A marca e o atalho para a visao geral. Fica como <button> com data-action (e
   nao como <a>) para reusar a mesma acao de navegacao dos itens de menu: assim
   o guard de alteracoes nao salvas da precificacao tambem vale aqui.
   Sem padding vertical nem min-height para o cabecalho nao crescer: a linha
   continua com a altura da marca. O alvo de toque vem da regra --hit no
   mobile, onde .sidebar-logo ja e alto. */
.sidebar-logo-home {
  display: flex; align-items: center; gap: 10px;
  flex: 1; min-width: 0;
  margin: 0 -6px; padding: 0 6px;
  border: 0; border-radius: var(--r-sm);
  background: transparent; appearance: none;
  font: inherit; text-align: left;
  cursor: pointer;
  transition: background-color var(--t-fast);
}
.sidebar-logo-home:hover { background: var(--surface-interaction); }
.sidebar-logo-mark {
  position: relative; flex-shrink: 0;
  width: 30px; height: 30px; border-radius: var(--r-sm);
  background: transparent;
  display: flex; align-items: center; justify-content: center;
  font-size: var(--fs-xs); font-weight: 700; letter-spacing: -0.5px; color: transparent;
}
.sidebar-logo-mark::before {
  content: ''; position: absolute; inset: 0;
  background: var(--text-primary);
  -webkit-mask: url('./lib/brand/cf-finance-symbol.svg?v=20261005-logo4') center / 130% 130% no-repeat;
  mask: url('./lib/brand/cf-finance-symbol.svg?v=20261005-logo4') center / 130% 130% no-repeat;
}
.icon-btn.sidebar-close { display: none; margin-left: auto; }
.sidebar-section { display: flex; flex-direction: column; gap: 4px; }
.sidebar-section-title {
  font-size: var(--fs-2xs); font-weight: 600; color: var(--text-muted);
  padding: 0 10px var(--s-1);
}
.sidebar-link {
  display: flex; align-items: center; gap: 10px;
  width: 100%; text-align: left; appearance: none;
  min-height: 36px; padding: var(--s-2) 10px; border-radius: var(--r-md);
  color: var(--text-secondary); font-family: inherit; font-size: var(--fs-sm); font-weight: 400; line-height: inherit;
  cursor: pointer; transition: background-color var(--t-fast), border-color var(--t-fast), color var(--t-fast);
  text-decoration: none; background: transparent;
  border: 1px solid transparent;
}
.sidebar-link:hover { background: var(--surface-interaction); color: var(--text-primary); }
/* Item ativo em cinza (a cor de destaque fica reservada às ações). */
.sidebar-link.active {
  background: var(--surface-raised); color: var(--text-primary); font-weight: 500;
  border-color: transparent;
}
/* Só a lista de navegação rola; marca, contexto e perfil ficam fixos (gabarito). */
.sidebar-nav {
  flex: 1; display: flex; flex-direction: column; gap: var(--s-4); min-height: 0;
  margin: 0 calc(var(--s-1) * -1); padding: 0 var(--s-1); overflow-y: auto;
  /* Indicio de rolagem so em CSS: as camadas "local" cobrem a borda na cor do fundo da
     sidebar e a deixam ao rolar; as camadas "scroll" (filete + degrade sutil) ficam fixas
     e so aparecem onde ha conteudo alem da borda. */
  background: transparent;
}
.sidebar-context {
  display: flex; align-items: center; gap: var(--s-2); width: 100%;
  padding: 10px var(--s-3); text-align: left;
  border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--surface); color: var(--text-primary); font: inherit;
}
.sidebar-context.is-clickable { cursor: pointer; transition: background var(--motion) var(--ease-out); }
.sidebar-context.is-clickable:hover { background: var(--surface-interaction); }
.sidebar-context-text { flex: 1; min-width: 0; }
.sidebar-context-text b,
.sidebar-profile-text b {
  display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: var(--fs-sm); font-weight: 600;
}
.sidebar-context-text span,
.sidebar-profile-text span {
  display: block; margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: var(--fs-2xs); color: var(--text-muted);
}
.sidebar-context-go { flex: none; color: var(--text-muted); }
.sidebar-profile {
  display: flex; align-items: center; gap: var(--s-1);
  margin-top: auto; padding-top: var(--s-3); border-top: 1px solid var(--border);
}
.sidebar-profile-main {
  display: flex; flex: 1; align-items: center; gap: 10px; min-width: 0;
  padding: var(--s-1) 6px; border: 0; border-radius: var(--r-sm);
  background: none; color: var(--text-primary); font: inherit; text-align: left;
}
.sidebar-profile-main.is-clickable { cursor: pointer; }
.sidebar-profile-main.is-clickable:hover { background: var(--surface-interaction); }
.sidebar-profile-text { flex: 1; min-width: 0; }
.sidebar-avatar {
  flex: none; display: grid; place-items: center; width: 30px; height: 30px;
  border-radius: 50%; background: var(--surface-interaction);
  font-size: var(--fs-2xs); font-weight: 600; color: var(--text-secondary);
}
.icon-btn {
  flex: none; display: inline-grid; place-items: center; width: 38px; height: 38px;
  border: 0; border-radius: var(--r-sm); background: none; cursor: pointer;
  color: var(--text-secondary); text-decoration: none;
  transition: background var(--motion) var(--ease-out), color var(--motion) var(--ease-out);
}
.topbar .icon-btn { width: var(--hit); height: var(--hit); }
.icon-btn:hover { background: var(--surface-interaction); color: var(--text-primary); }
.icon-btn[aria-pressed="true"] { background: var(--action-soft); color: var(--action); }
.topbar-crumbs {
  display: flex; align-items: center; gap: 6px; min-width: 0;
  font-size: var(--fs-md); color: var(--text-muted);
}
@media (min-width: 768px) {
  .topbar-crumbs { font-size: 1rem; }
}
.topbar-crumbs b {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-weight: 500; color: var(--text-primary);
}
.topbar-tools { display: flex; align-items: center; gap: var(--s-2); flex: none; margin-left: auto; }
.sidebar-userbox {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; border-radius: var(--radius-control);
  border: 1px solid transparent;
}
.sidebar-userbox-clickable { cursor: pointer; transition: background-color var(--t-fast), border-color var(--t-fast); }
.sidebar-userbox-clickable:hover { background: var(--s2); border-color: var(--b1); }
.sidebar-userbox-clickable:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.sidebar-user-gear { display: inline-flex; color: var(--t2); line-height: 1; flex-shrink: 0; }
.sidebar-userbox-clickable:hover .sidebar-user-gear { color: var(--t0); }
.sidebar-link-icon { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; width: 18px; height: 18px; opacity: 0.9; }
.sidebar-link-icon svg,
.sidebar-user-gear svg,
.dv-empty-ic svg { display: block; }
.sidebar-link-count {
  margin-left: auto;
  background: var(--s3); color: var(--t1);
  padding: 1px 7px; border-radius: var(--radius-control);
  font-size: .8571rem; font-weight: 700;
}

/* Botao de alternar ambiente (Pessoal x Empresarial) — so usuario hibrido.
   Deliberadamente NAO herda a aparencia neutra de .sidebar-link: precisa
   parecer um controle/interruptor, nao mais um link de pagina, e a cor muda
   com o ambiente ativo (reforco visual p/ nao confundir onde o dado cai). */
.sidebar-ambiente-toggle {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 9px 12px; border-radius: var(--radius-control);
  font-size: .9286rem; font-weight: 700; cursor: pointer;
  transition: background-color var(--t-fast), border-color var(--t-fast), color var(--t-fast), transform var(--t-fast);
  border-width: 1px; border-style: solid;
}
.sidebar-ambiente-toggle-empresarial {
  color: var(--accent); background: var(--acc-bg); border-color: var(--acc-bdr);
}
.sidebar-ambiente-toggle-empresarial:hover { background: var(--action-soft); }
.sidebar-ambiente-toggle-pessoal {
  color: var(--yellow); background: var(--yellow-bg); border-color: var(--yellow-bdr);
}
.sidebar-ambiente-toggle-pessoal:hover { background: var(--yellow-bg); }

/* Badge de contexto no topo dos modais de lancamento/cadastro — mesma
   convencao de cor do toggle da sidebar (ciano=empresarial, amarelo=pessoal),
   pra ficar claro em qual ambiente aquele registro vai cair. */
.modal-workspace-badge {
  display: inline-flex; align-items: center; gap: 6px;
  margin: 0 18px 4px; padding: 4px 10px; width: fit-content;
  border-radius: var(--radius-control); font-size: .8571rem; font-weight: 700;
}
.modal-workspace-badge-empresarial {
  color: var(--accent); background: var(--acc-bg); border: 1px solid var(--acc-bdr);
}
.modal-workspace-badge-pessoal {
  color: var(--yellow); background: var(--yellow-bg); border: 1px solid var(--yellow-bdr);
}

/* === Topbar === */
.topbar {
  height: var(--header-h);
  display: flex; align-items: center; gap: var(--s-4);
  padding: 0 var(--s-8); border-bottom: 1px solid var(--border);
  background: var(--topbar-glass); /* canvas a 85% (tokens) */

  position: sticky; top: 0; z-index: 50;
}
.topbar-left, .topbar-right {
  display: flex; align-items: center; gap: 12px;
}
/* Navegacao mobile: hamburger + backdrop ficam ocultos no desktop (sidebar fixa). */
.nav-toggle { display: none; }
.nav-backdrop { display: none; }

/* === Grids === */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}
.grid-2        { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
.grid-2-equal  { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 1050px) {
  .grid-2, .grid-2-equal { grid-template-columns: 1fr; }
  .app-shell { grid-template-columns: 1fr; }
  /* Sidebar vira drawer off-canvas; o hamburger no topbar abre/fecha. */
  .nav-toggle {
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 1.2857rem; line-height: 1; padding: 6px 11px;
  }
  .sidebar {
    position: fixed; top: 0; left: 0; z-index: 200;
    width: min(82vw, 300px); height: 100vh;
    transform: translateX(-100%);
    transition: transform var(--t-slow);
    box-shadow: var(--shadow-pop);
  }
  body.nav-open .sidebar { transform: translateX(0); }
  /* Sempre no DOM no mobile: o fade de entrada e saida vem de opacity + visibility. */
  .nav-backdrop {
    display: block; position: fixed; inset: 0; z-index: 150;
    background: var(--backdrop);
    opacity: 0; visibility: hidden; pointer-events: none;
    transition: opacity var(--t-slow), visibility var(--t-slow);
  }
  body.nav-open .nav-backdrop { opacity: 1; visibility: visible; pointer-events: auto; }
}
@media (max-width: 420px) {
  /* Phone: enxuga o topbar pra nao transbordar (mantem hamburger + acoes). */
  .topbar { padding: 0 14px; gap: 8px; }
  .topbar-left .page-subtitle { display: none; }
  .topbar-empresa .page-subtitle { display: none; }
  .topbar-empresa select { min-width: 120px !important; }
}

/* === List Row (transacoes, faturas, etc) === */
.list-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 4px;
  border-bottom: 1px solid var(--b0);
}
.list-row:last-child { border-bottom: none; }
.list-row-icon {
  width: 32px; height: 32px; border-radius: var(--radius-control);
  display: flex; align-items: center; justify-content: center;
  font-size: .9286rem; flex-shrink: 0;
}
.list-row-icon.success { background: var(--green-bg); color: var(--green); }
.list-row-icon.danger  { background: var(--red-bg);   color: var(--red); }
.list-row-icon.warning { background: var(--yellow-bg); color: var(--yellow); }
.list-row-icon.primary { background: var(--acc-bg);   color: var(--accent); }
.list-row-icon.purple  { background: var(--violet-bg); color: var(--violet); }
.list-row-main { flex: 1; min-width: 0; }
.list-row-title { font-size: .9286rem; color: var(--t0); font-weight: 500; }
.list-row-sub {
  font-size: .8571rem; color: var(--t2);
  display: flex; align-items: center; gap: 6px; margin-top: 2px;
}
.list-row-sub .dot { width: 2px; height: 2px; border-radius: 50%; background: var(--t3); }
.list-row-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.list-row-value { font-size: .9286rem; font-variant-numeric: tabular-nums; }
.toast.success { border-color: var(--green-bdr); }
.toast.error   { border-color: var(--red-bdr); }
/* === Auth shell === */
.auth-shell {
  min-height: 100vh;
  display: grid; place-items: center;
  padding: 24px;
}
.auth-card {
  width: 100%; max-width: 400px;
  padding: 32px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: none;
}
.auth-logo {
  display: flex; align-items: center; gap: 10px; margin-bottom: 24px;
  font-family: var(--font-head); font-size: 1.2857rem; font-weight: 700;
}
.auth-title { font-family: var(--font-head); font-size: 1.5714rem; font-weight: 500; letter-spacing: -0.02em; margin-bottom: 6px; }
.auth-subtitle { font-size: 1.0714rem; color: var(--t1); margin-bottom: 24px; }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-submit { margin-top: 6px; height: 44px; }
.auth-error {
  padding: 10px 12px; border-radius: var(--r);
  background: var(--red-bg); color: var(--red);
  border: 1px solid var(--red-bdr);
  font-size: .8929rem; margin-bottom: 14px;
}
.auth-switch {
  margin-top: 16px; text-align: center;
  font-size: .8571rem; color: var(--t2);
}

/* === Seleção de ambiente (views/ambiente-view.js) — cartões, não botões sólidos === */
.ambiente-card { width: 100%; max-width: 420px; padding: 28px; }
.ambiente-head { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 18px; }
.ambiente-head .sidebar-logo-mark { flex: 0 0 auto; width: 36px; height: 36px; font-size: .9286rem; }
.ambiente-head-text h3 { color: var(--t0); font-size: 1.2143rem; font-weight: 650; margin-bottom: 4px; }
.ambiente-head-text .muted { font-size: 1.0714rem; line-height: 1.5; }
.ambiente-erro {
  padding: 10px 12px; margin-bottom: 14px; border-radius: var(--radius-control);
  background: var(--red-bg); color: var(--red); border: 1px solid var(--red-bdr);
  font-size: .8929rem;
}
.ambiente-search { position: relative; display: block; margin-bottom: 12px; }
.ambiente-search-icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--t2); display: inline-flex; pointer-events: none;
}
.ambiente-search .input { width: 100%; padding-left: 36px; }
.ambiente-options {
  display: flex; flex-direction: column; gap: 6px; max-height: 320px; overflow-y: auto;
  margin: 0 -4px; padding: 0 4px 2px;
}
.ambiente-option {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 11px 12px; border-radius: var(--radius-control);
  border: 1px solid var(--b1); background: var(--s1); color: var(--t0);
  cursor: pointer; transition: border-color var(--t-fast), background var(--t-fast);
}
.ambiente-option:hover { border-color: var(--b3); background: var(--s2); }
.ambiente-option:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ambiente-option-icon {
  flex: 0 0 auto; display: grid; place-items: center; width: 34px; height: 34px;
  border-radius: var(--radius-control); background: var(--s2); color: var(--t1);
}
.ambiente-option:hover .ambiente-option-icon { color: var(--accent); }
.ambiente-option-body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ambiente-option-title {
  font-size: .9643rem; font-weight: 600; color: var(--t0);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ambiente-option-sub { font-size: .8571rem; color: var(--t2); }
.ambiente-option-badge { align-self: flex-start; padding: 1px 8px; font-size: .8571rem; cursor: inherit; }
.ambiente-option-arrow {
  flex: 0 0 auto; width: 7px; height: 7px; margin-right: 2px;
  border-right: 1.5px solid var(--t2); border-bottom: 1.5px solid var(--t2);
  transform: rotate(-45deg);
}
.ambiente-foot {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--b1);
}
@media (max-width: 420px) {
  .ambiente-card { padding: 20px; }
  .ambiente-options { max-height: 60vh; }
}

/* === Loading === */
.loading {
  display: inline-block; width: 18px; height: 18px;
  border: 2px solid var(--b2); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
/* Dentro do botão primário o azul do spinner some no fundo azul: segue a cor do texto. */
.btn-primary .loading { border-color: color-mix(in srgb, currentColor 35%, transparent); border-top-color: currentColor; }
/* Reduce motion: em vez de congelar, pulso lento de opacidade. O !important com
   seletor de classe vence a regra global de reduce (*, animation-duration 0.01ms !important). */
@media (prefers-reduced-motion: reduce) {
  .loading {
    border-color: var(--accent);
    animation: skeleton-pulse 1.6s var(--ease-out) infinite alternate !important;
  }
  .btn-primary .loading { border-color: currentColor; }
}
:root[data-motion="reduce"] .loading {
  border-color: var(--accent);
  animation: skeleton-pulse 1.6s var(--ease-out) infinite alternate !important;
}
:root[data-motion="reduce"] .btn-primary .loading { border-color: currentColor; }

/* ============================================================================
   Componentes v3 — adicionados para o frontend funcional
   ============================================================================ */

/* === Page header === */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 16px;
  flex-wrap: wrap;
}
.page-title {
  font-family: var(--font-head);
  font-size: 1.5714rem;
  font-weight: 500;
  color: var(--t0);
  letter-spacing: -0.01em;
}
.page-subtitle {
  font-size: 1.0714rem;
  color: var(--t1);
  margin-top: 4px;
}
.page-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* === KPI cards === */
.kpi-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px; margin-bottom: 20px;
}
.kpi-card {
  background: var(--s1); border: 1px solid var(--b1); border-radius: var(--r-lg);
  padding: 16px; display: flex; flex-direction: column; gap: 6px;

}
.kpi-label { font-size: .8571rem; color: var(--t2); }
.kpi-value { font-family: var(--font-head); font-size: 1.7143rem; font-weight: 500; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; color: var(--t0); }
.kpi-hint  { font-size: .8571rem; color: var(--t2); }
.kpi-primary .kpi-value { color: var(--t0); }
.kpi-success .kpi-value { color: var(--green); }
.kpi-danger  .kpi-value { color: var(--red); }
.kpi-warning .kpi-value { color: var(--yellow); }
.kpi-info    .kpi-value { color: var(--t0); }
/* Card simples: sem linha de contexto/slot visual vazios nem margem extra do cabeçalho. */
.kpi-card:not(.kpi-rich) > :is(.kpi-hint, .kpi-chart-area):empty { display: none; }
.kpi-card:not(.kpi-rich) > .kpi-rich-head { margin-bottom: 0; }

.card {
  background: var(--s1);
  border: 1px solid var(--b1);
  border-radius: var(--r-lg);
  padding: 16px;
  box-shadow: none;

  position: relative;
  margin-bottom: 16px;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 8px;
}
.card-header h2, .card-header h3 { font-family: var(--font-head); font-size: 1rem; color: var(--t0); font-weight: 500; }
.card-footer {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--b1);
  font-size: .8929rem;
  color: var(--t1);
}

/* === Grid layouts === */
.grid-2col { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 16px; }
.grid-3col { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }

/* === Empty state === */
.empty-state {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 32px; text-align: center;
}
.empty-state :is(h2, h3) { color: var(--t0); font-size: 1.0714rem; }
/* Subtítulo de seção (h2 sob o h1 da página; mantém o tamanho do antigo h3). */
.sec-title { font-size: 1.1429rem; }
.empty-state p { color: var(--t2); font-size: 1.0714rem; max-width: 380px; }
.empty-state-sm { color: var(--t2); padding: 16px; text-align: center; font-size: 1.0714rem; }
.empty-icon { font-size: 2rem; color: var(--t2); }

/* === Lists === */
.list-clean { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.list-clean li {
  display: flex; align-items: center; gap: 10px; padding: 8px;
  border-radius: var(--r); transition: background-color var(--t-fast);
}
.list-clean li:hover { background: var(--s2); }
.list-clean .grow { flex: 1; min-width: 0; }
.list-clean small.muted { color: var(--t2); font-size: .8571rem; }

/* === Dots === */
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex-shrink: 0; }
.dot-lg { display: inline-block; width: 12px; height: 12px; border-radius: 50%; background: var(--accent); flex-shrink: 0; }
.dot-success { background: var(--green); }
.dot-danger  { background: var(--red); }

/* === Tables === */
.data-table { width: 100%; border-collapse: separate; border-spacing: 0; } /* separate: o raio do hover vale nas células */
.data-table thead th {
  text-align: left; font-size: var(--fs-xs); font-weight: 500;
  color: var(--text-muted); padding: 8px; border-bottom: 1px solid var(--border);
}
.data-table td { padding: 10px 8px; border-bottom: 1px solid var(--border); font-size: .9286rem; color: var(--t0); }
.data-table tbody tr:hover td { background: var(--s2); }
/* Pontas arredondadas no hover (mesmo raio do .dt); o modo cartão do celular desfaz abaixo. */
.data-table tbody tr:hover td:first-child { border-top-left-radius: var(--r-md); border-bottom-left-radius: var(--r-md); }
.data-table tbody tr:hover td:last-child { border-top-right-radius: var(--r-md); border-bottom-right-radius: var(--r-md); }
.table-empty { color: var(--t2); text-align: center; padding: 24px !important; font-style: italic; }
/* Grupo de ações de uma linha de tabela (ex.: Receber / Editar / Excluir) */
.row-actions { display: inline-flex; align-items: center; gap: 6px; flex-wrap: nowrap; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 10px;
  border-radius: var(--r-pill);
  font-size: .8571rem;
  font-weight: 500;
}
.badge-success { background: var(--green-bg);  color: var(--green);  border: 1px solid transparent; }
.badge-warning { background: var(--yellow-bg); color: var(--yellow); border: 1px solid transparent; }
.badge-danger  { background: var(--red-bg);    color: var(--red);    border: 1px solid transparent; }
.badge-info    { background: var(--action-soft); color: var(--accent); border: 1px solid transparent; }
.badge-neutral { background: var(--s2);        color: var(--t1);     border: 1px solid transparent; }

/* === Filter chips === */
.filter-bar { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.chip {
  background: var(--s1); border: 1px solid var(--b1); color: var(--t1);
  padding: 6px 14px; border-radius: var(--r-pill); font-size: .8571rem; cursor: pointer;
  transition: background-color var(--t-fast), border-color var(--t-fast), color var(--t-fast);
}
.chip:hover { color: var(--t0); border-color: var(--b2); }
.chip.active { background: var(--surface-interaction); color: var(--text-primary); border-color: var(--border-strong); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 40px;
  padding: var(--s-2) var(--s-4);
  border-radius: var(--r-pill);
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--text-primary);
  font-family: inherit;
  font-size: var(--fs-sm);
  font-weight: 500;
  cursor: pointer;
  transition: background-color var(--t-fast), border-color var(--t-fast), color var(--t-fast), filter var(--t-fast);
  user-select: none;
}
.btn-primary {
  background: var(--action-fill);
  background-image: var(--grad-acao);
  color: var(--on-action);
  border-color: transparent;
}
/* Hover sem sombra e sem filter: mistura o preenchimento violeta com o canvas (15%): apaga no escuro e
   clareia no claro. */
.btn-primary:hover { background-color: color-mix(in srgb, var(--action-fill) 85%, var(--bg-app)); background-image: var(--grad-acao-hover); border-color: transparent; }
.btn-ghost {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--text-primary);
}
.btn-ghost:hover { background: var(--surface-interaction); border-color: var(--text-muted); }
.btn-success { background: var(--green-bg); color: var(--green); border-color: var(--green-bdr); }
.btn-success:hover { background: var(--green); color: var(--bg-app); }
.btn-sm {
  height: 32px;
  padding: 5px 14px;
  font-size: .8571rem;
}
.btn-icon {
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: var(--r-pill);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--t2);
  cursor: pointer;
  transition: background-color var(--t-fast), color var(--t-fast), transform var(--t-fast);
  font-size: 1rem;
}
.btn-icon:hover { background: var(--s2); color: var(--accent); border-color: var(--b1); }
.btn-icon.is-danger:hover { color: var(--red); }

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.field-label {
  font-size: .8571rem;
  font-weight: 600;
  color: var(--t1);
}
.input {
  width: 100%; padding: 10px 12px; border-radius: var(--r-md);
  border: 1px solid var(--border-input); background: var(--surface-raised);
  color: var(--t0); font-size: .9643rem; font-family: inherit;
  transition: border-color var(--t-fast), background-color var(--t-fast), box-shadow var(--t-fast); min-height: 40px;
}
/* Anel de foco vem da regra global :focus-visible (outline + --ui-focus-ring). */
.input:focus {
  border-color: var(--accent); background: var(--surface-raised);
}

/* === Segmented control === */
.seg { display: flex; gap: 4px; background: var(--s2); padding: 4px; border-radius: var(--r-pill); margin-bottom: 16px; }
.seg-btn {
  flex: 1; padding: 8px; border-radius: var(--r-pill); background: transparent;
  border: none; color: var(--t1); font-weight: 500; cursor: pointer; font-size: .9286rem;
  font-family: inherit; transition: background-color var(--t-fast), color var(--t-fast);
}
.seg-btn.active { background: var(--surface-interaction); color: var(--text-primary); }
@media (forced-colors: active) {
  .seg-btn:is(.active, [aria-pressed="true"]) {
    forced-color-adjust: none;
    background: Highlight;
    color: HighlightText;
    outline: 1px solid Highlight;
  }
}

/* Modal ou diálogo aberto: o fundo não rola (JS marca o body em syncNavigationState). */
body.overlay-open { overflow: hidden; }
.modal-backdrop {
  overscroll-behavior: contain;
  position: fixed;
  inset: 0;
  z-index: 999;
  background: var(--backdrop);

  display: grid;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fade-in var(--t-base);
  place-items: center;
}
.modal-card {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-lg);
  width: min(560px, 100%);
  max-width: 540px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-modal);
  animation: fade-up var(--t-base);
  overflow-y: auto;
}
/* Saida espelha a entrada (fade-up ao contrario), mesma duracao no backdrop e no card. */
.modal-backdrop.is-closing { animation: fade-out var(--motion) var(--ease-in) forwards; pointer-events: none; }
.modal-backdrop.is-closing .modal-card { animation: modal-scale-out var(--motion) var(--ease-in) forwards; }
@keyframes fade-out { from { opacity: 1; } to { opacity: 0; } }
@keyframes modal-scale-out { from { opacity: 1; scale: 1; } to { opacity: 0; scale: 0.97; } }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--b1);
}
.modal-title {
  font-family: var(--font-head);
  font-size: 1.1429rem;
  font-weight: 500;
  color: var(--t0);
}
.modal-error-slot:not(:empty) {
  margin: 14px 20px 0; padding: 10px 12px; border: 1px solid var(--red-bdr);
  border-radius: var(--r); background: var(--red-bg); color: var(--red);
  font-size: .8929rem; line-height: 1.4;
}
.modal-error-slot p { margin: 0; }
.modal-error-slot ul { margin: 6px 0 0; padding-left: 18px; }
.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}
.modal-footer {
  display: flex; gap: 8px; justify-content: flex-end;
  padding: 16px 20px; border-top: 1px solid var(--b1); margin-top: 8px;
}

/* === Progress bar === */
.progress {
  width: 100%; height: 8px; background: var(--s2); border-radius: 999px; overflow: hidden;
}
.progress span {
  display: block; height: 100%; background: var(--accent); border-radius: 999px;
  transition: width 0.3s var(--ease-out);
}
.progress span.progress-danger { background: var(--red); }

.debt-page {
  max-width: 1520px;
}
.debt-page .page-header,
.debt-grid {
  max-width: 1120px;
}
.debt-progress {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.debt-progress-head,
.debt-progress-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: .8571rem;
}
.debt-progress-head span,
.debt-progress-foot {
  color: var(--t2);
}
.debt-progress-head strong {
  color: var(--t0);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.debt-progress-foot span {
  white-space: nowrap;
}
.debt-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  justify-content: start;
  gap: 14px;
}
.debt-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
  margin-bottom: 0;
}
.debt-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.debt-card-head :is(h2, h3) {
  margin: 0;
  color: var(--t0);
  font-size: 1.1429rem;
  line-height: 1.25;
}
.debt-card-head p {
  margin: 4px 0 0;
  color: var(--t2);
  font-size: .8929rem;
}
.debt-card-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.debt-card-metrics div {
  min-width: 0;
  padding: 11px 12px;
  border: 1px solid var(--b1);
  border-radius: var(--radius-control);
  background: var(--s2);
}
.debt-card-metrics span {
  display: block;
  color: var(--t2);
  font-size: .8571rem;
  margin-bottom: 3px;
}
.debt-card-metrics strong {
  display: block;
  color: var(--t0);
  font-size: .8929rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.debt-card-actions {
  display: flex;
  justify-content: flex-end;
  padding-top: 2px;
}
@media (min-width: 1440px) {
  .debt-card {
    padding: 20px;
  }
}
@media (max-width: 1050px) {
  .debt-page .page-header,
  .debt-grid {
    max-width: none;
  }
}
@media (max-width: 420px) {
  .debt-grid { grid-template-columns: 1fr; }
  .debt-card-metrics { grid-template-columns: 1fr; }
  .debt-progress-head,
  .debt-progress-foot {
    align-items: flex-start;
    flex-direction: column;
    gap: 3px;
  }
}

/* === Helpers === */
.text-success { color: var(--green); }
.text-danger  { color: var(--red); }
.text-warning { color: var(--yellow); }

.currency-warning {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 0 0 16px;
  padding: 12px 14px;
  border: 1px solid var(--yellow-bdr);
  border-radius: var(--r);
  background: var(--yellow-bg);
  color: var(--text-primary);
  font-size: 1.0714rem;
  line-height: 1.45;
}
.currency-warning strong { color: var(--yellow); white-space: nowrap; }
@media (max-width: 700px) {
  .currency-warning { flex-direction: column; }
  .currency-warning strong { white-space: normal; }
}
.muted        { color: var(--t2); }

.toast-stack {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 9999;
  pointer-events: none;
}
.toast {
  padding: 12px 16px;
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--t0);
  border: 1px solid var(--b2);
  box-shadow: var(--shadow-pop);
  font-size: .9286rem;
  min-width: 220px;
  animation: toastIn 0.2s var(--ease-out);
  max-width: 360px;
  pointer-events: auto;
}
.toast-success { border-color: var(--green-bdr); color: var(--green); }
.toast-error   { border-color: var(--red-bdr);   color: var(--red); }
.toast-warning { border-color: var(--yellow-bdr); color: var(--yellow); }
.toast-info    { border-color: var(--b2); }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* === DRE — modelo planilha === */
.dre-card { padding: 0; overflow-x: auto; overflow-y: hidden; border-radius: var(--r-lg); }
.dre-cascade { display: flex; flex-direction: column; }
.dre-head, .dre-row {
  display: grid;
  /* Colunas data-driven: --dre-grid — setado inline pela view conforme as colunas
     visíveis do usuário; o fallback abaixo — o conjunto completo padrão. */
  grid-template-columns: var(--dre-grid, minmax(240px, 1.5fr) 128px 110px 104px 82px 128px 76px 128px 82px 128px 82px);
  min-width: min-content;
  align-items: center; gap: 10px;
  padding: 9px 14px;
  font-variant-numeric: tabular-nums;
}
.dre-head {
  font-size: .8571rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--t2); border-bottom: 1px solid var(--b1);
}
.dre-head .dre-num, .dre-head .dre-av, .dre-head .dre-unit, .dre-head .dre-var, .dre-head .dre-ajuste { text-align: right; }
.dre-row { font-size: .9286rem; border-bottom: 1px solid var(--b0); transition: background var(--t-fast); }
.dre-row:not(.dre-row--total):not(.dre-row--receita):hover { background: var(--s2); }
.dre-row .dre-label { color: var(--t1); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-left: var(--dre-indent, 0); }
.dre-row .dre-num   { text-align: right; color: var(--t0); }
.dre-row .dre-plano { text-align: right; color: var(--t2); }
.dre-row .dre-ajuste { text-align: right; color: var(--t2); font-size: .8571rem; }
.dre-row .dre-unit  { text-align: right; color: var(--t2); font-size: .8571rem; }
.dre-row .dre-var   { text-align: right; color: var(--t2); font-size: .8571rem; }
.dre-row .dre-av    { text-align: right; color: var(--t2); font-size: .8571rem; }
.dre-row--item { padding-top: 5px; padding-bottom: 5px; font-size: .8929rem; border-bottom: none; }
.dre-row--item .dre-label { color: var(--t2); }
.dre-row--item .dre-num   { color: var(--t1); }
.dre-row--sub .dre-label  { color: var(--t1); font-weight: 600; font-size: .8571rem; padding-left: 16px; }
.dre-row--section { margin-top: 3px; }
.dre-row--section > .dre-label { color: var(--t0); font-weight: 600; }
.dre-row--total {
  background: var(--s2);
  border-top: 1px solid var(--b1); border-bottom: 1px solid var(--b1);
}
.dre-row--total:hover { filter: brightness(1.06); }
.dre-row--total .dre-label, .dre-row--total .dre-num { color: var(--t0); font-weight: 700; }
.dre-row--receita { background: var(--s2); }
.dre-row--receita .dre-label, .dre-row--receita .dre-num { color: var(--t0); font-weight: 700; }
.dre-neg { color: var(--red) !important; }

/* === Grade de meses compartilhada: comparação mensal de Vendas (.dre-grid). A planilha do DRE usa o bloco "DRE — planilha", no fim do arquivo. === */
.dre-yearnav { display: inline-flex; align-items: center; gap: 2px; }
.dre-year { min-width: 46px; text-align: center; font: 600 1rem var(--font-head); color: var(--t0); font-variant-numeric: tabular-nums; }
.dre-gridcard { padding: 0; overflow: hidden; }
.dre-toolbar {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px 16px;
  padding: 10px 14px; border-bottom: 1px solid var(--b1);
}
.dre-toolbar-note { font-size: .8571rem; color: var(--t2); }
.dre-toolbar-actions { display: inline-flex; flex-wrap: wrap; gap: 8px; }
.dre-chip.is-on { background: var(--acc-bg); color: var(--accent); border-color: var(--acc-bdr); }
.dre-xscroll {
  overflow: auto; min-height: 260px; max-height: calc(100dvh - 250px);
  overscroll-behavior: contain; scrollbar-gutter: stable; background: var(--s0);
}
.dre-xscroll:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.dre-grid {
  --dre-label-w: 272px;
  border-collapse: separate; border-spacing: 0; table-layout: fixed;
  font-size: .9286rem; font-variant-numeric: tabular-nums;
}
.dre-col-label { width: var(--dre-label-w); }
.dre-col-val { width: 112px; }
.dre-col-tot { width: 124px; }

.dre-grid thead th {
  position: sticky; top: 0; z-index: 3; height: var(--hit); padding: 0 10px;
  background: var(--s0); border-bottom: 1px solid var(--b2);
  font-size: .8571rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--t2); text-align: right; white-space: nowrap;
}
.dre-grid thead th.dre-h--label { left: 0; z-index: 5; text-align: left; border-right: 1px solid var(--b1); }
.dre-h--tot { color: var(--t1); }

.dre-l {
  position: sticky; left: 0; z-index: 2; padding: 0 10px 0 8px; height: 34px;
  background: var(--s0); border-right: 1px solid var(--b1); border-bottom: 1px solid var(--b0);
  text-align: left; font-weight: 500; color: var(--t0); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dre-c {
  padding: 0 10px; height: 34px; text-align: right; white-space: nowrap;
  color: var(--t0); border-bottom: 1px solid var(--b0);
}
.dre-c--zero, .dre-c--na { color: var(--t3); }
.dre-c.is-neg { color: var(--red); }
.dre-c--tot { background: color-mix(in srgb, var(--t0) 3%, var(--s0)); font-weight: 600; }
.dre-c--acc:not(.dre-c--pct), .dre-h--acc:not(.dre-h--pct) { border-left: 1px solid var(--b2); }

.dre-r--item > .dre-l { padding-left: 42px; font-size: .8929rem; font-weight: 400; color: var(--t1); }
.dre-r--item > .dre-c { font-size: .8929rem; color: var(--t1); }
.dre-r--secao > .dre-l { font-weight: 600; }
.dre-r--receita > .dre-l, .dre-r--receita > .dre-c { font-weight: 700; }
.dre-r--total > .dre-l, .dre-r--total > .dre-c {
  font-weight: 700; background: color-mix(in srgb, var(--t0) 5%, var(--s0));
  border-top: 1px solid var(--b2); border-bottom: 1px solid var(--b2);
}
.dre-r:hover > .dre-l, .dre-r:hover > .dre-c { background: color-mix(in srgb, var(--t0) 7%, var(--s0)); }

.dre-label { display: flex; align-items: center; }
.dre-label > .dre-op { flex-shrink: 0; }
.dre-label > .dre-l-text { min-width: 0; }
.dre-op { display: inline-block; width: 14px; color: var(--t2); font-weight: 400; }
@media (max-width: 700px) {
  .dre-xscroll { max-height: none; }
  .dre-l { white-space: normal; line-height: 1.2; padding-block: 4px; font-size: .8929rem; }
  .dre-r--item > .dre-l { padding-left: 30px; }
}

/* === DRE — modo edição (admin) === */
.dre-edit-hint {
  margin-bottom: 12px; font-size: .8929rem; color: var(--t1);
  background: var(--s2);
}
.dre-bucket-tag {
  display: inline-block; margin-left: 8px; padding: 1px 7px; border-radius: var(--radius-control);
  font-size: .8571rem;
  background: var(--yellow-bg, var(--s2)); color: var(--yellow, var(--t2));
  border: 1px solid var(--yellow-bdr, var(--b1)); vertical-align: middle;
}
.dre-label--edit {
  display: flex; align-items: center; gap: 6px;
  overflow: visible !important; white-space: nowrap;
}
.dre-name-input {
  flex: 1 1 auto; min-width: 0; font: inherit; color: var(--t0);
  background: var(--s2); border: 1px solid var(--b1); border-radius: var(--r-sm);
  padding: 4px 8px;
}
.dre-name-input:focus { border-color: var(--accent); }
.dre-line-tools { display: inline-flex; gap: 3px; flex: 0 0 auto; }
.dre-tool {
  width: 22px; height: 22px; line-height: 1; padding: 0; cursor: pointer;
  border: 1px solid var(--b1); border-radius: var(--r-sm); background: var(--s2);
  color: var(--t2); font-size: .8571rem;
}
.dre-tool:hover { color: var(--t0); border-color: var(--accent); }
.dre-tool--danger:hover { color: var(--red); border-color: var(--red); }
.dre-plano--edit { display: flex; justify-content: flex-end; }
.dre-meta-input {
  width: 110px; font: inherit; text-align: right; color: var(--t0);
  background: var(--s2); border: 1px solid var(--b1); border-radius: var(--r-sm);
  padding: 4px 8px; font-variant-numeric: tabular-nums;
}
.dre-meta-input:focus { border-color: var(--accent); }
.dre-ajuste--edit { display: flex; justify-content: flex-end; }
.dre-ajuste-input {
  width: 92px; font: inherit; text-align: right; color: var(--t0);
  background: var(--s2); border: 1px solid var(--b1); border-radius: var(--r-sm);
  padding: 4px 8px; font-variant-numeric: tabular-nums;
}
.dre-ajuste-input:focus { border-color: var(--accent); }
/* Célula com edição não salva (pendente no lote). */
.dre-meta-input.is-dirty, .dre-ajuste-input.is-dirty {
  border-color: var(--yellow);
  box-shadow: inset 0 0 0 1px var(--yellow);
}
.dre-row--addline { border-bottom: none; padding-top: 2px; padding-bottom: 8px; }
.dre-addline-btn {
  font: inherit; font-size: .8571rem; cursor: pointer; color: var(--accent);
  background: transparent; border: 1px dashed var(--b1); border-radius: var(--r-sm);
  padding: 4px 10px; padding-left: var(--dre-indent, 8px);
}
.dre-addline-btn:hover { border-color: var(--accent); background: var(--acc-bg); }

/* Configurador de colunas (ocultar/mostrar + reordenar), salvo por usuário */
.dre-cols-popover {
  margin: 10px 0 4px; padding: 12px 14px; border: 1px solid var(--b1);
  border-radius: var(--r-lg); background: var(--s1); max-width: 340px;
  box-shadow: var(--shadow-pop);
}
.dre-cols-title { font-size: .8571rem; color: var(--t2); margin-bottom: 8px; }
.dre-cols-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 3px 0; }
.dre-cols-label { display: flex; align-items: center; gap: 8px; font-size: .9286rem; color: var(--t1); cursor: pointer; }
.dre-cols-move { display: inline-flex; gap: 3px; flex: 0 0 auto; }
.dre-cols-move .dre-tool[disabled] { opacity: .4; cursor: default; }

/* Construtor de fórmula (linhas de total) — Fase 2 */
.dre-label-text { color: var(--t0); font-weight: 700; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dre-tool--fx { font-style: italic; font-weight: 700; }
.dre-fb-meta { display: flex; flex-wrap: wrap; gap: 14px; margin: 6px 0 12px; }
.dre-fb-meta label { display: flex; flex-direction: column; gap: 4px; font-size: .8571rem; color: var(--t2); }
.dre-fb-meta .input { min-width: 180px; }
.dre-fb-terms { display: flex; flex-direction: column; gap: 8px; }
.dre-fb-term { display: flex; align-items: center; gap: 8px; }
.dre-fb-term .dre-fb-op { width: 64px; flex: 0 0 auto; text-align: center; }
.dre-fb-term .dre-fb-ref { flex: 1 1 auto; min-width: 0; }
.dre-fb-term .dre-fb-val { width: 130px; flex: 0 0 auto; }
.dre-fb-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; flex-wrap: wrap; }
.dre-fb-preview { font-size: .9286rem; color: var(--t1); }
.dre-fb-preview strong { color: var(--t0); }

/* Painel de mapeamento categoria ? linha */
.dre-map-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 10px; margin-top: 8px; }
.dre-map-row { display: flex; align-items: center; gap: 10px; justify-content: space-between; }
.dre-map-cat { font-size: .9286rem; color: var(--t1); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dre-map-select { max-width: 180px; flex: 0 0 auto; }

/* === DRE relatório (somente leitura) === */
.dre-report .dre-head .dre-num,
.dre-report .dre-head .dre-av { text-align: right; }
.dre-report .dre-row .dre-av { text-align: right; color: var(--t2); font-size: .8571rem; }

/* === DRE month picker === */
.dre-month-control {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.dre-month-trigger {
  min-width: 142px;
  justify-content: center;
  cursor: pointer;
  color: var(--t0);
  background: var(--surface-raised);
  border-color: var(--b2);
}
.dre-month-control.open .dre-month-trigger,
.dre-month-trigger:hover {
  color: var(--accent);
  border-color: var(--acc-bdr);
  background: var(--acc-bg);
}
.dre-calendar-popover {
  position: absolute;
  top: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  width: 278px;
  padding: 12px;
  border: 1px solid var(--b2);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-pop);
  transform-origin: top center;
  animation: popover-in var(--motion) var(--ease-out);
}
.dre-calendar-popover::before {
  content: "";
  position: absolute;
  top: -6px;
  left: 50%;
  width: 10px;
  height: 10px;
  transform: translateX(-50%) rotate(45deg);
  background: var(--surface);
  border-left: 1px solid var(--b2);
  border-top: 1px solid var(--b2);
}
.dre-calendar-head {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}
.dre-calendar-head strong {
  color: var(--t0);
  font-size: 1rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.dre-month-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
}
.dre-month-cell {
  height: 38px;
  border: 1px solid var(--b1);
  border-radius: var(--r);
  background: var(--surface-raised);
  color: var(--t1);
  font: inherit;
  font-size: .8571rem;
  font-weight: 700;
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast), transform var(--t-fast);
}
.dre-month-cell:hover {
  color: var(--t0);
  border-color: var(--b3);
  background: var(--s2);
}
.dre-month-cell.active {
  color: var(--text-primary);
  border-color: var(--border-strong);
  background: var(--surface-interaction);
  box-shadow: none;
}
@media (max-width: 420px) {
  .dre-calendar-popover {
    left: auto;
    right: -42px;
    transform: none;
  }
  .dre-calendar-popover::before {
    left: auto;
    right: 88px;
    transform: rotate(45deg);
  }
}

/* === Fluxo previsto — cards 30/60/90 === */
.forecast-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; }
.forecast-card {
  background: var(--s1); border: 1px solid var(--b1); border-radius: var(--r-lg);
  padding: 16px; display: flex; flex-direction: column; gap: 12px;
}
.forecast-card .fc-head { display: flex; align-items: baseline; justify-content: space-between; }
.forecast-card .fc-h { font-size: .8571rem; font-weight: 600; color: var(--t1); }
.forecast-card .fc-tag { font-size: .8571rem; color: var(--t2); }
.forecast-card .fc-saldo { font-size: 1.6429rem; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--t0); line-height: 1; }
.forecast-card.fc-pos .fc-saldo { color: var(--green); }
.forecast-card.fc-neg .fc-saldo { color: var(--red); }
.forecast-card .fc-rows { display: flex; flex-direction: column; gap: 5px; font-size: .8929rem; padding-top: 4px; border-top: 1px solid var(--b0); }
.forecast-card .fc-line { display: flex; justify-content: space-between; font-variant-numeric: tabular-nums; }
.forecast-card .fc-line > span:first-child { color: var(--t2); }
.forecast-card .fc-line > span:last-child  { color: var(--t0); }

/* === Dashboard 2-col grid === */
.dash-grid-2      { display: grid; grid-template-columns: 1.45fr 1fr;  gap: 16px; margin-top: 4px; }
@media (max-width: 1050px) { .dash-grid-2 { grid-template-columns: 1fr; } }

/* === Bar chart === */
.chart-svg { width: 100%; height: auto; display: block; max-height: 240px; overflow-y: auto; }
.chart-grid { stroke: var(--b1); stroke-width: 1; }
.chart-axis { fill: var(--t2); font-size: .8571rem; }
.bar-income  { fill: var(--chart-in); }
.bar-expense { fill: var(--chart-out); }
.chart-legend-inline { display: flex; gap: 12px; font-size: .8571rem; color: var(--t2); align-items: center; }
.chart-legend-inline span { display: flex; align-items: center; gap: 4px; }
.chart-legend-inline i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; }
.sw-income  { background: var(--chart-in); }
.sw-expense { background: var(--chart-out); }

/* === Donut chart === */
.donut-svg { max-width: 180px; width: 100%; height: auto; display: block; flex-shrink: 0; }
.donut-center-val { fill: var(--t0); font-weight: 700; font-size: 1.0714rem; }
.donut-center-cap { fill: var(--t2); font-size: .8571rem; letter-spacing: 0.08em; }
.donut-wrap   { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; padding-top: 6px; }
.donut-legend { display: flex; flex-direction: column; gap: 6px; min-width: 140px; flex: 1; list-style: none; }
.donut-legend li { display: flex; align-items: center; gap: 8px; font-size: .8929rem; }
.legend-dot  { width: 9px; height: 9px; border-radius: 2px; flex-shrink: 0; }
.legend-grow { flex: 1; color: var(--t1); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend-val  { color: var(--t0); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ============================================================
   === KPI CARDS RICOS =======================================
   ============================================================ */

/* Grid override para cards ricos (mais altos) */
.kpi-grid-rich { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 1050px) { .kpi-grid-rich { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 700px)  { .kpi-grid-rich { grid-template-columns: 1fr; } }

/* Card base rico */
.kpi-rich {
  gap: 0;
  padding: 14px 16px 12px;
  display: flex;
  flex-direction: column;
}

/* Header do card: label + selo. O rótulo nunca vira reticências por causa do selo:
   quebra em linhas ao lado dele (base 0, mínimo = maior palavra) e, se nem a maior
   palavra couber, o selo desce inteiro para a linha seguinte. */
.kpi-rich-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 4px 6px;
  margin-bottom: 4px;
}
.kpi-rich-head > .kpi-label { flex: 1 1 0; }
.kpi-rich-head > :not(.kpi-label) { flex-shrink: 0; max-width: 100%; }
.kpi-rich .kpi-value { font-size: 1.5714rem; margin-bottom: 8px; }
/* Slot visual de altura fixa (maior visual fixo = mini donut 40px), ancorado no pé do
   card: visuais da mesma linha alinham mesmo se o card esticar. */
.kpi-chart-area {
  --kpi-visual-h: 40px;
  flex: 0 0 var(--kpi-visual-h); height: var(--kpi-visual-h); margin-top: auto;
  align-self: stretch; min-width: 0; overflow: hidden;
  display: flex; flex-direction: column; justify-content: center;
}

/* Badges de contexto */
.kpi-badge-neu { font-size: .8571rem; font-weight: 600; color: var(--t1); background: var(--s2); border: 1px solid var(--b1); border-radius: var(--radius-xs); padding: 1px 6px; white-space: nowrap; }
.kpi-badge-ok  { font-size: .8571rem; color: var(--green); background: var(--green-bg); border: 1px solid var(--green-bdr); border-radius: var(--radius-xs); padding: 1px 6px; white-space: nowrap; }
.kpi-alert     { display: inline-flex; align-items: center; gap: 3px; font-size: .8571rem; color: var(--red); font-weight: 700; white-space: nowrap; }

/* Sparkline (barras 7 dias) */
.kpi-spark { width: 100%; height: 32px; display: block; }

.kpi-muted { color: var(--t2); font-size: .8571rem; }

/* Distribuição de contas (Card 1) */
.kpi-acct-list { display: flex; flex-direction: column; gap: 5px; }
/* No slot de 40px cabem 2 linhas inteiras (2 × 1.25 × .8571rem + 5px ≈ 39px); a 3ª
   conta fica oculta em vez de cortada ao meio. O selo do card mantém o total de contas. */
.kpi-chart-area > .kpi-acct-list { line-height: 1.25; }
.kpi-chart-area .kpi-acct-row:nth-child(n+3) { display: none; }
/* Cada conta em 1 linha: valor e % inteiros; o nome cede (ellipsis) e a trilha encolhe até 0. */
.kpi-acct-row  { display: flex; align-items: center; gap: 5px; font-size: .8571rem; white-space: nowrap; text-align: left; }
.kpi-acct-dot  { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.kpi-acct-name { color: var(--t2); flex: 0 1 68px; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.kpi-acct-track{ flex: 1; height: 4px; background: var(--s2); border-radius: 2px; overflow: hidden; }
.kpi-acct-fill { height: 100%; border-radius: 2px; transition: width .4s var(--ease-out); }
.kpi-acct-pct  { font-size: .8571rem; color: var(--t2); min-width: 26px; text-align: right; flex-shrink: 0; }
.kpi-acct-val  { font-size: .8571rem; color: var(--t0); min-width: 38px; text-align: right; font-variant-numeric: tabular-nums; flex-shrink: 0; }

/* Mini donut (Card 3 — Despesas) */
.kpi-mini-donut { width: 40px; height: 40px; flex-shrink: 0; }

/* Barra de progresso de margem (Card 4 — Lucro) */
.kpi-progress-wrap   { display: flex; flex-direction: column; gap: 5px; }
.kpi-progress-track  { position: relative; height: 7px; background: var(--s2); border-radius: 4px; overflow: visible; }
.kpi-progress-fill   { height: 100%; border-radius: 4px; transition: width .5s var(--ease-out); }
.kpi-progress-ref    {
  position: absolute; top: -3px; bottom: -3px; width: 2px;
  background: var(--progress-ref); border-radius: 1px;
}

/* Barra empilhada status (Cards 5 e 6) */
.kpi-stack-bar { height: 7px; display: flex; gap: 2px; border-radius: 4px; overflow: hidden; }
.kpi-stack-seg { border-radius: 4px; min-width: 3px; transition: flex .3s var(--ease-out); }

/* Barras de urgência — A Pagar (Card 6) */
.kpi-urg-wrap { display: flex; flex-direction: column; gap: 4px; }
.kpi-urg-svg  { width: 100%; height: 10px; display: block; }

/* ============================================================
   === DESPESAS VARIÁVEIS ====================================
   ============================================================ */

/* Tendência 6 meses (SVG) */
.tv-svg  { width: 100%; height: auto; display: block; }
.tv-bar  { fill: var(--s3); }
.tv-bar--cur { fill: var(--accent); }
.tv-val  { fill: var(--t1); font-size: .8571rem; font-variant-numeric: tabular-nums; }
.tv-axis { fill: var(--t2); font-size: .8571rem; }

/* Ranking por categoria */
.rank-list { display: flex; flex-direction: column; gap: 12px; padding-top: 4px; }
.rank-row  { display: flex; flex-direction: column; gap: 5px; }
.rank-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; font-size: .9286rem; }
.rank-name { color: var(--t1); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-val  { color: var(--t0); font-variant-numeric: tabular-nums; white-space: nowrap; }
.rank-track{ height: 8px; background: var(--s2); border-radius: 999px; overflow: hidden; }
.rank-fill {
  height: 100%; border-radius: 999px;
  background: var(--accent);
  transition: width .4s var(--ease-out);
}

/* Benchmark (vs média 3 meses) */
.bm-row   { display: flex; flex-direction: column; gap: 12px; padding-top: 6px; }
.bm-line  { display: grid; grid-template-columns: 80px 1fr 110px; align-items: center; gap: 10px; }
.bm-label { font-size: .8571rem; color: var(--t2); }
.bm-track { height: 12px; background: var(--s2); border-radius: 999px; overflow: hidden; }
.bm-fill  { height: 100%; border-radius: 999px; transition: width .4s var(--ease-out); }
.bm-fill--cur { background: var(--accent); }
.bm-fill--avg { background: var(--t2); opacity: 0.55; }
.bm-val   { font-size: .9286rem; color: var(--t0); text-align: right; font-variant-numeric: tabular-nums; }

/* Delta inline */
.dv-delta      { font-size: .8571rem; font-weight: 700; padding: 1px 7px; border-radius: var(--r-xs); }
.dv-delta-good { background: var(--green-bg); color: var(--green); border: 1px solid var(--green-bdr); }
.dv-delta-bad  { background: var(--red-bg);   color: var(--red);   border: 1px solid var(--red-bdr); }

/* Gridlines + estado vazio do gráfico de tendência */
.tv-grid  { stroke: var(--b1); stroke-width: 1; }
.tv-empty { padding: 40px 12px; text-align: center; color: var(--t2); font-style: italic; }

/* Estado vazio do painel inteiro */
.dv-empty { text-align: center; padding: 36px 24px; }
.dv-empty-ic   { display: inline-flex; color: var(--t2); line-height: 1; }
.dv-empty h2, .dv-empty h3 { margin: 14px 0 6px; font-size: 1.1429rem; color: var(--t0); font-weight: 600; }
.dv-empty-txt  { font-size: 1.0714rem; color: var(--t1); max-width: 420px; margin: 0 auto 8px; line-height: 1.55; }
.dv-empty-cats { font-size: .8571rem; color: var(--t2); max-width: 700px; margin: 0 auto 18px; line-height: 1.5; }

/* === Barra de filtros (Despesas Variáveis e telas operacionais) === */
.dv-filters {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  margin: 4px 0 14px;
}
.dv-month-nav { display: inline-flex; align-items: center; gap: 6px; }
.input-sm {
  width: auto; min-width: 170px; height: 34px;
  padding: 6px 10px; font-size: .9286rem;
}
@media (max-width: 700px) {
  .dv-filters > * { flex: 1 1 100%; }
  .dv-filters .input-sm { width: 100%; min-width: 0; }
}

/* Rolagem horizontal de tabelas em telas estreitas (item de responsividade). */
.table-scroll { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* Marca de campo obrigatório nos formulários. */
.req { color: var(--red); font-weight: 600; }

/* === Controles de formulário em dark (corrige a lista nativa do <select>) === */
select.input { color-scheme: dark; }
select.input option, .input option { background-color: var(--s0); color: var(--t0); }

.dash-cascade { display: flex; flex-direction: column; container-type: inline-size; }

.dash-line {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 14px; font-variant-numeric: tabular-nums;
  border-bottom: 1px solid var(--b0);
}
.dash-line-label { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 6px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dash-line-val   { flex: 0 0 auto; text-align: right; color: var(--t0); font-variant-numeric: tabular-nums; }
.dash-sign { display: inline-block; width: 12px; text-align: center; color: var(--t2); font-weight: 700; }
.dash-neg  { color: var(--red) !important; }
.dash-line-pct { flex: 0 0 56px; text-align: right; font-size: .8571rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.dash-line-val { min-width: 112px; }
.dash-line--clickable { cursor: pointer; transition: background-color var(--t-fast); }
.dash-line--clickable:hover { background-color: var(--s2); }
.dash-line--clickable:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.dash-line-label .dash-chevron { width: auto; margin-left: 2px; }

/* Linhas principais (Receita, Deduções, Despesas variáveis/fixas, Juros) */
.dash-line--main { font-size: .9643rem; }
.dash-line--main > .dash-line-label { color: var(--t0); font-weight: 600; }
.dash-line--main > .dash-line-val   { color: var(--t0); font-weight: 600; }

/* Subtotais calculados (Receita líquida, Margem, EBITDA) */
.dash-line--total {
  background: var(--s2);
  border-top: 1px solid var(--b1); border-bottom: 1px solid var(--b1);
}
.dash-line--total .dash-line-label, .dash-line--total .dash-line-val { color: var(--t0); font-weight: 700; }

/* Resultado final (Lucro / Prejuízo) */
.dash-line--final {
  background: var(--s2); border-top: 1px solid var(--b2);
  border-bottom: none; padding-top: 12px; padding-bottom: 12px; font-size: 1.0357rem;
}
.dash-line--final .dash-line-label, .dash-line--final .dash-line-val { color: var(--t0); font-weight: 800; }
.dash-line--final .dash-line-val.dash-neg { color: var(--red) !important; }

/* Itens expandidos (detalhe das seções) */
.dash-line--item { font-size: .8929rem; border-bottom: none; padding-top: 5px; padding-bottom: 5px; }
.dash-line--item .dash-line-label { color: var(--t2); padding-left: var(--dash-indent, 18px); }
.dash-line--item .dash-line-val   { color: var(--t1); }

/* Keep DRE labels and amounts readable when the panel becomes narrow. */
@container (max-width: 700px) {
  .dash-line-label { white-space: normal; overflow: visible; overflow-wrap: anywhere; }
}
@container (max-width: 440px) {
  .dash-line { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 3px 12px; }
  .dash-line-label { grid-column: 1 / -1; }
  .dash-line-pct { grid-column: 1; text-align: left; }
  .dash-line-val { grid-column: 2; min-width: 0; }
  .dash-line--item .dash-line-val { grid-row: 2; }
}

/* Chevron de expand */
.dash-chevron {
  flex: 0 0 auto; width: 18px; height: 18px; line-height: 18px; text-align: center;
  padding: 0; cursor: pointer; color: var(--t2); font-size: .8571rem;
  background: transparent; border: none; transition: transform var(--t-fast), color var(--t-fast);
}
.dash-chevron:hover { color: var(--accent); }
.dash-chevron.open  { transform: rotate(90deg); color: var(--accent); }

/* Filtros da inadimplência */
.inad-filters {
  display: flex; flex-wrap: wrap; gap: 18px 28px; align-items: flex-end;
  padding: 4px 2px 12px; border-bottom: 1px solid var(--b1); margin-bottom: 10px;
}
.inad-filter-group { display: flex; flex-direction: column; gap: 6px; }
.inad-filter-label { font-size: .8571rem; color: var(--t2); }
.dash-chip-row { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.dash-chip {
  font: inherit; font-size: .8571rem; cursor: pointer; padding: 4px 11px;
  border-radius: var(--r-pill); border: 1px solid var(--b1); background: var(--s2); color: var(--t1);
}
.dash-chip:hover  { border-color: var(--accent); color: var(--t0); }
.dash-chip.active { background: var(--surface-interaction); border-color: var(--border-strong); color: var(--text-primary); font-weight: 600; }
.inad-date-row { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 8px; max-width: 100%; font-size: .8571rem; }
.inad-date-row .input-sm { width: auto; }
.inad-list { margin-top: 4px; }

.dash-pct-neg  { color: var(--red); }
.dash-pct-pos  { color: var(--green); }
.dash-pct-info { color: var(--t1); }

@media (max-width: 700px) {
  .app-content { padding: 14px 12px; }
  .page-section { padding: 12px 0; }
}

/* Ponto do gráfico de linha (tendência) */
.line-dot { fill: var(--accent); stroke: var(--bg-deep); stroke-width: 1.5; }
.line-dot--neg { fill: var(--chart-neg); }

/* Diálogo interno (confirm/prompt) — fica acima de qualquer modal de formulário. */
.dialog-backdrop { z-index: 1001; padding: 16px; }
.dialog-card { width: min(440px, calc(100vw - 32px)); padding-top: var(--s-5); }

/* Mobile hardening v56 */
@media (max-width: 700px) {
  html,
  body {
    width: 100%;
    overflow-x: hidden;
  }

  .app-main,
  .app-content,
  .page-section {
    min-width: 0;
    max-width: 100%;
  }

  .app-content {
    padding: 14px 12px;
  }

  .page-section {
    padding: 12px 0;
  }

  .page-header {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .page-actions {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
    gap: 8px;
  }

  .page-actions .btn,
  .topbar-right .btn {
    min-width: 0;
    white-space: nowrap;
  }

  .topbar {
    height: auto;
    min-height: var(--header-h);
    padding: 10px 12px;
    gap: 8px;
    align-items: flex-start;
  }

  .topbar-left {
    min-width: 0;
    flex: 1 1 auto;
  }

  .topbar-right {
    flex: 0 1 auto;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .topbar-right .btn {
    min-height: 34px;
    padding: 0 10px;
    font-size: .8571rem;
  }

  .sidebar {
    width: min(88vw, 320px);
  }

  .sidebar-link,
  .sidebar-ambiente-toggle {
    min-height: 44px;
  }

  .dashboard-grid,
  .kpi-grid,
  .grid-2col,
  .grid-3col,
  .grid-2,
  .grid-2-equal {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .card {
    padding: 14px;
    border-radius: var(--radius-panel);
    overflow-wrap: anywhere;
  }

  .card-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .card:has(.data-table),
  .table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .data-table {
    min-width: 640px;
  }

  .row-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .field-row {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .input,
  .select,
  .textarea {
    font-size: 1.1429rem;
  }

  .modal-card input.input,
  .modal-card select.input,
  .modal-card .select {
    min-height: 44px;
  }

  .modal-card .btn,
  .modal-card .btn-icon,
  .modal-card .seg-btn {
    min-height: 44px;
  }

  .modal-card .btn-icon {
    min-width: 44px;
  }

  .seg {
    flex-wrap: wrap;
  }

  .seg-btn {
    min-height: 44px;
  }

  .modal-backdrop {
    align-items: stretch;
    justify-items: stretch;
    grid-template-columns: minmax(0, 1fr);
    padding: 8px;
  }

  .modal-card {
    width: auto;
    justify-self: stretch;
    max-width: none;
    max-height: calc(100dvh - 16px);
    border-radius: var(--radius-panel);
  }

  .modal-header,
  .modal-body {
    padding: 14px;
  }

  .modal-footer {
    flex-direction: column-reverse;
  }

  .modal-footer .btn {
    width: 100%;
    min-height: 44px;
  }

  .list-row {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .list-row-meta {
    width: 100%;
    align-items: flex-start;
    padding-left: 44px;
  }

  .toast-stack {
    left: 12px;
    right: 12px;
    bottom: 12px;
  }

  .toast {
    width: 100%;
    min-width: 0;
    max-width: none;
  }

  .page-section [style*="justify-content:space-between"],
  .page-section [style*="justify-content: space-between"] {
    flex-wrap: wrap !important;
    align-items: flex-start !important;
  }

  .page-section [style*="white-space:nowrap"],
  .page-section [style*="white-space: nowrap"] {
    white-space: normal !important;
  }
}

@media (max-width: 420px) {
  .app-content {
    padding: 10px 8px;
  }

  .page-actions {
    grid-template-columns: 1fr;
  }

  .topbar-right .btn {
    padding: 0 8px;
  }

  .data-table {
    min-width: 560px;
  }

  .modal-backdrop {
    padding: 0;
  }

  .modal-card {
    min-height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
    border-left: 0;
    border-right: 0;
  }
}

/* ============================================================================
   [WS1] Camada de layout e responsividade (generica e do app)
   (antigo ui-foundation.css; ordem original preservada: vem por ultimo)
   ============================================================================ */

/* ============================================================================
   ui-foundation.css - camada canonica de layout e responsividade do CF Finance
   Carregada por ultimo em todas as superficies para unificar regras legadas.
   ============================================================================ */

:root {
  --ui-content-max: var(--content-max);
  --ui-gutter: clamp(14px, 2.2vw, 32px);
  --ui-panel-radius: var(--radius-panel);
  --ui-control-radius: var(--r-md);
  --ui-dialog-radius: var(--r-lg);
  --ui-control-height: 40px;
  --ui-touch-height: 44px;
  --ui-panel-bg: var(--s1);
  --ui-focus-ring: 0 0 0 3px color-mix(in srgb, var(--action) 24%, transparent);
}

html {
  min-width: 320px;
  scrollbar-gutter: stable;
  text-size-adjust: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  min-width: 320px;
  overflow-x: clip;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
.btn,
a {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

img,
svg,
canvas {
  max-width: 100%;
}

:where(a, button, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  box-shadow: var(--ui-focus-ring);
}

.skip-link {
  position: fixed;
  top: -48px;
  left: 12px;
  z-index: 1000;
  padding: 10px 16px;
  background: var(--s2);
  color: var(--t0);
  border: 1px solid var(--b3);
  border-radius: var(--radius-control);
  font-size: .9286rem;
  font-weight: 600;
  text-decoration: none;
  transition: top var(--t-fast);
}
.skip-link:focus-visible {
  top: 12px;
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

:where(h1, h2, h3, .page-title, .modal-title) {
  font-family: var(--font-head);
  font-weight: 500;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

:where(p, .page-subtitle, .muted, .hint) {
  text-wrap: pretty;
}

/* Shell e cabecalhos ------------------------------------------------------- */

.app-shell {
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
}

.app-main {
  width: 100%;
  min-width: 0;
}

.app-content {
  container: app-content / inline-size;
  width: 100%;
  max-width: none;
  min-width: 0;
  padding: var(--s-8) var(--s-10) var(--s-10);
}

.page-section {
  width: 100%;
  min-width: 0;
  padding-block: clamp(14px, 1.8vw, 24px);
}

.page-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: var(--s-3) var(--s-6);
  margin-bottom: var(--s-6);
}

.page-header > div:first-child {
  min-width: 0;
}

.page-title,
.page-header h1 {
  font-family: var(--font-head);
  font-size: var(--fs-2xl);
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.page-subtitle {
  max-width: 72ch;
  margin-top: 6px;
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  line-height: 1.45;
}

.page-actions {
  display: flex;
  min-width: 0;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.topbar {
  min-width: 0;
  padding-inline: var(--ui-gutter);
}

.topbar-left,
.topbar-right,
.topbar-empresa {
  min-width: 0;
}

/* Componentes base -------------------------------------------------------- */

.btn {
  min-height: var(--ui-control-height);
  height: auto;
  border-radius: var(--r-pill);
  transition: color var(--t-fast), background-color var(--t-fast), border-color var(--t-fast),
    box-shadow var(--t-fast), filter var(--t-fast), transform var(--t-fast), opacity var(--t-fast);
}

.btn {
  padding-block: 8px;
}

.btn-sm {
  min-height: 36px;
  padding-block: 6px;
}

.btn-icon {
  min-width: var(--ui-control-height);
  min-height: var(--ui-control-height);
}

.card,
.kpi-card,
.debt-card {
  min-width: 0;
  border-radius: var(--ui-panel-radius);
}

.card {
  padding: var(--card-pad);
  background: var(--ui-panel-bg);
  border-color: var(--border);
  box-shadow: none;
}

.card::before {
  opacity: 0.18;
}

.card-header {
  gap: 12px;
}

.input,
.select,
.textarea {
  min-height: var(--ui-control-height);
  border-radius: var(--ui-control-radius);
}

.field-row {
  align-items: start;
}

.empty-state {
  min-width: 0;
}

/* Dados densos: o conteudo rola dentro do proprio painel, nunca a pagina. */

.table-scroll,
.card:has(> .data-table),
.dre-card,
.pricing-table-card {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scrollbar-gutter: stable;
  -webkit-overflow-scrolling: touch;
}

.data-table {
  width: 100%;
  font-variant-numeric: tabular-nums;
}

.data-table th,
.data-table td {
  vertical-align: middle;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.categoria-filters {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr));
  gap: var(--s-3); margin: var(--s-4) 0;
}
.categoria-filters > .input { min-width: 0; width: 100%; }
.categoria-actions .row-actions { display: grid; grid-template-columns: repeat(2, max-content); justify-content: end; }

/* Modais ------------------------------------------------------------------ */

.modal-backdrop {
  padding: clamp(8px, 2vw, 24px);
}

.modal-card {
  width: min(680px, calc(100vw - 32px));
  max-width: 100%;
  max-height: calc(100dvh - 32px);
  border-radius: var(--ui-dialog-radius);
}

.modal-body {
  min-width: 0;
  overscroll-behavior: contain;
}

.modal-footer {
  gap: 8px;
  flex-wrap: wrap;
}

/* Dashboard e relatorios -------------------------------------------------- */

.dashboard-grid,
.kpi-grid,
.kpi-grid-rich,
.grid-2,
.grid-2-equal,
.grid-2col,
.grid-3col,
.debt-grid {
  min-width: 0;
}

/* Paginas publicas -------------------------------------------------------- */

/* Quebra a grade tripla generica da landing sem alterar a semantica. */

/* Admin ------------------------------------------------------------------- */

/* Breakpoint de navegacao: tablet e notebook estreito. */

@media (max-width: 1050px) {
  body.nav-open { overflow: hidden; }
  .icon-btn.sidebar-close { display: inline-flex; }
  .sidebar :is(.sidebar-link, .sidebar-profile-main, .sidebar-org-head.is-clickable, .sidebar-org-seg .segmented-item, .sidebar-logo-home, .input, .icon-btn) { min-height: var(--hit); }
  .sidebar .icon-btn { min-width: var(--hit); }
  .sidebar > :not(.sidebar-nav) { flex-shrink: 0; }
  .icon-btn.nav-toggle { width: auto; flex-shrink: 0; gap: var(--s-1); font-size: var(--fs-xs); }
  .topbar-crumbs { flex: 1; }
  .topbar-tools { flex-wrap: wrap; justify-content: flex-end; max-width: 50%; }
  .app-shell {
      grid-template-columns: minmax(0, 1fr);
    }

  .nav-toggle {
      display: inline-flex;
      min-width: var(--ui-touch-height);
      min-height: var(--ui-touch-height);
    }

  .sidebar {
      position: fixed;
      inset: 0 auto 0 0;
      padding-top: var(--s-4);
      padding-bottom: max(var(--s-3), env(safe-area-inset-bottom));
      z-index: 200;
      width: min(86vw, 320px);
      height: 100dvh;
      transform: translateX(-100%);
    }

  body.nav-open .sidebar {
      transform: translateX(0);
    }

  body.nav-open .nav-backdrop {
      display: block;
      position: fixed;
      inset: 0;
      z-index: 150;
      background: var(--backdrop);
    }

  .grid-2,
  .grid-2-equal,
  .grid-2col,
  .grid-3col {
      grid-template-columns: minmax(0, 1fr);
    }
}

@media (max-width: 1050px) and (max-height: 500px) {
  .sidebar { overscroll-behavior-y: contain; scroll-padding-top: 60px; }
  .sidebar-logo { position: sticky; top: 0; z-index: 1; min-height: var(--hit); background: var(--bg-structural); }
  .sidebar-nav { flex: none; overflow: visible; }
}

/* Breakpoint de conteudo: celular e tablet vertical. */

@media (max-width: 700px) {
  :root {
      --ui-gutter: 12px;
    }

  .app-content { padding: var(--s-6) var(--s-5) var(--s-8); }

  .page-section {
      padding-block: 10px;
    }

  .page-header {
      grid-template-columns: minmax(0, 1fr);
      align-items: stretch;
      gap: 12px;
    }

  .page-title,
  .page-header h1 {
      font-size: clamp(23px, 7vw, 30px);
    }

  .page-actions {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      width: 100%;
    }

  .page-actions .btn,
  .page-actions > a {
      width: 100%;
      min-width: 0;
      min-height: var(--ui-touch-height);
      white-space: normal;
    }

  .topbar {
      min-height: 58px;
      height: auto;
      align-items: center;
      gap: 8px;
      padding-block: 7px;
    }

  .topbar-right {
      flex-wrap: wrap;
      justify-content: flex-end;
    }

  .topbar-right .btn,
  .btn-sm,
  .btn-icon {
      min-height: var(--ui-touch-height);
    }

  .btn-icon {
      min-width: var(--ui-touch-height);
    }

  .card,
  .kpi-card,
  .debt-card {
      border-radius: var(--radius-panel);

      box-shadow: none;
    }

  .card-header {
      align-items: flex-start;
      flex-wrap: wrap;
    }

  .field-row,
  .pricing-toolbar,
  .pricing-management-grid,
  .pricing-grid-2,
  .pricing-grid-3,
  .pricing-summary-grid {
      grid-template-columns: minmax(0, 1fr);
    }

  .input,
  .select,
  .textarea {
      min-height: var(--ui-touch-height);
      font-size: 1.1429rem;
    }

  .modal-backdrop {
      align-items: stretch;
      padding: 8px;
    }

  .modal-card {
      width: 100%;
      max-height: calc(100dvh - 16px);
      border-radius: var(--radius-panel);
    }

  .modal-header,
  .modal-body,
  .modal-footer {
      padding-inline: 14px;
    }

  .modal-footer .btn {
      width: 100%;
      min-height: var(--ui-touch-height);
      flex: 0 0 auto;
    }

  .data-table {
      min-width: 620px;
    }

}

@media (max-width: 420px) {
  :root {
      --ui-gutter: 8px;
    }

  /* Ajuste fino ≤480 (§12): 12px laterais para o hint de 1 linha do KPI caber sem cortar valor. */
  .app-content { padding: var(--s-6) var(--s-3) var(--s-8); }

  .topbar-left .page-subtitle,
  .topbar-right .btn:not(.nav-toggle) {
      display: none;
    }

  .card,
  .kpi-card,
  .debt-card {
      padding: 14px 12px;
    }

  .modal-backdrop {
      padding: 0;
    }

  .modal-card {
      min-height: 100dvh;
      max-height: 100dvh;
      border-radius: 0;
      border-inline: 0;
    }

  .data-table {
      min-width: 560px;
    }
}

@container app-content (max-width: 700px) {
  .page-header {
      grid-template-columns: minmax(0, 1fr);
      align-items: stretch;
    }

  .page-actions {
      justify-content: stretch;
    }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
      scroll-behavior: auto !important;
      animation-duration: 0.01ms !important;
      animation-iteration-count: 1 !important;
      transition-duration: 0.01ms !important;
    }
}

/* Contorno solido em --t1 (no modo contraste --border-strong >= --border). */
@media (prefers-contrast: more) {
  .card, .panel, .kpi-strip, .input, .select, .textarea, .btn, .chip, .sidebar-link,
  .data-table, .dt th, .dt td, .modal-card, .dialog-card {
    border-color: var(--t1) !important;
  }
}

/* ==========================================================================
   Componentes do contrato visual (DS-02, plano V3 §3.1 e §4)
   Gabarito: docs/reference/*.html. Só tokens. Render em views/shared.js;
   catálogo com todos os estados em /_components.
   ========================================================================== */

/* Rótulos de seção em caixa de frase (revisão de UI S1, 02/11/2026): sem caixa-alta nem espaçamento largo;
   cabeçalhos de tabela densa (DRE) mantêm a caixa-alta. */
.eyebrow {
  font-family: var(--font-head);
  font-size: var(--fs-2xs); font-weight: 500; color: var(--text-muted);
}
.num { white-space: nowrap; font-variant-numeric: tabular-nums; font-family: var(--font-head); font-weight: 500; }
.tone-pos { color: var(--success); }
.tone-neg { color: var(--danger); }
.tone-warn { color: var(--warning); }
.tone-muted { color: var(--text-muted); }

/* Link de ação ("Ver todas →"). Revisão de UI S3: links em texto neutro sublinhado; o azul (--action) fica no
   botão principal, na série principal dos gráficos, no foco e nos LEDs. O sublinhado leva um toque do azul. */
.link-go {
  display: inline-flex; align-items: center; gap: var(--s-1);
  color: var(--link); font-size: var(--fs-xs); font-weight: 500; white-space: nowrap;
  text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px;
  text-decoration-color: color-mix(in srgb, var(--action) 55%, transparent);
  background: none; border: 0; padding: 0; cursor: pointer;
}
.link-go:hover { text-decoration-color: var(--action); }
.link-go svg { width: 14px; height: 14px; }

/* Panel */
.panel {
  /* Respiro interno do painel = --card-pad (24px no desktop, 20px até 640px); os filhos leem --panel-pad. */
  --panel-pad: var(--card-pad);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: none; min-width: 0; overflow: hidden;
}
.panel-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: var(--s-3); padding: var(--panel-pad, var(--s-5)) var(--panel-pad, var(--s-5)) var(--s-2);
}
.panel-title { margin: 0; font-family: var(--font-head); font-size: var(--fs-lg); font-weight: 500; letter-spacing: -0.01em; color: var(--text-primary); }
.panel-sub { margin: 2px 0 0; font-size: var(--fs-xs); color: var(--text-muted); }
.panel-body { padding: var(--s-1) var(--panel-pad, var(--s-5)) var(--panel-pad, var(--s-5)); }

/* Hero + kpi-strip */
.hero-value {
  margin-top: var(--s-2); font-family: var(--font-head); font-size: var(--fs-hero); font-weight: 500;
  letter-spacing: -0.02em; line-height: 1.15; color: var(--text-primary);
}
.hero-cur { margin-right: var(--s-2); font-size: var(--fs-xl); font-weight: 400; letter-spacing: 0; color: var(--text-secondary); }
.hero-note { margin-top: var(--s-2); font-size: var(--fs-xs); color: var(--text-muted); }

.kpi-strip {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(clamp(12rem, 22%, 18rem), 1fr));
  padding: var(--s-1); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: none;
}
/* Colunas determinísticas por quantidade de métricas (--cols/--nN vêm de kpiStrip): com auto-fit a faixa de 5
   quebrava em 4 + 1 entre ~1250 e 1450px e o separador ficava solto no item que abre a nova linha. Larguras
   menores redefinem as colunas abaixo, e cada faixa esconde o separador do primeiro item de cada linha. */
.kpi-strip--n2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.kpi-strip--n3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpi-strip--n4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpi-strip--n5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.kpi-strip-item {
  position: relative; display: block; min-width: 0;
  padding: var(--s-3) var(--s-4); border-radius: calc(var(--r-lg) - var(--s-1) - 1px); /* concêntrico ao kpi-strip */
  color: inherit; text-decoration: none;
}
.kpi-strip-item + .kpi-strip-item::before {
  content: ""; position: absolute; left: -2px; top: var(--s-3); bottom: var(--s-3);
  width: 1px; background: var(--border);
}
a.kpi-strip-item { transition: background var(--motion) var(--ease-out); }
a.kpi-strip-item:hover { background: var(--surface-interaction); }
.kpi-strip-label { display: flex; align-items: center; gap: var(--s-2); font-size: var(--fs-xs); color: var(--text-secondary); }
.kpi-strip-go { margin-left: auto; opacity: 0; color: var(--text-muted); transition: opacity var(--motion) var(--ease-out); }
a.kpi-strip-item:hover .kpi-strip-go,
a.kpi-strip-item:focus-visible .kpi-strip-go { opacity: 1; }
.kpi-strip-value {
  display: block; margin: var(--s-2) 0 2px; font-family: var(--font-head); font-size: var(--fs-xl); font-weight: 500;
  letter-spacing: -0.02em; font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--text-primary);
}
.kpi-strip-sub { font-size: var(--fs-2xs); color: var(--text-secondary); }
/* Botão centra o conteúdo na vertical: com itens de alturas diferentes na mesma linha o mais curto descia. Coluna alinhada ao topo. */
button.kpi-strip-item { display: flex; flex-direction: column; justify-content: flex-start; align-items: stretch; width: 100%; border: 0; background: none; font: inherit; text-align: left; cursor: pointer; }
button.kpi-strip-item:hover { background: var(--surface-interaction); }
button.kpi-strip-item:hover .kpi-strip-go,
button.kpi-strip-item:focus-visible .kpi-strip-go { opacity: 1; }
.skeleton + .skeleton { margin-top: var(--s-3); }
.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0, 0, 0, 0); white-space: nowrap;
}

/* Insight-line */
.insight-line {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-3) var(--s-4); background: var(--bg-structural);
  border: 1px solid var(--border); border-radius: var(--r-md);
  font-size: var(--fs-sm); color: var(--text-primary);
}
.insight-line.is-warning > svg { flex: none; width: 18px; height: 18px; color: var(--warning); }
.insight-line b { font-weight: 600; }
.insight-line .link-go { margin-left: auto; }

/* List row do contrato (não confundir com .list-row legado) */
.rows { list-style: none; margin: 0; padding: 0 var(--panel-pad, var(--s-5)) var(--s-2); }
.row-item {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-3) 0; border-bottom: 1px solid var(--border);
  color: inherit; text-decoration: none;
}
.rows > li:last-child .row-item { border-bottom: 0; }
.row-day { width: 22px; flex: none; font-size: var(--fs-xs); color: var(--text-muted); }
.row-main { flex: 1; min-width: 0; }
.row-title {
  display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: var(--fs-sm); font-weight: 500; color: var(--text-primary);
}
.row-meta { display: block; margin-top: 2px; font-size: var(--fs-2xs); color: var(--text-muted); }
.row-value { flex: none; font-size: var(--fs-sm); font-weight: 500; font-variant-numeric: tabular-nums; text-align: right; }
.row-item.is-transfer .row-value { color: var(--text-muted); }

/* Date badge */
.date-badge {
  flex: none; width: 38px; padding: var(--s-1) 0; text-align: center; line-height: 1.2;
  background: var(--surface-raised); border-radius: var(--r-sm);
}
.date-badge b { display: block; font-size: var(--fs-md); font-weight: 500; }
.date-badge small { font-size: var(--fs-2xs); color: var(--text-muted); }
.date-badge.is-today { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--warning) 45%, transparent); }
.date-badge.is-late { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--danger) 45%, transparent); }

/* Monograma (conta bancária, perfil) */
.mono {
  flex: none; display: grid; place-items: center; width: 32px; height: 32px;
  border-radius: var(--r-sm); background: var(--surface-interaction);
  font-size: var(--fs-2xs); font-weight: 600; letter-spacing: 0.3px; color: var(--text-secondary);
}

/* Rank bar (ranking por opacidade do azul) */
.rank-bars { display: grid; gap: var(--s-4); }
.rank-bar-head { display: flex; justify-content: space-between; gap: var(--s-3); margin-bottom: var(--s-2); font-size: var(--fs-xs); }
.rank-bar-head span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-secondary); }
.rank-bar-track { height: 5px; border-radius: var(--r-xs); background: var(--surface-interaction); overflow: hidden; }
.rank-bar-fill { display: block; height: 100%; border-radius: var(--r-xs); background: var(--chart-in); }

/* Segmented (filtro de status) */
.segmented {
  display: inline-flex; gap: 2px; padding: 3px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-pill);
}
.segmented-item {
  padding: 6px var(--s-3); border: 0; border-radius: var(--r-pill); background: none; cursor: pointer;
  font: inherit; font-size: var(--fs-xs); color: var(--text-secondary); white-space: nowrap;
  text-decoration: none;
}
.segmented-item:hover { color: var(--text-primary); }
.segmented-item[aria-current="true"],
.segmented-item[aria-pressed="true"] { background: var(--surface-interaction); color: var(--text-primary); }

/* KPI navegável (kpi-analytic, KPI-NAV-01): link que cobre o card. */
.kpi-card.is-linked { position: relative; transition: background var(--motion) var(--ease-out); }
.kpi-card.is-linked:hover { background: var(--surface-interaction); }

/* Tabela no celular: o card herda overflow-wrap:anywhere e quebrava valores no
   meio ("R$ 700,|00"). Na tabela, só quebra entre palavras; a tabela já rola
   na horizontal dentro do card. Valores usam NBSP entre símbolo e número. */
.data-table th,
.data-table td { overflow-wrap: normal; }

.dash-resumo {
  display: grid; grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.3fr);
  gap: var(--s-6); align-items: center; height: 100%;
}
@media (max-width: 1050px) {
  .dash-resumo { grid-template-columns: minmax(0, 1fr); gap: var(--s-4); }
}

/* DataTable (TABLE-01, gabarito §8): lista com separadores de 1px, sem zebra. */
.dt-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3); padding: var(--s-4) var(--panel-pad, var(--s-5)) var(--s-2); }
.dt-search {
  display: flex; align-items: center; gap: var(--s-2); flex: 1; min-width: 180px; max-width: 300px; height: 36px;
  padding: 0 var(--s-3); border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--surface-raised); color: var(--text-muted);
}
/* Anel do foco global no wrapper (o input interno fica sem contorno proprio). */
.dt-search:focus-within {
  border-color: var(--action); outline: 2px solid var(--accent); outline-offset: 2px; box-shadow: var(--ui-focus-ring);
}
.dt-search input {
  width: 100%; height: 100%; min-width: 0; border: 0; outline: 0; box-shadow: none; background: none;
  color: var(--text-primary); font: inherit; font-size: var(--fs-sm);
}
.dt-count { margin-left: auto; font-size: var(--fs-2xs); color: var(--text-muted); }
.dt-wrap { padding: 0 calc(var(--panel-pad, var(--s-5)) - 10px) var(--s-3); }
.dt { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--fs-sm); font-variant-numeric: tabular-nums; }
.dt th {
  padding: 10px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap;
  font-size: var(--fs-xs); font-weight: 500; letter-spacing: 0; color: var(--text-muted);
}
.dt td { padding: var(--s-3) 10px; border-bottom: 1px solid var(--border); vertical-align: middle; color: var(--text-primary); }
.dt tbody tr:last-child td { border-bottom: 0; }
.dt tbody tr:hover td { background: color-mix(in srgb, var(--surface-interaction) 50%, transparent); }
.dt .is-num, .dt td.dt-value { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.dt td small { display: block; margin-top: 1px; font-size: var(--fs-2xs); color: var(--text-muted); }
.dt-sort {
  display: inline-flex; align-items: center; gap: var(--s-1); padding: 0; border: 0; background: none; cursor: pointer;
  font: inherit; letter-spacing: inherit; color: inherit;
}
.dt-sort:hover { color: var(--text-primary); }
.dt-sort-ic { font-size: var(--fs-2xs); color: var(--action); }
.dt-actions { width: 1%; white-space: nowrap; text-align: right; }
.dt-actions .row-actions { justify-content: flex-end; flex-wrap: nowrap; }
.dt-pager {
  display: flex; align-items: center; justify-content: flex-end; gap: var(--s-3);
  padding: 0 var(--panel-pad, var(--s-5)) var(--s-4); font-size: var(--fs-xs); color: var(--text-muted);
}
/* Lista em cartões até 900px (revisão de UI #5): entre 700 e 900px a tabela de títulos espremia nomes em 3 linhas. */
@media (max-width: 900px) {
  .dt-search { max-width: none; }
  .dt-count { margin-left: 0; }
  .dt-wrap { padding: 0 var(--panel-pad, var(--s-4)) var(--s-2); }
  .dt thead { display: none; }
  .dt, .dt tbody { display: block; }
  .dt tr {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px var(--s-3);
    padding: var(--s-3) 0; border-bottom: 1px solid var(--border);
  }
  .dt tbody tr:last-child { border-bottom: 0; }
  .dt td { display: block; padding: 0; border: 0; }
  .dt tbody tr:hover td { background: none; }
  .dt td.dt-primary { grid-column: 1; grid-row: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
  .dt td.dt-value { grid-column: 2; grid-row: 1; text-align: right; font-weight: 500; }
  .dt td.dt-meta { grid-column: 1 / -1; font-size: var(--fs-xs); color: var(--text-secondary); }
  .dt td.dt-meta::before { content: attr(data-label) ": "; color: var(--text-muted); }
  .dt td.dt-actions { grid-column: 1 / -1; width: auto; margin-top: var(--s-2); text-align: right; }
  .dt-actions .row-actions { justify-content: flex-end; flex-wrap: wrap; }
  .dt-pager { justify-content: space-between; padding-inline: var(--s-4); }
  .dt-pager .btn { min-height: var(--hit); }
}

/* Faixa de filtros acima de uma lista (ex.: A pagar ?f=late) */
.page-filters { display: flex; flex-wrap: wrap; gap: var(--s-2); margin-bottom: var(--s-4); }
.page-filters .segmented { max-width: 100%; overflow-x: auto; }
/* Faixa de filtros rolável no celular (revisão de UI #4): a borda direita esmaece para mostrar que há mais itens,
   e o espaço extra no fim deixa o último item sair de baixo do esmaecimento. */
/* Título focado ao trocar de tela (finance-render.js focusRouteHeading): anel discreto que abraça o texto, em vez de
   uma caixa na largura toda (revisão de UI #9). O foco continua no título para leitores de tela. */
#app-content h1[tabindex="-1"] { width: fit-content; max-width: 100%; }
#app-content h1[tabindex="-1"]:focus-visible { outline: 2px solid color-mix(in srgb, var(--action) 70%, transparent); outline-offset: 4px; border-radius: var(--r-xs); box-shadow: none; }
@media (max-width: 700px) {
  .page-filters .segmented {
    scroll-snap-type: x proximity; padding-right: var(--s-6);
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - var(--s-6)), transparent);
    mask-image: linear-gradient(to right, #000 calc(100% - var(--s-6)), transparent);
  }
  .page-filters .segmented > * { scroll-snap-align: start; }
}

/* Status badge do contrato */
.status-badge {
  display: inline-flex; align-items: center; padding: 2px var(--s-2);
  border-radius: var(--r-pill); font-size: var(--fs-2xs); font-weight: 500; white-space: nowrap;
  color: var(--text-secondary); background: var(--surface-interaction);
}
.status-badge.is-ok { color: var(--success); background: color-mix(in srgb, var(--success) 10%, transparent); }
.status-badge.is-late { color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, transparent); }
.status-badge.is-today { color: var(--warning); background: color-mix(in srgb, var(--warning) 10%, transparent); }
.status-badge.is-link { color: var(--action); background: var(--action-soft); }
.status-badge.is-muted { color: var(--text-secondary); background: var(--surface-interaction); }

/* Estados: skeleton, vazio, erro, sem permissão */
.skeleton {
  display: block; height: 12px; border-radius: var(--r-xs);
  background: var(--surface-interaction); animation: skeleton-pulse 1.2s var(--ease-out) infinite alternate;
}
.skeleton.is-value { height: 24px; width: 60%; }
@keyframes skeleton-pulse { from { opacity: 0.55; } to { opacity: 1; } }
.state-block { padding: var(--s-8) var(--s-5); text-align: center; font-size: var(--fs-sm); color: var(--text-secondary); }
.state-block b { display: block; margin-bottom: var(--s-1); font-weight: 600; color: var(--text-primary); }
.state-block.is-error b { color: var(--danger); }
.state-block > span { display: block; }
.state-block .btn { margin-top: var(--s-3); }
/* Botão de ação em andamento (Atualizar): aparência de ocupado e sem clique. */
[data-action="refresh"][aria-busy="true"] { opacity: .6; pointer-events: none; }

/* Legenda com o mesmo traço da série */
.legend { display: flex; flex-wrap: wrap; gap: var(--s-4); font-size: var(--fs-2xs); color: var(--text-secondary); }
.legend span { display: inline-flex; align-items: center; gap: var(--s-2); }
.legend-swatch { width: 10px; height: 10px; border-radius: 2px; background: var(--chart-in); }
.legend-swatch.is-neutral { background: var(--text-muted); }
.legend-line { width: 14px; height: 0; border-top: 2px solid var(--text-primary); }
.legend-line.is-dashed { border-top-style: dashed; border-color: var(--text-muted); }

/* Catálogo interno /_components */
.components-catalog { max-width: var(--content-max); margin: 0 auto; padding: var(--s-8) var(--s-10) var(--s-10); }
.components-section { display: grid; gap: var(--s-3); margin-top: var(--s-8); }
.components-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--s-3); }
.components-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: var(--s-4); }

/* Faixas responsivas do contrato (§12). A faixa vira 2×2 já em ≤1050 (gabarito),
   para o valor nunca truncar com a sidebar ocupando espaço. */
@media (max-width: 1050px) {
  .kpi-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-strip-item:nth-child(odd)::before { display: none; }
}
/* Faixa de 3 métricas cabe numa linha até 700px (vira 2×2 só no celular). */
@media (min-width: 701px) and (max-width: 1050px) {
  .kpi-strip--n3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kpi-strip--n3 .kpi-strip-item:nth-child(odd)::before { display: block; }
  .kpi-strip--n3 .kpi-strip-item:first-child::before { display: none; }
}
@media (max-width: 700px) {
  .insight-line { flex-wrap: wrap; }
  .insight-line .link-go { margin-left: 0; min-height: var(--hit); }
  .segmented-item { min-height: var(--hit); min-width: var(--hit); }
  .components-catalog { padding: var(--s-6) var(--s-4) var(--s-8); }
}
@media (max-width: 420px) {
  .kpi-strip-item { padding: var(--s-2); }
  .kpi-strip-value { font-size: var(--fs-md); letter-spacing: 0; }
  .hero-value { font-size: var(--fs-2xl); }
}
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }

/* Ícones Lucide: traço 1.8 (contrato §2.6). */
svg[stroke="currentColor"][stroke-width="2"] { stroke-width: 1.8; }

/* ==========================================================================
   Sheet no celular (SHEET-01, plano V3 §4 e §12): até 700px, modal e diálogo
   de confirmação sobem da borda inferior. Cabeçalho e rodapé fixos; o conteúdo
   rola no meio. Foco preso, Escape e retorno do foco seguem o sistema de modal.
   ========================================================================== */
@keyframes sheet-up   { from { transform: translateY(100%); } to { transform: none; } }
@keyframes sheet-down { from { transform: none; } to { transform: translateY(100%); } }

@media (max-width: 700px) {
  .modal-backdrop {
    display: flex;
    align-items: flex-end;
    justify-content: stretch;
    padding: 0;
  }
  .modal-card,
  .dialog-card {
    width: 100%;
    max-width: none;
    min-height: 0;
    max-height: 92dvh;
    border: 1px solid var(--border);
    border-bottom: 0;
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    background: var(--surface-raised);
    box-shadow: var(--shadow-modal);
    animation: sheet-up var(--t-slow);
    padding-bottom: env(safe-area-inset-bottom, 0);
  }
  .modal-backdrop.is-closing .modal-card { animation: sheet-down var(--t-base) forwards; }
  /* Alça: só visual (arrastar para fechar não existe; fechar = ×, Escape ou fundo). */
  .modal-card::before {
    content: ""; flex: none; align-self: center;
    width: 36px; height: 4px; margin-top: var(--s-2);
    border-radius: var(--r-pill); background: var(--border-strong);
  }
  .modal-header {
    position: sticky; top: 0; z-index: 1;
    padding: var(--s-3) var(--s-5);
    background: var(--surface-raised);
  }
  .modal-body { padding: var(--s-4) var(--s-5); }
  .modal-footer {
    position: sticky; bottom: 0; z-index: 1;
    margin-top: var(--s-2);
    padding: var(--s-3) var(--s-5) var(--s-4);
    background: var(--surface-raised);
  }
}

/* ==========================================================================
   Acessibilidade (A11Y-01, plano V3 §13)
   ========================================================================== */
/* Campos de formulário com contorno visível (3:1). Foco e erro continuam
   com as regras próprias (maior especificidade). */
.input,
.select,
.textarea,
.dt-search { border-color: var(--border-input); }

/* Alvos de toque de 44px no celular (.btn, chips, ícones). No desktop esses controles seguem
   densos de propósito (tabelas e barras de filtro). Exceção em todos os viewports: ações de
   linha de tabela e atalhos dentro de .field-hint, regra "Alvo mínimo 44x44" mais abaixo. */
@media (max-width: 700px) {
  .btn { min-height: var(--hit); min-width: var(--hit); }
  .page-actions .btn { min-width: var(--hit); }
  .icon-btn { width: var(--hit); height: var(--hit); }
  .chip,
  .dash-chip { min-height: var(--hit); min-width: var(--hit); }
  .link-go { min-height: var(--hit); min-width: var(--hit); }
  .dt-search { height: var(--hit); }
}

/* Alto contraste pela preferência do app (Configurações → Aparência), com o mesmo
   reforço de contorno que o prefers-contrast já aplica. */
:root.contrast :is(.card, .panel, .kpi-strip, .input, .select, .textarea, .btn, .dt-search, .data-table, .modal-card) {
  border-color: var(--text-secondary);
}

.settings-aparencia { margin: 0 0 var(--s-4); padding: 0; border: 0; }
.settings-check {
  display: flex; align-items: flex-start; gap: var(--s-3); min-height: var(--hit);
  padding: var(--s-2) 0; cursor: pointer; font-size: var(--fs-sm); color: var(--text-primary);
}
.settings-check input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--action); flex: none; }
.settings-check small { display: block; margin-top: 2px; font-size: var(--fs-xs); color: var(--text-muted); }
/* Grupos segmentados de Aparência (tema, transparência, movimento). O anel na opção
   ativa dá o contraste de 3:1 do estado (WCAG 1.4.11); aria-pressed leva o estado ao leitor de tela. */
.settings-aparencia > legend { margin-bottom: var(--s-2); }
.settings-pref { margin: 0 0 var(--s-3); }
.settings-pref-label { display: block; margin-bottom: var(--s-2); font-size: var(--fs-sm); color: var(--text-primary); }
.settings-pref .seg { margin-bottom: 0; }
.settings-pref .seg-btn { min-height: var(--hit); }
.settings-pref .seg-btn.active { box-shadow: inset 0 0 0 1px var(--border-input); }
.settings-pref .seg-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.settings-pref-hint { display: block; margin-top: var(--s-2); font-size: var(--fs-xs); color: var(--text-muted); }
.settings-pref-hint[hidden] { display: none; }

/* Seleção (período do dashboard) em cinza: azul fica só para ação (paleta 27/09). */
.dash-periodo { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); }
.dash-periodo input { width: 150px; min-width: 0; }
.btn[data-action="dash-periodo-tipo"][aria-pressed="true"] {
  background: var(--surface-interaction); color: var(--text-primary); border-color: var(--border-strong);
}

/* DATA-01: bloco recolhível "Mais detalhes" nos formulários (vínculos + competência). */
.modal-more {
  margin: 0 0 var(--s-3); border: 1px solid var(--border); border-radius: var(--r-md);
}
.modal-more > summary {
  cursor: pointer; list-style: none; padding: var(--s-2) var(--s-3); min-height: 44px;
  display: flex; flex-wrap: wrap; align-items: center; gap: 0 var(--s-1); font-weight: 600; color: var(--text-primary);
}
.modal-more > summary .muted { font-weight: 400; }
.modal-more > summary::-webkit-details-marker { display: none; }
.modal-more > summary::after { content: '+'; margin-left: auto; color: var(--text-muted); }
.modal-more[open] > summary::after { content: '−'; }
.modal-more > summary:focus-visible { outline: 2px solid var(--action); outline-offset: 2px; border-radius: var(--r-md); }
.modal-more-body { padding: 0 var(--s-3) var(--s-1); }
.field-grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 var(--s-3); }
.field-check { display: flex; flex-direction: row; align-items: flex-start; gap: var(--s-2); padding-top: 26px; }
.field > .field-check { padding-top: 26px; margin-bottom: var(--s-2); }
.field-check input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--action-fill); }
.field-check .field-hint { display: block; }
.sidebar-loja { padding: 0 var(--s-2); }
@media (max-width: 700px) {
  .field-grid-2 { grid-template-columns: 1fr; }
  .field-check { padding-top: 0; }
}

/* DASH-02: linhas navegáveis, barra de progresso e mini-números dos panels. */
button.row-item.is-link {
  width: 100%; background: none; border: 0; border-bottom: 1px solid var(--border);
  font: inherit; text-align: left; cursor: pointer; min-height: 44px;
}
.rows > li:last-child button.row-item.is-link { border-bottom: 0; }
button.row-item.is-link:hover .row-title { color: var(--action); }
button.row-item.is-link:focus-visible { outline: 2px solid var(--action); outline-offset: 2px; border-radius: var(--r-sm); }
.progress-bar { height: 8px; border-radius: var(--r-pill); background: var(--surface-interaction); overflow: hidden; }
.progress-bar > span { display: block; height: 100%; border-radius: inherit; background: var(--action); }
.panel-body--tight { padding-bottom: 0; }
.panel-note { margin: var(--s-2) 0 0; font-size: var(--fs-2xs); color: var(--text-muted); }
.panel-note--foot { padding: 0 var(--panel-pad, var(--s-5)) var(--s-4); margin: 0; }
.mini-stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: var(--s-3);
  margin: 0 0 var(--s-3);
}
.mini-stats > div { min-width: 0; }
.mini-stats dt { font-size: var(--fs-2xs); color: var(--text-muted); }
.mini-stats dd { margin: 2px 0 0; font-size: var(--fs-sm); font-weight: 500; font-variant-numeric: tabular-nums; color: var(--text-primary); white-space: nowrap; }
.mini-stats dd.tone-neg { color: var(--danger); }
.dash-resumo--stack { grid-template-columns: minmax(0, 1fr); gap: var(--s-4); align-content: center; }
.dash-resumo-group { display: grid; gap: var(--s-2); min-width: 0; }
.dash-resumo-group-title { margin: 0; font-size: var(--fs-md); font-weight: 600; line-height: 1.4; letter-spacing: 0; color: var(--text-primary); }
.dash-resumo-group-title span { font-weight: 400; color: var(--text-muted); }
.dash-resumo-group .kpi-strip-label { font-size: var(--fs-sm); line-height: 1.4; align-self: start; }
.dash-resumo-group .kpi-strip-item { display: grid; grid-template-rows: 2.8em auto minmax(3.5em, auto); align-content: start; }
.dash-resumo-group .kpi-strip-sub { font-size: var(--fs-xs); line-height: 1.4; }
.dash-fixas-detail { padding: var(--s-2) var(--s-4); }
.dash-fixas-detail h3 { margin: 0 0 var(--s-2); color: var(--text-secondary); font-size: var(--fs-xs); font-weight: 600; }
.dash-fixas-detail .mini-stats { margin: 0; }
@media (max-width: 700px) {
  .dash-resumo-group .kpi-strip-item { container-type: inline-size; }
  .dash-resumo-group .kpi-strip-value { font-size: clamp(var(--fs-md), 10.5cqi, var(--fs-xl)); letter-spacing: -0.02em; }
}

/* Telas estreitas: o botão Menu vira só o ícone (continua com aria-label) para o nome caber. */
@media (max-width: 440px) {
  .topbar .icon-btn.nav-toggle > span { display: none; }
}
/* FIN-01: nome do título abre o detalhe; drawer lateral (≥701px); no celular é o painel inferior do SHEET-01. */
.dt-open {
  display: inline; padding: 0; border: 0; background: none; font: inherit; font-weight: 500;
  color: var(--text-primary); text-align: left; cursor: pointer;
}
.dt-open:hover { color: var(--action); }
.dt-open:focus-visible { outline: 2px solid var(--action); outline-offset: 2px; border-radius: var(--r-xs); }
@media (max-width: 700px) {
  .dt-open { display: inline-flex; align-items: center; min-height: var(--hit); min-width: var(--hit); }
  /* Topbar numa linha só: Menu | nome (ellipsis, espaço flexível) | 5 ícones de 40px. */
  /* Revisão de UI #8: o desenho fica em 40px para caber numa linha, mas a área de toque vai a 44px (2px para cada lado,
     dentro dos 4px de espaço entre os botões, sem sobrepor o vizinho). */
  .topbar :is(.icon-btn, .topbar-search, .topbar-avatar-btn, .btn.topbar-novo) { position: relative; }
  .topbar :is(.icon-btn, .topbar-search, .topbar-avatar-btn, .btn.topbar-novo)::after { content: ""; position: absolute; inset: -2px; }
  .topbar { height: var(--header-h); min-height: 0; padding: 0 var(--s-2); gap: var(--s-1); align-items: center; flex-wrap: nowrap; }
  .topbar-crumbs { flex: 1 1 0; min-width: 0; }
  .topbar-tools { flex: none; flex-wrap: nowrap; max-width: none; gap: 0; }
  .topbar .icon-btn { width: 40px; height: 40px; }
  .topbar .icon-btn.nav-toggle { width: auto; min-width: 40px; padding: 0 var(--s-2); }
  .topbar-crumbs > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topbar-crumbs > b,
  .topbar-crumbs > span[aria-hidden="true"] { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }
  .page-actions .dash-periodo .btn { width: auto; flex: 1; }
  .dash-periodo { width: 100%; grid-column: 1 / -1; }
  .dash-periodo input { flex: 1; }
  .page-actions > .btn:only-child,
  .page-actions > .dash-periodo + .btn { grid-column: 1 / -1; }
}
.dt-sub { display: block; margin-top: 2px; font-size: var(--fs-2xs); color: var(--text-muted); overflow-wrap: anywhere; }
@media (min-width: 701px) {
  .modal-backdrop--drawer { display: flex; justify-content: flex-end; align-items: stretch; padding: 0; }
  .modal-card--drawer {
    width: min(440px, 100vw); max-width: 100vw; max-height: none; height: 100dvh;
    border-radius: 0; border-width: 0 0 0 1px; animation: drawer-in var(--t-slow);
  }
  .modal-backdrop--drawer.is-closing .modal-card { animation: drawer-out var(--t-base) forwards; }
  .modal-card--drawer .modal-footer { margin-top: auto; position: sticky; bottom: 0; background: var(--s0); }
}
@keyframes drawer-in  { from { transform: translateX(100%); } to { transform: none; } }
@keyframes drawer-out { from { transform: none; } to { transform: translateX(100%); } }
.titulo-detalhe-topo { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-3); margin-bottom: var(--s-4); }
.titulo-detalhe-valor { margin: var(--s-1) 0 0; font-family: var(--font-head); font-size: 2rem; font-weight: 500; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; color: var(--text-primary); white-space: nowrap; }
.detalhe-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-3) var(--s-4); margin: 0; }
.detalhe-grid dt { font-size: var(--fs-2xs); color: var(--text-muted); }
.detalhe-grid dd { margin: 2px 0 0; font-size: var(--fs-sm); color: var(--text-primary); overflow-wrap: anywhere; }
.titulo-detalhe-desc { margin: var(--s-4) 0 0; font-size: var(--fs-sm); color: var(--text-secondary); overflow-wrap: anywhere; }
.titulo-detalhe-desc .field-label { display: block; margin-bottom: var(--s-1); }
.titulo-detalhe-acoes { display: flex; flex-wrap: wrap; gap: var(--s-2); justify-content: flex-end; }
.titulo-detalhe-acoes .is-danger { margin-right: auto; color: var(--danger); }

/* FIN-01: faixa de 5 números (A pagar/A receber) vira 3 + 2 entre 1051 e 1320px, para o valor não cortar
   (acima disso cabe em 5 colunas; abaixo, as regras de 2 colunas valem). */
@media (min-width: 1051px) and (max-width: 1320px) {
  .kpi-strip--n5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kpi-strip--n5 .kpi-strip-item:nth-child(3n + 1)::before { display: none; }
}
/* Valor da faixa acompanha a largura da coluna (até o tamanho padrão): milhões cabem sem cortar. */
@media (min-width: 701px) {
  .kpi-strip-item { container-type: inline-size; }
  .kpi-strip-value { font-size: clamp(var(--fs-md), 10.5cqi, var(--fs-xl)); }
}
/* A11Y: no painel inferior (fundo surface-raised) o selo "Empresarial" ficava em 4,43:1; tinta mais leve → ≥ 4,5:1. */
@media (max-width: 700px) {
  .modal-card .modal-workspace-badge-empresarial { background: color-mix(in srgb, var(--action) 8%, transparent); }
}
/* FIN-01: respiro entre a faixa de números e os filtros da lista. */
.kpi-strip + .page-filters { margin-top: var(--s-4); }

/* REC-01: parcelas e série no detalhe do título. */
.titulo-detalhe-bloco { margin-top: var(--s-5); padding-top: var(--s-4); border-top: 1px solid var(--border); display: grid; gap: var(--s-2); justify-items: start; }
.parcelas-lista { list-style: none; margin: 0; padding: 0; width: 100%; display: grid; gap: 2px; }
.parcela-item {
  width: 100%; min-height: 44px; display: grid; grid-template-columns: 3.2em 4.2em 1fr auto; align-items: center; gap: var(--s-2);
  padding: var(--s-1) var(--s-2); border: 0; border-radius: var(--r-sm); background: none; color: var(--text-primary);
  font: inherit; font-size: var(--fs-xs); text-align: left; cursor: pointer;
}
.parcela-item:hover { background: var(--surface-interaction); }
.parcela-item.is-atual { background: var(--surface-interaction); font-weight: 600; }
.parcela-item .status-badge { justify-self: start; }
.parcela-item:focus-visible { outline: 2px solid var(--action); outline-offset: 1px; }

/* Detalhe do título no celular: ação principal em cima, as demais 2 por linha (rodapé mais baixo). */
@media (max-width: 700px) {
  .titulo-detalhe-acoes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-2); }
  .titulo-detalhe-acoes .btn { width: 100%; min-width: 0; margin: 0; }
  .titulo-detalhe-acoes .btn-primary { grid-column: 1 / -1; order: -1; }
  .titulo-detalhe-acoes .is-danger { margin-right: 0; }
}

/* Dashboard fixo: painéis adaptáveis ao conteúdo; altura máxima responsiva. */
.dash-fixo-corpo { 
  display: grid; 
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); 
  gap: var(--s-5); 
  container: dash-fixo / inline-size;
}
.dash-row { display: contents; }
.dash-row > * { min-width: 0; }
.dash-fixo-corpo .panel { position: relative; height: auto; max-height: clamp(480px, 70vh, 900px); margin: 0; overflow: visible; }
.dash-fixo-corpo .panel > .panel-head { min-height: 86px; background: transparent; }
.dash-fixo-corpo > .dash-resumo { height: auto; grid-column: 1 / -1; }
.dash-fixo-corpo > .insight-line { margin: 0; grid-column: 1 / -1; }
/* Estado vazio ocupa a linha inteira: não estica ao lado do gráfico nem deixa vão. */
.dash-fixo-corpo > .empty-state { grid-column: 1 / -1; margin: 0; }

@media (max-width: 700px) { .dash-fixo-corpo .panel { max-height: clamp(440px, 65vh, 800px); } }

@container dash-fixo (max-width: 500px) {
  .dash-fixo-corpo .panel { max-height: clamp(400px, 60vh, 700px); }
  .dash-fixo-corpo .panel .kpi-strip { grid-template-columns: minmax(0, 1fr); }
  .dash-fixo-corpo .panel .kpi-strip-item + .kpi-strip-item::before { display: none; }
}
.dre-page { display: grid; gap: var(--s-5); }
.dre-month-nav { display: flex; align-items: center; gap: var(--s-2); }
.dre-month-nav .input { width: min(240px, 100%); min-width: 0; }
.dre-month-nav .btn { min-width: var(--hit); min-height: var(--hit); }
.dre-overview { display: grid; gap: var(--s-5); min-width: 0; }
.dre-result-head { display: grid; grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.5fr); align-items: center; gap: var(--s-5); }
.dre-result-value { min-width: 0; }
.dre-result-value > strong { display: block; margin-top: var(--s-2); font-family: var(--font-head); font-size: clamp(var(--fs-xl), 3vw, var(--fs-hero)); font-weight: 500; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.dre-result-value p { margin: var(--s-2) 0 0; font-size: var(--fs-xs); color: var(--text-secondary); }
.dre-story-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-5); min-width: 0; }
.dre-story-grid > .panel { min-width: 0; }
.dre-story-grid .panel-head { min-height: 90px; }
.dre-flow { list-style: none; margin: 0; padding: 0; }
.dre-flow-stage { padding: var(--s-3) 0; border-bottom: 1px solid var(--border); }
.dre-flow-stage:first-child { padding-top: 0; }
.dre-flow-stage:last-child { border-bottom: 0; }
.dre-flow-heading { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s-3); font-size: var(--fs-sm); }
.dre-flow-heading > span { min-width: 0; color: var(--text-secondary); }
.dre-flow-heading > strong { font-size: var(--fs-md); font-weight: 600; }
.dre-flow-stage p { margin: var(--s-1) 0 0; font-size: var(--fs-2xs); color: var(--text-secondary); }
.dre-flow-stage--result .dre-flow-heading > span { color: var(--text-primary); font-weight: 600; }
.dre-flow-track { height: 4px; margin-top: var(--s-2); border-radius: var(--r-xs); overflow: hidden; background: var(--surface-interaction); }
.dre-flow-track > span { display: block; height: 100%; background: var(--text-secondary); }
.dre-flow-stage:first-child .dre-flow-track > span { background: var(--chart-in); }
.dre-flow-stage--result .dre-flow-track > span { background: var(--chart-result); }
.dre-flow-track > span.is-negative { background: var(--chart-neg); }
.dash-row .dre-flow-stage { padding-block: var(--s-2); }
.dash-row .dre-flow-heading, .dash-row .dre-flow-stage p { line-height: 1.4; }
.dash-row .dre-flow-track { margin-top: var(--s-1); height: 3px; }
.dre-cost-totals { margin: 0 0 var(--s-5); }
.dre-cost-totals > div { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s-3); padding: var(--s-4) 0; border-bottom: 1px solid var(--border); }
.dre-cost-totals > div:first-child { padding-top: 0; }
.dre-cost-totals dt { min-width: 0; font-size: var(--fs-sm); color: var(--text-primary); }
.dre-cost-totals small { display: block; margin-top: var(--s-1); font-size: var(--fs-2xs); color: var(--text-secondary); }
.dre-cost-totals dd { margin: 0; font-size: var(--fs-md); font-weight: 600; }
.dre-costs h3 { margin: 0 0 var(--s-3); font-size: var(--fs-sm); font-weight: 600; }
@media (max-width: 1050px) {
  .dre-result-head, .dre-story-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 700px) {
  .dre-flow-heading, .dre-cost-totals > div { flex-wrap: wrap; gap: var(--s-1) var(--s-3); }
  .dre-flow-heading > strong, .dre-cost-totals dd { margin-left: auto; }
  .dre-result-head .kpi-strip { grid-template-columns: minmax(0, 1fr); }
  .dre-result-head .kpi-strip-item + .kpi-strip-item::before { display: none; }
}
.fv-linha { display: grid; gap: var(--s-1); margin-bottom: var(--s-4); }
.fv-head { display: flex; justify-content: space-between; gap: var(--s-3); font-size: var(--fs-sm); color: var(--text-secondary); }
.fv-head > span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fv-head .num { color: var(--text-primary); font-weight: 500; white-space: nowrap; }
.metas-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0 var(--s-6); }
/* Linha de cotações das moedas mais usadas (dashboard Pessoal). */
.cotacoes-linha {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--s-1) var(--s-4);
  margin: 0 0 var(--s-5); font-size: var(--fs-xs); color: var(--text-secondary);
}
.cotacoes-rotulo { font-size: var(--fs-2xs); font-weight: 600; color: var(--text-secondary); }
.cotacao-item { white-space: nowrap; }
.cotacao-item b { font-weight: 600; color: var(--text-primary); }
.cotacao-data { font-size: var(--fs-2xs); color: var(--text-secondary); }
/* No escuro, sobre o vidro com papel de parede claro, o cinza secundário fica abaixo de 4,5:1. */
:root[data-theme="dark"] .cotacoes-rotulo,
:root[data-theme="dark"] .cotacao-data { color: var(--text-primary); }


/* ============================================================================
   DASH-03 — gráficos e informações extras do dashboard (28/09/2026)
   Só tokens existentes: azul = série principal, cinza = comparação,
   verde/vermelho = resultado/estado (mesmo significado do resto do app).
   ============================================================================ */
.chart-zero { stroke: var(--border-strong); stroke-width: 1; stroke-dasharray: 3 3; }

/* Receitas × Despesas (linhas com área) */
.ln-income-line  { stroke: var(--chart-in); stroke-width: 2.25; stroke-linejoin: round; stroke-linecap: round; }
.ln-income-area  { fill: color-mix(in srgb, var(--chart-in) 16%, transparent); }
.ln-income-dot   { fill: var(--chart-in); stroke: var(--surface); stroke-width: 1.5; }
.ln-expense-line { stroke: var(--chart-out); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.ln-expense-area { fill: color-mix(in srgb, var(--chart-out) 16%, transparent); }
.ln-expense-dot  { fill: var(--chart-out); stroke: var(--surface); stroke-width: 1.5; }

/* Comparativo mensal: azul para resultado, vermelho para saída maior que entrada. */
.bar-result      { fill: var(--chart-in); }
.bar-result--neg { fill: var(--chart-neg); }
.sw-result       { background: var(--chart-in); }

/* Projeção em leque */
.fan-area       { fill: color-mix(in srgb, var(--chart-in) 8%, transparent); }
.fan-base       { stroke: var(--chart-in); stroke-width: 2.5; stroke-linejoin: round; }
.fan-otimista   { stroke: var(--chart-result); stroke-width: 1.75; stroke-dasharray: 5 4; }
.fan-pessimista { stroke: var(--chart-neg); stroke-width: 1.75; stroke-dasharray: 5 4; }
.fan-hoje       { fill: var(--text-primary); stroke: var(--surface); stroke-width: 2; }
.fan-tag text   { font-size: .8571rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.fan-base-tag rect       { fill: color-mix(in srgb, var(--chart-in) 18%, var(--surface)); }
.fan-base-tag text       { fill: var(--action); }
.fan-otimista-tag rect   { fill: color-mix(in srgb, var(--chart-result) 16%, var(--surface)); }
.fan-otimista-tag text   { fill: var(--success); }
.fan-pessimista-tag rect { fill: color-mix(in srgb, var(--chart-neg) 16%, var(--surface)); }
.fan-pessimista-tag text { fill: var(--danger); }

/* Saúde do período: medidor + meta */
.saude { display: grid; gap: var(--s-5); }
.gauge-svg { display: block; width: 100%; max-width: 220px; height: auto; margin: 0 auto; }
.gauge-track { stroke: var(--surface-interaction); }
.gauge-pos { stroke: var(--success); }
.gauge-warn { stroke: var(--warning); }
.gauge-neg { stroke: var(--danger); }
.gauge-neutro { stroke: var(--text-muted); }
.gauge-num { fill: var(--text-primary); font-size: var(--fs-xl); font-weight: 700; font-variant-numeric: tabular-nums; }
.gauge-cap { fill: var(--text-muted); font-size: var(--fs-2xs); }
.saude-meta { display: grid; gap: var(--s-2); padding-top: var(--s-4); border-top: 1px solid var(--border); }
.saude-meta-titulo { margin: 0; font-size: var(--fs-sm); font-weight: 600; color: var(--text-primary); }
.saude-meta .state-block { padding: var(--s-2) 0; }
.panel-note.tone-neg { color: var(--danger); }

/* Janela dos gráficos mensais */
.panel-body > .segmented { margin-bottom: var(--s-4); }

/* Donuts por categoria */
.legend-pct { min-width: 4ch; text-align: right; color: var(--text-muted); font-size: var(--fs-2xs); }

/* Onde está o dinheiro: barra de composição */
.alloc-bar {
  display: flex; gap: 2px; height: 12px; overflow: hidden;
  border-radius: var(--r-sm); background: var(--surface-interaction);
}
.alloc-seg { height: 100%; min-width: 3px; }
.alloc-legend {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
  gap: var(--s-4); margin: var(--s-4) 0 0; padding: 0; list-style: none;
}
.alloc-legend li { display: grid; grid-template-columns: 10px minmax(0, 1fr); column-gap: var(--s-2); align-items: center; min-width: 0; }
.alloc-legend i { width: 10px; height: 10px; border-radius: 3px; }
.alloc-label { font-size: var(--fs-2xs); color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.alloc-pct { grid-column: 1 / -1; font-size: var(--fs-xl); font-weight: 600; color: var(--text-primary); line-height: 1.2; }
.alloc-val { grid-column: 1 / -1; font-size: var(--fs-2xs); color: var(--text-muted); white-space: nowrap; }

/* Pontos de atenção */
.sev-wrap { overflow-x: auto; }
/* Tabela dentro de painel/card: o conteúdo respeita o raio do cartão (cabeçalho e linhas não
   vazam pelos cantos). overflow: clip só nos painéis que contêm tabela, sem popovers próprios. */
:is(.panel, .card) > :is(.sev-wrap, .dt-wrap, .table-scroll) { border-radius: 0 0 calc(var(--r-lg) - 1px) calc(var(--r-lg) - 1px); }
.dash-fixo-corpo .panel:has(> :is(.sev-wrap, .dt-wrap, .table-scroll)) { overflow: clip; border-radius: var(--r-lg); }
.sev-table thead th { background: transparent; }
.sev-table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.sev-table th, .sev-table td { padding: var(--s-3) var(--s-5); border-top: 1px solid var(--border); text-align: left; vertical-align: middle; }
.sev-table thead th { border-top: 0; font-size: var(--fs-2xs); font-weight: 500; color: var(--text-muted); }
.sev-titulo { font-weight: 500; color: var(--text-primary); }
.sev-table td.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.sev-table td.num.tone-neg { color: var(--danger); }
.sev-table thead th:nth-child(4) { text-align: right; }
.sev-acao { width: 1%; text-align: right; white-space: nowrap; }
@media (max-width: 700px) {
  .sev-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .sev-table, .sev-table tbody { display: block; }
  .sev-table tr {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--s-1) var(--s-3);
    padding: var(--s-3) var(--s-5); border-top: 1px solid var(--border);
  }
  .sev-table th, .sev-table td { padding: 0; border: 0; }
  .sev-titulo { grid-column: 1 / -1; }
  .sev-table td[data-label="Prazo"] { color: var(--text-muted); font-size: var(--fs-2xs); }
  .sev-table td.num { text-align: left; }
  .sev-acao { grid-column: 2; grid-row: 2 / span 3; align-self: center; }
}
.legend-num { display: grid; justify-items: end; line-height: 1.25; }
.saude-meta-valor { margin: 0; font-size: var(--fs-sm); font-weight: 600; color: var(--text-primary); }

/* Importação de extrato/fatura: revisão antes de movimentar a conta. */
.import-panel { margin-bottom: var(--s-5); }
.account-card--selected { border-color: var(--action); }
.account-history { margin-top: var(--s-5); }
.account-history-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--s-4); }
.account-history-head h2 { margin: 0 0 var(--s-2); font-size: var(--fs-lg); }
.account-history-head p { margin: 0; }
.account-history-eyebrow { color: var(--text-muted); font-size: var(--fs-2xs); font-weight: 600; }
.account-history-filters { display: flex; flex-wrap: wrap; align-items: end; gap: var(--s-3); margin: var(--s-5) 0; }
.account-history-filters label { display: grid; gap: var(--s-2); color: var(--text-secondary); font-size: var(--fs-sm); }
.account-history-filters .input { min-width: 155px; }
.account-history-count { margin: 0 0 var(--s-3); font-size: var(--fs-sm); }
.account-history-table { min-width: 650px; }
.account-history-table th:nth-child(n+4), .account-history-table td:nth-child(n+4) { text-align: right; white-space: nowrap; }
.account-history-table td:nth-child(2) { min-width: 220px; overflow-wrap: anywhere; }
.account-history-origin { display: block; }
.account-history-pages { display: flex; justify-content: flex-end; gap: var(--s-2); margin-top: var(--s-4); }
@media (max-width: 700px) {
  .account-history-head { flex-direction: column; }
  .account-history-filters label { flex: 1 1 130px; }
  .account-history-table { min-width: 0; }
  .account-history-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .account-history-table, .account-history-table tbody { display: block; width: 100%; }
  .account-history-table tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--s-2); padding: var(--s-4) 0; border-top: 1px solid var(--border); }
  .account-history-table td { display: block; min-width: 0; padding: 0; border: 0; }
  .account-history-table td:nth-child(1) { grid-column: 1; grid-row: 1; color: var(--text-muted); }
  .account-history-table td:nth-child(2) { grid-column: 1 / -1; grid-row: 2; min-width: 0; }
  .account-history-table td:nth-child(3) { grid-column: 1; grid-row: 3; color: var(--text-muted); }
  .account-history-table td:nth-child(4) { grid-column: 2; grid-row: 1; }
  .account-history-table td:nth-child(5) { grid-column: 2; grid-row: 3; color: var(--text-muted); }
  .account-history-table td:nth-child(5)::before { content: 'Saldo após '; font-size: var(--fs-2xs); }
  .account-history-table tr:has(.table-empty) { display: block; }
}
.import-controls, .import-mapping { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 210px), 1fr)); gap: var(--s-3); }
.import-mapping { margin-top: var(--s-4); padding-top: var(--s-4); border-top: 1px solid var(--border); }
.import-field { display: grid; gap: var(--s-2); min-width: 0; color: var(--text-secondary); font-size: var(--fs-sm); }
.import-file-picker { position: relative; display: inline-flex; align-items: center; justify-content: center; min-height: var(--hit); padding: 0 var(--s-4); border: 1px solid var(--border-input); border-radius: var(--r-sm); color: var(--text-primary); cursor: pointer; }
.import-file-picker input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.import-file-picker:focus-within { outline: 2px solid var(--action); outline-offset: 2px; }
.import-map-details { margin-top: var(--s-4); }
.import-map-details summary { color: var(--text-secondary); cursor: pointer; font-size: var(--fs-sm); }
.import-panel .panel-note { margin: var(--s-4) 0; }
.import-summary { margin: var(--s-4) 0; padding: var(--s-3); border: 1px solid var(--border); border-radius: var(--r-md); color: var(--text-secondary); font-size: var(--fs-sm); }
.import-summary strong { color: var(--text-primary); }
.import-table-wrap { max-height: 480px; overflow: auto; border: 1px solid var(--border); border-radius: var(--r-md); }
.import-table { min-width: 850px; }
.import-table thead { position: sticky; top: 0; z-index: 1; background: var(--surface); }
.import-table th[scope="row"] { font-weight: 500; min-width: 180px; max-width: 340px; overflow-wrap: anywhere; }
.import-table .select { min-width: 120px; }
.import-table td.num { white-space: nowrap; font-variant-numeric: tabular-nums; }
.import-scroll-hint { margin: 0 0 var(--s-2); color: var(--text-muted); font-size: var(--fs-xs); }
.import-duplicate { opacity: .6; }
.import-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: var(--s-3); margin-top: var(--s-4); }

/* === Vendas e contratos (Empresarial) ===
   Abas e filtros usam só tokens existentes; a comparação mensal reutiliza a grade do DRE (.dre-grid). */
.vendas-tabs { display: flex; gap: var(--s-1); margin: 0 0 var(--s-4); border-bottom: 1px solid var(--border); overflow-x: auto; }
.vendas-tab {
  min-height: var(--hit); padding: 0 var(--s-4); border: 0; border-radius: var(--r-sm) var(--r-sm) 0 0; background: none;
  font: inherit; font-size: var(--fs-sm); font-weight: 500; color: var(--text-secondary); white-space: nowrap; cursor: pointer;
}
.vendas-tab:hover { color: var(--text-primary); background: var(--surface-interaction); }
.vendas-tab[aria-selected="true"] { color: var(--text-primary); font-weight: 600; box-shadow: inset 0 -2px 0 var(--action); }
.vendas-tab:focus-visible { outline: 2px solid var(--action); outline-offset: -2px; }
.vendas-painel { display: grid; gap: var(--s-4); min-width: 0; }
.vendas-painel:focus { outline: none; }
.vendas-filtros { display: grid; gap: var(--s-3); }
.vendas-filtros-linha { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--s-3) var(--s-4); }
.vendas-field { margin: 0; min-width: 0; }
.vendas-filtro-grupo { display: grid; gap: var(--s-1); min-width: 0; }
.vendas-filtro-rotulo { font-size: var(--fs-2xs); color: var(--text-muted); }
.vendas-filtros .segmented { max-width: 100%; overflow-x: auto; }
.vendas-aviso { margin: 0; padding: var(--s-3) var(--s-4); border: 1px solid var(--border); border-radius: var(--r-sm); font-size: var(--fs-xs); color: var(--text-secondary); }
.vendas-aviso.is-erro { border-color: var(--danger); color: var(--text-primary); }
.vendas-vazio-acoes { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--s-2); padding: 0 var(--s-4) var(--s-6); }
.dt-origem { padding: 0; border: 0; background: none; font: inherit; color: var(--link); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.dt-origem:focus-visible { outline: 2px solid var(--action); outline-offset: 2px; border-radius: var(--r-xs); }
@media (max-width: 700px) { .dt-origem { display: inline-flex; align-items: center; min-height: var(--hit); } }

/* Comparação mensal: título de grupo dentro da grade do DRE e resumo de um mês para o celular. */
.vendas-grupo > .dre-l .dre-l-text small { font-weight: 400; color: var(--text-muted); }
.vendas-comp .dre-r--item > .dre-l { padding-left: 24px; }
.vendas-comp-celular { display: none; }
.vendas-mini { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); font-variant-numeric: tabular-nums; }
.vendas-mini th, .vendas-mini td { padding: var(--s-2); border-bottom: 1px solid var(--border); text-align: left; font-weight: 400; }
.vendas-mini thead th { font-size: var(--fs-2xs); color: var(--text-muted); font-weight: 600; }
.vendas-mini .num { text-align: right; white-space: nowrap; }
.vendas-mini-grupo th { padding-top: var(--s-4); font-size: var(--fs-2xs); font-weight: 600; color: var(--text-secondary); }
@media (max-width: 700px) {
  .vendas-comp-celular { display: grid; gap: var(--s-3); }
  .vendas-filtros .segmented-item, .vendas-filtros .input-sm { min-height: var(--hit); }
  .vendas-filtros-linha > .vendas-field { flex: 1 1 140px; }
  /* Celular: cada grupo de filtro ocupa a linha; a faixa rolável é definida no bloco "Auditoria 12/10/2026". */
  .vendas-filtros-linha > .vendas-filtro-grupo, .vendas-filtros-linha > .segmented { flex: 1 1 100%; min-width: 0; }
}

/* Formulário de venda e contrato. */
.venda-sub { margin: 0 0 var(--s-2); font-size: var(--fs-sm); font-weight: 600; color: var(--text-primary); }
.venda-itens { display: grid; gap: var(--s-3); }
.venda-item { display: grid; gap: var(--s-2); min-width: 0; margin: 0; padding: var(--s-3); border: 1px solid var(--border); border-radius: var(--r-sm); }
.venda-item legend { padding: 0; }
.venda-item-topo { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); min-height: 28px; }
.venda-item-n { font-size: var(--fs-2xs); font-weight: 600; color: var(--text-muted); }
.venda-item-linha { display: grid; grid-template-columns: minmax(0, 0.7fr) minmax(0, 1fr) minmax(0, 1fr); gap: var(--s-2); }
.venda-item-total { display: flex; align-items: center; min-height: var(--hit); font-size: var(--fs-sm); color: var(--text-primary); white-space: nowrap; }
.venda-add { justify-self: start; }
.venda-totais { display: grid; gap: var(--s-1); padding: var(--s-3) var(--s-4); border-radius: var(--r-sm); background: var(--surface-interaction); }
.venda-totais dl { display: grid; gap: var(--s-1); margin: 0; }
.venda-totais dl > div { display: flex; justify-content: space-between; gap: var(--s-3); font-size: var(--fs-sm); color: var(--text-secondary); }
.venda-totais dd { margin: 0; }
.venda-totais .is-total { font-weight: 600; color: var(--text-primary); }
.venda-totais .is-total dd { font-size: var(--fs-md); }
.venda-totais .field-hint { margin: 0; }
.venda-erro { color: var(--danger); }
.venda-erro:empty { display: none; }
.venda-recebi-bloco { gap: var(--s-2); }
.venda-recebi-check { padding-top: 0; }
.venda-recebi { margin-top: var(--s-2); }
.venda-ciclos-aviso { margin: 0; padding: var(--s-3) var(--s-4); border-left: 3px solid var(--warning); border-radius: var(--r-xs); background: var(--surface-interaction); font-size: var(--fs-xs); color: var(--text-primary); }
.venda-form [hidden] { display: none; }
@media (max-width: 700px) {
  .venda-item-linha { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .venda-item-linha > .field:last-child { grid-column: 1 / -1; }
}

/* Detalhe da venda e do contrato (drawer). */
.venda-lista { list-style: none; margin: 0; padding: 0; width: 100%; display: grid; gap: var(--s-1); }
.venda-lista > li { display: grid; grid-template-columns: 4.2em 1fr auto; align-items: center; gap: var(--s-2); min-height: 36px; font-size: var(--fs-xs); color: var(--text-primary); }
.venda-lista .num { font-variant-numeric: tabular-nums; text-align: right; }
.venda-lista-n { color: var(--text-muted); }
.venda-lista-meta { grid-column: 1 / -1; color: var(--text-muted); overflow-wrap: anywhere; }
.venda-lista .is-estornado { color: var(--text-muted); }
.venda-lista .is-estornado .num { text-decoration: line-through; }
.venda-lista--eventos > li { grid-template-columns: 5.5em 1fr; }
.venda-lista--ciclos > li { display: block; }
.venda-ciclo {
  width: 100%; min-height: var(--hit); display: grid; grid-template-columns: 4.8em 5.4em 1fr auto; align-items: center; gap: var(--s-2);
  padding: var(--s-1) var(--s-2); border: 0; border-radius: var(--r-sm); background: none; color: var(--text-primary);
  font: inherit; font-size: var(--fs-xs); text-align: left; cursor: pointer;
}
.venda-ciclo:hover { background: var(--surface-interaction); }
.venda-ciclo:focus-visible { outline: 2px solid var(--action); outline-offset: 1px; }
.venda-ciclo .num { text-align: right; font-variant-numeric: tabular-nums; }
.venda-tabela { width: 100%; border-collapse: collapse; font-size: var(--fs-xs); font-variant-numeric: tabular-nums; }
.venda-tabela th, .venda-tabela td { padding: var(--s-2) var(--s-1); border-bottom: 1px solid var(--border); text-align: left; font-weight: 400; vertical-align: top; }
.venda-tabela thead th { font-size: var(--fs-2xs); color: var(--text-muted); font-weight: 600; }
.venda-tabela tbody th { overflow-wrap: anywhere; color: var(--text-primary); }
.venda-tabela .num { text-align: right; white-space: nowrap; }
.venda-editar-desc { justify-self: start; margin-top: var(--s-2); }

/* Menu "⋯" das ações da linha (listas de lançamentos e admin) */
.row-menu { position: relative; }
.row-menu > summary { list-style: none; min-width: 36px; justify-content: center; }
.row-menu > summary::-webkit-details-marker { display: none; }
/* Alvo mínimo 44x44 nos botões de ação da linha (WCAG 2.5.8 / R-03). */
.row-actions .btn-sm, .row-menu > summary, .row-menu-item, td > .btn-sm, .field-hint .btn-sm { min-block-size: var(--hit); min-inline-size: var(--hit); }
.row-menu-pop {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 20; display: grid; min-width: 160px; padding: var(--s-1);
  border: 1px solid var(--border-strong); border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow-pop);
  transform-origin: top right; animation: popover-in var(--motion) var(--ease-out);
}
.row-menu-item { justify-content: flex-start; width: 100%; border: 0; }
@media (max-width: 700px) { .row-menu-pop { right: auto; left: 0; transform-origin: top left; } }
/* No app o popover vira position: fixed (app-hotfix.js), então tabelas com rolagem não o cortam. */
.row-menu-item.is-danger { color: var(--danger, var(--text-primary)); }

/* Histórico do lançamento (modal): linha do tempo de quem fez o quê */
.historico-lista { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s-1); }
.historico-item { display: grid; grid-template-columns: 1fr auto; gap: 2px var(--s-3); padding: var(--s-3) 0; border-bottom: 1px solid var(--border); }
.historico-item:last-child { border-bottom: 0; }
.historico-acao { font-weight: 600; color: var(--text-primary); }
.historico-quando { font-size: var(--fs-2xs); color: var(--text-muted); text-align: right; white-space: nowrap; }
.historico-quem { grid-column: 1 / -1; font-size: var(--fs-2xs); color: var(--text-muted); }

/* ==========================================================================
   Entrada dos blocos na troca de tela (route) e de período (period).
   Só vale enquanto <html data-enter="route|period"> existe (lib/view-transition.js): digitar na
   busca, abrir menu ou re-render comum não tocam nesses atributos e não animam nada.
   Só opacity + translateY de 6px, 1,5 x --motion, escalonado em passos de 0,2 x --motion
   (6 posições; do 7º em diante entram junto com o 6º). --motion = 0ms zera duração e atraso.
   Blocos dentro de outro bloco não animam (o externo já anima). Sem will-change.
   ========================================================================== */
:root[data-vt="period"] .app-content { view-transition-name: app-content; }
:root[data-vt="period"]::view-transition-group(app-content) { animation: none; }
:root[data-vt="period"]::view-transition-old(app-content),
:root[data-vt="period"]::view-transition-new(app-content) {
  animation-duration: var(--motion);
  animation-timing-function: var(--ease-out);
}
/* A entrada usa <html data-enter> (lib/view-transition.js), que dura a animação inteira sem
   prolongar a View Transition — durante a transição a página não recebe cliques. */
@keyframes vt-block-in { from { opacity: 0; transform: translateY(6px); } }

:root:is([data-enter="route"], [data-enter="period"]) .app-content
  :is(.kpi-strip-item, .panel, .card, .kpi-card, .dash-resumo-group):not(:is(.panel, .card, .kpi-card, .dash-resumo-group) *) {
  animation: vt-block-in calc(var(--motion) * 1.5) var(--ease-out) backwards;
  animation-delay: calc(var(--vt-i, 0) * var(--motion) * 0.2);
}
.app-content :is(.kpi-strip-item, .panel, .card, .kpi-card, .dash-resumo-group):nth-child(2) { --vt-i: 1; }
.app-content :is(.kpi-strip-item, .panel, .card, .kpi-card, .dash-resumo-group):nth-child(3) { --vt-i: 2; }
.app-content :is(.kpi-strip-item, .panel, .card, .kpi-card, .dash-resumo-group):nth-child(4) { --vt-i: 3; }
.app-content :is(.kpi-strip-item, .panel, .card, .kpi-card, .dash-resumo-group):nth-child(5) { --vt-i: 4; }
.app-content :is(.kpi-strip-item, .panel, .card, .kpi-card, .dash-resumo-group):nth-child(n+6) { --vt-i: 5; }

/* ==========================================================================
   Campo de data dd/mm/aaaa (lib/date-field.js)
   O input[type=date] original fica oculto mas renderizado (showPicker precisa disso), ancorado sob o
   botao do calendario para o seletor nativo abrir perto; o texto dd/mm/aaaa e o campo visivel.
   ========================================================================== */
.df { position: relative; display: flex; align-items: center; min-width: 0; }
.df-text { flex: 1 1 auto; min-width: 0; padding-right: 40px; font-variant-numeric: tabular-nums; }
.df-text.input-sm { min-width: 0; width: 11.5rem; flex: 0 1 auto; padding-right: 36px; }
.df-text[aria-invalid="true"] { border-color: var(--red); }
.df > .df-native {
  position: absolute; right: 0; bottom: 0; width: 1px; height: 1px; min-width: 0; min-height: 0;
  padding: 0; margin: 0; border: 0; opacity: 0; pointer-events: none;
}
.df-pick {
  position: absolute; top: 0; right: 0; bottom: 0; width: 40px; height: auto;
  min-width: 36px; min-height: 36px; color: var(--t2);
}
.df-text.input-sm + .df-pick { width: 36px; }
.df-text:disabled + .df-pick { opacity: .5; cursor: not-allowed; }
@media (max-width: 700px) {
  .df-text.input-sm { width: 100%; }
}

/* === DRE seção própria: layout e abas (agente layout) === */
/* A DRE é uma seção imersiva: no desktop (>= 961px) sem sidebar nem topbar (classe is-dre-secao,
   posta por renderApp() quando activeNav === 'dre'); no celular usa o shell normal com drawer.
   Vidro só no cabeçalho (chrome); grade e gráficos ficam sobre superfície sólida. */
.dre-page { grid-template-columns: minmax(0, 1fr); }
.dre-page > * { min-width: 0; }
.dre-header {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: var(--s-3) var(--s-6); padding: var(--s-3) var(--s-4);
  background: var(--topbar-glass); border: 1px solid var(--border); border-radius: var(--radius-panel);
}
.dre-header-main { display: flex; align-items: center; gap: var(--s-4); min-width: 0; }
.dre-header-title { min-width: 0; }
.dre-titulo {
  margin: 0; font-family: var(--font-head); font-size: var(--fs-xl); font-weight: 600;
  letter-spacing: -0.5px; line-height: 1.2; color: var(--text-primary);
}
.dre-titulo:focus { outline: none; }
.dre-titulo:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: var(--r-xs); }
.dre-subtitulo { margin: 2px 0 0; font-size: var(--fs-xs); color: var(--text-secondary); }
.dre-header-controls { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-4); }
.dre-header .btn { min-height: var(--hit); }
.dre-yearnav .btn { min-width: var(--hit); }
.dre-voltar { gap: var(--s-2); }

.dre-abas { display: grid; gap: var(--s-3); min-width: 0; }
.dre-tabs-wrap { display: flex; min-width: 0; }
.dre-tabs { max-width: 100%; }
.dre-tabs .segmented-item {
  min-height: 40px; padding: 0 var(--s-5); font-size: var(--fs-sm); font-weight: 500;
  transition: background-color var(--motion) var(--ease-out), color var(--motion) var(--ease-out);
}
.dre-tabs .segmented-item[aria-selected="true"] {
  background: var(--surface-interaction); color: var(--text-primary); font-weight: 600;
  box-shadow: inset 0 0 0 1px var(--border-strong);
}
.dre-tabs .segmented-item:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.dre-painel { min-width: 0; display: grid; gap: var(--s-5); }
.dre-painel[hidden] { display: none; }

@supports (backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px)) {
  :root[data-glass="glass"] .dre-header {
    background: var(--material-chrome);
    -webkit-backdrop-filter: var(--material-filter-chrome);
    backdrop-filter: var(--material-filter-chrome);
    box-shadow: inset 0 1px 0 var(--material-edge);
  }
}

@media (min-width: 1051px) {
  .app-shell.is-dre-secao { grid-template-columns: minmax(0, 1fr); }
  .app-shell.is-dre-secao > .sidebar,
  .app-shell.is-dre-secao .topbar { display: none; }
  .app-shell.is-dre-secao .app-content { max-width: none; padding: 0 var(--s-6) var(--s-8); }
  .is-dre-secao .dre-page { max-width: none; padding: 0; gap: var(--s-5); }
  .is-dre-secao .dre-header {
    position: sticky; top: 0; z-index: 30;
    margin-inline: calc(var(--s-6) * -1); padding-inline: var(--s-6);
    border-width: 0 0 1px; border-radius: 0;
  }
}

@media (max-width: 1050px) {
  .dre-header-controls { width: 100%; }
}
@media (max-width: 700px) {
  .dre-header-main { width: 100%; }
  .dre-tabs { display: flex; width: 100%; }
  .dre-tabs .segmented-item { flex: 1 1 0; min-width: 0; padding-inline: var(--s-2); }
  .dre-export { margin-left: auto; }
}
/* fim DRE layout */

/* === DRE dashboard: indicadores, gráficos, acumulado, comparação (agente dashboard) === */
.dre-dash { display: grid; gap: var(--s-5); min-width: 0; }
.dre-dash-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-5); min-width: 0; }
.dre-dash-grid > .panel { min-width: 0; }
.dre-dash-grid > .dre-dash-wide { grid-column: 1 / -1; }
.dre-dash .panel-note { margin: var(--s-3) 0 0; }
/* Indicadores: 5 colunas quando cabe; senão 3 com o último ocupando 2 (sem item sozinho numa linha). */
.dre-dash { container: dre-dash / inline-size; }
.dre-dash .kpi-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.dre-dash .kpi-strip-item:last-child:nth-child(5) { grid-column: span 2; }
@container dre-dash (min-width: 900px) {
  .dre-dash .kpi-strip { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .dre-dash .kpi-strip-item:last-child:nth-child(5) { grid-column: auto; }
}
/* Painéis lado a lado com a mesma altura; o corpo preenche e a rosca (menor) fica centrada. */
.dre-dash-grid > .panel { display: flex; flex-direction: column; }
.dre-dash-grid > .panel > .panel-body { flex: 1; display: flex; flex-direction: column; }
.dre-dash-grid > .panel > .panel-body:has(.donut-wrap) { justify-content: center; }
.dre-dash .donut-wrap { padding-top: 0; gap: var(--s-4); }
.dre-dash .donut-wrap .donut-svg { width: 132px; max-width: 132px; }
.dre-dash .donut-legend { min-width: 180px; }
.dre-dash-legend { flex-wrap: wrap; margin-top: var(--s-3); color: var(--text-secondary); }
.dre-bars-compact { display: none; }
@media (max-width: 700px) { .dre-bars-wide { display: none; } .dre-bars-compact { display: block; } }

/* Marcas dos gráficos: azul = receita, cinza vazado com contorno = despesa, verde/vermelho = resultado positivo/negativo.
   O sinal do resultado também aparece pela posição (barra abaixo da linha de zero) e pelo texto. */
.dre-bar-receita { fill: var(--chart-in); }
.dre-bar-despesa { fill: color-mix(in srgb, var(--text-muted) 30%, transparent); stroke: var(--text-muted); stroke-width: 1.5; }
.dre-bar-resultado { fill: var(--chart-result); }
.dre-bar-resultado--neg { fill: var(--chart-neg); }
.sw-dre-receita { background: var(--chart-in); }
.sw-dre-despesa { background: color-mix(in srgb, var(--text-muted) 30%, transparent); box-shadow: inset 0 0 0 1.5px var(--text-muted); }
.sw-dre-resultado { background: var(--chart-result); }
.sw-dre-prejuizo { background: var(--chart-neg); }

/* Margens: contribuição em azul contínuo, líquida em rosa-terra tracejado (não depende só de cor). */
.dre-ln-mc-line { stroke: var(--chart-in); stroke-width: 2.25; stroke-linejoin: round; stroke-linecap: round; }
.dre-ln-mc-dot { fill: var(--chart-in); stroke: var(--surface); stroke-width: 1.5; }
.dre-ln-ml-line { stroke: var(--chart-out); stroke-width: 2.25; stroke-dasharray: 6 4; stroke-linejoin: round; stroke-linecap: round; }
.dre-ln-ml-dot { fill: var(--chart-out); stroke: var(--surface); stroke-width: 1.5; }
.dre-lg-line { display: inline-block; width: 18px; height: 0; border-top: 2px solid var(--action); }
.dre-lg-line--ml { border-top-color: var(--cat-6); border-top-style: dashed; }

/* Acumulado e comparação: tabelas de dados em superfície sólida, sem vidro. */
.dre-tbl-wrap { overflow-x: auto; max-width: 100%; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); }
.dre-tbl-wrap:focus-visible { outline: 2px solid var(--action); outline-offset: 2px; }
.dre-tbl { width: 100%; min-width: 520px; border-collapse: collapse; font-size: var(--fs-sm); font-variant-numeric: tabular-nums; }
.dre-tbl th, .dre-tbl td { padding: var(--s-2) var(--s-3); border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.dre-tbl thead th { font-size: var(--fs-xs); font-weight: 600; color: var(--text-secondary); white-space: nowrap; background: var(--surface); }
.dre-tbl .is-num { text-align: right; white-space: nowrap; }
.dre-tbl tbody tr:last-child > * { border-bottom: 0; }
.dre-tbl-l { font-weight: 400; color: var(--text-primary); }
.dre-tbl-l--item { padding-left: var(--s-6); color: var(--text-secondary); }
.dre-tbl-r--receita > *, .dre-tbl-r--computed > * { font-weight: 600; }
.dre-tbl-r--computed > * { background: color-mix(in srgb, var(--surface-interaction) 45%, transparent); }
.dre-tbl-r--filha > * { font-size: var(--fs-xs); color: var(--text-secondary); }
.dre-tbl .is-neg { color: var(--danger); }
.dre-tbl-na, .dre-tbl-zero { color: var(--text-muted); }
.dre-tbl .dre-op { margin-right: var(--s-1); }
.dre-cmp-controls { display: flex; flex-wrap: wrap; gap: var(--s-4); margin-bottom: var(--s-4); }
.dre-cmp-field { display: grid; gap: var(--s-1); min-width: min(240px, 100%); flex: 1 1 200px; max-width: 320px; }
.dre-cmp-field label { font-size: var(--fs-xs); font-weight: 600; color: var(--text-secondary); }
.dre-cmp-leitura { white-space: nowrap; font-weight: 500; color: var(--text-secondary); }
.dre-cmp-leitura--melhora { color: var(--success); }
.dre-cmp-leitura--piora { color: var(--danger); }
@media (max-width: 1050px) {
  .dre-dash-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 700px) {
  .dre-dash .kpi-strip { grid-template-columns: minmax(0, 1fr); }
  .dre-dash .kpi-strip-item:last-child:nth-child(5) { grid-column: auto; }
  .dre-dash .kpi-strip-item + .kpi-strip-item::before { display: none; }
  .dre-cmp-field { max-width: none; }
}
/* fim DRE dashboard */

/* === DRE — planilha ===
   Tela própria da grade mensal (#/dre?v=grade): ocupa a janela, uma única área de rolagem (.plan-scroll),
   cabeçalho de colunas, coluna Conta e colunas Acumulado/Média fixas. Vidro só no cabeçalho da tela;
   a tabela é superfície sólida. Cada célula tem fundo opaco (--row-bg) para a coluna fixa nunca deixar
   os números rolarem por baixo à mostra. */
.plan-page { display: flex; flex-direction: column; min-width: 0; min-height: 0; height: 100dvh; }
.is-dre-secao .app-content:has(> .plan-page) { max-width: none; padding: 0; }
.plan-head {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: var(--s-2) var(--s-4); padding: var(--s-2) var(--s-4);
  background: var(--topbar-glass); border-bottom: 1px solid var(--border);
}
.plan-head-main { display: flex; align-items: center; gap: var(--s-3); min-width: 0; }
.plan-head-title { min-width: 0; }
.plan-titulo {
  margin: 0; font-family: var(--font-head); font-size: var(--fs-lg); font-weight: 600;
  line-height: 1.2; letter-spacing: -0.2px; color: var(--text-primary);
}
.plan-titulo:focus { outline: none; }
.plan-titulo:focus-visible { outline: 2px solid var(--action); outline-offset: 4px; border-radius: var(--r-xs); }
.plan-sub { margin: 1px 0 0; font-size: var(--fs-xs); color: var(--text-secondary); }
.plan-ctrl { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-3); }
.plan-head .btn, .plan-head .chip { min-height: 36px; }
.plan-voltar { gap: var(--s-2); }
.plan-escala .segmented-item { min-height: 30px; }
.plan-erro { margin: var(--s-4); }

.plan-scroll {
  flex: 1 1 auto; min-height: 0; overflow: auto; overscroll-behavior: contain; background: var(--surface);
}
.plan-scroll:focus-visible { outline: 2px solid var(--action); outline-offset: -2px; }

.plan-table {
  --plan-hh: 36px; --plan-sub-h: 24px; --plan-rh: 32px;
  --plan-focus: color-mix(in srgb, var(--action) 10%, transparent);
  --plan-shadow: rgb(0 0 0 / .32);
  width: 100%; border-collapse: separate; border-spacing: 0; table-layout: fixed;
  font-size: var(--fs-sm); font-variant-numeric: tabular-nums; color: var(--text-primary);
}
:root[data-theme="light"] .plan-table { --plan-shadow: rgb(0 0 0 / .12); }

/* Linhas: faixa leve nas seções, linha de topo nos subtotais, hover cruzado. */
.plan-r { --row-bg: var(--surface); }
.plan-r--receita, .plan-r--secao { --row-bg: color-mix(in srgb, var(--text-primary) 4%, var(--surface)); }
.plan-r:hover { --row-bg: color-mix(in srgb, var(--text-primary) 5%, var(--surface)); }
.plan-l, .plan-c {
  height: var(--plan-rh); padding: 0 10px; background: var(--row-bg);
  border-bottom: 1px solid var(--border); white-space: nowrap; font-weight: 400;
}
.plan-c { text-align: right; }
.plan-r--receita > *, .plan-r--secao > *, .plan-r--total > * { font-weight: 600; }
.plan-r--total > * { box-shadow: inset 0 1px 0 var(--border-strong); }
.plan-r--pctrow > * { font-weight: 400; color: var(--text-secondary); }
.plan-r--item > .plan-l { color: var(--text-secondary); }

/* Coluna Conta (fixa à esquerda). */
.plan-l {
  position: sticky; left: 0; z-index: 2; text-align: left; padding-left: var(--s-2);
  border-right: 1px solid transparent;
}
.plan-lab { display: flex; align-items: center; min-width: 0; }
.plan-r--item .plan-lab { padding-left: 40px; }
.plan-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.plan-op { flex: none; width: 14px; margin-right: 2px; color: var(--text-muted); font-weight: 400; }
.plan-tgl-sp { flex: none; width: 24px; }
.plan-tgl {
  position: relative; flex: none; width: 24px; height: 24px; margin-right: 2px; padding: 0;
  border: 0; border-radius: var(--r-xs); background: none; color: var(--text-muted); cursor: pointer;
}
.plan-tgl::before {
  content: ''; position: absolute; left: 9px; top: 7px; width: 6px; height: 6px;
  border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg); transition: transform var(--motion) var(--ease-out);
}
.plan-tgl[aria-expanded="false"]::before { transform: translate(-1px, 2px) rotate(-45deg); }
.plan-tgl::after { content: ''; position: absolute; inset: -8px -4px; }
.plan-tgl:hover { color: var(--text-primary); }
.plan-tgl:focus-visible, .plan-h-btn:focus-visible { outline: 2px solid var(--action); outline-offset: -2px; }
.plan-tag {
  flex: none; display: inline-flex; align-items: center; gap: 5px; margin-left: var(--s-2); padding: 1px 8px;
  border: 1px solid var(--border-strong); border-radius: var(--r-pill);
  font-size: var(--fs-xs); font-weight: 400; color: var(--text-secondary);
}
.plan-tag::before { content: ''; width: 6px; height: 6px; border: 1.5px solid currentColor; border-radius: 50%; }

/* Números: zero discreto, negativo em vermelho semântico, mês em foco com fundo sutil. */
.plan-c.is-zero, .plan-c.is-na { color: var(--text-muted); }
.plan-c.is-neg { color: var(--danger); }
.plan-c--pct { font-size: var(--fs-xs); color: var(--text-secondary); }
.plan-c.is-focus { background: linear-gradient(var(--plan-focus), var(--plan-focus)), var(--row-bg); }

/* Acumulado e Média/mês (fixas à direita), com tom próprio e borda de separação. */
.plan-c--acc, .plan-c--accp, .plan-c--avg { background: color-mix(in srgb, var(--row-bg) 94%, var(--text-primary)); font-weight: 600; }
.plan-c--acc, .plan-c--accp { position: sticky; z-index: 2; }
.plan-c--avg { position: sticky; right: 0; z-index: 2; }
.plan-c--accp { right: var(--plan-tot-w); font-weight: 400; }
.plan-c--acc { right: calc(var(--plan-tot-w) + var(--plan-pct-w)); border-left: 1px solid var(--border-strong); }

/* Cabeçalho de colunas (fixo no topo). */
.plan-h {
  position: sticky; top: 0; z-index: 3; height: var(--plan-hh); padding: 0 10px;
  background: var(--surface); border-bottom: 1px solid var(--border-strong);
  font-size: var(--fs-xs); font-weight: 600; color: var(--text-secondary); text-align: right; white-space: nowrap;
}
.plan-hr--sub .plan-h { top: var(--plan-hh); height: var(--plan-sub-h); font-weight: 400; }
.plan-h--label { left: 0; z-index: 5; text-align: left; padding-left: var(--s-3); border-right: 1px solid transparent; }
.plan-h--accgrp, .plan-h--avg, .plan-h--acc, .plan-h--accp { z-index: 4; color: var(--text-primary); }
.plan-h--accgrp { right: var(--plan-tot-w); border-left: 1px solid var(--border-strong); }
.plan-h--acc { right: calc(var(--plan-tot-w) + var(--plan-pct-w)); border-left: 1px solid var(--border-strong); }
.plan-h--accp { right: var(--plan-tot-w); }
.plan-h--avg { right: 0; }
.plan-h.is-focus { color: var(--text-primary); background: linear-gradient(var(--plan-focus), var(--plan-focus)), var(--surface); }
.plan-h:not(.plan-h--sub).is-focus { box-shadow: inset 0 -2px 0 var(--action); }
.plan-h:has(> .plan-h-btn) { padding: 0; }
.plan-h-btn {
  display: block; width: 100%; height: 100%; min-height: var(--plan-hh); padding: 0 10px;
  border: 0; background: none; cursor: pointer; font: inherit; color: inherit; text-align: right;
}
.plan-h-btn:hover { background: var(--surface-interaction); color: var(--text-primary); }
.plan-h[colspan="2"] > .plan-h-btn { text-align: center; }

/* Sombra de separação das colunas fixas: só com rolagem horizontal naquele lado (classes via JS). */
.plan-l::after, .plan-h--label::after, .plan-c--acc::before, .plan-h--acc::before, .plan-h--accgrp::before {
  content: ''; position: absolute; top: 0; bottom: 0; width: 9px; pointer-events: none;
  opacity: 0; transition: opacity var(--motion) var(--ease-out);
}
.plan-l::after, .plan-h--label::after { right: -10px; background: linear-gradient(90deg, var(--plan-shadow), transparent); }
.plan-c--acc::before, .plan-h--acc::before, .plan-h--accgrp::before { left: -10px; background: linear-gradient(270deg, var(--plan-shadow), transparent); }
.plan-scroll.is-scroll-l :is(.plan-l, .plan-h--label) { border-right-color: var(--border-strong); }
.plan-scroll.is-scroll-l :is(.plan-l, .plan-h--label)::after,
.plan-scroll.is-scroll-r :is(.plan-c--acc, .plan-h--acc, .plan-h--accgrp)::before { opacity: 1; }

@supports (backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px)) {
  :root[data-glass="glass"] .plan-head {
    background: var(--material-chrome);
    -webkit-backdrop-filter: var(--material-filter-chrome);
    backdrop-filter: var(--material-filter-chrome);
    box-shadow: inset 0 1px 0 var(--material-edge);
  }
}

/* Resumo na aba Mensal (leva à planilha). */
.plan-resumo { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: var(--s-4) var(--s-6); }
.plan-resumo-txt { display: grid; gap: var(--s-2); min-width: 0; }
.plan-resumo-titulo { margin: 0; font-family: var(--font-head); font-size: var(--fs-lg); font-weight: 600; color: var(--text-primary); }
.plan-resumo-desc, .plan-resumo-nota { margin: 0; font-size: var(--fs-sm); color: var(--text-secondary); }
.plan-resumo-nota { font-size: var(--fs-xs); color: var(--text-muted); }
.plan-fatos { display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-8); margin: var(--s-1) 0 0; }
.plan-fato dt { font-size: var(--fs-xs); color: var(--text-secondary); }
.plan-fato dd { margin: 0; font-size: var(--fs-lg); font-weight: 600; font-variant-numeric: tabular-nums; color: var(--text-primary); }
.plan-fato dd.is-neg { color: var(--danger); }

@media (pointer: coarse) {
  .plan-head .btn, .plan-head .chip { min-height: var(--hit); }
  .plan-escala .segmented-item { min-height: 38px; }
}
@media (max-width: 1050px) {
  /* A planilha é a própria tela: no celular a barra superior sai e o Voltar/Esc fazem a navegação. */
  .app-shell:has(.plan-page) .topbar { display: none; }
  .app-content:has(> .plan-page) { max-width: none; padding: 0; }
}
@media (max-width: 700px) {
  .plan-head { gap: var(--s-1) var(--s-3); padding: var(--s-2) var(--s-3); }
  .plan-head-main { width: 100%; gap: var(--s-2); }
  .plan-voltar { flex: none; white-space: nowrap; }
  .plan-ctrl { width: 100%; gap: var(--s-2); }
  .plan-sub { display: none; }
  .plan-name {
    font-size: var(--fs-xs); line-height: 1.15; white-space: normal;
    display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2;
  }
  .plan-op { display: none; }
  .plan-r--item .plan-lab { padding-left: 18px; }
  .plan-tag { padding: 0; border: 0; margin-left: var(--s-1); }
  .plan-tag-txt { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
  .plan-c--acc, .plan-c--accp, .plan-c--avg, .plan-h--accgrp, .plan-h--acc, .plan-h--accp, .plan-h--avg { right: auto; }
  .plan-c--acc::before, .plan-h--acc::before, .plan-h--accgrp::before { display: none; }
}
/* fim DRE — planilha */

.billing-view { display: grid; gap: var(--s-4); }
.billing-view .card { min-width: 0; }
.billing-view h2 { margin-bottom: var(--s-3); }
.billing-breakdown { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: var(--s-4); margin: var(--s-4) 0; }
.billing-breakdown dt { color: var(--t2); }
.billing-breakdown dd { margin: var(--s-1) 0 0; font-variant-numeric: tabular-nums; }
.billing-form, .billing-plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: var(--s-4); margin: var(--s-4) 0; }
.billing-form button { align-self: end; }
.billing-actions { display: flex; flex-wrap: wrap; gap: var(--s-3); margin: var(--s-4) 0; }
.billing-view summary { cursor: pointer; padding: var(--s-3) 0; }
.billing-view summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.billing-history { padding-left: var(--s-5); }
.billing-history li { margin: var(--s-2) 0; overflow-wrap: anywhere; }
/* Auditoria 12/10/2026 — celular.
   Segmented no celular: os itens quebram em linhas em vez de cortar o texto (sem rolagem horizontal). */
@media (max-width: 700px) {
  .segmented,
  .page-filters .segmented { display: flex; flex-wrap: wrap; max-width: 100%; overflow-x: visible; }
  .segmented-item { flex: 1 1 auto; white-space: normal; text-align: center; }
  /* Filtros de lista (A pagar/A receber): faixa rolável numa linha só, sem barra visível. */
  .page-filters { flex-wrap: nowrap; }
  .page-filters .segmented,
  .vendas-filtros .segmented {
    display: flex; max-width: 100%; flex: 1 1 auto; min-width: 0; flex-wrap: nowrap; overflow-x: auto; overscroll-behavior-x: contain;
    scroll-snap-type: x proximity; scrollbar-width: none; -webkit-overflow-scrolling: touch;
  }
  .page-filters .segmented::-webkit-scrollbar,
  .vendas-filtros .segmented::-webkit-scrollbar { display: none; }
  .page-filters .segmented-item,
  .vendas-filtros .segmented-item { flex: none; white-space: nowrap; scroll-snap-align: start; padding-inline: var(--s-4); }
}
/* Modal Novo lançamento no celular: linha 1 = Cancelar | Salvar e novo, linha 2 = Salvar lançamento (largura total).
   Ordem visual = ordem do DOM = ordem de Tab; todos os alvos com 44px e texto numa linha só. */
@media (max-width: 700px) {
  .modal-footer.modal-footer--lancamento {
    display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-2);
    padding-block: var(--s-3);
  }
  .modal-footer--lancamento .btn { width: 100%; min-height: var(--hit); white-space: nowrap; font-size: var(--fs-md); font-weight: 600; }
  .modal-footer--lancamento .btn-ghost { border-color: var(--border-input); }
  /* O rodapé é fixo (sticky): campo focado e "Mais detalhes" rolam para acima dele, nunca por baixo. */
  .modal-card { scroll-padding-bottom: 9rem; }
  /* O rodapé já traz o próprio respiro inferior (+ área segura): sem padding extra do formulário abaixo dele, que o deixava solto do fundo. */
  .modal-body:has(> .modal-footer--lancamento) { padding-bottom: 0; }
  .modal-footer--lancamento { padding-bottom: calc(var(--s-4) + env(safe-area-inset-bottom, 0px)); }
  .modal-footer--lancamento .modal-save-new ~ .btn-primary { grid-column: 1 / -1; }
}

/* ==========================================================================
   Polimento visual 14/10/2026 (relatório UI 13/10): selects, camadas, barra da DRE,
   estados vazios, números e contraste. Só tokens existentes; sem inline (CSP).
   ========================================================================== */

/* --- 2. Camadas: no máximo 2 níveis. --layer-1 = card/painel sobre o fundo; --layer-2 = o que
   vive DENTRO de um card/painel (campos, bloco interno, aviso). Um terceiro nível fica plano. --- */
:root { --layer-1: var(--surface); --layer-2: var(--surface-raised); --layer-line: var(--border); }
:root :is(.card, .panel, .dre-card) :is(.card, .panel) {
  background: var(--layer-2); border: 1px solid var(--layer-line); box-shadow: none; margin-bottom: 0;
}
:root :is(.card, .panel, .dre-card) .kpi-strip {
  background: transparent; border-color: transparent; box-shadow: none; padding: 0;
}
:root :is(.card, .panel, .dre-card) :is(.card, .panel, .kpi-strip) :is(.card, .panel, .kpi-strip) {
  background: transparent; border-color: transparent; box-shadow: none;
}
.insight-line { background: var(--layer-2); }

/* --- 1. Select nativo com a mesma aparência dos inputs (seta própria, foco, alvo de 44px). --- */
select.input, select.select, .admin-field select, .admin-filtros select {
  -webkit-appearance: none; appearance: none;
  min-height: var(--hit); padding: 0 40px 0 14px; cursor: pointer; text-overflow: ellipsis;
  border: 1px solid var(--border-input); border-radius: var(--radius-control);
  color: var(--text-primary); background-color: var(--surface-raised);
  background-image: linear-gradient(45deg, transparent 50%, var(--text-secondary) 50%), linear-gradient(135deg, var(--text-secondary) 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 15px) 50%;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat;
}
select.input:hover, select.select:hover, .admin-field select:hover { border-color: var(--text-muted); }
select.input:focus, select.select:focus, .admin-field select:focus, .admin-filtros select:focus {
  border-color: var(--action); background-color: var(--surface-raised);
  background-image: linear-gradient(45deg, transparent 50%, var(--action) 50%), linear-gradient(135deg, var(--action) 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 15px) 50%;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat;
}
select.input:disabled, select.select:disabled, .admin-field select:disabled { opacity: 0.62; cursor: not-allowed; }
select.input[aria-invalid="true"], .admin-field select[aria-invalid="true"] { border-color: var(--danger); }
select[multiple], select[size]:not([size="1"]) { background-image: none; padding-right: 14px; min-height: 0; }
:root[data-theme="light"] select.input option, :root[data-theme="light"] .input option { background-color: var(--surface); color: var(--text-primary); }

/* --- 7. Placeholder e desabilitados legíveis nos dois temas (>= 4,5:1 sobre campo e foco). --- */
::placeholder { color: var(--text-muted); opacity: 1; }
.input:disabled, .textarea:disabled { color: var(--text-secondary); }

/* --- 3. Barra de controles da DRE: período à esquerda, ações à direita, mesma altura. --- */
.dre-header-controls { justify-content: flex-end; align-items: center; gap: var(--s-3) var(--s-6); }
.dre-periodo, .dre-header-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3); min-width: 0; }
.dre-header-actions { gap: var(--s-2); }
.dre-nav-group {
  display: inline-flex; align-items: center; gap: 0; padding: 0; overflow: hidden;
  border: 1px solid var(--border-input); border-radius: var(--r-md); background: var(--surface-raised);
}
.dre-header .dre-nav-group .btn { border: 0; border-radius: 0; background: transparent; min-width: var(--hit); min-height: var(--hit); padding: 0; }
.dre-header .dre-nav-group .btn:hover { background: var(--surface-interaction); }
.dre-nav-group .dre-year { min-width: 56px; padding: 0 var(--s-1); }
.dre-month-nav .input, .dre-nav-group select.input {
  width: 208px; border: 0; border-radius: 0; background-color: transparent; font-weight: 600; text-align: center;
}
.dre-nav-group select.input:focus { background-color: var(--surface-interaction); }
.dre-header-tools { display: inline-flex; align-items: center; gap: var(--s-1); flex: none; }
.dre-header-actions :is(.btn-icon, .icon-btn) { width: var(--hit); height: var(--hit); }
@media (max-width: 1050px) {
  .dre-header-controls { justify-content: flex-start; }
}
@media (max-width: 700px) {
  .dre-header-controls { width: 100%; gap: var(--s-3); }
  .dre-periodo { width: 100%; gap: var(--s-2); }
  .dre-periodo .dre-nav-group { flex: 1 1 100%; min-width: 0; }
  .dre-yearnav.dre-nav-group { justify-content: space-between; }
  .dre-yearnav .dre-year { flex: 1; }
  .dre-month-nav .input, .dre-nav-group select.input { flex: 1 1 auto; width: auto; min-width: 0; }
  .dre-header-actions { width: 100%; }
  .dre-header-actions { flex-wrap: nowrap; }
  .dre-header-actions > .btn { flex: 1 1 0; min-width: 0; padding-inline: var(--s-2); }
  .dre-header-tools { margin-left: auto; }
  .dre-header-actions .dre-export { margin-left: 0; }
}

/* --- 5. Estado vazio reutilizável. Uso: emptyState({ titulo, texto, icone, action }) em views/shared.js,
   ou o markup: .empty-state > .empty-state__icon + .empty-state__title + .empty-state__text + .empty-state__actions.
   Modificadores: .empty-state--compact (dentro de tabela/painel pequeno), .empty-state--card (caixa tracejada). --- */
.empty-state, .state-block.is-empty {
  display: flex; flex-direction: column; align-items: center; gap: var(--s-2);
  padding: var(--s-10) var(--s-5); text-align: center;
}
.empty-state--compact { padding: var(--s-6) var(--s-4); }
.empty-state--card { border: 1px dashed var(--border-strong); border-radius: var(--radius-panel); }
.empty-state__icon {
  display: grid; place-items: center; flex: none; width: 48px; height: 48px; margin-bottom: var(--s-1);
  border-radius: var(--r-pill); background: var(--surface-interaction); color: var(--text-secondary);
}
/* state-block vazio: sem o círculo decorativo (revisão de UI #6: parecia um ícone que não carregou). Título, texto e
   ação já dizem o que fazer; quem precisa de ícone usa emptyState(), com glifo real. */
.empty-state .empty-state__title, .state-block.is-empty > b { margin: 0; font-size: var(--fs-md); font-weight: 600; color: var(--text-primary); }
.empty-state .empty-state__text, .state-block.is-empty > span:not(.empty-state__icon) { margin: 0; max-width: 42ch; font-size: var(--fs-sm); line-height: 1.5; color: var(--text-secondary); }
.empty-state__actions { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--s-2); margin-top: var(--s-3); }
.data-table td.table-empty, .dt td.table-empty { padding: 0 !important; font-style: normal; text-align: center; }
.tv-empty { font-style: normal; color: var(--text-secondary); }

/* --- 6. Números: tabulares e à direita. Utilitárias: .tnum, .col-valor. tableHeader() marca th.is-num
   e o CSS alinha as células da mesma coluna (até 9 colunas). --- */
.tnum, .num, .is-num, .col-valor { font-variant-numeric: tabular-nums; }
.col-valor { text-align: right; white-space: nowrap; }
.data-table th.is-num, .data-table td.is-num, .data-table td.num { text-align: right; }
@media (min-width: 701px) {
  .data-table:has(> thead th:nth-child(1).is-num) > tbody > tr > td:nth-child(1):not([colspan]),
  .data-table:has(> thead th:nth-child(2).is-num) > tbody > tr > td:nth-child(2):not([colspan]),
  .data-table:has(> thead th:nth-child(3).is-num) > tbody > tr > td:nth-child(3):not([colspan]),
  .data-table:has(> thead th:nth-child(4).is-num) > tbody > tr > td:nth-child(4):not([colspan]),
  .data-table:has(> thead th:nth-child(5).is-num) > tbody > tr > td:nth-child(5):not([colspan]),
  .data-table:has(> thead th:nth-child(6).is-num) > tbody > tr > td:nth-child(6):not([colspan]),
  .data-table:has(> thead th:nth-child(7).is-num) > tbody > tr > td:nth-child(7):not([colspan]),
  .data-table:has(> thead th:nth-child(8).is-num) > tbody > tr > td:nth-child(8):not([colspan]),
  .data-table:has(> thead th:nth-child(9).is-num) > tbody > tr > td:nth-child(9):not([colspan]) {
    text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums;
  }
}

/* --- 8. Gráficos: a altura do painel segue o conteúdo (o max-height com overflow visível
   deixava o gráfico vazar sobre o painel de baixo e a legenda cortada na dobra). --- */
.dash-fixo-corpo .panel { max-height: none; }
.panel :is(.chart-svg, .donut-wrap svg) { max-width: 100%; height: auto; }

/* Coluna Conta das transações: uma linha, com reticências quando o nome é longo. */
.data-table td.col-conta { white-space: nowrap; max-width: 14rem; overflow: hidden; text-overflow: ellipsis; }

/* === Dashboard (Dimension) === */
/* Bloco principal limpo (KPIs, vence hoje) + "Mais análises" recolhido. Só tokens. */
.dash-fixo .dash-fixo-corpo { display: flex; flex-direction: column; gap: var(--s-6); }
.dash-fixo-corpo > .kpi-strip { padding: var(--s-2); }
.dash-fixo-corpo > .kpi-strip .kpi-strip-item { min-width: 0; }
/* Valor acompanha a coluna (container = o próprio item): "R$ 1.234.567,89" não vaza para a vizinha. */
.dash-fixo-corpo > .kpi-strip .kpi-strip-value {
  font-family: var(--font-head); font-size: clamp(22px, 11cqi, var(--fs-2xl)); letter-spacing: -0.6px;
  min-width: 0; max-width: 100%; overflow: hidden; text-overflow: ellipsis;
}

.dash-vence { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s-4); }
.dash-vence > .panel { max-height: none; }
.dash-fixo-corpo .dash-vence .panel > .panel-head { min-height: 0; padding-bottom: var(--s-3); }
.dash-vence .rows { padding-bottom: var(--s-2); }
.dash-vence-vazio { display: flex; flex-direction: column; align-items: center; gap: var(--s-1); padding: 0 var(--panel-pad, var(--s-5)) var(--panel-pad, var(--s-5)); }
.dash-vence-vazio .state-block { padding-block: var(--s-3) var(--s-2); }
.dash-fixo-corpo .dash-vence .panel { overflow: hidden; }
.dash-fixo-corpo .dash-vence .panel > .panel-head { background: transparent; }
.dash-vence-resumo { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s-3); padding: 0 var(--panel-pad, var(--s-5)) var(--s-3); }
.dash-vence-resumo.has-late { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-4); }
.dash-vence-num { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.dash-vence-rotulo { font-size: var(--fs-xs); font-weight: 600; color: var(--text-secondary); }
.dash-vence-total { font-family: var(--font-head); font-size: var(--fs-2xl); font-weight: 500; letter-spacing: -0.02em; line-height: 1.15; color: var(--text-primary); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.dash-vence-late .dash-vence-rotulo, .dash-vence-late .dash-vence-total { color: var(--danger); }
.dash-vence-late .link-go { align-self: flex-start; padding: 0; color: var(--danger); }
.dash-vence-sub { font-size: var(--fs-xs); color: var(--text-muted); font-variant-numeric: tabular-nums; }
@container dash-fixo (max-width: 640px) {
  .dash-vence-resumo.has-late .dash-vence-total { font-size: var(--fs-xl); }
}
/* Saldo da semana: faixa fina acima dos painéis (duas linhas no celular). */
.dash-semana { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: var(--s-1) var(--s-4); padding: var(--s-3) var(--s-4); border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); font-size: var(--fs-sm); color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.dash-semana-rotulo { font-weight: 600; color: var(--text-primary); margin-right: var(--s-1); }
.dash-semana-op { color: var(--text-muted); margin-inline: var(--s-1); }
.dash-semana b { font-weight: 600; color: var(--text-primary); }
.dash-semana-saldo { font-family: var(--font-head); font-size: var(--fs-md); font-weight: 600; }
.dash-semana-nota { font-size: var(--fs-2xs); color: var(--text-muted); margin-left: var(--s-2); }
@container dash-fixo (max-width: 640px) {
  .dash-semana { flex-direction: column; align-items: flex-start; }
}
.dash-vence-dia-titulo { margin: var(--s-3) 0 0; padding: 0 var(--panel-pad, var(--s-5)); font-size: var(--fs-2xs); font-weight: 600; color: var(--text-muted); }
.dash-vence-dia .rows { padding-bottom: 0; }
.dash-vence .row-value { font-variant-numeric: tabular-nums; }
@container dash-fixo (min-width: 720px) {
  .dash-vence { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: var(--s-6); }
}
@container dash-fixo (max-width: 640px) {
  .dash-fixo-corpo > .kpi-strip { grid-template-columns: minmax(0, 1fr); }
  .dash-fixo-corpo > .kpi-strip .kpi-strip-item + .kpi-strip-item::before { display: none; }
}

/* ── Pulso (Visão geral do Empresarial): saudação, equação do mês, régua da semana, lista do dia ── */
.pulso-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: baseline; gap: var(--s-2) var(--s-6); margin-bottom: var(--s-6); }
.pulso-saudacao { min-width: 0; overflow-wrap: anywhere; }
.pulso-data { margin: 0; font-size: var(--fs-md); color: var(--text-muted); white-space: nowrap; }
.pulso-briefing { grid-column: 1 / -1; margin: 0; max-width: 72ch; font-size: var(--fs-lg); line-height: 1.5; color: var(--text-secondary); }
.pulso-acoes { grid-column: 1 / -1; justify-content: flex-start; margin-top: var(--s-2); }
@media (max-width: 700px) {
  .pulso-saudacao { font-size: var(--fs-xl); }
  .pulso-acoes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pulso-acoes > .btn { width: 100%; }
  .pulso-acoes > .btn:only-of-type { grid-column: 1 / -1; }
}
.pulso-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--card-pad); min-width: 0; }
.pulso-titulo { margin: 0 0 var(--s-4); font-size: var(--fs-2xs); font-weight: 600; color: var(--text-muted); }

/* Equação: Recebido − Pago = Resultado, com Vendas ao lado */
.pulso-eq-corpo { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s-5); }
.pulso-eq-corpo.has-lateral { grid-template-columns: minmax(0, 1fr) minmax(200px, 260px); gap: var(--s-6); }
.pulso-eq { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto minmax(0, 1fr); align-items: start; gap: var(--s-4); }
.pulso-termo { display: flex; flex-direction: column; gap: var(--s-1); min-width: 0; }
.pulso-rotulo { font-size: var(--fs-sm); font-weight: 600; color: var(--text-secondary); }
.pulso-valor { font-family: var(--font-head); font-size: var(--fs-2xl); font-weight: 500; letter-spacing: -0.02em; line-height: 1.15; color: var(--text-primary); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.pulso-termo.is-resultado .pulso-valor { font-weight: 600; }
.pulso-op { font-family: var(--font-head); font-size: var(--fs-2xl); line-height: 1.15; padding-top: calc(var(--fs-sm) * 1.4 + var(--s-1)); color: var(--text-muted); }
.pulso-sub { font-size: var(--fs-xs); color: var(--text-muted); font-variant-numeric: tabular-nums; }
.pulso-barra { height: 6px; border-radius: var(--r-pill); background: var(--surface-interaction); overflow: hidden; margin-top: var(--s-1); }
.pulso-barra-fill { display: block; height: 100%; border-radius: inherit; background: var(--text-secondary); }
.pulso-barra-fill--pos { background: var(--chart-in); }
.pulso-barra-fill--neg { background: var(--chart-out); }
.pulso-termo .link-go, .pulso-lateral .link-go { align-self: flex-start; padding: 0; }
.pulso-lateral-bloco { display: flex; flex-direction: column; gap: var(--s-1); min-width: 0; }
.pulso-lateral-bloco--extra { margin-top: var(--s-4); padding-top: var(--s-4); border-top: 1px solid var(--border); }
.pulso-valor--md { font-size: var(--fs-xl); }
.pulso-valor.tone-pos { color: var(--success); }
.pulso-valor.tone-neg { color: var(--danger); }
.pulso-nota { font-size: var(--fs-2xs); color: var(--text-muted); }
.pulso-regua-links { display: flex; flex-wrap: wrap; gap: var(--s-1) var(--s-5); margin: var(--s-2) 0 0; }
.pulso-regua-links .link-go { padding: 0; }
.pulso-lateral { display: flex; flex-direction: column; gap: 0; min-width: 0; padding-left: var(--s-6); border-left: 1px solid var(--border); }
@container dash-fixo (max-width: 760px) {
  .pulso-eq-corpo.has-lateral { grid-template-columns: minmax(0, 1fr); }
  .pulso-lateral { padding: var(--s-4) 0 0; border-left: 0; border-top: 1px solid var(--border); }
}
/* Celular: os termos empilham e o operador fica entre as linhas */
@container dash-fixo (max-width: 560px) {
  .pulso-eq { grid-template-columns: minmax(0, 1fr); gap: var(--s-2); }
  .pulso-op { display: none; } /* revisão de UI #11: empilhados, "—" e "=" viravam linhas soltas; os rótulos bastam */
  .pulso-valor { font-size: var(--fs-xl); }
}

/* Régua da semana: 8 colunas divergentes (entra sobe, sai desce) com escala comum */
.pulso-regua-rolagem { overflow-x: auto; scroll-snap-type: x proximity; margin-inline: calc(var(--s-2) * -1); padding-inline: var(--s-2); padding-bottom: var(--s-1); }
.pulso-regua { --pulso-h: 84px; display: grid; grid-template-columns: repeat(8, minmax(72px, 1fr)); gap: var(--s-1); min-width: 0; }
.pulso-dia { display: flex; flex-direction: column; align-items: stretch; gap: var(--s-1); padding: var(--s-2) var(--s-1); border: 1px solid transparent; border-radius: var(--r-md); background: transparent; color: var(--text-primary); font: inherit; cursor: pointer; scroll-snap-align: start; min-width: 0; }
.pulso-dia:hover { background: var(--surface-interaction); }
.pulso-dia:focus-visible { outline: 2px solid var(--action); outline-offset: 2px; }
/* Dia selecionado: cinza no tom do fundo, com glow violeta fraco subindo da base (tokens --glow-sel*, bloco
   "Glow de seleção" no fim do arquivo). */
.pulso-dia[aria-pressed="true"] { border-color: var(--border-strong); background-color: var(--surface-raised); }
/* Atrasado sem ênfase de vermelho: a coluna fica neutra; o estado selecionado segue o dos outros dias. */
.pulso-dia-rotulo { text-align: center; font-size: var(--fs-xs); font-weight: 600; color: var(--text-secondary); white-space: nowrap; }
.pulso-pilar { display: flex; flex-direction: column; align-items: center; height: var(--pulso-h); }
.pulso-pilar--entra { justify-content: flex-end; }
.pulso-pilar--sai { justify-content: flex-start; }
.pulso-pilar-valor { font-size: var(--fs-xs); line-height: 1.4; color: var(--text-secondary); font-variant-numeric: tabular-nums; white-space: nowrap; }
.pulso-pilar-barra { display: block; width: 60%; max-width: 32px; min-height: 3px; height: calc(var(--p) * 0.01 * (var(--pulso-h) - var(--s-5))); border-radius: var(--r-xs); }
.pulso-pilar--entra .pulso-pilar-barra { background: var(--pulso-in); }
.pulso-pilar--sai .pulso-pilar-barra { background: var(--pulso-out); }
.pulso-eixo { display: block; height: 1px; background: var(--border-strong); }
.pulso-dia-saldo { text-align: center; font-size: var(--fs-sm); font-weight: 600; color: var(--text-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.pulso-legenda { display: flex; flex-wrap: wrap; gap: var(--s-1) var(--s-4); margin: var(--s-3) 0 0; font-size: var(--fs-xs); color: var(--text-muted); }
.pulso-legenda span { display: inline-flex; align-items: center; gap: var(--s-1); }
.pulso-sw { display: inline-block; width: 10px; height: 10px; border-radius: var(--r-xs); }
.pulso-sw--entra { background: var(--pulso-in); }
.pulso-sw--sai { background: var(--pulso-out); }

/* Lista do dia selecionado */
.pulso-lista-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-6); }
.pulso-lista-col { min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: var(--s-2); }
.pulso-lista-col > .rows, .pulso-lista-col > .panel-note { align-self: stretch; }
.pulso-lista-head { align-self: stretch; display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-3); }
.pulso-lista-titulo { margin: 0; font-size: var(--fs-md); font-weight: 600; color: var(--text-primary); }
.pulso-lista-total { font-family: var(--font-head); font-size: var(--fs-lg); font-weight: 500; color: var(--text-primary); font-variant-numeric: tabular-nums; }
.pulso-lista-vazio { margin: 0; font-size: var(--fs-sm); color: var(--text-muted); }
.pulso-lista .row-value { font-variant-numeric: tabular-nums; }
.pulso-lista .row-item { padding-inline: 0; }
@container dash-fixo (max-width: 640px) {
  .pulso-lista-grid { grid-template-columns: minmax(0, 1fr); gap: var(--s-5); }
}

/* Atenção compacta e atalhos */
.pulso-atencao-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-3); }
.pulso-atencao-head .pulso-titulo { margin-bottom: var(--s-3); }
.pulso-atencao-lista { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.pulso-atencao-item { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: var(--s-3); padding: var(--s-2) 0; border-top: 1px solid var(--border); font-size: var(--fs-sm); }
.pulso-atencao-item:first-child { border-top: 0; }
.pulso-atencao-texto { min-width: 0; overflow-wrap: anywhere; color: var(--text-primary); }
.pulso-atalhos { display: flex; flex-wrap: wrap; gap: var(--s-1) var(--s-5); padding: 0 var(--s-1); }

.dash-mais { display: flex; flex-direction: column; align-items: flex-start; gap: var(--s-6); }
.dash-mais-toggle {
  display: inline-flex; align-items: center; gap: var(--s-2); min-height: 44px; padding: 0 var(--s-5);
  border: 1px solid var(--border); border-radius: var(--r-pill); background: var(--surface);
  color: var(--text-secondary); font: inherit; font-size: var(--fs-md); font-weight: 500; cursor: pointer;
  transition: background var(--motion) var(--ease-out), color var(--motion) var(--ease-out);
}
.dash-mais-toggle:hover { background: var(--surface-interaction); color: var(--text-primary); }
.dash-mais-toggle:focus-visible { outline: 2px solid var(--action); outline-offset: 2px; }
.dash-mais-toggle svg { transition: transform var(--motion) var(--ease-out); }
.dash-mais-toggle[aria-expanded="true"] svg { transform: rotate(180deg); }
.dash-mais-corpo { display: flex; flex-direction: column; gap: var(--s-8); width: 100%; min-width: 0; }
.dash-mais-corpo[hidden] { display: none; }

/* Seções de "Mais análises": título curto + painéis em 2 colunas (1 no estreito). */
.dash-sec { display: flex; flex-direction: column; gap: var(--s-4); min-width: 0; }
.dash-sec-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--s-1) var(--s-3); }
.dash-sec-title { margin: 0; font-size: var(--fs-lg); font-weight: 600; color: var(--text-primary); }
.dash-sec-sub { margin: 0; font-size: var(--fs-sm); color: var(--text-muted); }
.dash-sec-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s-5); min-width: 0; }
.dash-sec-grid > * { min-width: 0; }
.dash-sec-grid > .panel { max-height: none; }
.dash-sec-grid > .panel--atencao, .dash-sec-grid > .cotacoes-linha { grid-column: 1 / -1; }
@container dash-fixo (min-width: 720px) {
  .dash-sec-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
/* Menos ruído: cabeçalho de painel sem altura mínima e números tabulares à direita. */
.dash-sec .panel > .panel-head { min-height: 0; }
.dash-sec :is(.num, .legend-val, .legend-pct, .mini-stats dd, .fv-head .num) { font-variant-numeric: tabular-nums; }
.dash-sec .mini-stats > div { text-align: right; }
.dash-sec .donut-wrap { gap: var(--s-4); }
.dash-sec .donut-wrap .donut-svg { width: 132px; max-width: 132px; }
.dash-sec .donut-legend { min-width: 160px; }
.dash-sec .legend-val { text-align: right; }
.dash-sec .panel-note { color: var(--text-muted); }
/* Resultado do mês e categorias: barras horizontais em HTML/CSS (nome e valor na linha, barra embaixo). */
.dash-mes-nav { display: inline-flex; align-items: center; gap: var(--s-1); margin-bottom: var(--s-3); }
.dash-mes-nav .btn { min-width: var(--hit); min-height: var(--hit); }
.dash-mes-label { min-width: 6ch; text-align: center; font-size: var(--fs-md); font-weight: 600; color: var(--text-primary); font-variant-numeric: tabular-nums; }
.hbars { display: grid; gap: var(--s-4); margin: 0; padding: 0; list-style: none; }
.hbar { display: grid; gap: var(--s-1); min-width: 0; }
.hbar-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-3); font-size: var(--fs-md); }
.hbar-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-secondary); }
.hbar-val { display: inline-flex; align-items: baseline; gap: var(--s-2); white-space: nowrap; color: var(--text-primary); font-weight: 600; font-variant-numeric: tabular-nums; }
.hbar-pct { min-width: 4ch; text-align: right; font-size: var(--fs-2xs); font-weight: 400; color: var(--text-muted); }
.hbar-track { height: 10px; border-radius: var(--r-pill); background: var(--surface-interaction); overflow: hidden; }
.hbar-fill { display: block; height: 100%; min-width: 0; border-radius: var(--r-pill); background: var(--chart-in); }
.hbar--income .hbar-fill { background: var(--chart-in); }
.hbar--expense .hbar-fill { background: var(--chart-out); }
.hbar--neg .hbar-fill { background: var(--chart-neg); }
.hbar--pos .hbar-fill { background: var(--chart-result); }
.hbar--neg .hbar-val { color: var(--danger); }
.resultado-margem { margin: var(--s-4) 0 0; font-size: var(--fs-md); color: var(--text-secondary); }
.resultado-margem strong { margin-left: var(--s-1); color: var(--text-primary); font-variant-numeric: tabular-nums; }
.resultado-margem strong.tone-neg { color: var(--danger); }
/* Frase-título dos gráficos de fluxo e projeção. */
.chart-frase { margin: 0 0 var(--s-3); font-size: var(--fs-lg); font-weight: 600; color: var(--text-primary); }
.chart-frase.tone-neg { color: var(--danger); }
/* Projeção: uma linha (base) e faixa entre otimista e pessimista. */
.band-area { fill: color-mix(in srgb, var(--chart-in) 14%, transparent); }
.band-base { stroke: var(--chart-in); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.band-cross { fill: var(--chart-neg); stroke: var(--surface); stroke-width: 2; }
.sw-faixa { background: color-mix(in srgb, var(--chart-in) 30%, transparent); }
@media (max-width: 700px) {
  /* Linha 1: período em segmented de largura total (2 metades iguais); linha 2: ações em 2 colunas iguais. */
  .dash-fixo .page-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-2); width: 100%; }
  .dash-fixo .page-actions > .dash-periodo {
    grid-column: 1 / -1; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px; padding: 2px;
    border: 1px solid var(--border); border-radius: var(--r-pill); background: var(--surface);
  }
  .dash-fixo .page-actions > .dash-periodo > .btn { min-height: 36px; width: 100%; border-radius: var(--r-pill); justify-content: center; }
  .dash-fixo .page-actions > .dash-periodo > input { width: 100%; grid-column: auto; }
  .dash-fixo .page-actions > .dash-periodo > .muted { display: none; }
  .dash-fixo .page-actions > .btn { width: 100%; min-height: 40px; justify-content: center; }
  .dash-fixo .page-actions > .dash-periodo + .btn { grid-column: auto; } /* anula a regra genérica acima (largura total) */
  .dash-fixo .page-actions > .btn:last-child:nth-child(2) { grid-column: 1 / -1; }
}
/* ==========================================================================
   Pacote D (QA 31/10/2026): visual e acessibilidade. Só tokens existentes.
   ========================================================================== */

/* Bug 24: o diálogo de confirmação não tinha respiro (título e texto colados na borda). O rodapé
   mantém o próprio padding e a linha divisória de borda a borda. */
.dialog-card > :not(.modal-footer) { padding-inline: var(--s-5); }

/* Bug 8: o selo do ambiente fica dentro do .modal-body (rola com o conteúdo). */
.modal-body > .modal-workspace-badge { margin: 0 0 var(--s-3); max-width: 100%; }

/* Bug 11: tabelas largas viram cartões empilhados no celular (mesmo padrão de .dt e .pricing-table).
   Cada td leva data-label com o nome da coluna; a coluna de ações fica sem rótulo. */
@media (max-width: 700px) {
  .data-table.data-table--stack { min-width: 0; width: 100%; display: block; }
  .data-table--stack thead { display: none; }
  .data-table--stack tbody { display: block; }
  .data-table--stack tbody tr {
    display: grid; gap: var(--s-1);
    padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--border);
  }
  .data-table--stack tbody tr:last-child { border-bottom: 0; }
  .data-table--stack tbody tr:hover td { background: none; }
  .data-table--stack tbody tr:hover td:first-child,
  .data-table--stack tbody tr:hover td:last-child { border-radius: 0; }
  .data-table.data-table--stack td {
    display: flex; justify-content: space-between; align-items: baseline; gap: var(--s-3);
    padding: 2px 0; border: 0; text-align: right;
    max-width: none; white-space: normal; overflow: visible;
  }
  .data-table--stack td[data-label]::before {
    content: attr(data-label); flex: none; text-align: left;
    font-size: var(--fs-xs); color: var(--text-muted);
  }
  .data-table--stack td > .stack-val { min-width: 0; text-align: right; }
  .data-table--stack td.table-empty { display: block; text-align: center; }
  .data-table--stack td:not([data-label]):last-child { justify-content: flex-end; margin-top: var(--s-1); }
  .data-table--stack .row-actions { justify-content: flex-end; }

  /* Contas a pagar: célula vazia ("-") some do cartão em vez de ocupar uma linha de rótulo sem valor. */
  .dt td:has(> .dt-vazio:only-child),
  .data-table--stack td:has(> .dt-vazio:only-child) { display: none; }

  /* Categorias (Regressão A): cartão compacto. Linha 1 = nome; linha 2 = metadados em
     fila; linha 3 = ações (4 botões não cabem ao lado do nome a 390px), sem rótulos repetidos (só "Lançamentos" mantém o rótulo, porque o número sozinho é ambíguo). */
  .data-table--stack tbody tr.categoria-row {
    display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-1) var(--s-2);
    padding: var(--s-2) var(--s-3);
  }
  .data-table--stack tr.categoria-row > td { padding: 0; }
  .data-table--stack tr.categoria-row > td[data-label]::before { display: none; }
  /* Nome e situação dividem a primeira linha; os metadados seguem na segunda. */
  .data-table--stack tr.categoria-row > td.categoria-nome { flex: 1 1 calc(100% - 96px); min-width: 0; justify-content: flex-start; text-align: left; font-weight: 600; }
  .data-table--stack tr.categoria-row > td.categoria-nome .stack-val { text-align: left; }
  .data-table--stack tr.categoria-row > td.categoria-actions { flex: 1 1 100%; order: 3; margin: 0; justify-content: flex-start; }
  /* Ações numa linha só: botões repartem a largura (mantêm a altura de 44 px); "Ver lançamentos" vira "Ver". */
  .data-table--stack tr.categoria-row > td.categoria-actions .row-actions { display: flex; flex-wrap: nowrap; justify-content: stretch; gap: var(--s-1); width: 100%; }
  .data-table--stack tr.categoria-row > td.categoria-actions .row-actions .btn { flex: 1 1 0; min-width: 0; padding-inline: var(--s-2); }
  .categoria-ver-extra { display: none; }
  .data-table--stack tr.categoria-row > td.categoria-actions:empty { display: none; }
  .data-table--stack tr.categoria-row > td[data-label]:not(.categoria-nome) { order: 2; flex: 0 0 auto; font-size: var(--fs-xs); color: var(--text-muted); }
  .data-table--stack tr.categoria-row > td[data-label="Status"]:not(.categoria-nome) { order: 1; }
  .data-table--stack tr.categoria-row > td[data-label="Lançamentos"]::before { display: inline; content: "Lançamentos: "; margin-inline-end: var(--s-1); }
}

/* Título de cartão de item (Dívidas, Investimentos, Lixeira): h2 com o tamanho do antigo h3. */
.card-item-title { margin: 0; color: var(--t0); font-size: 1.1429rem; line-height: 1.25; }

/* A11Y: região rolável focável (tabela de precificação) com foco visível. */
.pricing-table-card:focus-visible { outline: 2px solid var(--action); outline-offset: 2px; }

/* Bug 19: mensagem de período inválido, na largura do seletor. */
.dash-periodo-erro { flex-basis: 100%; margin: var(--s-1) 0 0; font-size: var(--fs-xs); }

/* Legenda da rosca no dashboard e no DRE: nome à esquerda, valor e % em linha à direita, alinhados. */
:is(.dash-sec, .dre-dash) .donut-legend li { align-items: center; }
:is(.dash-sec, .dre-dash) .legend-num { display: flex; align-items: baseline; justify-content: flex-end; gap: var(--s-2); }
:is(.dash-sec, .dre-dash) .legend-pct { min-width: 4ch; }

/* Cantos concêntricos (31/10/2026): filho com fundo, hover, seleção ou foco encostado na borda de um contêiner
   arredondado herda o raio do contêiner menos o recuo (padding + borda), em vez de um raio menor fixo, para o
   canto do filho nunca ficar mais reto que o do pai (ex.: .kpi-strip-item: 24px - 4px - 1px). */
/* Linha de tabela com hover: as pontas da linha acompanham o arredondamento (a tabela usa
   border-collapse: separate para o raio valer nas células). */
.dt tbody tr:hover td:first-child { border-top-left-radius: var(--r-md); border-bottom-left-radius: var(--r-md); }
.dt tbody tr:hover td:last-child { border-top-right-radius: var(--r-md); border-bottom-right-radius: var(--r-md); }

/* === Visão geral Pessoal (Pulso) === */
/* Briefing, "o mês em uma conta", barra de orçamento, semana (condicional) e categorias. Só tokens. */
.vgp-corpo { gap: var(--s-6); }
.vgp-briefing { margin: 0; max-width: 62ch; font-size: var(--fs-md); line-height: 1.5; color: var(--text-secondary); }
.vgp-secao { margin: 0; font-family: var(--font-head); font-size: var(--fs-xs); font-weight: 500; color: var(--text-muted); }

.vgp-conta { display: flex; flex-direction: column; gap: var(--s-3); }
.vgp-equacao {
  display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto minmax(0, 1.15fr);
  align-items: center; gap: var(--s-4);
  padding: var(--s-6);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
}
.vgp-termo { display: flex; flex-direction: column; gap: var(--s-1); min-width: 0; }
.vgp-rotulo { font-size: var(--fs-sm); color: var(--text-secondary); }
.vgp-valor {
  font-size: clamp(22px, 3.2vw, var(--fs-2xl)); font-weight: 500; letter-spacing: -0.6px; line-height: 1.1;
  color: var(--text-primary); min-width: 0; overflow: hidden; text-overflow: ellipsis;
}
.vgp-termo--resultado .vgp-valor { font-size: clamp(26px, 3.8vw, var(--fs-hero)); }
.vgp-sub { font-size: var(--fs-xs); color: var(--text-muted); }
.vgp-op { font-family: var(--font-head); font-size: var(--fs-2xl); line-height: 1; color: var(--text-secondary); }
@media (max-width: 700px) {
  .vgp-equacao { grid-template-columns: minmax(0, 1fr); gap: var(--s-2); padding: var(--s-5); }
  .vgp-op { font-size: var(--fs-xl); padding-left: var(--s-1); }
}

.vgp-orc {
  display: flex; flex-direction: column; gap: var(--s-3);
  padding: var(--s-5) var(--s-6);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
}
.vgp-orc-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: var(--s-2) var(--s-4); }
.vgp-orc-valores { margin: 0; font-size: var(--fs-lg); color: var(--text-primary); white-space: normal; }
.vgp-orc-de { font-size: var(--fs-sm); color: var(--text-secondary); font-weight: 400; }
.vgp-orc-trilha { position: relative; height: 10px; border-radius: var(--r-pill); background: var(--surface-interaction); }
.vgp-orc-fill { display: block; height: 100%; border-radius: inherit; background: var(--action); }
.vgp-orc-trilha.is-estouro .vgp-orc-fill { background: var(--chart-neg); }
.vgp-orc-marca {
  position: absolute; top: -4px; bottom: -4px; width: 2px; margin-left: -1px;
  background: var(--text-primary); border-radius: var(--r-pill);
}
.vgp-orc-msg { margin: 0; font-size: var(--fs-sm); color: var(--text-secondary); }
.vgp-orc-msg.tone-neg { color: var(--danger); }
.vgp-orc--vazio { flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-2) var(--s-4); padding-block: var(--s-4); }
.vgp-orc-vazio { margin: 0; font-size: var(--fs-sm); color: var(--text-secondary); }

.vgp-baixo { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s-5); align-items: start; }
@media (min-width: 1024px) { .vgp-baixo.tem-semana { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.vgp-links { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--s-1) var(--s-3); }
.vgp-semana-corpo { padding-bottom: var(--s-2); }
.vgp-dia-titulo { margin: 0; padding: var(--s-2) var(--panel-pad, var(--s-5)) 0; font-size: var(--fs-xs); font-weight: 500; color: var(--text-muted); }
.vgp-dia--atraso .vgp-dia-titulo { color: var(--danger); }
/* ==========================================================================
   Pulso-A (01/11/2026): topbar estilo Mercury, paleta de comandos, menu do avatar e
   bloco de organização da sidebar. Só tokens.
   ========================================================================== */

/* Topbar: busca larga à esquerda, ação principal + ícones + avatar à direita (sem breadcrumb). */
.topbar-search {
  flex: 1 1 280px; max-width: 520px; min-width: 0; height: 40px;
  display: flex; align-items: center; gap: var(--s-3); padding: 0 var(--s-3) 0 var(--s-4);
  border: 1px solid var(--border); border-radius: var(--r-pill);
  background: var(--surface); color: var(--text-muted);
  font: inherit; font-size: var(--fs-sm); text-align: left; cursor: text;
  transition: border-color var(--motion) var(--ease-out), background var(--motion) var(--ease-out);
}
.topbar-search:hover { border-color: var(--border-strong); background: var(--surface-raised); }
.topbar-search-ico { flex: none; display: inline-flex; }
.topbar-search-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-kbd {
  flex: none; padding: 2px var(--s-2); border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  font: inherit; font-size: var(--fs-2xs); color: var(--text-muted); white-space: nowrap;
}
.topbar-icons { display: flex; align-items: center; gap: 0; }
.topbar-novo { height: 40px; min-height: 40px; gap: var(--s-2); padding: 0 var(--s-4); white-space: nowrap; }
.topbar-novo-ico { display: inline-flex; }
.topbar-novo-ico--mais { display: none; }
.topbar-avatar-btn {
  flex: none; display: inline-grid; place-items: center; width: 40px; height: 40px; padding: 0;
  border: 0; border-radius: 50%; background: none; cursor: pointer;
}
.topbar-avatar {
  width: 32px; height: 32px; flex: none; display: grid; place-items: center; border-radius: 50%;
  background: var(--surface-interaction); border: 1px solid var(--border-strong);
  color: var(--text-primary); font-size: var(--fs-xs); font-weight: 600; letter-spacing: 0;
}
.topbar-avatar--lg { width: 40px; height: 40px; font-size: var(--fs-sm); }
.topbar-avatar-btn:hover .topbar-avatar,
.topbar-avatar-btn[aria-expanded="true"] .topbar-avatar { border-color: var(--action); }

@media (max-width: 1050px) {
  .topbar-kbd { display: none; }
  .topbar-tools { max-width: none; flex-wrap: nowrap; }
}

/* Celular: busca vira ícone (abre a paleta em tela cheia), "Novo lançamento" vira "+" redondo. */
@media (max-width: 700px) {
  .topbar .topbar-search {
    flex: none; width: 40px; padding: 0; justify-content: center; margin-left: auto;
    border-color: transparent; background: none; color: var(--text-secondary); cursor: pointer;
  }
  .topbar-search-text {
    position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap;
  }
  .topbar-tools { margin-left: 0; gap: var(--s-1); }
  .topbar-icons > :is(a.icon-btn, [data-action="refresh"]) { display: none; } /* admin e atualizar ficam no menu do avatar */
  .topbar .btn.topbar-novo { width: 40px; padding: 0; justify-content: center; }
  .topbar-novo-texto {
    position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap;
  }
  .topbar-novo-ico--troca { display: none; }
  .topbar-novo-ico--mais { display: inline-flex; }
  .topbar .status-badge { display: none; }
}

/* Menu do avatar (fora do #root, em #menu-avatar-root). */
.avatar-menu {
  position: fixed; top: var(--menu-top, 64px); right: var(--menu-right, 16px); z-index: 300;
  width: min(300px, calc(100vw - 24px)); padding: var(--s-2);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-lg);
  box-shadow: var(--shadow-pop); transform-origin: top right;
  animation: popover-in var(--motion) var(--ease-out);
}
.avatar-menu-head {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-3); margin-bottom: var(--s-1); border-bottom: 1px solid var(--border);
}
.avatar-menu-quem { flex: 1; min-width: 0; }
.avatar-menu-quem b,
.avatar-menu-quem span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar-menu-quem b { font-size: var(--fs-md); font-weight: 600; color: var(--text-primary); }
.avatar-menu-quem span { margin-top: 1px; font-size: var(--fs-xs); color: var(--text-muted); }
.avatar-menu-lista { display: flex; flex-direction: column; gap: 2px; }
.avatar-menu-item {
  display: flex; align-items: center; gap: var(--s-3); width: 100%; min-height: var(--hit);
  padding: 0 var(--s-3); border: 0; border-radius: var(--r-md); background: none; cursor: pointer;
  color: var(--text-primary); font: inherit; font-size: var(--fs-sm); text-align: left; text-decoration: none;
}
.avatar-menu-item:hover { background: var(--surface-interaction); }
.avatar-menu-item svg { flex: none; color: var(--text-secondary); }
.avatar-menu-item.is-sair,
.avatar-menu-item.is-sair svg { color: var(--danger); }
@media (max-width: 700px) {
  .avatar-menu { right: var(--s-2); }
}

/* Sidebar: bloco de organização + segmentado de ambiente (Empresarial | Pessoal). */
.sidebar-org { display: flex; flex-direction: column; gap: var(--s-2); }
.sidebar-org-head {
  display: flex; align-items: center; gap: var(--s-3); width: 100%; padding: var(--s-2) var(--s-3);
  border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface);
  color: var(--text-primary); font: inherit; text-align: left;
}
.sidebar-org-head.is-clickable { cursor: pointer; transition: background var(--motion) var(--ease-out); }
.sidebar-org-head.is-clickable:hover { background: var(--surface-interaction); }
.sidebar-org-mark {
  flex: none; display: grid; place-items: center; width: 32px; height: 32px; border-radius: var(--r-sm);
  background: var(--action-soft); color: var(--action); font-size: var(--fs-md); font-weight: 600;
}
.sidebar-org-text { flex: 1; min-width: 0; }
.sidebar-org-text b,
.sidebar-org-text span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-org-text b { font-size: var(--fs-sm); font-weight: 600; }
.sidebar-org-text span { margin-top: 1px; font-size: var(--fs-2xs); color: var(--text-muted); }
.sidebar-org-go { flex: none; display: inline-flex; color: var(--text-muted); }
.sidebar-org-seg { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
.sidebar-org-seg .segmented-item { text-align: center; }

/* Paleta de comandos (lib/paleta-comandos.js). */
body.paleta-aberta { overflow: hidden; }
.paleta-backdrop {
  position: fixed; inset: 0; z-index: 400; display: flex; justify-content: center; align-items: flex-start;
  padding: 12vh var(--s-4) var(--s-4); background: var(--backdrop);
}
.paleta {
  width: min(640px, 100%); max-height: min(560px, 76dvh); display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-lg);
  box-shadow: var(--shadow-modal); animation: popover-in var(--motion) var(--ease-out);
}
.paleta-busca {
  flex: none; display: flex; align-items: center; gap: var(--s-3); height: 56px; padding: 0 var(--s-3) 0 var(--s-4);
  border-bottom: 1px solid var(--border); color: var(--text-muted);
}
.paleta-busca:focus-within { box-shadow: inset 0 -2px 0 var(--action); }
.paleta-busca-ico { flex: none; display: inline-flex; }
.paleta-input {
  flex: 1; min-width: 0; height: 100%; padding: 0; border: 0; border-radius: 0; background: transparent;
  color: var(--text-primary); font: inherit; font-size: var(--fs-lg);
}
.paleta-input:focus-visible { outline: none; box-shadow: none; }
.paleta-input::placeholder { color: var(--text-muted); opacity: 1; }
.paleta-fechar {
  flex: none; display: inline-grid; place-items: center; min-width: 40px; height: 32px; padding: 0 var(--s-2);
  border: 1px solid var(--border-strong); border-radius: var(--r-sm); background: none; cursor: pointer;
  color: var(--text-muted); font: inherit; font-size: var(--fs-2xs);
}
.paleta-fechar:hover { background: var(--surface-interaction); color: var(--text-primary); }
.paleta-fechar-x { display: none; }
.paleta-lista { flex: 1; min-height: 0; overflow-y: auto; padding: var(--s-2); }
.paleta-grupo-titulo {
  padding: var(--s-3) var(--s-3) var(--s-1); font-size: var(--fs-2xs); font-weight: 600; color: var(--text-muted);
}
.paleta-item {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-3);
  min-height: var(--hit); padding: var(--s-2) var(--s-3); border-radius: var(--r-md); cursor: pointer;
}
.paleta-item[aria-selected="true"] { background: var(--surface-interaction); box-shadow: inset 3px 0 0 var(--action); }
.paleta-item-titulo { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--fs-sm); color: var(--text-primary); }
.paleta-item-sub { flex: 0 1 55%; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: right; font-size: var(--fs-xs); color: var(--text-muted); }
.paleta-lista[hidden], #paleta-vazio[hidden] { display: none; }
.paleta-vazio { margin: 0; padding: var(--s-8) var(--s-4); text-align: center; color: var(--text-secondary); font-size: var(--fs-sm); }
.paleta-vazio span { display: block; margin-top: var(--s-1); font-size: var(--fs-xs); color: var(--text-muted); }
.paleta-rodape {
  flex: none; display: flex; gap: var(--s-4); padding: var(--s-2) var(--s-4);
  border-top: 1px solid var(--border); font-size: var(--fs-2xs); color: var(--text-muted);
}
.paleta-rodape kbd {
  margin-right: 4px; padding: 1px 6px; border: 1px solid var(--border-strong); border-radius: var(--r-xs);
  font: inherit; font-size: var(--fs-2xs);
}
@media (max-width: 700px) {
  .paleta-backdrop { padding: 0; }
  .paleta { width: 100%; max-height: none; height: 100dvh; border: 0; border-radius: 0; }
  .paleta-rodape { display: none; }
  .paleta-fechar { width: var(--hit); height: var(--hit); border-color: transparent; }
  .paleta-fechar-esc { display: none; }
  .paleta-fechar-x { display: inline-flex; }
}
:root[data-motion="reduce"] :is(.paleta, .avatar-menu) { animation: none; }
@media (prefers-reduced-motion: reduce) {
  .paleta, .avatar-menu { animation: none; }
}

/* Cards sobre o fundo: opacos no escuro (02/11/2026, visual da produção), translúcidos a 90% no claro.
   Opacos em alto contraste / menos transparência / contraste forçado. */
:root :is(.card, .panel, .pulso-card, .kpi-card, .kpi-strip, .debt-card, .forecast-card) { background: var(--card-fill); }
@media not ((prefers-reduced-transparency: reduce) or (prefers-contrast: more) or (forced-colors: active)) {
  :root[data-theme="light"]:not(.contrast) { --card-fill: color-mix(in srgb, var(--surface) 90%, transparent); }
}

/* Glow de seleção (02/11/2026): mesma linguagem do dia selecionado da régua, só em estados selecionados/ativos
   (dia da régua e item ativo da sidebar). Chips, segmentados, botões, cards e KPIs não usam.
   Sem glow em alto contraste e contraste forçado (a borda/fundo continuam indicando). */
:root {
  --glow-sel: linear-gradient(to top, color-mix(in srgb, var(--action) 24%, transparent), transparent 65%);
  --glow-sel-line: inset 0 -1px 0 color-mix(in srgb, var(--action) 45%, transparent);
}
:root[data-theme="light"] {
  --glow-sel: linear-gradient(to top, color-mix(in srgb, var(--action) 14%, transparent), transparent 65%);
  --glow-sel-line: inset 0 -1px 0 color-mix(in srgb, var(--action) 35%, transparent);
}
:root.contrast { --glow-sel: none; --glow-sel-line: none; }
@media (prefers-contrast: more), (forced-colors: active) { :root, :root[data-theme="light"] { --glow-sel: none; --glow-sel-line: none; } }
/* Reduzido a 2 lugares (revisão de UI #7, antislop R-13: glow em no máximo 1-2 elementos por tela). */
:is(.pulso-dia[aria-pressed="true"], .sidebar-link.active) {
  background-image: var(--glow-sel);
  box-shadow: var(--glow-sel-line);
}
.pulso-dia[aria-pressed="true"]:hover { background-color: var(--surface-interaction); }

/* Assinatura (revisão de UI #10): a situação abre a página; pendências e administração ficam recolhíveis. */
.billing-details > summary { display: flex; align-items: center; gap: var(--s-2); min-height: var(--hit); cursor: pointer; list-style: none; }
.billing-details > summary::-webkit-details-marker { display: none; }
.billing-details > summary::after { content: ""; width: 8px; height: 8px; margin-left: auto; border-right: 2px solid var(--text-muted); border-bottom: 2px solid var(--text-muted); transform: rotate(45deg); transition: transform var(--motion) var(--ease-out); }
.billing-details[open] > summary::after { transform: rotate(-135deg); }
.billing-details > summary h2 { margin: 0; }
.billing-details[open] > summary { margin-bottom: var(--s-3); }

/* ==========================================================================
   Revisão de UI 002, lote 4: rodapé dos formulários
   ========================================================================== */
/* Rodapé "Cancelar / Salvar" sempre à vista: antes só era fixo até 700px e, em desktop e tablet,
   ficava centenas de pixels abaixo da dobra em formulários longos (Receber, Pagar, Venda). */
@media (min-width: 701px) {
  .modal-card:not(.modal-card--drawer) .modal-body > .modal-footer {
    position: sticky; bottom: 0; z-index: 1; background: var(--surface);
  }
}
/* O rodapé já traz o próprio respiro: sem padding do formulário abaixo dele, onde o conteúdo rolava. */
.modal-body:has(> .modal-footer) { padding-bottom: 0; }
/* Celular: botões lado a lado na ordem do DOM (= ordem de Tab); sem espaço, quebram para a linha de baixo.
   O column-reverse antigo punha o primário acima de "Cancelar" e invertia a ordem visual em relação ao Tab. */
@media (max-width: 700px) {
  .modal-footer:not(.modal-footer--lancamento) { flex-direction: row; flex-wrap: wrap; }
  .modal-footer:not(.modal-footer--lancamento) .btn { flex: 1 1 9rem; width: auto; }
}
/* Movimentações: a lista não é um cartão dentro do cartão do modal. */
.mov-panel .data-table { border: 0; background: none; }

/* Revisão de UI 002, lote 6: ação destrutiva com cara de perigo. `.btn` (declarado depois) zerava
   background, cor e borda do `.btn-danger` antigo; a especificidade a mais devolve o vermelho. */
.btn.btn-danger { background: var(--red-bg); color: var(--red); border-color: var(--red-bdr); }
.btn.btn-danger:hover { background: var(--red); color: var(--bg-app); }

/* Revisão de UI 002 (B4): Movimentações. O rolável é o painel, com a lista e o formulário; o <form> sai do
   layout (display: contents) para o rodapé fixo acompanhar toda a rolagem e ficar sempre à vista
   (antes o botão "Registrar movimentação" começava abaixo da tela em 390px). */
.mov-panel { flex: 1 1 auto; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: var(--s-4); padding: var(--s-4) var(--s-5) 0; overscroll-behavior: contain; }
.mov-panel > *, .mov-panel > form > * { flex-shrink: 0; } /* sem isso a lista é espremida e cortada */
.mov-panel > form.modal-body { display: contents; }
.mov-panel > form > .modal-footer { position: sticky; bottom: 0; z-index: 1; margin-inline: calc(-1 * var(--s-5)); padding-inline: var(--s-5); background: var(--surface); }
@media (max-width: 700px) { .mov-panel > form > .modal-footer { background: var(--surface-raised); } }

/* Revisão de UI 002: alvos de toque de pelo menos 24px (WCAG 2.5.8) em botões de ordenar da tabela,
   links "Ver ..." dos painéis e checkboxes de formulário. */
.dt-sort { min-height: 24px; padding-block: 4px; }
.link-go { min-height: 24px; }
.field-check { min-height: 24px; }
@media (max-width: 700px) { .field-check { min-height: var(--hit); align-items: center; } }

/* Revisão de UI 002 (A16, A21, A23): nos modais a dica de campo não é maior que o campo, a folha de baixo não
   tem alça de arrastar (o gesto não existe) e botões fantasma e chips têm borda legível como os campos. */
.modal-card .field-hint { font-size: var(--fs-sm); color: var(--text-secondary); margin-block: var(--s-1) var(--s-3); }
.modal-card::before { content: none; }
.modal-card .btn-ghost, .modal-card .chip { border-color: var(--border-input); }

/* Revisão de UI 002 (A15): o selo de ambiente é informação, não destaque: texto secundário e borda neutra
   (o azul fica para o botão primário, o foco e o item ativo). */
.modal-workspace-badge, .modal-card .modal-workspace-badge { font-weight: 500; color: var(--text-secondary); background: none; border: 1px solid var(--border); }

/* ==========================================================================
   KPIs translúcidos (04/11/2026), nos dois níveis (Sólido, o padrão, e Vidro). Faixas e cards de indicador deixam o sol/fundo de LEDs aparecer por baixo:
   fill de 56% do --surface, borda de 1px mais clara e um fio de luz no topo. SEM blur próprio: topbar, sidebar e
   overlays já usam o único material com blur (regra R-10 do antislop) e dezenas de KPIs com backdrop-filter
   custariam GPU a cada rolagem. Texto sempre sobre >= 56% do --surface, com os tokens de texto reforçados pelo
   fundo de LEDs (ver acima). Sem Vidro, menos transparência, alto contraste e contraste forçado o KPI volta ao
   fill opaco do nível Sólido.
   ========================================================================== */
:root:is([data-glass="glass"], [data-glass="solid"]) {
  --glass-kpi-fill: color-mix(in srgb, var(--surface) 56%, transparent);
  --glass-kpi-hover: color-mix(in srgb, var(--surface-interaction) 62%, transparent);
  --glass-kpi-edge: color-mix(in srgb, var(--text-primary) 14%, transparent);
}
@media (prefers-reduced-transparency: reduce), (prefers-contrast: more), (forced-colors: active) {
  :root:is([data-glass="glass"], [data-glass="solid"])[data-theme] { --glass-kpi-fill: var(--surface); --glass-kpi-hover: var(--surface-interaction); }
}
:root.contrast:is([data-glass="glass"], [data-glass="solid"])[data-theme] { --glass-kpi-fill: var(--surface); --glass-kpi-hover: var(--surface-interaction); }
:root:is([data-glass="glass"], [data-glass="solid"]):is([data-theme="dark"], [data-theme="light"]) :is(.kpi-strip, .kpi-card),
:root:is([data-glass="glass"], [data-glass="solid"]):is([data-theme="dark"], [data-theme="light"]) :is(.card, .panel, .modal-card, .dialog-card) :is(.kpi-strip, .kpi-card),
:root:is([data-glass="glass"], [data-glass="solid"]) .dre-dash .kpi-strip {
  background: var(--glass-kpi-fill);
  -webkit-backdrop-filter: none; backdrop-filter: none;
  border-color: var(--glass-kpi-edge);
  box-shadow: inset 0 1px 0 color-mix(in srgb, var(--text-primary) 8%, transparent);
}
:root:is([data-glass="glass"], [data-glass="solid"]) a.kpi-strip-item:hover,
:root:is([data-glass="glass"], [data-glass="solid"]) button.kpi-strip-item:hover { background: var(--glass-kpi-hover); }

/* Brilho sutil no topo dos cards (gradiente frio de 7%); camada de imagem sobre a cor de fundo que cada card já tem.
   Na Visão geral (.vg) os cartões ficam lisos desde 10/11/2026: o brilho em todo cartão era o que dava cara de gerado (DECISOES.md). */
:is(.panel, .card, .kpi-strip) { background-image: var(--sheen-card); }
.vg :is(.panel, .card, .pulso-card, .vg-kpi, .vg-faixa) { background-image: none; }

/* ── Visão geral em cartões (09/11/2026): resumo da semana, indicadores, realizado x previsto, pendências ── */
.vg .pulso-head { margin-bottom: var(--s-5); }
.vg .pulso-saudacao, .vg .pulso-data { grid-column: 1; }
.vg .pulso-data { white-space: normal; }
.vg .pulso-acoes { grid-column: 2; grid-row: 1 / span 2; align-self: center; justify-content: flex-end; margin-top: 0; }
@media (max-width: 900px) { .vg .pulso-acoes { grid-column: 1; grid-row: auto; justify-content: flex-start; margin-top: var(--s-2); } }
.vg-corpo { display: flex; flex-direction: column; gap: var(--s-4); }

/* Tipografia dos valores em reais (lib/valor-visual.js): símbolo menor, dígitos em destaque, centavos mais leves. */
.vv-moeda { font-size: .6em; font-weight: 500; letter-spacing: 0; color: var(--text-secondary); margin-right: .08em; }
.vv-sinal { font-weight: 500; }
.vv-int { font-weight: 600; }
.vv-cent { font-size: .72em; font-weight: 500; letter-spacing: 0; color: var(--text-secondary); }
.tone-pos :is(.vv-moeda, .vv-cent), .tone-neg :is(.vv-moeda, .vv-cent) { color: inherit; }

/* Faixa da semana: UMA caixa com três segmentos separados por filete (é contexto, não três métricas). */
.vg-faixa { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); background: var(--surface); border: 1px solid var(--border); border-radius: 14px; overflow: hidden; }
.vg-seg { display: flex; flex-direction: column; align-items: flex-start; gap: var(--s-1); min-width: 0; padding: var(--s-4) var(--card-pad); }
.vg-seg + .vg-seg { border-left: 1px solid var(--border); }
.vg-seg-rotulo { margin: 0; font-size: var(--fs-sm); font-weight: 500; color: var(--text-secondary); }
.vg-seg-valor { margin: 0; font-family: var(--font-head); font-size: var(--fs-xl); letter-spacing: -0.02em; line-height: 1.2; color: var(--text-primary); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.vg-seg-valor.tone-pos { color: var(--success); }
.vg-seg-valor.tone-neg { color: var(--danger); }
.vg-seg-nota { margin: 0; font-size: var(--fs-xs); color: var(--text-secondary); }
.vg-seg-acao { margin-top: var(--s-1); }
.vg-seg-acao .link-go { padding: 0; white-space: nowrap; }
.vg-seg--alerta { background: color-mix(in srgb, var(--danger) 6%, var(--surface)); }

/* Indicadores com pesos diferentes: Resultado em destaque (duas linhas), Recebido e Pago compactos, o último largo embaixo. */
.vg-kpis { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: auto auto; gap: var(--s-4); }
.vg-kpi { display: flex; flex-direction: column; gap: var(--s-1); min-width: 0; padding: var(--card-pad); background: var(--surface); border: 1px solid var(--border); border-radius: 14px; }
.vg-kpi--destaque { grid-row: 1 / span 2; gap: var(--s-2); padding: var(--s-8) var(--s-8) var(--s-6); border-radius: var(--r-lg); }
.vg-kpi--largo { grid-column: 2 / span 2; }
.vg-kpi-rotulo { margin: 0; font-family: var(--font-body); font-size: var(--fs-sm); font-weight: 500; color: var(--text-secondary); }
.vg-kpi-valor { margin: 0; font-family: var(--font-head); font-size: 26px; letter-spacing: -0.02em; line-height: 1.15; color: var(--text-primary); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.vg-kpi--destaque .vg-kpi-valor { font-size: 48px; line-height: 1.05; letter-spacing: -0.03em; }
.vg-kpi-valor.tone-pos { color: var(--success); }
.vg-kpi-valor.tone-neg { color: var(--danger); }
.vg-kpi-sub { margin: 0; font-size: var(--fs-sm); color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.vg-kpi-detalhe { margin: 0; font-size: var(--fs-xs); color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.vg-kpi-serie { margin-top: auto; padding-top: var(--s-5); }
.vg-kpi-serie-nota { margin: var(--s-1) 0 0; font-size: var(--fs-xs); color: var(--text-secondary); }
.vg-kpi-serie-nota--vazio { margin-top: auto; padding-top: var(--s-5); }
.vg-kpi .link-go { align-self: flex-start; margin-top: var(--s-2); padding: 0; }
.vg-kpi--destaque .link-go { margin-top: auto; }

/* Minigráfico: saldo mensal dos últimos meses; só desenha com dados reais (views/dashboard-visao.js serieDeSaldo). */
.vg-spark { display: block; width: 100%; height: auto; max-height: 96px; overflow: visible; }
.vg-spark-linha { fill: none; stroke: var(--chart-result); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.vg-spark-zero { stroke: var(--border-strong); stroke-width: 1; stroke-dasharray: 3 4; vector-effect: non-scaling-stroke; }
.vg-spark-ponto { fill: var(--chart-result); stroke: var(--surface); stroke-width: 2; }

/* Barra com a marca de previsto: o tique fica no ponto do previsto e a barra pode passar dele. */
.vg-barra { position: relative; height: 6px; margin-top: var(--s-2); border-radius: var(--r-pill); background: var(--surface-interaction); }
.vg-barra--larga { height: 10px; }
.vg-barra-fill { display: block; height: 100%; border-radius: inherit; background: var(--text-secondary); }
.vg-barra-marca { position: absolute; top: -3px; bottom: -3px; width: 2px; margin-left: -1px; border-radius: var(--r-pill); background: var(--text-primary); }
.vg-barra--larga .vg-barra-marca { top: -4px; bottom: -4px; }
.vg-barra-fill--acao { background: var(--action-fill); }
.vg-barra-fill--aviso { background: var(--warning); }
.vg-barra-fill--saida { background: var(--chart-out); }
.vg-barra-fill--pos { background: var(--success); }
.vg-barra-fill--neg { background: var(--danger); }

.vg-duplo { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: var(--s-4); align-items: start; }
.vg-pp-corpo { display: flex; flex-direction: column; gap: var(--s-5); padding: var(--s-2) var(--panel-pad) var(--panel-pad); }
.vg-pp-topo { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-3); }
.vg-pp-rotulo { font-size: var(--fs-sm); color: var(--text-secondary); }
.vg-pp-valores { font-size: var(--fs-sm); font-variant-numeric: tabular-nums; text-align: right; }
.vg-pp-valores strong { color: var(--text-primary); font-weight: 600; }
.vg-pp-valores strong.tone-neg { color: var(--danger); }
.vg-pp-de { color: var(--text-muted); }
.vg-pp-resto { margin: var(--s-1) 0 0; font-size: var(--fs-xs); color: var(--text-muted); }
.vg-legenda { display: flex; gap: var(--s-5); margin: 0; font-size: var(--fs-xs); color: var(--text-muted); }
.vg-sw { display: inline-block; width: 8px; height: 8px; margin-right: var(--s-1); border-radius: 50%; background: var(--action-fill); }
.vg-sw--marca { width: 2px; height: 12px; margin: 0 var(--s-2) -2px 3px; border-radius: var(--r-pill); background: var(--text-primary); }
.vg-vazio { margin: 0; font-size: var(--fs-sm); color: var(--text-muted); }

.vg-pend-lista { list-style: none; margin: 0; padding: 0 var(--panel-pad) var(--s-3); }
.vg-pend-linha { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3) 0; border-top: 1px solid var(--border); }
.vg-pend-linha:first-child { border-top: 0; }
.vg-pend-rotulo { flex: 1 1 auto; min-width: 0; font-size: var(--fs-sm); color: var(--text-secondary); }
.vg-pend-nota { display: block; margin-top: 2px; font-size: var(--fs-xs); color: var(--text-muted); }
.vg-pend-valor { flex: 0 0 auto; font-size: var(--fs-sm); font-weight: 600; font-variant-numeric: tabular-nums; color: var(--text-primary); text-align: right; }
.vg-pend-linha .link-go { flex: 0 0 auto; padding: 0; }

@container dash-fixo (max-width: 980px) {
  .vg-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: auto; }
  .vg-kpi--destaque { grid-row: auto; grid-column: 1 / -1; }
  .vg-kpi--largo { grid-column: 1 / -1; }
  .vg-duplo { grid-template-columns: minmax(0, 1fr); }
}
@container dash-fixo (max-width: 760px) {
  .vg-faixa { grid-template-columns: minmax(0, 1fr); }
  .vg-seg + .vg-seg { border-left: 0; border-top: 1px solid var(--border); }
  .vg-kpi--destaque { padding: var(--s-6); }
  .vg-kpi--destaque .vg-kpi-valor { font-size: 40px; }
}
@container dash-fixo (max-width: 480px) {
  .vg-kpis { grid-template-columns: minmax(0, 1fr); }
  .vg-kpi--destaque .vg-kpi-valor { font-size: 36px; }
}

/* Rodapé do menu lateral (09/11/2026): Assinatura e Administração ficam fixas embaixo; os grupos acima rolam. */
.sidebar-foot { display: flex; flex-direction: column; gap: var(--s-3); padding-top: var(--s-3); border-top: 1px solid var(--border); }

/* Faixa de destaque da Visão geral: brilho frio atrás do cabeçalho (decorativo; o texto fica sobre alfa <= 14%). */
.vg .pulso-head, .vg .page-header { position: relative; isolation: isolate; }
.vg .pulso-head::before, .vg .page-header::before {
  content: ''; position: absolute; z-index: -1; pointer-events: none;
  inset: calc(var(--card-pad) * -1) calc(var(--card-pad) * -1) calc(var(--s-2) * -1);
  background: var(--grad-faixa); border-radius: var(--r-lg);
}

/* Gráficos com degradê frio (as definições <linearGradient> ficam em app.html). O fallback depois do url() mantém a cor
   sólida se a definição não existir. Linhas, donuts e legendas seguem sólidos. */
.svg-defs { position: absolute; width: 0; height: 0; overflow: hidden; }
.gs-in-a { stop-color: color-mix(in srgb, var(--chart-in) 78%, #fff); }
.gs-in-b { stop-color: var(--chart-in); }
.gs-out-a { stop-color: color-mix(in srgb, var(--chart-out) 78%, #fff); }
.gs-out-b { stop-color: var(--chart-out); }
.gs-res-a { stop-color: color-mix(in srgb, var(--chart-result) 78%, #fff); }
.gs-res-b { stop-color: var(--chart-result); }
.ga-in-a, .ga-in-b { stop-color: var(--chart-in); }
.ga-out-a, .ga-out-b { stop-color: var(--chart-out); }
.ga-in-a, .ga-out-a { stop-opacity: .34; }
.ga-in-b, .ga-out-b { stop-opacity: .02; }
:root.contrast .svg-defs, :root[data-glass="glass"] .svg-defs { display: none; }
.bar-income, .dre-bar-receita, .bar-result { fill: url(#g-bar-in) var(--chart-in); }
.bar-expense { fill: url(#g-bar-out) var(--chart-out); }
.dre-bar-resultado { fill: url(#g-bar-res) var(--chart-result); }
.ln-income-area { fill: url(#g-area-in) color-mix(in srgb, var(--chart-in) 16%, transparent); }
.ln-expense-area { fill: url(#g-area-out) color-mix(in srgb, var(--chart-out) 16%, transparent); }
:root.contrast :is(.bar-income, .dre-bar-receita, .bar-result) { fill: var(--chart-in); }
:root.contrast .bar-expense { fill: var(--chart-out); }
:root.contrast .dre-bar-resultado { fill: var(--chart-result); }
:root.contrast .ln-income-area { fill: color-mix(in srgb, var(--chart-in) 16%, transparent); }
:root.contrast .ln-expense-area { fill: color-mix(in srgb, var(--chart-out) 16%, transparent); }

/* Barras de progresso (HTML): a cor da barra clareia (escuro) ou escurece (claro) até o fim, sempre aumentando o contraste. */
.vg-barra-fill, .hbar-fill, .rank-bar-fill, .progress-bar > span { background-image: linear-gradient(90deg, transparent, color-mix(in srgb, var(--text-primary) 22%, transparent)); }
:root.contrast :is(.vg-barra-fill, .hbar-fill, .rank-bar-fill, .progress-bar > span), :root[data-glass="glass"] :is(.vg-barra-fill, .hbar-fill, .rank-bar-fill, .progress-bar > span) { background-image: none; }

/* ── Animações (09/11/2026) ──────────────────────────────────────────────────────────────────────
   Entrada (só barras, linhas e a contagem do Resultado; os cartões não animam desde 10/11/2026): lib/entrada.js liga <html data-entra> por ~1,6 s na primeira vez que a tela mostra dados (uma vez por tela e período);
   atualizar, ocultar valores ou trocar o dia da régua não repete. Só transform, opacity e clip-path. Com "reduzir movimento"
   (app ou sistema) o atributo nem é ligado e o corte global de l.587 zera o resto. */
@keyframes barra-cresce { from { transform: scaleX(0); } }
@keyframes barra-sobe { from { transform: scaleY(0); } }
@keyframes linha-desenha { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
:root[data-entra] :is(.vg-barra-fill, .hbar-fill, .rank-bar-fill, .progress-bar > span, .pulso-barra-fill) { transform-origin: left center; animation: barra-cresce 640ms var(--ease-out) 240ms backwards; }
:root[data-entra] .pulso-pilar--entra .pulso-pilar-barra { transform-origin: bottom; animation: barra-sobe 560ms var(--ease-out) 200ms backwards; }
:root[data-entra] .pulso-pilar--sai .pulso-pilar-barra { transform-origin: top; animation: barra-sobe 560ms var(--ease-out) 200ms backwards; }
:root[data-entra] :is(.bar-income, .bar-expense, .bar-result, .dre-bar-receita, .dre-bar-resultado) { transform-box: fill-box; transform-origin: bottom; animation: barra-sobe 620ms var(--ease-out) 200ms backwards; }
:root[data-entra] :is(.ln-income-line, .ln-income-area, .ln-expense-line, .ln-expense-area, .dre-ln-mc-line, .dre-ln-ml-line, .vg-spark-linha) { animation: linha-desenha 900ms var(--ease-out) 200ms backwards; }
:root[data-entra] :is(.ln-income-dot, .ln-expense-dot, .dre-ln-mc-dot, .dre-ln-ml-dot, .vg-spark-ponto) { animation: fade-in 260ms var(--ease-out) 900ms backwards; }

@media print { :root[data-entra] * { animation: none !important; } }
