:root {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: #1f2430;
}

body {
  margin: 0;
  background: #f4f5f7;
}

header {
  background: #16324f;
  color: white;
  padding: 1rem 2rem;
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.header-logo {
  height: 40px;
  width: auto;
  filter: brightness(0) invert(1);
  flex-shrink: 0;
}

header h1 {
  margin: 0;
  font-size: 1.3rem;
}

main {
  max-width: 1100px;
  margin: 1.5rem auto;
  padding: 0 1.5rem 3rem;
}

/* --- Painel --- */
.painel {
  background: white;
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.painel h2 {
  margin: 0;
  font-size: 1.05rem;
}

/* --- Cabeçalho de seção com badges --- */
.secao-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.35rem;
}

.badges {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: 99px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge-empresa  { background: #dbeafe; color: #1e40af; }
.badge-embrapii { background: #dcfce7; color: #166534; }
.badge-sebrae   { background: #fef9c3; color: #854d0e; }

.desc-secao {
  margin: 0 0 0.85rem;
  font-size: 0.82rem;
  color: #6b7280;
}

/* --- Projeto / Salvar --- */
.acoes-projeto {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.acoes-salvar {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.campo-inline {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.9rem;
  font-weight: 500;
}

/* --- Inputs base --- */
input[type="text"],
input[type="number"] {
  border: 1px solid #d0d5dd;
  border-radius: 6px;
  padding: 0.4rem 0.6rem;
  font-size: 0.85rem;
  background: #fff;
  color: #1f2430;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  box-sizing: border-box;
}

input[type="text"]:focus,
input[type="number"]:focus {
  border-color: #16324f;
  box-shadow: 0 0 0 3px rgba(22, 50, 79, 0.12);
}

select {
  border: 1px solid #d0d5dd;
  border-radius: 6px;
  padding: 0.4rem 0.6rem;
  font-size: 0.85rem;
  background: #fff;
  color: #1f2430;
  outline: none;
  cursor: pointer;
  transition: border-color 0.15s;
  box-sizing: border-box;
  width: 100%;
}

select:focus {
  border-color: #16324f;
  box-shadow: 0 0 0 3px rgba(22, 50, 79, 0.12);
}

/* --- Input com unidade acoplada --- */
.input-unidade {
  display: flex;
  align-items: stretch;
  border: 1px solid #d0d5dd;
  border-radius: 6px;
  background: white;
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.input-unidade:focus-within {
  border-color: #16324f;
  box-shadow: 0 0 0 3px rgba(22, 50, 79, 0.12);
}

.input-unidade input {
  flex: 1;
  min-width: 0;
  border: none !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  background: transparent;
  padding: 0.4rem 0.55rem;
}

.input-unidade input:focus {
  border: none !important;
  box-shadow: none !important;
}

.unidade {
  display: flex;
  align-items: center;
  padding: 0 0.55rem;
  background: #f0f2f5;
  color: #6b7280;
  font-size: 0.8rem;
  white-space: nowrap;
  user-select: none;
}

.unidade.sufixo  { border-left:  1px solid #d0d5dd; }
.unidade.prefixo { border-right: 1px solid #d0d5dd; }

/* --- Tabela --- */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  margin-top: 0.5rem;
}

th, td {
  border: 1px solid #e1e4e8;
  padding: 0.4rem 0.5rem;
  text-align: left;
}

th {
  background: #f0f2f5;
  font-weight: 600;
  font-size: 0.8rem;
  color: #444b58;
}

td input,
td select {
  width: 100%;
  border: 1px solid #e2e6ea;
  border-radius: 4px;
  padding: 0.3rem 0.45rem;
  background: #fafbfc;
  font-size: 0.85rem;
  outline: none;
  transition: border-color 0.12s, box-shadow 0.12s;
  box-sizing: border-box;
}

td input:focus,
td select:focus {
  border-color: #16324f;
  background: white;
  box-shadow: 0 0 0 2px rgba(22, 50, 79, 0.1);
}

.linha-total td {
  background: #f8fafc;
  font-size: 0.87rem;
}

.td-total {
  background: #f8fafc;
  text-align: right;
  white-space: nowrap;
}

.calc-total {
  font-weight: 500;
  color: #16324f;
  font-size: 0.85rem;
}

/* --- Linha de total abaixo da tabela --- */
.total-linha {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 1rem;
  padding: 0.55rem 0.5rem 0;
  font-size: 0.9rem;
  color: #444b58;
}

.total-linha strong {
  color: #16324f;
  font-size: 1rem;
}

/* --- Subseção (ex: Taxas FUNPEC) --- */
.subsecao {
  margin-top: 1.25rem;
  padding-top: 1.1rem;
  border-top: 1px solid #e1e4e8;
}

.subsecao-titulo {
  margin: 0 0 0.25rem;
  font-size: 0.95rem;
  color: #1f2430;
}

/* --- Ações --- */
.acoes-equipe {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

/* --- Botões --- */
button {
  cursor: pointer;
  border-radius: 6px;
  border: 1px solid #16324f;
  background: white;
  color: #16324f;
  padding: 0.45rem 0.9rem;
  font-size: 0.85rem;
  transition: background 0.12s, color 0.12s;
}

button:hover    { background: #f0f4f8; }

button.primario         { background: #16324f; color: white; }
button.primario:hover   { background: #1d4068; }
button.primario.grande  { padding: 0.6rem 2rem; font-size: 0.95rem; }

button.secundario       { border-color: #8a93a3; color: #444b58; }
button.secundario:hover { background: #f5f6f8; }

button.remover          { border-color: #e9b8b8; color: #c0392b; padding: 0.2rem 0.55rem; font-size: 0.8rem; }
button.remover:hover    { background: #fdf2f2; }

.btn-carregar-arquivo {
  cursor: pointer;
  border-radius: 6px;
  border: 1px solid #8a93a3;
  background: white;
  color: #444b58;
  padding: 0.45rem 0.9rem;
  font-size: 0.85rem;
  display: inline-block;
  transition: background 0.12s;
}

.btn-carregar-arquivo:hover { background: #f5f6f8; }

/* --- Regras avançadas --- */
.grade-regras {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.9rem 1.25rem;
  margin-top: 0.75rem;
  font-size: 0.85rem;
}

.grade-2col {
  grid-template-columns: repeat(2, 1fr);
}

.grade-regras label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  color: #444b58;
  font-weight: 500;
}

summary {
  cursor: pointer;
  font-size: 1.05rem;
  font-weight: 600;
  color: #1f2430;
}

/* --- Cards totais --- */
.cards-totais {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.card {
  border: 1px solid #e1e4e8;
  border-radius: 8px;
  padding: 0.75rem 1rem;
}

.card-empresa  { border-left: 3px solid #3b82f6; }
.card-embrapii { border-left: 3px solid #22c55e; }
.card-sebrae   { border-left: 3px solid #eab308; }

.card .rotulo {
  font-size: 0.72rem;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.card .valor {
  font-size: 1.2rem;
  font-weight: 600;
  margin-top: 0.2rem;
}

.card .percentual {
  font-size: 0.78rem;
  color: #6b7280;
  margin-top: 0.1rem;
}

.card-detalhe {
  margin-top: 0.35rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.75rem;
  color: #6b7280;
}

.badge-pct {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  font-weight: 600;
  font-size: 0.72rem;
  white-space: nowrap;
}

/* --- Restrições avançadas --- */
.restricoes-avancadas {
  margin-top: 1rem;
  padding-top: 0.85rem;
  border-top: 1px solid #e1e4e8;
}

.campo-checkbox {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: #444b58;
  cursor: pointer;
}

.campo-checkbox input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: #16324f;
}

/* --- Resumo financeiro --- */
.resumo-secao-header td {
  background: #f0f2f5;
  font-weight: 700;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #16324f;
  padding: 0.55rem 0.5rem 0.3rem;
  border-top: 2px solid #d0d5dd;
}

.val-resumo {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.resumo-sebrae   td { color: #854d0e; font-size: 0.82rem; padding-left: 1.5rem; }
.resumo-embrapii td { color: #166534; }
.resumo-empresa  td { color: #1e40af; }
.resumo-ict      td { color: #6b7280; font-style: italic; }

.resumo-secao-sub td {
  color: #6b7280;
  font-size: 0.79rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.4rem 0.5rem 0.1rem;
  border-top: 1px solid #e8ecf0;
}

.linha-subtotal td {
  background: #f8fafc;
  font-size: 0.84rem;
  color: #444b58;
}

/* --- Tabela configurável (ex: ressarcimento) --- */
.label-tabela-config {
  font-size: 0.82rem;
  font-weight: 600;
  color: #444b58;
  margin: 0.6rem 0 0.3rem;
}

.tabela-config {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.tabela-config th,
.tabela-config td {
  padding: 0.3rem 0.4rem;
  border: 1px solid #dde1e7;
  vertical-align: middle;
}

.tabela-config th {
  background: #f0f2f5;
  font-weight: 600;
  font-size: 0.78rem;
}

.tabela-config input {
  border: none;
  background: transparent;
  font-size: 0.82rem;
  width: 100%;
  padding: 0.1rem 0;
  outline: none;
}

.tabela-config input:focus {
  outline: none;
  background: #f0f7ff;
}

.btn-sm {
  font-size: 0.78rem;
  padding: 0.25rem 0.6rem;
  border: 1px solid #8a93a3;
  border-radius: 4px;
  background: white;
  color: #444b58;
  cursor: pointer;
}

.btn-sm:hover { background: #f5f6f8; }

.btn-remover-linha {
  border: none;
  background: none;
  color: #c0392b;
  cursor: pointer;
  font-size: 0.75rem;
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
  opacity: 0.7;
}

.btn-remover-linha:hover { opacity: 1; background: #fdf2f2; }

.resumo-informativo td {
  color: #9ca3af;
  font-size: 0.78rem;
  font-style: italic;
  border-top: 1px dashed #d0d5dd;
  padding-top: 0.4rem;
}

.resumo-desembolso-fonte td {
  font-size: 0.88rem;
  padding: 0.35rem 0.5rem;
  border-top: 1px solid currentColor;
  opacity: 0.9;
}

.resumo-desembolso-embrapii {
  background: #f0fdf4;
}
.resumo-desembolso-embrapii td {
  color: #166534;
  border-top-color: #86efac;
}

.resumo-desembolso-sebrae {
  background: #fefce8;
}
.resumo-desembolso-sebrae td {
  color: #854d0e;
  border-top-color: #fde047;
}

.resumo-desembolso-real {
  background: #16324f;
  color: white;
}

.resumo-desembolso-real td {
  color: white;
  font-size: 1rem;
  padding: 0.6rem 0.5rem;
  border-top: 2px solid #0f2030;
}

.resumo-desembolso-real .val-resumo {
  font-size: 1.1rem;
}

/* --- Erro --- */
.erro {
  color: #c0392b;
  font-size: 0.85rem;
  margin-top: 0.5rem;
}

/* --- Tabela cronograma (distribuição por mês) --- */
.tabela-scroll {
  overflow-x: auto;
  margin-top: 0.5rem;
}

.th-funcao {
  min-width: 160px;
  text-align: left;
}

.th-mes {
  min-width: 90px;
  text-align: center;
  white-space: nowrap;
}

.td-funcao-nome {
  white-space: nowrap;
  font-weight: 500;
}

.cel-fonte {
  text-align: center;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
  padding: 0.3rem 0.2rem;
  letter-spacing: 0.02em;
}

.cel-empresa  { background: #dbeafe; color: #1e40af; }
.cel-embrapii { background: #dcfce7; color: #166534; }
.cel-sebrae   { background: #fef9c3; color: #854d0e; }
.cel-fora     { background: #f4f5f7; }

/* Coluna Total (por linha) */
.th-total-row {
  width: 110px;
  text-align: right;
  white-space: nowrap;
}

.td-total-row {
  text-align: right;
  white-space: nowrap;
  font-weight: 600;
  font-size: 0.78rem;
  padding: 0.3rem 0.4rem;
}

/* Borda separadora antes das colunas totalizadoras */
.th-sep,
.td-total-row.th-sep {
  border-left: 2px solid #8a93a3 !important;
}

/* Separador antes do rodapé */
.tr-separador td {
  padding: 2px 0;
  background: #e1e4e8;
  border: none;
}

/* Linhas de rodapé totalizadoras */
.cel-total-mes {
  text-align: right;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
  padding: 0.25rem 0.3rem;
}

.tr-total-fonte .td-label-total {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 0.3rem 0.5rem;
}

.td-total-fonte {
  font-weight: 700;
  border-left: 2px solid #d0d5dd;
}

/* Linha de total geral */
.tr-total-geral td {
  background: #e8edf2;
  border-top: 2px solid #8a93a3;
}

.td-label-total {
  white-space: nowrap;
}

.cel-total-geral {
  background: #e8edf2;
  color: #1f2430;
  font-weight: 700;
}

.td-total-geral-val {
  background: #e8edf2;
  color: #16324f;
  font-weight: 700;
  font-size: 0.85rem;
  border-left: 2px solid #8a93a3;
}

/* --- Legenda de fontes --- */
.legenda-fontes {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.6rem;
  flex-wrap: wrap;
}

.leg-item {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.65rem;
  border-radius: 4px;
  letter-spacing: 0.03em;
}

.leg-empresa  { background: #dbeafe; color: #1e40af; }
.leg-embrapii { background: #dcfce7; color: #166534; }
.leg-sebrae   { background: #fef9c3; color: #854d0e; }
