/* ==========================================================================
   ZMEDPLUS — Nova Tela Faturamento (Contas, Auditoria, Taxas, Lotes TISS)
   Escopado estritamente em #fcn-raiz. Visual nativo ZmedPlus (.orx / .zm-cad).
   ========================================================================== */

#fcn-raiz {
  display: flex;
  flex-direction: column;
  gap: 11px;
  min-width: 0;
}

#fcn-raiz *, #fcn-raiz *::before, #fcn-raiz *::after { box-sizing: border-box; }

/* 4 KPIs no hero (Total Contas, Selecionadas, Valor Lote, Saldo) */
#fcn-raiz .fcn-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(112px, auto));
  gap: 8px;
}

#fcn-raiz .fcn-hk {
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.26);
  border-radius: 11px;
  padding: 6px 12px;
  text-align: center;
}

#fcn-raiz .fcn-hk span {
  display: block;
  font-size: 0.63rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.88;
  font-weight: 700;
}

#fcn-raiz .fcn-hk b {
  display: block;
  font-size: 1.02rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

#fcn-raiz .fcn-hk.destaque {
  background: rgba(16, 185, 129, 0.28);
  border-color: rgba(167, 243, 208, 0.65);
}

/* Barra de ações */
#fcn-raiz .fcn-actionbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  background: var(--color-surface, #fff);
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 9px 12px;
  box-shadow: 0 2px 10px -4px rgba(15, 42, 68, 0.08);
}

#fcn-raiz .fcn-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 11px;
  border-radius: 9px;
  border: 1px solid #cbd5e1;
  background: #fff;
  color: #1e293b;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.12s, background 0.14s, border-color 0.14s, box-shadow 0.14s, opacity 0.14s;
}

#fcn-raiz .fcn-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 10px -4px rgba(15, 42, 68, 0.22);
}

#fcn-raiz .fcn-btn:disabled {
  opacity: 0.42;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

#fcn-raiz .fcn-btn.prim  { background: #155785; border-color: #155785; color: #fff; }
#fcn-raiz .fcn-btn.prim:hover:not(:disabled) { background: #10456a; }
#fcn-raiz .fcn-btn.teal  { background: #129f82; border-color: #129f82; color: #fff; }
#fcn-raiz .fcn-btn.teal:hover:not(:disabled) { background: #0f8a70; }
#fcn-raiz .fcn-btn.cyan  { background: #147c8a; border-color: #147c8a; color: #fff; }
#fcn-raiz .fcn-btn.cyan:hover:not(:disabled) { background: #106470; }
#fcn-raiz .fcn-btn.lote  { background: #0f766e; border-color: #0f766e; color: #fff; }
#fcn-raiz .fcn-btn.lote:hover:not(:disabled) { background: #115e59; }
#fcn-raiz .fcn-btn.ok    { background: #ecfdf5; border-color: #6ee7b7; color: #047857; }
#fcn-raiz .fcn-btn.ok:hover:not(:disabled) { background: #d1fae5; }
#fcn-raiz .fcn-btn.info  { background: #eff6ff; border-color: #93c5fd; color: #1d4ed8; }
#fcn-raiz .fcn-btn.info:hover:not(:disabled) { background: #dbeafe; }
#fcn-raiz .fcn-btn.warn  { background: #fffbeb; border-color: #fcd34d; color: #b45309; }
#fcn-raiz .fcn-btn.warn:hover:not(:disabled) { background: #fef3c7; }
#fcn-raiz .fcn-btn.perigo { background: #fef2f2; border-color: #fca5a5; color: #b91c1c; }
#fcn-raiz .fcn-btn.perigo:hover:not(:disabled) { background: #fee2e2; }
#fcn-raiz .fcn-btn.sair  { margin-left: auto; background: #f8fafc; color: #475569; }
#fcn-raiz .fcn-btn.sair:hover:not(:disabled) { background: #fee2e2; border-color: #fca5a5; color: #b91c1c; }

#fcn-raiz .fcn-sep { width: 1px; height: 22px; background: #e2e8f0; margin: 0 2px; }

/* Painel de filtros (colapsável) */
#fcn-raiz .fcn-filter-card {
  background: var(--color-surface, #fff);
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  overflow: hidden;
}

#fcn-raiz .fcn-filter-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 14px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  cursor: pointer;
  user-select: none;
}

#fcn-raiz .fcn-filter-head b {
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #155785;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

#fcn-raiz .fcn-filter-body {
  padding: 11px 14px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

#fcn-raiz .fcn-filter-card.collapsed .fcn-filter-body { display: none; }
#fcn-raiz .fcn-filter-card.collapsed .fcn-filter-head { border-bottom: none; }

#fcn-raiz .fcn-fgrid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 8px 10px;
  align-items: end;
}

#fcn-raiz .fcn-f { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
#fcn-raiz .fcn-f label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #64748b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#fcn-raiz .fcn-f input,
#fcn-raiz .fcn-f select {
  height: 32px;
  padding: 0 8px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font: inherit;
  font-size: 0.8rem;
  color: #1e293b;
  background: #fff;
  width: 100%;
}
#fcn-raiz .fcn-f input:focus,
#fcn-raiz .fcn-f select:focus {
  outline: none;
  border-color: #147c8a;
  box-shadow: 0 0 0 3px rgba(20, 124, 138, 0.12);
}

