/* =========================================================
   QUALILEITE — FINANCEIRO MODULAR V5
   ========================================================= */

.finance-page {
  min-width: 0;
  padding-bottom: 36px;
}

.finance-page-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.finance-filter-toggle {
  width: auto !important;
  flex: 0 0 auto;
  display: inline-flex !important;
  align-items: center;
  gap: 8px;
}

.finance-filter-toggle[aria-expanded="false"] #toggleFiltersIcon {
  transform: rotate(-90deg);
}

.finance-tabs {
  width: fit-content;
  padding: 5px;
  border: 1px solid #d6e4f1;
  border-radius: 14px;
  background: #fff;
  display: inline-flex;
  gap: 4px;
  box-shadow: 0 8px 22px rgba(17,65,108,.06);
}

.finance-tab {
  min-height: 42px;
  padding: 0 18px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #637b92;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-weight: 850;
  cursor: pointer;
}

.finance-tab span {
  min-width: 24px;
  height: 24px;
  padding: 0 7px;
  border-radius: 999px;
  background: rgba(15,103,182,.10);
  display: inline-grid;
  place-items: center;
  font-size: .68rem;
}

.finance-tab.active {
  background: linear-gradient(135deg,#176ec3,#2a94e2);
  color: #fff;
}

.finance-tab.active span {
  background: rgba(255,255,255,.18);
}

.finance-filters-panel {
  display: grid;
  grid-template-rows: 1fr;
  opacity: 1;
  transition: .2s ease;
}

.finance-filters-panel.collapsed {
  grid-template-rows: 0fr;
  opacity: 0;
  margin-bottom: -14px;
  pointer-events: none;
}

.finance-filters-panel.collapsed > section:not([hidden]) {
  min-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  border-width: 0;
  overflow: hidden;
}

.finance-toolbar {
  width: 100%;
  min-width: 0;
  display: flex !important;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px;
  overflow: visible !important;
}

.finance-toolbar > * {
  min-width: 160px;
  flex: 1 1 170px;
}

.finance-toolbar .search-box {
  min-width: 230px;
  flex-basis: 280px;
}

.finance-toolbar .date-filter {
  min-width: 155px;
  flex: .8 1 165px;
}

.finance-toolbar .btn {
  width: auto !important;
  min-width: 145px;
  flex: 0 0 auto;
}

.date-filter label {
  display: block;
  margin: 0 0 6px 3px;
  color: #4d6682;
  font-size: .68rem;
  font-weight: 850;
  text-transform: uppercase;
}

.finance-summary-grid {
  margin-bottom: 24px;
  display: grid;
  grid-template-columns: repeat(4,minmax(0,1fr));
  gap: 16px;
}

.finance-summary-card {
  min-width: 0;
  min-height: 112px;
  padding: 18px;
  border: 1px solid #d4e3f1;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 10px 28px rgba(19,66,108,.07);
}

.finance-summary-card span,
.finance-summary-card small {
  display: block;
}

.finance-summary-card span {
  color: #698198;
  font-size: .72rem;
  font-weight: 850;
  text-transform: uppercase;
}

.finance-summary-card strong {
  display: block;
  margin-top: 10px;
  color: #0a3769;
  font-size: 1.35rem;
}

.finance-summary-card small {
  margin-top: 7px;
  color: #8595a6;
  font-size: .7rem;
}

.selection-action-bar {
  min-height: 78px;
  margin-bottom: 22px;
  padding: 13px 16px;
  border: 1px solid #bcdcf5;
  border-radius: 16px;
  background: linear-gradient(135deg,#f5fbff,#e9f5ff);
  display: flex;
  align-items: center;
  gap: 16px;
}

.selection-description {
  min-width: 0;
  flex: 1;
}

.selection-description strong,
.selection-description span,
.selection-total strong,
.selection-total span {
  display: block;
}

.selection-description span,
.selection-total span {
  margin-top: 4px;
  color: #70859b;
  font-size: .72rem;
}

.selection-total {
  min-width: 150px;
  text-align: right;
}

.finance-table-card {
  min-width: 0;
  min-height: 430px;
  overflow: hidden;
  display: grid;
  grid-template-rows: minmax(0,1fr) auto;
}

.finance-table-scroll {
  width: 100%;
  min-width: 0;
  min-height: 0;
  overflow: auto;
  position: relative;
}

.finance-table {
  width: 100%;
  min-width: 1450px;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
}

.billings-table {
  min-width: 1540px;
}

.finance-table thead th {
  position: sticky;
  top: 0;
  z-index: 4;
  background: #eaf4fd;
  box-shadow: inset 0 -1px #cddfed;
}

.finance-table th,
.finance-table td {
  padding: 13px 15px;
  vertical-align: middle;
}

.finance-table tbody tr {
  height: 70px;
}

.col-check {
  width: 55px;
}

.finance-farm strong,
.finance-farm small,
.sample-cell strong,
.sample-cell small {
  display: block;
}

.finance-farm small,
.sample-cell small {
  margin-top: 4px;
  color: #75899e;
}

.finance-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  max-width: 100%;
  padding: 5px 9px;
  border-radius: 999px;
  font-size: .68rem;
  font-weight: 850;
  white-space: nowrap;
}

.finance-status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.finance-status.success {
  background: #e6f8ec;
  color: #1b7f46;
}

.finance-status.success::before {
  background: #20a85d;
}

.finance-status.warning {
  background: #fff5d9;
  color: #9a6810;
}

.finance-status.warning::before {
  background: #e2a413;
}

.finance-status.danger {
  background: #fff0ef;
  color: #bd3832;
}

.finance-status.danger::before {
  background: #dc4238;
}

.finance-status.info {
  background: #e9f4ff;
  color: #1169b6;
}

.finance-status.info::before {
  background: #1882d8;
}

.action-group {
  display: flex;
  gap: 7px;
}

.finance-action-button {
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 10px;
  background: #e8f4ff;
  color: #0869c0;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.finance-action-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.finance-modal-card {
  width: calc(100vw - 34px);
  max-width: 1460px;
  height: calc(100dvh - 28px);
  max-height: calc(100dvh - 28px);
  display: grid;
  grid-template-rows: auto minmax(0,1fr);
}

.finance-modal-card > form {
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0,1fr) auto;
}

