/* Reset e Variáveis */
:root {
  --sidebar-bg: #000000;
  --sidebar-active: #059669;
  --sidebar-hover: #1a1a1a;
  --main-bg: #f8fafc;
  --card-bg: #ffffff;
  --border: #e2e8f0;
  --text-primary: #0f172a;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --accent: #059669;
  --accent-light: #d1fae5;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --warning: #f59e0b;
  --info: #3b82f6;
  --info-light: #dbeafe;
  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.05), 0 1px 2px -1px rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.07), 0 2px 4px -2px rgb(0 0 0 / 0.05);
  --radius: 8px;
  --radius-sm: 6px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--main-bg);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ===== LAYOUT PRINCIPAL ===== */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ===== SIDEBAR ===== */
.sidebar {
  width: 256px;
  background: var(--sidebar-bg);
  color: white;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-header {
  padding: 24px 20px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.sidebar-logo-link {
  display: block;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  transition: opacity 0.2s;
}

.sidebar-logo-link:hover {
  opacity: 0.8;
}

.sidebar-logo-img {
  display: none;
}

.sidebar-logo-icon {
  width: 220px;
  height: 80px;
  background: var(--accent);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}

.sidebar-logo-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: none;
  padding: 4px;
  filter: brightness(0) invert(1);
}

.sidebar-logo-icon.has-image {
  background: transparent;
  border-radius: 0;
}

.sidebar-logo-icon.has-image img {
  display: block;
}

.sidebar-logo-icon.has-image svg {
  display: none;
}

.sidebar-logo-icon svg {
  width: 20px;
  height: 20px;
  color: white;
}

.sidebar-logo h1 {
  font-size: 16px;
  font-weight: 700;
  color: white;
  line-height: 1.2;
}

.sidebar-logo span {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}

/* Seletor de Igreja */
.sidebar-church {
  padding: 12px 20px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  position: relative;
}

.church-selector {
  cursor: pointer;
  position: relative;
}

.church-selector.open .church-dropdown {
  display: block;
}

.church-dropdown {
  display: none;
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  right: 0;
  background: #1a1a1a;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm);
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.4);
  z-index: 200;
  overflow: hidden;
}

.church-dropdown::after {
  content: '';
  position: absolute;
  bottom: -6px;
  right: 16px;
  width: 12px;
  height: 12px;
  background: #1a1a1a;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  transform: rotate(45deg);
}

.church-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  color: #cbd5e1;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.church-dropdown-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: white;
}

.church-dropdown-item svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.church-dropdown-item.danger {
  color: #ef4444;
}

.church-dropdown-item.danger:hover {
  background: rgba(239, 68, 68, 0.1);
}

.church-dropdown-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.08);
}

.church-selector {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s;
}

.church-selector:hover {
  background: rgba(255, 255, 255, 0.1);
}

.church-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.church-info svg {
  width: 16px;
  height: 16px;
  color: var(--accent);
}

.church-info span {
  font-size: 13px;
  font-weight: 500;
}

.church-selector svg.chevron {
  width: 14px;
  height: 14px;
  color: var(--text-muted);
}

/* Navegação */
.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: #cbd5e1;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s ease;
  margin-bottom: 2px;
}

.nav-item:hover {
  background: var(--sidebar-hover);
  color: white;
}

.nav-item.active {
  background: var(--sidebar-active);
  color: white;
}

.nav-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.nav-item-badge {
  margin-left: auto;
  background: var(--accent);
  color: white;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 10px;
}

.nav-section {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.nav-section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 0 12px;
  margin-bottom: 8px;
  letter-spacing: 0.5px;
}

/* ===== MAIN CONTENT ===== */
.main-content {
  margin-left: 256px;
  flex: 1;
  min-width: 0;
}

.page-header {
  background: white;
  padding: 24px 32px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.page-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.page-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
}

.page-actions {
  display: flex;
  gap: 8px;
}

.page-content {
  padding: 24px 32px;
}