#fcn-raiz .c1  { grid-column: span 1; }
#fcn-raiz .c2  { grid-column: span 2; }
#fcn-raiz .c3  { grid-column: span 3; }
#fcn-raiz .c4  { grid-column: span 4; }
#fcn-raiz .c6  { grid-column: span 6; }
#fcn-raiz .c12 { grid-column: span 12; }

/* Linha "Buscar Por" */
#fcn-raiz .fcn-search-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding-top: 2px;
}

#fcn-raiz .fcn-search-row > span {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  color: #475569;
}

#fcn-raiz .fcn-radio-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  color: #475569;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
}
#fcn-raiz .fcn-radio-chip input { display: none; }
#fcn-raiz .fcn-radio-chip.on { background: #155785; border-color: #155785; color: #fff; }

/* Faixa de chaves de status sobre a grade */
#fcn-raiz .fcn-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
}

#fcn-raiz .fcn-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid #cbd5e1;
  background: #fff;
  color: #475569;
  font-size: 0.74rem;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
  transition: all 0.14s;
}
#fcn-raiz .fcn-chip input { display: none; }
#fcn-raiz .fcn-chip .dot { width: 7px; height: 7px; border-radius: 50%; background: #94a3b8; }
#fcn-raiz .fcn-chip.on { background: #e6f7f5; border-color: #14b8a6; color: #0f687a; }
#fcn-raiz .fcn-chip.on .dot { background: #129f82; }
#fcn-raiz .fcn-chip.selall.on { background: #dbeafe; border-color: #3b82f6; color: #1d4ed8; }
#fcn-raiz .fcn-chip.selall.on .dot { background: #2563eb; }

/* Painéis e tabelas */
#fcn-raiz .fcn-panel {
  background: var(--color-surface, #fff);
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 2px 10px -4px rgba(15, 42, 68, 0.06);
}

#fcn-raiz .fcn-scroll { overflow: auto; max-height: 310px; }
#fcn-raiz .fcn-scroll.det { max-height: 245px; }

#fcn-raiz .fcn-table { width: 100%; border-collapse: collapse; font-size: 0.79rem; }
#fcn-raiz .fcn-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #155785;
  color: #fff;
  text-align: left;
  padding: 7px 9px;
  font-size: 0.69rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}
#fcn-raiz .fcn-table tbody td {
  padding: 7px 9px;
  border-bottom: 1px solid #edf2f7;
  vertical-align: middle;
  white-space: nowrap;
}
#fcn-raiz .fcn-table tbody tr { cursor: pointer; transition: background 0.1s; }
#fcn-raiz .fcn-table tbody tr:hover { background: #f0f9ff; }
#fcn-raiz .fcn-table tbody tr.ativo { background: #e0f2fe !important; box-shadow: inset 4px 0 0 #155785; }
#fcn-raiz .fcn-table tbody tr.marcado { background: #f0fdf4; }
#fcn-raiz .fcn-table tbody tr.inativo { opacity: 0.56; }
#fcn-raiz .fcn-table td.n, #fcn-raiz .fcn-table th.n { text-align: right; font-variant-numeric: tabular-nums; }
#fcn-raiz .fcn-table td.c, #fcn-raiz .fcn-table th.c { text-align: center; }

/* Badges clicáveis e status */
#fcn-raiz .fcn-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.69rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}
#fcn-raiz .fcn-pill.sim     { background: #dcfce7; color: #166534; }
#fcn-raiz .fcn-pill.nao     { background: #f1f5f9; color: #64748b; }
#fcn-raiz .fcn-pill.aberto  { background: #fef3c7; color: #92400e; }
#fcn-raiz .fcn-pill.fechado { background: #dbeafe; color: #1e40af; }
#fcn-raiz .fcn-pill.inativo { background: #fee2e2; color: #991b1b; }
#fcn-raiz .fcn-pill.guia    { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
#fcn-raiz .fcn-pill.copart  { background: #fef3c7; color: #92400e; min-width: 28px; }
#fcn-raiz .fcn-pill.click   { cursor: pointer; }
#fcn-raiz .fcn-pill.click:hover { filter: brightness(0.93); }

/* Abas inferiores (1 Procedimentos | 2 Taxas | 3 Outras Despesas) */
#fcn-raiz .fcn-det-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 12px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
}

#fcn-raiz .fcn-det-tabs { display: flex; gap: 8px; flex-wrap: wrap; }
#fcn-raiz .fcn-dtab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 13px;
  border-radius: 999px;
  border: 1px solid #cbd5e1;
  background: #fff;
  color: #475569;
  font: inherit;
  font-size: 0.79rem;
  font-weight: 700;
  cursor: pointer;
}
#fcn-raiz .fcn-dtab .num {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #e2e8f0;
  color: #334155;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.71rem;
  font-weight: 800;
}
#fcn-raiz .fcn-dtab.active {
  background: #155785;
  border-color: #155785;
  color: #fff;
}
#fcn-raiz .fcn-dtab.active .num { background: #129f82; color: #fff; }