.finance-modal-card .modal-body {
  min-height: 0;
  overflow: auto;
  padding: 18px 22px;
}

.payment-modal-card {
  width: min(720px,calc(100vw - 26px));
}

.finance-modal-section {
  margin-bottom: 18px;
  padding: 17px;
  border: 1px solid #d7e6f3;
  border-radius: 16px;
  background: #fff;
}

.section-heading {
  margin-bottom: 14px;
}

.section-heading h3 {
  margin: 0;
  color: #0a3463;
}

.section-heading p {
  margin: 4px 0 0;
  color: #768a9e;
  font-size: .75rem;
}

.row-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.service-details-grid {
  display: grid;
  grid-template-columns: repeat(4,minmax(160px,1fr));
  gap: 10px;
}

.detail-box {
  min-height: 72px;
  padding: 12px;
  border: 1px solid #dce8f2;
  border-radius: 12px;
  background: #f7fbff;
}

.detail-box span,
.detail-box strong {
  display: block;
}

.detail-box span {
  color: #71869b;
  font-size: .66rem;
  font-weight: 850;
  text-transform: uppercase;
}

.detail-box strong {
  margin-top: 7px;
  color: #143e69;
  overflow-wrap: anywhere;
}

.service-values-grid,
.billing-total-grid {
  display: grid;
  grid-template-columns:
    repeat(3,minmax(120px,.72fr))
    repeat(3,minmax(160px,1fr))
    minmax(190px,1.15fr);
  gap: 11px;
  align-items: end;
}

.billing-total-grid {
  grid-template-columns:
    minmax(150px,.8fr)
    repeat(3,minmax(170px,1fr))
    minmax(210px,1.15fr);
}

.metric-finance-box,
.total-value-box {
  min-height: 78px;
  padding: 13px;
  border-radius: 13px;
}

.metric-finance-box {
  border: 1px solid #d5e4f2;
  background: #f5faff;
}

.metric-finance-box.discarded {
  background: #fff7ed;
  border-color: #f2dfc4;
}

.metric-finance-box.billable {
  background: #ecf9f1;
  border-color: #cbead8;
}

