/* ================================================================
   PRECIFIKA — RELATÓRIOS FINANCEIROS DE OBRAS
   css/finance-report.css — v1.0 — Junho 2026
   ================================================================ */

/* ── Variáveis ── */
:root {
  --rpt-primary:    #1d4ed8;
  --rpt-primaryDk:  #1e40af;
  --rpt-primaryLt:  #bfdbfe;
  --rpt-primaryXL:  #eff6ff;
  --rpt-green:      #16a34a;
  --rpt-greenLt:    #dcfce7;
  --rpt-red:        #dc2626;
  --rpt-redLt:      #fee2e2;
  --rpt-orange:     #ea580c;
  --rpt-orangeLt:   #ffedd5;
  --rpt-purple:     #7c3aed;
  --rpt-purpleLt:   #ede9fe;
  --rpt-gray50:     #f8fafc;
  --rpt-gray100:    #f1f5f9;
  --rpt-gray200:    #e2e8f0;
  --rpt-gray400:    #94a3b8;
  --rpt-gray600:    #475569;
  --rpt-gray800:    #1e293b;
  --rpt-shadow:     0 4px 16px rgba(0,0,0,.10);
  --rpt-shadow-lg:  0 20px 60px rgba(0,0,0,.22);
  --rpt-radius:     14px;
}

/* ================================================================
   1. BOTÃO "RELATÓRIOS" na página financeira
   ================================================================ */
.btn-rpt-open {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  background: linear-gradient(135deg, #7c3aed, #5b21b6);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: opacity .15s, transform .1s, box-shadow .15s;
  box-shadow: 0 2px 8px rgba(124,58,237,.3);
  white-space: nowrap;
}
.btn-rpt-open:hover  { opacity: .9; box-shadow: 0 4px 14px rgba(124,58,237,.4); }
.btn-rpt-open:active { transform: scale(.97); }

/* ================================================================
   2. OVERLAY DO MODAL
   ================================================================ */
.rpt-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .72);
  z-index: 1100; /* padronizado — precifika-fixes.css */
  align-items: flex-start;
  justify-content: center;
  padding: 24px 16px;
  overflow-y: auto;
  backdrop-filter: blur(3px);
}
.rpt-modal-overlay.active { display: flex; }

/* ================================================================
   3. CAIXA DO MODAL
   ================================================================ */
.rpt-modal-box {
  background: #fff;
  border-radius: 20px;
  width: 100%;
  max-width: 960px;
  min-height: 500px;
  box-shadow: var(--rpt-shadow-lg);
  display: flex;
  flex-direction: column;
  animation: rptModalIn .22s ease;
  position: relative;
}
@keyframes rptModalIn {
  from { opacity: 0; transform: translateY(-18px) scale(.98); }
  to   { opacity: 1; transform: translateY(0)     scale(1);   }
}