#fcn-raiz .fcn-empty {
  text-align: center;
  padding: 28px 16px;
  color: #64748b;
  font-size: 0.84rem;
}

#fcn-raiz .fm-it-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  margin-top: 8px;
}
#fcn-raiz .fm-it-table th {
  background: #f1f5f9;
  color: #334155;
  text-align: left;
  padding: 8px;
  font-size: 0.71rem;
  font-weight: 800;
  text-transform: uppercase;
  border-bottom: 1.5px solid #cbd5e1;
}
#fcn-raiz .fm-it-table td {
  padding: 7px 6px;
  border-bottom: 1px solid #edf2f7;
  vertical-align: middle;
}
#fcn-raiz .fm-it-table input,
#fcn-raiz .fm-it-table select {
  height: 32px;
  padding: 0 8px;
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  font: inherit;
  font-size: 0.81rem;
  width: 100%;
}
#fcn-raiz .fm-it-table tfoot td {
  padding: 9px 8px;
  background: #f8fafc;
  border-top: 1.5px solid #cbd5e1;
  font-size: 0.84rem;
}

/* Pesquisa na Tabela de Procedimentos dentro do modal Faturar */
#fcn-raiz .fmf-searchbar {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
  padding: 8px 10px;
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  border-radius: 10px;
  flex-wrap: wrap;
}
#fcn-raiz .fmf-busca-wrap {
  position: relative;
  flex: 1;
  min-width: 240px;
}
#fcn-raiz .fmf-busca-wrap > i {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: #64748b;
  font-size: 0.82rem;
  pointer-events: none;
}
#fcn-raiz .fmf-busca-wrap input {
  padding-left: 30px;
  height: 34px;
  width: 100%;
}
#fcn-raiz .fmf-drop {
  display: none;
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.2);
  max-height: 240px;
  overflow-y: auto;
  z-index: 50;
}
#fcn-raiz .fmf-drop-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 11px;
  border-bottom: 1px solid #f1f5f9;
  cursor: pointer;
  font-size: 0.82rem;
}
#fcn-raiz .fmf-drop-item:hover { background: #eff6ff; }
#fcn-raiz .fmf-drop-item b { color: #155785; white-space: nowrap; }
#fcn-raiz .fmf-drop-item .desc { flex: 1; min-width: 0; color: #1e293b; }
#fcn-raiz .fmf-drop-item .desc small { color: #64748b; }
#fcn-raiz .fmf-drop-item .vl { color: #129f82; font-weight: 800; white-space: nowrap; }
#fcn-raiz .fmf-drop-empty { padding: 10px 12px; color: #64748b; font-size: 0.81rem; }

#fcn-raiz .fmf-del-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 7px;
  border: 1px solid #fecaca;
  background: #fef2f2;
  color: #b91c1c;
  cursor: pointer;
  transition: background 0.14s, transform 0.12s;
}
#fcn-raiz .fmf-del-btn:hover { background: #fee2e2; transform: scale(1.05); }

/* Barra de ações secundária (Contas do Lote em Fechamento) e badges financeiros */
#fcn-raiz .fcn-subbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
}

#fcn-raiz .ff-st {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  color: #fff;
}
#fcn-raiz .ff-st.fechado   { background: #dc2626; }
#fcn-raiz .ff-st.xml       { background: #0284c7; }
#fcn-raiz .ff-st.efetivado { background: #155785; }
#fcn-raiz .ff-st.baixado   { background: #129f82; }
#fcn-raiz .ff-st.cancelado { background: #64748b; }

#fcn-raiz .ff-val {
  display: inline-block;
  padding: 0;
  background: transparent;
  border-radius: 0;
  font-size: 0.79rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
#fcn-raiz .ff-val.baixa    { color: #0369a1; }
#fcn-raiz .ff-val.pendente { color: #b45309; }
#fcn-raiz .ff-val.glosa    { color: #dc2626; }
#fcn-raiz .ff-val.acatada  { color: #334155; }
#fcn-raiz .ff-val.recurso  { color: #16a34a; }
#fcn-raiz .ff-val.recrec   { color: #d97706; }

@media (max-width: 1180px) {
  #fcn-raiz .fcn-kpis { grid-template-columns: repeat(2, minmax(110px, 1fr)); }
  #fcn-raiz .fcn-fgrid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  #fcn-raiz .c4 { grid-column: span 3; }
  #fcn-raiz .c3 { grid-column: span 3; }
  #fcn-raiz .c2 { grid-column: span 2; }
}
@media (max-width: 760px) {
  #fcn-raiz .fcn-fgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #fcn-raiz .c1, #fcn-raiz .c2, #fcn-raiz .c3, #fcn-raiz .c4, #fcn-raiz .c6, #fcn-raiz .c12 { grid-column: span 2; }
  #fcn-raiz .fcn-btn.sair { margin-left: 0; }
}