/* ===== BOTÕES ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  background: white;
  color: var(--text-primary);
  border-color: var(--border);
}

.btn:hover {
  background: var(--main-bg);
}

.btn svg {
  width: 16px;
  height: 16px;
}

.btn-primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.btn-primary:hover {
  background: #047857;
  border-color: #047857;
}

.btn-success {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.btn-danger {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
}

.btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
}

.btn-icon svg {
  width: 16px;
  height: 16px;
}

/* ===== STATS CARDS ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: box-shadow 0.2s;
}

.stat-card:hover {
  box-shadow: var(--shadow-md);
}

.stat-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.stat-label {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
}

.stat-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.stat-icon svg {
  width: 16px;
  height: 16px;
  color: white;
}

.stat-icon.green {
  background: #10b981;
}

.stat-icon.blue {
  background: var(--info);
}

.stat-icon.purple {
  background: #8b5cf6;
}

.stat-icon.orange {
  background: #f97316;
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
  line-height: 1.2;
}

.stat-value.green {
  color: var(--accent);
}

.stat-detail {
  font-size: 12px;
  color: var(--text-muted);
}

.stat-detail svg {
  width: 12px;
  height: 12px;
  display: inline-block;
  vertical-align: middle;
  margin-right: 4px;
}

/* ===== FILTROS ===== */
.filters-bar {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.search-input {
  flex: 1;
  min-width: 250px;
  position: relative;
}

.search-input svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-muted);
}

.search-input input {
  width: 100%;
  padding: 9px 12px 9px 38px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  background: var(--main-bg);
  color: var(--text-primary);
  transition: all 0.2s;
}

.search-input input:focus {
  outline: none;
  border-color: var(--accent);
  background: white;
}

.period-tabs {
  display: flex;
  gap: 4px;
  background: var(--main-bg);
  padding: 4px;
  border-radius: var(--radius-sm);
}

.period-tab {
  padding: 6px 14px;
  border: none;
  background: transparent;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}

.period-tab:hover {
  color: var(--text-primary);
}

.period-tab.active {
  background: var(--accent);
  color: white;
}

/* ===== CARDS DE CONTEÚDO ===== */
.content-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.content-card-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.content-card-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.content-card-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
}

.content-card-body {
  padding: 0;
}

/* ===== TABELA ===== */
.table-container {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table thead {
  background: var(--main-bg);
}

.data-table th {
  padding: 12px 24px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-secondary);
  letter-spacing: 0.5px;
}

.data-table td {
  padding: 16px 24px;
  font-size: 14px;
  color: var(--text-primary);
  border-top: 1px solid var(--border);
}

.data-table tbody tr:hover {
  background: var(--main-bg);
}

.data-table .actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

.action-btn {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  background: white;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.action-btn svg {
  width: 14px;
  height: 14px;
}

.action-btn.edit:hover {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent);
}

.action-btn.delete:hover {
  background: var(--danger-light);
  border-color: var(--danger);
  color: var(--danger);
}

.action-btn.edit svg {
  color: var(--accent);
}

.action-btn.delete svg {
  color: var(--danger);
}

/* ===== BADGES ===== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}

.badge-success {
  background: var(--accent-light);
  color: #065f46;
}

.badge-info {
  background: var(--info-light);
  color: #1e40af;
}

.badge-warning {
  background: #fef3c7;
  color: #92400e;
}

.badge-danger {
  background: var(--danger-light);
  color: #991b1b;
}

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-overlay.show {
  display: flex;
}

.modal {
  background: white;
  border-radius: 12px;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 25px 50px -12px rgb(0 0 0 / 0.25);
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.modal-close {
  width: 32px;
  height: 32px;
  border: none;
  background: var(--main-bg);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: all 0.2s;
}

.modal-close:hover {
  background: var(--border);
  color: var(--text-primary);
}

.modal-body {
  padding: 24px;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ===== FORMULÁRIOS ===== */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  background: white;
  color: var(--text-primary);
  transition: all 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.1);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* ===== AUTENTICAÇÃO ===== */
.auth-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  padding: 20px;
}

.auth-card {
  background: white;
  border-radius: 12px;
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 25px 50px -12px rgb(0 0 0 / 0.25);
}

.auth-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
  justify-content: center;
}

.auth-logo-icon {
  width: 48px;
  height: 48px;
  background: var(--accent);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-logo-icon svg {
  width: 24px;
  height: 24px;
  color: white;
}

.auth-logo-img {
  width: 220px;
  height: 80px;
  object-fit: contain;
}

.auth-title {
  font-size: 22px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 4px;
  color: var(--text-primary);
}

.auth-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  text-align: center;
  margin-bottom: 32px;
  margin-top: 8px;
}

.auth-footer {
  text-align: center;
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-secondary);
}

.auth-footer a {
  color: var(--accent);
  font-weight: 500;
  text-decoration: none;
}

.password-wrapper {
  position: relative;
}

.password-toggle {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px;
}

.password-toggle svg {
  width: 16px;
  height: 16px;
}

.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
  display: none;
}

.alert.show {
  display: block;
}

.alert-error {
  background: var(--danger-light);
  color: #991b1b;
  border: 1px solid #fecaca;
}