/* ── Cabeçalho ── */
.rpt-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 22px 24px 18px;
  border-bottom: 1px solid var(--rpt-gray200);
  gap: 12px;
}
.rpt-modal-header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}
.rpt-modal-header-icon {
  width: 46px;
  height: 46px;
  background: linear-gradient(135deg, #7c3aed, #5b21b6);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 20px;
  flex-shrink: 0;
}
.rpt-modal-title {
  font-size: 17px;
  font-weight: 800;
  color: var(--rpt-gray800);
  margin: 0 0 3px;
  line-height: 1.2;
}
.rpt-modal-subtitle {
  font-size: 12px;
  color: var(--rpt-gray400);
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.rpt-modal-subtitle span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.rpt-modal-close {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  border: 1px solid var(--rpt-gray200);
  background: var(--rpt-gray50);
  color: var(--rpt-gray400);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  transition: all .15s;
  font-family: inherit;
  flex-shrink: 0;
}
.rpt-modal-close:hover {
  background: var(--rpt-redLt);
  color: var(--rpt-red);
  border-color: #fecaca;
}

/* ── Abas ── */
.rpt-modal-tabs {
  display: flex;
  gap: 4px;
  padding: 12px 24px 0;
  border-bottom: 1px solid var(--rpt-gray200);
}
.rpt-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border: none;
  background: none;
  border-radius: 9px 9px 0 0;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  color: var(--rpt-gray600);
  cursor: pointer;
  transition: all .15s;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.rpt-tab-btn:hover { background: var(--rpt-gray100); color: var(--rpt-gray800); }
.rpt-tab-btn.active {
  color: var(--rpt-primary);
  border-bottom-color: var(--rpt-primary);
  background: var(--rpt-primaryXL);
}
.rpt-tab-btn i { font-size: 12px; }

/* ── Corpo dos painéis ── */
.rpt-modal-body {
  flex: 1;
  padding: 0;
  overflow: hidden;
}
.rpt-tab-panel {
  display: none;
  padding: 20px 24px;
  overflow: auto;
  max-height: calc(100vh - 300px);
}
.rpt-tab-panel.active { display: block; }

/* ── Rodapé com botões de exportação ── */
.rpt-modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px 18px;
  border-top: 1px solid var(--rpt-gray200);
  gap: 12px;
  flex-wrap: wrap;
}
.rpt-footer-label {
  font-size: 12px;
  color: var(--rpt-gray400);
  font-weight: 600;
}
.rpt-export-btns {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.rpt-btn-export {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 16px;
  border-radius: 10px;
  border: 1.5px solid;
  font-size: 13px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}
.rpt-btn-export--pdf {
  background: #fff1f2;
  color: #be123c;
  border-color: #fecdd3;
}
.rpt-btn-export--pdf:hover { background: #ffe4e6; border-color: #fda4af; }

.rpt-btn-export--excel {
  background: #f0fdf4;
  color: #15803d;
  border-color: #bbf7d0;
}
.rpt-btn-export--excel:hover { background: #dcfce7; border-color: #86efac; }

/* ================================================================
   4. TABELA DO EXTRATO
   ================================================================ */
.rpt-table-scroll {
  overflow-x: auto;
  border-radius: 10px;
  border: 1px solid var(--rpt-gray200);
}
.rpt-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
.rpt-table th {
  padding: 9px 12px;
  background: var(--rpt-gray50);
  color: var(--rpt-gray600);
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .4px;
  border-bottom: 1px solid var(--rpt-gray200);
  white-space: nowrap;
}
.rpt-th-right { text-align: right !important; }

.rpt-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--rpt-gray200);
  color: var(--rpt-gray800);
  vertical-align: middle;
}
.rpt-table tr:last-child td { border-bottom: none; }
.rpt-table tr:hover td { background: var(--rpt-gray50); }

/* Linhas coloridas por tipo */
.rpt-row--receita td:first-child {
  border-left: 3px solid var(--rpt-green);
}
.rpt-row--despesa td:first-child {
  border-left: 3px solid var(--rpt-red);
}

/* Colunas */
.rpt-td-date  { white-space: nowrap; color: var(--rpt-gray600); font-size: 12px; }
.rpt-td-desc  { min-width: 180px; }
.rpt-td-value { text-align: right; white-space: nowrap; font-weight: 700; font-size: 13px; }
.rpt-td-saldo { text-align: right; white-space: nowrap; font-weight: 700; font-size: 13px; }

/* Cores de valor */
.rpt-value--receita { color: var(--rpt-green); }
.rpt-value--despesa { color: var(--rpt-red); }
.rpt-saldo--pos     { color: var(--rpt-green); }
.rpt-saldo--neg     { color: var(--rpt-red); }

/* Tfoot */
.rpt-tfoot-row td {
  background: var(--rpt-gray50);
  font-weight: 700;
  border-top: 2px solid var(--rpt-gray200);
}
.rpt-tot-receita { color: var(--rpt-green); font-size: 12px; }
.rpt-tot-despesa { color: var(--rpt-red); font-size: 12px; margin-top: 2px; }

/* Compact variant */
.rpt-table--compact th, .rpt-table--compact td { padding: 7px 10px; font-size: 12px; }

/* Badges de tipo */
.rpt-type-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.rpt-type-badge--receita {
  background: var(--rpt-greenLt);
  color: var(--rpt-green);
}
.rpt-type-badge--despesa {
  background: var(--rpt-redLt);
  color: var(--rpt-red);
}

/* Chips de categoria */
.rpt-cat-chip {
  display: inline-block;
  padding: 2px 8px;
  background: var(--rpt-primaryXL);
  color: var(--rpt-primary);
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.rpt-cat-chip--desp { background: var(--rpt-redLt);   color: var(--rpt-red); }
.rpt-cat-chip--rec  { background: var(--rpt-greenLt); color: var(--rpt-green); }

/* Notas */
.rpt-notes {
  color: var(--rpt-gray400);
  font-size: 11px;
  font-style: italic;
}

/* ── Resumo total abaixo da tabela de extrato ── */
.rpt-extract-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
  padding: 12px 16px;
  background: var(--rpt-gray50);
  border-radius: 10px;
  border: 1px solid var(--rpt-gray200);
}
.rpt-sum-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--rpt-gray600);
  padding: 4px 12px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--rpt-gray200);
}
.rpt-sum-item--receita { color: var(--rpt-green); border-color: var(--rpt-greenLt); background: var(--rpt-greenLt); }
.rpt-sum-item--despesa { color: var(--rpt-red);   border-color: var(--rpt-redLt);   background: var(--rpt-redLt);   }
.rpt-sum-item--pos     { color: var(--rpt-green); border-color: var(--rpt-greenLt); background: var(--rpt-greenLt); }
.rpt-sum-item--neg     { color: var(--rpt-red);   border-color: var(--rpt-redLt);   background: var(--rpt-redLt);   }