.metric-finance-box span,
.metric-finance-box strong,
.total-value-box span,
.total-value-box strong {
  display: block;
}

.metric-finance-box span,
.total-value-box span {
  font-size: .66rem;
  font-weight: 850;
  text-transform: uppercase;
}

.metric-finance-box strong {
  margin-top: 8px;
  color: #0c3f70;
  font-size: 1.3rem;
}

.total-value-box {
  background: linear-gradient(145deg,#0758ab,#1596d9);
  color: #fff;
}

.total-value-box strong {
  margin-top: 8px;
  font-size: 1.3rem;
}

.money-input {
  position: relative;
}

.money-input > span {
  position: absolute;
  top: 50%;
  left: 13px;
  z-index: 1;
  transform: translateY(-50%);
  color: #58738e;
  font-size: .78rem;
  font-weight: 800;
}

.money-input .control {
  padding-left: 39px;
}

.finance-form-grid {
  display: grid;
  grid-template-columns: repeat(4,minmax(170px,1fr));
  gap: 11px;
}

.finance-form-grid .span-all {
  grid-column: 1 / -1;
}

.billing-items-preview {
  max-width: 100%;
  overflow: auto;
  border: 1px solid #d7e5f1;
  border-radius: 13px;
}

.billing-items-table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
}

.billing-items-table th,
.billing-items-table td {
  padding: 11px 13px;
  border-bottom: 1px solid #e0e9f1;
  text-align: left;
  font-size: .76rem;
}

.billing-items-table th {
  background: #edf6fe;
  color: #28567f;
  font-size: .66rem;
  text-transform: uppercase;
}

.billing-footer .btn-danger {
  margin-right: auto;
}

.btn-danger {
  min-height: 42px;
  padding: 0 17px;
  border: 1px solid #efc2bf;
  border-radius: 11px;
  background: #fff0ef;
  color: #bd352f;
  font-weight: 850;
  cursor: pointer;
}

.report-grid {
  display: grid;
  grid-template-columns: repeat(2,minmax(0,1fr));
  gap: 18px;
}

.report-card {
  min-width: 0;
  padding: 18px;
  border: 1px solid #d5e4f1;
  border-radius: 16px;
  background: #fff;
}

.report-card h2 {
  margin: 0 0 16px;
  color: #0a3769;
  font-size: 1rem;
}

.report-card.span-two {
  grid-column: 1 / -1;
}

.report-list {
  display: grid;
  gap: 10px;
}

.report-list-item {
  padding: 11px 12px;
  border: 1px solid #e0eaf3;
  border-radius: 11px;
  background: #f8fbfe;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.report-list-item strong,
.report-list-item span {
  display: block;
}

.report-list-item small {
  color: #778ba0;
}

.report-table {
  width: 100%;
  min-width: 720px;
}

@media (max-width: 1100px) {
  .finance-summary-grid {
    grid-template-columns: repeat(2,minmax(0,1fr));
  }

  .service-details-grid,
  .service-values-grid,
  .billing-total-grid,
  .finance-form-grid {
    grid-template-columns: repeat(2,minmax(0,1fr));
  }

  .total-value-box {
    grid-column: span 2;
  }
}

@media (max-width: 700px) {
  .finance-page-heading {
    flex-direction: column;
  }

  .finance-tabs {
    width: 100%;
  }

  .finance-tab {
    flex: 1;
    justify-content: center;
    padding: 0 9px;
  }

  .finance-summary-grid,
  .report-grid,
  .service-details-grid,
  .service-values-grid,
  .billing-total-grid,
  .finance-form-grid {
    grid-template-columns: 1fr;
  }

  .report-card.span-two,
  .finance-form-grid .span-all,
  .total-value-box {
    grid-column: auto;
  }

  .selection-action-bar {
    align-items: stretch;
    flex-direction: column;
  }

  .selection-total {
    text-align: left;
  }

  .finance-toolbar > * {
    flex-basis: 100%;
    min-width: 100%;
  }

  .row-heading {
    align-items: stretch;
    flex-direction: column;
  }
}


/* =========================================================
   CORREÇÃO V5.3 — ESPAÇAMENTO DAS ABAS, FILTROS E CARDS
   ========================================================= */

/*
  O atributo hidden precisa prevalecer sobre o
  display:flex da classe finance-toolbar.
*/
.finance-toolbar[hidden],
#servicesFilters[hidden],
#billingsFilters[hidden],
#reportsFilters[hidden] {
  display: none !important;
}