.alert-success {
  background: var(--accent-light);
  color: #065f46;
  border: 1px solid #a7f3d0;
}

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
}

.empty-state svg {
  width: 48px;
  height: 48px;
  color: var(--text-muted);
  margin-bottom: 12px;
  opacity: 0.5;
}

.empty-state h3 {
  font-size: 16px;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.empty-state p {
  font-size: 13px;
}

/* ===== TOAST ===== */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: white;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  min-width: 280px;
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.toast.success {
  border-color: var(--accent);
  background: var(--accent-light);
  color: #065f46;
}

.toast.error {
  border-color: var(--danger);
  background: var(--danger-light);
  color: #991b1b;
}

/* ===== SPINNER ===== */
.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.9);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.loading-overlay.show {
  display: flex;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* ===== RESPONSIVE ===== */

/* Mobile pequeno (até 480px) */
@media (max-width: 480px) {
  .sidebar { width: 100%; }
  .sidebar-logo-icon { width: 160px; height: 60px; }
  .page-header { padding: 14px 12px; }
  .page-header h1, .page-title { font-size: 18px; }
  .page-subtitle { font-size: 12px; }
  .page-content { padding: 12px; }
  .stats-grid { grid-template-columns: 1fr; gap: 10px; }
  .dashboard-stats-grid { grid-template-columns: 1fr; gap: 10px; }
  .stat-card { padding: 12px; }
  .stat-value { font-size: 18px; }
  .stat-card-header { flex-direction: column; align-items: flex-start; gap: 4px; }
  .stat-icon { width: 32px; height: 32px; }
  .content-card-header { padding: 14px; }
  .content-card-title { font-size: 14px; }
  .content-card-body { padding: 0; }
  .content-card-body[style*="padding"] { padding: 14px !important; }
  .filters-bar { padding: 12px; flex-direction: column; gap: 8px; }
  .search-input { width: 100%; }
  .period-tabs { width: 100%; overflow-x: auto; }
  .data-table { font-size: 12px; }
  .data-table th, .data-table td { padding: 8px 6px; }
  .data-table th { font-size: 11px; }
  .btn { padding: 8px 12px; font-size: 13px; }
  .btn svg { width: 14px; height: 14px; }
  .btn-icon { width: 28px; height: 28px; }
  .modal { width: 95%; max-width: none; margin: 10px; max-height: 90vh; overflow-y: auto; }
  .modal-body { padding: 14px; }
  .modal-header { padding: 14px; }
  .modal-footer { padding: 12px; gap: 8px; flex-direction: column; }
  .modal-footer .btn { width: 100%; }
  .form-group { margin-bottom: 12px; }
  .form-row { grid-template-columns: 1fr; gap: 12px; }
  .form-group input, .form-group select, .form-group textarea { padding: 9px 10px; font-size: 14px; }
  textarea { min-height: 80px; }
  .page-actions { width: 100%; flex-direction: column; align-items: stretch; gap: 8px; }
  .page-actions .btn { width: 100%; justify-content: center; }
  .page-actions .dashboard-periodo-select { width: 100%; }
  .dashboard-grid-2, .dashboard-grid-3 { grid-template-columns: 1fr; gap: 14px; }
  #chart-fluxo, #chart-donut { width: 100%; height: auto; }
  .donut-legend { font-size: 12px; }
  .chart-legend-inline { flex-wrap: wrap; gap: 8px; font-size: 12px; }
  .toast { padding: 10px 14px; font-size: 13px; max-width: 90%; }
  .nav-item { padding: 10px 12px; font-size: 14px; }
  .nav-item svg { width: 18px; height: 18px; }
  .sidebar-church { padding: 10px 14px; }
  .church-info span { font-size: 13px; }
  .sidebar-header { padding: 16px 14px 14px; }
  .sidebar-nav { padding: 12px 8px; }
  .table-container { overflow-x: auto; }
  .data-table { min-width: 480px; }
  .empty-state { padding: 30px 16px; }
  .empty-state p { font-size: 13px; }
  .badge { padding: 3px 8px; font-size: 10px; }
}

/* Mobile médio / Tablet pequeno (481px - 768px) */
@media (min-width: 481px) and (max-width: 768px) {
  .sidebar { width: 280px; }
  .page-content { padding: 16px; }
  .page-header { padding: 18px 16px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-stats-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid-2 { grid-template-columns: 1fr; }
  .dashboard-grid-3 { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .modal { width: 92%; margin: 16px auto; }
  .page-title { font-size: 20px; }
  .stat-value { font-size: 20px; }
  .filters-bar { flex-direction: column; align-items: stretch; }
  .search-input { width: 100%; }
}

/* Tablet (769px - 1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
  .sidebar { width: 220px; }
  .main-content { margin-left: 220px; }
  .page-content { padding: 20px 24px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-stats-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid-2 { grid-template-columns: 1fr; }
  .dashboard-grid-3 { grid-template-columns: 1fr; }
  .page-title { font-size: 22px; }
  .nav-item { font-size: 13px; padding: 9px 10px; }
  .nav-item svg { width: 16px; height: 16px; }
  .modal { width: 80%; }
}

/* Mobile geral (até 768px) - sidebar mobile + ajustes gerais */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    z-index: 200;
    box-shadow: 2px 0 12px rgba(0,0,0,0.3);
  }

  .sidebar.show {
    transform: translateX(0);
  }

  .main-content {
    margin-left: 0;
    width: 100%;
  }

  .page-header {
    padding: 16px;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .page-content {
    padding: 16px;
  }

  .stats-grid {
    gap: 12px;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .filters-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .search-input {
    width: 100%;
  }

  .period-tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
  }

  .content-card-body {
    padding: 0;
  }

  .modal-overlay {
    align-items: flex-start;
    padding-top: 16px;
  }

  /* Backdrop ao abrir sidebar mobile */
  body.sidebar-open::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 150;
  }
}

/* Desktop médio (1025px - 1280px) */
@media (min-width: 1025px) and (max-width: 1280px) {
  .sidebar { width: 240px; }
  .main-content { margin-left: 240px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-stats-grid { grid-template-columns: repeat(4, 1fr); }
  .dashboard-grid-3 { grid-template-columns: 1fr 1fr; }
}

/* Telas muito grandes (acima de 1600px) */
@media (min-width: 1600px) {
  .sidebar { width: 280px; }
  .main-content { margin-left: 280px; }
  .page-content { padding: 32px 40px; max-width: 1600px; }
  .page-title { font-size: 28px; }
  .page-subtitle { font-size: 15px; }
  .stat-value { font-size: 26px; }
}

/* Landscape em mobile */
@media (max-height: 500px) and (orientation: landscape) {
  .sidebar { overflow-y: auto; }
  .page-header { padding: 10px 16px; }
  .page-content { padding: 12px 16px; }
  .modal { max-height: 85vh; }
  .modal-body { padding: 12px; max-height: 60vh; overflow-y: auto; }
}

/* Impressão */
@media print {
  .sidebar, .page-actions, .btn, .filters-bar, .church-selector { display: none !important; }
  .main-content { margin-left: 0 !important; }
  .content-card { break-inside: avoid; }
  body { background: white; }
}

/* ===== SIDEBAR FOOTER (PERFIL + SAIR) ===== */
.sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  gap: 8px;
  margin-top: auto;
}

.sidebar-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm);
  color: #cbd5e1;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
}

