:root {
  --azul-marinho: #222B40;
  --azul-marinho-claro: #2f3b56;
  --dourado: #C4AE8A;
  --dourado-claro: #e9dfc9;
  --cinza-texto: #333333;
  --cinza-claro: #f9f9f9;
  --branco: #ffffff;
  --borda: #dcdcdc;
  --vermelho: #b23b3b;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "DM Sans", "Segoe UI", system-ui, sans-serif;
  color: var(--cinza-texto);
  background: var(--cinza-claro);
}

a { color: inherit; text-decoration: none; }

/* ---------- Topbar ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--azul-marinho);
  color: var(--branco);
  padding: 0.5rem 1.25rem;
  gap: 1.5rem;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 1.05rem;
  white-space: nowrap;
}

.topbar-logo { height: 34px; width: 34px; object-fit: contain; border-radius: 4px; }

.topbar-nav { display: flex; gap: 1.25rem; flex: 1; }
.topbar-nav a { opacity: 0.85; font-weight: 500; padding: 0.4rem 0; border-bottom: 2px solid transparent; }
.topbar-nav a:hover, .topbar-nav a.ativo { opacity: 1; border-color: var(--dourado); }

.topbar-user { display: flex; align-items: center; gap: 0.75rem; font-size: 0.9rem; }

/* ---------- Botões ---------- */

.botao {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.9rem;
  border-radius: 4px;
  border: 1px solid var(--borda);
  background: var(--branco);
  color: var(--cinza-texto);
  cursor: pointer;
  font-size: 0.88rem;
  font-family: inherit;
}
.botao:hover { border-color: var(--dourado); }
.botao:disabled { opacity: 0.5; cursor: default; }

.botao-primario { background: var(--dourado); border-color: var(--dourado); color: var(--azul-marinho); font-weight: 700; }
.botao-primario:hover { background: var(--dourado-claro); }

.botao-outline { background: transparent; border-color: rgba(255,255,255,0.4); color: var(--branco); }
.botao-outline:hover { border-color: var(--dourado); }

.botao-perigo { color: var(--vermelho); border-color: var(--vermelho); background: var(--branco); }

/* ---------- Layout geral ---------- */

.conteudo { padding: 1.25rem; }

.cartao {
  background: var(--branco);
  border: 1px solid var(--borda);
  border-radius: 6px;
  padding: 1rem 1.25rem;
}

/* ---------- Tela de login ---------- */

.tela-login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--azul-marinho);
}

.caixa-login {
  background: var(--branco);
  border-radius: 8px;
  padding: 2.5rem 2.5rem 2rem;
  width: 340px;
  text-align: center;
  box-shadow: 0 10px 40px rgba(0,0,0,0.25);
}

.caixa-login img { height: 70px; margin-bottom: 1rem; }
.caixa-login h1 { font-size: 1.1rem; color: var(--azul-marinho); margin: 0 0 1.5rem; }

.campo { text-align: left; margin-bottom: 1rem; }
.campo label { display: block; font-size: 0.82rem; margin-bottom: 0.3rem; color: #555; }
.campo input, .campo select, .campo textarea {
  width: 100%;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--borda);
  border-radius: 4px;
  font-family: inherit;
  font-size: 0.9rem;
}
.campo input:focus, .campo select:focus, .campo textarea:focus {
  outline: none;
  border-color: var(--dourado);
}

.erro { color: var(--vermelho); font-size: 0.85rem; margin-bottom: 1rem; }

/* ---------- Lista de cálculos ---------- */

.lista-topo { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.lista-topo h1 { font-size: 1.2rem; color: var(--azul-marinho); }

table.tabela-simples { width: 100%; border-collapse: collapse; background: var(--branco); }
table.tabela-simples th {
  background: var(--azul-marinho);
  color: var(--branco);
  text-align: left;
  padding: 0.6rem 0.8rem;
  font-size: 0.82rem;
  font-weight: 500;
}
table.tabela-simples td {
  padding: 0.55rem 0.8rem;
  border-bottom: 1px solid var(--borda);
  font-size: 0.88rem;
}
table.tabela-simples tr:hover td { background: var(--cinza-claro); }

/* ---------- Tela de cálculo (estilo Exotics) ---------- */

.calculo-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--branco);
  border: 1px solid var(--borda);
  border-radius: 6px;
  padding: 0.6rem 1rem;
  margin-bottom: 0.75rem;
}
.calculo-header h1 { font-size: 1rem; color: var(--azul-marinho); margin: 0; }
.calculo-header .acoes { display: flex; gap: 0.5rem; }

.layout-calculo { display: flex; gap: 0.75rem; align-items: flex-start; }

.painel-lateral {
  width: 300px;
  flex-shrink: 0;
  background: var(--branco);
  border: 1px solid var(--borda);
  border-radius: 6px;
  overflow: hidden;
}

.painel-abas { display: flex; border-bottom: 1px solid var(--borda); }
.painel-abas button {
  flex: 1;
  padding: 0.55rem;
  border: none;
  background: var(--cinza-claro);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.85rem;
  border-bottom: 2px solid transparent;
}
.painel-abas button.ativo { background: var(--branco); border-color: var(--dourado); font-weight: 700; color: var(--azul-marinho); }

.secao-colapsavel { border-bottom: 1px solid var(--borda); }
.secao-colapsavel > summary {
  padding: 0.6rem 0.9rem;
  background: var(--dourado-claro);
  color: var(--azul-marinho);
  cursor: pointer;
  font-weight: 700;
  font-size: 0.85rem;
  list-style: none;
  display: flex;
  justify-content: space-between;
}
.secao-colapsavel > summary::-webkit-details-marker { display: none; }
.secao-colapsavel[open] > summary::after { content: "▲"; }
.secao-colapsavel:not([open]) > summary::after { content: "▼"; }
.secao-conteudo { padding: 0.8rem 0.9rem; }