/* =========================================================
   FILTROS VISÍVEIS
   ========================================================= */

.finance-filters-panel:not(.collapsed) {
  display: block !important;

  /* Espaço entre as abas e os filtros */
  margin-top: 18px !important;

  /* Espaço entre os filtros e os cards */
  margin-bottom: 24px !important;

  padding: 0 !important;
}

/* =========================================================
   FILTROS RECOLHIDOS
   ========================================================= */

.finance-filters-panel.collapsed {
  display: none !important;
  min-height: 0 !important;
  height: 0 !important;

  margin: 0 !important;
  padding: 0 !important;

  border: 0 !important;
  overflow: hidden !important;
  pointer-events: none !important;
}

/* Remove qualquer altura herdada dos filtros */
.finance-filters-panel.collapsed .toolbar-card,
.finance-filters-panel.collapsed .finance-toolbar {
  display: none !important;

  min-height: 0 !important;
  height: 0 !important;

  margin: 0 !important;
  padding: 0 !important;

  border: 0 !important;
  overflow: hidden !important;
}

/* =========================================================
   ESPAÇO ABAIXO DAS ABAS QUANDO OS FILTROS ESTÃO OCULTOS
   ========================================================= */

/*
  Aqui usamos ~ em vez de +.

  O sinal ~ encontra qualquer irmão posterior, não apenas
  o elemento imediatamente seguinte.
*/
.finance-filters-panel.collapsed ~ #servicesView:not([hidden]),
.finance-filters-panel.collapsed ~ #billingsView:not([hidden]),
.finance-filters-panel.collapsed ~ #reportsView:not([hidden]) {
  margin-top: 24px !important;
}

/* =========================================================
   ABAS
   ========================================================= */

.finance-tabs {
  margin-top: 0 !important;
  margin-bottom: 0 !important;
}

/* Evita margem antiga nos painéis */
#servicesView,
#billingsView,
#reportsView {
  margin-bottom: 0;
}

/* =========================================================
   FINANCEIRO V5.4 — MODO COMPACTO
   Mais espaço para a tabela
   ========================================================= */

/* ---------------------------------------------------------
   TÍTULO DA PÁGINA
   --------------------------------------------------------- */

.finance-page-heading {
  margin-bottom: 12px !important;
}

.finance-page-heading h1 {
  margin-bottom: 4px !important;
  font-size: 1.65rem !important;
}

.finance-page-heading p {
  margin: 0 !important;
  font-size: .82rem !important;
}

/* ---------------------------------------------------------
   ABAS
   --------------------------------------------------------- */

.finance-tabs {
  min-height: 44px !important;
  padding: 4px !important;
}

.finance-tab {
  min-height: 36px !important;
  padding: 0 15px !important;
}

/* Quando os filtros estão ocultos, aproxima os cards */
.finance-filters-panel.collapsed ~ #servicesView:not([hidden]),
.finance-filters-panel.collapsed ~ #billingsView:not([hidden]),
.finance-filters-panel.collapsed ~ #reportsView:not([hidden]) {
  margin-top: 14px !important;
}

/* ---------------------------------------------------------
   CARDS DE RESUMO MAIS COMPACTOS
   --------------------------------------------------------- */

.finance-summary-grid {
  gap: 12px !important;
  margin-bottom: 14px !important;
}

.finance-summary-card {
  min-height: 82px !important;
  padding: 13px 16px !important;
  border-radius: 14px !important;
}

.finance-summary-card span {
  font-size: .64rem !important;
}

.finance-summary-card strong {
  margin-top: 6px !important;
  font-size: 1.18rem !important;
  line-height: 1.1 !important;
}

.finance-summary-card small {
  margin-top: 5px !important;
  font-size: .65rem !important;
  line-height: 1.2 !important;
}

/* ---------------------------------------------------------
   BARRA DE SELEÇÃO
   --------------------------------------------------------- */

/*
  Corrige o mesmo problema que ocorreu nos filtros:
  display:flex não pode anular o atributo hidden.
*/
.selection-action-bar[hidden] {
  display: none !important;
}

