/*
 * FYNIX — a folha visual da plataforma (SDK 2.5.0).
 *
 * Uma folha só, para o host e para todo módulo. Os valores vêm do Fynix
 * Design System (tokens/colors, typography, spacing, elevation, motion) e o
 * vocabulário de classe `fx-*` é o mesmo do kit de referência: canvas cinza
 * claro, cartões brancos de 18px com borda fina e sombra difusa, verde-floresta
 * como tinta, lima como ação e como série principal dos gráficos.
 *
 * O que NÃO existe aqui, de propósito: cor por categoria. Os gráficos são
 * lima + verde escuro (+ lima-200 e neutro-300 em fatias menores) e a
 * distinção entre categorias vem do RÓTULO, nunca do matiz — o que também é a
 * regra do método de dataviz da plataforma (tema.ts). A única rosca com mais
 * de quatro fatias é a ORDENADA (SDK 2.12.0): a cor codifica a posição numa
 * rampa da própria marca, verde-floresta → lima (RAMPA_ORDENADA em tema.ts).
 */

:root {
  /* Marca */
  --lime-50: #f2fcea; --lime-100: #e4f8d6; --lime-200: #cdf2b3; --lime-300: #b6ec91;
  --lime-400: #aaea80; --lime-500: #9fe870; --lime-600: #84cb56; --lime-700: #6aa843; --lime-800: #4e7c31;
  --green-50: #eaf2f0; --green-100: #cbdeda; --green-200: #9bbdb6; --green-300: #6a9b92;
  --green-400: #3d7268; --green-500: #1f5349; --green-600: #123f37; --green-700: #0c372f;
  --green-800: #09332b; --green-900: #062f28; --green-950: #04201b;
  --neutral-0: #ffffff; --neutral-25: #fafafa; --neutral-50: #f5f5f5; --neutral-100: #efefef;
  --neutral-150: #eaeaea; --neutral-200: #e2e2e2; --neutral-300: #d6d6d6; --neutral-400: #b8b9b9;
  --neutral-500: #787b7b; --neutral-600: #5c5f5f; --neutral-700: #414343; --neutral-900: #1c1e1e;

  /* Estado — só em selo, valor com sinal e aviso. Nunca decoração. */
  --status-positive: #2f9e5b; --status-positive-soft: #e7f6ec;
  --status-warning: #e2a32b; --status-warning-soft: #fbf1dc;
  --status-negative: #e0473a; --status-negative-soft: #fbe7e5;
  --status-info: #3b7dd8; --status-info-soft: #e6eefa;

  /* Superfícies e texto */
  --surface-canvas: var(--neutral-150);
  --surface-card: var(--neutral-0);
  --surface-sunken: var(--neutral-50);
  --surface-muted: var(--neutral-100);
  --surface-inverse: var(--green-900);
  --surface-accent: var(--lime-500);
  --surface-accent-soft: var(--lime-50);
  --surface-glass: rgba(255, 255, 255, 0.72);
  --text-strong: var(--green-900);
  --text-body: var(--neutral-700);
  --text-muted: var(--neutral-500);
  --text-faint: var(--neutral-400);
  --text-on-accent: var(--green-900);
  --text-on-inverse: var(--neutral-0);
  --border-subtle: #ececec;
  --border-default: #e2e2e2;
  --border-strong: #d2d2d2;

  /* Dataviz */
  --chart-1: var(--lime-500);
  --chart-2: var(--green-900);
  --chart-3: var(--lime-200);
  --chart-4: var(--neutral-300);
  --chart-grid: #ededed;
  --chart-area-top: rgba(159, 232, 112, 0.35);
  --chart-area-bottom: rgba(159, 232, 112, 0);

  --gradient-balance: radial-gradient(120% 140% at 12% 18%, #c9f2a6 0%, #9fe870 42%, #6fcb52 100%);
  --gradient-soft-card: linear-gradient(160deg, #ffffff 0%, #f4fbee 100%);

  /* Tipografia */
  --font-display: "Space Grotesk", "Urbanist", system-ui, sans-serif;
  --font-ui: "Urbanist", "Plus Jakarta Sans", system-ui, sans-serif;
  --font-body: "Plus Jakarta Sans", "Urbanist", system-ui, sans-serif;
  --font-numeric: "Space Grotesk", ui-monospace, monospace;
  --text-h1: 32px; --text-h2: 26px; --text-h3: 20px; --text-h4: 17px;
  --text-body-lg: 15px; --text-body: 14px; --text-sm: 13px; --text-xs: 12px; --text-2xs: 11px;
  --text-metric-xl: 38px; --text-metric: 24px;
  --tracking-tight: -0.01em; --tracking-display: -0.02em; --tracking-label: 0.06em;

  /* Raios, espaço, elevação, movimento */
  --radius-xs: 6px; --radius-sm: 10px; --radius-md: 14px; --radius-lg: 18px;
  --radius-xl: 24px; --radius-pill: 999px;
  --app-sidebar-w: 232px; --app-topbar-h: 60px; --app-gutter: 16px; --card-pad: 18px; --grid-gap: 16px;
  --shadow-xs: 0 1px 2px rgba(6, 47, 40, 0.04);
  --shadow-sm: 0 1px 3px rgba(6, 47, 40, 0.05), 0 1px 1px rgba(6, 47, 40, 0.03);
  --shadow-md: 0 4px 16px rgba(6, 47, 40, 0.06);
  --shadow-lg: 0 12px 32px rgba(6, 47, 40, 0.08);
  --shadow-xl: 0 24px 60px rgba(6, 47, 40, 0.1);
  --shadow-accent: 0 8px 20px rgba(132, 203, 86, 0.28);
  --ring-accent: 0 0 0 3px rgba(159, 232, 112, 0.45);
  --duration-fast: 140ms; --duration-base: 200ms; --duration-slow: 320ms;
  --ease-standard: cubic-bezier(0.22, 0.61, 0.36, 1);
  --transition-base: all var(--duration-base) var(--ease-standard);
}

/* ------------------------------------------------------------ base */
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; background: var(--surface-canvas); color: var(--text-body); font-family: var(--font-ui); font-size: var(--text-body); line-height: 1.45; -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4 { margin: 0; font-family: var(--font-display); color: var(--text-strong); letter-spacing: var(--tracking-tight); }
button, input, select, textarea { font: inherit; }

/* ------------------------------------------------------------ utilidades */
.fx-num { font-family: var(--font-numeric); font-variant-numeric: tabular-nums; letter-spacing: var(--tracking-tight); }
.fx-eyebrow { font-size: var(--text-2xs); letter-spacing: var(--tracking-label); text-transform: uppercase; color: var(--text-faint); font-weight: 600; }
.fx-muted { color: var(--text-muted); }
.fx-sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* ------------------------------------------------------------ página do módulo */
.fx-page { display: flex; flex-direction: column; gap: var(--grid-gap); min-width: 0; }
.fx-page > * { min-width: 0; }

/* Linhas do painel: contagens de coluna misturadas, como no Fynix. */
.fx-row { display: grid; gap: var(--grid-gap); align-items: stretch; }
.fx-row > * { min-width: 0; }
.fx-row--hero { grid-template-columns: minmax(260px, 1.1fr) 1.6fr minmax(240px, 1fr); }
.fx-row--2 { grid-template-columns: 1.55fr 1fr; }
.fx-row--2e { grid-template-columns: 1fr 1fr; }
.fx-row--3 { grid-template-columns: 1.45fr 1fr 1fr; }
.fx-row--3e { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.fx-row--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.fx-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; }
.fx-tiles > * { min-width: 0; }
.fx-span-all { grid-column: 1 / -1; }

@media (max-width: 1180px) {
  .fx-row--hero, .fx-row--2, .fx-row--3, .fx-row--3e, .fx-row--4 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 760px) {
  .fx-row--hero, .fx-row--2, .fx-row--2e, .fx-row--3, .fx-row--3e, .fx-row--4 { grid-template-columns: 1fr; }
}

/* ------------------------------------------------------------ cartão */
.fx-card {
  display: flex; flex-direction: column; min-width: 0;
  background: var(--surface-card); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
}
.fx-card--sunken { background: var(--surface-sunken); box-shadow: none; }
.fx-card--soft { background: var(--gradient-soft-card); border-color: var(--lime-100); }
.fx-card--inverse { background: var(--green-900); border-color: var(--green-900); color: var(--neutral-0); }
.fx-card--inverse .fx-card__title, .fx-card--inverse .fx-card__sub { color: inherit; }
.fx-card__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: var(--card-pad) var(--card-pad) 0; }
.fx-card__head > div:first-child { min-width: 0; }
.fx-card__title { margin: 0; font-family: var(--font-display); font-size: var(--text-h4); font-weight: 700; color: var(--text-strong); letter-spacing: var(--tracking-tight); }
.fx-card__sub { margin: 2px 0 0; font-size: var(--text-xs); color: var(--text-muted); line-height: 1.45; }
.fx-card__actions { display: flex; align-items: center; gap: 8px; flex: none; flex-wrap: wrap; justify-content: flex-end; }
.fx-card__body { padding: var(--card-pad); flex: 1; min-height: 0; min-width: 0; }
.fx-card__body--flush { padding: 0; }
.fx-card__foot { padding: 12px var(--card-pad) var(--card-pad); border-top: 1px solid var(--border-subtle); font-size: var(--text-xs); color: var(--text-muted); line-height: 1.5; }
.fx-card--compact .fx-card__head { padding: 14px 14px 0; }
.fx-card--compact .fx-card__body { padding: 14px; }

/* Sub-painel afundado dentro de um cartão. */
.fx-inset { background: var(--surface-sunken); border-radius: var(--radius-md); padding: 14px; }

/* ------------------------------------------------------------ tile de número */
.fx-tile {
  display: flex; flex-direction: column; gap: 2px; min-width: 0; margin: 0; container-type: inline-size;
  background: var(--surface-card); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md); padding: 14px; box-shadow: var(--shadow-xs);
}
.fx-tile__top { order: 1; display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.fx-tile__icon { width: 30px; height: 30px; border-radius: var(--radius-pill); background: var(--surface-sunken); display: inline-flex; align-items: center; justify-content: center; color: var(--green-900); flex: none; }
.fx-tile__value { order: 2; margin: 0; font-family: var(--font-numeric); font-size: var(--text-metric); font-weight: 700; color: var(--text-strong); letter-spacing: var(--tracking-display); font-variant-numeric: tabular-nums; line-height: 1.1; overflow-wrap: anywhere; }
/* Tile estreito: o número encolhe antes de quebrar no meio. */
@container (max-width: 190px) { .fx-tile__value { font-size: 20px; } }
@container (max-width: 150px) { .fx-tile__value { font-size: 17px; } }
.fx-tile__label { order: 3; margin: 0; font-size: var(--text-xs); color: var(--text-muted); }
.fx-tile__note { order: 4; margin-top: 6px; font-size: var(--text-2xs); color: var(--text-faint); line-height: 1.45; }
.fx-tile--sunken { background: var(--surface-sunken); box-shadow: none; border-color: transparent; }
.fx-tile--sunken .fx-tile__icon { background: var(--surface-card); }
.fx-tile--positive .fx-tile__value { color: var(--status-positive); }
.fx-tile--negative .fx-tile__value { color: var(--status-negative); }
.fx-tile--warning .fx-tile__value { color: #b07a10; }
dl.fx-tiles, dl.fx-row { margin: 0; }

/* Herói lima: um por tela. Grade: bloco principal em cima, fatos embaixo. */
.fx-hero {
  position: relative; overflow: hidden; min-width: 0; margin: 0;
  border-radius: var(--radius-lg); background: var(--gradient-balance);
  padding: var(--card-pad); box-shadow: var(--shadow-md); color: var(--green-900);
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px;
}
.fx-hero::before, .fx-hero::after { content: ""; position: absolute; border-radius: 50%; border: 1px solid rgba(255, 255, 255, 0.35); pointer-events: none; }
.fx-hero::before { width: 260px; height: 260px; right: -60px; top: -120px; }
.fx-hero::after { width: 200px; height: 200px; right: -40px; bottom: -120px; border-color: rgba(255, 255, 255, 0.3); }
.fx-hero > * { position: relative; }
.fx-hero__main { flex: 1 1 100%; min-width: 0; display: flex; flex-direction: column; margin-bottom: auto; }
.fx-hero__actions { position: absolute; top: 0; right: 0; }
.fx-hero__label { font-size: var(--text-xs); font-weight: 600; color: var(--green-700); margin: 0; }
.fx-hero__value { font-family: var(--font-numeric); font-size: var(--text-metric-xl); font-weight: 700; letter-spacing: var(--tracking-display); line-height: 1.05; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; margin: 2px 0 0; }
.fx-hero__caption { font-size: var(--text-xs); color: var(--green-700); font-weight: 500; margin-top: 4px; }
.fx-hero__fact { display: inline-flex; flex-direction: column; gap: 1px; padding: 8px 12px; border-radius: var(--radius-sm); background: rgba(255, 255, 255, 0.55); min-width: 0; margin-top: 8px; }
.fx-hero__fact > :first-child { font-size: var(--text-2xs); color: var(--green-700); font-weight: 600; margin: 0; }
.fx-hero__fact > :last-child { font-family: var(--font-numeric); font-size: var(--text-sm); font-weight: 700; font-variant-numeric: tabular-nums; margin: 0; }

/* ------------------------------------------------------------ selo */
.fx-badge { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: var(--radius-pill); font-size: var(--text-2xs); font-weight: 600; line-height: 1.2; white-space: nowrap; background: var(--neutral-100); color: var(--text-muted); }
.fx-badge--positive { background: var(--status-positive-soft); color: var(--status-positive); }
.fx-badge--warning { background: var(--status-warning-soft); color: #9a6a12; }
.fx-badge--negative { background: var(--status-negative-soft); color: var(--status-negative); }
.fx-badge--info { background: var(--status-info-soft); color: var(--status-info); }
.fx-badge--accent { background: var(--lime-500); color: var(--green-900); }
.fx-badge--soft { background: var(--lime-50); color: var(--green-700); }
.fx-badge--inverse { background: var(--green-900); color: var(--neutral-0); }
.fx-badge__dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }

/* ------------------------------------------------------------ botão */
.fx-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 16px; border-radius: var(--radius-pill); cursor: pointer;
  font-family: var(--font-ui); font-size: var(--text-sm); font-weight: 600; line-height: 1.2;
  border: 1px solid var(--border-default); background: var(--surface-card); color: var(--text-strong);
  transition: var(--transition-base); white-space: nowrap;
}
.fx-btn:hover:not(:disabled) { filter: brightness(0.96); }
.fx-btn:active:not(:disabled) { transform: scale(0.98); }
.fx-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.fx-btn--primary { background: var(--green-900); color: var(--neutral-0); border-color: var(--green-900); }
.fx-btn--accent { background: var(--lime-500); color: var(--green-900); border-color: var(--lime-500); }
.fx-btn--accent:hover:not(:disabled) { box-shadow: var(--shadow-accent); }
.fx-btn--ghost { background: transparent; border-color: transparent; color: var(--text-body); }
.fx-btn--soft { background: var(--lime-50); border-color: var(--lime-200); color: var(--green-900); }
.fx-btn--sm { padding: 6px 12px; font-size: var(--text-xs); }
.fx-btn--icon { width: 36px; height: 36px; padding: 0; border-radius: var(--radius-pill); }
.fx-btn .fx-spin { width: 13px; height: 13px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: fx-girar 0.7s linear infinite; }
@keyframes fx-girar { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------ chips e abas */
.fx-chips { display: inline-flex; flex-wrap: wrap; gap: 6px; padding: 5px; background: var(--surface-card); border: 1px solid var(--border-subtle); border-radius: var(--radius-pill); box-shadow: var(--shadow-xs); }
.fx-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 13px; border-radius: var(--radius-pill);
  border: 1px solid transparent; background: transparent; cursor: pointer;
  font-family: var(--font-ui); font-size: var(--text-sm); font-weight: 500; color: var(--text-muted);
  transition: var(--transition-base); white-space: nowrap;
}
.fx-chip:hover { color: var(--text-strong); background: var(--surface-sunken); }
.fx-chip[aria-pressed="true"], .fx-chip--active { background: var(--lime-500); border-color: var(--lime-500); color: var(--green-900); font-weight: 600; }
.fx-chips--outline { padding: 0; background: transparent; border: none; box-shadow: none; }
.fx-chips--outline .fx-chip { background: var(--surface-card); border-color: var(--border-default); color: var(--text-body); }
.fx-chips--outline .fx-chip[aria-pressed="true"] { background: var(--lime-50); border-color: var(--lime-300); color: var(--green-900); }

.fx-tabs { display: flex; align-items: center; gap: 22px; border-bottom: 1px solid var(--border-subtle); overflow-x: auto; }
.fx-tab { background: none; border: none; cursor: pointer; padding: 0 0 9px; margin-bottom: -1px; border-bottom: 2px solid transparent; font-family: var(--font-ui); font-size: var(--text-sm); font-weight: 500; color: var(--text-muted); white-space: nowrap; transition: var(--transition-base); }
.fx-tab[aria-pressed="true"] { color: var(--text-strong); font-weight: 700; border-bottom-color: var(--lime-500); }

/* ------------------------------------------------------------ formulário */
.fx-toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 12px; }
.fx-toolbar > * { min-width: 0; }
.fx-toolbar__spacer { flex: 1; }
.fx-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.fx-field > span { font-size: var(--text-xs); font-weight: 600; color: var(--text-muted); }
.fx-field input, .fx-field select, .fx-input {
  height: 40px; padding: 0 12px; min-width: 0; width: 100%;
  font-family: var(--font-ui); font-size: var(--text-body); color: var(--text-strong);
  background: var(--surface-card); border: 1px solid var(--border-default); border-radius: var(--radius-sm);
  transition: var(--transition-base); color-scheme: light;
}
.fx-field select { padding-right: 32px; appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23787b7b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='m6 9 6 6 6-6'/></svg>");
  background-repeat: no-repeat; background-position: right 10px center; }
