.fluxo-caixa {
  --fc-receita: #16836f;
  --fc-despesa: #d76059;
  --fc-border: color-mix(in srgb, currentColor 14%, transparent);
  /* Tokens de superficie/texto proprios: o projeto troca de tema por classe
     (html.dark / html.azul), nao pelo Bootstrap nativo. Usar --bs-body-bg ou
     --bs-secondary-color deixava as caixas do montador brancas e os rotulos
     invisiveis no tema escuro. Estes tokens sao sobrescritos por tema abaixo. */
  --fc-surface: #fff;
  --fc-surface-2: #f6f8fa;
  --fc-text: #232c27;
  /* Cor do titulo da coluna ordenada. O azul do Bootstrap serve sobre o fundo
     claro, mas sobre as superficies escuras dos outros dois temas ele cai para
     contraste 3,6. Mesmo no tema claro o azul padrao ficava em 3,5 sobre o
     fundo da coluna ordenada - dai o tom mais fechado aqui. */
  --fc-ordenada-texto: #0a58ca;
  --fc-muted: var(--bs-secondary-color, #64748b);
}

html.dark .fluxo-caixa,
body.dark .fluxo-caixa {
  --fc-surface: rgb(18, 24, 32);
  --fc-surface-2: rgb(14, 18, 24);
  --fc-text: #f2f2f2;
  --fc-muted: #aab3c0;
  --fc-ordenada-texto: #7db8ff;
  --fc-border: rgb(46, 60, 78);
}

html.azul .fluxo-caixa,
body.azul .fluxo-caixa {
  --fc-surface: rgba(50, 70, 90, 0.85);
  --fc-surface-2: rgba(36, 52, 68, 0.95);
  --fc-text: #e6eef8;
  --fc-muted: #b7cce4;
  --fc-ordenada-texto: #7db8ff;
  --fc-border: #3a5a7a;
}

/* Lupa da busca: o .input-group-text padrao do Bootstrap fica com fundo claro e
   icone estridente no tema escuro. Alinha ao input (mesma superficie, borda do
   tema) e deixa o icone em tom suave, nao branco puro. */
.fluxo-caixa .input-group-text {
  background: var(--fc-surface);
  border-color: var(--fc-border);
  color: var(--fc-muted);
}

/* Filtro de situacao: dropdown proprio de checkboxes (o <select multiple> nativo
   nao acompanha o tema escuro). Menu e botao usam os tokens do fluxo. */
.fc-situacoes-dd { position: relative; }
.fc-situacoes-dd > .form-select { cursor: pointer; }
.fluxo-caixa .fc-situacoes-menu {
  min-width: 100%;
  background: var(--fc-surface);
  border: 1px solid var(--fc-border);
  color: var(--fc-text);
}
.fluxo-caixa .fc-situacoes-menu .form-check-label { color: var(--fc-text); }
.fc-situacao-item {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .3rem .35rem;
  border-radius: .35rem;
  cursor: pointer;
}
.fc-situacao-item:hover { background: var(--fc-surface-2); }
.fc-situacao-item .form-check-input { margin: 0; float: none; }
.fc-situacao-item .form-check-label { cursor: pointer; }

/* Autocomplete de Empresa: digitacao direta no campo com lista filtrada. */
.fc-autocomplete { position: relative; }
.fc-autocomplete-menu {
  position: absolute;
  z-index: 1080;
  left: 0;
  right: 0;
  top: calc(100% + 2px);
  max-height: 15rem;
  overflow-y: auto;
  padding: .25rem;
  background: var(--fc-surface);
  border: 1px solid var(--fc-border);
  border-radius: .5rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .18);
}
.fc-autocomplete-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: .4rem .55rem;
  border: 0;
  border-radius: .35rem;
  background: transparent;
  color: var(--fc-text);
  font-size: .85rem;
  cursor: pointer;
}
.fc-autocomplete-item:hover,
.fc-autocomplete-item.is-active {
  background: color-mix(in srgb, var(--bs-primary) 14%, var(--fc-surface-2));
  color: var(--fc-text);
}
.fc-autocomplete-vazio { padding: .55rem; font-size: .82rem; color: var(--fc-muted); text-align: center; }

.fc-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
  gap: 1rem;
  align-items: start;
}

.fc-layout.is-horizontal { grid-template-columns: 1fr; }
.fc-layout.is-horizontal .fc-summary { display: grid; grid-template-columns: 1fr 2fr; gap: 1rem; }

/* Modo "montar colunas": o seletor de campos assume a esquerda e a tabela vai
   para a direita, para a previa se remontar ao lado da lista que o usuario mexe. */
.fc-layout.is-config { grid-template-columns: minmax(290px, 330px) minmax(0, 1fr); }
.fc-layout.is-config .fc-column-builder { order: 1; }
.fc-layout.is-config .fc-main { order: 2; }
.fc-layout.is-config .fc-summary { display: none; }