.selection-action-bar {
  min-height: 58px !important;
  margin-bottom: 14px !important;
  padding: 9px 14px !important;
  border-radius: 13px !important;
}

.selection-description strong {
  font-size: .82rem !important;
}

.selection-description span,
.selection-total span {
  margin-top: 2px !important;
  font-size: .65rem !important;
}

.selection-total strong {
  font-size: .9rem !important;
}

.selection-action-bar .btn {
  min-height: 38px !important;
  padding: 0 15px !important;
}

/* ---------------------------------------------------------
   TABELA OCUPANDO O ESPAÇO RESTANTE
   --------------------------------------------------------- */

.finance-table-card {
  /*
    A tabela cresce conforme a altura disponível.
    O valor mínimo evita que fique pequena em notebooks.
  */
  min-height: clamp(
    390px,
    calc(100dvh - 445px),
    680px
  ) !important;
}

.finance-table thead tr {
  height: 48px !important;
}

.finance-table thead th {
  padding-top: 10px !important;
  padding-bottom: 10px !important;
}

.finance-table tbody tr {
  height: 61px !important;
}

.finance-table td {
  padding-top: 10px !important;
  padding-bottom: 10px !important;
}

.finance-table-card .table-footer {
  min-height: 40px !important;
  padding-top: 8px !important;
  padding-bottom: 8px !important;
}

/* ---------------------------------------------------------
   QUANDO OS FILTROS ESTIVEREM VISÍVEIS
   --------------------------------------------------------- */

.finance-filters-panel:not(.collapsed) {
  margin-top: 14px !important;
  margin-bottom: 16px !important;
}

.finance-toolbar {
  padding-top: 12px !important;
  padding-bottom: 12px !important;
}

/* ---------------------------------------------------------
   TELAS MENORES
   --------------------------------------------------------- */

@media (max-width: 1100px) {
  .finance-summary-card {
    min-height: 78px !important;
  }

  .finance-table-card {
    min-height: clamp(
      360px,
      calc(100dvh - 480px),
      650px
    ) !important;
  }
}

/* =========================================================
   FINANCEIRO V6 — VISUALIZAÇÃO, ALTURA E MOBILIDADE
   ========================================================= */

