:root {
  --sidebar-width: 240px;
  --sidebar-bg: #1a2744;
  --sidebar-hover: #243460;
  --sidebar-active: #2e4080;
  --accent: #4a7fd4;
  --accent-light: #e8f0fe;
  --topbar-height: 56px;
  --text-muted-sidebar: #8a9cc4;
  --success: #28a745;
  --danger: #dc3545;
  --warning: #ffc107;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Segoe UI', sans-serif; background: #f0f2f8; display: flex; min-height: 100vh; }

/* ─── SIDEBAR ─── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 1000;
  transition: transform 0.3s ease;
  overflow-y: auto;
}
.sidebar.collapsed { transform: translateX(calc(-1 * var(--sidebar-width))); }

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-logo {
  width: 40px; height: 40px;
  background: var(--accent);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; flex-shrink: 0;
}
.sidebar-title { font-weight: 700; font-size: 15px; }
.sidebar-subtitle { font-size: 11px; color: var(--text-muted-sidebar); }

.sidebar-nav { padding: 12px 0; flex: 1; }
.nav-section-label {
  font-size: 10px; font-weight: 700; letter-spacing: 1.2px;
  color: var(--text-muted-sidebar); padding: 8px 18px 4px;
  text-transform: uppercase;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 18px;
  color: #c5d0e8;
  text-decoration: none;
  font-size: 14px;
  border-radius: 0;
  transition: background 0.15s, color 0.15s;
  position: relative;
}
.nav-item:hover { background: var(--sidebar-hover); color: #fff; }
.nav-item.active {
  background: var(--sidebar-active);
  color: #fff;
  border-left: 3px solid var(--accent);
}
.nav-item i { font-size: 16px; width: 20px; text-align: center; }

/* #appPrincipal precisa ocupar 100% da largura do body — sem isso, como a sidebar é
   position:fixed (fora do fluxo), o container flex encolhe pro tamanho do conteúdo
   em vez de esticar pra tela toda, apertando os cards e quebrando o texto. */
#appPrincipal { width: 100%; }

/* ─── MAIN ─── */
.main-content {
  margin-left: var(--sidebar-width);
  width: 100%;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left 0.3s ease;
}
.main-content.expanded { margin-left: 0; }

.topbar {
  height: var(--topbar-height);
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.btn-menu {
  background: none; border: none;
  font-size: 22px; cursor: pointer;
  color: #4a5568; padding: 4px 6px;
  border-radius: 6px;
  line-height: 1;
}
.btn-menu:hover { background: #f0f2f8; }
.topbar-title { font-weight: 700; font-size: 17px; color: #1a2744; flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 12px; }

.page-content { padding: 28px 28px 40px; flex: 1; }

/* ─── CARDS ─── */
.card {
  border: none;
  border-radius: 12px;
  box-shadow: 0 1px 6px rgba(0,0,0,0.07);
}
.card-header {
  background: #fff;
  border-bottom: 1px solid #eef0f6;
  border-radius: 12px 12px 0 0 !important;
  padding: 16px 20px;
  font-weight: 700;
  font-size: 15px;
  color: #1a2744;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ─── STAT CARDS ─── */
.stat-card {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 1px 6px rgba(0,0,0,0.07);
  display: flex;
  align-items: flex-start;
  gap: 16px;
}
.stat-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}
.stat-icon.blue   { background: #e8f0fe; color: #4a7fd4; }
.stat-icon.green  { background: #e6f9f0; color: #28a745; }
.stat-icon.red    { background: #fde8e8; color: #dc3545; }
.stat-icon.orange { background: #fff3e0; color: #e67e22; }
.stat-icon.purple { background: #f0e8ff; color: #7b4fd4; }
.stat-icon.teal   { background: #e0f7f7; color: #17a2b8; }

/* min-width:0 permite que o texto encolha dentro do flex item — sem isso, valores
   monetários (que usam espaço não separável entre "R$" e o número) forçam o card
   a "vazar" pra fora em vez de quebrar linha. */
.stat-card > div:not(.stat-icon) { min-width: 0; flex: 1 1 auto; }

.stat-label { font-size: 12px; color: #8a99b0; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; overflow-wrap: break-word; }
.stat-value { font-size: 22px; font-weight: 800; color: #1a2744; line-height: 1.2; margin-top: 2px; overflow-wrap: break-word; }
.stat-sub   { font-size: 12px; color: #8a99b0; margin-top: 4px; overflow-wrap: break-word; }

/* ─── TABELAS ─── */
.table-card { background: #fff; border-radius: 12px; box-shadow: 0 1px 6px rgba(0,0,0,0.07); overflow: hidden; }
.table-card-header {
  padding: 16px 20px;
  border-bottom: 1px solid #eef0f6;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
}
.table-card-title { font-weight: 700; font-size: 15px; color: #1a2744; }
.table { margin-bottom: 0; }
.table th { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: #8a99b0; border-bottom-width: 1px; }
.table td { vertical-align: middle; font-size: 14px; }
.table tbody tr:hover { background: #f7f9ff; }

/* ─── BADGES ─── */
.badge-tipo {
  font-size: 11px; padding: 4px 10px; border-radius: 20px; font-weight: 600;
}
.badge-terca   { background: #e8f0fe; color: #4a7fd4; }
.badge-quinta  { background: #e6f9f0; color: #28a745; }
.badge-domingo { background: #fff3e0; color: #e67e22; }
.badge-especial{ background: #f0e8ff; color: #7b4fd4; }
.badge-depto   { background: #fde8e8; color: #dc3545; }
.badge-manha   { background: #e0f7f7; color: #17a2b8; }

.badge-pago    { background: #e6f9f0; color: #28a745; font-size: 11px; padding: 3px 9px; border-radius: 20px; font-weight: 600; }
.badge-pendente{ background: #fff3e0; color: #e67e22; font-size: 11px; padding: 3px 9px; border-radius: 20px; font-weight: 600; }
.badge-aberto  { background: #fde8e8; color: #dc3545; font-size: 11px; padding: 3px 9px; border-radius: 20px; font-weight: 600; }

/* Badges de movimento interno (transferência / devolução) */
.badge-mov-transf { background: #e8f0fe; color: #4a7fd4; }
.badge-mov-dev     { background: #fff3e0; color: #e67e22; }

/* ─── FORMULÁRIOS ─── */
.form-label { font-size: 13px; font-weight: 600; color: #4a5568; margin-bottom: 4px; }
.form-control, .form-select {
  font-size: 14px; border-radius: 8px;
  border: 1px solid #dde2ef;
  padding: 8px 12px;
}
.form-control:focus, .form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(74,127,212,0.15);
}

/* ─── CALCULO DÍZIMO ─── */
.calc-dizimo {
  background: #f7f9ff;
  border: 1px solid #dde2ef;
  border-radius: 10px;
  padding: 14px 16px;
}
.calc-dizimo .calc-row {
  display: flex; justify-content: space-between;
  font-size: 13px; padding: 3px 0;
}
.calc-dizimo .calc-row.total {
  font-weight: 700; border-top: 1px solid #dde2ef;
  margin-top: 6px; padding-top: 8px;
  font-size: 14px;
}
.calc-dizimo .calc-label { color: #4a5568; }
.calc-dizimo .calc-val   { font-weight: 600; color: #1a2744; }
.calc-dizimo .calc-val.sede    { color: #4a7fd4; }
.calc-dizimo .calc-val.prebenda{ color: #28a745; }
.calc-dizimo .calc-val.pastoral{ color: #e67e22; }
.calc-dizimo .calc-val.igreja  { color: #7b4fd4; }

/* ─── BOTÕES ─── */
.btn { border-radius: 8px; font-size: 14px; font-weight: 600; }
.btn-primary { background: var(--accent); border-color: var(--accent); }
.btn-primary:hover { background: #3a6fc4; border-color: #3a6fc4; }
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* ─── CÉLULAS DE LANÇAMENTO (Renda Ativa) ─── */
.table-renda th, .table-renda td { white-space: nowrap; }
.renda-cel-btn {
  width: 100%;
  min-height: 38px;
  border: 1px dashed #dde2ef;
  background: transparent;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 13px;
  font-weight: 700;
  color: #b9c2d4;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}
.renda-cel-btn:hover { background: var(--accent-light); border-color: var(--accent); color: var(--accent); }
.renda-cel-btn.tem-valor { border-style: solid; border-color: #dde2ef; background: #f7f9ff; color: #1a2744; }
.renda-cel-btn.tem-valor:hover { background: var(--accent-light); border-color: var(--accent); }
.renda-cel-badge {
  font-size: 10px; font-weight: 700; background: var(--accent); color: #fff;
  border-radius: 10px; padding: 1px 6px; line-height: 1.4;
}
body.dark .renda-cel-btn { border-color: #1e2d46; color: #3a4a6a; }
body.dark .renda-cel-btn.tem-valor { background: #0f1a2a; border-color: #1e2d46; color: #d0d8ee; }
body.dark .renda-cel-btn:hover { background: #182a44; border-color: var(--accent); color: #7aaaee; }

/* ─── OFERTA ITEMS ─── */
.oferta-item {
  background: #f7f9ff;
  border: 1px solid #dde2ef;
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.oferta-item:last-child { margin-bottom: 0; }
.oferta-item .btn-remover {
  margin-left: auto;
  background: none; border: none;
  color: #dc3545; cursor: pointer; font-size: 16px; padding: 2px;
}

/* ─── PROGRESS ─── */
.meta-progress { background: #eef0f6; border-radius: 10px; height: 8px; overflow: hidden; }
.meta-progress-bar { height: 100%; border-radius: 10px; background: var(--accent); transition: width 0.4s; }

/* ─── EMPTY STATE ─── */
.empty-state {
  text-align: center; padding: 48px 24px;
  color: #8a99b0;
}
.empty-state i { font-size: 48px; margin-bottom: 12px; display: block; }
.empty-state p { font-size: 15px; }

/* ─── RESPONSIVO ─── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(calc(-1 * var(--sidebar-width))); }
  .sidebar.mobile-open { transform: translateX(0); }
  .main-content { margin-left: 0; }
}

/* ─── TELA DE LOGIN ─── */
.tela-login {
  position: fixed; inset: 0;
  background: linear-gradient(135deg, #1a2744 0%, #2e4080 100%);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999; padding: 16px;
}
.login-card {
  background: #fff; border-radius: 16px;
  padding: 40px 36px;
  width: 100%; max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.login-logo {
  width: 64px; height: 64px;
  background: linear-gradient(135deg, #4a7fd4, #1a2744);
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  font-size: 32px; color: #fff; margin: 0 auto 16px;
}
.login-titulo    { text-align: center; font-weight: 800; color: #1a2744; margin-bottom: 4px; }
.login-subtitulo { text-align: center; color: #8a99b0; font-size: 14px; margin-bottom: 24px; }

/* ─── SIDEBAR FOOTER ─── */
.sidebar-footer { border-top: 1px solid rgba(255,255,255,0.08); padding: 12px 18px; margin-top: auto; }
.sidebar-user   { display: flex; align-items: center; gap: 10px; }
.sidebar-user i { font-size: 28px; color: var(--text-muted-sidebar); flex-shrink: 0; }
.sidebar-user-name  { font-size: 13px; font-weight: 600; color: #e0e8f8; line-height: 1.2; }
.sidebar-user-email { font-size: 11px; color: var(--text-muted-sidebar); }

/* ─── IMPRESSÃO ─── */
@media print {
  .sidebar, .topbar, .btn, .no-print { display: none !important; }
  .main-content { margin-left: 0; }
  .page-content { padding: 0; }
  .card, .table-card { box-shadow: none; border: 1px solid #ddd; }
}

/* ══════════════════════════════════════════════
   MODO ESCURO — body.dark
══════════════════════════════════════════════ */
body.dark {
  background: #0f1623;
  color: #d0d8ee;
}

/* Topbar */
body.dark .topbar {
  background: #141d2e;
  border-bottom-color: #1e2d46;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}
body.dark .topbar-title { color: #d0d8ee; }
body.dark .btn-menu { color: #8a9cc4; }
body.dark .btn-menu:hover { background: #1e2d46; }
body.dark .text-muted { color: #6a7a9a !important; }

/* Sidebar — já é escuro por padrão, apenas afinar */
body.dark .sidebar { background: #0d1520; }
body.dark .sidebar-header { border-bottom-color: rgba(255,255,255,0.05); }
body.dark .nav-item:hover  { background: #1a2537; }
body.dark .nav-item.active { background: #1f2f4d; }

/* Cards */
body.dark .stat-card,
body.dark .table-card,
body.dark .card {
  background: #141d2e;
  box-shadow: 0 1px 8px rgba(0,0,0,0.35);
}
body.dark .card-header {
  background: #141d2e;
  border-bottom-color: #1e2d46;
  color: #d0d8ee;
}
body.dark .table-card-header { border-bottom-color: #1e2d46; }
body.dark .table-card-title  { color: #d0d8ee; }

/* Ícones de stat */
body.dark .stat-icon.blue   { background: #182a44; }
body.dark .stat-icon.green  { background: #152a1e; }
body.dark .stat-icon.red    { background: #2a1515; }
body.dark .stat-icon.orange { background: #2a1f10; }
body.dark .stat-icon.purple { background: #1e1535; }
body.dark .stat-icon.teal   { background: #102828; }
body.dark .stat-value { color: #e0e8f8; }
body.dark .stat-label,
body.dark .stat-sub   { color: #5a6a8a; }

/* Tabelas */
body.dark .table { color: #c5d0e8; }
body.dark .table th { color: #5a6a8a; border-bottom-color: #1e2d46; }
body.dark .table td { border-top-color: #1a2537; }
body.dark .table tbody tr:hover { background: #19263a !important; }
body.dark .table-light,
body.dark .table tfoot tr   { background: #0f1623 !important; color: #a0b0cc !important; }

/* Formulários */
body.dark .form-control,
body.dark .form-select {
  background: #0f1623;
  border-color: #1e2d46;
  color: #d0d8ee;
}
body.dark .form-control:focus,
body.dark .form-select:focus {
  background: #0f1623;
  border-color: var(--accent);
  color: #d0d8ee;
}
body.dark .form-control::placeholder { color: #3a4a6a; }
body.dark .form-label { color: #8090b0; }
body.dark .form-text  { color: #4a5a7a !important; }

/* Cálculo dízimo */
body.dark .calc-dizimo {
  background: #0f1a2a;
  border-color: #1e2d46;
}
body.dark .calc-dizimo .calc-row.total { border-top-color: #1e2d46; }
body.dark .calc-dizimo .calc-label { color: #8090b0; }
body.dark .calc-dizimo .calc-val   { color: #d0d8ee; }

/* Oferta items */
body.dark .oferta-item {
  background: #0f1a2a;
  border-color: #1e2d46;
}

/* Alert info */
body.dark .alert-info {
  background: #0e2035;
  border-color: #1a3860;
  color: #7ab4e8;
}

/* Modal */
body.dark .modal-content {
  background: #141d2e;
  color: #d0d8ee;
  border: 1px solid #1e2d46;
}
body.dark .modal-header {
  border-bottom-color: #1e2d46;
}
body.dark .modal-footer {
  border-top-color: #1e2d46;
}
body.dark .modal-title { color: #d0d8ee; }
body.dark .btn-close { filter: invert(1) brightness(0.7); }

/* bg-light em modais/info boxes */
body.dark .bg-light {
  background: #0f1a2a !important;
  border-color: #1e2d46 !important;
}
body.dark .border-light { border-color: #1e2d46 !important; }

/* Badges */
body.dark .badge-terca    { background: #182a44; color: #7aaaee; }
body.dark .badge-quinta   { background: #152a1e; color: #5ecb7a; }
body.dark .badge-domingo  { background: #2a1f10; color: #e6a04a; }
body.dark .badge-especial { background: #1e1535; color: #a67ee8; }
body.dark .badge-depto    { background: #2a1515; color: #e87070; }
body.dark .badge-manha    { background: #102828; color: #4ac8c8; }
body.dark .badge-pago     { background: #152a1e; color: #5ecb7a; }
body.dark .badge-pendente { background: #2a1f10; color: #e6a04a; }
body.dark .badge-aberto   { background: #2a1515; color: #e87070; }
body.dark .badge-mov-transf { background: #182a44; color: #7aaaee; }
body.dark .badge-mov-dev    { background: #2a1f10; color: #e6a04a; }

/* Progress */
body.dark .meta-progress { background: #1e2d46; }

/* Empty state */
body.dark .empty-state { color: #3a4a6a; }

/* Botões outline no dark */
body.dark .btn-outline-secondary {
  color: #8090b0;
  border-color: #2a3a56;
}
body.dark .btn-outline-secondary:hover {
  background: #1e2d46;
  color: #d0d8ee;
  border-color: #3a4a66;
}

/* Scrollbar (Chrome) */
body.dark ::-webkit-scrollbar { width: 6px; }
body.dark ::-webkit-scrollbar-track { background: #0f1623; }
body.dark ::-webkit-scrollbar-thumb { background: #2a3a56; border-radius: 3px; }
body.dark ::-webkit-scrollbar-thumb:hover { background: #3a4a66; }

/* ─── BOTÃO TOGGLE TEMA ─── */
.btn-tema {
  background: none;
  border: 1px solid #dde2ef;
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  color: #4a5568;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
  white-space: nowrap;
}
.btn-tema:hover { background: #f0f2f8; }
body.dark .btn-tema {
  border-color: #2a3a56;
  color: #8090b0;
}
body.dark .btn-tema:hover { background: #1e2d46; color: #d0d8ee; }