.fc-preview-bar {
  display: flex;
  align-items: center;
  gap: .4rem;
  padding: .45rem .85rem;
  margin-bottom: .6rem;
  border-radius: .5rem;
  font-size: .82rem;
  font-weight: 500;
  color: var(--bs-primary);
  background: color-mix(in srgb, var(--bs-primary) 12%, transparent);
}

.fc-table-wrap { max-height: 64vh; }
.fc-table-wrap thead { position: sticky; top: 0; z-index: 2; }
.fc-table-wrap th { background: var(--fc-surface-2); color: inherit; white-space: nowrap; cursor: pointer; user-select: none; }
.fc-table-wrap td { white-space: nowrap; }
.fc-table-wrap tbody tr { cursor: pointer; }
.fc-table-wrap tr.is-selected > td { background: color-mix(in srgb, var(--bs-primary) 12%, transparent); }
.fc-select { width: 42px; text-align: center; cursor: default; }

/* Indicador de ordenacao: seta esmaecida no hover mostra que a coluna e clicavel;
   solida quando a ordenacao esta ativa. */
.fc-table-wrap th[data-field]::after {
  content: "\F235";
  font-family: "bootstrap-icons";
  font-size: .7rem;
  margin-left: .3rem;
  opacity: 0;
  vertical-align: -.05em;
}
.fc-table-wrap th[data-field]:hover::after { opacity: .45; }
.fc-table-wrap th[aria-sort="ascending"]::after,
.fc-table-wrap th[aria-sort="descending"]::after { opacity: 1; }
.fc-table-wrap th[aria-sort="descending"]::after { content: "\F229"; }
/* Guia de destino ao arrastar uma coluna: barra na primaria na borda esquerda. */
.fc-table-wrap th.fc-th-drop { box-shadow: inset 3px 0 0 var(--bs-primary); }
.fc-table-wrap th[aria-sort="ascending"],
.fc-table-wrap th[aria-sort="descending"] {
  color: var(--fc-ordenada-texto, var(--bs-primary));
  background: color-mix(in srgb, var(--bs-primary) 14%, var(--fc-surface-2));
}

.fc-tab-count {
  display: inline-block;
  min-width: 1.4rem;
  padding: 0 .35rem;
  margin-left: .3rem;
  border-radius: 999px;
  font-size: .72rem;
  font-variant-numeric: tabular-nums;
  background: color-mix(in srgb, currentColor 16%, transparent);
}

.fc-situacoes { height: auto; min-height: calc(1.5em + .75rem + 2px); }