.sidebar-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: white;
}

.sidebar-btn.profile:hover {
  background: var(--accent);
  border-color: var(--accent);
}

.sidebar-btn.logout:hover {
  background: var(--danger);
  border-color: var(--danger);
}

.sidebar-btn svg {
  width: 16px;
  height: 16px;
}

/* ===== MODAL PERFIL ===== */
.profile-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin: -24px -24px 24px;
}

.profile-tab {
  flex: 1;
  padding: 14px 16px;
  background: none;
  border: none;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}

.profile-tab:hover {
  color: var(--text-primary);
}

.profile-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.profile-content {
  display: none;
}

.profile-content.active {
  display: block;
}

.profile-info {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  background: var(--main-bg);
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
}

.profile-avatar {
  width: 60px;
  height: 60px;
  background: var(--accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 22px;
  font-weight: 600;
}

.profile-details h4 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 2px;
}

/* ===== DASHBOARD NOVO ===== */
.dashboard-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.stat-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.stat-label {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
}

.stat-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stat-icon svg {
  width: 18px;
  height: 18px;
}

.stat-icon.green { background: #d1fae5; color: #059669; }
.stat-icon.blue { background: #dbeafe; color: #3b82f6; }
.stat-icon.orange { background: #fef3c7; color: #f59e0b; }
.stat-icon.purple { background: #ede9fe; color: #7c3aed; }

.stat-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.stat-value.green { color: var(--accent); }

.stat-detail {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.sparkline {
  width: 100%;
  height: 30px;
  margin-top: 8px;
}

/* Linha 2: Fluxo + Resumo */
.dashboard-grid-2 {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

.dashboard-grid-2 .content-card {
  display: flex;
  flex-direction: column;
}

.dashboard-grid-2 .content-card-body {
  flex: 1;
}

/* Linha 3: 3 colunas */
.dashboard-grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 20px;
}

.dashboard-grid-3 .content-card {
  display: flex;
  flex-direction: column;
}

.dashboard-grid-3 .content-card-body {
  flex: 1;
}

/* Chart legend inline */
.chart-legend-inline {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--text-secondary);
}

.chart-legend-inline .dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
}

/* Resumo do período */
#resumo-periodo {
  padding: 16px 20px;
}

.resumo-linha {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.resumo-linha:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.resumo-linha span {
  color: var(--text-secondary);
}

.resumo-linha strong {
  font-weight: 600;
  color: var(--text-primary);
}

/* Donut chart */
#chart-donut {
  padding: 16px 20px 0;
}

.donut-legend {
  list-style: none;
  margin-top: 16px;
  width: 100%;
  padding: 0 20px 16px;
}

.donut-leg-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  font-size: 12px;
}

.donut-leg-cor {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
}

.donut-leg-label {
  flex: 1;
  color: var(--text-secondary);
}

.donut-leg-pct {
  font-weight: 600;
  color: var(--text-primary);
  min-width: 36px;
  text-align: right;
}

.donut-leg-valor {
  color: var(--text-primary);
  font-weight: 500;
  min-width: 70px;
  text-align: right;
}

/* Últimos lançamentos */
#ultimos-lancamentos {
  padding: 16px 20px;
}