.fx-field input:focus, .fx-field select:focus, .fx-input:focus { outline: none; border-color: var(--lime-400); box-shadow: var(--ring-accent); }
.fx-field input[aria-invalid="true"] { border-color: var(--status-negative); }
.fx-field--sm input, .fx-field--sm select { height: 34px; font-size: var(--text-sm); }
.fx-field--inline { flex-direction: row; align-items: center; gap: 8px; }
.fx-field--inline > span { white-space: nowrap; }

/* ------------------------------------------------------------ tabela */
.fx-scroll { overflow-x: auto; min-width: 0; }
.fx-table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.fx-table th, .fx-table td { padding: 10px 12px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--border-subtle); }
.fx-table thead th { font-size: var(--text-2xs); font-weight: 600; letter-spacing: 0.02em; text-transform: uppercase; color: var(--text-muted); background: var(--surface-sunken); border-bottom: 1px solid var(--border-subtle); white-space: nowrap; }
.fx-table thead th:first-child { border-top-left-radius: var(--radius-sm); }
.fx-table thead th:last-child { border-top-right-radius: var(--radius-sm); }
.fx-table tbody tr:hover td { background: var(--lime-50); }
.fx-table tbody tr:last-child td { border-bottom: none; }
.fx-table td { color: var(--text-body); }
.fx-table td:first-child { color: var(--text-strong); font-weight: 500; }
.fx-table .fx-num, .fx-table th.fx-num, .fx-table td.fx-num { text-align: right; white-space: nowrap; }
.fx-table tfoot th, .fx-table tfoot td { border-top: 1px solid var(--border-default); border-bottom: none; font-weight: 700; color: var(--text-strong); background: var(--surface-sunken); }
.fx-table tfoot th { text-align: left; font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.02em; }
.fx-table--compact th, .fx-table--compact td { padding: 8px 10px; font-size: var(--text-xs); }
.fx-table .fx-cell-sub { display: block; font-size: var(--text-2xs); color: var(--text-faint); font-weight: 400; }