/*
  Cadeia completa de altura. Sem isso, a tabela cresce para fora
  da tela e o rodapé desaparece abaixo do viewport.
*/
body[data-page="finance"] {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

body[data-page="finance"] .app-shell {
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
}

body[data-page="finance"] .main.users-main {
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

body[data-page="finance"] .finance-page {
  height: calc(100vh - 76px);
  height: calc(100dvh - 76px);
  min-width: 0;
  min-height: 0;
  padding-bottom: 14px;

  display: flex;
  flex-direction: column;

  overflow: hidden;
}

/* Elementos superiores nunca consomem a área rolável da tabela. */
body[data-page="finance"] .finance-page-heading,
body[data-page="finance"] .finance-tabs,
body[data-page="finance"] .finance-filters-panel {
  flex: 0 0 auto;
}

/* O painel ativo recebe exatamente o espaço restante. */
body[data-page="finance"] .finance-view {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
}

body[data-page="finance"] .finance-view[hidden] {
  display: none !important;
}

/* Serviços e faturamentos: cards fixos + tabela flexível. */
body[data-page="finance"] .finance-data-view:not([hidden]) {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

body[data-page="finance"] .finance-data-view > .finance-summary-grid,
body[data-page="finance"] .finance-data-view > .selection-action-bar {
  flex: 0 0 auto;
}

/*
  Remove a altura mínima antiga baseada em clamp().
  A tabela passa a usar apenas a altura realmente disponível.
*/
body[data-page="finance"] .finance-data-view > .finance-table-card {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0 !important;
  height: auto !important;

  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;

  overflow: hidden;
}

/* Somente as linhas da tabela rolam. */
body[data-page="finance"] .finance-primary-scroll {
  min-width: 0;
  min-height: 0;
  height: 100%;

  overflow-x: auto !important;
  overflow-y: auto !important;

  overscroll-behavior: contain;
  scrollbar-gutter: stable both-edges;
  -webkit-overflow-scrolling: touch;
}

body[data-page="finance"] .finance-primary-scroll:focus-visible {
  outline: 3px solid rgba(34, 143, 226, .22);
  outline-offset: -3px;
}

/* Cabeçalho permanece visível durante a rolagem vertical. */
body[data-page="finance"] .finance-primary-scroll .finance-table thead th {
  position: sticky;
  top: 0;
  z-index: 5;
}

/* Rodapé com quantidade sempre visível. */
body[data-page="finance"] .finance-table-card > .table-footer {
  position: relative;
  z-index: 6;
  flex: 0 0 auto;
  min-height: 40px;
  background: #fff;
}

/* Relatórios rolam como um painel próprio. */
body[data-page="finance"] .finance-reports-view:not([hidden]) {
  display: block;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  padding-right: 4px;
  padding-bottom: 18px;
}

/* Barras discretas, porém visíveis. */
body[data-page="finance"] .finance-primary-scroll,
body[data-page="finance"] .finance-reports-view {
  scrollbar-width: thin;
  scrollbar-color: #9fc6e8 #edf5fb;
}

body[data-page="finance"] .finance-primary-scroll::-webkit-scrollbar,
body[data-page="finance"] .finance-reports-view::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

body[data-page="finance"] .finance-primary-scroll::-webkit-scrollbar-track,
body[data-page="finance"] .finance-reports-view::-webkit-scrollbar-track {
  background: #edf5fb;
}

body[data-page="finance"] .finance-primary-scroll::-webkit-scrollbar-thumb,
body[data-page="finance"] .finance-reports-view::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: #9fc6e8;
}

body[data-page="finance"] .finance-primary-scroll::-webkit-scrollbar-thumb:hover,
body[data-page="finance"] .finance-reports-view::-webkit-scrollbar-thumb:hover {
  background: #72aeda;
}

/* Abas utilizáveis sem estourar a largura. */
body[data-page="finance"] .finance-tabs {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  white-space: nowrap;
}

body[data-page="finance"] .finance-tabs::-webkit-scrollbar {
  display: none;
}

body[data-page="finance"] .finance-tab {
  flex: 0 0 auto;
}

/* Filtros: quebram de linha sem sair do cartão. */
body[data-page="finance"] .finance-toolbar {
  max-width: 100%;
  min-width: 0;
}

body[data-page="finance"] .finance-toolbar > * {
  max-width: 100%;
}

/* Evita que textos grandes alarguem colunas ou botões. */
body[data-page="finance"] .finance-table td,
body[data-page="finance"] .finance-table th {
  overflow-wrap: anywhere;
}

body[data-page="finance"] .finance-farm,
body[data-page="finance"] .sample-cell,
body[data-page="finance"] .action-group {
  min-width: 0;
}

/* =========================================================
   ALTURAS MENORES — ENTREGA MAIS ESPAÇO À TABELA
   ========================================================= */
@media (max-height: 820px) {
  body[data-page="finance"] .finance-page {
    padding-top: 12px;
    padding-bottom: 10px;
  }

  body[data-page="finance"] .finance-page-heading {
    margin-bottom: 8px !important;
  }

  body[data-page="finance"] .finance-page-heading h1 {
    font-size: 1.45rem !important;
  }

  body[data-page="finance"] .finance-page-heading p {
    font-size: .75rem !important;
  }

  body[data-page="finance"] .finance-tabs {
    min-height: 40px !important;
  }

  body[data-page="finance"] .finance-tab {
    min-height: 32px !important;
  }

  body[data-page="finance"] .finance-summary-grid {
    gap: 10px !important;
    margin-bottom: 10px !important;
  }

  body[data-page="finance"] .finance-summary-card {
    min-height: 72px !important;
    padding: 10px 14px !important;
  }

  body[data-page="finance"] .finance-summary-card strong {
    margin-top: 4px !important;
    font-size: 1.05rem !important;
  }

  body[data-page="finance"] .selection-action-bar {
    min-height: 50px !important;
    margin-bottom: 10px !important;
    padding: 7px 12px !important;
  }

  body[data-page="finance"] .finance-table tbody tr {
    height: 56px !important;
  }

  body[data-page="finance"] .finance-table th,
  body[data-page="finance"] .finance-table td {
    padding-top: 8px !important;
    padding-bottom: 8px !important;
  }
}

/* =========================================================
   LARGURAS INTERMEDIÁRIAS
   ========================================================= */
@media (max-width: 1100px) {
  body[data-page="finance"] .finance-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  body[data-page="finance"] .finance-toolbar > * {
    min-width: 145px;
    flex: 1 1 180px;
  }

  body[data-page="finance"] .finance-toolbar .search-box {
    min-width: min(100%, 260px);
    flex-basis: 320px;
  }
}

/* =========================================================
   CELULAR / JANELA ESTREITA
   ========================================================= */
@media (max-width: 700px) {
  body[data-page="finance"] .finance-page-heading {
    flex-direction: row;
    align-items: flex-start;
  }

  body[data-page="finance"] .finance-filter-toggle {
    min-height: 38px;
    padding: 0 11px;
  }

  body[data-page="finance"] .finance-tabs {
    width: 100%;
  }

  body[data-page="finance"] .finance-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  body[data-page="finance"] .finance-summary-card {
    min-height: 76px !important;
  }

  body[data-page="finance"] .finance-toolbar {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
  }

  body[data-page="finance"] .finance-toolbar > *,
  body[data-page="finance"] .finance-toolbar .search-box,
  body[data-page="finance"] .finance-toolbar .btn {
    width: 100% !important;
    min-width: 0 !important;
  }

  body[data-page="finance"] .finance-toolbar .search-box {
    grid-column: 1 / -1;
  }

  body[data-page="finance"] .selection-action-bar {
    display: grid;
    grid-template-columns: 1fr auto;
  }

  body[data-page="finance"] .selection-description {
    grid-column: 1 / -1;
  }

  body[data-page="finance"] .selection-total {
    min-width: 0;
    text-align: left;
  }

  body[data-page="finance"] .selection-action-bar .btn {
    width: auto;
  }
}

@media (max-width: 520px) {
  body[data-page="finance"] .finance-summary-grid {
    grid-template-columns: 1fr;
  }

  body[data-page="finance"] .finance-toolbar {
    grid-template-columns: 1fr;
  }

  body[data-page="finance"] .finance-toolbar .search-box {
    grid-column: auto;
  }
}

/* =========================================================
   FINANCEIRO — CABEÇALHO DA TABELA CORRIGIDO
   ========================================================= */

/*
  Não reserva uma faixa vazia dos dois lados da tabela.
  A barra vertical utiliza apenas o lado direito quando necessária.
*/
body[data-page="finance"] .finance-primary-scroll {
  scrollbar-gutter: auto !important;
}

/* O azul passa a pertencer à linha inteira do cabeçalho. */
body[data-page="finance"] .finance-table thead,
body[data-page="finance"] .finance-table thead tr {
  background: #eaf4fd !important;
}

body[data-page="finance"] .finance-table thead th {
  background: #eaf4fd !important;
}

/* Identifica claramente a coluna dos checkboxes individuais. */
body[data-page="finance"] .col-select-heading {
  padding-left: 8px !important;
  padding-right: 8px !important;
  color: #28567f;
  font-size: .61rem !important;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
}

/* Evita que a primeira coluna pareça fazer parte de REG. */
body[data-page="finance"] .services-table .col-check,
body[data-page="finance"] .services-table th:first-child,
body[data-page="finance"] .services-table td:first-child {
  width: 64px !important;
  min-width: 64px !important;
  max-width: 64px !important;
  text-align: center;
}

body[data-page="finance"] .services-table td:first-child input[type="checkbox"] {
  display: inline-block;
  margin: 0;
  vertical-align: middle;
}

/* =========================================================
   FINANCEIRO — OCULTAR BARRA SEM BLOQUEAR A ROLAGEM
   ========================================================= */

body[data-page="finance"] .finance-table-scroll {
  overflow-x: auto !important;
  overflow-y: auto !important;

  /* Firefox */
  scrollbar-width: none !important;

  /* Internet Explorer antigo / Edge antigo */
  -ms-overflow-style: none !important;
}

/* Chrome, Edge, Opera e Safari */
body[data-page="finance"]
.finance-table-scroll::-webkit-scrollbar {
  width: 0 !important;
  height: 0 !important;
  display: none !important;
}