.lancamento-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.lancamento-item:last-child {
  border-bottom: none;
}

.lancamento-icone {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.lancamento-icone.dizimo { background: #d1fae5; color: #059669; }
.lancamento-icone.oferta { background: #dbeafe; color: #3b82f6; }
.lancamento-icone.despesa { background: #fee2e2; color: #ef4444; }

.lancamento-icone svg {
  width: 16px;
  height: 16px;
}

.lancamento-info {
  flex: 1;
  min-width: 0;
}

.lancamento-info strong {
  display: block;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lancamento-data {
  font-size: 11px;
  color: var(--text-muted);
}

.lancamento-valor {
  font-size: 13px;
  font-weight: 600;
}

.lancamento-valor.dizimo,
.lancamento-valor.oferta { color: var(--accent); }

.lancamento-valor.despesa { color: var(--danger); }

.lancamento-badge {
  font-size: 10px;
  padding: 2px 6px;
}

/* Próximos eventos */
#proximos-eventos {
  padding: 16px 20px;
}

.evento-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.evento-item:last-child {
  border-bottom: none;
}

.evento-data {
  width: 48px;
  text-align: center;
  flex-shrink: 0;
}

.evento-dia {
  display: block;
  font-size: 22px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
}

.evento-mes {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
}

.evento-ano {
  display: block;
  font-size: 10px;
  color: var(--text-muted);
}

.evento-info {
  flex: 1;
  min-width: 0;
}

.evento-info strong {
  display: block;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.evento-local {
  font-size: 11px;
  color: var(--text-muted);
}

/* Badge realizado */
.badge-realizado {
  background: #bbf7d0;
  color: #15803d;
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 500;
}

/* Período select */
.dashboard-periodo-select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  background: white;
  color: var(--text-primary);
  cursor: pointer;
}

.dashboard-periodo-select:focus {
  outline: none;
  border-color: var(--accent);
}

/* Ver todos link */
.ver-todos {
  font-size: 12px;
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

.ver-todos:hover {
  text-decoration: underline;
}

/* Responsive */
@media (max-width: 1200px) {
  .dashboard-stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .dashboard-grid-2 {
    grid-template-columns: 1fr;
  }

  .dashboard-grid-3 {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 768px) {
  .dashboard-stats-grid {
    grid-template-columns: 1fr;
  }

  .dashboard-grid-3 {
    grid-template-columns: 1fr;
  }
}

/* ===== BOTÃO HAMBURGER MOBILE ===== */
.menu-toggle {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 300;
  width: 40px;
  height: 40px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  transition: all 0.2s ease;
}

.menu-toggle:hover {
  background: #047857;
  transform: scale(1.05);
}

.menu-toggle:active {
  transform: scale(0.95);
}

.menu-toggle svg {
  width: 22px;
  height: 22px;
}

@media (max-width: 768px) {
  .menu-toggle {
    display: flex;
  }
}

/* Ajuste para não sobrepor o botão nos headers */
@media (max-width: 768px) {
  .page-header {
    padding-left: 64px !important;
    min-height: 56px;
  }
}