/* ================================================================
   5. CARDS DE RESULTADO
   ================================================================ */
.rpt-res-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}
.rpt-res-card {
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  border: 1px solid var(--rpt-gray200);
  background: var(--rpt-gray50);
  transition: box-shadow .15s;
}
.rpt-res-card:hover { box-shadow: var(--rpt-shadow); }
.rpt-res-card--contracted { background: var(--rpt-primaryXL); border-color: var(--rpt-primaryLt); }
.rpt-res-card--received   { background: #f0fdf4; border-color: #bbf7d0; }
.rpt-res-card--expense    { background: #fff1f2; border-color: #fecdd3; }
.rpt-res-card--profit     { background: var(--rpt-purpleLt); border-color: #c4b5fd; }

.rpt-res-card-icon {
  width: 38px;
  height: 38px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  background: rgba(255,255,255,.7);
  color: var(--rpt-primary);
}
.rpt-res-card--received .rpt-res-card-icon  { color: var(--rpt-green); }
.rpt-res-card--expense  .rpt-res-card-icon  { color: var(--rpt-red); }
.rpt-res-card--profit   .rpt-res-card-icon  { color: var(--rpt-purple); }

.rpt-res-card-body { flex: 1; min-width: 0; }
.rpt-res-card-label {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--rpt-gray600);
  margin-bottom: 4px;
}
.rpt-res-card-value {
  font-size: 16px;
  font-weight: 800;
  color: var(--rpt-gray800);
  /* valor monetário: nunca quebra, mas nunca corta */
  white-space: nowrap;
  overflow: visible;
  min-width: 0;
}
.rpt-res-card-sub {
  font-size: 11px;
  color: var(--rpt-gray400);
  margin-top: 2px;
}

/* Cores de valor no resultado */
.rpt-res--pos  { color: var(--rpt-green) !important; }
.rpt-res--neg  { color: var(--rpt-red) !important; }
.rpt-res--rec  { color: var(--rpt-green) !important; }
.rpt-res--desp { color: var(--rpt-red) !important; }

/* ================================================================
   6. BARRAS DE PROGRESSO DO RESULTADO
   ================================================================ */
.rpt-result-bar-section {
  background: var(--rpt-gray50);
  border: 1px solid var(--rpt-gray200);
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 20px;
}
.rpt-result-bar-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--rpt-gray600);
  margin-bottom: 6px;
}
.rpt-result-bar-track {
  height: 10px;
  background: var(--rpt-gray200);
  border-radius: 20px;
  overflow: hidden;
}
.rpt-result-bar-fill {
  height: 100%;
  border-radius: 20px;
  transition: width .5s ease;
}
.rpt-result-bar-fill--rec  { background: linear-gradient(90deg, #4ade80, #16a34a); }
.rpt-result-bar-fill--desp { background: linear-gradient(90deg, #f87171, #dc2626); }
.rpt-result-bar-fill--pos  { background: linear-gradient(90deg, #4ade80, #16a34a); }
.rpt-result-bar-fill--neg  { background: linear-gradient(90deg, #f87171, #dc2626); }

/* ================================================================
   7. BREAKDOWN DE CATEGORIAS
   ================================================================ */
.rpt-breakdown-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}
.rpt-breakdown-section {
  border: 1px solid var(--rpt-gray200);
  border-radius: 12px;
  overflow: hidden;
}
.rpt-breakdown-title {
  padding: 10px 14px;
  background: var(--rpt-gray50);
  font-size: 12px;
  font-weight: 700;
  color: var(--rpt-gray800);
  border-bottom: 1px solid var(--rpt-gray200);
  display: flex;
  align-items: center;
  gap: 7px;
}

/* Mini barras inline */
.rpt-mini-bar {
  display: inline-block;
  width: 60px;
  height: 6px;
  background: var(--rpt-gray200);
  border-radius: 20px;
  overflow: hidden;
  vertical-align: middle;
  margin-right: 4px;
}
.rpt-mini-bar-fill {
  height: 100%;
  border-radius: 20px;
  transition: width .4s ease;
}
.rpt-mini-bar-fill--desp { background: #f87171; }
.rpt-mini-bar-fill--rec  { background: #4ade80; }
.rpt-mini-pct { font-size: 11px; color: var(--rpt-gray600); vertical-align: middle; }

.rpt-empty-row { text-align: center; color: var(--rpt-gray400); font-style: italic; }

/* ================================================================
   8. RESULTADO FINAL (rodapé do painel)
   ================================================================ */
.rpt-final-result {
  display: flex;
  flex-direction: column;
  gap: 2px;
  border: 1px solid var(--rpt-gray200);
  border-radius: 12px;
  overflow: hidden;
}
.rpt-final-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  border-bottom: 1px solid var(--rpt-gray200);
  background: #fff;
}
.rpt-final-item:last-child { border-bottom: none; }
.rpt-final-item--highlight {
  background: var(--rpt-primaryXL);
  border-color: var(--rpt-primaryLt);
}
.rpt-final-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--rpt-gray600);
  display: flex;
  align-items: center;
  gap: 7px;
}
.rpt-final-value {
  font-size: 16px;
  font-weight: 800;
  color: var(--rpt-gray800);
}

/* ================================================================
   9. ESTADO VAZIO
   ================================================================ */
.rpt-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 48px 24px;
  color: var(--rpt-gray400);
  text-align: center;
  gap: 10px;
}
.rpt-empty i  { font-size: 36px; }
.rpt-empty p  { font-size: 13px; margin: 0; }

/* ================================================================
   10. RESPONSIVO MOBILE
   ================================================================ */
@media (max-width: 720px) {
  .rpt-modal-overlay {
    padding: 0;
    align-items: flex-end;
  }
  .rpt-modal-box {
    border-radius: 20px 20px 0 0;
    max-height: 96vh;
    width: 100%;
    max-width: 100%;
    margin: 0;
  }
  .rpt-modal-header { padding: 14px 16px 10px; }

  /* Abas com scroll horizontal */
  .rpt-modal-tabs {
    padding: 6px 12px 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
    display: flex;
    gap: 0;
  }
  .rpt-tab-btn { padding: 9px 14px; font-size: 12.5px; white-space: nowrap; }

  /* Painel de conteúdo */
  .rpt-tab-panel { padding: 14px; max-height: calc(100vh - 260px); }

  /* Cards de resultado: 2 colunas */
  .rpt-res-cards      { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .rpt-res-card       { padding: 12px; border-radius: 12px; }
  .rpt-res-card-value { font-size: 16px; }
  .rpt-res-card-label { font-size: 11px; }

  /* Breakdown: 1 coluna */
  .rpt-breakdown-grid { grid-template-columns: 1fr; }

  /* Tabela extrato → scroll */
  .rpt-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .rpt-table { min-width: 480px; }
  .rpt-table th, .rpt-table td { padding: 8px 10px; font-size: 12px; }

  /* Footer */
  .rpt-modal-footer {
    flex-direction: column;
    align-items: stretch;
    padding: 12px 16px 24px;
    gap: 8px;
  }
  .rpt-export-btns {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }
  .rpt-btn-export {
    width: 100%;
    justify-content: center;
    min-height: 48px;
    font-size: 14px;
  }
}

@media (max-width: 480px) {
  .rpt-res-cards      { grid-template-columns: 1fr 1fr; gap: 8px; }
  .rpt-res-card-value { font-size: 14px; }
  .rpt-table th, .rpt-table td { padding: 7px 8px; font-size: 11px; }
  .rpt-tab-btn { padding: 8px 12px; font-size: 12px; }
}