/* ------------------------------------------------------------ linhas (extrato) */
.fx-rows { display: flex; flex-direction: column; }
.fx-rowitem { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border-subtle); min-width: 0; }
.fx-rowitem:last-child { border-bottom: none; }
.fx-rowitem__bubble { width: 30px; height: 30px; flex: none; border-radius: var(--radius-pill); background: var(--lime-50); color: var(--green-700); display: inline-flex; align-items: center; justify-content: center; font-family: var(--font-display); font-size: var(--text-2xs); font-weight: 700; }
.fx-rowitem__bubble--negative { background: var(--status-negative-soft); color: var(--status-negative); }
.fx-rowitem__bubble--positive { background: var(--status-positive-soft); color: var(--status-positive); }
.fx-rowitem__bubble--neutral { background: var(--neutral-100); color: var(--text-muted); }
.fx-rowitem__main { flex: 1; min-width: 0; }
.fx-rowitem__name { display: block; font-size: var(--text-sm); font-weight: 600; color: var(--text-strong); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fx-rowitem__meta { display: block; font-size: var(--text-2xs); color: var(--text-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fx-rowitem__amount { font-family: var(--font-numeric); font-size: var(--text-sm); font-weight: 600; color: var(--text-strong); white-space: nowrap; font-variant-numeric: tabular-nums; }
.fx-rowitem__amount--positive { color: var(--status-positive); }
.fx-rowitem__amount--negative { color: var(--status-negative); }

/* ------------------------------------------------------------ ranking (barras horizontais) */
.fx-bars { display: flex; flex-direction: column; gap: 10px; }
.fx-bar { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; align-items: center; min-width: 0; }
.fx-bar__label { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: var(--text-sm); color: var(--text-strong); font-weight: 500; }
.fx-bar__label span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fx-bar__rank { flex: none; width: 22px; height: 22px; border-radius: 50%; background: var(--surface-sunken); color: var(--text-muted); font-size: var(--text-2xs); font-weight: 700; display: inline-flex; align-items: center; justify-content: center; font-family: var(--font-numeric); }
.fx-bar__value { font-family: var(--font-numeric); font-size: var(--text-sm); font-weight: 600; color: var(--text-strong); white-space: nowrap; font-variant-numeric: tabular-nums; }
.fx-bar__meta { font-size: var(--text-2xs); color: var(--text-faint); white-space: nowrap; margin-left: 6px; font-weight: 400; }
.fx-bar__track { grid-column: 1 / -1; position: relative; height: 8px; border-radius: 4px; background: var(--surface-sunken); overflow: hidden; }
.fx-bar__fill { position: absolute; top: 0; bottom: 0; left: 0; border-radius: 4px; background: var(--chart-1); transition: width var(--duration-slow) var(--ease-standard); }
.fx-bar__fill--secondary { background: var(--chart-2); }
.fx-bar__fill--negative { background: var(--status-negative); }
.fx-bar__zero { position: absolute; top: -2px; bottom: -2px; width: 1px; background: var(--neutral-400); }

/* Barra empilhada: partes de um todo, com legenda por rótulo. */
.fx-stack { display: flex; flex-direction: column; gap: 8px; }
.fx-stack__track { display: flex; height: 12px; border-radius: 6px; overflow: hidden; background: var(--surface-sunken); }
.fx-stack__seg { height: 100%; min-width: 2px; background: var(--chart-1); }
.fx-stack__seg--2 { background: var(--chart-2); }
.fx-stack__seg--3 { background: var(--chart-4); }
.fx-stack__seg--negative { background: var(--status-negative); }

/* ------------------------------------------------------------ gráficos */
.fx-chart { position: relative; min-width: 0; }
.fx-chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.fx-chart__axis { font-family: var(--font-numeric); font-size: 10px; fill: var(--text-faint); }
.fx-chart__grid { stroke: var(--chart-grid); stroke-width: 1; }
.fx-chart__zero { stroke: var(--neutral-400); stroke-width: 1; }
.fx-chart__bar { fill: var(--chart-1); transition: fill var(--duration-fast) var(--ease-standard); }
.fx-chart__bar--secondary { fill: var(--chart-2); }
.fx-chart__bar--negative { fill: var(--status-negative); }
.fx-chart__bar--dim { fill: var(--chart-3); }
.fx-chart__bar--highlight { fill: var(--green-900); }
.fx-chart__bar--dashed { fill: var(--lime-100); stroke: var(--green-900); stroke-dasharray: 4 3; }
.fx-chart__hit { fill: transparent; cursor: pointer; }
.fx-chart__hit:focus-visible { outline: none; fill: rgba(159, 232, 112, 0.18); }
.fx-chart__slot { position: relative; flex: 1; min-width: 0; max-width: 96px; height: 100%; border: none; background: transparent; padding: 0; margin: 0; cursor: pointer; border-radius: 4px; transition: background var(--duration-fast) var(--ease-standard); }
.fx-chart__slot:hover, .fx-chart__slot[aria-pressed="true"] { background: rgba(159, 232, 112, 0.14); }
.fx-chart__slot:focus-visible { outline: none; box-shadow: var(--ring-accent); }
.fx-chart__slot--bare:hover, .fx-chart__slot--bare[aria-pressed="true"] { background: transparent; }
.fx-chart__col { position: absolute; left: 14%; right: 14%; border-radius: 4px 4px 0 0; background: var(--chart-1); transition: background var(--duration-fast) var(--ease-standard); }
.fx-chart__col--negative { border-radius: 0 0 4px 4px; background: var(--status-negative); }
.fx-chart__col--highlight { background: var(--green-900); }
.fx-chart__col--dashed { background: var(--lime-100); border: 1.5px dashed var(--green-900); }
.fx-chart__slot:hover .fx-chart__col:not(.fx-chart__col--negative):not(.fx-chart__col--highlight):not(.fx-chart__col--dashed) { background: var(--lime-600); }
.fx-chart__tip { position: absolute; z-index: 5; pointer-events: none; transform: translate(-50%, calc(-100% - 10px)); background: var(--green-900); color: var(--neutral-0); border-radius: var(--radius-sm); padding: 7px 10px; font-size: var(--text-xs); line-height: 1.35; box-shadow: var(--shadow-lg); white-space: nowrap; }
.fx-chart__tip strong { display: block; font-family: var(--font-numeric); font-size: var(--text-sm); font-weight: 700; }
.fx-chart__tip::after { content: ""; position: absolute; left: 50%; bottom: -5px; width: 10px; height: 10px; background: var(--green-900); transform: translateX(-50%) rotate(45deg); border-radius: 2px; }
.fx-chart__tip--multi { transform: translate(-50%, 0); text-align: left; }
.fx-chart__tip--multi::after { display: none; }
.fx-chart__tip-row { display: flex; align-items: center; gap: 6px; margin-top: 3px; font-size: var(--text-2xs); }
.fx-chart__tip-row i { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.fx-chart__tip-row strong { display: inline; margin-left: auto; padding-left: 10px; font-size: var(--text-xs); }
.fx-chart__stack { position: absolute; left: 14%; right: 14%; bottom: 0; display: flex; flex-direction: column-reverse; border-radius: 4px 4px 0 0; overflow: hidden; min-height: 0; }
.fx-chart__seg { display: block; width: 100%; min-height: 1px; transition: opacity var(--duration-fast) var(--ease-standard); }
.fx-legend--interactive { margin-top: 8px; }
.fx-legend__item { display: inline-flex; align-items: center; gap: 6px; padding: 3px 8px; border-radius: var(--radius-pill); border: 1px solid transparent; background: transparent; cursor: pointer; font-family: var(--font-ui); font-size: var(--text-xs); color: var(--text-muted); transition: var(--transition-base); }
.fx-legend__item i { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.fx-legend__item:hover, .fx-legend__item[aria-pressed="true"] { background: var(--surface-sunken); color: var(--text-strong); border-color: var(--border-subtle); }
.fx-chart__labels { display: flex; justify-content: space-between; gap: 4px; margin-top: 6px; font-family: var(--font-numeric); font-size: var(--text-2xs); color: var(--text-faint); }
.fx-chart__labels span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: center; }
.fx-chart__labels--sparse { position: relative; display: block; height: 16px; margin-top: 6px; }
.fx-chart__labels--sparse span { position: absolute; top: 0; transform: translateX(-50%); max-width: 72px; }
.fx-chart__status { font-size: var(--text-xs); color: var(--text-muted); min-height: 18px; margin: 6px 0 0; }
.fx-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: var(--text-xs); color: var(--text-muted); }
.fx-legend span { display: inline-flex; align-items: center; gap: 6px; }
.fx-legend i { width: 9px; height: 9px; border-radius: 50%; background: var(--chart-1); flex: none; }
.fx-legend i.fx-legend--2 { background: var(--chart-2); }
.fx-legend i.fx-legend--3 { background: var(--chart-3); }
.fx-legend i.fx-legend--4 { background: var(--chart-4); }
.fx-legend i.fx-legend--negative { background: var(--status-negative); }
.fx-legend i.fx-legend--positive { background: var(--status-positive); }
.fx-legend i.fx-legend--warning { background: var(--status-warning); }
.fx-donut { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 16px; align-items: center; }
/* Rosca ORDENADA (até onze entradas): a legenda desce para baixo do anel, com a
   largura inteira do cartão — ao lado, onze nomes com valor viravam reticência
   depois da primeira letra. O anel fica centrado; a posição na legenda é a
   mesma da rampa (a primeira linha é a fatia mais escura). */
.fx-donut--empilhada { grid-template-columns: minmax(0, 1fr); justify-items: center; gap: 14px; }
.fx-donut--empilhada > ul { width: 100%; }
.fx-donut--empilhada .fx-donut__posicao { font-family: var(--font-numeric); font-size: var(--text-2xs); color: var(--text-faint); width: 14px; text-align: right; }
/* Passar o mouse: a fatia sob o cursor fica inteira, as outras apagam, e o
   centro troca o total pelo nome, valor e percentual dela. A linha da legenda
   faz o mesmo no sentido contrário, e responde ao foco do teclado. */
.fx-chart__slice { transition: stroke-opacity var(--duration-fast) var(--ease-standard); cursor: default; }
/* stroke-opacity, e não opacity: a animação de entrada (fx-surgir, `both`) fixa opacity em 1 e venceria a classe. */
.fx-chart__slice--apagada { stroke-opacity: 0.3; }
.fx-donut__center { pointer-events: none; }
.fx-donut__nome { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.2; text-transform: none; }
.fx-donut__item { border-radius: var(--radius-sm); padding: 2px 4px; margin: 0 -4px; transition: background var(--duration-fast) var(--ease-standard); outline: none; }
.fx-donut__item--ativa, .fx-donut__item:focus-visible { background: var(--surface-accent-soft); }
.fx-donut__center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.fx-donut__center small { font-size: var(--text-2xs); color: var(--text-muted); }
.fx-donut__center strong { font-family: var(--font-numeric); font-size: var(--text-h4); font-weight: 700; color: var(--text-strong); }
.fx-gauge { display: flex; flex-direction: column; align-items: center; text-align: center; }
.fx-gauge__label { font-family: var(--font-display); font-size: var(--text-h3); font-weight: 700; color: var(--text-strong); margin-top: -8px; }
.fx-gauge__value { font-family: var(--font-numeric); font-size: var(--text-sm); color: var(--text-muted); }
.fx-gauge__caption { font-size: var(--text-2xs); color: var(--text-faint); }

/* A tabela gêmea do gráfico, recolhida. */
.fx-details { margin-top: 10px; font-size: var(--text-sm); }
.fx-details > summary { cursor: pointer; width: fit-content; color: var(--green-700); font-weight: 600; font-size: var(--text-xs); padding: 4px 0; list-style: none; display: inline-flex; align-items: center; gap: 6px; }
.fx-details > summary::-webkit-details-marker { display: none; }
.fx-details > summary::before { content: ""; width: 6px; height: 6px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(-45deg); transition: transform var(--duration-fast); margin-left: 2px; }
.fx-details[open] > summary::before { transform: rotate(45deg); }
.fx-details > *:not(summary) { margin-top: 8px; }

/* ------------------------------------------------------------ estados e avisos */
.fx-state { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: var(--radius-md); background: var(--surface-sunken); color: var(--text-muted); font-size: var(--text-sm); line-height: 1.45; margin: 0; }
.fx-state > svg { flex: none; margin-top: 1px; }
.fx-state--loading { color: var(--text-muted); }
.fx-state--error { background: var(--status-negative-soft); color: #9d3229; }
.fx-state--warning { background: var(--status-warning-soft); color: #7a5410; }
.fx-state--info { background: var(--lime-50); color: var(--green-700); }
.fx-state small { display: block; opacity: 0.8; margin-top: 2px; }
.fx-note { margin: 0; font-size: var(--text-xs); color: var(--text-muted); line-height: 1.5; }
.fx-note--body { font-size: var(--text-sm); color: var(--text-body); }
.fx-skeleton { background: linear-gradient(90deg, var(--neutral-100) 25%, var(--neutral-50) 50%, var(--neutral-100) 75%); background-size: 200% 100%; animation: fx-brilho 1.4s ease-in-out infinite; border-radius: var(--radius-sm); }
@keyframes fx-brilho { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .fx-skeleton { animation: none; } .fx-btn .fx-spin { animation-duration: 1.8s; } }

/* ------------------------------------------------------------ avatar */
.fx-avatar { display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; background: var(--green-900); color: var(--lime-500); font-family: var(--font-display); font-weight: 700; flex: none; letter-spacing: 0.02em; }

/* ------------------------------------------------------------ movimento */
/* Fynix: rápido e pequeno. Entrada com 8px de subida, colunas crescendo, linha
   se desenhando, arco varrendo. Nada quica, nada anima em laço. */
@keyframes fx-entrar { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes fx-crescer-y { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes fx-crescer-x { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes fx-revelar { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
@keyframes fx-varrer { from { stroke-dashoffset: var(--fx-len); } to { stroke-dashoffset: 0; } }
@keyframes fx-surgir { from { opacity: 0; } to { opacity: 1; } }
.fx-page > *, .fx-row > * { animation: fx-entrar var(--duration-slow) var(--ease-standard) both; }
.fx-page > *:nth-child(2), .fx-row > *:nth-child(2) { animation-delay: 40ms; }
.fx-page > *:nth-child(3), .fx-row > *:nth-child(3) { animation-delay: 80ms; }
.fx-page > *:nth-child(4), .fx-row > *:nth-child(4) { animation-delay: 120ms; }
.fx-page > *:nth-child(5) { animation-delay: 160ms; }
.fx-page > *:nth-child(6) { animation-delay: 200ms; }
.fx-page > *:nth-child(n+7) { animation-delay: 240ms; }
.fx-hero__value, .fx-tile__value { animation: fx-entrar 360ms var(--ease-standard) both 80ms; }
.fx-chart__col, .fx-chart__stack { transform-origin: bottom; animation: fx-crescer-y 480ms var(--ease-standard) both 120ms; }
.fx-chart__col--negative { transform-origin: top; }
.fx-bar__fill, .fx-stack__seg { transform-origin: left; animation: fx-crescer-x 480ms var(--ease-standard) both 120ms; }
/* A linha se revela da esquerda para a direita. Recorte, e não dash: com
   `preserveAspectRatio="none"` o traço em dash sai com lacunas no meio. */
.fx-chart__reveal { animation: fx-revelar 700ms var(--ease-standard) both 120ms; }
.fx-chart__sweep { animation: fx-varrer 700ms var(--ease-standard) both 120ms; }
.fx-chart__slice { animation: fx-surgir 400ms var(--ease-standard) both; }
.fx-chart__tip { animation: fx-surgir var(--duration-fast) var(--ease-standard) both; }
@media (prefers-reduced-motion: reduce) {
  .fx-page > *, .fx-row > *, .fx-hero__value, .fx-tile__value, .fx-chart__col, .fx-chart__stack, .fx-bar__fill, .fx-stack__seg, .fx-chart__reveal, .fx-chart__sweep, .fx-chart__slice, .fx-chart__tip { animation: none; }
}
@media print { .fx-page > *, .fx-row > *, .fx-chart__col, .fx-chart__stack, .fx-bar__fill, .fx-stack__seg, .fx-chart__reveal, .fx-chart__sweep, .fx-chart__slice { animation: none; } }

/* ------------------------------------------------------------ impressão */
@media print {
  .fx-card { box-shadow: none; break-inside: avoid; }
  .fx-hero { background: var(--lime-200) !important; box-shadow: none; }
  .fx-chart__tip { display: none; }
}