.area-principal { flex: 1; min-width: 0; background: var(--branco); border: 1px solid var(--borda); border-radius: 6px; }

.abas-tabelas { display: flex; border-bottom: 1px solid var(--borda); }
.abas-tabelas button {
  padding: 0.6rem 1.2rem;
  border: none;
  background: transparent;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9rem;
  border-bottom: 3px solid transparent;
}
.abas-tabelas button.ativo { border-color: var(--dourado); font-weight: 700; color: var(--azul-marinho); }

.barra-acoes-tabela { display: flex; gap: 0.5rem; padding: 0.6rem 0.9rem; border-bottom: 1px solid var(--borda); }

table.tabela-itens { width: 100%; border-collapse: collapse; }
table.tabela-itens th {
  background: #eceff4;
  text-align: right;
  padding: 0.5rem 0.7rem;
  font-size: 0.78rem;
  color: #555;
}
table.tabela-itens th:first-child, table.tabela-itens th:nth-child(2) { text-align: left; }
table.tabela-itens td { padding: 0.5rem 0.7rem; text-align: right; border-bottom: 1px solid var(--borda); font-size: 0.86rem; }
table.tabela-itens td:first-child, table.tabela-itens td:nth-child(2) { text-align: left; }
table.tabela-itens tr.selecionada td { background: var(--dourado-claro); }
table.tabela-itens tfoot td { background: var(--azul-marinho); color: var(--branco); font-weight: 700; }

.painel-resumo { padding: 0.9rem; }
.painel-resumo table { width: 100%; border-collapse: collapse; }
.painel-resumo td { padding: 0.5rem 0.7rem; border-bottom: 1px solid var(--borda); font-size: 0.88rem; }
.painel-resumo td:last-child { text-align: right; }
.painel-resumo tr.total td { background: var(--azul-marinho); color: var(--branco); font-weight: 700; font-size: 0.95rem; }
.painel-resumo tr.amortizado td { color: var(--vermelho); }

.linha-campos { display: flex; gap: 0.6rem; }
.linha-campos .campo { flex: 1; }

/* ---------- Modal ---------- */

.modal-fundo {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
.modal-caixa {
  background: var(--branco); border-radius: 6px; padding: 1.25rem 1.5rem;
  width: 460px; max-height: 88vh; overflow-y: auto;
}
.modal-caixa h2 { font-size: 1rem; color: var(--azul-marinho); margin-top: 0; }
.modal-rodape { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 1rem; }

.oculto { display: none !important; }

/* ---------- Avisos (meses de indice faltando etc.) ---------- */

.caixa-aviso {
  background: #fff4e5;
  border: 1px solid #e0a942;
  color: #7a4a00;
  border-radius: 4px;
  padding: 0.6rem 0.8rem;
  font-size: 0.82rem;
  margin-bottom: 0.8rem;
}
.caixa-aviso strong { display: block; margin-bottom: 0.3rem; }
.caixa-aviso ul { margin: 0; padding-left: 1.1rem; }

/* ---------- Matriz Principal x Amortizado (Multa/Honorarios) ---------- */

table.tabela-matriz { width: 100%; border-collapse: collapse; margin-bottom: 0.9rem; font-size: 0.82rem; }
table.tabela-matriz th {
  background: #eceff4;
  padding: 0.35rem 0.5rem;
  font-weight: 700;
  color: var(--azul-marinho);
  text-align: center;
}
table.tabela-matriz th:first-child { text-align: left; background: transparent; }
table.tabela-matriz td { padding: 0.35rem 0.5rem; border-bottom: 1px solid var(--borda); text-align: center; }
table.tabela-matriz td:first-child { text-align: left; color: #555; }
table.tabela-matriz input[type="number"] { width: 80px; text-align: right; padding: 0.2rem 0.4rem; }
table.tabela-matriz input[type="checkbox"] { width: 16px; height: 16px; }

/* ---------- Impressão / PDF ---------- */

.folha-impressao { max-width: 900px; margin: 0 auto; background: var(--branco); padding: 2rem; }
.timbre-topo { display: flex; align-items: center; gap: 1rem; border-bottom: 3px solid var(--dourado); padding-bottom: 1rem; margin-bottom: 1.25rem; }
.timbre-topo img { height: 60px; }
.timbre-topo .nome-escritorio { color: var(--azul-marinho); font-size: 1.15rem; font-weight: 700; }
.timbre-topo .dados-escritorio { color: #666; font-size: 0.78rem; }
.folha-impressao h2 { color: var(--azul-marinho); font-size: 1rem; border-bottom: 1px solid var(--borda); padding-bottom: 0.4rem; margin-top: 1.5rem; }
.folha-impressao table { width: 100%; border-collapse: collapse; margin-bottom: 0.5rem; }
.folha-impressao th { background: var(--azul-marinho); color: var(--branco); padding: 0.4rem 0.6rem; font-size: 0.78rem; text-align: right; }
.folha-impressao th:first-child, .folha-impressao th:nth-child(2) { text-align: left; }
.folha-impressao td { padding: 0.4rem 0.6rem; border-bottom: 1px solid var(--borda); font-size: 0.8rem; text-align: right; }
.folha-impressao td:first-child, .folha-impressao td:nth-child(2) { text-align: left; }
.folha-impressao tfoot td, .folha-impressao .linha-total td { background: var(--azul-marinho); color: var(--branco); font-weight: 700; }
.folha-impressao .rodape-impressao { margin-top: 2rem; font-size: 0.72rem; color: #888; text-align: center; }

@media print {
  body { background: var(--branco); }
  .folha-impressao { padding: 0; max-width: none; }
}
