/*
 * SOALHE ERP · DOSSIÊ OPERACIONAL CONTÍNUO v4
 * Camada visual tardia, aditiva e sem alteração de contratos funcionais.
 * Objetivo: impedir “cabeçalho premium + conteúdo legado” em qualquer rota.
 */

body.soalhe-system-v4 {
  --portal-canvas: #f1f0eb;
  --portal-paper: rgba(255, 255, 255, .91);
  --portal-paper-strong: #fff;
  --portal-quiet: #f7f4eb;
  --portal-ink: #22231f;
  --portal-muted: #69706b;
  --portal-line: rgba(118, 101, 57, .17);
  --portal-line-strong: rgba(167, 132, 37, .35);
  --portal-gold: #c9a227;
  --portal-gold-deep: #876713;
  --portal-green: #0e7a59;
  color: var(--portal-ink);
  background:
    radial-gradient(circle at 91% 3%, rgba(201, 162, 39, .09), transparent 24rem),
    linear-gradient(rgba(75, 71, 59, .026) 1px, transparent 1px),
    linear-gradient(90deg, rgba(75, 71, 59, .026) 1px, transparent 1px),
    var(--portal-canvas);
  background-size: auto, 28px 28px, 28px 28px, auto;
  font-family: var(--font-body);
  font-size: 13px;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

body.soalhe-system-v4 :where(button, input, select, textarea) {
  font-family: var(--font-body);
}

/*
 * Contrato tipográfico transversal. Os módulos históricos declaravam Inter ou
 * `sans-serif` em centenas de descendentes; herdar apenas no body não vence
 * essas declarações. A camada tardia troca somente a família visual — sem
 * alterar medidas, valores ou semântica — e preserva display/dados abaixo.
 */
body.soalhe-system-v4 :where(#view, #erpSidebar, #erpBusca, .topbar, .statusbar)
  :where(p, span, small, strong, b, em, label, a, button, input, select, textarea, li, dt, dd, table) {
  font-family: var(--font-body) !important;
}

body.soalhe-system-v4 #view
  :where(h1, h2, h3, h4, .tile-title, .card-header, .fh-razao, .modal-header h3, .value, .stat-display) {
  font-family: var(--font-display) !important;
}

body.soalhe-system-v4 #view
  :where(code, pre, kbd, samp, time, th, .eyebrow, .lbl, .ff-k, .cap, .result-count, .op-mini, .op-badge) {
  font-family: var(--font-data) !important;
}

body.soalhe-system-v4 :where(h1, h2, h3, h4, .tile-title, .card-header, .fh-razao, .modal-header h3) {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: var(--letter-display);
  line-height: 1.14;
}

body.soalhe-system-v4 :where(.eyebrow, .lbl, .label, .ff-k, th, .cap, .result-count, .nav-sep, time) {
  letter-spacing: var(--letter-label);
}

body.soalhe-system-v4 :where(time, .value, .stat-display, .money, td[style*="text-align:right"], .cli-mensalidade, .ff-v.big) {
  font-variant-numeric: tabular-nums;
}

body.soalhe-system-v4 ::selection {
  color: #171710;
  background: rgba(227, 195, 75, .48);
}

body.soalhe-system-v4 :where(.content, .page, #view) {
  min-width: 0;
}

body.soalhe-system-v4 .content {
  background: transparent;
}

body.soalhe-system-v4 .page {
  padding: 12px 14px 20px;
}

body.soalhe-system-v4 .page > :first-child {
  margin-top: 0;
}

/* Superfícies: mesma linguagem em cards, módulos, caixas e drawers. */
body.soalhe-system-v4 :where(.card, .tile, .kpi, .ficha-sheet, .modal, dialog, .sf-panel, .contract-module) {
  border-color: var(--portal-line);
  background: var(--surface-paper);
  box-shadow: var(--shadow);
}

body.soalhe-system-v4 :where(.card, .tile, .kpi, .cli-card) {
  background-size: 150% 150%;
  transition:
    border-color .26s var(--motion-natural),
    box-shadow .26s var(--motion-natural),
    background-position .34s var(--motion-natural);
}

body.soalhe-system-v4 :where(.card, .tile, .kpi, .cli-card):hover {
  transform: none;
  border-color: var(--portal-line-strong);
  background-position: 100% 100%;
  box-shadow: 0 1px 1px rgba(255, 255, 255, .86) inset, 0 14px 32px rgba(48, 43, 31, .09);
}

body.soalhe-system-v4 :where(.card-header, .tile-head, .modal-header) {
  min-height: 42px;
}

body.soalhe-system-v4 .card-header {
  padding: 10px 14px 10px 18px;
  border-bottom: 1px solid var(--portal-line);
  color: var(--portal-ink);
  background: linear-gradient(115deg, rgba(246, 240, 220, .92), rgba(255, 255, 255, .72));
  font-size: 13px;
}

body.soalhe-system-v4 .card-body {
  padding: 13px 14px;
}

body.soalhe-system-v4 :where(.empty, .doc-empty, .contract-empty-inline, .atd-empty, .cc-empty) {
  min-height: 0;
  padding: 18px 14px;
  border-radius: 12px;
  color: #7a7d77;
  background: linear-gradient(135deg, rgba(247, 244, 235, .82), rgba(255, 255, 255, .76));
}

/* Botões: resposta visual sem alterar largura/altura do card pai. */
body.soalhe-system-v4 :where(.btn, .btn-outline, .btn-danger, .btn-icon, .subtab, button) {
  transition:
    color .22s var(--motion-natural),
    background-color .22s var(--motion-natural),
    border-color .22s var(--motion-natural),
    box-shadow .22s var(--motion-natural),
    filter .22s var(--motion-natural),
    transform .12s var(--motion-natural);
}

body.soalhe-system-v4 :where(.btn, .btn-outline, .btn-danger) {
  min-height: 36px;
  border-radius: 11px;
  font-size: 12px;
  font-weight: 700;
}

body.soalhe-system-v4 .btn {
  border: 1px solid #b78e18;
  background: linear-gradient(135deg, #e5c64e 0%, #c89e22 62%, #e4ca69 100%);
  box-shadow: 0 6px 14px rgba(137, 99, 10, .12), inset 0 1px rgba(255, 255, 255, .42);
}

body.soalhe-system-v4 .btn:hover {
  color: #181711;
  filter: saturate(1.06) brightness(1.025);
  box-shadow: 0 9px 20px rgba(137, 99, 10, .18), inset 0 1px rgba(255, 255, 255, .52);
}

body.soalhe-system-v4 .btn-outline {
  border: 1px solid rgba(161, 126, 32, .55);
  color: #735811;
  background: rgba(255, 255, 255, .82);
  box-shadow: inset 0 1px rgba(255, 255, 255, .84);
}

body.soalhe-system-v4 .btn-outline:hover {
  border-color: #b58c1d;
  background: linear-gradient(135deg, #fffdf7, #f3e4ad);
  box-shadow: 0 7px 16px rgba(115, 86, 17, .1);
}

body.soalhe-system-v4 :where(.btn, .btn-outline, .btn-danger, .btn-icon):active {
  transform: translateY(1px);
}

body.soalhe-system-v4 :where(button, a, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid #b58d1f;
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(201, 162, 39, .14);
}

body.soalhe-system-v4 :where(button, a) svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  stroke-width: 1.8;
}

body.soalhe-system-v4 .premium-auto-icon {
  display: inline-grid;
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  place-items: center;
  color: currentColor;
  vertical-align: middle;
}

body.soalhe-system-v4 .premium-auto-icon svg {
  width: 15px;
  height: 15px;
}

/* Campos e agrupadores. */
body.soalhe-system-v4 :where(input:not([type="checkbox"]):not([type="radio"]), select, textarea) {
  min-height: 38px;
  padding: 8px 11px;
  border: 1px solid #d8d5cc;
  border-radius: 11px;
  color: #272923;
  background: rgba(255, 255, 255, .9);
  box-shadow: inset 0 1px 2px rgba(51, 46, 34, .035);
  font-size: 12.5px;
}

body.soalhe-system-v4 textarea {
  min-height: 88px;
}

body.soalhe-system-v4 :where(input:not([type="checkbox"]):not([type="radio"]), select, textarea):hover {
  border-color: #c8bea3;
}

body.soalhe-system-v4 :where(input:not([type="checkbox"]):not([type="radio"]), select, textarea):focus {
  border-color: #b88e19;
  background: #fff;
  box-shadow: 0 0 0 4px rgba(201, 162, 39, .12), inset 0 1px 2px rgba(51, 46, 34, .03);
}

body.soalhe-system-v4 :where(label, .lbl, .field > label) {
  color: #73766f;
  font-size: 10.5px;
  font-weight: 700;
}

body.soalhe-system-v4 .field {
  margin-bottom: 10px;
}

body.soalhe-system-v4 :where(.grid2, .grid3) {
  gap: 10px;
}

/* Subabas: régua única, compacta e previsível em todas as rotas. */
body.soalhe-system-v4 .subtabs {
  gap: 3px;
  margin-bottom: 10px;
  padding: 4px;
  overflow-x: auto;
  overflow-y: hidden;
  border: 1px solid var(--portal-line);
  border-radius: 14px;
  background: rgba(248, 246, 240, .82);
  box-shadow: inset 0 1px rgba(255, 255, 255, .84);
  scrollbar-width: thin;
}

body.soalhe-system-v4 .subtab {
  min-height: 34px;
  margin: 0;
  padding: 7px 11px;
  border: 1px solid transparent;
  border-radius: 10px;
  color: #666b66;
  background: transparent;
  font-size: 11.5px;
  font-weight: 650;
  white-space: nowrap;
}

body.soalhe-system-v4 .subtab:hover {
  border-color: rgba(184, 142, 25, .25);
  color: #5f4a14;
  background: rgba(255, 250, 235, .86);
}

body.soalhe-system-v4 .subtab.active {
  border-color: rgba(180, 137, 24, .46);
  color: #29251b;
  background: linear-gradient(145deg, #fff9e7, #ecd37e);
  box-shadow: 0 6px 14px rgba(129, 94, 12, .1), inset 0 1px rgba(255, 255, 255, .55);
}

/* Filtros: deck compacto, sem fileira vazia e sem botões perdidos. */
body.soalhe-system-v4 .portal-filter-deck {
  display: grid;
  grid-template-columns: minmax(220px, 1.4fr) repeat(3, minmax(145px, .7fr)) auto;
  align-items: end;
  gap: 7px;
  margin: 0 0 8px;
  padding: 8px;
  border: 1px solid var(--portal-line);
  border-radius: 15px;
  background: rgba(255, 255, 255, .73);
  box-shadow: 0 8px 20px rgba(48, 43, 31, .05), inset 0 1px rgba(255, 255, 255, .92);
  backdrop-filter: blur(14px);
}

body.soalhe-system-v4 .portal-filter-deck > :where(input, select, div) {
  min-width: 0;
}

body.soalhe-system-v4 .client-filter-deck {
  grid-template-columns: minmax(220px, 1.15fr) repeat(3, minmax(145px, .62fr));
}

/* O rótulo de grupos WhatsApp precisa caber no desktop sem mudar os breakpoints existentes. */
body.soalhe-system-v4 .client-filter-deck .erp-search-filter-wrap:has(#fWhatsAppGrupo) { min-width: 190px; }
body.soalhe-system-v4 .client-filter-deck .erp-search-filter-wrap:has(#fWhatsAppGrupo) .erp-search-filter { min-width: 190px; }

body.soalhe-system-v4 .op-pipeline-cards {
  display: flex;
  gap: 8px;
  margin: 12px 0;
  flex-wrap: wrap;
}

body.soalhe-system-v4 .op-pipeline-card {
  border: 1px solid var(--gold-light);
  border-radius: 9px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  min-width: 110px;
  padding: 7px 10px;
  text-align: left;
}

body.soalhe-system-v4 .op-pipeline-card span { display: block; font-size: 11px; color: #756f61; }
body.soalhe-system-v4 .op-pipeline-card b { font-size: 18px; }
body.soalhe-system-v4 .op-pipeline-card.active { border-color: var(--gold); box-shadow: 0 0 0 2px #c9a22722; }

body.soalhe-system-v4 .client-filter-deck .spacer {
  display: none;
}

body.soalhe-system-v4 .client-filter-deck .sort-btns,
body.soalhe-system-v4 .client-filter-deck .view-toggle {
  display: flex;
  min-width: 0;
  gap: 5px;
  overflow-x: auto;
  padding-top: 1px;
  scrollbar-width: thin;
}

body.soalhe-system-v4 .client-filter-deck .sort-btns {
  grid-column: 1 / -2;
}

body.soalhe-system-v4 .client-filter-deck .view-toggle {
  grid-column: -2 / -1;
  justify-self: end;
  margin-top: 0;
  overflow: visible;
}

body.soalhe-system-v4 :where(.sort-btns, .view-toggle) button {
  min-height: 31px;
  padding: 5px 9px;
  border: 1px solid #d7d3ca;
  border-radius: 9px;
  color: #5f655f;
  background: rgba(255, 255, 255, .8);
  font-size: 10.5px;
  font-weight: 700;
  white-space: nowrap;
}

body.soalhe-system-v4 :where(.sort-btns, .view-toggle) button.ativo {
  border-color: #bd941e;
  color: #29251a;
  background: linear-gradient(145deg, #efd66f, #c99e22);
}

body.soalhe-system-v4 .opportunity-filter-deck {
  grid-template-columns: minmax(260px, 1.4fr) minmax(150px, .55fr) minmax(190px, .65fr) auto;
}

body.soalhe-system-v4 .portal-result-count {
  display: flex;
  align-items: center;
  min-height: 28px;
  margin: 0 0 5px;
  padding: 4px 8px;
  color: #6d716b;
  font: 650 10.5px/1.2 var(--font-data);
  text-transform: uppercase;
}

/* Ledger de dados: cabeçalhos editoriais, linhas densas e leitura horizontal segura. */
body.soalhe-system-v4 :where(.tbl-scroll, .table-scroll, .portal-ledger-scroll, .sf-federal-table-wrap) {
  scrollbar-color: #c7b36f #eeeae0;
  scrollbar-width: thin;
}

body.soalhe-system-v4 .portal-ledger-scroll {
  max-width: 100%;
  overflow: auto;
  border-radius: inherit;
}

body.soalhe-system-v4 :where(table:not(.fisc), .cli-tbl, .op-tbl, .ficha-table, .cmp-table) {
  border-collapse: separate;
  border-spacing: 0;
  color: #343832;
  font-size: 12px;
}

body.soalhe-system-v4 :where(table:not(.fisc), .cli-tbl, .op-tbl, .ficha-table, .cmp-table) thead th {
  padding: 9px 10px;
  border: 0;
  border-bottom: 1px solid rgba(150, 124, 48, .22);
  color: #765c16;
  background: linear-gradient(180deg, #fffaf0, #f6efdb);
  font: 700 10.5px/1.2 var(--font-data);
  letter-spacing: .065em;
  text-transform: uppercase;
}

body.soalhe-system-v4 :where(table:not(.fisc), .cli-tbl, .op-tbl, .ficha-table, .cmp-table) tbody td {
  height: 42px;
  padding: 7px 10px;
  border: 0;
  border-bottom: 1px solid rgba(92, 88, 76, .095);
  background: rgba(255, 255, 255, .57);
  vertical-align: middle;
}

body.soalhe-system-v4 :where(table:not(.fisc), .cli-tbl, .op-tbl, .ficha-table, .cmp-table) tbody tr:last-child td {
  border-bottom: 0;
}

body.soalhe-system-v4 :where(table:not(.fisc), .cli-tbl, .op-tbl, .ficha-table, .cmp-table) tbody tr:hover td {
  background: linear-gradient(90deg, rgba(255, 249, 228, .92), rgba(249, 247, 240, .92));
  box-shadow: inset 0 1px rgba(201, 162, 39, .12), inset 0 -1px rgba(201, 162, 39, .12);
}

body.soalhe-system-v4 .portal-ledger-card {
  overflow: hidden;
  border-radius: 16px;
}

/* Clientes · carteira e ficha completa. */
body.soalhe-system-v4[data-erp-route="clientes"] .cli-mgmt-kpis {
  gap: 6px;
  margin-bottom: 8px;
}

body.soalhe-system-v4[data-erp-route="clientes"] .cli-mgmt-kpis .kpi {
  min-height: 62px;
  padding: 8px 10px;
  border: 1px solid var(--portal-line);
  border-left: 3px solid var(--portal-gold);
  border-radius: 13px;
}

body.soalhe-system-v4[data-erp-route="clientes"] .cli-mgmt-kpis .kpi .value {
  font-family: var(--font-display);
  font-size: 20px;
  letter-spacing: -.04em;
}

body.soalhe-system-v4[data-erp-route="clientes"] #lista > .card {
  overflow: hidden;
  border: 1px solid var(--portal-line);
  border-radius: 16px;
}

body.soalhe-system-v4[data-erp-route="clientes"] .cli-tbl--overview {
  width: 100%;
  min-width: 0;
  table-layout: fixed;
  font-size: 13px;
}

.cli-tbl--overview .cli-col-code { width: 5%; }
.cli-tbl--overview .cli-col-client { width: 28%; }
.cli-tbl--overview .cli-col-value { width: 13%; }
.cli-tbl--overview .cli-col-links { width: 17%; }
.cli-tbl--overview .cli-col-dates { width: 16%; }
.cli-tbl--overview .cli-col-status { width: 13%; }
.cli-tbl--overview .cli-col-actions { width: 8%; }

body.soalhe-system-v4[data-erp-route="clientes"] .cli-tbl--overview :is(th, td) {
  height: auto;
  padding: 10px 8px;
  font-size: 13px;
  line-height: 1.4;
  white-space: normal;
  overflow-wrap: anywhere;
}

body.soalhe-system-v4[data-erp-route="clientes"] .cli-tbl--overview th {
  letter-spacing: .02em;
}

.cli-tbl--overview .cli-client-name { font-weight: 600; }
.cli-tbl--overview .cli-client-document { margin-top: 5px; color: var(--portal-muted); }
.cli-tbl--overview .cli-cell-stack { display: flex; flex-direction: column; align-items: flex-start; gap: 5px; }
.cli-tbl--overview .cli-status-tags { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; }
.cli-tbl--overview .cli-date-stack { display: grid; gap: 3px; font-variant-numeric: tabular-nums; }
.cli-tbl--overview .cli-date-stack > div { display: flex; flex-wrap: wrap; justify-content: space-between; column-gap: 5px; }
.cli-tbl--overview .cli-data-label { color: var(--portal-muted); }
.cli-tbl--overview .cli-date-alert { color: #dc2626; font-weight: 600; }

body.soalhe-system-v4[data-erp-route="clientes"] .cli-tbl--overview :is(.badge, .cli-mensalidade-excecao, .cli-sem-mensalidade, .btn-xs) {
  max-width: 100%;
  font-size: 13px;
  line-height: 1.4;
  white-space: normal;
  overflow: visible;
  overflow-wrap: anywhere;
  text-overflow: clip;
}

.cli-tbl--overview .badge { padding: 3px 6px; }
.cli-tbl--overview .cli-mensalidade { text-align: left; }
.cli-tbl--overview .cli-row-actions { display: flex; flex-wrap: wrap; gap: 5px; }
.cli-tbl--overview .cli-row-actions .btn-xs { flex: 1 1 28px; margin: 0; min-width: 28px; padding: 4px; }
.cli-tbl--overview .cli-row-actions .cli-open-client { flex-basis: 100%; }

body.soalhe-system-v4[data-erp-route="clientes"] .cli-tbl tbody tr {
  cursor: pointer;
}

body.soalhe-system-v4[data-erp-route="clientes"] .row-acts {
  opacity: .7;
  transition: opacity .2s var(--motion-natural);
}

body.soalhe-system-v4[data-erp-route="clientes"] tr:hover .row-acts,
body.soalhe-system-v4[data-erp-route="clientes"] tr:focus-within .row-acts {
  opacity: 1;
}

body.soalhe-system-v4[data-erp-route="clientes"] .cad-head {
  position: sticky;
  top: 53px;
  z-index: 18;
  backdrop-filter: blur(14px);
}

body.soalhe-system-v4[data-erp-route="clientes"] .ficha-sheet {
  overflow: visible;
  border: 0;
  background: transparent;
  box-shadow: none;
}

body.soalhe-system-v4[data-erp-route="clientes"] .ficha-head {
  min-height: 96px;
  padding: 14px 17px;
  border: 1px solid rgba(191, 151, 39, .34);
  border-bottom: 2px solid #c8a128;
  border-radius: 18px 18px 0 0;
  background:
    radial-gradient(circle at 86% -15%, rgba(228, 197, 88, .22), transparent 34%),
    linear-gradient(132deg, #272720, #191b18 62%, #20241f);
  box-shadow: 0 12px 28px rgba(36, 34, 26, .13);
}

body.soalhe-system-v4[data-erp-route="clientes"] .ficha-logo {
  width: 52px;
  height: 52px;
}

body.soalhe-system-v4[data-erp-route="clientes"] .fh-razao {
  font-size: clamp(18px, 2vw, 26px);
}

body.soalhe-system-v4[data-erp-route="clientes"] .ficha-actions {
  gap: 6px;
  padding: 8px 10px;
  border: 1px solid var(--portal-line);
  border-top: 0;
  background: rgba(255, 255, 255, .77);
  backdrop-filter: blur(12px);
}

body.soalhe-system-v4[data-erp-route="clientes"] .ficha-actions :where(.btn, .btn-outline) {
  min-height: 32px;
  padding: 5px 9px;
  font-size: 10.5px;
}

body.soalhe-system-v4[data-erp-route="clientes"] .ficha-body {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 8px;
  padding: 8px 0 0;
}

body.soalhe-system-v4[data-erp-route="clientes"] .ficha-section {
  grid-column: span 4;
  min-width: 0;
  padding: 13px 14px;
  border: 1px solid var(--portal-line);
  border-radius: 15px;
  background: var(--surface-paper);
  box-shadow: var(--shadow);
}

body.soalhe-system-v4[data-erp-route="clientes"] .ficha-section:nth-child(1) {
  grid-column: 1 / -1;
}

body.soalhe-system-v4[data-erp-route="clientes"] .ficha-section:nth-child(5) {
  grid-column: span 7;
}

body.soalhe-system-v4[data-erp-route="clientes"] .ficha-section:nth-child(6) {
  grid-column: span 5;
}

body.soalhe-system-v4[data-erp-route="clientes"] .ficha-section-title {
  margin-bottom: 10px;
  color: #705714;
  font: 700 10.5px/1.2 var(--font-data);
  letter-spacing: .075em;
}

body.soalhe-system-v4[data-erp-route="clientes"] .ficha-section-title::before {
  width: 4px;
  height: 18px;
  border-radius: 99px;
  background: linear-gradient(180deg, #e6c851, #a77c12);
}

body.soalhe-system-v4[data-erp-route="clientes"] .ficha-fields {
  grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
  gap: 10px 14px;
}

body.soalhe-system-v4[data-erp-route="clientes"] .ficha-field {
  min-height: 43px;
  padding: 7px 8px;
  border-left: 2px solid rgba(201, 162, 39, .2);
  border-radius: 0 8px 8px 0;
  background: linear-gradient(90deg, rgba(246, 241, 225, .68), transparent);
}

body.soalhe-system-v4[data-erp-route="clientes"] .ficha-field .ff-k {
  font-family: var(--font-data);
  font-size: 10.5px;
  letter-spacing: .07em;
}

body.soalhe-system-v4[data-erp-route="clientes"] .ficha-field .ff-v {
  font-size: 12.5px;
  line-height: 1.3;
}

body.soalhe-system-v4[data-erp-route="clientes"] .ficha-foot {
  margin-top: 8px;
  padding: 8px 12px;
  border: 1px solid var(--portal-line);
  border-radius: 12px;
  background: rgba(255, 255, 255, .68);
  font-family: var(--font-data);
  font-size: 10px;
}

/* Prévia contratual legível: mantém a estrutura A4, elimina o “documento em miniatura”. */
body.soalhe-system-v4[data-erp-route="clientes"] .contract-paper-head :where(strong, em),
body.soalhe-system-v4[data-erp-route="clientes"] .contract-paper-summary span,
body.soalhe-system-v4[data-erp-route="clientes"] .contract-paper-clauses span {
  font-size: 10px;
}

body.soalhe-system-v4[data-erp-route="clientes"] .contract-paper-summary :where(strong, small),
body.soalhe-system-v4[data-erp-route="clientes"] .contract-paper-clauses p {
  font-size: 10.5px;
}

body.soalhe-system-v4[data-erp-route="clientes"] .contract-paper-intro,
body.soalhe-system-v4[data-erp-route="clientes"] .contract-paper-clauses strong {
  font-size: 11px;
}

body.soalhe-system-v4[data-erp-route="clientes"] .contract-paper-clauses p,
body.soalhe-system-v4[data-erp-route="clientes"] .contract-paper-intro {
  line-height: 1.55;
}

/* Oportunidades · filtros e pipeline passam a pertencer ao mesmo sistema do topo. */
body.soalhe-system-v4[data-erp-route="oportunidades"] .op-pipe {
  min-width: 1360px;
}

body.soalhe-system-v4[data-erp-route="oportunidades"] .op-pipe td {
  height: 46px;
}

body.soalhe-system-v4[data-erp-route="oportunidades"] .op-pipe-tit b {
  font-family: var(--font-display);
  font-size: 12.5px;
  letter-spacing: -.02em;
}

body.soalhe-system-v4[data-erp-route="oportunidades"] .op-sub {
  color: #737974;
  font-size: 10.5px;
}

body.soalhe-system-v4[data-erp-route="oportunidades"] .op-mini,
body.soalhe-system-v4[data-erp-route="oportunidades"] .op-badge {
  padding: 2px 7px;
  border-radius: 7px;
  font-family: var(--font-data);
  font-size: 10px;
  letter-spacing: .02em;
}

body.soalhe-system-v4[data-erp-route="oportunidades"] .op-grid2 > .card {
  max-height: 330px;
}

body.soalhe-system-v4[data-erp-route="oportunidades"] .op-funrow,
body.soalhe-system-v4[data-erp-route="oportunidades"] .op-dimension-row {
  transform: none;
}

body.soalhe-system-v4[data-erp-route="oportunidades"] .op-funrow:hover,
body.soalhe-system-v4[data-erp-route="oportunidades"] .op-dimension-row:hover {
  transform: none;
  box-shadow: inset 3px 0 #c8a128;
}

/* Modal e overlays: hierarquia idêntica às páginas, sem bloco escuro desproporcional. */
body.soalhe-system-v4 .modal-bg {
  z-index: 90;
  background: rgba(27, 29, 26, .52);
  backdrop-filter: blur(8px) saturate(.85);
}

/* O assistente flutuante preserva o contexto, mas nunca disputa ações com um diálogo. */
body.soalhe-system-v4:has(> .modal-bg) #crisRoot {
  display: none !important;
}

body.soalhe-system-v4 .modal {
  display: flex;
  overflow: hidden;
  flex-direction: column;
  border: 1px solid rgba(211, 187, 112, .4);
  border-radius: 20px;
  background: rgba(255, 255, 255, .96);
  box-shadow: 0 28px 74px rgba(23, 25, 22, .24), inset 0 1px rgba(255, 255, 255, .9);
}

body.soalhe-system-v4 .modal-header {
  padding: 12px 16px;
  border-bottom: 1px solid rgba(229, 199, 89, .45);
  background:
    radial-gradient(circle at 88% 0, rgba(224, 190, 72, .18), transparent 38%),
    linear-gradient(120deg, #282922, #181a17);
}

body.soalhe-system-v4 .modal-body {
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 14px 16px;
}

body.soalhe-system-v4 .modal-footer {
  position: sticky;
  bottom: 0;
  z-index: 2;
  padding: 9px 14px;
  border-top: 1px solid var(--portal-line);
  background: rgba(249, 247, 241, .92);
  backdrop-filter: blur(12px);
}

/* Gestão de Mensalidades: prévia contida; URLs longas nunca vazam do diálogo. */
body.soalhe-system-v4 .mens-wa-dialog,
body.soalhe-system-v4 .mens-wa-dialog .field {
  min-width: 0;
}

body.soalhe-system-v4 .mens-wa-help {
  margin: 0 0 10px;
  overflow-wrap: anywhere;
  font-size: 13px;
  line-height: 1.5;
}

body.soalhe-system-v4 .mens-wa-preview textarea {
  width: 100%;
  max-width: 100%;
  min-height: 180px;
  resize: vertical;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  font: 500 13px/1.5 var(--font-body);
}

/* Unificação de módulos independentes: tipografia e superfícies sem apagar sua semântica. */
body.soalhe-system-v4 :where(.cora-root, .atd-shell, .cc-root, .sf-root, .contract-module, .tarefas-root, .agents-page, .fin-shell) {
  font-family: var(--font-body);
  color: var(--portal-ink);
}

body.soalhe-system-v4 :where(.cora-root, .atd-shell, .cc-root, .sf-root, .contract-module, .tarefas-root, .agents-page, .fin-shell)
  :where(h1, h2, h3, h4) {
  font-family: var(--font-display);
  letter-spacing: var(--letter-display);
}

body.soalhe-system-v4 :where(.cora-root, .atd-shell, .cc-root, .sf-root, .contract-module, .tarefas-root, .agents-page, .fin-shell)
  :where(article, section, .card) {
  border-radius: min(18px, var(--radius-lg));
}

/* Financeiro › Conciliação: uma única dobra operacional, sem os vazios
   acumulados pelas três réguas, pelo root Cora e pelo cabeçalho em coluna. */
body.soalhe-system-v4[data-erp-route="financeiro"] .fin-bank-context-row {
  margin: 0 0 5px;
}

body.soalhe-system-v4[data-erp-route="financeiro"] .fin-bank-context-row > .subtabs,
body.soalhe-system-v4[data-erp-route="financeiro"] .fin-bank-subtabs {
  margin-bottom: 0;
}

body.soalhe-system-v4[data-erp-route="financeiro"] .fin-bank-subtabs {
  margin-top: 0;
}

body.soalhe-system-v4[data-erp-route="financeiro"] #itau-sub-view > .cora-root.fin-conc-active {
  width: 100%;
  max-width: 100%;
  margin: 0;
  padding: 5px 0 12px;
}

body.soalhe-system-v4[data-erp-route="financeiro"] .cora-root.fin-conc-active {
  gap: 8px;
}

body.soalhe-system-v4[data-erp-route="financeiro"] .cora-root .fin-conc-stack {
  gap: 8px;
}

body.soalhe-system-v4[data-erp-route="financeiro"] .cora-root .fin-conc-period {
  display: flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

body.soalhe-system-v4[data-erp-route="financeiro"] .cora-root .fin-conc-card {
  gap: 10px;
  padding: 14px 0 12px;
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(49, 44, 32, .07);
}

body.soalhe-system-v4[data-erp-route="financeiro"] .cora-root .fin-conc-head {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) auto;
  align-items: center;
  gap: 8px 16px;
  padding: 0 16px;
}

body.soalhe-system-v4[data-erp-route="financeiro"] .cora-root .fin-conc-actions {
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
}

body.soalhe-system-v4[data-erp-route="financeiro"] .cora-root .fin-conc-content {
  padding: 0 16px;
}

/* Filtros e pesquisa ocupam a mesma régua. A busca cresce até o contador,
   eliminando a faixa branca criada pelo antigo limite fixo de 34rem. */
body.soalhe-system-v4[data-erp-route="financeiro"] .cora-root .fin-conc-controls {
  display: flex;
  align-items: flex-end;
  gap: 7px;
  margin: 0 0 7px;
  flex-wrap: wrap;
}

body.soalhe-system-v4[data-erp-route="financeiro"] .cora-root .fin-conc-search {
  position: relative;
  min-width: 260px;
  flex: 1 1 320px;
}

body.soalhe-system-v4[data-erp-route="financeiro"] .cora-root .fin-conc-count {
  align-self: center;
  margin-left: auto;
  white-space: nowrap;
}

body.soalhe-system-v4[data-erp-route="financeiro"] .cora-root.fin-conc-active :where(.cr-card-desc, .cr-input, table.cr-tbl) {
  font-size: 14px;
}

body.soalhe-system-v4[data-erp-route="financeiro"] .cora-root.fin-conc-active :where(.cr-xs, .cr-10, .cr-11, .cr-label, .cr-kpi-label) {
  font-size: 13px;
}

body.soalhe-system-v4[data-erp-route="financeiro"] .cora-root.fin-conc-active :where(
  .cc-status,
  .ic-status,
  [style*="font-size:.78rem"],
  [style*="font-size:.8rem"]
) {
  font-size: 13px !important;
}

body.soalhe-system-v4[data-erp-route="financeiro"] .cora-root.fin-conc-active .cr-btn--h6 {
  min-height: 32px;
  height: 32px;
  padding-inline: 10px;
  font-size: 13px;
}

body.soalhe-system-v4[data-erp-route="financeiro"] .cora-root.fin-conc-active .erp-search-filter {
  min-height: 34px;
  font-size: 13px;
}

body.soalhe-system-v4[data-erp-route="financeiro"] .cora-root.fin-conc-active .mn-notif.cr-btn--h6 {
  min-height: 32px;
  height: 32px;
  font-size: 13px !important;
  line-height: 1.2;
}

body.soalhe-system-v4[data-erp-route="financeiro"] .cora-root.fin-conc-active .cr-tbl-wrap {
  overflow: hidden;
  border-color: rgba(112, 107, 93, .2);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 7px 20px rgba(49, 44, 32, .055);
}

body.soalhe-system-v4[data-erp-route="financeiro"] .cora-root.fin-conc-active table.cr-tbl--conc th {
  height: 38px;
  padding: 0 8px;
  font-size: 13px;
  letter-spacing: .025em;
  color: #595548;
  background: linear-gradient(180deg, #fbf7e8 0%, #f5eed6 100%);
}

body.soalhe-system-v4[data-erp-route="financeiro"] .cora-root.fin-conc-active table.cr-tbl--conc td {
  height: 44px;
  padding: 7px 8px;
  line-height: 1.28;
}

body.soalhe-system-v4[data-erp-route="financeiro"] .cora-root.fin-conc-active table.cr-tbl--conc tbody tr {
  border-color: rgba(112, 107, 93, .14);
}

body.soalhe-system-v4[data-erp-route="financeiro"] .cora-root.fin-conc-active table.cr-tbl--conc tbody tr:not(.cr-subtotal):hover {
  background: #fcfaf3;
}

body.soalhe-system-v4[data-erp-route="financeiro"] .cora-root.fin-conc-active :where(.cr-badge, .cc-tipo) {
  min-height: 24px;
  padding: 3px 7px;
  border-radius: 8px;
  font-size: 13px;
}

/* No Financeiro, o CRIS ocupa um slot próprio na faixa global de atalhos.
   O botão segue disponível e abre o mesmo painel, mas não mascara valores,
   tags ou ações da conciliação em desktop, zoom ou mobile. */
body.soalhe-system-v4[data-erp-route="financeiro"].has-busca #erpBusca {
  padding-right: 76px !important;
}

body.soalhe-system-v4[data-erp-route="financeiro"].has-busca #crisFab {
  top: 32px !important;
  right: 12px !important;
  bottom: auto !important;
  left: auto !important;
  z-index: 99971 !important;
  width: 52px !important;
  height: 36px !important;
  border-width: 1px !important;
  border-radius: 9px !important;
  font-size: 11px !important;
  box-shadow: 0 3px 12px rgba(0, 0, 0, .28) !important;
}

body.soalhe-system-v4[data-erp-route="financeiro"].has-busca #crisFab:focus-visible {
  outline: 3px solid rgba(201, 168, 76, .32);
  outline-offset: 2px;
}

body.soalhe-system-v4 .fin-reconcile-dialog {
  width: min(1180px, calc(100vw - 32px));
  max-width: min(1180px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  gap: 12px;
  padding: 18px;
  border: 1px solid rgba(184, 142, 25, .38);
  border-radius: 18px;
  background: #fbfaf7;
  box-shadow: 0 26px 80px rgba(23, 22, 18, .28);
}

body.soalhe-system-v4 .fin-reconcile-dialog .cr-dialog-title {
  font-size: 21px;
  line-height: 1.2;
}

body.soalhe-system-v4 .fin-reconcile-dialog .cr-dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

body.soalhe-system-v4 .fin-reconcile-dialog .cr-dialog-x {
  display: inline-grid;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  place-items: center;
  border: 1px solid rgba(112, 107, 93, .24);
  border-radius: 11px;
  color: #4c4b45;
  background: #fff;
  cursor: pointer;
}

body.soalhe-system-v4 .fin-reconcile-dialog .cr-dialog-x:hover,
body.soalhe-system-v4 .fin-reconcile-dialog .cr-dialog-x:focus-visible {
  border-color: #b88e19;
  color: #6f5614;
  outline: 3px solid rgba(201, 162, 39, .18);
}

body.soalhe-system-v4 .fin-reconcile-dialog :where(.cr-dialog-desc, .cr-input, .cr-btn, label, .cr-11, .cr-12) {
  font-size: 14px;
}

body.soalhe-system-v4 .fin-reconcile-dialog .cr-balance-options small {
  font-size: 13px;
  line-height: 1.35;
}

body.soalhe-system-v4 .fin-reconcile-dialog .cr-input,
body.soalhe-system-v4 .fin-reconcile-dialog .cr-btn {
  min-height: 38px;
}

body.soalhe-system-v4 .fin-reconcile-dialog .cp-opt {
  min-height: 56px;
  padding: 9px 11px !important;
  border-radius: 12px !important;
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}

body.soalhe-system-v4 .fin-reconcile-dialog .cp-opt:hover,
body.soalhe-system-v4 .fin-reconcile-dialog .cp-opt:focus-within {
  border-color: rgba(184, 142, 25, .72) !important;
  box-shadow: 0 7px 18px rgba(104, 81, 20, .09);
  transform: translateY(-1px);
}

body.soalhe-system-v4 .fin-reconcile-dialog .cp-opt [style*="font-size"] {
  font-size: 13px !important;
}

/* A ilha de conciliação ainda trazia microtextos inline do layout anterior.
   O escopo do modal impede impacto em qualquer outra tela e garante o piso
   operacional combinado sem reescrever o conteúdo financeiro. */
body.soalhe-system-v4 .fin-reconcile-dialog :where(
  [style*="font-size:.6rem"],
  [style*="font-size:.66rem"],
  [style*="font-size:.7rem"],
  [style*="font-size:.72rem"],
  [style*="font-size:.76rem"],
  [style*="font-size:10px"],
  [style*="font-size:11px"],
  [style*="font-size:12px"]
) {
  font-size: 13px !important;
}

@media (max-width: 1100px) {
  body.soalhe-system-v4[data-erp-route="financeiro"] .cora-root .fin-conc-head {
    grid-template-columns: 1fr;
  }

  body.soalhe-system-v4[data-erp-route="financeiro"] .cora-root .fin-conc-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 700px) {
  body.soalhe-system-v4[data-erp-route="financeiro"] .cora-root .fin-conc-period {
    justify-content: flex-start;
  }

  body.soalhe-system-v4[data-erp-route="financeiro"] .cora-root .fin-conc-head,
  body.soalhe-system-v4[data-erp-route="financeiro"] .cora-root .fin-conc-content {
    padding-inline: 12px;
  }

  body.soalhe-system-v4[data-erp-route="financeiro"] .cora-root .fin-conc-search {
    min-width: 100%;
  }

  body.soalhe-system-v4[data-erp-route="financeiro"] .cora-root .fin-conc-count {
    width: 100%;
    margin-left: 0;
  }

  body.soalhe-system-v4 .fin-reconcile-dialog {
    width: calc(100vw - 16px);
    max-width: calc(100vw - 16px);
    max-height: calc(100dvh - 16px);
    margin: 8px;
    padding: 13px;
  }

  body.soalhe-system-v4 .fin-reconcile-dialog .cr-balance-options {
    grid-template-columns: 1fr !important;
  }
}

/* Agentes e Terminais: altura nasce do conteúdo; nunca completa o viewport com vazio. */
body.soalhe-system-v4[data-erp-route="agentes"] .agent-os {
  min-height: 0;
  align-self: start;
}

body.soalhe-system-v4[data-erp-route="agentes"] :where(.terminal-catalog, .terminal-list) {
  align-content: start;
}

/* Situação Fiscal em notebooks: seis KPIs permanecem em uma linha, sem cortar valores. */
@media (min-width: 1221px) and (max-width: 1600px) {
  body.soalhe-system-v4 .sf-kpis--federal .sf-kpi {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
    padding: 10px 11px;
  }

  body.soalhe-system-v4 .sf-kpis--federal .sf-kpi-icon {
    width: 30px;
    height: 30px;
    border-radius: 9px;
  }

  body.soalhe-system-v4 .sf-kpis--federal .sf-kpi-copy {
    width: 100%;
  }

  body.soalhe-system-v4 .sf-kpis--federal .sf-kpi-copy strong {
    overflow: hidden;
    font-size: clamp(14px, 1.16vw, 18px);
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

/* Scrollbars discretas e consistentes. */
body.soalhe-system-v4 *::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}

body.soalhe-system-v4 *::-webkit-scrollbar-track {
  background: rgba(235, 231, 220, .76);
}

body.soalhe-system-v4 *::-webkit-scrollbar-thumb {
  border: 1px solid rgba(255, 255, 255, .72);
  border-radius: 999px;
  background: linear-gradient(180deg, #cfbd82, #a98d3f);
}

@media (max-width: 1280px) {
  body.soalhe-system-v4 .client-filter-deck {
    grid-template-columns: repeat(2, minmax(190px, 1fr));
  }

  body.soalhe-system-v4 .client-filter-deck .view-toggle {
    grid-column: auto;
  }

  body.soalhe-system-v4[data-erp-route="clientes"] .ficha-section {
    grid-column: span 6;
  }

  body.soalhe-system-v4[data-erp-route="clientes"] .ficha-section:nth-child(1),
  body.soalhe-system-v4[data-erp-route="clientes"] .ficha-section:nth-child(5),
  body.soalhe-system-v4[data-erp-route="clientes"] .ficha-section:nth-child(6) {
    grid-column: 1 / -1;
  }
}

@media (max-width: 900px) {
  body.soalhe-system-v4 .page {
    padding: 8px;
  }

  body.soalhe-system-v4 .portal-filter-deck,
  body.soalhe-system-v4 .client-filter-deck,
  body.soalhe-system-v4 .opportunity-filter-deck {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  body.soalhe-system-v4 .portal-filter-deck > :first-child {
    grid-column: 1 / -1;
  }

  body.soalhe-system-v4 .client-filter-deck .sort-btns,
  body.soalhe-system-v4 .client-filter-deck .view-toggle {
    grid-column: 1 / -1;
    justify-self: stretch;
    margin-top: 0;
  }

  body.soalhe-system-v4[data-erp-route="clientes"] .ficha-body {
    grid-template-columns: 1fr;
  }

  body.soalhe-system-v4[data-erp-route="clientes"] .ficha-section,
  body.soalhe-system-v4[data-erp-route="clientes"] .ficha-section:nth-child(n) {
    grid-column: 1;
  }
}

@media (max-width: 560px) {
  body.soalhe-system-v4 .modal-bg {
    align-items: flex-end;
    padding: 10px;
    padding-top: max(10px, env(safe-area-inset-top));
  }

  body.soalhe-system-v4.has-statusbar .modal-bg {
    padding-top: 44px;
  }

  body.soalhe-system-v4.has-busca .modal-bg {
    padding-top: 84px;
  }

  body.soalhe-system-v4 .modal,
  body.soalhe-system-v4.has-statusbar .modal,
  body.soalhe-system-v4.has-busca .modal {
    width: 100% !important;
    max-width: none !important;
    max-height: calc(100dvh - 20px);
    border-radius: 18px;
  }

  body.soalhe-system-v4.has-statusbar .modal {
    max-height: calc(100dvh - 54px);
  }

  body.soalhe-system-v4.has-busca .modal {
    max-height: calc(100dvh - 94px);
  }

  body.soalhe-system-v4 .modal-header,
  body.soalhe-system-v4 .modal-body {
    padding-inline: 13px;
  }

  body.soalhe-system-v4 .portal-filter-deck,
  body.soalhe-system-v4 .client-filter-deck,
  body.soalhe-system-v4 .opportunity-filter-deck {
    grid-template-columns: 1fr;
  }

  body.soalhe-system-v4 .portal-filter-deck > *,
  body.soalhe-system-v4 .client-filter-deck > *,
  body.soalhe-system-v4 .opportunity-filter-deck > * {
    grid-column: 1 / -1;
  }

  body.soalhe-system-v4[data-erp-route="clientes"] .ficha-head {
    gap: 10px;
    padding: 12px;
  }

  body.soalhe-system-v4[data-erp-route="clientes"] .ficha-head-meta {
    flex-wrap: wrap;
    justify-content: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  body.soalhe-system-v4 *,
  body.soalhe-system-v4 *::before,
  body.soalhe-system-v4 *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

@media print {
  body.soalhe-system-v4[data-erp-route="clientes"] .ficha-body {
    display: block;
    padding: 8px 20px 18px;
  }

  body.soalhe-system-v4[data-erp-route="clientes"] .ficha-section {
    margin: 0;
    padding: 13px 0;
    border: 0;
    border-bottom: 1px dashed #ddd;
    border-radius: 0;
    box-shadow: none;
  }
}
