/* Prestação de Contas - Condomínio Solar da Serra */
/* Identidade visual: verde #388E3C, branco, preto */

:root {
  --verde: #388E3C;
  --verde-claro: #e8f5e9;
  --verde-hover: #2e7d32;
  --preto: #1a1a1a;
  --branco: #ffffff;
  --cinza-fundo: #f5f5f5;
  --cinza-texto: #555;
  --sombra: 0 2px 8px rgba(0, 0, 0, 0.08);
  --sombra-hover: 0 4px 12px rgba(0, 0, 0, 0.12);
  --raio: 8px;
  --transicao: 0.2s ease;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Montserrat", -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--cinza-fundo);
  color: var(--preto);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.header {
  background: var(--verde);
  color: var(--branco);
  padding: 1rem 2rem;
  box-shadow: var(--sombra);
}

.header-content {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.logo {
  height: 56px;
  width: auto;
  object-fit: contain;
}

.header-title h1 {
  font-size: 1.5rem;
  font-weight: 600;
}

.subtitle {
  font-size: 0.9rem;
  opacity: 0.9;
  margin-top: 0.25rem;
}

/* Tabs */
.tabs {
  background: var(--branco);
  padding: 0 2rem;
  box-shadow: var(--sombra);
  display: flex;
  gap: 0.5rem;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

.tab {
  padding: 1rem 1.5rem;
  border: none;
  background: none;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--cinza-texto);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: var(--transicao);
}

.tab:hover {
  color: var(--verde);
}

.tab.active {
  color: var(--verde);
  border-bottom-color: var(--verde);
}

/* Main */
.main {
  flex: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
  width: 100%;
}

/* Página Recebimento/Pagamento - full screen */
.main-recebimento {
  max-width: 100%;
  padding: 1rem 2rem;
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 140px);
}

.main-recebimento .section {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.section {
  display: none;
}

.section.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.section h2 {
  font-size: 1.4rem;
  color: var(--preto);
  margin-bottom: 1.5rem;
  font-weight: 600;
}

.section-header-despesas {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.section-header-despesas h2 {
  margin-bottom: 0;
}

.filter-grupo-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: var(--preto);
  margin-left: auto;
}

.filter-grupo-label select {
  min-width: 280px;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--cinza-borda, #ccc);
  border-radius: 4px;
  font-family: inherit;
  font-size: 0.85rem;
}

.filter-grupo-bar {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  margin-bottom: 1.25rem;
}

.filter-grupo-global {
  padding: 0.75rem 1rem 0;
  max-width: 1200px;
  margin-left: auto;
  margin-right: auto;
}

.filter-grupo-centered {
  margin-left: 0;
  margin-right: 0;
  justify-content: center;
}

.bloco-saldos {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.bloco-saldos h2 {
  margin-bottom: 0.35rem;
}

.cards-compact {
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.cards-compact .card {
  padding: 0.85rem 1rem;
}

.cards-compact .card-label {
  font-size: 0.8rem;
}

.cards-compact .card-value {
  font-size: 1.1rem;
}

.charts-row-compact {
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.chart-container-compact {
  padding: 1rem;
}

.chart-container-compact h3 {
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}

.chart-container-compact canvas {
  max-height: none;
}

.chart-wrap {
  position: relative;
  height: 180px;
  width: 100%;
}

.table-container-compact {
  padding: 1rem;
  margin-bottom: 0;
}

.table-container-compact h3 {
  font-size: 0.95rem;
  margin-bottom: 0.75rem;
}

.saldos-table {
  font-size: 0.85rem;
}

.saldos-table .linha-total td {
  border-top: 2px solid var(--cinza-borda, #ccc);
  background: #fafafa;
}

@media (max-width: 640px) {
  .filter-grupo-label {
    width: 100%;
    justify-content: flex-end;
  }

  .filter-grupo-label select {
    flex: 1;
    max-width: 100%;
  }
}

.section h3 {
  font-size: 1rem;
  color: var(--preto);
  margin-bottom: 0.75rem;
  font-weight: 600;
}

/* Cards */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.card {
  background: var(--branco);
  padding: 1.25rem;
  border-radius: var(--raio);
  box-shadow: var(--sombra);
  transition: var(--transicao);
  border-left: 4px solid var(--verde);
}

.card:hover {
  box-shadow: var(--sombra-hover);
}

.card-label {
  display: block;
  font-size: 0.85rem;
  color: var(--cinza-texto);
  margin-bottom: 0.5rem;
}

.card-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--preto);
}

.card-value.positivo {
  color: var(--verde);
}

.card-value.negativo {
  color: #c62828;
}

/* Charts */
.charts-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.chart-container {
  background: var(--branco);
  padding: 1.5rem;
  border-radius: var(--raio);
  box-shadow: var(--sombra);
}

.chart-container h3 {
  margin-bottom: 1rem;
}

.chart-container canvas {
  max-height: 280px;
}

/* Tables */
.table-container,
.balanco-tables,
.dre-tables {
  background: var(--branco);
  padding: 1.5rem;
  border-radius: var(--raio);
  box-shadow: var(--sombra);
  margin-bottom: 1.5rem;
}

.filters {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.filters label {
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.filters select {
  padding: 0.4rem 0.75rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-family: inherit;
  font-size: 0.9rem;
}

.table-scroll {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

/* Tabela de receitas: fonte menor para caber mais colunas */
.receitas-table {
  font-size: 0.75rem;
}

.receitas-table th,
.receitas-table td {
  padding: 0.4rem 0.5rem;
}

.receitas-table .valor {
  white-space: nowrap;
}

.table-valores-info {
  font-size: 0.85rem;
  color: var(--cinza-texto);
  margin-bottom: 0.5rem;
  font-style: italic;
}

.data-table th,
.data-table td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid #eee;
}

.data-table th {
  background: var(--verde-claro);
  color: var(--preto);
  font-weight: 600;
}

.data-table tbody tr:hover {
  background: var(--verde-claro);
}

.data-table .valor {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.data-table .positivo {
  color: var(--verde);
}

.data-table .negativo {
  color: #c62828;
}

/* Balanço e DRE */
.balanco-tables,
.dre-tables {
  display: grid;
  gap: 1.5rem;
}

.balanco-section,
.dre-section {
  border: 1px solid #eee;
  border-radius: var(--raio);
  overflow: hidden;
}

.balanco-section h3,
.dre-section h3 {
  background: var(--verde-claro);
  padding: 0.75rem 1rem;
  margin: 0;
  font-size: 0.95rem;
}

/* Loading e Error */
.loading,
.error {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 1.5rem 2rem;
  background: var(--branco);
  border-radius: var(--raio);
  box-shadow: var(--sombra-hover);
  z-index: 1000;
  font-weight: 500;
}

.loading.hidden,
.error.hidden {
  display: none !important;
}

.error {
  max-width: 400px;
  text-align: center;
}

.error code,
.error .error-code {
  display: block;
  margin-top: 0.5rem;
  padding: 0.5rem;
  background: var(--cinza-fundo);
  border-radius: 4px;
  font-size: 0.85rem;
  white-space: pre-wrap;
}

/* Footer */
.footer {
  background: var(--preto);
  color: var(--branco);
  text-align: center;
  padding: 1rem 2rem;
  font-size: 0.85rem;
  margin-top: auto;
}

/* Receitas Ordinárias - tabela hierárquica */
.section-desc {
  color: var(--cinza-texto);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.receitas-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.receitas-filters label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  cursor: pointer;
}

.btn-secondary {
  padding: 0.5rem 1rem;
  border: 1px solid var(--verde);
  background: var(--branco);
  color: var(--verde);
  font-family: inherit;
  font-size: 0.9rem;
  border-radius: 4px;
  cursor: pointer;
  transition: var(--transicao);
}

.btn-secondary:hover {
  background: var(--verde-claro);
}

.receitas-table .col-expand {
  width: 36px;
  text-align: center;
  vertical-align: middle;
}

.receitas-table .col-nota {
  position: sticky;
  right: 0;
  background: var(--branco);
  box-shadow: -4px 0 8px rgba(0, 0, 0, 0.05);
  min-width: 280px;
  vertical-align: top;
}

.receitas-table thead .col-nota {
  background: var(--verde-claro);
}

.btn-expand {
  width: 24px;
  height: 24px;
  padding: 0;
  border: 1px solid var(--verde);
  background: var(--verde-claro);
  color: var(--verde);
  font-size: 1rem;
  font-weight: 600;
  line-height: 1;
  border-radius: 4px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: var(--transicao);
}

.btn-expand:hover {
  background: var(--verde);
  color: var(--branco);
}

.col-expand-placeholder {
  display: inline-block;
  width: 24px;
  height: 24px;
}

.despesas-table .despesas-row-sub {
  background: #fafafa;
}

.despesas-table .despesas-row-sub .col-categoria {
  padding-left: 1.5rem;
  font-size: 0.9rem;
  color: var(--preto);
}

.despesas-table .despesas-row-sub .col-mes {
  color: var(--cinza, #888);
  font-size: 0.85rem;
}

.despesas-table .col-expand {
  width: 36px;
  text-align: center;
  vertical-align: middle;
}

.input-nota {
  width: 100%;
  min-width: 250px;
  min-height: 3.5em;
  padding: 0.5rem 0.75rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-family: inherit;
  font-size: 0.9rem;
  line-height: 1.4;
  resize: vertical;
  box-sizing: border-box;
}

.input-nota:focus {
  outline: none;
  border-color: var(--verde);
  box-shadow: 0 0 0 2px rgba(56, 142, 60, 0.2);
}

.receitas-table .receitas-row.has-children .col-conta {
  font-weight: 600;
}

.receitas-table .receitas-row.has-comment {
  background-color: #fffde7;
}

.receitas-table .receitas-row.has-comment:hover {
  background-color: #fff9c4;
}

.receitas-table .receitas-row.has-comment .col-nota {
  background-color: #fffde7;
}

.receitas-table .receitas-row.has-comment:hover .col-nota {
  background-color: #fff9c4;
}

/* Campo de busca */
.busca-input {
  padding: 0.5rem 1rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-family: inherit;
  font-size: 0.95rem;
  min-width: 220px;
}

.busca-input:focus {
  outline: none;
  border-color: var(--verde);
}

.busca-input::placeholder {
  color: #999;
}

/* Overlay de senha */
.senha-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.senha-overlay.senha-ok,
.senha-overlay[style*="display: none"] {
  display: none !important;
}

.senha-box {
  background: var(--branco);
  padding: 2rem;
  border-radius: var(--raio);
  box-shadow: var(--sombra-hover);
  text-align: center;
  min-width: 280px;
}

.senha-box h2 {
  font-size: 1.2rem;
  margin-bottom: 0.5rem;
  color: var(--preto);
}

.senha-box p {
  font-size: 0.9rem;
  color: var(--cinza-texto);
  margin-bottom: 1rem;
}

.senha-input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 1rem;
  font-family: inherit;
  margin-bottom: 1rem;
  box-sizing: border-box;
}

.senha-input:focus {
  outline: none;
  border-color: var(--verde);
}

.senha-erro {
  color: #c62828;
  font-size: 0.85rem;
  margin-bottom: 0.5rem !important;
}

.receitas-table-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.receitas-table-container .table-scroll {
  flex: 1;
  min-height: 400px;
  max-height: calc(100vh - 280px);
  overflow: auto;
}

/* Responsivo */
@media (max-width: 768px) {
  .header-content {
    flex-direction: column;
    text-align: center;
  }

  .tabs {
    padding: 0 1rem;
    overflow-x: auto;
  }

  .tab {
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
    white-space: nowrap;
  }

  .main {
    padding: 1rem;
  }

  .charts-row {
    grid-template-columns: 1fr;
  }

  .cards {
    grid-template-columns: 1fr;
  }
}

/* Modal lançamentos — Despesas v2 */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  padding: 1rem;
}

.modal-overlay.hidden {
  display: none !important;
}

body.modal-open {
  overflow: hidden;
}

.modal-panel {
  background: var(--branco);
  border-radius: var(--raio);
  box-shadow: var(--sombra-hover);
  width: min(1200px, 100%);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid #eee;
}

.modal-header h3 {
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.4;
  flex: 1;
}

.modal-fechar {
  background: none;
  border: none;
  font-size: 1.75rem;
  line-height: 1;
  cursor: pointer;
  color: var(--cinza-texto);
  padding: 0 0.25rem;
}

.modal-fechar:hover {
  color: var(--preto);
}

.modal-resumo {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 1.5rem;
  padding: 1rem 1.5rem;
  background: var(--verde-claro);
  font-size: 0.9rem;
}

.modal-busca {
  margin: 1rem 1.5rem 0;
  padding: 0.6rem 0.75rem;
  border: 1px solid #ddd;
  border-radius: var(--raio);
  font-family: inherit;
  font-size: 0.95rem;
  width: calc(100% - 3rem);
}

.modal-busca:focus {
  outline: none;
  border-color: var(--verde);
}

.modal-table-scroll {
  margin: 1rem 1.5rem 1.5rem;
  max-height: 50vh;
}

.modal-empty {
  text-align: center;
  color: var(--cinza-texto);
  padding: 1.5rem !important;
}

.btn-detalhes {
  background: var(--verde);
  color: var(--branco);
  border: none;
  border-radius: 4px;
  padding: 0.35rem 0.65rem;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--transicao);
}

.btn-detalhes:hover {
  background: var(--verde-hover);
}

#tabela-lancamentos .col-descricao {
  min-width: 180px;
  max-width: 280px;
  white-space: normal;
  word-break: break-word;
}
