* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
  background-color: #f4f6f9;
  color: #1f2430;
}

.oculto {
  display: none !important;
}

/* ---------- LOGIN ---------- */
#tela-login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #eef2f5;
}

.card-login {
  background: #ffffff;
  padding: 2.5rem;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  width: 100%;
  max-width: 380px;
  text-align: center;
}

.card-login h1 {
  font-size: 1.5rem;
  margin-bottom: 0.4rem;
}

.card-login .subtitulo {
  font-size: 0.9rem;
  color: #667;
  margin-bottom: 1.5rem;
}

.card-login input {
  width: 100%;
  padding: 0.75rem;
  margin-bottom: 0.9rem;
  border: 1px solid #dde1e7;
  border-radius: 8px;
  font-size: 0.95rem;
}

.card-login button {
  width: 100%;
  padding: 0.75rem;
  background-color: #2f5be0;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}

.card-login button:hover {
  background-color: #2447b8;
}

.erro {
  color: #dc3545;
  font-size: 0.85rem;
  margin-top: 1rem;
  min-height: 18px;
}

/* ---------- CABEÇALHO ---------- */
.topo {
  background-color: #ffffff;
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #e0e0e0;
}

.topo h1 {
  font-size: 1.25rem;
}

.btn-secundario {
  background-color: transparent;
  border: 1px solid #ccc;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 500;
  font-size: 0.9rem;
}

.btn-secundario:hover {
  background-color: #f0f0f0;
}

/* ---------- ABAS DE NAVEGAÇÃO ---------- */
.abas {
  display: flex;
  background-color: #ffffff;
  padding: 0 2rem;
  border-bottom: 1px solid #e0e0e0;
  gap: 0.5rem;
  overflow-x: visible;
  position: relative;
  z-index: 50;
}

.aba {
  background: transparent;
  border: none;
  padding: 1rem 1.1rem;
  font-size: 0.95rem;
  font-weight: 500;
  color: #667;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  white-space: nowrap;
}

.aba:hover {
  color: #2f5be0;
}

.aba.ativa {
  color: #2f5be0;
  border-bottom-color: #2f5be0;
  font-weight: 600;
}

/* ---------- CONTEÚDO / PAINÉIS ---------- */
.painel {
  padding: 1.5rem 2rem;
  max-width: 1400px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

.painel h2 {
  font-size: 1.1rem;
  margin: 1.5rem 0 0.8rem;
  color: #333;
}

.painel h2:first-child {
  margin-top: 0;
}

/* ---------- DASHBOARD: CARDS DE KPI ---------- */
#painel-dashboard {
  padding: 1.5rem 2rem;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.2rem;
  margin-bottom: 2rem;
}

@media (max-width: 1024px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 600px) {
  .kpi-grid { grid-template-columns: 1fr; }
}

.kpi-card {
  background: #ffffff;
  padding: 1.4rem;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  display: flex;
  flex-direction: column;
  border-left: 4px solid #2f5be0;
}

.kpi-card.azul    { border-left-color: #2f5be0; }
.kpi-card.verde   { border-left-color: #10b981; }
.kpi-card.amarelo { border-left-color: #f59e0b; }
.kpi-card.roxo    { border-left-color: #8b5cf6; }

.kpi-titulo {
  font-size: 0.8rem;
  color: #667;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 0.5rem;
}

.kpi-card h3 {
  font-size: 1.7rem;
  font-weight: 700;
  color: #1a1a1a;
  margin-bottom: 0.4rem;
}

.kpi-sub {
  font-size: 0.8rem;
  color: #8a94a6;
}

/* ---------- DASHBOARD: GRÁFICOS ---------- */
.graficos-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;
}

@media (max-width: 900px) {
  .graficos-grid { grid-template-columns: 1fr; }
}

.grafico-card {
  background: #ffffff;
  padding: 1.4rem;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  height: 380px;
}

.grafico-card h3 {
  font-size: 0.95rem;
  color: #333;
  margin-bottom: 1rem;
}

.grafico-card canvas {
  max-height: 300px;
}

/* ---------- FORMULÁRIOS ---------- */
.form-linha, .form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  background: #fff;
  padding: 16px;
  border-radius: 10px;
  border: 1px solid #e3e6eb;
  max-width: 1000px;
  margin-bottom: 1rem;
}

.form-linha input,
.form-linha select,
.form-grid input,
.form-grid select {
  padding: 0.65rem 0.8rem;
  border: 1px solid #dde1e7;
  border-radius: 8px;
  font-size: 0.9rem;
}

.form-linha button,
.form-grid button {
  grid-column: 1 / -1;
  max-width: 260px;
  padding: 0.65rem 1.2rem;
  background-color: #2f5be0;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
}

.form-linha button:hover,
.form-grid button:hover {
  background-color: #1e40af;
}

/* ---------- FILTROS ---------- */
.filtros {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.filtros button {
  background: #eef2f5;
  border: none;
  padding: 0.4rem 0.9rem;
  border-radius: 20px;
  font-size: 0.82rem;
  cursor: pointer;
}

.filtros button:hover {
  background: #dde3ea;
}

/* ---------- TABELAS ---------- */
table[id^="tabela-"] {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid #e3e6eb;
  margin-top: 10px;
}

table[id^="tabela-"] th,
table[id^="tabela-"] td {
  text-align: left;
  padding: 0.75rem 0.9rem;
  font-size: 0.85rem;
  border-bottom: 1px solid #eef0f3;
}

table[id^="tabela-"] th {
  background: #f8fafc;
  color: #475569;
  font-weight: 600;
}

table[id^="tabela-"] tr:last-child td {
  border-bottom: none;
}

/* ---------- TAGS DE STATUS ---------- */
.tag {
  display: inline-block;
  padding: 0.25rem 0.6rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}

.tag-solicitada { background-color: #fef3c7; color: #92400e; }
.tag-aguardando_pagamento { background-color: #e0f2fe; color: #075985; }
.tag-paga_confirmada, .tag-confirmada, .tag-paga { background-color: #d1fae5; color: #065f46; }
.tag-cancelada { background-color: #fee2e2; color: #991b1b; }
.tag-pendente { background-color: #fef3c7; color: #92400e; }
.tag-pago { background-color: #d1fae5; color: #065f46; }
.tag-pago_parcial { background-color: #fef3c7; color: #b45309; }

/* ---------- BOTÕES DE AÇÃO NAS TABELAS ---------- */
.acao-btn {
  padding: 5px 10px;
  border: none;
  border-radius: 6px;
  background: #2f5be0;
  color: #fff;
  font-size: 12px;
  cursor: pointer;
  margin-right: 4px;
}

.acao-btn:hover {
  background: #1e40af;
}

.acao-btn.perigo {
  background: #d3402f;
}

.acao-btn.perigo:hover {
  background: #b53021;
}

hr {
  border: none;
  border-top: 1px solid #eee;
  margin: 1.5rem 0;
}

/* ---------- SUB-TABELA DE PARCELAS (Acordeão / Linha Expandida) ---------- */
.linha-detalhes-parcelas td {
  background: #f8fafc;
  padding: 1rem !important;
  border-bottom: 1px solid #e3e6eb;
}

.tabela-parcelas-container {
  width: 100%;
  overflow-x: auto;
}

/* --- SUBMENU DE CLIENTES (Por clique via JS) --- */
.dropdown {
  position: relative;
  display: inline-block;
}

.submenu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  background-color: #fff;
  min-width: 180px;
  box-shadow: 0px 8px 16px rgba(0,0,0,0.15);
  z-index: 99999;
  list-style: none;
  padding: 5px 0;
  margin: 0;
  border-radius: 4px;
  border: 1px solid #e5e7eb;
}

.submenu li button, .submenu li a {
  color: #374151;
  padding: 10px 15px;
  text-decoration: none;
  display: block;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
  font-size: 14px;
}

.submenu li button:hover, .submenu li a:hover {
  background-color: #f3f4f6;
  color: #1f2937;
}

/* --- MODAL E CAMPOS DE CADASTRO --- */
.modal-cadastro-conteudo {
  max-height: 85vh;
  overflow-y: auto;
  width: 600px;
  max-width: 90%;
}

.form-linha-grupo {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.form-linha-grupo input, .form-linha-grupo select {
  flex: 1;
  min-width: 150px;
  padding: 10px;
  border: 1px solid #ccc;
  border-radius: 4px;
}

/* Botão principal de envio/cadastro dentro dos modais (excluindo o botão de fechar) */
.modal-conteudo button[type="submit"],
.modal-conteudo form > button:not(.btn-fechar),
.modal-cadastro-conteudo > button:not(.btn-fechar) {
  width: 100%;
  padding: 0.75rem;
  background-color: #2f5be0;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 10px;
}

.modal-conteudo button[type="submit"]:hover,
.modal-conteudo form > button:not(.btn-fechar):hover,
.modal-cadastro-conteudo > button:not(.btn-fechar):hover {
  background-color: #1e40af;
}

/* ---------- MODAL GERAL ---------- */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
}

.modal.oculto {
  display: none !important;
}

.modal-conteudo {
  background: #ffffff;
  padding: 2rem;
  border-radius: 12px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
  width: 100%;
  max-width: 600px;
  position: relative;
}

.modal-cabecalho {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.2rem;
}

.modal-cabecalho h3 {
  font-size: 1.2rem;
  color: #1f2430;
}

.btn-fechar {
  background: none !important;
  border: none !important;
  font-size: 1.5rem !important;
  cursor: pointer;
  color: #667 !important;
  width: auto !important;
  padding: 0 !important;
  margin: 0 !important;
}

.btn-fechar:hover {
  color: #000 !important;
  background: none !important;
}

/* Estilo do Logo na Tela de Login */
.login-logo {
  width: 100%;
  max-width: 140px; /* Ajuste o tamanho ideal para o card de login */
  height: auto;
  margin: 0 auto 24px auto;
  display: block;
  object-fit: contain;
}

/* Estilo do Cabeçalho da Sidebar no Painel */
.sidebar-header {
  padding: 24px 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

/* Estilo do Logo no Menu Lateral */
.sidebar-logo {
  width: 100%;
  max-width: 110px; /* Tamanho proporcional ao menu lateral */
  height: auto;
  object-fit: contain;
}

.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background-color: #f1f5f9;
  }

  .login-card {
    background: #ffffff;
    padding: 40px 30px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    width: 100%;
    max-width: 400px;
    text-align: center;
  }

  .logo-wrapper {
    margin-bottom: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
  }

  /* AJUSTE ESSENCIAL PARA O LOGO NÃO ESTOURAR O TINGIMENTO */
  .login-logo {
    max-width: 130px;  /* Controla o tamanho ideal no card */
    height: auto;      /* Mantém a proporção exata da imagem */
    object-fit: contain;
    display: block;
  }

  .login-card h2 {
    margin-bottom: 24px;
    color: #1e293b;
    font-size: 1.5rem;
    font-weight: 600;
  }

  .input-group {
    text-align: left;
    margin-bottom: 16px;
  }

  .input-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.875rem;
    color: #64748b;
    font-weight: 500;
  }

  .input-group input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s;
  }

  .input-group input:focus {
    border-color: #3b82f6;
  }

  .btn-login {
    width: 100%;
    padding: 12px;
    background-color: #0f172a;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    margin-top: 10px;
    transition: background-color 0.2s;
  }

  .btn-login:hover {
    background-color: #1e293b;
  }