/* Resumo em quatro blocos 2x2, um por aba do fluxo. */
.fc-blocos { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.fc-bloco { border: 1px solid var(--fc-border); border-radius: .55rem; overflow: hidden; min-width: 0; }
.fc-bloco__head {
  display: flex;
  flex-direction: column;
  padding: .35rem .55rem;
  border-bottom: 1px solid var(--fc-border);
  background: color-mix(in srgb, currentColor 4%, transparent);
}
.fc-bloco__title { font-size: .76rem; font-weight: 600; }
.fc-bloco__sum { font-size: .82rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.fc-bloco__row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: .4rem;
  padding: .16rem .55rem;
  font-size: .74rem;
}
.fc-bloco__row:last-child { padding-bottom: .45rem; }
.fc-bloco__row span { color: var(--fc-muted); }
.fc-bloco__row b { font-variant-numeric: tabular-nums; font-weight: 500; }

.fc-transferencias { display: flex; gap: .5rem; margin-top: .75rem; }
.fc-transferencias > div {
  flex: 1 1 0;
  min-width: 0;
  padding: .45rem .6rem;
  border-radius: .5rem;
  background: color-mix(in srgb, currentColor 5%, transparent);
}
.fc-transferencias small { display: block; font-size: .68rem; color: var(--fc-muted); }
.fc-transferencias b { font-size: .84rem; font-variant-numeric: tabular-nums; }

.fc-kpi-total {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: .75rem;
  padding-top: .6rem;
  border-top: 1px solid var(--fc-border);
  font-size: 1.02rem;
}
.fc-kpi-total span { color: var(--fc-muted); }
.fc-kpi-total strong { font-variant-numeric: tabular-nums; }

.fc-chart { width: 100%; min-height: 190px; overflow: visible; }
.fc-chart text { fill: var(--fc-muted); font-size: 10px; }
.fc-chart .grid { stroke: var(--fc-border); stroke-width: 1; }
.fc-chart .receita { fill: var(--fc-receita); }
.fc-chart .despesa { fill: var(--fc-despesa); }
.fc-chart-legend { display: flex; justify-content: center; gap: 1.5rem; font-size: .8rem; color: var(--fc-muted); }
.fc-chart-legend span::before { content: ""; display: inline-block; width: .7rem; height: .7rem; border-radius: 50%; margin-right: .35rem; }
.fc-chart-legend .receita::before { background: var(--fc-receita); }
.fc-chart-legend .despesa::before { background: var(--fc-despesa); }
.fc-ano { width: 88px; }

/* Montador de colunas: duas listas com arraste entre elas. */
.fc-picker-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: .6rem 0 .3rem;
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--fc-muted);
}
.fc-picker-label em { font-style: normal; font-variant-numeric: tabular-nums; }
.fc-picklist {
  display: flex;
  flex-direction: column;
  gap: .15rem;
  padding: .25rem;
  max-height: 11rem;
  overflow-y: auto;
  border: 1px solid var(--fc-border);
  border-radius: .5rem;
  background: var(--fc-surface-2);
}
.fc-pick {
  position: relative;
  display: flex;
  align-items: center;
  gap: .5rem;
  min-height: 2.5rem;
  padding: .5rem .6rem;
  border: 1px solid var(--fc-border);
  border-radius: .45rem;
  background: var(--fc-surface);
  color: inherit;
  font-size: .84rem;
  cursor: grab;
  user-select: none;
}
.fc-pick:hover { border-color: var(--bs-primary); }
.fc-pick[data-marcado="true"] {
  border-color: var(--bs-primary);
  color: var(--bs-primary);
  background: color-mix(in srgb, var(--bs-primary) 10%, transparent);
  font-weight: 500;
}
.fc-pick.is-dragging { opacity: .35; }
/* Linha-guia de destino: barra grossa na primaria mostra onde a coluna encaixa. */
.fc-pick.fc-drop-before::before,
.fc-pick.fc-drop-after::after {
  content: "";
  position: absolute;
  left: 2px;
  right: 2px;
  height: 3px;
  border-radius: 3px;
  background: var(--bs-primary);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--bs-primary) 40%, transparent);
}
.fc-pick.fc-drop-before::before { top: -2px; }
.fc-pick.fc-drop-after::after { bottom: -2px; }
.fc-pick__ord {
  min-width: 1.4rem;
  height: 1.4rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: .7rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--bs-primary);
  background: color-mix(in srgb, var(--bs-primary) 14%, transparent);
  border-radius: .35rem;
}
.fc-pick__nome { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.fc-pick__grip { color: var(--fc-muted); opacity: .6; font-size: 1rem; }
/* Lista de destino inteira realca quando o campo esta sobre area vazia. */
.fc-picklist.is-dropzone {
  border-color: var(--bs-primary);
  background: color-mix(in srgb, var(--bs-primary) 8%, var(--fc-surface-2));
}
.fc-pick-vazio { margin: 0; padding: 1.2rem .4rem; text-align: center; font-size: .8rem; color: var(--fc-muted); }
.fc-picker-arrows { display: flex; gap: .4rem; margin-top: .5rem; }
.fc-picker-arrows .btn { flex: 1 1 0; }

.fc-status { font-size: .75rem; border-radius: 999px; padding: .28rem .55rem; font-weight: 600; }
.fc-status-pago { color: #0c6658; background: #d8f4ed; }
.fc-status-a_compensar, .fc-status-parcial { color: #775500; background: #fff0bd; }
.fc-status-vencido { color: #9c2924; background: #ffe1df; }
.fc-status-a_vencer { color: #315b87; background: #deedfc; }

@media (max-width: 1100px) {
  .fc-layout, .fc-layout.is-config { grid-template-columns: 1fr; }
  .fc-layout.is-config .fc-column-builder { order: 0; }
  .fc-summary { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
}
@media (max-width: 700px) {
  .fc-summary, .fc-layout.is-horizontal .fc-summary { grid-template-columns: 1fr; }
  .fc-blocos { grid-template-columns: 1fr; }
}

/* Tema: o projeto alterna por classe no <html> (.dark / .azul), nao por
   preferencia do sistema operacional. Usar prefers-color-scheme aqui deixaria as
   etiquetas claras para quem escolhe o tema escuro manualmente com o SO em claro. */
html.dark .fc-status-pago,
html.azul .fc-status-pago { color: #93e2d3; background: #153f38; }
html.dark .fc-status-a_compensar, html.dark .fc-status-parcial,
html.azul .fc-status-a_compensar, html.azul .fc-status-parcial { color: #ffe08a; background: #493b13; }
html.dark .fc-status-vencido,
html.azul .fc-status-vencido { color: #ffaaa5; background: #4b2321; }
html.dark .fc-status-a_vencer,
html.azul .fc-status-a_vencer { color: #a7d3ff; background: #203a54; }

